-
Notifications
You must be signed in to change notification settings - Fork 0
/
user
45 lines (41 loc) · 1.24 KB
/
user
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
---
- name: users | managing user accounts
user:
name: "{{ item.user }}"
password: "{{ item.pass|password_hash('sha512') }}"
shell: "{{ item.shell|default (omit) }}"
comment: "{{ item.comment|default (omit) }}"
generate_ssh_key: "{{ item.generate_keys|default (omit) }}"
system: "{{ item.system_account|default (omit) }}"
state: "{{ item.state }}"
with_items: '{{ create_users }}'
- name: users | adding users to sudoers
lineinfile:
dest: "/etc/sudoers"
regexp: '^{{ item.user }} ALL'
line: '{{ item.user }} ALL=(ALL) NOPASSWD:ALL'
validate: 'visudo -cf %s'
state: present
with_items: '{{ create_users }}'
when: >
item.state == "present" and
item.sudo
- name: users | removing users from sudoers
lineinfile:
dest: "/etc/sudoers"
regexp: '^{{ item.user }} ALL'
line: '{{ item.user }} ALL=(ALL) NOPASSWD:ALL'
validate: 'visudo -cf %s'
state: absent
with_items: '{{ create_users }}'
when: >
(item.state == "present" and
not item.sudo) or
item.state == "absent"
- name: users | add user in allow
lineinfile:
dest: "/etc/sshd/sshd.allow"
line: '{{ item.user }}'
state: present
backup: yes
with_items: '{{ create_users }}'