blob: f64b373a037ff256abcd6c4c6d52cbfa5c2befe6 [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
Dennis Dmitriev411dd102017-09-15 16:04:47 +03005# Glusterfs
6#-----------
7
8- description: Prepare glusterfs service
9 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@glusterfs:server:enabled:True' state.sls glusterfs.server.service
10 node_name: {{ HOSTNAME_CFG01 }}
11 retry: {count: 1, delay: 5}
12 skip_fail: false
13
14- description: Setup glusterfs server
15 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@glusterfs:server:enabled:True' state.sls glusterfs.server.setup -b 1
16 node_name: {{ HOSTNAME_CFG01 }}
17 retry: {count: 2, delay: 5}
18 skip_fail: false
19
20- description: Setup glusterfs client
21 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@glusterfs:client:enabled:True' state.sls glusterfs.client
22 node_name: {{ HOSTNAME_CFG01 }}
23 retry: {count: 1, delay: 5}
24 skip_fail: false
25
26- description: Check the gluster status
27 cmd: salt --hard-crash --state-output=mixed --state-verbose=False
Dennis Dmitriev807ade12017-10-19 21:01:02 +030028 -C 'I@glusterfs:server:enabled:True' cmd.run 'gluster peer status; gluster volume status' -b 1
Dennis Dmitriev411dd102017-09-15 16:04:47 +030029 node_name: {{ HOSTNAME_CFG01 }}
30 retry: {count: 1, delay: 5}
31 skip_fail: false
32
Dennis Dmitriev07ce4182017-10-18 16:46:33 +030033# Elasticsearch (system service)
34#-------------------------------
35- description: Setup Elasticsearch
36 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@elasticsearch:server' state.sls elasticsearch.server -b 1
37 node_name: {{ HOSTNAME_CFG01 }}
38 retry: {count: 3, delay: 10}
39 skip_fail: false
40
41- description: Setup Elasticsearch
42 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@elasticsearch:client' state.sls elasticsearch.client
43 node_name: {{ HOSTNAME_CFG01 }}
44 retry: {count: 3, delay: 10}
45 skip_fail: false
46
Dennis Dmitriev411dd102017-09-15 16:04:47 +030047# Setup Docker Swarm
48#-------------------
49
50- description: "Workaround: create /var/lib/jenkins to get Jenkins slaves working"
51 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@jenkins:client' cmd.run 'mkdir -p /var/lib/jenkins'
52 node_name: {{ HOSTNAME_CFG01 }}
53 retry: {count: 1, delay: 10}
54 skip_fail: false
55
56- description: Prepare Docker host
57 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:host:enabled:True' state.sls docker.host
58 node_name: {{ HOSTNAME_CFG01 }}
59 retry: {count: 1, delay: 5}
60 skip_fail: false
61
62- description: Install Docker Swarm master
63 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master' state.sls docker.swarm
64 node_name: {{ HOSTNAME_CFG01 }}
65 retry: {count: 1, delay: 5}
66 skip_fail: false
67
68- description: Collect grains
69 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master' state.sls salt.minion.grains &&
70 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master' mine.flush &&
71 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master' mine.update &&
72 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm' saltutil.refresh_modules &&
73 sleep 10
74 node_name: {{ HOSTNAME_CFG01 }}
75 retry: {count: 3, delay: 15}
76 skip_fail: false
77
78- description: Install Docker Swarm on other nodes
79 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm' state.sls docker.swarm
80 node_name: {{ HOSTNAME_CFG01 }}
81 retry: {count: 2, delay: 5}
82 skip_fail: false
83
84- description: Show Docker Swarm nodes
85 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master' cmd.run 'docker node ls'
86 node_name: {{ HOSTNAME_CFG01 }}
87 retry: {count: 1, delay: 5}
88 skip_fail: false
89
Dennis Dmitriev002c2672018-03-06 18:43:27 +020090# Keepalived
91#-----------
92- description: Install keepalived
93 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@keepalived:cluster:enabled:True' state.sls keepalived
94 node_name: {{ HOSTNAME_CFG01 }}
95 retry: {count: 1, delay: 10}
96 skip_fail: false
97
98- description: Install haproxy
99 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@haproxy:proxy:enabled:True' state.sls haproxy
100 node_name: {{ HOSTNAME_CFG01 }}
101 retry: {count: 1, delay: 10}
102 skip_fail: false
103
104- description: Check the CICD VIP
105 cmd: |
106 CICD_CONTROL_ADDRESS=`salt --out=newline_values_only -C 'I@haproxy:proxy and I@jenkins:client' pillar.get _param:cluster_vip_address`;
107 echo "_param:cluster_vip_address (vip): ${CICD_CONTROL_ADDRESS}";
108 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}
109 node_name: {{ HOSTNAME_CFG01 }}
110 retry: {count: 1, delay: 5}
111 skip_fail: false
112
Dennis Dmitriev411dd102017-09-15 16:04:47 +0300113# 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 }}
Dennis Dmitrievc83b3d42018-03-16 00:59:18 +0200185 retry: {count: 10, delay: 30}
Dennis Dmitriev411dd102017-09-15 16:04:47 +0300186 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 }}
Dennis Dmitrievc83b3d42018-03-16 00:59:18 +0200203 retry: {count: 10, delay: 30}
Dennis Dmitriev411dd102017-09-15 16:04:47 +0300204 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..."
Dennis Dmitriev820b26d2018-02-07 21:51:22 +0200216 cmd: timeout 60 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:client:stack:jenkins' cmd.run
Dennis Dmitriev411dd102017-09-15 16:04:47 +0300217 '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 }}
Dennis Dmitrievc83b3d42018-03-16 00:59:18 +0200225 retry: {count: 10, delay: 30}
Dennis Dmitriev411dd102017-09-15 16:04:47 +0300226 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'
Dennis Dmitriev820b26d2018-02-07 21:51:22 +0200240 cmd: timeout 300 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:client:stack:postgresql' cmd.run
Dennis Dmitriev411dd102017-09-15 16:04:47 +0300241 '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 &&
Dennis Dmitriev820b26d2018-02-07 21:51:22 +0200250 timeout 300 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:client:stack:postgresql' cmd.run
Dennis Dmitriev411dd102017-09-15 16:04:47 +0300251 '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...
Dennis Dmitriev820b26d2018-02-07 21:51:22 +0200261 cmd: timeout 30 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:client:stack:rundeck' cmd.run
Dennis Dmitriev411dd102017-09-15 16:04:47 +0300262 '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