mirror of
https://github.com/ansible-collections/community.crypto.git
synced 2026-05-08 14:22:56 +00:00
Refactor and extend argument spec helper, use for ACME modules (#749)
* Refactor argument spec helper. * Remove superfluous comments.
This commit is contained in:
@@ -21,6 +21,8 @@ from ansible.module_utils.common.text.converters import to_bytes
|
||||
from ansible.module_utils.urls import fetch_url
|
||||
from ansible.module_utils.six import PY3
|
||||
|
||||
from ansible_collections.community.crypto.plugins.module_utils.argspec import ArgumentSpec
|
||||
|
||||
from ansible_collections.community.crypto.plugins.module_utils.acme.backend_openssl_cli import (
|
||||
OpenSSLCLIBackend,
|
||||
)
|
||||
@@ -439,6 +441,28 @@ def get_default_argspec(with_account=True):
|
||||
return argspec
|
||||
|
||||
|
||||
def create_default_argspec(with_account=True, require_account_key=True):
|
||||
'''
|
||||
Provides default argument spec for the options documented in the acme doc fragment.
|
||||
'''
|
||||
result = ArgumentSpec(
|
||||
get_default_argspec(with_account=with_account),
|
||||
)
|
||||
if with_account:
|
||||
if require_account_key:
|
||||
result.update(
|
||||
required_one_of=[
|
||||
['account_key_src', 'account_key_content'],
|
||||
],
|
||||
)
|
||||
result.update(
|
||||
mutually_exclusive=[
|
||||
['account_key_src', 'account_key_content'],
|
||||
],
|
||||
)
|
||||
return result
|
||||
|
||||
|
||||
def create_backend(module, needs_acme_v2):
|
||||
if not HAS_IPADDRESS:
|
||||
module.fail_json(msg=missing_required_lib('ipaddress'), exception=IPADDRESS_IMPORT_ERROR)
|
||||
|
||||
Reference in New Issue
Block a user