blob: 52bf89069fecaadbe833819caeed2c1926a14754 [file] [log] [blame]
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +03001{% from 'virtual-mcp11-k8s-calico/underlay.yaml' import HOSTNAME_CFG01 with context %}
Victor Ryzhenkin2a2cd8e2018-05-07 18:38:43 +04002{% from 'virtual-mcp11-k8s-calico/salt.yaml' import ENVIRONMENT_MODEL_INVENTORY_NAME with context %}
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +03003
4# Install docker swarm
Tatyana Leontovich5acc82a2017-05-23 15:41:35 +03005- description: Configure docker service
Dennis Dmitriev281221b2018-02-13 16:40:48 +02006 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm' state.sls docker.host
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +03007 node_name: {{ HOSTNAME_CFG01 }}
8 retry: {count: 1, delay: 10}
Tatyana Leontovich5acc82a2017-05-23 15:41:35 +03009 skip_fail: false
10
11- description: Install docker swarm on master node
Dennis Dmitriev281221b2018-02-13 16:40:48 +020012 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master' state.sls docker.swarm
Tatyana Leontovich5acc82a2017-05-23 15:41:35 +030013 node_name: {{ HOSTNAME_CFG01 }}
14 retry: {count: 1, delay: 10}
15 skip_fail: false
16
17- description: Send grains to the swarm slave nodes
Dennis Dmitriev281221b2018-02-13 16:40:48 +020018 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm' state.sls salt.minion.grains
Tatyana Leontovich5acc82a2017-05-23 15:41:35 +030019 node_name: {{ HOSTNAME_CFG01 }}
20 retry: {count: 1, delay: 10}
21 skip_fail: false
22
23- description: Update mine
Dennis Dmitriev281221b2018-02-13 16:40:48 +020024 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm' mine.update
Tatyana Leontovich5acc82a2017-05-23 15:41:35 +030025 node_name: {{ HOSTNAME_CFG01 }}
26 retry: {count: 1, delay: 10}
27 skip_fail: false
28
29- description: Refresh modules
Dennis Dmitriev281221b2018-02-13 16:40:48 +020030 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm' saltutil.refresh_modules; sleep 5;
Tatyana Leontovich5acc82a2017-05-23 15:41:35 +030031 node_name: {{ HOSTNAME_CFG01 }}
32 retry: {count: 1, delay: 10}
33 skip_fail: false
34
Tatyana Leontovich2fec09a2017-08-22 13:52:11 +030035- description: Rerun swarm on slaves to proper token population
Dennis Dmitriev281221b2018-02-13 16:40:48 +020036 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master' state.sls docker.swarm
Tatyana Leontovich2fec09a2017-08-22 13:52:11 +030037 node_name: {{ HOSTNAME_CFG01 }}
38 retry: {count: 1, delay: 10}
39 skip_fail: false
40
Tatyana Leontovich5acc82a2017-05-23 15:41:35 +030041- description: Configure slave nodes
Dennis Dmitriev281221b2018-02-13 16:40:48 +020042 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:manager' state.sls docker.swarm -b 1
Tatyana Leontovich5acc82a2017-05-23 15:41:35 +030043 node_name: {{ HOSTNAME_CFG01 }}
44 retry: {count: 1, delay: 10}
45 skip_fail: false
46
47- description: List registered Docker swarm nodes
Dennis Dmitriev281221b2018-02-13 16:40:48 +020048 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master' cmd.run 'docker node ls'
Tatyana Leontovich5acc82a2017-05-23 15:41:35 +030049 node_name: {{ HOSTNAME_CFG01 }}
50 retry: {count: 1, delay: 10}
51 skip_fail: false
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +030052
Victor Ryzhenkin2a2cd8e2018-05-07 18:38:43 +040053- description: Install keepalived on mon nodes
54 cmd: salt --hard-crash --state-output=mixed --state-verbose=False
55 -C 'mon*' state.sls keepalived
56 node_name: {{ HOSTNAME_CFG01 }}
57 retry: {count: 1, delay: 10}
58 skip_fail: false
59
60- description: Check the VIP on mon nodes
61 cmd: |
62 SL_VIP=`salt-call --out=newline_values_only pillar.get _param:stacklight_monitor_address`;
63 echo "_param:stacklight_monitor_address (vip): ${SL_VIP}";
64 salt --hard-crash --state-output=mixed --state-verbose=False -C 'mon*' cmd.run "ip a | grep ${SL_VIP}" | grep -B1 ${SL_VIP}
65 node_name: {{ HOSTNAME_CFG01 }}
66 retry: {count: 1, delay: 5}
67 skip_fail: false
68
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +030069# Install slv2 infra
Dennis Dmitriev371ba5b2018-05-31 12:00:38 +000070# Install MongoDB for alerta
Tatyana Leontovich48a6af92018-06-04 15:16:20 +030071- description: Install Mongo if target matches
72 cmd: |
73 if salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@mongodb:server' match.pillar 'mongodb:server' ; then
74 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@mongodb:server' state.sls mongodb
75 fi
Dennis Dmitriev371ba5b2018-05-31 12:00:38 +000076 node_name: {{ HOSTNAME_CFG01 }}
Tatyana Leontovich48a6af92018-06-04 15:16:20 +030077 retry: {count: 1, delay: 10}
78 skip_fail: false
79
80- description: Configure Alerta if it is exists
81 cmd: |
82 if salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@prometheus:alerta' match.pillar 'prometheus:alerta' ; then
83 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm and I@prometheus:alerta' state.sls prometheus.alerta
84 fi
85 node_name: {{ HOSTNAME_CFG01 }}
86 retry: {count: 1, delay: 10}
Dennis Dmitriev371ba5b2018-05-31 12:00:38 +000087 skip_fail: false
88
Victor Ryzhenkin2a2cd8e2018-05-07 18:38:43 +040089#Launch containers
90- description: launch prometheus containers
91 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master and I@prometheus:server' state.sls docker.client
92 node_name: {{ HOSTNAME_CFG01 }}
93 retry: {count: 2, delay: 10}
94 skip_fail: false
95
96- description: Check docker ps
97 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm and I@prometheus:server' cmd.run "docker ps"
98 node_name: {{ HOSTNAME_CFG01 }}
99 retry: {count: 2, delay: 10}
100 skip_fail: false
101
Tatyana Leontovich5acc82a2017-05-23 15:41:35 +0300102- description: Install telegraf
Dennis Dmitriev281221b2018-02-13 16:40:48 +0200103 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@telegraf:agent or I@telegraf:remote_agent' state.sls telegraf
Tatyana Leontovichf00b2342017-07-04 18:26:25 +0300104 node_name: {{ HOSTNAME_CFG01 }}
Tatyana Leontovich2fec09a2017-08-22 13:52:11 +0300105 retry: {count: 2, delay: 10}
106 skip_fail: false
107
Dennis Dmitrievcc6e9b52017-09-01 11:27:58 +0300108- description: Configure Prometheus exporters, if pillar 'prometheus:exporters' exists on any server
109 cmd: |
Dennis Dmitriev281221b2018-02-13 16:40:48 +0200110 if salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@prometheus:exporters' match.pillar 'prometheus:exporters' ; then
111 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@prometheus:exporters' state.sls prometheus
Dennis Dmitrievcc6e9b52017-09-01 11:27:58 +0300112 fi
Tatyana Leontovich2fec09a2017-08-22 13:52:11 +0300113 node_name: {{ HOSTNAME_CFG01 }}
Tatyana Leontovichf00b2342017-07-04 18:26:25 +0300114 retry: {count: 1, delay: 10}
115 skip_fail: false
116
Tatyana Leontovich5acc82a2017-05-23 15:41:35 +0300117- description: Install elasticsearch server
Dennis Dmitriev281221b2018-02-13 16:40:48 +0200118 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@elasticsearch:server' state.sls elasticsearch.server -b 1
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +0300119 node_name: {{ HOSTNAME_CFG01 }}
120 retry: {count: 1, delay: 10}
Tatyana Leontovich5acc82a2017-05-23 15:41:35 +0300121 skip_fail: false
122
123- description: Install kibana server
Dennis Dmitriev281221b2018-02-13 16:40:48 +0200124 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@kibana:server' state.sls kibana.server -b 1
Tatyana Leontovich5acc82a2017-05-23 15:41:35 +0300125 node_name: {{ HOSTNAME_CFG01 }}
126 retry: {count: 1, delay: 10}
127 skip_fail: false
128
Tatyana Leontovich5acc82a2017-05-23 15:41:35 +0300129- description: Install elasticsearch client
Dennis Dmitriev281221b2018-02-13 16:40:48 +0200130 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@elasticsearch:client' state.sls elasticsearch.client
Tatyana Leontovich5acc82a2017-05-23 15:41:35 +0300131 node_name: {{ HOSTNAME_CFG01 }}
Dennis Dmitriev4ad63e42018-05-01 05:18:54 +0300132 retry: {count: 2, delay: 30}
Tatyana Leontovich5acc82a2017-05-23 15:41:35 +0300133 skip_fail: false
134
135- description: Install kibana client
Dennis Dmitriev281221b2018-02-13 16:40:48 +0200136 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@kibana:client' state.sls kibana.client
Tatyana Leontovich5acc82a2017-05-23 15:41:35 +0300137 node_name: {{ HOSTNAME_CFG01 }}
138 retry: {count: 1, delay: 10}
139 skip_fail: false
140
Tatyana Leontovich3645d2b2017-06-13 16:51:23 +0300141- description: Check influix db
142 cmd: |
Dennis Dmitriev281221b2018-02-13 16:40:48 +0200143 INFLUXDB_SERVICE=`salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@influxdb:server' test.ping 1>/dev/null 2>&1 && echo true`;
Tatyana Leontovich3645d2b2017-06-13 16:51:23 +0300144 echo "Influxdb service presence: ${INFLUXDB_SERVICE}";
145 if [[ "$INFLUXDB_SERVICE" == "true" ]]; then
Dennis Dmitriev281221b2018-02-13 16:40:48 +0200146 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@influxdb:server' state.sls influxdb
Tatyana Leontovich3645d2b2017-06-13 16:51:23 +0300147 fi
148 node_name: {{ HOSTNAME_CFG01 }}
149 retry: {count: 1, delay: 5}
150 skip_fail: true
151
Victor Ryzhenkin2a2cd8e2018-05-07 18:38:43 +0400152# Install Prometheus LTS(optional if set in model)
153- description: Prometheus LTS(optional if set in model)
154 cmd: |
155 PROMETHEUS_SERVICE=`salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@prometheus:relay' test.ping 1>/dev/null 2>&1 && echo true`;
156 echo "PROMETHEUS rely service presence: ${PROMETHEUS_SERVICE}";
157 if [[ "$PROMETHEUS_SERVICE" == "true" ]]; then
158 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@prometheus:relay' state.sls prometheus
159 fi
160 node_name: {{ HOSTNAME_CFG01 }}
161 retry: {count: 1, delay: 5}
162 skip_fail: true
163
164# Install service for the log collection
165- description: Configure fluentd
166 cmd: |
167 FLUENTD_SERVICE=`salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@fluentd:agent' test.ping 1>/dev/null 2>&1 && echo true`;
168 echo "Fluentd service presence: ${FLUENTD_SERVICE}";
169 if [[ "$FLUENTD_SERVICE" == "true" ]]; then
170 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@fluentd:agent' state.sls fluentd
171 else
172 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@heka:log_collector' state.sls heka.log_collector
173 fi
174 node_name: {{ HOSTNAME_CFG01 }}
175 retry: {count: 1, delay: 10}
176 skip_fail: false
177
178#Install heka ceilometer collector
179- description: Install heka ceilometer if they exists
180 cmd: |
181 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`;
182 echo "Ceilometer service presence: ${CEILO}";
183 if [[ "$CEILO" == "true" ]]; then
184 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@heka:ceilometer_collector:enabled' state.sls heka.ceilometer_collector;
185 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@heka:ceilometer_collector:enabled' service.restart ceilometer_collector
186 fi
187 node_name: {{ HOSTNAME_CFG01 }}
188 retry: {count: 1, delay: 10}
189 skip_fail: false
190
Tatyana Leontovich5acc82a2017-05-23 15:41:35 +0300191# Collect grains needed to configure the services
192
193- description: Get grains
Dennis Dmitriev281221b2018-02-13 16:40:48 +0200194 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@salt:minion' state.sls salt.minion.grains
Tatyana Leontovich5acc82a2017-05-23 15:41:35 +0300195 node_name: {{ HOSTNAME_CFG01 }}
196 retry: {count: 1, delay: 10}
197 skip_fail: false
198
199- description: Sync modules
Dennis Dmitriev281221b2018-02-13 16:40:48 +0200200 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@salt:minion' saltutil.refresh_modules
Tatyana Leontovich5acc82a2017-05-23 15:41:35 +0300201 node_name: {{ HOSTNAME_CFG01 }}
202 retry: {count: 1, delay: 10}
203 skip_fail: false
204
205- description: Update mine
Dennis Dmitriev281221b2018-02-13 16:40:48 +0200206 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@salt:minion' mine.update; sleep 5;
Tatyana Leontovich5acc82a2017-05-23 15:41:35 +0300207 node_name: {{ HOSTNAME_CFG01 }}
Victor Ryzhenkin2a2cd8e2018-05-07 18:38:43 +0400208 retry: {count: 5, delay: 15}
Tatyana Leontovich5acc82a2017-05-23 15:41:35 +0300209 skip_fail: false
210
211# Configure the services running in Docker Swarm
Victor Ryzhenkin2a2cd8e2018-05-07 18:38:43 +0400212- description: Configure prometheus in docker swarm
213 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm and I@prometheus:server' state.sls prometheus
Tatyana Leontovich5acc82a2017-05-23 15:41:35 +0300214 node_name: {{ HOSTNAME_CFG01 }}
215 retry: {count: 1, delay: 10}
216 skip_fail: false
217
Victor Ryzhenkin2a2cd8e2018-05-07 18:38:43 +0400218###
219# From pipeline-library:
220# if (!common.checkContains('STACK_INSTALL', 'k8s')) {
221# salt.enforceState(master, 'I@docker:swarm and I@prometheus:server', 'heka.remote_collector', true, false)
222# }
223
224#- description: Configure Remote Collector in Docker Swarm for Openstack deployments
225# cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm and I@prometheus:server' state.sls heka.remote_collector
226# node_name: {{ HOSTNAME_CFG01 }}
227# retry: {count: 1, delay: 10}
228# skip_fail: false
229###
230
231- description: Install sphinx
232 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@sphinx:server' state.sls sphinx
Tatyana Leontovich5acc82a2017-05-23 15:41:35 +0300233 node_name: {{ HOSTNAME_CFG01 }}
234 retry: {count: 1, delay: 10}
235 skip_fail: false
236
Victor Ryzhenkin2a2cd8e2018-05-07 18:38:43 +0400237
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
Tatyana Leontovich5acc82a2017-05-23 15:41:35 +0300255
256- description: Configure Grafana dashboards and datasources
Dennis Dmitriev281221b2018-02-13 16:40:48 +0200257 cmd: sleep 30; salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@grafana:client' state.sls grafana.client
Tatyana Leontovich5acc82a2017-05-23 15:41:35 +0300258 node_name: {{ HOSTNAME_CFG01 }}
Tatyana Leontovich572f7492017-07-14 13:36:11 +0300259 retry: {count: 2, delay: 10}
Tatyana Leontovich5acc82a2017-05-23 15:41:35 +0300260 skip_fail: false
Tatyana Leontovichea450642017-07-11 18:56:11 +0300261
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: 1, delay: 10}
266 skip_fail: false
267