blob: 33ad49b108dc8eedc4a43cddba54f9fc5c3eea82 [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
51 -C 'I@glusterfs:client:enabled:True' cmd.run 'gluster peer status; gluster volume status' -b 1
52 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
161- description: "Wait for Aptly to come up in container..."
162 cmd: timeout 300 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@aptly:server' cmd.run
163 'export CICD_CONTROL_ADDRESS=$(salt-call --out=newline_values_only pillar.get _param:cluster_vip_address);
164 while true; do curl -sf http://${CICD_CONTROL_ADDRESS}:8084/api/version && break; sleep 2; done'
165 node_name: {{ HOSTNAME_CFG01 }}
166 retry: {count: 3, delay: 15}
167 skip_fail: false
168
169- description: "Setup Aptly"
170 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@aptly:server' state.sls aptly
171 node_name: {{ HOSTNAME_CFG01 }}
172 retry: {count: 3, delay: 10}
173 skip_fail: false
174
175# OpenLDAP
176#---------
177
178- description: "Waiting for OpenLDAP to come up in container..."
179 cmd: timeout 60 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@openldap:client' cmd.run
180 'export CICD_CONTROL_ADDRESS=$(salt-call --out=newline_values_only pillar.get _param:cluster_vip_address);
181 while true; do curl -sf ldap://${CICD_CONTROL_ADDRESS} && break; sleep 2; done'
182 node_name: {{ HOSTNAME_CFG01 }}
183 retry: {count: 3, delay: 10}
184 skip_fail: false
185
186- description: "Setup OpenLDAP"
187 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@openldap:client' state.sls openldap &&
188 sleep 20
189 node_name: {{ HOSTNAME_CFG01 }}
190 retry: {count: 3, delay: 10}
191 skip_fail: false
192
193# Gerrit
194#-------
195
196- description: "Waiting for Gerrit to come up in container..."
197 cmd: timeout 60 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@gerrit:client' cmd.run
198 'export CICD_CONTROL_ADDRESS=$(salt-call --out=newline_values_only pillar.get _param:cluster_vip_address);
199 while true; do curl -sf http://${CICD_CONTROL_ADDRESS}:8080/config/server/version && break; sleep 2; done'
200 node_name: {{ HOSTNAME_CFG01 }}
201 retry: {count: 3, delay: 10}
202 skip_fail: false
203
204- description: "Setup Gerrit"
205 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@gerrit:client' state.sls gerrit
206 node_name: {{ HOSTNAME_CFG01 }}
207 retry: {count: 3, delay: 10}
208 skip_fail: false
209
210# Jenkins
211#--------
212
213- description: "Waiting for Jenkins to come up in container..."
214 cmd: timeout 60 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@jenkins:client' cmd.run
215 'export CICD_CONTROL_ADDRESS=$(salt-call --out=newline_values_only pillar.get _param:cluster_vip_address);
216 export JENKINS_CLIENT_USER=$(salt-call --out=newline_values_only pillar.get _param:jenkins_client_user);
217 export JENKINS_CLIENT_PASSWORD=$(salt-call --out=newline_values_only pillar.get _param:jenkins_client_password);
218 while true; do
219 curl -f -u ${JENKINS_CLIENT_USER}:${JENKINS_CLIENT_PASSWORD} http://${CICD_CONTROL_ADDRESS}:8081/api/json?pretty=true && break;
220 sleep 2;
221 done'
222 node_name: {{ HOSTNAME_CFG01 }}
223 retry: {count: 3, delay: 10}
224 skip_fail: false
225
226- description: "Setup Jenkins"
227 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@jenkins:client' state.sls jenkins
228 node_name: {{ HOSTNAME_CFG01 }}
229 retry: {count: 3, delay: 10}
230 skip_fail: false
231
232# Postgres && Pushkin
233#--------------------
234
235- description: "Waiting for postgresql database to come up in container..."
236# cmd: timeout 300 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@postgresql:client' cmd.run
237# 'while true; do if docker service logs postgresql_db | grep -q "ready to accept"; then break; else sleep 5; fi; done'
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_postgresql-db | grep -q "ready to accept"; then break; else sleep 5; fi; done'
240 node_name: {{ HOSTNAME_CFG01 }}
241 retry: {count: 3, delay: 10}
242 skip_fail: false
243
244- description: ("Create PostgreSQL databases, it fails at first run because of known deadlock:\n"
245 "1. State postgresql.client cannot insert values into 'pushkin' database because it is created empty,\n"
246 "2. Container with Pushkin cannot start and fill the database scheme until state postgresql.client created users.")
247 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@postgresql:client' state.sls postgresql.client -b 1 &&
248 timeout 300 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@postgresql:client' cmd.run
249 'export CICD_CONTROL_ADDRESS=$(salt-call --out=newline_values_only pillar.get _param:cluster_vip_address);
250 while true; do curl -sf http://${CICD_CONTROL_ADDRESS}:8887/apps && break; sleep 2; done'
251 node_name: {{ HOSTNAME_CFG01 }}
252 retry: {count: 3, delay: 100}
253 skip_fail: false
254
255# Rundeck
256#--------
257
258- description: Waiting for Rundeck to come up in container...
259 cmd: timeout 30 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@rundeck:client' cmd.run
260 'export CICD_CONTROL_ADDRESS=$(salt-call --out=newline_values_only pillar.get _param:cluster_vip_address);
261 while true; do curl -sf http://${CICD_CONTROL_ADDRESS}:4440 && break; sleep 2; done'
262 node_name: {{ HOSTNAME_CFG01 }}
263 retry: {count: 3, delay: 10}
264 skip_fail: false
265
266- description: Setup Rundeck
267 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@rundeck:client' state.sls rundeck.client
268 node_name: {{ HOSTNAME_CFG01 }}
269 retry: {count: 3, delay: 10}
270 skip_fail: false
271
Dennis Dmitriev07ce4182017-10-18 16:46:33 +0300272# Elasticsearch (in container, disabled until https://mirantis.jira.com/browse/PROD-15297 is not fixed)
Dennis Dmitriev411dd102017-09-15 16:04:47 +0300273#--------------
Dennis Dmitriev07ce4182017-10-18 16:46:33 +0300274#- description: 'Waiting for Elasticsearch to come up in container...'
275# cmd: timeout 30 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@elasticsearch:client' cmd.run
276# 'export CICD_CONTROL_ADDRESS=$(salt-call --out=newline_values_only pillar.get _param:cluster_vip_address);
277# while true; do curl -sf http://${CICD_CONTROL_ADDRESS}:9200/?pretty && break; sleep 2; done'
278# node_name: {{ HOSTNAME_CFG01 }}
279# retry: {count: 3, delay: 10}
280# skip_fail: false
281#
282#- description: Setup Elasticsearch
283# cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@elasticsearch:client' state.sls elasticsearch.client
284# node_name: {{ HOSTNAME_CFG01 }}
285# retry: {count: 3, delay: 10}
286# skip_fail: false
Dennis Dmitriev411dd102017-09-15 16:04:47 +0300287
288
289# Generate docs
290#--------------
291
292- description: Install sphinx (may fail depending on the model)
293 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@sphinx:server' state.sls sphinx
294 node_name: {{ HOSTNAME_CFG01 }}
295 retry: {count: 1, delay: 10}
296 skip_fail: true
297
298- description: Generate docs (may fail depending on the model)
299 cmd: salt-run state.orchestrate sphinx.orch.generate_doc
300 node_name: {{ HOSTNAME_CFG01 }}
301 retry: {count: 1, delay: 10}
302 skip_fail: true
303
Dennis Dmitrievc7b17312017-10-01 00:08:11 +0300304- description: Run salt minion to create cert files for nginx
305 cmd: salt --hard-crash --state-output=mixed --state-verbose=False
306 -C 'I@nginx:server' state.sls salt.minion
307 node_name: {{ HOSTNAME_CFG01 }}
308 retry: {count: 1, delay: 10}
309 skip_fail: false
310
Dennis Dmitriev411dd102017-09-15 16:04:47 +0300311- description: Install nginx
312 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@nginx:server' state.sls nginx
313 node_name: {{ HOSTNAME_CFG01 }}
314 retry: {count: 3, delay: 10}
315 skip_fail: false
316
317# Final checks
318#-------------
319
320- description: Check for system services in failed state
321 cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' cmd.run "systemctl --failed | grep -E 'loaded[ \t]+failed' && echo 'Command execution failed' || true"
322 node_name: {{ HOSTNAME_CFG01 }}
323 retry: {count: 1, delay: 10}
324 skip_fail: false