From d86183f595e45ee03bfc77329890561f2bc89e94 Mon Sep 17 00:00:00 2001 From: Hideki Saito Date: Mon, 10 Jun 2019 16:48:02 +0900 Subject: [PATCH] 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 --- .../fragments/tower_user-system-auditor.yaml | 2 ++ .../ansible_tower/tower_user.py | 31 ++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/tower_user-system-auditor.yaml diff --git a/changelogs/fragments/tower_user-system-auditor.yaml b/changelogs/fragments/tower_user-system-auditor.yaml new file mode 100644 index 0000000000..262319d4b9 --- /dev/null +++ b/changelogs/fragments/tower_user-system-auditor.yaml @@ -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) diff --git a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_user.py b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_user.py index a16a44d823..13acab8279 100644 --- a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_user.py +++ b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_user.py @@ -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)