blob: f4b05d0fc4adb5fcc4915bb362878559fcbd3b92 [file] [log] [blame]
Oleksii Butenko7d9671c2017-11-01 17:27:23 +02001{% from 'cookied-bm-mcp-dvr-vxlan/underlay.yaml' import HOSTNAME_CFG01 with context %}
Oleksii Butenkobb46b0b2017-10-24 11:11:48 +03002
3# Install docker swarm.
Oleksii Butenkobb46b0b2017-10-24 11:11:48 +03004- description: Configure docker service
Dennis Dmitriev281221b2018-02-13 16:40:48 +02005 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm' state.sls docker.host
Oleksii Butenkobb46b0b2017-10-24 11:11:48 +03006 node_name: {{ HOSTNAME_CFG01 }}
7 retry: {count: 1, delay: 10}
8 skip_fail: false
9
10- description: Install docker swarm on master node
Dennis Dmitriev281221b2018-02-13 16:40:48 +020011 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master' state.sls docker.swarm
Oleksii Butenkobb46b0b2017-10-24 11:11:48 +030012 node_name: {{ HOSTNAME_CFG01 }}
13 retry: {count: 1, delay: 10}
14 skip_fail: false
15
16- description: Send grains to the swarm slave nodes
Dennis Dmitriev281221b2018-02-13 16:40:48 +020017 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm' state.sls salt.minion.grains
Oleksii Butenkobb46b0b2017-10-24 11:11:48 +030018 node_name: {{ HOSTNAME_CFG01 }}
19 retry: {count: 1, delay: 10}
20 skip_fail: false
21
22- description: Update mine
Dennis Dmitriev281221b2018-02-13 16:40:48 +020023 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm' mine.update
Oleksii Butenkobb46b0b2017-10-24 11:11:48 +030024 node_name: {{ HOSTNAME_CFG01 }}
25 retry: {count: 1, delay: 10}
26 skip_fail: false
27
28- description: Refresh modules
Dennis Dmitriev281221b2018-02-13 16:40:48 +020029 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm' saltutil.refresh_modules; sleep 5;
Oleksii Butenkobb46b0b2017-10-24 11:11:48 +030030 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
Dennis Dmitriev281221b2018-02-13 16:40:48 +020035 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master' state.sls docker.swarm
Oleksii Butenkobb46b0b2017-10-24 11:11:48 +030036 node_name: {{ HOSTNAME_CFG01 }}
37 retry: {count: 1, delay: 10}
38 skip_fail: false
39
40- description: Configure slave nodes
Dennis Dmitriev281221b2018-02-13 16:40:48 +020041 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:manager' state.sls docker.swarm -b 1
Oleksii Butenkobb46b0b2017-10-24 11:11:48 +030042 node_name: {{ HOSTNAME_CFG01 }}
43 retry: {count: 1, delay: 10}
44 skip_fail: false
45
46- description: List registered Docker swarm nodes
Dennis Dmitriev281221b2018-02-13 16:40:48 +020047 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master' cmd.run 'docker node ls'
Oleksii Butenkobb46b0b2017-10-24 11:11:48 +030048 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 StackLight mon nodes
60 cmd: |
61 SL_VIP=$(salt --out=newline_values_only "mon01*" pillar.get _param:cluster_vip_address);
62 echo "_param:cluster_vip_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
Oleksii Butenkobb46b0b2017-10-24 11:11:48 +030068# Install slv2 infra
Tatyana Leontovich48a6af92018-06-04 15:16:20 +030069- description: Install Mongo if target matches
70 cmd: |
71 if salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@mongodb:server' match.pillar 'mongodb:server' ; then
72 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@mongodb:server' state.sls mongodb
73 fi
74 node_name: {{ HOSTNAME_CFG01 }}
75 retry: {count: 1, delay: 10}
76 skip_fail: false
77
78- description: Configure Alerta if it is exists
79 cmd: |
80 if salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@prometheus:alerta' match.pillar 'prometheus:alerta' ; then
81 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm and I@prometheus:alerta' state.sls prometheus.alerta
82 fi
83 node_name: {{ HOSTNAME_CFG01 }}
84 retry: {count: 1, delay: 10}
85 skip_fail: false
86
Oleksii Butenkobb46b0b2017-10-24 11:11:48 +030087- description: Install telegraf
Dennis Dmitriev281221b2018-02-13 16:40:48 +020088 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@telegraf:agent or I@telegraf:remote_agent' state.sls telegraf
Oleksii Butenkobb46b0b2017-10-24 11:11:48 +030089 node_name: {{ HOSTNAME_CFG01 }}
90 retry: {count: 2, delay: 10}
91 skip_fail: false
92
93- description: Configure Prometheus exporters, if pillar 'prometheus:exporters' exists on any server
94 cmd: |
Dennis Dmitriev281221b2018-02-13 16:40:48 +020095 if salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@prometheus:exporters' match.pillar 'prometheus:exporters' ; then
96 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@prometheus:exporters' state.sls prometheus
Oleksii Butenkobb46b0b2017-10-24 11:11:48 +030097 fi
98 node_name: {{ HOSTNAME_CFG01 }}
99 retry: {count: 1, delay: 10}
100 skip_fail: false
101
Dmitry Kalashnik78d99632018-02-05 17:10:13 +0400102- description: Configure fluentd
Dennis Dmitriev281221b2018-02-13 16:40:48 +0200103 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@fluentd:agent' state.sls fluentd
Oleksii Butenkobb46b0b2017-10-24 11:11:48 +0300104 node_name: {{ HOSTNAME_CFG01 }}
105 retry: {count: 1, delay: 10}
106 skip_fail: false
107
108- 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
Oleksii Butenkobb46b0b2017-10-24 11:11:48 +0300110 node_name: {{ HOSTNAME_CFG01 }}
111 retry: {count: 1, delay: 10}
112 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
Oleksii Butenkobb46b0b2017-10-24 11:11:48 +0300116 node_name: {{ HOSTNAME_CFG01 }}
117 retry: {count: 1, delay: 10}
118 skip_fail: false
119
120- 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
Oleksii Butenkobb46b0b2017-10-24 11:11:48 +0300122 node_name: {{ HOSTNAME_CFG01 }}
Dennis Dmitriev4ad63e42018-05-01 05:18:54 +0300123 retry: {count: 2, delay: 30}
Oleksii Butenkobb46b0b2017-10-24 11:11:48 +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
Oleksii Butenkobb46b0b2017-10-24 11:11:48 +0300128 node_name: {{ HOSTNAME_CFG01 }}
129 retry: {count: 1, delay: 10}
130 skip_fail: false
131
132- 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`;
Oleksii Butenkobb46b0b2017-10-24 11:11:48 +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
Oleksii Butenkobb46b0b2017-10-24 11:11:48 +0300138 fi
139 node_name: {{ HOSTNAME_CFG01 }}
140 retry: {count: 1, delay: 5}
141 skip_fail: true
142
143# Collect grains needed to configure the services
144
145- description: Get grains
Dennis Dmitriev281221b2018-02-13 16:40:48 +0200146 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@salt:minion' state.sls salt.minion.grains
Oleksii Butenkobb46b0b2017-10-24 11:11:48 +0300147 node_name: {{ HOSTNAME_CFG01 }}
148 retry: {count: 1, delay: 10}
149 skip_fail: false
150
151- description: Sync modules
Dennis Dmitriev281221b2018-02-13 16:40:48 +0200152 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@salt:minion' saltutil.refresh_modules
Oleksii Butenkobb46b0b2017-10-24 11:11:48 +0300153 node_name: {{ HOSTNAME_CFG01 }}
154 retry: {count: 1, delay: 10}
155 skip_fail: false
156
157- description: Update mine
Dennis Dmitriev281221b2018-02-13 16:40:48 +0200158 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@salt:minion' mine.update; sleep 5;
Oleksii Butenkobb46b0b2017-10-24 11:11:48 +0300159 node_name: {{ HOSTNAME_CFG01 }}
160 retry: {count: 1, delay: 10}
161 skip_fail: false
162
163# Configure the services running in Docker Swarm
164- description: Install prometheus alertmanager
Dmitry Kalashnik81444d92018-02-15 17:42:15 +0400165 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@prometheus:server' state.sls prometheus -b 1
Oleksii Butenkobb46b0b2017-10-24 11:11:48 +0300166 node_name: {{ HOSTNAME_CFG01 }}
167 retry: {count: 2, delay: 10}
168 skip_fail: false
169
170- description: run docker state
Dennis Dmitriev281221b2018-02-13 16:40:48 +0200171 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master' state.sls docker
Oleksii Butenkobb46b0b2017-10-24 11:11:48 +0300172 node_name: {{ HOSTNAME_CFG01 }}
173 retry: {count: 2, delay: 120}
174 skip_fail: false
175
176- description: docker ps
Dennis Dmitriev281221b2018-02-13 16:40:48 +0200177 cmd: sleep 120; salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm' dockerng.ps
Oleksii Butenkobb46b0b2017-10-24 11:11:48 +0300178 node_name: {{ HOSTNAME_CFG01 }}
179 retry: {count: 1, delay: 10}
180 skip_fail: false
181
182- description: Configure Grafana dashboards and datasources
Dennis Dmitriev281221b2018-02-13 16:40:48 +0200183 cmd: sleep 60; salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@grafana:client' state.sls grafana.client
Oleksii Butenkobb46b0b2017-10-24 11:11:48 +0300184 node_name: {{ HOSTNAME_CFG01 }}
185 retry: {count: 2, delay: 10}
186 skip_fail: false
187
188- description: Run salt minion to create cert files
189 cmd: salt --hard-crash --state-output=mixed --state-verbose=False "*" state.sls salt.minion
190 node_name: {{ HOSTNAME_CFG01 }}
191 retry: {count: 1, delay: 10}
192 skip_fail: false
193