blob: ba09e454ccd4d97a829af70f753793b104a7bbd0 [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
56# Setup Docker Swarm
57#-------------------
58
59- description: "Workaround: create /var/lib/jenkins to get Jenkins slaves working"
60 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@jenkins:client' cmd.run 'mkdir -p /var/lib/jenkins'
61 node_name: {{ HOSTNAME_CFG01 }}
62 retry: {count: 1, delay: 10}
63 skip_fail: false
64
65- description: Prepare Docker host
66 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:host:enabled:True' state.sls docker.host
67 node_name: {{ HOSTNAME_CFG01 }}
68 retry: {count: 1, delay: 5}
69 skip_fail: false
70
71- description: Install Docker Swarm master
72 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master' state.sls docker.swarm
73 node_name: {{ HOSTNAME_CFG01 }}
74 retry: {count: 1, delay: 5}
75 skip_fail: false
76
77- description: Collect grains
78 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master' state.sls salt.minion.grains &&
79 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master' mine.flush &&
80 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master' mine.update &&
81 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm' saltutil.refresh_modules &&
82 sleep 10
83 node_name: {{ HOSTNAME_CFG01 }}
84 retry: {count: 3, delay: 15}
85 skip_fail: false
86
87- description: Install Docker Swarm on other nodes
88 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm' state.sls docker.swarm
89 node_name: {{ HOSTNAME_CFG01 }}
90 retry: {count: 2, delay: 5}
91 skip_fail: false
92
93- description: Show Docker Swarm nodes
94 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master' cmd.run 'docker node ls'
95 node_name: {{ HOSTNAME_CFG01 }}
96 retry: {count: 1, delay: 5}
97 skip_fail: false
98
99# Configure OSS services
100#-----------------------
101
102- description: Setup devops portal
103 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@devops_portal:config:enabled' state.sls devops_portal.config
104 node_name: {{ HOSTNAME_CFG01 }}
105 retry: {count: 1, delay: 5}
106 skip_fail: false
107
108- description: Setup Rundeck server
109 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@rundeck:server' state.sls rundeck.server
110 node_name: {{ HOSTNAME_CFG01 }}
111 retry: {count: 1, delay: 5}
112 skip_fail: false
113
114# Deploy Docker services
115#-----------------------
116
117# Original comment from pipeline: XXX: for some weird unknown reason, refresh_pillar is required to execute here
118
119- description: "Workaround from the pipeline: XXX: for some weird unknown reason, refresh_pillar is required to execute here"
120 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@aptly:publisher' saltutil.refresh_pillar
121 node_name: {{ HOSTNAME_CFG01 }}
122 retry: {count: 1, delay: 5}
123 skip_fail: false
124
125- 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]"
126 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@aptly:publisher' state.sls aptly.publisher
127 node_name: {{ HOSTNAME_CFG01 }}
Dennis Dmitriev8072d902017-09-21 18:29:42 +0300128 retry: {count: 2, delay: 5}
Dennis Dmitriev411dd102017-09-15 16:04:47 +0300129 skip_fail: false
130
131- description: Install Docker client
132 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master' state.sls docker.client
133 node_name: {{ HOSTNAME_CFG01 }}
134 retry: {count: 3, delay: 5}
135 skip_fail: false
136
137- description: "Workaround from the pipeline: sync all salt objects"
138 cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.sync_all && sleep 5
139 node_name: {{ HOSTNAME_CFG01 }}
140 retry: {count: 1, delay: 5}
141 skip_fail: false
142
143
144# Aptly
145#------
146
147- description: "Wait for Aptly to come up in container..."
148 cmd: timeout 300 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@aptly:server' cmd.run
149 'export CICD_CONTROL_ADDRESS=$(salt-call --out=newline_values_only pillar.get _param:cluster_vip_address);
150 while true; do curl -sf http://${CICD_CONTROL_ADDRESS}:8084/api/version && break; sleep 2; done'
151 node_name: {{ HOSTNAME_CFG01 }}
152 retry: {count: 3, delay: 15}
153 skip_fail: false
154
155- description: "Setup Aptly"
156 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@aptly:server' state.sls aptly
157 node_name: {{ HOSTNAME_CFG01 }}
158 retry: {count: 3, delay: 10}
159 skip_fail: false
160
161# OpenLDAP
162#---------
163
164- description: "Waiting for OpenLDAP to come up in container..."
165 cmd: timeout 60 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@openldap:client' cmd.run
166 'export CICD_CONTROL_ADDRESS=$(salt-call --out=newline_values_only pillar.get _param:cluster_vip_address);
167 while true; do curl -sf ldap://${CICD_CONTROL_ADDRESS} && break; sleep 2; done'
168 node_name: {{ HOSTNAME_CFG01 }}
169 retry: {count: 3, delay: 10}
170 skip_fail: false
171
172- description: "Setup OpenLDAP"
173 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@openldap:client' state.sls openldap &&
174 sleep 20
175 node_name: {{ HOSTNAME_CFG01 }}
176 retry: {count: 3, delay: 10}
177 skip_fail: false
178
179# Gerrit
180#-------
181
182- description: "Waiting for Gerrit to come up in container..."
183 cmd: timeout 60 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@gerrit:client' cmd.run
184 'export CICD_CONTROL_ADDRESS=$(salt-call --out=newline_values_only pillar.get _param:cluster_vip_address);
185 while true; do curl -sf http://${CICD_CONTROL_ADDRESS}:8080/config/server/version && break; sleep 2; done'
186 node_name: {{ HOSTNAME_CFG01 }}
187 retry: {count: 3, delay: 10}
188 skip_fail: false
189
190- description: "Setup Gerrit"
191 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@gerrit:client' state.sls gerrit
192 node_name: {{ HOSTNAME_CFG01 }}
193 retry: {count: 3, delay: 10}
194 skip_fail: false
195
196# Jenkins
197#--------
198
199- description: "Waiting for Jenkins to come up in container..."
200 cmd: timeout 60 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@jenkins:client' cmd.run
201 'export CICD_CONTROL_ADDRESS=$(salt-call --out=newline_values_only pillar.get _param:cluster_vip_address);
202 export JENKINS_CLIENT_USER=$(salt-call --out=newline_values_only pillar.get _param:jenkins_client_user);
203 export JENKINS_CLIENT_PASSWORD=$(salt-call --out=newline_values_only pillar.get _param:jenkins_client_password);
204 while true; do
205 curl -f -u ${JENKINS_CLIENT_USER}:${JENKINS_CLIENT_PASSWORD} http://${CICD_CONTROL_ADDRESS}:8081/api/json?pretty=true && break;
206 sleep 2;
207 done'
208 node_name: {{ HOSTNAME_CFG01 }}
209 retry: {count: 3, delay: 10}
210 skip_fail: false
211
212- description: "Setup Jenkins"
213 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@jenkins:client' state.sls jenkins
214 node_name: {{ HOSTNAME_CFG01 }}
215 retry: {count: 3, delay: 10}
216 skip_fail: false
217
218# Postgres && Pushkin
219#--------------------
220
221- description: "Waiting for postgresql database to come up in container..."
222# cmd: timeout 300 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@postgresql:client' cmd.run
223# 'while true; do if docker service logs postgresql_db | grep -q "ready to accept"; then break; else sleep 5; fi; done'
224 cmd: timeout 300 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@postgresql:client' cmd.run
225 'while true; do if docker service logs postgresql_postgresql-db | grep -q "ready to accept"; then break; else sleep 5; fi; done'
226 node_name: {{ HOSTNAME_CFG01 }}
227 retry: {count: 3, delay: 10}
228 skip_fail: false
229
230- description: ("Create PostgreSQL databases, it fails at first run because of known deadlock:\n"
231 "1. State postgresql.client cannot insert values into 'pushkin' database because it is created empty,\n"
232 "2. Container with Pushkin cannot start and fill the database scheme until state postgresql.client created users.")
233 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@postgresql:client' state.sls postgresql.client -b 1 &&
234 timeout 300 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@postgresql:client' cmd.run
235 'export CICD_CONTROL_ADDRESS=$(salt-call --out=newline_values_only pillar.get _param:cluster_vip_address);
236 while true; do curl -sf http://${CICD_CONTROL_ADDRESS}:8887/apps && break; sleep 2; done'
237 node_name: {{ HOSTNAME_CFG01 }}
238 retry: {count: 3, delay: 100}
239 skip_fail: false
240
241# Rundeck
242#--------
243
244- description: Waiting for Rundeck to come up in container...
245 cmd: timeout 30 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@rundeck:client' cmd.run
246 'export CICD_CONTROL_ADDRESS=$(salt-call --out=newline_values_only pillar.get _param:cluster_vip_address);
247 while true; do curl -sf http://${CICD_CONTROL_ADDRESS}:4440 && break; sleep 2; done'
248 node_name: {{ HOSTNAME_CFG01 }}
249 retry: {count: 3, delay: 10}
250 skip_fail: false
251
252- description: Setup Rundeck
253 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@rundeck:client' state.sls rundeck.client
254 node_name: {{ HOSTNAME_CFG01 }}
255 retry: {count: 3, delay: 10}
256 skip_fail: false
257
258# Elasticsearch
259#--------------
260
261- description: 'Waiting for Elasticsearch to come up in container...'
262 cmd: timeout 30 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@elasticsearch:client' cmd.run
263 'export CICD_CONTROL_ADDRESS=$(salt-call --out=newline_values_only pillar.get _param:cluster_vip_address);
264 while true; do curl -sf http://${CICD_CONTROL_ADDRESS}:9200/?pretty && break; sleep 2; done'
265 node_name: {{ HOSTNAME_CFG01 }}
266 retry: {count: 3, delay: 10}
267 skip_fail: false
268
269- description: Setup Elasticsearch
270 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@elasticsearch:client' state.sls elasticsearch.client
271 node_name: {{ HOSTNAME_CFG01 }}
272 retry: {count: 3, delay: 10}
273 skip_fail: false
274
275
276
277# Generate docs
278#--------------
279
280- description: Install sphinx (may fail depending on the model)
281 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@sphinx:server' state.sls sphinx
282 node_name: {{ HOSTNAME_CFG01 }}
283 retry: {count: 1, delay: 10}
284 skip_fail: true
285
286- description: Generate docs (may fail depending on the model)
287 cmd: salt-run state.orchestrate sphinx.orch.generate_doc
288 node_name: {{ HOSTNAME_CFG01 }}
289 retry: {count: 1, delay: 10}
290 skip_fail: true
291
292- description: Install nginx
293 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@nginx:server' state.sls nginx
294 node_name: {{ HOSTNAME_CFG01 }}
295 retry: {count: 3, delay: 10}
296 skip_fail: false
297
298# Final checks
299#-------------
300
301- description: Check for system services in failed state
302 cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' cmd.run "systemctl --failed | grep -E 'loaded[ \t]+failed' && echo 'Command execution failed' || true"
303 node_name: {{ HOSTNAME_CFG01 }}
304 retry: {count: 1, delay: 10}
305 skip_fail: false