blob: 4f3d9bcfaaf0c718fd86920c7ed1490616f03443 [file] [log] [blame]
Dennis Dmitriev47433912018-03-25 04:24:59 +03001{% from 'cookied-mcp-pike-dvr-ssl/underlay.yaml' import HOSTNAME_CFG01 with context %}
Tatyana Leontovichc447b122018-02-22 12:30:42 +02002{% import 'shared-sl-tests.yaml' as SHARED_SL_TESTS with context %}
3# Install docker swarm
Tatyana Leontovichc447b122018-02-22 12:30:42 +02004- 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
Dennis Dmitriev002c2672018-03-06 18:43:27 +020052- 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
Tatyana Leontovichc447b122018-02-22 12:30:42 +020068# Install slv2 infra
Dennis Dmitriev371ba5b2018-05-31 12:00:38 +000069# Install MongoDB for alerta
Tatyana Leontovich48a6af92018-06-04 15:16:20 +030070- 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
Dmitry Kalashnik2fffc4a2018-06-07 16:34:06 +040073 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@mongodb:server' state.sls mongodb.server
Tatyana Leontovich48a6af92018-06-04 15:16:20 +030074 fi
Dennis Dmitriev371ba5b2018-05-31 12:00:38 +000075 node_name: {{ HOSTNAME_CFG01 }}
Tatyana Leontovich48a6af92018-06-04 15:16:20 +030076 retry: {count: 1, delay: 10}
77 skip_fail: false
78
Dmitry Kalashnik2fffc4a2018-06-07 16:34:06 +040079# Create MongoDB cluster
80- description: Install Mongo if target matches
Tatyana Leontovich48a6af92018-06-04 15:16:20 +030081 cmd: |
Dmitry Kalashnik2fffc4a2018-06-07 16:34:06 +040082 if salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@mongodb:server' match.pillar 'mongodb:server' ; then
83 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@mongodb:server' state.sls mongodb.cluster
Tatyana Leontovich48a6af92018-06-04 15:16:20 +030084 fi
85 node_name: {{ HOSTNAME_CFG01 }}
Dmitry Kalashnik2fffc4a2018-06-07 16:34:06 +040086 retry: {count: 5, delay: 20}
Dennis Dmitriev371ba5b2018-05-31 12:00:38 +000087 skip_fail: false
88
Tatyana Leontovichc447b122018-02-22 12:30:42 +020089- description: Install telegraf
90 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@telegraf:agent or I@telegraf:remote_agent' state.sls telegraf
91 node_name: {{ HOSTNAME_CFG01 }}
92 retry: {count: 2, delay: 10}
93 skip_fail: false
94
95- description: Configure Prometheus exporters, if pillar 'prometheus:exporters' exists on any server
96 cmd: |
97 if salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@prometheus:exporters' match.pillar 'prometheus:exporters' ; then
98 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@prometheus:exporters' state.sls prometheus
99 fi
100 node_name: {{ HOSTNAME_CFG01 }}
101 retry: {count: 1, delay: 10}
102 skip_fail: false
103
104- description: Configure fluentd
105 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@fluentd:agent' state.sls fluentd
106 node_name: {{ HOSTNAME_CFG01 }}
107 retry: {count: 1, delay: 10}
108 skip_fail: false
109
110- description: Install elasticsearch server
111 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@elasticsearch:server' state.sls elasticsearch.server -b 1
112 node_name: {{ HOSTNAME_CFG01 }}
113 retry: {count: 1, delay: 10}
114 skip_fail: false
115
116- description: Install kibana server
117 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@kibana:server' state.sls kibana.server -b 1
118 node_name: {{ HOSTNAME_CFG01 }}
119 retry: {count: 1, delay: 10}
120 skip_fail: false
121
122- description: Install elasticsearch client
123 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@elasticsearch:client' state.sls elasticsearch.client
124 node_name: {{ HOSTNAME_CFG01 }}
Dennis Dmitriev4ad63e42018-05-01 05:18:54 +0300125 retry: {count: 2, delay: 30}
Tatyana Leontovichc447b122018-02-22 12:30:42 +0200126 skip_fail: false
127
128- description: Install kibana client
129 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@kibana:client' state.sls kibana.client
130 node_name: {{ HOSTNAME_CFG01 }}
131 retry: {count: 1, delay: 10}
132 skip_fail: false
133
134- description: Check influix db
135 cmd: |
136 INFLUXDB_SERVICE=`salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@influxdb:server' test.ping 1>/dev/null 2>&1 && echo true`;
137 echo "Influxdb service presence: ${INFLUXDB_SERVICE}";
138 if [[ "$INFLUXDB_SERVICE" == "true" ]]; then
139 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@influxdb:server' state.sls influxdb
140 fi
141 node_name: {{ HOSTNAME_CFG01 }}
142 retry: {count: 1, delay: 5}
143 skip_fail: true
144
145# Collect grains needed to configure the services
146
147- description: Get grains
148 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@salt:minion' state.sls salt.minion.grains
149 node_name: {{ HOSTNAME_CFG01 }}
150 retry: {count: 1, delay: 10}
151 skip_fail: false
152
153- description: Sync modules
154 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@salt:minion' saltutil.refresh_modules
155 node_name: {{ HOSTNAME_CFG01 }}
156 retry: {count: 1, delay: 10}
157 skip_fail: false
158
159- description: Update mine
160 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@salt:minion' mine.update; sleep 5;
161 node_name: {{ HOSTNAME_CFG01 }}
162 retry: {count: 5, delay: 15}
163 skip_fail: false
164
165# Configure the services running in Docker Swarm
Dmitry Kalashnik2fffc4a2018-06-07 16:34:06 +0400166- description: Configure prometheus in docker swarm
167 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm and I@prometheus:server' state.sls prometheus,heka.remote_collector
Tatyana Leontovichc447b122018-02-22 12:30:42 +0200168 node_name: {{ HOSTNAME_CFG01 }}
169 retry: {count: 1, delay: 10}
170 skip_fail: false
171
Dmitry Kalashnik2fffc4a2018-06-07 16:34:06 +0400172#Launch containers
173- description: launch prometheus containers
174 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master and I@prometheus:server' state.sls docker.client
Tatyana Leontovichc447b122018-02-22 12:30:42 +0200175 node_name: {{ HOSTNAME_CFG01 }}
Dmitry Kalashnik2fffc4a2018-06-07 16:34:06 +0400176 retry: {count: 2, delay: 10}
Tatyana Leontovichc447b122018-02-22 12:30:42 +0200177 skip_fail: false
178
Dmitry Kalashnik2fffc4a2018-06-07 16:34:06 +0400179- description: Check docker ps
180 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm and I@prometheus:server' cmd.run "docker ps"
Tatyana Leontovichc447b122018-02-22 12:30:42 +0200181 node_name: {{ HOSTNAME_CFG01 }}
Dmitry Kalashnik2fffc4a2018-06-07 16:34:06 +0400182 retry: {count: 2, delay: 10}
Tatyana Leontovichc447b122018-02-22 12:30:42 +0200183 skip_fail: false
184
185- description: Configure Grafana dashboards and datasources
186 cmd: sleep 30; salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@grafana:client' state.sls grafana.client
187 node_name: {{ HOSTNAME_CFG01 }}
188 retry: {count: 2, delay: 10}
189 skip_fail: false
190
191- description: Run salt minion to create cert files
192 cmd: salt --hard-crash --state-output=mixed --state-verbose=False "*" state.sls salt.minion
193 node_name: {{ HOSTNAME_CFG01 }}
194 retry: {count: 1, delay: 10}
195 skip_fail: false
196
197{{ SHARED_SL_TESTS.MACRO_CLONE_SL_TESTS() }}
198{{ SHARED_SL_TESTS.MACRO_CONFIGURE_TESTS() }}