blob: 1d323ba291a47cd134e13da3db204895966b0c6e [file] [log] [blame]
Oleksii Butenko87d00c02018-09-05 19:11:17 +03001{% from 'cookied-mcp-queens-dvr/underlay.yaml' import HOSTNAME_CFG01 with context %}
2{% import 'shared-sl-tests.yaml' as SHARED_SL_TESTS with context %}
3# Install docker swarm
4- description: Configure docker service
5 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm' state.sls docker.host
6 node_name: {{ HOSTNAME_CFG01 }}
7 retry: {count: 1, delay: 10}
8 skip_fail: false
9
10- description: Install docker swarm on master node
11 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master' state.sls docker.swarm
12 node_name: {{ HOSTNAME_CFG01 }}
13 retry: {count: 1, delay: 10}
14 skip_fail: false
15
16- description: Send grains to the swarm slave nodes
17 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm' state.sls salt.minion.grains
18 node_name: {{ HOSTNAME_CFG01 }}
19 retry: {count: 1, delay: 10}
20 skip_fail: false
21
22- description: Update mine
23 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm' mine.update
24 node_name: {{ HOSTNAME_CFG01 }}
25 retry: {count: 1, delay: 10}
26 skip_fail: false
27
28- description: Refresh modules
29 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm' saltutil.refresh_modules; sleep 5;
30 node_name: {{ HOSTNAME_CFG01 }}
31 retry: {count: 1, delay: 10}
32 skip_fail: false
33
34- description: Rerun swarm on slaves to proper token population
35 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master' state.sls docker.swarm
36 node_name: {{ HOSTNAME_CFG01 }}
37 retry: {count: 1, delay: 10}
38 skip_fail: false
39
40- description: Configure slave nodes
41 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:manager' state.sls docker.swarm -b 1
42 node_name: {{ HOSTNAME_CFG01 }}
43 retry: {count: 1, delay: 10}
44 skip_fail: false
45
46- description: List registered Docker swarm nodes
47 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master' cmd.run 'docker node ls'
48 node_name: {{ HOSTNAME_CFG01 }}
49 retry: {count: 1, delay: 10}
50 skip_fail: false
51
52- description: Install keepalived on mon nodes
53 cmd: salt --hard-crash --state-output=mixed --state-verbose=False
54 -C 'mon*' state.sls keepalived
55 node_name: {{ HOSTNAME_CFG01 }}
56 retry: {count: 1, delay: 10}
57 skip_fail: false
58
59- description: Check the VIP on mon nodes
60 cmd: |
61 SL_VIP=`salt-call --out=newline_values_only pillar.get _param:stacklight_monitor_address`;
62 echo "_param:stacklight_monitor_address (vip): ${SL_VIP}";
63 salt --hard-crash --state-output=mixed --state-verbose=False -C 'mon*' cmd.run "ip a | grep ${SL_VIP}" | grep -B1 ${SL_VIP}
64 node_name: {{ HOSTNAME_CFG01 }}
65 retry: {count: 1, delay: 5}
66 skip_fail: false
67
68# Install slv2 infra
69# Install MongoDB for alerta
70- description: Install Mongo if target matches
71 cmd: |
72 if salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@mongodb:server' match.pillar 'mongodb:server' ; then
73 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@mongodb:server' state.sls mongodb.server
74 fi
75 node_name: {{ HOSTNAME_CFG01 }}
76 retry: {count: 1, delay: 10}
77 skip_fail: false
78
79# Create MongoDB cluster
80- description: Install Mongo if target matches
81 cmd: |
82 if salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@mongodb:server' match.pillar 'mongodb:server' ; then
83 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@mongodb:server' state.sls mongodb.cluster
84 fi
85 node_name: {{ HOSTNAME_CFG01 }}
86 retry: {count: 5, delay: 20}
87 skip_fail: false
88
89- description: Install telegraf
90 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@telegraf:agent or I@telegraf:remote_agent' state.sls telegraf
91 node_name: {{ HOSTNAME_CFG01 }}
92 retry: {count: 2, delay: 10}
93 skip_fail: false
94
95- description: Configure Prometheus exporters, if pillar 'prometheus:exporters' exists on any server
96 cmd: |
97 if salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@prometheus:exporters' match.pillar 'prometheus:exporters' ; then
98 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@prometheus:exporters' state.sls prometheus
99 fi
100 node_name: {{ HOSTNAME_CFG01 }}
101 retry: {count: 1, delay: 10}
102 skip_fail: false
103
104- description: Install elasticsearch server
105 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@elasticsearch:server' state.sls elasticsearch.server -b 1
106 node_name: {{ HOSTNAME_CFG01 }}
107 retry: {count: 1, delay: 10}
108 skip_fail: false
109
110- description: Install kibana server
111 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@kibana:server' state.sls kibana.server -b 1
112 node_name: {{ HOSTNAME_CFG01 }}
113 retry: {count: 1, delay: 10}
114 skip_fail: false
115
116- description: Install elasticsearch client
117 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@elasticsearch:client' state.sls elasticsearch.client
118 node_name: {{ HOSTNAME_CFG01 }}
119 retry: {count: 2, delay: 30}
120 skip_fail: false
121
122- description: Install kibana client
123 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@kibana:client' state.sls kibana.client
124 node_name: {{ HOSTNAME_CFG01 }}
125 retry: {count: 1, delay: 10}
126 skip_fail: false
127
128- description: Check influix db
129 cmd: |
130 INFLUXDB_SERVICE=`salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@influxdb:server' test.ping 1>/dev/null 2>&1 && echo true`;
131 echo "Influxdb service presence: ${INFLUXDB_SERVICE}";
132 if [[ "$INFLUXDB_SERVICE" == "true" ]]; then
133 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@influxdb:server' state.sls influxdb
134 fi
135 node_name: {{ HOSTNAME_CFG01 }}
136 retry: {count: 1, delay: 5}
137 skip_fail: true
138
139# Install Prometheus LTS(optional if set in model)
140- description: Prometheus LTS(optional if set in model)
141 cmd: |
142 PROMETHEUS_SERVICE=`salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@prometheus:relay' test.ping 1>/dev/null 2>&1 && echo true`;
143 echo "PROMETHEUS rely service presence: ${PROMETHEUS_SERVICE}";
144 if [[ "$PROMETHEUS_SERVICE" == "true" ]]; then
145 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@prometheus:relay' state.sls prometheus
146 fi
147 node_name: {{ HOSTNAME_CFG01 }}
148 retry: {count: 1, delay: 5}
149 skip_fail: true
150
151# Install service for the log collection
152- description: Configure fluentd
153 cmd: |
154 FLUENTD_SERVICE=`salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@fluentd:agent' test.ping 1>/dev/null 2>&1 && echo true`;
155 echo "Fluentd service presence: ${FLUENTD_SERVICE}";
156 if [[ "$FLUENTD_SERVICE" == "true" ]]; then
157 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@fluentd:agent' state.sls fluentd
158 else
159 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@heka:log_collector' state.sls heka.log_collector
160 fi
161 node_name: {{ HOSTNAME_CFG01 }}
162 retry: {count: 1, delay: 10}
163 skip_fail: false
164
165#Install heka ceilometer collector
166- description: Install heka ceilometer if they exists
167 cmd: |
168 CEILO=`salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@heka:ceilometer_collector:enabled' test.ping 1>/dev/null 2>&1 && echo true`;
169 echo "Ceilometer service presence: ${CEILO}";
170 if [[ "$CEILO" == "true" ]]; then
171 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@heka:ceilometer_collector:enabled' state.sls heka.ceilometer_collector;
172 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@heka:ceilometer_collector:enabled' service.restart ceilometer_collector
173 fi
174 node_name: {{ HOSTNAME_CFG01 }}
175 retry: {count: 1, delay: 10}
176 skip_fail: false
177
178# Collect grains needed to configure the services
179
180- description: Get grains
181 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@salt:minion' state.sls salt.minion.grains
182 node_name: {{ HOSTNAME_CFG01 }}
183 retry: {count: 1, delay: 10}
184 skip_fail: false
185
186- description: Sync modules
187 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@salt:minion' saltutil.refresh_modules
188 node_name: {{ HOSTNAME_CFG01 }}
189 retry: {count: 1, delay: 10}
190 skip_fail: false
191
192- description: Update mine
193 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@salt:minion' mine.update; sleep 5;
194 node_name: {{ HOSTNAME_CFG01 }}
195 retry: {count: 5, delay: 15}
196 skip_fail: false
197
198# Configure the services running in Docker Swarm
199- description: Configure prometheus in docker swarm
200 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm and I@prometheus:server' state.sls prometheus,heka.remote_collector
201 node_name: {{ HOSTNAME_CFG01 }}
202 retry: {count: 1, delay: 10}
203 skip_fail: false
204
205#Launch containers
206- description: launch prometheus containers
207 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master and I@prometheus:server' state.sls docker.client
208 node_name: {{ HOSTNAME_CFG01 }}
209 retry: {count: 2, delay: 10}
210 skip_fail: false
211
212- description: Check docker ps
213 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm and I@prometheus:server' cmd.run "docker ps"
214 node_name: {{ HOSTNAME_CFG01 }}
215 retry: {count: 2, delay: 10}
216 skip_fail: false
217
218- description: Install sphinx
219 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@sphinx:server' state.sls sphinx
220 node_name: {{ HOSTNAME_CFG01 }}
221 retry: {count: 1, delay: 10}
222 skip_fail: false
223
224
225#- description: Install prometheus alertmanager
226# cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm' state.sls prometheus,heka.remote_collector -b 1
227# node_name: {{ HOSTNAME_CFG01 }}
228# retry: {count: 1, delay: 10}
229# skip_fail: false
230
231#- description: run docker state
232# cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master' state.sls docker
233# node_name: {{ HOSTNAME_CFG01 }}
234# retry: {count: 1, delay: 10}
235# skip_fail: false
236#
237#- description: docker ps
238# cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm' dockerng.ps
239# node_name: {{ HOSTNAME_CFG01 }}
240# retry: {count: 1, delay: 10}
241# skip_fail: false
242
243- description: Configure Grafana dashboards and datasources
244 cmd: sleep 30; salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@grafana:client' state.sls grafana.client
245 node_name: {{ HOSTNAME_CFG01 }}
246 retry: {count: 2, delay: 10}
247 skip_fail: false
248
249- description: Run salt minion to create cert files
250 cmd: salt --hard-crash --state-output=mixed --state-verbose=False "*" state.sls salt.minion
251 node_name: {{ HOSTNAME_CFG01 }}
252 retry: {count: 1, delay: 10}
253 skip_fail: false
254
255{{ SHARED_SL_TESTS.MACRO_CLONE_SL_TESTS() }}
256{{ SHARED_SL_TESTS.MACRO_CONFIGURE_TESTS() }}