-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_users.yml
42 lines (42 loc) · 988 Bytes
/
create_users.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
---
- name: Create Users with given yml file nested_items
hosts: all
become: yes
gather_facts: no
vars:
group:
- dev
- prod
vars_files:
- user_list.yml
tasks:
- yum:
name: expect
state: latest
ignore_errors: yes
- group:
name: "{{ item }}"
state: present
loop: "{{ group }}"
- user:
name: "{{ item.0.name }}"
password: "{{ item.0.pw |password_hash('SHA512') }}"
group: dev
groups: "{{ items.1 }}"
when:
- "item.0.job == 'dev'"
- "inventory_hostname in groups['webservers']"
with_nested:
- "{{ users }}"
- "{{ groups }}"
- user:
name: "{{ item.0.name }}"
password: "{{ item.0.pw |password_hash('SHA512') }}"
group: prod
groups: "{{ items.1 }}"
when:
- "item.0.job == 'prod'"
- "inventory_hostname in groups['dbservers']"
with_nested:
- "{{ users }}"
- "{{ groups }}"