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