tower_user: Fix to create a system auditor properly (#54585)

- Fixed issue #54446: tower_user cannot create an auditor user

Signed-off-by: Hideki Saito <saito@fgrep.org>
pull/57036/head
Hideki Saito 6 years ago committed by René Moser
parent 7eae4761b8
commit d86183f595

@ -0,0 +1,2 @@
bugfixes:
- tower_user - Fix to create user as a system auditor when specifying the `auditor` option (https://github.com/ansible/ansible/issues/54446)

@ -55,6 +55,10 @@ options:
- Desired state of the resource.
default: "present"
choices: ["present", "absent"]
requirements:
- ansible-tower-cli >= 3.2.0
extends_documentation_fragment: tower
'''
@ -69,6 +73,31 @@ EXAMPLES = '''
last_name: Doe
state: present
tower_config_file: "~/tower_cli.cfg"
- name: Add tower user as a system administrator
tower_user:
username: jdoe
password: foobarbaz
email: jdoe@example.org
superuser: yes
state: present
tower_config_file: "~/tower_cli.cfg"
- name: Add tower user as a system auditor
tower_user:
username: jdoe
password: foobarbaz
email: jdoe@example.org
auditor: yes
state: present
tower_config_file: "~/tower_cli.cfg"
- name: Delete tower user
tower_user:
username: jdoe
email: jdoe@example.org
state: absent
tower_config_file: "~/tower_cli.cfg"
'''
from ansible.module_utils.ansible_tower import TowerModule, tower_auth_config, tower_check_mode
@ -115,7 +144,7 @@ def main():
if state == 'present':
result = user.modify(username=username, first_name=first_name, last_name=last_name,
email=email, password=password, is_superuser=superuser,
is_auditor=auditor, create_on_missing=True)
is_system_auditor=auditor, create_on_missing=True)
json_output['id'] = result['id']
elif state == 'absent':
result = user.delete(username=username)

Loading…
Cancel
Save