From aa8648425bbf562f0b8d7e26a46f51c9ffb43b92 Mon Sep 17 00:00:00 2001 From: Rafael Guterres Jeffman Date: Mon, 4 Oct 2021 14:06:43 -0300 Subject: [PATCH 1/2] templates: Use IPAAnsibleModule params_fail_used_invalid. Modify new module templates to use IPAAnsibleModule method `params_fail_used_invalid` to check for invalid parameter use for a given state/action. --- utils/templates/ipamodule+member.py.in | 6 +----- utils/templates/ipamodule.py.in | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/utils/templates/ipamodule+member.py.in b/utils/templates/ipamodule+member.py.in index 7e7ad8ea..d3438b1b 100644 --- a/utils/templates/ipamodule+member.py.in +++ b/utils/templates/ipamodule+member.py.in @@ -185,11 +185,7 @@ def main(): if action == "$name": invalid.append("PARAMETER2") - for x in invalid: - if vars()[x] is not None: - ansible_module.fail_json( - msg="Argument '%s' can not be used with action " - "'%s' and state '%s'" % (x, action, state)) + ansible_module.params_fail_used_invalid(invalid, state, action) # Init diff --git a/utils/templates/ipamodule.py.in b/utils/templates/ipamodule.py.in index b179a0b8..e305c976 100644 --- a/utils/templates/ipamodule.py.in +++ b/utils/templates/ipamodule.py.in @@ -151,11 +151,7 @@ def main(): ansible_module.fail_json(msg="No name given.") invalid = ["PARAMETER1", "PARAMETER2"] - for x in invalid: - if vars()[x] is not None: - ansible_module.fail_json( - msg="Argument '%s' can not be used with state '%s'" % - (x, state)) + ansible_module.params_fail_used_invalid(invalid, state) # Init From 2a169ceb469ca90540a8547e58fb1ded9a3024de Mon Sep 17 00:00:00 2001 From: Rafael Guterres Jeffman Date: Mon, 4 Oct 2021 14:11:04 -0300 Subject: [PATCH 2/2] templates: Add IPA API connection variables to README. All modules should use the same description for IPA API connection variables. This change add description for ipaapi_context and ipaapi_ldap_cache variable to the module README templates. --- utils/templates/README-module+member.md.in | 2 ++ utils/templates/README-module.md.in | 2 ++ 2 files changed, 4 insertions(+) diff --git a/utils/templates/README-module+member.md.in b/utils/templates/README-module+member.md.in index 026496b3..074ea4ec 100644 --- a/utils/templates/README-module+member.md.in +++ b/utils/templates/README-module+member.md.in @@ -119,6 +119,8 @@ Variable | Description | Required -------- | ----------- | -------- `ipaadmin_principal` | The admin principal is a string and defaults to `admin` | no `ipaadmin_password` | The admin password is a string and is required if there is no admin ticket available on the node | no +`ipaapi_context` | The context in which the module will execute. Executing in a server context is preferred. If not provided context will be determined by the execution environment. Valid values are `server` and `client`. | no +`ipaapi_ldap_cache` | Use LDAP cache for IPA connection. The bool setting defaults to yes. (bool) | no `name` \| `ALIAS` | The list of $name name strings. | yes `PARAMETER1` \| `API_PARAMETER_NAME` | DESCRIPTION | BOOL `PARAMETER2` \| `API_PARAMETER_NAME` | DESCRIPTION | BOOL diff --git a/utils/templates/README-module.md.in b/utils/templates/README-module.md.in index e5054fb2..25c69e4d 100644 --- a/utils/templates/README-module.md.in +++ b/utils/templates/README-module.md.in @@ -84,6 +84,8 @@ Variable | Description | Required -------- | ----------- | -------- `ipaadmin_principal` | The admin principal is a string and defaults to `admin` | no `ipaadmin_password` | The admin password is a string and is required if there is no admin ticket available on the node | no +`ipaapi_context` | The context in which the module will execute. Executing in a server context is preferred. If not provided context will be determined by the execution environment. Valid values are `server` and `client`. | no +`ipaapi_ldap_cache` | Use LDAP cache for IPA connection. The bool setting defaults to yes. (bool) | no `name` \| `ALIAS` | The list of $name name strings. | yes `PARAMETER1` \| `API_PARAMETER_NAME` | DESCRIPTION | BOOL `PARAMETER2` \| `API_PARAMETER_NAME` | DESCRIPTION | BOOL