blob: 4eff139d13082d2dbb2900ab491040a9d36f814a [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
Dmitry Kalashnik2fffc4a2018-06-07 16:34:06 +040074 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@mongodb:server' state.sls mongodb.server
Tatyana Leontovich48a6af92018-06-04 15:16:20 +030075 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
Dmitry Kalashnik2fffc4a2018-06-07 16:34:06 +040080# Create MongoDB cluster
81- description: Install Mongo if target matches
Tatyana Leontovich48a6af92018-06-04 15:16:20 +030082 cmd: |
Dmitry Kalashnik2fffc4a2018-06-07 16:34:06 +040083 if salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@mongodb:server' match.pillar 'mongodb:server' ; then
84 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@mongodb:server' state.sls mongodb.cluster
Tatyana Leontovich48a6af92018-06-04 15:16:20 +030085 fi
86 node_name: {{ HOSTNAME_CFG01 }}
Dmitry Kalashnik2fffc4a2018-06-07 16:34:06 +040087 retry: {count: 5, delay: 20}
Victor Ryzhenkin2a2cd8e2018-05-07 18:38:43 +040088 skip_fail: false
89
Tatyana Leontovich5acc82a2017-05-23 15:41:35 +030090- description: Install telegraf
Dennis Dmitriev281221b2018-02-13 16:40:48 +020091 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 +030092 node_name: {{ HOSTNAME_CFG01 }}
Tatyana Leontovich2fec09a2017-08-22 13:52:11 +030093 retry: {count: 2, delay: 10}
94 skip_fail: false
95
Dennis Dmitrievcc6e9b52017-09-01 11:27:58 +030096- description: Configure Prometheus exporters, if pillar 'prometheus:exporters' exists on any server
97 cmd: |
Dennis Dmitriev281221b2018-02-13 16:40:48 +020098 if salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@prometheus:exporters' match.pillar 'prometheus:exporters' ; then
99 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@prometheus:exporters' state.sls prometheus
Dennis Dmitrievcc6e9b52017-09-01 11:27:58 +0300100 fi
Tatyana Leontovich2fec09a2017-08-22 13:52:11 +0300101 node_name: {{ HOSTNAME_CFG01 }}
Tatyana Leontovichf00b2342017-07-04 18:26:25 +0300102 retry: {count: 1, delay: 10}
103 skip_fail: false
104
Tatyana Leontovich5acc82a2017-05-23 15:41:35 +0300105- description: Install elasticsearch server
Dennis Dmitriev281221b2018-02-13 16:40:48 +0200106 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 +0300107 node_name: {{ HOSTNAME_CFG01 }}
108 retry: {count: 1, delay: 10}
Tatyana Leontovich5acc82a2017-05-23 15:41:35 +0300109 skip_fail: false
110
111- description: Install kibana server
Dennis Dmitriev281221b2018-02-13 16:40:48 +0200112 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 +0300113 node_name: {{ HOSTNAME_CFG01 }}
114 retry: {count: 1, delay: 10}
115 skip_fail: false
116
Tatyana Leontovich5acc82a2017-05-23 15:41:35 +0300117- description: Install elasticsearch client
Dennis Dmitriev281221b2018-02-13 16:40:48 +0200118 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 +0300119 node_name: {{ HOSTNAME_CFG01 }}
Dennis Dmitriev4ad63e42018-05-01 05:18:54 +0300120 retry: {count: 2, delay: 30}
Tatyana Leontovich5acc82a2017-05-23 15:41:35 +0300121 skip_fail: false
122
123- description: Install kibana client
Dennis Dmitriev281221b2018-02-13 16:40:48 +0200124 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 +0300125 node_name: {{ HOSTNAME_CFG01 }}
126 retry: {count: 1, delay: 10}
127 skip_fail: false
128
Tatyana Leontovich3645d2b2017-06-13 16:51:23 +0300129- description: Check influix db
130 cmd: |
Dennis Dmitriev281221b2018-02-13 16:40:48 +0200131 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 +0300132 echo "Influxdb service presence: ${INFLUXDB_SERVICE}";
133 if [[ "$INFLUXDB_SERVICE" == "true" ]]; then
Dennis Dmitriev281221b2018-02-13 16:40:48 +0200134 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@influxdb:server' state.sls influxdb
Tatyana Leontovich3645d2b2017-06-13 16:51:23 +0300135 fi
136 node_name: {{ HOSTNAME_CFG01 }}
137 retry: {count: 1, delay: 5}
138 skip_fail: true
139
Victor Ryzhenkin2a2cd8e2018-05-07 18:38:43 +0400140# Install Prometheus LTS(optional if set in model)
141- description: Prometheus LTS(optional if set in model)
142 cmd: |
143 PROMETHEUS_SERVICE=`salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@prometheus:relay' test.ping 1>/dev/null 2>&1 && echo true`;
144 echo "PROMETHEUS rely service presence: ${PROMETHEUS_SERVICE}";
145 if [[ "$PROMETHEUS_SERVICE" == "true" ]]; then
146 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@prometheus:relay' state.sls prometheus
147 fi
148 node_name: {{ HOSTNAME_CFG01 }}
149 retry: {count: 1, delay: 5}
150 skip_fail: true
151
152# Install service for the log collection
153- description: Configure fluentd
154 cmd: |
155 FLUENTD_SERVICE=`salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@fluentd:agent' test.ping 1>/dev/null 2>&1 && echo true`;
156 echo "Fluentd service presence: ${FLUENTD_SERVICE}";
157 if [[ "$FLUENTD_SERVICE" == "true" ]]; then
158 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@fluentd:agent' state.sls fluentd
159 else
160 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@heka:log_collector' state.sls heka.log_collector
161 fi
162 node_name: {{ HOSTNAME_CFG01 }}
163 retry: {count: 1, delay: 10}
164 skip_fail: false
165
166#Install heka ceilometer collector
167- description: Install heka ceilometer if they exists
168 cmd: |
169 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`;
170 echo "Ceilometer service presence: ${CEILO}";
171 if [[ "$CEILO" == "true" ]]; then
172 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@heka:ceilometer_collector:enabled' state.sls heka.ceilometer_collector;
173 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@heka:ceilometer_collector:enabled' service.restart ceilometer_collector
174 fi
175 node_name: {{ HOSTNAME_CFG01 }}
176 retry: {count: 1, delay: 10}
177 skip_fail: false
178
Tatyana Leontovich5acc82a2017-05-23 15:41:35 +0300179# Collect grains needed to configure the services
180
181- description: Get grains
Dennis Dmitriev281221b2018-02-13 16:40:48 +0200182 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 +0300183 node_name: {{ HOSTNAME_CFG01 }}
184 retry: {count: 1, delay: 10}
185 skip_fail: false
186
187- description: Sync modules
Dennis Dmitriev281221b2018-02-13 16:40:48 +0200188 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@salt:minion' saltutil.refresh_modules
Tatyana Leontovich5acc82a2017-05-23 15:41:35 +0300189 node_name: {{ HOSTNAME_CFG01 }}
190 retry: {count: 1, delay: 10}
191 skip_fail: false
192
193- description: Update mine
Dennis Dmitriev281221b2018-02-13 16:40:48 +0200194 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 +0300195 node_name: {{ HOSTNAME_CFG01 }}
Victor Ryzhenkin2a2cd8e2018-05-07 18:38:43 +0400196 retry: {count: 5, delay: 15}
Tatyana Leontovich5acc82a2017-05-23 15:41:35 +0300197 skip_fail: false
198
199# Configure the services running in Docker Swarm
Victor Ryzhenkin2a2cd8e2018-05-07 18:38:43 +0400200- description: Configure prometheus in docker swarm
201 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 +0300202 node_name: {{ HOSTNAME_CFG01 }}
203 retry: {count: 1, delay: 10}
204 skip_fail: false
205
Dmitry Kalashnik2fffc4a2018-06-07 16:34:06 +0400206#Launch containers
207- description: launch prometheus containers
208 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master and I@prometheus:server' state.sls docker.client
209 node_name: {{ HOSTNAME_CFG01 }}
210 retry: {count: 2, delay: 10}
211 skip_fail: false
212
213- description: Check docker ps
214 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm and I@prometheus:server' cmd.run "docker ps"
215 node_name: {{ HOSTNAME_CFG01 }}
216 retry: {count: 2, delay: 10}
217 skip_fail: false
218
Victor Ryzhenkin2a2cd8e2018-05-07 18:38:43 +0400219###
220# From pipeline-library:
221# if (!common.checkContains('STACK_INSTALL', 'k8s')) {
222# salt.enforceState(master, 'I@docker:swarm and I@prometheus:server', 'heka.remote_collector', true, false)
223# }
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
232- description: Install sphinx
233 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@sphinx:server' state.sls sphinx
Tatyana Leontovich5acc82a2017-05-23 15:41:35 +0300234 node_name: {{ HOSTNAME_CFG01 }}
235 retry: {count: 1, delay: 10}
236 skip_fail: false
237
Victor Ryzhenkin2a2cd8e2018-05-07 18:38:43 +0400238
239#- description: Install prometheus alertmanager
240# cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm' state.sls prometheus,heka.remote_collector -b 1
241# node_name: {{ HOSTNAME_CFG01 }}
242# retry: {count: 1, delay: 10}
243# skip_fail: false
244
245#- description: run docker state
246# cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master' state.sls docker
247# node_name: {{ HOSTNAME_CFG01 }}
248# retry: {count: 1, delay: 10}
249# skip_fail: false
250#
251#- description: docker ps
252# cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm' dockerng.ps
253# node_name: {{ HOSTNAME_CFG01 }}
254# retry: {count: 1, delay: 10}
255# skip_fail: false
Tatyana Leontovich5acc82a2017-05-23 15:41:35 +0300256
257- description: Configure Grafana dashboards and datasources
Dennis Dmitriev281221b2018-02-13 16:40:48 +0200258 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 +0300259 node_name: {{ HOSTNAME_CFG01 }}
Tatyana Leontovich572f7492017-07-14 13:36:11 +0300260 retry: {count: 2, delay: 10}
Tatyana Leontovich5acc82a2017-05-23 15:41:35 +0300261 skip_fail: false
Tatyana Leontovichea450642017-07-11 18:56:11 +0300262
263- description: Run salt minion to create cert files
264 cmd: salt --hard-crash --state-output=mixed --state-verbose=False "*" state.sls salt.minion
265 node_name: {{ HOSTNAME_CFG01 }}
266 retry: {count: 1, delay: 10}
267 skip_fail: false
268