blob: c7a708da86e11fbaa5caca0d5b1e3ea4d38c1190 [file] [log] [blame]
Dennis Dmitriev411dd102017-09-15 16:04:47 +03001{% from 'cookied-mcp-ocata-dop-sl2/underlay.yaml' import HOSTNAME_CFG01 with context %}
2
3# Install docker swarm
4- description: Install keepalived on mon nodes
5 cmd: salt --hard-crash --state-output=mixed --state-verbose=False
6 -C 'mon*' state.sls keepalived
7 node_name: {{ HOSTNAME_CFG01 }}
8 retry: {count: 1, delay: 10}
9 skip_fail: false
10
11- description: Check the VIP on StackLight mon nodes
12 cmd: |
13 SL_VIP=$(salt --out=newline_values_only "mon01*" pillar.get _param:cluster_vip_address);
14 echo "_param:cluster_vip_address (vip): ${SL_VIP}";
15 salt --hard-crash --state-output=mixed --state-verbose=False -C 'mon*' cmd.run "ip a | grep ${SL_VIP}" | grep -B1 ${SL_VIP}
16 node_name: {{ HOSTNAME_CFG01 }}
17 retry: {count: 1, delay: 5}
18 skip_fail: false
19
20- description: Configure docker service
21 cmd: salt -C 'I@docker:swarm' state.sls docker.host
22 node_name: {{ HOSTNAME_CFG01 }}
23 retry: {count: 1, delay: 10}
24 skip_fail: false
25
26- description: Install docker swarm on master node
27 cmd: salt -C 'I@docker:swarm:role:master' state.sls docker.swarm
28 node_name: {{ HOSTNAME_CFG01 }}
29 retry: {count: 1, delay: 10}
30 skip_fail: false
31
32- description: Send grains to the swarm slave nodes
33 cmd: salt -C 'I@docker:swarm' state.sls salt.minion.grains
34 node_name: {{ HOSTNAME_CFG01 }}
35 retry: {count: 1, delay: 10}
36 skip_fail: false
37
38- description: Update mine
39 cmd: salt -C 'I@docker:swarm' mine.update
40 node_name: {{ HOSTNAME_CFG01 }}
41 retry: {count: 1, delay: 10}
42 skip_fail: false
43
44- description: Refresh modules
45 cmd: salt -C 'I@docker:swarm' saltutil.refresh_modules; sleep 5;
46 node_name: {{ HOSTNAME_CFG01 }}
47 retry: {count: 1, delay: 10}
48 skip_fail: false
49
50- description: Rerun swarm on slaves to proper token population
51 cmd: salt -C 'I@docker:swarm:role:master' state.sls docker.swarm
52 node_name: {{ HOSTNAME_CFG01 }}
53 retry: {count: 1, delay: 10}
54 skip_fail: false
55
56- description: Configure slave nodes
57 cmd: salt -C 'I@docker:swarm:role:manager' state.sls docker.swarm -b 1
58 node_name: {{ HOSTNAME_CFG01 }}
59 retry: {count: 1, delay: 10}
60 skip_fail: false
61
62- description: List registered Docker swarm nodes
63 cmd: salt -C 'I@docker:swarm:role:master' cmd.run 'docker node ls'
64 node_name: {{ HOSTNAME_CFG01 }}
65 retry: {count: 1, delay: 10}
66 skip_fail: false
67
68# Install slv2 infra
69- description: Install telegraf
70 cmd: salt -C 'I@telegraf:agent or I@telegraf:remote_agent' state.sls telegraf
71 node_name: {{ HOSTNAME_CFG01 }}
72 retry: {count: 2, delay: 10}
73 skip_fail: false
74
75- description: Configure Prometheus exporters, if pillar 'prometheus:exporters' exists on any server
76 cmd: |
77 if salt -C 'I@prometheus:exporters' match.pillar 'prometheus:exporters' ; then
78 salt -C 'I@prometheus:exporters' state.sls prometheus
79 fi
80 node_name: {{ HOSTNAME_CFG01 }}
81 retry: {count: 1, delay: 10}
82 skip_fail: false
83
84- description: Configure collector
85 cmd: salt -C 'I@heka:log_collector' state.sls heka.log_collector
86 node_name: {{ HOSTNAME_CFG01 }}
87 retry: {count: 1, delay: 10}
88 skip_fail: false
89
90- description: Install elasticsearch server
91 cmd: salt -C 'I@elasticsearch:server' state.sls elasticsearch.server -b 1
92 node_name: {{ HOSTNAME_CFG01 }}
93 retry: {count: 1, delay: 10}
94 skip_fail: false
95
96- description: Install kibana server
97 cmd: salt -C 'I@kibana:server' state.sls kibana.server -b 1
98 node_name: {{ HOSTNAME_CFG01 }}
99 retry: {count: 1, delay: 10}
100 skip_fail: false
101
102- description: Install elasticsearch client
103 cmd: salt -C 'I@elasticsearch:client' state.sls elasticsearch.client
104 node_name: {{ HOSTNAME_CFG01 }}
105 retry: {count: 1, delay: 10}
106 skip_fail: false
107
108- description: Install kibana client
109 cmd: salt -C 'I@kibana:client' state.sls kibana.client
110 node_name: {{ HOSTNAME_CFG01 }}
111 retry: {count: 1, delay: 10}
112 skip_fail: false
113
114- description: Check influix db
115 cmd: |
116 INFLUXDB_SERVICE=`salt -C 'I@influxdb:server' test.ping 1>/dev/null 2>&1 && echo true`;
117 echo "Influxdb service presence: ${INFLUXDB_SERVICE}";
118 if [[ "$INFLUXDB_SERVICE" == "true" ]]; then
119 salt -C 'I@influxdb:server' state.sls influxdb
120 fi
121 node_name: {{ HOSTNAME_CFG01 }}
122 retry: {count: 1, delay: 5}
123 skip_fail: true
124
125# Collect grains needed to configure the services
126
127- description: Get grains
128 cmd: salt -C 'I@salt:minion' state.sls salt.minion.grains
129 node_name: {{ HOSTNAME_CFG01 }}
130 retry: {count: 1, delay: 10}
131 skip_fail: false
132
133- description: Sync modules
134 cmd: salt -C 'I@salt:minion' saltutil.refresh_modules
135 node_name: {{ HOSTNAME_CFG01 }}
136 retry: {count: 1, delay: 10}
137 skip_fail: false
138
139- description: Update mine
140 cmd: salt -C 'I@salt:minion' mine.update; sleep 5;
141 node_name: {{ HOSTNAME_CFG01 }}
142 retry: {count: 1, delay: 10}
143 skip_fail: false
144
145# Change environment configuration before deploy
146- description: Set SL docker images deploy parameters
147 cmd: |
148 {% for sl_opt, value in config.sl_deploy.items() %}
149 {% if value|string() %}
150 salt-call reclass.cluster_meta_set {{ sl_opt }} {{ value }};
151 {% endif %}
152 {% endfor %}
153 node_name: {{ HOSTNAME_CFG01 }}
154 retry: {count: 1, delay: 1}
155 skip_fail: false
156
157# Configure the services running in Docker Swarm
158- description: Install prometheus alertmanager
159 cmd: salt -C 'I@docker:swarm' state.sls prometheus,heka.remote_collector -b 1
160 node_name: {{ HOSTNAME_CFG01 }}
161 retry: {count: 1, delay: 10}
162 skip_fail: false
163
164- description: run docker state
165 cmd: salt -C 'I@docker:swarm:role:master' state.sls docker
166 node_name: {{ HOSTNAME_CFG01 }}
167 retry: {count: 1, delay: 10}
168 skip_fail: false
169
170- description: docker ps
171 cmd: salt -C 'I@docker:swarm' dockerng.ps
172 node_name: {{ HOSTNAME_CFG01 }}
173 retry: {count: 1, delay: 10}
174 skip_fail: false
175
176- description: Configure Grafana dashboards and datasources
177 cmd: sleep 30; salt -C 'I@grafana:client' state.sls grafana.client
178 node_name: {{ HOSTNAME_CFG01 }}
179 retry: {count: 2, delay: 10}
180 skip_fail: false
181
182- description: Run salt minion to create cert files
183 cmd: salt --hard-crash --state-output=mixed --state-verbose=False "*" state.sls salt.minion
184 node_name: {{ HOSTNAME_CFG01 }}
185 retry: {count: 1, delay: 10}
186 skip_fail: false
187