-
Notifications
You must be signed in to change notification settings - Fork 0
/
prepare-node.yml
165 lines (134 loc) · 4.74 KB
/
prepare-node.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
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
- hosts: dswarm_leaders
gather_facts: yes
become: true
tasks:
- name: Updates apt cache
shell: sudo apt-get update
delegate_to: "{{ item }}"
with_items:
- "{{ groups.dswarm_leaders }}"
- "{{ groups.dswarm_managers }}"
- "{{ groups.postgres_hosts }}"
- name: Install dependencies
apt:
name: docker, docker-compose, python-pip, python3-pip, postgresql, python-dev, build-essential
state: present
delegate_to: "{{ item }}"
with_items:
- "{{ groups.dswarm_hosts }}"
- "{{ groups.postgres_hosts }}"
- name: Install postgres and dependencies
apt:
name: postgresql, libpq-dev
state: present
delegate_to: "{{ item }}"
with_items: "{{ groups.postgres_hosts }}"
- name: Install pip - wheel, docker, jsondiff
pip:
name: wheel, docker, jsondiff
state: present
delegate_to: "{{ item }}"
with_items:
- "{{ groups.dswarm_hosts }}"
- "{{ groups.postgres_hosts }}"
- name: Install pip wheel, docker, jsondiff, psycopg2
pip:
name: wheel, docker, jsondiff, psycopg2
state: present
delegate_to: "{{ item }}"
with_items:
- "{{ groups.postgres_hosts }}"
- name: Install pymongo
pip:
name: pymongo
state: present
delegate_to: "{{ item }}"
with_items: "{{ groups.dswarm_hosts }}"
- name: Install docker-compose
pip:
name: docker-compose
state: present
delegate_to: "{{ item }}"
with_items: "{{ groups.dswarm_hosts }}"
- name: Configure docker network
docker_network:
name: examplcorp
scope: swarm
force: true
driver: overlay
attachable: yes
ipam_config:
- subnet: "10.200.200.0/24"
gateway: "10.200.200.1"
delegate_to: "{{ item }}"
with_items: "{{ groups.dswarm_managers }}"
- name: Ensure group dockerized exists # only for historiacal compability with Avra env needs
group:
name: dockerized
state: present
- name: Create a user dockerized # only for historiacal compability with Avra env needs
user:
name: dockerized
append: yes
groups: "dockerized"
comment: "Uzytkownik na potrzeby zgodnosci historycznej z Avra"
shell: "/bin/bash"
- name: Set /etc/dockerized file premisions
file:
path: /etc/dockerized
owner: dockerized
group: docker
state: directory
mode: 0774
- name: Set /var/log/dockerized file premisions
file:
path: /var/log/dockerized
owner: dockerized
group: docker
state: directory
mode: 0774
- name: Add jenkins user to docker group
user:
name: jenkins
groups: docker
append: yes
- name: "Add {{ user_wykonawczy }} user to docker group"
user:
name: "{{ user_wykonawczy }}"
groups: docker
append: yes
- name: Allow localhost authentication for posgres
lineinfile:
path: /etc/postgresql/10/main/pg_hba.conf
regexp: '^local(.*)all(.*)postgres'
line: 'local all postgres trust'
delegate_to: "{{ item }}"
with_items: "{{ groups.postgres_hosts }}"
- name: Allow AWS subnets authentication for posgres
lineinfile:
path: /etc/postgresql/10/main/pg_hba.conf
line: |
host all all {{ hostvars.dswarm_manager1.ansible_host }}/32 trust
host all all {{ hostvars.dswarm_leader1.ansible_host }}/32 trust
host all all {{ hostvars.postgres1.ansible_host }}/32 trust
delegate_to: "{{ item }}"
with_items: "{{ groups.postgres_hosts }}"
- name: Setup listen on adress for postgres
lineinfile:
path: /etc/postgresql/10/main/postgresql.conf
regexp: '(.*)listen_addresses =(.*)localhost(.*)'
line: |
listen_addresses = '*'
delegate_to: "{{ item }}"
with_items: "{{ groups.postgres_hosts }}"
- name: Restart the PostgreSQL service
service: name=postgresql state=restarted enabled=yes
delegate_to: "{{ item }}"
with_items: "{{ groups.postgres_hosts }}"
- name: Reboot a server to force permissions change
reboot:
msg: |
UWAGA
Serwer zostawnie za chwile zrestartowany w ramach prac administracyjnych.
W razie pytan skontaktuj się z DevOps team.
pre_reboot_delay: 10