blob: 70d9a3b0bec7116b1697040a8fecd186433fa5c0 [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
Tatyana Leontoviche4a28502018-06-08 13:24:56 +03004
5{% import 'shared-sl-tests.yaml' as SHARED_SL_TESTS with context %}
6
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +03007# Install docker swarm
Tatyana Leontovich5acc82a2017-05-23 15:41:35 +03008- description: Configure docker service
Dennis Dmitriev281221b2018-02-13 16:40:48 +02009 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 +030010 node_name: {{ HOSTNAME_CFG01 }}
11 retry: {count: 1, delay: 10}
Tatyana Leontovich5acc82a2017-05-23 15:41:35 +030012 skip_fail: false
13
14- description: Install docker swarm on master node
Dennis Dmitriev281221b2018-02-13 16:40:48 +020015 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 +030016 node_name: {{ HOSTNAME_CFG01 }}
17 retry: {count: 1, delay: 10}
18 skip_fail: false
19
20- description: Send grains to the swarm slave nodes
Dennis Dmitriev281221b2018-02-13 16:40:48 +020021 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 +030022 node_name: {{ HOSTNAME_CFG01 }}
23 retry: {count: 1, delay: 10}
24 skip_fail: false
25
26- description: Update mine
Dennis Dmitriev281221b2018-02-13 16:40:48 +020027 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm' mine.update
Tatyana Leontovich5acc82a2017-05-23 15:41:35 +030028 node_name: {{ HOSTNAME_CFG01 }}
29 retry: {count: 1, delay: 10}
30 skip_fail: false
31
32- description: Refresh modules
Dennis Dmitriev281221b2018-02-13 16:40:48 +020033 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 +030034 node_name: {{ HOSTNAME_CFG01 }}
35 retry: {count: 1, delay: 10}
36 skip_fail: false
37
Tatyana Leontovich2fec09a2017-08-22 13:52:11 +030038- description: Rerun swarm on slaves to proper token population
Dennis Dmitriev281221b2018-02-13 16:40:48 +020039 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 +030040 node_name: {{ HOSTNAME_CFG01 }}
41 retry: {count: 1, delay: 10}
42 skip_fail: false
43
Tatyana Leontovich5acc82a2017-05-23 15:41:35 +030044- description: Configure slave nodes
Dennis Dmitriev281221b2018-02-13 16:40:48 +020045 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 +030046 node_name: {{ HOSTNAME_CFG01 }}
47 retry: {count: 1, delay: 10}
48 skip_fail: false
49
50- description: List registered Docker swarm nodes
Dennis Dmitriev281221b2018-02-13 16:40:48 +020051 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 +030052 node_name: {{ HOSTNAME_CFG01 }}
53 retry: {count: 1, delay: 10}
54 skip_fail: false
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +030055
Victor Ryzhenkin2a2cd8e2018-05-07 18:38:43 +040056- description: Install keepalived on mon nodes
57 cmd: salt --hard-crash --state-output=mixed --state-verbose=False
58 -C 'mon*' state.sls keepalived
59 node_name: {{ HOSTNAME_CFG01 }}
60 retry: {count: 1, delay: 10}
61 skip_fail: false
62
63- description: Check the VIP on mon nodes
64 cmd: |
65 SL_VIP=`salt-call --out=newline_values_only pillar.get _param:stacklight_monitor_address`;
66 echo "_param:stacklight_monitor_address (vip): ${SL_VIP}";
67 salt --hard-crash --state-output=mixed --state-verbose=False -C 'mon*' cmd.run "ip a | grep ${SL_VIP}" | grep -B1 ${SL_VIP}
68 node_name: {{ HOSTNAME_CFG01 }}
69 retry: {count: 1, delay: 5}
70 skip_fail: false
71
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +030072# Install slv2 infra
Dennis Dmitriev371ba5b2018-05-31 12:00:38 +000073# Install MongoDB for alerta
Tatyana Leontovich48a6af92018-06-04 15:16:20 +030074- description: Install Mongo if target matches
75 cmd: |
76 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 +040077 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@mongodb:server' state.sls mongodb.server
Tatyana Leontovich48a6af92018-06-04 15:16:20 +030078 fi
Dennis Dmitriev371ba5b2018-05-31 12:00:38 +000079 node_name: {{ HOSTNAME_CFG01 }}
Tatyana Leontovich48a6af92018-06-04 15:16:20 +030080 retry: {count: 1, delay: 10}
81 skip_fail: false
82
Dmitry Kalashnik2fffc4a2018-06-07 16:34:06 +040083# Create MongoDB cluster
84- description: Install Mongo if target matches
Tatyana Leontovich48a6af92018-06-04 15:16:20 +030085 cmd: |
Dmitry Kalashnik2fffc4a2018-06-07 16:34:06 +040086 if salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@mongodb:server' match.pillar 'mongodb:server' ; then
87 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@mongodb:server' state.sls mongodb.cluster
Tatyana Leontovich48a6af92018-06-04 15:16:20 +030088 fi
89 node_name: {{ HOSTNAME_CFG01 }}
Dmitry Kalashnik2fffc4a2018-06-07 16:34:06 +040090 retry: {count: 5, delay: 20}
Victor Ryzhenkin2a2cd8e2018-05-07 18:38:43 +040091 skip_fail: false
92
Tatyana Leontovich5acc82a2017-05-23 15:41:35 +030093- description: Install telegraf
Dennis Dmitriev281221b2018-02-13 16:40:48 +020094 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 +030095 node_name: {{ HOSTNAME_CFG01 }}
Tatyana Leontovich2fec09a2017-08-22 13:52:11 +030096 retry: {count: 2, delay: 10}
97 skip_fail: false
98
Dennis Dmitrievcc6e9b52017-09-01 11:27:58 +030099- description: Configure Prometheus exporters, if pillar 'prometheus:exporters' exists on any server
100 cmd: |
Dennis Dmitriev281221b2018-02-13 16:40:48 +0200101 if salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@prometheus:exporters' match.pillar 'prometheus:exporters' ; then
102 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@prometheus:exporters' state.sls prometheus
Dennis Dmitrievcc6e9b52017-09-01 11:27:58 +0300103 fi
Tatyana Leontovich2fec09a2017-08-22 13:52:11 +0300104 node_name: {{ HOSTNAME_CFG01 }}
Tatyana Leontovichf00b2342017-07-04 18:26:25 +0300105 retry: {count: 1, delay: 10}
106 skip_fail: false
107
Tatyana Leontovich5acc82a2017-05-23 15:41:35 +0300108- description: Install elasticsearch server
Dennis Dmitriev281221b2018-02-13 16:40:48 +0200109 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 +0300110 node_name: {{ HOSTNAME_CFG01 }}
111 retry: {count: 1, delay: 10}
Tatyana Leontovich5acc82a2017-05-23 15:41:35 +0300112 skip_fail: false
113
114- description: Install kibana server
Dennis Dmitriev281221b2018-02-13 16:40:48 +0200115 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 +0300116 node_name: {{ HOSTNAME_CFG01 }}
117 retry: {count: 1, delay: 10}
118 skip_fail: false
119
Tatyana Leontovich5acc82a2017-05-23 15:41:35 +0300120- description: Install elasticsearch client
Dennis Dmitriev281221b2018-02-13 16:40:48 +0200121 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 +0300122 node_name: {{ HOSTNAME_CFG01 }}
Dennis Dmitriev4ad63e42018-05-01 05:18:54 +0300123 retry: {count: 2, delay: 30}
Tatyana Leontovich5acc82a2017-05-23 15:41:35 +0300124 skip_fail: false
125
126- description: Install kibana client
Dennis Dmitriev281221b2018-02-13 16:40:48 +0200127 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 +0300128 node_name: {{ HOSTNAME_CFG01 }}
129 retry: {count: 1, delay: 10}
130 skip_fail: false
131
Tatyana Leontovich3645d2b2017-06-13 16:51:23 +0300132- description: Check influix db
133 cmd: |
Dennis Dmitriev281221b2018-02-13 16:40:48 +0200134 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 +0300135 echo "Influxdb service presence: ${INFLUXDB_SERVICE}";
136 if [[ "$INFLUXDB_SERVICE" == "true" ]]; then
Dennis Dmitriev281221b2018-02-13 16:40:48 +0200137 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@influxdb:server' state.sls influxdb
Tatyana Leontovich3645d2b2017-06-13 16:51:23 +0300138 fi
139 node_name: {{ HOSTNAME_CFG01 }}
140 retry: {count: 1, delay: 5}
141 skip_fail: true
142
Victor Ryzhenkin2a2cd8e2018-05-07 18:38:43 +0400143# Install Prometheus LTS(optional if set in model)
144- description: Prometheus LTS(optional if set in model)
145 cmd: |
146 PROMETHEUS_SERVICE=`salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@prometheus:relay' test.ping 1>/dev/null 2>&1 && echo true`;
147 echo "PROMETHEUS rely service presence: ${PROMETHEUS_SERVICE}";
148 if [[ "$PROMETHEUS_SERVICE" == "true" ]]; then
149 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@prometheus:relay' state.sls prometheus
150 fi
151 node_name: {{ HOSTNAME_CFG01 }}
152 retry: {count: 1, delay: 5}
153 skip_fail: true
154
155# Install service for the log collection
156- description: Configure fluentd
157 cmd: |
158 FLUENTD_SERVICE=`salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@fluentd:agent' test.ping 1>/dev/null 2>&1 && echo true`;
159 echo "Fluentd service presence: ${FLUENTD_SERVICE}";
160 if [[ "$FLUENTD_SERVICE" == "true" ]]; then
161 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@fluentd:agent' state.sls fluentd
162 else
163 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@heka:log_collector' state.sls heka.log_collector
164 fi
165 node_name: {{ HOSTNAME_CFG01 }}
166 retry: {count: 1, delay: 10}
167 skip_fail: false
168
169#Install heka ceilometer collector
170- description: Install heka ceilometer if they exists
171 cmd: |
172 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`;
173 echo "Ceilometer service presence: ${CEILO}";
174 if [[ "$CEILO" == "true" ]]; then
175 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@heka:ceilometer_collector:enabled' state.sls heka.ceilometer_collector;
176 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@heka:ceilometer_collector:enabled' service.restart ceilometer_collector
177 fi
178 node_name: {{ HOSTNAME_CFG01 }}
179 retry: {count: 1, delay: 10}
180 skip_fail: false
181
Tatyana Leontovich5acc82a2017-05-23 15:41:35 +0300182# Collect grains needed to configure the services
183
184- description: Get grains
Dennis Dmitriev281221b2018-02-13 16:40:48 +0200185 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 +0300186 node_name: {{ HOSTNAME_CFG01 }}
187 retry: {count: 1, delay: 10}
188 skip_fail: false
189
190- description: Sync modules
Dennis Dmitriev281221b2018-02-13 16:40:48 +0200191 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@salt:minion' saltutil.refresh_modules
Tatyana Leontovich5acc82a2017-05-23 15:41:35 +0300192 node_name: {{ HOSTNAME_CFG01 }}
193 retry: {count: 1, delay: 10}
194 skip_fail: false
195
196- description: Update mine
Dennis Dmitriev281221b2018-02-13 16:40:48 +0200197 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 +0300198 node_name: {{ HOSTNAME_CFG01 }}
Victor Ryzhenkin2a2cd8e2018-05-07 18:38:43 +0400199 retry: {count: 5, delay: 15}
Tatyana Leontovich5acc82a2017-05-23 15:41:35 +0300200 skip_fail: false
201
202# Configure the services running in Docker Swarm
Victor Ryzhenkin2a2cd8e2018-05-07 18:38:43 +0400203- description: Configure prometheus in docker swarm
204 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 +0300205 node_name: {{ HOSTNAME_CFG01 }}
206 retry: {count: 1, delay: 10}
207 skip_fail: false
208
Dmitry Kalashnik2fffc4a2018-06-07 16:34:06 +0400209#Launch containers
210- description: launch prometheus containers
211 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master and I@prometheus:server' state.sls docker.client
212 node_name: {{ HOSTNAME_CFG01 }}
213 retry: {count: 2, delay: 10}
214 skip_fail: false
215
216- description: Check docker ps
217 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm and I@prometheus:server' cmd.run "docker ps"
218 node_name: {{ HOSTNAME_CFG01 }}
219 retry: {count: 2, delay: 10}
220 skip_fail: false
221
Tatyana Leontovich5acc82a2017-05-23 15:41:35 +0300222- description: Configure Grafana dashboards and datasources
Dennis Dmitriev281221b2018-02-13 16:40:48 +0200223 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 +0300224 node_name: {{ HOSTNAME_CFG01 }}
Tatyana Leontovich572f7492017-07-14 13:36:11 +0300225 retry: {count: 2, delay: 10}
Tatyana Leontovich5acc82a2017-05-23 15:41:35 +0300226 skip_fail: false
Tatyana Leontovichea450642017-07-11 18:56:11 +0300227
228- description: Run salt minion to create cert files
229 cmd: salt --hard-crash --state-output=mixed --state-verbose=False "*" state.sls salt.minion
230 node_name: {{ HOSTNAME_CFG01 }}
231 retry: {count: 1, delay: 10}
232 skip_fail: false
233
Tatyana Leontoviche4a28502018-06-08 13:24:56 +0300234
235{{ SHARED_SL_TESTS.MACRO_CLONE_SL_TESTS() }}
236{{ SHARED_SL_TESTS.MACRO_CONFIGURE_TESTS() }}