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