mirror of
https://github.com/freeipa/ansible-freeipa.git
synced 2026-05-07 05:43:26 +00:00
New ipamodule_base_vars
There are common parameters in all modules like ipaadmin_principal and ipaadmin_password. As this list of common parameters will be extended soon, there is a need to reduce the code and documentation duplicates. A ModuleDocFragment is added to provide the module documentation for the common parameters. This is used in the modules with extends_documentation_fragment. ansible_freeipa_module has additional ipamodule_base_spec and get_ipamodule_base_vars. ipamodule_base_spec extends argument_spec in the module and get_ipamodule_base_vars is used to return a dict containing the common parameters.
This commit is contained in:
@@ -109,6 +109,22 @@ else:
|
||||
if six.PY3:
|
||||
unicode = str
|
||||
|
||||
# AnsibleModule argument specs for all modules
|
||||
ipamodule_base_spec = dict(
|
||||
ipaadmin_principal=dict(type="str", default="admin"),
|
||||
ipaadmin_password=dict(type="str", required=False, no_log=True),
|
||||
)
|
||||
|
||||
# Get ipamodule common vars as nonlocal
|
||||
def get_ipamodule_base_vars(module):
|
||||
ipaadmin_principal = module_params_get(module, "ipaadmin_principal")
|
||||
ipaadmin_password = module_params_get(module, "ipaadmin_password")
|
||||
|
||||
return dict(
|
||||
ipaadmin_principal=ipaadmin_principal,
|
||||
ipaadmin_password=ipaadmin_password,
|
||||
)
|
||||
|
||||
def valid_creds(module, principal): # noqa
|
||||
"""Get valid credentials matching the princial, try GSSAPI first."""
|
||||
if "KRB5CCNAME" in os.environ:
|
||||
|
||||
Reference in New Issue
Block a user