blob: df0fbae5c678800d1929d5113fb7f8110078484b [file] [log] [blame]
abaraniuk68c7f7c2018-08-06 16:06:29 +03001{% from 'cookied-bm-contrail40-nfv/underlay.yaml' import HOSTNAME_CFG01 with context %}
2
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: 3, 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: 2, 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: 3, 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#Launch containers
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
74 fi
75 node_name: {{ HOSTNAME_CFG01 }}
76 retry: {count: 4, delay: 40}
77 skip_fail: false
78
79- description: Configure Alerta if it is exists
80 cmd: |
81 if salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@prometheus:alerta' match.pillar 'prometheus:alerta' ; then
82 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm and I@prometheus:alerta' state.sls prometheus.alerta
83 fi
84 node_name: {{ HOSTNAME_CFG01 }}
85 retry: {count: 4, delay: 10}
86 skip_fail: false
87
88- description: launch prometheus containers
89 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master and I@prometheus:server' state.sls docker.client
90 node_name: {{ HOSTNAME_CFG01 }}
91 retry: {count: 2, delay: 10}
92 skip_fail: false
93
94- description: Check docker ps
95 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm and I@prometheus:server' cmd.run "docker ps"
96 node_name: {{ HOSTNAME_CFG01 }}
97 retry: {count: 2, delay: 10}
98 skip_fail: false
99
100- description: Install telegraf
101 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@telegraf:agent or I@telegraf:remote_agent' state.sls telegraf
102 node_name: {{ HOSTNAME_CFG01 }}
103 retry: {count: 2, delay: 10}
104 skip_fail: false
105
106- description: Configure Prometheus exporters, if pillar 'prometheus:exporters' exists on any server
107 cmd: |
108 if salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@prometheus:exporters' match.pillar 'prometheus:exporters' ; then
109 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@prometheus:exporters' state.sls prometheus
110 fi
111 node_name: {{ HOSTNAME_CFG01 }}
112 retry: {count: 1, delay: 10}
113 skip_fail: false
114
115- description: Configure Prometheus exporters, if pillar 'prometheus:collector' exists on any server
116 cmd: |
117 if salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@prometheus:collector' match.pillar 'prometheus:collector' ; then
118 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@prometheus:collector' state.sls prometheus.collector
119 fi
120 node_name: {{ HOSTNAME_CFG01 }}
121 retry: {count: 1, delay: 10}
122 skip_fail: false
123
124- description: Install elasticsearch server
125 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@elasticsearch:server' state.sls elasticsearch.server -b 1
126 node_name: {{ HOSTNAME_CFG01 }}
127 retry: {count: 1, delay: 10}
128 skip_fail: false
129
130- description: Install kibana server
131 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@kibana:server' state.sls kibana.server -b 1
132 node_name: {{ HOSTNAME_CFG01 }}
133 retry: {count: 1, delay: 10}
134 skip_fail: false
135
136- description: Install elasticsearch client
137 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@elasticsearch:client' state.sls elasticsearch.client
138 node_name: {{ HOSTNAME_CFG01 }}
139 retry: {count: 2, delay: 30}
140 skip_fail: false
141
142- description: Install kibana client
143 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@kibana:client' state.sls kibana.client
144 node_name: {{ HOSTNAME_CFG01 }}
145 retry: {count: 1, delay: 10}
146 skip_fail: false
147
148- description: Check influix db
149 cmd: |
150 INFLUXDB_SERVICE=`salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@influxdb:server' test.ping 1>/dev/null 2>&1 && echo true`;
151 echo "Influxdb service presence: ${INFLUXDB_SERVICE}";
152 if [[ "$INFLUXDB_SERVICE" == "true" ]]; then
153 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@influxdb:server' state.sls influxdb
154 fi
155 node_name: {{ HOSTNAME_CFG01 }}
156 retry: {count: 1, delay: 5}
157 skip_fail: true
158
159# Install Prometheus LTS(optional if set in model)
160- description: Prometheus LTS(optional if set in model)
161 cmd: |
162 PROMETHEUS_SERVICE=`salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@prometheus:relay' test.ping 1>/dev/null 2>&1 && echo true`;
163 echo "PROMETHEUS rely service presence: ${PROMETHEUS_SERVICE}";
164 if [[ "$PROMETHEUS_SERVICE" == "true" ]]; then
165 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@prometheus:relay' state.sls prometheus
166 fi
167 node_name: {{ HOSTNAME_CFG01 }}
168 retry: {count: 1, delay: 5}
169 skip_fail: true
170
171# Install service for the log collection
172- description: Configure fluentd
173 cmd: |
174 FLUENTD_SERVICE=`salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@fluentd:agent' test.ping 1>/dev/null 2>&1 && echo true`;
175 echo "Fluentd service presence: ${FLUENTD_SERVICE}";
176 if [[ "$FLUENTD_SERVICE" == "true" ]]; then
177 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@fluentd:agent' state.sls fluentd
178 else
179 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@heka:log_collector' state.sls heka.log_collector
180 fi
181 node_name: {{ HOSTNAME_CFG01 }}
182 retry: {count: 1, delay: 10}
183 skip_fail: false
184
185#Install heka ceilometer collector
186- description: Install heka ceilometer if they exists
187 cmd: |
188 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`;
189 echo "Ceilometer service presence: ${CEILO}";
190 if [[ "$CEILO" == "true" ]]; then
191 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@heka:ceilometer_collector:enabled' state.sls heka.ceilometer_collector;
192 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@heka:ceilometer_collector:enabled' service.restart ceilometer_collector
193 fi
194 node_name: {{ HOSTNAME_CFG01 }}
195 retry: {count: 1, delay: 10}
196 skip_fail: false
197
198# Collect grains needed to configure the services
199
200- description: Get grains
201 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@salt:minion' state.sls salt.minion.grains
202 node_name: {{ HOSTNAME_CFG01 }}
203 retry: {count: 1, delay: 10}
204 skip_fail: false
205
206- description: Sync modules
207 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@salt:minion' saltutil.refresh_modules
208 node_name: {{ HOSTNAME_CFG01 }}
209 retry: {count: 1, delay: 10}
210 skip_fail: false
211
212- description: Update mine
213 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@salt:minion' mine.update; sleep 5;
214 node_name: {{ HOSTNAME_CFG01 }}
215 retry: {count: 5, delay: 15}
216 skip_fail: false
217
218# Configure the services running in Docker Swarm
219- description: Configure prometheus in docker swarm
220 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm and I@prometheus:server' state.sls prometheus
221 node_name: {{ HOSTNAME_CFG01 }}
222 retry: {count: 1, delay: 10}
223 skip_fail: false
224
225- description: Configure Remote Collector in Docker Swarm for Openstack deployments
226 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm and I@prometheus:server' state.sls heka.remote_collector
227 node_name: {{ HOSTNAME_CFG01 }}
228 retry: {count: 1, delay: 10}
229 skip_fail: false
230
231- description: Install sphinx
232 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@sphinx:server' state.sls sphinx
233 node_name: {{ HOSTNAME_CFG01 }}
234 retry: {count: 1, delay: 10}
235 skip_fail: false
236
237
238#- description: Install prometheus alertmanager
239# cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm' state.sls prometheus,heka.remote_collector -b 1
240# node_name: {{ HOSTNAME_CFG01 }}
241# retry: {count: 1, delay: 10}
242# skip_fail: false
243
244#- description: run docker state
245# cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master' state.sls docker
246# node_name: {{ HOSTNAME_CFG01 }}
247# retry: {count: 1, delay: 10}
248# skip_fail: false
249#
250#- description: docker ps
251# cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm' dockerng.ps
252# node_name: {{ HOSTNAME_CFG01 }}
253# retry: {count: 1, delay: 10}
254# skip_fail: false
255
256- description: Configure Grafana dashboards and datasources
257 cmd: sleep 30; salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@grafana:client' state.sls grafana.client
258 node_name: {{ HOSTNAME_CFG01 }}
259 retry: {count: 2, delay: 10}
260 skip_fail: false
261
262- description: Run salt minion to create cert files
263 cmd: salt --hard-crash --state-output=mixed --state-verbose=False "*" state.sls salt.minion
264 node_name: {{ HOSTNAME_CFG01 }}
265 retry: {count: 3, delay: 15}
266 skip_fail: false