blob: 9c6a504ae05200d2c02b6a6a1c73febc8d98cd4d [file] [log] [blame]
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +03001{% from 'virtual-mcp-ocata-cicd/underlay.yaml' import HOSTNAME_CFG01 with context %}
2
3# Pattern that helps salt to select CICD nodes
4{% set CICD_NODES_SELECTOR = os_env('CICD_NODES_SELECTOR','cid*') %}
5
6# Install OSS: Operational Support System Tools
7
8# Keepalived
9#-----------
10- description: Install keepalived on {{ CICD_NODES_SELECTOR }} nodes
11 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@haproxy:proxy and {{ CICD_NODES_SELECTOR }}' state.sls keepalived
12 node_name: {{ HOSTNAME_CFG01 }}
13 retry: {count: 1, delay: 10}
14 skip_fail: false
15
16- description: Install haproxy on {{ CICD_NODES_SELECTOR }} nodes
17 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@haproxy:proxy and {{ CICD_NODES_SELECTOR }}' state.sls haproxy
18 node_name: {{ HOSTNAME_CFG01 }}
19 retry: {count: 1, delay: 10}
20 skip_fail: false
21
22- description: Check the VIP
23 cmd: |
24 CICD_CONTROL_ADDRESS=`salt-call --out=newline_values_only pillar.get _param:cicd_control_address`;
25 echo "_param:cicd_control_address (vip): ${CICD_CONTROL_ADDRESS}";
26 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@haproxy:proxy and {{ CICD_NODES_SELECTOR }}' cmd.run "ip a | grep ${CICD_CONTROL_ADDRESS}" | grep -B1 ${CICD_CONTROL_ADDRESS}
27 node_name: {{ HOSTNAME_CFG01 }}
28 retry: {count: 1, delay: 5}
29 skip_fail: false
30
31# Glusterfs
32#-----------
33
34- description: Prepare glusterfs service
35 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@glusterfs:server and {{ CICD_NODES_SELECTOR }}' state.sls glusterfs.server.service
36 node_name: {{ HOSTNAME_CFG01 }}
37 retry: {count: 1, delay: 5}
38 skip_fail: false
39
40- description: Setup glusterfs server
41 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@glusterfs:server and {{ CICD_NODES_SELECTOR }}' state.sls glusterfs.server.setup -b 1
42 node_name: {{ HOSTNAME_CFG01 }}
43 retry: {count: 2, delay: 5}
44 skip_fail: false
45
46- description: Setup glusterfs client
47 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@glusterfs:client and {{ CICD_NODES_SELECTOR }}' state.sls glusterfs.client
48 node_name: {{ HOSTNAME_CFG01 }}
49 retry: {count: 1, delay: 5}
50 skip_fail: false
51
52- description: Check the gluster status
53 cmd: salt --hard-crash --state-output=mixed --state-verbose=False
54 -C 'I@glusterfs:client and {{ CICD_NODES_SELECTOR }}*' cmd.run 'gluster peer status; gluster volume status' -b 1
55 node_name: {{ HOSTNAME_CFG01 }}
56 retry: {count: 1, delay: 5}
57 skip_fail: false
58
59# Setup Docker Swarm
60#-------------------
61
62- description: "Workaround: create /var/lib/jenkins to get Jenkins slaves working"
63 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@jenkins:client' cmd.run 'mkdir -p /var/lib/jenkins'
64 node_name: {{ HOSTNAME_CFG01 }}
65 retry: {count: 1, delay: 10}
66 skip_fail: false
67
68- description: Prepare Docker host
69 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:host and {{ CICD_NODES_SELECTOR }}' state.sls docker.host
70 node_name: {{ HOSTNAME_CFG01 }}
71 retry: {count: 1, delay: 5}
72 skip_fail: false
73
74- description: Install Docker Swarm master
75 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master and {{ CICD_NODES_SELECTOR }}' state.sls docker.swarm
76 node_name: {{ HOSTNAME_CFG01 }}
77 retry: {count: 1, delay: 5}
78 skip_fail: false
79
Dennis Dmitriev41f0b792017-07-27 18:08:50 +030080- description: Collect grains
81 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master and {{ CICD_NODES_SELECTOR }}' state.sls salt.minion.grains &&
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +030082 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master and {{ CICD_NODES_SELECTOR }}' mine.flush &&
Dennis Dmitriev41f0b792017-07-27 18:08:50 +030083 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master and {{ CICD_NODES_SELECTOR }}' mine.update &&
84 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm and {{ CICD_NODES_SELECTOR }}' saltutil.refresh_modules &&
85 sleep 10
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +030086 node_name: {{ HOSTNAME_CFG01 }}
87 retry: {count: 3, delay: 15}
88 skip_fail: false
89
90- description: Install Docker Swarm on other nodes
91 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm and {{ CICD_NODES_SELECTOR }}' state.sls docker.swarm
92 node_name: {{ HOSTNAME_CFG01 }}
Dennis Dmitriev41f0b792017-07-27 18:08:50 +030093 retry: {count: 2, delay: 5}
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +030094 skip_fail: false
95
96- description: Show Docker Swarm nodes
97 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master and {{ CICD_NODES_SELECTOR }}' cmd.run 'docker node ls'
98 node_name: {{ HOSTNAME_CFG01 }}
99 retry: {count: 1, delay: 5}
100 skip_fail: false
101
102# Configure OSS services
103#-----------------------
104
105- description: Setup devops portal
106 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@devops_portal:config:enabled' state.sls devops_portal.config
107 node_name: {{ HOSTNAME_CFG01 }}
108 retry: {count: 1, delay: 5}
109 skip_fail: false
110
111- description: Setup Rundeck server
112 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@rundeck:server' state.sls rundeck.server
113 node_name: {{ HOSTNAME_CFG01 }}
114 retry: {count: 1, delay: 5}
115 skip_fail: false
116
117# Deploy Docker services
118#-----------------------
119
120# Original comment from pipeline: XXX: for some weird unknown reason, refresh_pillar is required to execute here
121
122- description: "Workaround from the pipeline: XXX: for some weird unknown reason, refresh_pillar is required to execute here"
123 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@aptly:publisher' saltutil.refresh_pillar
124 node_name: {{ HOSTNAME_CFG01 }}
125 retry: {count: 1, delay: 5}
126 skip_fail: false
127
128- 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]"
129 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@aptly:publisher' state.sls aptly.publisher
130 node_name: {{ HOSTNAME_CFG01 }}
Dennis Dmitriev8072d902017-09-21 18:29:42 +0300131 retry: {count: 2, delay: 5}
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300132 skip_fail: false
133
134- description: Install Docker client
Dennis Dmitrievf8546172017-07-20 21:57:05 +0300135 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master and {{ CICD_NODES_SELECTOR }}' state.sls docker.client
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300136 node_name: {{ HOSTNAME_CFG01 }}
137 retry: {count: 3, delay: 5}
138 skip_fail: false
139
140- description: "Workaround from the pipeline: sync all salt objects"
Dennis Dmitriev9a6cacc2017-08-14 00:08:41 +0300141 cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.sync_all && sleep 5
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300142 node_name: {{ HOSTNAME_CFG01 }}
143 retry: {count: 1, delay: 5}
144 skip_fail: false
145
146
147# Aptly
148#------
149
Dennis Dmitriev41f0b792017-07-27 18:08:50 +0300150- description: "Wait for Aptly to come up in container..."
151 cmd: timeout 300 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@aptly:server' cmd.run
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300152 'export CICD_CONTROL_ADDRESS=$(salt-call --out=newline_values_only pillar.get _param:cicd_control_address);
153 while true; do curl -sf http://${CICD_CONTROL_ADDRESS}:8084/api/version && break; sleep 2; done'
154 node_name: {{ HOSTNAME_CFG01 }}
Dennis Dmitriev41f0b792017-07-27 18:08:50 +0300155 retry: {count: 3, delay: 15}
156 skip_fail: false
157
158- description: "Setup Aptly"
159 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@aptly:server' state.sls aptly
160 node_name: {{ HOSTNAME_CFG01 }}
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300161 retry: {count: 3, delay: 10}
162 skip_fail: false
163
164# OpenLDAP
165#---------
166
Dennis Dmitriev41f0b792017-07-27 18:08:50 +0300167- description: "Waiting for OpenLDAP to come up in container..."
168 cmd: timeout 60 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@openldap:client' cmd.run
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300169 'export CICD_CONTROL_ADDRESS=$(salt-call --out=newline_values_only pillar.get _param:cicd_control_address);
Dennis Dmitriev41f0b792017-07-27 18:08:50 +0300170 while true; do curl -sf ldap://${CICD_CONTROL_ADDRESS} && break; sleep 2; done'
171 node_name: {{ HOSTNAME_CFG01 }}
172 retry: {count: 3, delay: 10}
173 skip_fail: false
174
175- description: "Setup OpenLDAP"
176 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@openldap:client' state.sls openldap &&
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300177 sleep 20
178 node_name: {{ HOSTNAME_CFG01 }}
179 retry: {count: 3, delay: 10}
180 skip_fail: false
181
182# Gerrit
183#-------
184
Dennis Dmitriev41f0b792017-07-27 18:08:50 +0300185- description: "Waiting for Gerrit to come up in container..."
186 cmd: timeout 60 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@gerrit:client' cmd.run
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300187 'export CICD_CONTROL_ADDRESS=$(salt-call --out=newline_values_only pillar.get _param:cicd_control_address);
Dennis Dmitriev41f0b792017-07-27 18:08:50 +0300188 while true; do curl -sf http://${CICD_CONTROL_ADDRESS}:8080/config/server/version && break; sleep 2; done'
189 node_name: {{ HOSTNAME_CFG01 }}
190 retry: {count: 3, delay: 10}
191 skip_fail: false
192
193- description: "Setup Gerrit"
194 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@gerrit:client' state.sls gerrit
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300195 node_name: {{ HOSTNAME_CFG01 }}
196 retry: {count: 3, delay: 10}
197 skip_fail: false
198
199# Jenkins
200#--------
201
Dennis Dmitriev41f0b792017-07-27 18:08:50 +0300202- description: "Waiting for Jenkins to come up in container..."
203 cmd: timeout 60 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@jenkins:client' cmd.run
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300204 'export CICD_CONTROL_ADDRESS=$(salt-call --out=newline_values_only pillar.get _param:cicd_control_address);
Dennis Dmitrievf8546172017-07-20 21:57:05 +0300205 export JENKINS_CLIENT_USER=$(salt-call --out=newline_values_only pillar.get _param:jenkins_client_user);
206 export JENKINS_CLIENT_PASSWORD=$(salt-call --out=newline_values_only pillar.get _param:jenkins_client_password);
207 while true; do
208 curl -f -u ${JENKINS_CLIENT_USER}:${JENKINS_CLIENT_PASSWORD} http://${CICD_CONTROL_ADDRESS}:8081/api/json?pretty=true && break;
209 sleep 2;
210 done'
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300211 node_name: {{ HOSTNAME_CFG01 }}
212 retry: {count: 3, delay: 10}
213 skip_fail: false
214
Dennis Dmitriev41f0b792017-07-27 18:08:50 +0300215- description: "Setup Jenkins"
216 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@jenkins:client' state.sls jenkins
217 node_name: {{ HOSTNAME_CFG01 }}
218 retry: {count: 3, delay: 10}
219 skip_fail: false
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300220
Dennis Dmitriev41f0b792017-07-27 18:08:50 +0300221# Postgres && Pushkin
222#--------------------
223
224- description: "Waiting for postgresql database to come up in container..."
Dennis Dmitrievbfc06a82017-09-21 14:10:25 +0300225# cmd: timeout 300 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@postgresql:client' cmd.run
226# 'while true; do if docker service logs postgresql_db | grep -q "ready to accept"; then break; else sleep 5; fi; done'
Dennis Dmitriev41f0b792017-07-27 18:08:50 +0300227 cmd: timeout 300 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@postgresql:client' cmd.run
Dennis Dmitrievbfc06a82017-09-21 14:10:25 +0300228 'while true; do if docker service logs postgresql_postgresql-db | grep -q "ready to accept"; then break; else sleep 5; fi; done'
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300229 node_name: {{ HOSTNAME_CFG01 }}
230 retry: {count: 3, delay: 10}
231 skip_fail: false
232
Dennis Dmitriev41f0b792017-07-27 18:08:50 +0300233- description: ("Create PostgreSQL databases, it fails at first run because of known deadlock:\n"
234 "1. State postgresql.client cannot insert values into 'pushkin' database because it is created empty,\n"
235 "2. Container with Pushkin cannot start and fill the database scheme until state postgresql.client created users.")
236 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@postgresql:client' state.sls postgresql.client -b 1 &&
237 timeout 300 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@postgresql:client' cmd.run
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300238 'export CICD_CONTROL_ADDRESS=$(salt-call --out=newline_values_only pillar.get _param:cicd_control_address);
Dennis Dmitrievf8546172017-07-20 21:57:05 +0300239 while true; do curl -sf http://${CICD_CONTROL_ADDRESS}:8887/apps && break; sleep 2; done'
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300240 node_name: {{ HOSTNAME_CFG01 }}
Dennis Dmitriev41f0b792017-07-27 18:08:50 +0300241 retry: {count: 3, delay: 100}
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300242 skip_fail: false
243
244# Rundeck
245#--------
246
Dennis Dmitriev41f0b792017-07-27 18:08:50 +0300247- description: Waiting for Rundeck to come up in container...
248 cmd: timeout 30 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@rundeck:client' cmd.run
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300249 'export CICD_CONTROL_ADDRESS=$(salt-call --out=newline_values_only pillar.get _param:cicd_control_address);
250 while true; do curl -sf http://${CICD_CONTROL_ADDRESS}:4440 && break; sleep 2; done'
251 node_name: {{ HOSTNAME_CFG01 }}
252 retry: {count: 3, delay: 10}
253 skip_fail: false
254
Dennis Dmitriev41f0b792017-07-27 18:08:50 +0300255- description: Setup Rundeck
256 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@rundeck:client' state.sls rundeck.client
257 node_name: {{ HOSTNAME_CFG01 }}
258 retry: {count: 3, delay: 10}
259 skip_fail: false
260
261# Elasticsearch
262#--------------
263
264- description: 'Waiting for Elasticsearch to come up in container...'
265 cmd: timeout 30 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@elasticsearch:client' cmd.run
266 'export CICD_CONTROL_ADDRESS=$(salt-call --out=newline_values_only pillar.get _param:cicd_control_address);
267 while true; do curl -sf http://${CICD_CONTROL_ADDRESS}:9200/?pretty && break; sleep 2; done'
268 node_name: {{ HOSTNAME_CFG01 }}
269 retry: {count: 3, delay: 10}
270 skip_fail: false
271
272- description: Setup Elasticsearch
273 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@elasticsearch:client' state.sls elasticsearch.client
274 node_name: {{ HOSTNAME_CFG01 }}
275 retry: {count: 3, delay: 10}
276 skip_fail: false
277
278
279
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300280# Generate docs
281#--------------
282
283- description: Install sphinx (may fail depending on the model)
284 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@sphinx:server' state.sls sphinx
285 node_name: {{ HOSTNAME_CFG01 }}
286 retry: {count: 1, delay: 10}
287 skip_fail: true
288
289- description: Generate docs (may fail depending on the model)
290 cmd: salt-run state.orchestrate sphinx.orch.generate_doc
291 node_name: {{ HOSTNAME_CFG01 }}
292 retry: {count: 1, delay: 10}
293 skip_fail: true
294
295- description: Install nginx
296 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@nginx:server' state.sls nginx
297 node_name: {{ HOSTNAME_CFG01 }}
298 retry: {count: 3, delay: 10}
299 skip_fail: false
300
301# Final checks
302#-------------
303
304- description: Check for system services in failed state
305 cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' cmd.run "systemctl --failed | grep -E 'loaded[ \t]+failed' && echo 'Command execution failed' || true"
306 node_name: {{ HOSTNAME_CFG01 }}
307 retry: {count: 1, delay: 10}
308 skip_fail: false