-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd_admins.yml
47 lines (39 loc) · 1.11 KB
/
add_admins.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
---
- hosts: testing
sudo: yes
gather_facts: yes
vars:
main_grp: linuxadm
sudo_rule: "ALL=(ALL) NOPASSWD: ALL"
# Path to get usernames and passwords
vars_files:
- vars/vars.yml
tasks:
# Add linux groups to server
- include_tasks: tasks/create_group.yml
group: '{{ main_grp }}'
# Add to sudo group
# - include: tasks/add_sudo_rules.yml group="{{main_grp}}" rule="{{sudo_rule}}"
- include_tasks: tasks/add_sudo_rules.yml
group: '{{ main_grp }}'
rule: '{{ sudo_rule }}'
# Add linux admins
- name: add linux admins
user:
name: '{{ item.user }}'
password: '{{ item.password }}'
shell: '{{ default_shell }}'
groups: '{{ item.groups }}'
comment: '{{ item.comment }}'
with_items: linuxusers
register: task
# На всех серверах, что записаны в файле host
# ???
- include_tasks: tasks/collect_changed_hosts.yml
# Cleaning sudoers file
- name: cleaning sudoers file
lineinfile:
dest: '{{ sudoers_file }}'
state: absent
regexp: '^{{ item.user }}'
with_items: linuxusers