Merge pull request #1035 from t-woerner/new_module_github_user_fix

Fixes and enhancements for utils/new_module and templates
This commit is contained in:
Rafael Guterres Jeffman
2023-04-20 10:03:19 -03:00
committed by GitHub
7 changed files with 34 additions and 52 deletions

View File

@@ -63,7 +63,7 @@ for (( i=0; i<OPTIND-1; i++)); do
shift
done
if [ ${#@} -ne 3 ]; then
if [ ${#@} -ne 4 ]; then
usage;
exit 1
fi
@@ -78,7 +78,7 @@ if [ -z "$name" ] || [ -z "$author" ] || [ -z "$email" ] || [ -z "$github_user"
[ -z "$name" ] && echo "ERROR: name is not valid"
[ -z "$author" ] && echo "ERROR: author is not valid"
[ -z "$email" ] && echo "ERROR: email is not valid"
[ -z "$githubuser" ] && echo "ERROR: github_user is not valid"
[ -z "$github_user" ] && echo "ERROR: github_user is not valid"
echo
usage;
exit 1;

View File

@@ -45,7 +45,7 @@ Example playbook to make sure $name "NAME" is present:
---
- name: Playbook to manage IPA $name.
hosts: ipaserver
become: no
become: false
tasks:
- ipa$name:
@@ -60,7 +60,7 @@ Example playbook to make sure $name "NAME" member PARAMETER2 VALUE is present:
---
- name: Playbook to manage IPA $name PARAMETER2 member.
hosts: ipaserver
become: no
become: false
tasks:
- ipa$name:
@@ -78,7 +78,7 @@ Example playbook to make sure $name "NAME" member PARAMETER2 VALUE is absent:
---
- name: Playbook to manage IPA $name PARAMETER2 member.
hosts: ipaserver
become: no
become: false
tasks:
- ipa$name:
@@ -96,7 +96,7 @@ Example playbook to make sure $name "NAME" is absent:
---
- name: Playbook to manage IPA $name.
hosts: ipaserver
become: no
become: false
tasks:
- ipa$name:
@@ -117,7 +117,7 @@ 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
`ipaapi_ldap_cache` | Use LDAP cache for IPA connection. The bool setting defaults to true. (bool) | no
`name` \| `ALIAS` | The list of $name name strings. | yes
`PARAMETER1` \| `API_PARAMETER_NAME` | DESCRIPTION | TYPE
`PARAMETER2` \| `API_PARAMETER_NAME` | DESCRIPTION | TYPE

View File

@@ -45,7 +45,7 @@ Example playbook to make sure $name "NAME" is present:
---
- name: Playbook to manage IPA $name.
hosts: ipaserver
become: no
become: false
tasks:
- ipa$name:
@@ -61,7 +61,7 @@ Example playbook to make sure $name "NAME" is absent:
---
- name: Playbook to manage IPA $name.
hosts: ipaserver
become: no
become: false
tasks:
- ipa$name:
@@ -82,7 +82,7 @@ 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
`ipaapi_ldap_cache` | Use LDAP cache for IPA connection. The bool setting defaults to true. (bool) | no
`name` \| `ALIAS` | The list of $name name strings. | yes
`PARAMETER1` \| `API_PARAMETER_NAME` | DESCRIPTION | TYPE
`PARAMETER2` \| `API_PARAMETER_NAME` | DESCRIPTION | TYPE

View File

@@ -121,7 +121,7 @@ def main():
argument_spec=dict(
# general
name=dict(type="list", elements="str", required=True,
aliases=["API_PARAMETER_NAME"],
aliases=["API_PARAMETER_NAME"]),
# present
PARAMETER1=dict(required=False, type='str',
aliases=["API_PARAMETER_NAME"], default=None),

View File

@@ -1,10 +1,15 @@
---
- name: Test $name
hosts: "{{ ipa_test_host | default('ipaserver') }}"
# Change "become" or "gather_facts" to "yes",
# if you test playbook requires any.
become: no
gather_facts: no
# It is normally not needed to set "become" to "true" for a module test.
# Only set it to true if it is needed to execute commands as root.
become: false
# Enable "gather_facts" only if "ansible_facts" variable needs to be used.
gather_facts: false
module_defaults:
ipa$name:
ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
tasks:
@@ -12,7 +17,6 @@
- name: Ensure $name NAME is absent
ipa$name:
ipaadmin_password: SomeADMINpassword
name: NAME
state: absent
@@ -22,8 +26,6 @@
- name: Ensure $name NAME is present
ipa$name:
ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: NAME
# Add needed parameters here
register: result
@@ -31,8 +33,6 @@
- name: Ensure $name NAME is present again
ipa$name:
ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: NAME
# Add needed parameters here
register: result
@@ -40,8 +40,6 @@
- name: Ensure $name NAME member PARAMETER2 VALUE is present
ipa$name:
ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: NAME
PARAMETER2: VALUE
action: member
@@ -50,8 +48,6 @@
- name: Ensure $name NAME member PARAMETER2 VALUE is present again
ipa$name:
ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: NAME
PARAMETER2: VALUE
action: member
@@ -60,8 +56,6 @@
- name: Ensure $name NAME member PARAMETER2 VALUE is absent
ipa$name:
ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: NAME
PARAMETER2: VALUE
action: member
@@ -71,8 +65,6 @@
- name: Ensure $name NAME member PARAMETER2 VALUE is absent again
ipa$name:
ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: NAME
PARAMETER2: VALUE
action: member
@@ -84,8 +76,6 @@
- name: Ensure $name NAME is absent
ipa$name:
ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: NAME
state: absent
register: result
@@ -93,8 +83,6 @@
- name: Ensure $name NAME is absent again
ipa$name:
ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: NAME
state: absent
register: result
@@ -104,7 +92,5 @@
- name: Ensure $name NAME is absent
ipa$name:
ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: NAME
state: absent

View File

@@ -1,10 +1,15 @@
---
- name: Test $name
hosts: "{{ ipa_test_host | default('ipaserver') }}"
# Change "become" or "gather_facts" to "yes",
# if you test playbook requires any.
become: no
gather_facts: no
# It is normally not needed to set "become" to "true" for a module test.
# Only set it to true if it is needed to execute commands as root.
become: false
# Enable "gather_facts" only if "ansible_facts" variable needs to be used.
gather_facts: false
module_defaults:
ipa$name:
ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
tasks:
@@ -12,8 +17,6 @@
- name: Ensure $name NAME is absent
ipa$name:
ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: NAME
state: absent
@@ -23,7 +26,6 @@
- name: Ensure $name NAME is present
ipa$name:
ipaadmin_password: SomeADMINpassword
name: NAME
# Add needed parameters here
register: result
@@ -31,8 +33,6 @@
- name: Ensure $name NAME is present again
ipa$name:
ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: NAME
# Add needed parameters here
register: result
@@ -42,8 +42,6 @@
- name: Ensure $name NAME is absent
ipa$name:
ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: NAME
state: absent
register: result
@@ -51,8 +49,6 @@
- name: Ensure $name NAME is absent again
ipa$name:
ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: NAME
state: absent
register: result
@@ -62,6 +58,5 @@
- name: Ensure $name NAME is absent
ipa$name:
ipaadmin_password: SomeADMINpassword
name: NAME
state: absent

View File

@@ -1,10 +1,11 @@
---
- name: Test ${name}
hosts: ipaclients, ipaserver
# Change "become" or "gather_facts" to "yes",
# if you test playbook requires any.
become: no
gather_facts: no
# It is normally not needed to set "become" to "true" for a module test.
# Only set it to true if it is needed to execute commands as root.
become: false
# Enable "gather_facts" only if "ansible_facts" variable needs to be used.
gather_facts: false
tasks:
- name: Include FreeIPA facts.