Refactor and extend argument spec helper, use for ACME modules (#749)

* Refactor argument spec helper.

* Remove superfluous comments.
This commit is contained in:
Felix Fontein
2024-05-05 11:42:42 +02:00
committed by GitHub
parent f82b335916
commit f3c9cb7a8a
16 changed files with 166 additions and 121 deletions

View File

@@ -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)