-
Notifications
You must be signed in to change notification settings - Fork 7
/
manageiq_add_user.yml
52 lines (49 loc) · 1.64 KB
/
manageiq_add_user.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
---
- name: Get auth token from manageiq and create new user
hosts: all
gather_facts: no
vars:
manageiq_user: admin
manageiq_pass: smartvm
manageiq_auth_url: "https://{{ manageiq_host | default('localhost') }}/api/auth"
manageiq_url: "https://{{ manageiq_host | default('localhost') }}"
tasks:
# - name: Check
# fail:
# msg: "manageiq_host variable is not set. Set this var to the IP or hostname of ManageIQ appliance."
# when: manageiq_host is not defined
- name: Install manageiq api client module when playbook is executed on Ansible Tower/Embedded
delegate_to: "{{ manageiq_host | default('localhost') }}"
pip:
virtualenv: /var/lib/awx/venv/ansible/
name: git+https://github.com/ManageIQ/manageiq-api-client-python.git
when: manageiq.api_token is defined
- name: Get token from ManageIQ
uri:
url: "{{ manageiq_auth_url }}"
method: GET
body:
user: "{{ manageiq_user }}"
password: "{{ manageiq_pass }}"
body_format: json
validate_certs: False
headers:
Content-Type: "application/json"
status_code: 200
register: manageiq_token
- name: check how the token looks like
debug:
msg: var="{{ manageiq_token.json.auth_token }}"
- name: Create a new user in ManageIQ using a token
manageiq_user:
userid: 'jdoe'
name: 'Jane Doe'
password: 'VerySecret'
group: 'EvmGroup-user'
email: '[email protected]'
manageiq_connection:
url: "{{ manageiq_url }}"
token: "{{ manageiq_token.json.auth_token }}"
verify_ssl: False
# username: admin
# password: smartvm