blob: c69013e978c90092dec375c82e4a1d254dca5119 [file] [log] [blame]
Dennis Dmitriev411dd102017-09-15 16:04:47 +03001{% from 'cookied-mcp-ocata-dop-sl2/underlay.yaml' import HOSTNAME_CFG01 with context %}
2
3# Install OSS: Operational Support System Tools
4
5# Keepalived
6#-----------
7- description: Install keepalived
8 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@keepalived:cluster:enabled:True' state.sls keepalived
9 node_name: {{ HOSTNAME_CFG01 }}
10 retry: {count: 1, delay: 10}
11 skip_fail: false
12
13- description: Install haproxy
14 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@haproxy:proxy:enabled:True' state.sls haproxy
15 node_name: {{ HOSTNAME_CFG01 }}
16 retry: {count: 1, delay: 10}
17 skip_fail: false
18
19- description: Check the CICD VIP
20 cmd: |
21 CICD_CONTROL_ADDRESS=`salt --out=newline_values_only -C 'I@haproxy:proxy and I@jenkins:client' pillar.get _param:cluster_vip_address`;
22 echo "_param:cluster_vip_address (vip): ${CICD_CONTROL_ADDRESS}";
23 salt --hard-crash --state-output=mixed --state-verbose=False -C "I@keepalived:cluster:instance:*:address:${CICD_CONTROL_ADDRESS}" cmd.run "ip a | grep ${CICD_CONTROL_ADDRESS}" | grep -B1 ${CICD_CONTROL_ADDRESS}
24 node_name: {{ HOSTNAME_CFG01 }}
25 retry: {count: 1, delay: 5}
26 skip_fail: false
27
28# Glusterfs
29#-----------
30
31- description: Prepare glusterfs service
32 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@glusterfs:server:enabled:True' state.sls glusterfs.server.service
33 node_name: {{ HOSTNAME_CFG01 }}
34 retry: {count: 1, delay: 5}
35 skip_fail: false
36
37- description: Setup glusterfs server
38 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@glusterfs:server:enabled:True' state.sls glusterfs.server.setup -b 1
39 node_name: {{ HOSTNAME_CFG01 }}
40 retry: {count: 2, delay: 5}
41 skip_fail: false
42
43- description: Setup glusterfs client
44 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@glusterfs:client:enabled:True' state.sls glusterfs.client
45 node_name: {{ HOSTNAME_CFG01 }}
46 retry: {count: 1, delay: 5}
47 skip_fail: false
48
49- description: Check the gluster status
50 cmd: salt --hard-crash --state-output=mixed --state-verbose=False
Dennis Dmitriev807ade12017-10-19 21:01:02 +030051 -C 'I@glusterfs:server:enabled:True' cmd.run 'gluster peer status; gluster volume status' -b 1
Dennis Dmitriev411dd102017-09-15 16:04:47 +030052 node_name: {{ HOSTNAME_CFG01 }}
53 retry: {count: 1, delay: 5}
54 skip_fail: false
55
Dennis Dmitriev07ce4182017-10-18 16:46:33 +030056# Elasticsearch (system service)
57#-------------------------------
58- description: Setup Elasticsearch
59 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@elasticsearch:server' state.sls elasticsearch.server -b 1
60 node_name: {{ HOSTNAME_CFG01 }}
61 retry: {count: 3, delay: 10}
62 skip_fail: false
63
64- description: Setup Elasticsearch
65 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@elasticsearch:client' state.sls elasticsearch.client
66 node_name: {{ HOSTNAME_CFG01 }}
67 retry: {count: 3, delay: 10}
68 skip_fail: false
69
Dennis Dmitriev411dd102017-09-15 16:04:47 +030070# Setup Docker Swarm
71#-------------------
72
73- description: "Workaround: create /var/lib/jenkins to get Jenkins slaves working"
74 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@jenkins:client' cmd.run 'mkdir -p /var/lib/jenkins'
75 node_name: {{ HOSTNAME_CFG01 }}
76 retry: {count: 1, delay: 10}
77 skip_fail: false
78
79- description: Prepare Docker host
80 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:host:enabled:True' state.sls docker.host
81 node_name: {{ HOSTNAME_CFG01 }}
82 retry: {count: 1, delay: 5}
83 skip_fail: false
84
85- description: Install Docker Swarm master
86 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master' state.sls docker.swarm
87 node_name: {{ HOSTNAME_CFG01 }}
88 retry: {count: 1, delay: 5}
89 skip_fail: false
90
91- description: Collect grains
92 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master' state.sls salt.minion.grains &&
93 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master' mine.flush &&
94 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master' mine.update &&
95 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm' saltutil.refresh_modules &&
96 sleep 10
97 node_name: {{ HOSTNAME_CFG01 }}
98 retry: {count: 3, delay: 15}
99 skip_fail: false
100
101- description: Install Docker Swarm on other nodes
102 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm' state.sls docker.swarm
103 node_name: {{ HOSTNAME_CFG01 }}
104 retry: {count: 2, delay: 5}
105 skip_fail: false
106
107- description: Show Docker Swarm nodes
108 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master' cmd.run 'docker node ls'
109 node_name: {{ HOSTNAME_CFG01 }}
110 retry: {count: 1, delay: 5}
111 skip_fail: false
112
113# Configure OSS services
114#-----------------------
115
116- description: Setup devops portal
117 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@devops_portal:config:enabled' state.sls devops_portal.config
118 node_name: {{ HOSTNAME_CFG01 }}
119 retry: {count: 1, delay: 5}
120 skip_fail: false
121
122- description: Setup Rundeck server
123 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@rundeck:server' state.sls rundeck.server
124 node_name: {{ HOSTNAME_CFG01 }}
125 retry: {count: 1, delay: 5}
126 skip_fail: false
127
128# Deploy Docker services
129#-----------------------
130
131# Original comment from pipeline: XXX: for some weird unknown reason, refresh_pillar is required to execute here
132
133- description: "Workaround from the pipeline: XXX: for some weird unknown reason, refresh_pillar is required to execute here"
134 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@aptly:publisher' saltutil.refresh_pillar
135 node_name: {{ HOSTNAME_CFG01 }}
136 retry: {count: 1, delay: 5}
137 skip_fail: false
138
139- description: "Workaround from the pipeline: We need /etc/aptly-publisher.yaml to be present before services are deployed. [dd: there were issues when /etc/aptly-publisher.yaml becomes a directory, so this step should be considered]"
140 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@aptly:publisher' state.sls aptly.publisher
141 node_name: {{ HOSTNAME_CFG01 }}
Dennis Dmitriev8072d902017-09-21 18:29:42 +0300142 retry: {count: 2, delay: 5}
Dennis Dmitriev411dd102017-09-15 16:04:47 +0300143 skip_fail: false
144
145- description: Install Docker client
146 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master' state.sls docker.client
147 node_name: {{ HOSTNAME_CFG01 }}
148 retry: {count: 3, delay: 5}
149 skip_fail: false
150
151- description: "Workaround from the pipeline: sync all salt objects"
152 cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.sync_all && sleep 5
153 node_name: {{ HOSTNAME_CFG01 }}
154 retry: {count: 1, delay: 5}
155 skip_fail: false
156
157
158# Aptly
159#------
160
sgudzbaaf0ac2018-02-05 18:37:39 +0200161#### Steps are commented due to PROD-17598
Dennis Dmitriev411dd102017-09-15 16:04:47 +0300162
sgudzbaaf0ac2018-02-05 18:37:39 +0200163#- description: "Wait for Aptly to come up in container..."
164# cmd: timeout 300 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@aptly:server' cmd.run
165# 'export CICD_CONTROL_ADDRESS=$(salt-call --out=newline_values_only pillar.get _param:cluster_vip_address);
166# while true; do curl -sf http://${CICD_CONTROL_ADDRESS}:8084/api/version && break; sleep 2; done'
167# node_name: {{ HOSTNAME_CFG01 }}
168# retry: {count: 3, delay: 15}
169# skip_fail: false
170
171#- description: "Setup Aptly"
172# cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@aptly:server' state.sls aptly
173# node_name: {{ HOSTNAME_CFG01 }}
174# retry: {count: 3, delay: 10}
175# skip_fail: false
Dennis Dmitriev411dd102017-09-15 16:04:47 +0300176
177# OpenLDAP
178#---------
179
180- description: "Waiting for OpenLDAP to come up in container..."
181 cmd: timeout 60 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@openldap:client' cmd.run
182 'export CICD_CONTROL_ADDRESS=$(salt-call --out=newline_values_only pillar.get _param:cluster_vip_address);
183 while true; do curl -sf ldap://${CICD_CONTROL_ADDRESS} && break; sleep 2; done'
184 node_name: {{ HOSTNAME_CFG01 }}
185 retry: {count: 3, delay: 10}
186 skip_fail: false
187
188- description: "Setup OpenLDAP"
189 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@openldap:client' state.sls openldap &&
190 sleep 20
191 node_name: {{ HOSTNAME_CFG01 }}
192 retry: {count: 3, delay: 10}
193 skip_fail: false
194
195# Gerrit
196#-------
197
198- description: "Waiting for Gerrit to come up in container..."
199 cmd: timeout 60 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@gerrit:client' cmd.run
200 'export CICD_CONTROL_ADDRESS=$(salt-call --out=newline_values_only pillar.get _param:cluster_vip_address);
201 while true; do curl -sf http://${CICD_CONTROL_ADDRESS}:8080/config/server/version && break; sleep 2; done'
202 node_name: {{ HOSTNAME_CFG01 }}
203 retry: {count: 3, delay: 10}
204 skip_fail: false
205
206- description: "Setup Gerrit"
207 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@gerrit:client' state.sls gerrit
208 node_name: {{ HOSTNAME_CFG01 }}
209 retry: {count: 3, delay: 10}
210 skip_fail: false
211
212# Jenkins
213#--------
214
215- description: "Waiting for Jenkins to come up in container..."
216 cmd: timeout 60 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@jenkins:client' cmd.run
217 'export CICD_CONTROL_ADDRESS=$(salt-call --out=newline_values_only pillar.get _param:cluster_vip_address);
218 export JENKINS_CLIENT_USER=$(salt-call --out=newline_values_only pillar.get _param:jenkins_client_user);
219 export JENKINS_CLIENT_PASSWORD=$(salt-call --out=newline_values_only pillar.get _param:jenkins_client_password);
220 while true; do
221 curl -f -u ${JENKINS_CLIENT_USER}:${JENKINS_CLIENT_PASSWORD} http://${CICD_CONTROL_ADDRESS}:8081/api/json?pretty=true && break;
222 sleep 2;
223 done'
224 node_name: {{ HOSTNAME_CFG01 }}
225 retry: {count: 3, delay: 10}
226 skip_fail: false
227
228- description: "Setup Jenkins"
229 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@jenkins:client' state.sls jenkins
230 node_name: {{ HOSTNAME_CFG01 }}
Dennis Dmitrieva95a6d42017-10-24 15:09:04 +0300231 retry: {count: 10, delay: 30}
Dennis Dmitriev411dd102017-09-15 16:04:47 +0300232 skip_fail: false
233
234# Postgres && Pushkin
235#--------------------
236
237- description: "Waiting for postgresql database to come up in container..."
238# cmd: timeout 300 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@postgresql:client' cmd.run
239# 'while true; do if docker service logs postgresql_db | grep -q "ready to accept"; then break; else sleep 5; fi; done'
240 cmd: timeout 300 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@postgresql:client' cmd.run
241 'while true; do if docker service logs postgresql_postgresql-db | grep -q "ready to accept"; then break; else sleep 5; fi; done'
242 node_name: {{ HOSTNAME_CFG01 }}
243 retry: {count: 3, delay: 10}
244 skip_fail: false
245
246- description: ("Create PostgreSQL databases, it fails at first run because of known deadlock:\n"
247 "1. State postgresql.client cannot insert values into 'pushkin' database because it is created empty,\n"
248 "2. Container with Pushkin cannot start and fill the database scheme until state postgresql.client created users.")
249 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@postgresql:client' state.sls postgresql.client -b 1 &&
250 timeout 300 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@postgresql:client' cmd.run
251 'export CICD_CONTROL_ADDRESS=$(salt-call --out=newline_values_only pillar.get _param:cluster_vip_address);
252 while true; do curl -sf http://${CICD_CONTROL_ADDRESS}:8887/apps && break; sleep 2; done'
253 node_name: {{ HOSTNAME_CFG01 }}
254 retry: {count: 3, delay: 100}
255 skip_fail: false
256
257# Rundeck
258#--------
259
260- description: Waiting for Rundeck to come up in container...
261 cmd: timeout 30 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@rundeck:client' cmd.run
262 'export CICD_CONTROL_ADDRESS=$(salt-call --out=newline_values_only pillar.get _param:cluster_vip_address);
263 while true; do curl -sf http://${CICD_CONTROL_ADDRESS}:4440 && break; sleep 2; done'
264 node_name: {{ HOSTNAME_CFG01 }}
265 retry: {count: 3, delay: 10}
266 skip_fail: false
267
268- description: Setup Rundeck
269 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@rundeck:client' state.sls rundeck.client
270 node_name: {{ HOSTNAME_CFG01 }}
271 retry: {count: 3, delay: 10}
272 skip_fail: false
273
Dennis Dmitriev07ce4182017-10-18 16:46:33 +0300274# Elasticsearch (in container, disabled until https://mirantis.jira.com/browse/PROD-15297 is not fixed)
Dennis Dmitriev411dd102017-09-15 16:04:47 +0300275#--------------
Dennis Dmitriev07ce4182017-10-18 16:46:33 +0300276#- description: 'Waiting for Elasticsearch to come up in container...'
277# cmd: timeout 30 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@elasticsearch:client' cmd.run
278# 'export CICD_CONTROL_ADDRESS=$(salt-call --out=newline_values_only pillar.get _param:cluster_vip_address);
279# while true; do curl -sf http://${CICD_CONTROL_ADDRESS}:9200/?pretty && break; sleep 2; done'
280# node_name: {{ HOSTNAME_CFG01 }}
281# retry: {count: 3, delay: 10}
282# skip_fail: false
283#
284#- description: Setup Elasticsearch
285# cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@elasticsearch:client' state.sls elasticsearch.client
286# node_name: {{ HOSTNAME_CFG01 }}
287# retry: {count: 3, delay: 10}
288# skip_fail: false
Dennis Dmitriev411dd102017-09-15 16:04:47 +0300289
290
291# Generate docs
292#--------------
293
294- description: Install sphinx (may fail depending on the model)
295 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@sphinx:server' state.sls sphinx
296 node_name: {{ HOSTNAME_CFG01 }}
297 retry: {count: 1, delay: 10}
298 skip_fail: true
299
300- description: Generate docs (may fail depending on the model)
301 cmd: salt-run state.orchestrate sphinx.orch.generate_doc
302 node_name: {{ HOSTNAME_CFG01 }}
303 retry: {count: 1, delay: 10}
304 skip_fail: true
305
Dennis Dmitrievc7b17312017-10-01 00:08:11 +0300306- description: Run salt minion to create cert files for nginx
307 cmd: salt --hard-crash --state-output=mixed --state-verbose=False
308 -C 'I@nginx:server' state.sls salt.minion
309 node_name: {{ HOSTNAME_CFG01 }}
310 retry: {count: 1, delay: 10}
311 skip_fail: false
312
Dennis Dmitriev411dd102017-09-15 16:04:47 +0300313- description: Install nginx
314 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@nginx:server' state.sls nginx
315 node_name: {{ HOSTNAME_CFG01 }}
316 retry: {count: 3, delay: 10}
317 skip_fail: false
318
319# Final checks
320#-------------
321
322- description: Check for system services in failed state
323 cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' cmd.run "systemctl --failed | grep -E 'loaded[ \t]+failed' && echo 'Command execution failed' || true"
324 node_name: {{ HOSTNAME_CFG01 }}
325 retry: {count: 1, delay: 10}
326 skip_fail: false