-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplaybook-loop.yml
More file actions
84 lines (75 loc) · 2.19 KB
/
Copy pathplaybook-loop.yml
File metadata and controls
84 lines (75 loc) · 2.19 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# установить гит и пользователей
# /home/kosm/.local/bin/ansible-playbook playbook-loop.yml -i inventory.ini -u root --skip-tags delete_git_users
# удалить гит и пользователей
# /home/kosm/.local/bin/ansible-playbook playbook-loop.yml -i inventory.ini -u root -t delete_git_users
- hosts: devops
become: yes
vars:
users:
- jaime
- sansa
- robert
tasks:
- name: Update apt cache
apt:
update_cache: yes
tags: cache
- name: install git
apt:
name: git
state: present
update_cache: yes
- name: add users
user:
name: "{{item}}"
state: present
password: "{{ item | password_hash('sha512') }}"
loop: "{{users}}"
- name: make directory files
ansible.builtin.file:
path: files
state: directory
- name: Creating a file .gitconfig with content for each user
copy:
dest: "/home/{{item}}/.gitconfig"
content: |
[alias]
co = checkout
ci = commit
st = status
br = branch
hist = log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short
type = cat-file -t
dump = cat-file -p
commend = commit --amend
[core]
excludesFile = ~/.gitignore_global
editor = vim
[user]
email = {{item}}@test.com
name = {{item}}
[credential]
helper = store
loop: "{{users}}"
- name: copy pub key to files
ansible.builtin.copy:
src: /home/kosm/.ssh/hexlet_devops.pub
dest: files/hexlet_devops.pub
- name: Set authorized key taken from file
ansible.posix.authorized_key:
user: "{{item}}"
state: present
key: "{{ lookup('file', '/home/kosm/.ssh/hexlet_devops.pub') }}"
loop: "{{users}}"
- name: delete git
apt:
name: git
state: absent
tags: delete_git_users
- name: delete users
user:
name: "{{item}}"
state: absent
remove: yes
loop: "{{users}}"
tags: delete_git_users