blob: af678dc7b5f49e8b8ebca95ede95345aed9387f4 [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
80- description: Setup salt-minion on docker swarm master
81 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master and {{ CICD_NODES_SELECTOR }}' state.sls salt &&
82 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master and {{ CICD_NODES_SELECTOR }}' mine.flush &&
83 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master and {{ CICD_NODES_SELECTOR }}' mine.update
84 node_name: {{ HOSTNAME_CFG01 }}
85 retry: {count: 3, delay: 15}
86 skip_fail: false
87
88- description: Install Docker Swarm on other nodes
89 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm and {{ CICD_NODES_SELECTOR }}' state.sls docker.swarm
90 node_name: {{ HOSTNAME_CFG01 }}
91 retry: {count: 1, delay: 5}
92 skip_fail: false
93
94- description: Show Docker Swarm nodes
95 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'
96 node_name: {{ HOSTNAME_CFG01 }}
97 retry: {count: 1, delay: 5}
98 skip_fail: false
99
100# Configure OSS services
101#-----------------------
102
103- description: Setup devops portal
104 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@devops_portal:config:enabled' state.sls devops_portal.config
105 node_name: {{ HOSTNAME_CFG01 }}
106 retry: {count: 1, delay: 5}
107 skip_fail: false
108
109- description: Setup Rundeck server
110 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@rundeck:server' state.sls rundeck.server
111 node_name: {{ HOSTNAME_CFG01 }}
112 retry: {count: 1, delay: 5}
113 skip_fail: false
114
115# Deploy Docker services
116#-----------------------
117
118# Original comment from pipeline: XXX: for some weird unknown reason, refresh_pillar is required to execute here
119
120- description: "Workaround from the pipeline: XXX: for some weird unknown reason, refresh_pillar is required to execute here"
121 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@aptly:publisher' saltutil.refresh_pillar
122 node_name: {{ HOSTNAME_CFG01 }}
123 retry: {count: 1, delay: 5}
124 skip_fail: false
125
126- 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]"
127 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@aptly:publisher' state.sls aptly.publisher
128 node_name: {{ HOSTNAME_CFG01 }}
129 retry: {count: 1, delay: 5}
130 skip_fail: false
131
132- description: Install Docker client
Dennis Dmitrievf8546172017-07-20 21:57:05 +0300133 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 +0300134 node_name: {{ HOSTNAME_CFG01 }}
135 retry: {count: 3, delay: 5}
136 skip_fail: false
137
138- description: "Workaround from the pipeline: sync all salt objects"
139 cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.sync_all
140 node_name: {{ HOSTNAME_CFG01 }}
141 retry: {count: 1, delay: 5}
142 skip_fail: false
143
144
145# Aptly
146#------
147
Dennis Dmitrievf8546172017-07-20 21:57:05 +0300148- description: "Install Aptly and check it's API"
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300149 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@aptly:server' state.sls aptly &&
150 timeout 90 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@aptly:server' cmd.run
151 'export CICD_CONTROL_ADDRESS=$(salt-call --out=newline_values_only pillar.get _param:cicd_control_address);
152 while true; do curl -sf http://${CICD_CONTROL_ADDRESS}:8084/api/version && break; sleep 2; done'
153 node_name: {{ HOSTNAME_CFG01 }}
154 retry: {count: 3, delay: 10}
155 skip_fail: false
156
157# OpenLDAP
158#---------
159
Dennis Dmitrievf8546172017-07-20 21:57:05 +0300160- description: "Install LDAP and check it's availability"
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300161 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@openldap:client' state.sls openldap &&
162 timeout 60 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@openldap:client' cmd.run
163 'export CICD_CONTROL_ADDRESS=$(salt-call --out=newline_values_only pillar.get _param:cicd_control_address);
164 while true; do curl -sf ldap://${CICD_CONTROL_ADDRESS} >/dev/null && break; sleep 2; done' &&
165 sleep 20
166 node_name: {{ HOSTNAME_CFG01 }}
167 retry: {count: 3, delay: 10}
168 skip_fail: false
169
170# Gerrit
171#-------
172
Dennis Dmitrievf8546172017-07-20 21:57:05 +0300173- description: "Install Gerrit and check it's availability"
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300174 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@gerrit:client' state.sls gerrit &&
175 timeout 60 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@gerrit:client' cmd.run
176 'export CICD_CONTROL_ADDRESS=$(salt-call --out=newline_values_only pillar.get _param:cicd_control_address);
177 while true; do curl -sf http://${CICD_CONTROL_ADDRESS}:8080 >/dev/null && break; sleep 2; done'
178 node_name: {{ HOSTNAME_CFG01 }}
179 retry: {count: 3, delay: 10}
180 skip_fail: false
181
182# Jenkins
183#--------
184
185
Dennis Dmitrievf8546172017-07-20 21:57:05 +0300186- description: "Install Jenkins and check it's availability"
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300187 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@jenkins:client' state.sls jenkins &&
188 timeout 60 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@jenkins:client' cmd.run
189 'export CICD_CONTROL_ADDRESS=$(salt-call --out=newline_values_only pillar.get _param:cicd_control_address);
Dennis Dmitrievf8546172017-07-20 21:57:05 +0300190 export JENKINS_CLIENT_USER=$(salt-call --out=newline_values_only pillar.get _param:jenkins_client_user);
191 export JENKINS_CLIENT_PASSWORD=$(salt-call --out=newline_values_only pillar.get _param:jenkins_client_password);
192 while true; do
193 curl -f -u ${JENKINS_CLIENT_USER}:${JENKINS_CLIENT_PASSWORD} http://${CICD_CONTROL_ADDRESS}:8081/api/json?pretty=true && break;
194 sleep 2;
195 done'
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300196 node_name: {{ HOSTNAME_CFG01 }}
197 retry: {count: 3, delay: 10}
198 skip_fail: false
199
200# Postgres
201#---------
202
203- description: Install PostgreSQL and create databases
204 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@postgresql:client' state.sls postgresql.client -b 1&&
205 timeout 300 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@postgresql:client' cmd.run
206 'while true; do if docker service logs postgresql_db | grep -q "ready to accept"; then break; else sleep 5; fi; done'
207 node_name: {{ HOSTNAME_CFG01 }}
208 retry: {count: 3, delay: 10}
209 skip_fail: false
210
211# Pushkin
212#--------
213
214- description: Check Pushkin API availability
215 cmd: timeout 60 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@postgresql:client' cmd.run
216 'export CICD_CONTROL_ADDRESS=$(salt-call --out=newline_values_only pillar.get _param:cicd_control_address);
Dennis Dmitrievf8546172017-07-20 21:57:05 +0300217 while true; do curl -sf http://${CICD_CONTROL_ADDRESS}:8887/apps && break; sleep 2; done'
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300218 node_name: {{ HOSTNAME_CFG01 }}
219 retry: {count: 1, delay: 10}
220 skip_fail: false
221
222# Rundeck
223#--------
224
225- description: Install Rundeck and check availability
226 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@rundeck:client' state.sls rundeck.client &&
227 timeout 30 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@rundeck:client' cmd.run
228 'export CICD_CONTROL_ADDRESS=$(salt-call --out=newline_values_only pillar.get _param:cicd_control_address);
229 while true; do curl -sf http://${CICD_CONTROL_ADDRESS}:4440 && break; sleep 2; done'
230 node_name: {{ HOSTNAME_CFG01 }}
231 retry: {count: 3, delay: 10}
232 skip_fail: false
233
234# Generate docs
235#--------------
236
237- description: Install sphinx (may fail depending on the model)
238 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@sphinx:server' state.sls sphinx
239 node_name: {{ HOSTNAME_CFG01 }}
240 retry: {count: 1, delay: 10}
241 skip_fail: true
242
243- description: Generate docs (may fail depending on the model)
244 cmd: salt-run state.orchestrate sphinx.orch.generate_doc
245 node_name: {{ HOSTNAME_CFG01 }}
246 retry: {count: 1, delay: 10}
247 skip_fail: true
248
249- description: Install nginx
250 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@nginx:server' state.sls nginx
251 node_name: {{ HOSTNAME_CFG01 }}
252 retry: {count: 3, delay: 10}
253 skip_fail: false
254
255# Final checks
256#-------------
257
258- description: Check for system services in failed state
259 cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' cmd.run "systemctl --failed | grep -E 'loaded[ \t]+failed' && echo 'Command execution failed' || true"
260 node_name: {{ HOSTNAME_CFG01 }}
261 retry: {count: 1, delay: 10}
262 skip_fail: false