|
|
|
@ -55,6 +55,10 @@ options:
|
|
|
|
- Desired state of the resource.
|
|
|
|
- Desired state of the resource.
|
|
|
|
default: "present"
|
|
|
|
default: "present"
|
|
|
|
choices: ["present", "absent"]
|
|
|
|
choices: ["present", "absent"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
requirements:
|
|
|
|
|
|
|
|
- ansible-tower-cli >= 3.2.0
|
|
|
|
|
|
|
|
|
|
|
|
extends_documentation_fragment: tower
|
|
|
|
extends_documentation_fragment: tower
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
|
|
@ -69,6 +73,31 @@ EXAMPLES = '''
|
|
|
|
last_name: Doe
|
|
|
|
last_name: Doe
|
|
|
|
state: present
|
|
|
|
state: present
|
|
|
|
tower_config_file: "~/tower_cli.cfg"
|
|
|
|
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
|
|
|
|
from ansible.module_utils.ansible_tower import TowerModule, tower_auth_config, tower_check_mode
|
|
|
|
@ -115,7 +144,7 @@ def main():
|
|
|
|
if state == 'present':
|
|
|
|
if state == 'present':
|
|
|
|
result = user.modify(username=username, first_name=first_name, last_name=last_name,
|
|
|
|
result = user.modify(username=username, first_name=first_name, last_name=last_name,
|
|
|
|
email=email, password=password, is_superuser=superuser,
|
|
|
|
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']
|
|
|
|
json_output['id'] = result['id']
|
|
|
|
elif state == 'absent':
|
|
|
|
elif state == 'absent':
|
|
|
|
result = user.delete(username=username)
|
|
|
|
result = user.delete(username=username)
|
|
|
|
|