blob: dddb5fd01d331bba1ad8c1a917f55f768fcfa056 [file] [log] [blame]
Dennis Dmitriev411dd102017-09-15 16:04:47 +03001{% from 'cookied-mcp-ocata-dop-sl2/underlay.yaml' import HOSTNAME_CFG01 with context %}
Dennis Dmitriev386845b2017-11-21 13:11:12 +02002{% from 'cookied-mcp-ocata-dop-sl2/salt.yaml' import ENVIRONMENT_MODEL_INVENTORY_NAME with context %}
Dennis Dmitriev411dd102017-09-15 16:04:47 +03003
4# Install docker swarm
5- description: Install keepalived on mon nodes
6 cmd: salt --hard-crash --state-output=mixed --state-verbose=False
7 -C 'mon*' state.sls keepalived
8 node_name: {{ HOSTNAME_CFG01 }}
9 retry: {count: 1, delay: 10}
10 skip_fail: false
11
12- description: Check the VIP on StackLight mon nodes
13 cmd: |
14 SL_VIP=$(salt --out=newline_values_only "mon01*" pillar.get _param:cluster_vip_address);
15 echo "_param:cluster_vip_address (vip): ${SL_VIP}";
16 salt --hard-crash --state-output=mixed --state-verbose=False -C 'mon*' cmd.run "ip a | grep ${SL_VIP}" | grep -B1 ${SL_VIP}
17 node_name: {{ HOSTNAME_CFG01 }}
18 retry: {count: 1, delay: 5}
19 skip_fail: false
20
21- description: Configure docker service
Dennis Dmitriev281221b2018-02-13 16:40:48 +020022 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm' state.sls docker.host
Dennis Dmitriev411dd102017-09-15 16:04:47 +030023 node_name: {{ HOSTNAME_CFG01 }}
24 retry: {count: 1, delay: 10}
25 skip_fail: false
26
27- description: Install docker swarm on master node
Dennis Dmitriev281221b2018-02-13 16:40:48 +020028 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master' state.sls docker.swarm
Dennis Dmitriev411dd102017-09-15 16:04:47 +030029 node_name: {{ HOSTNAME_CFG01 }}
30 retry: {count: 1, delay: 10}
31 skip_fail: false
32
33- description: Send grains to the swarm slave nodes
Dennis Dmitriev281221b2018-02-13 16:40:48 +020034 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm' state.sls salt.minion.grains
Dennis Dmitriev411dd102017-09-15 16:04:47 +030035 node_name: {{ HOSTNAME_CFG01 }}
36 retry: {count: 1, delay: 10}
37 skip_fail: false
38
39- description: Update mine
Dennis Dmitriev281221b2018-02-13 16:40:48 +020040 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm' mine.update
Dennis Dmitriev411dd102017-09-15 16:04:47 +030041 node_name: {{ HOSTNAME_CFG01 }}
42 retry: {count: 1, delay: 10}
43 skip_fail: false
44
45- description: Refresh modules
Dennis Dmitriev281221b2018-02-13 16:40:48 +020046 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm' saltutil.refresh_modules; sleep 5;
Dennis Dmitriev411dd102017-09-15 16:04:47 +030047 node_name: {{ HOSTNAME_CFG01 }}
48 retry: {count: 1, delay: 10}
49 skip_fail: false
50
51- description: Rerun swarm on slaves to proper token population
Dennis Dmitriev281221b2018-02-13 16:40:48 +020052 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master' state.sls docker.swarm
Dennis Dmitriev411dd102017-09-15 16:04:47 +030053 node_name: {{ HOSTNAME_CFG01 }}
54 retry: {count: 1, delay: 10}
55 skip_fail: false
56
57- description: Configure slave nodes
Dennis Dmitriev281221b2018-02-13 16:40:48 +020058 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:manager' state.sls docker.swarm -b 1
Dennis Dmitriev411dd102017-09-15 16:04:47 +030059 node_name: {{ HOSTNAME_CFG01 }}
60 retry: {count: 1, delay: 10}
61 skip_fail: false
62
63- description: List registered Docker swarm nodes
Dennis Dmitriev281221b2018-02-13 16:40:48 +020064 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master' cmd.run 'docker node ls'
Dennis Dmitriev411dd102017-09-15 16:04:47 +030065 node_name: {{ HOSTNAME_CFG01 }}
66 retry: {count: 1, delay: 10}
67 skip_fail: false
68
69# Install slv2 infra
70- description: Install telegraf
Dennis Dmitriev281221b2018-02-13 16:40:48 +020071 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@telegraf:agent or I@telegraf:remote_agent' state.sls telegraf
Dennis Dmitriev411dd102017-09-15 16:04:47 +030072 node_name: {{ HOSTNAME_CFG01 }}
73 retry: {count: 2, delay: 10}
74 skip_fail: false
75
76- description: Configure Prometheus exporters, if pillar 'prometheus:exporters' exists on any server
77 cmd: |
Dennis Dmitriev281221b2018-02-13 16:40:48 +020078 if salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@prometheus:exporters' match.pillar 'prometheus:exporters' ; then
79 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@prometheus:exporters' state.sls prometheus
Dennis Dmitriev411dd102017-09-15 16:04:47 +030080 fi
81 node_name: {{ HOSTNAME_CFG01 }}
82 retry: {count: 1, delay: 10}
83 skip_fail: false
84
Dmitry Kalashnik78d99632018-02-05 17:10:13 +040085- description: Configure fluentd
Dennis Dmitriev281221b2018-02-13 16:40:48 +020086 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@fluentd:agent' state.sls fluentd
Dennis Dmitriev411dd102017-09-15 16:04:47 +030087 node_name: {{ HOSTNAME_CFG01 }}
88 retry: {count: 1, delay: 10}
89 skip_fail: false
90
91- description: Install elasticsearch server
Dennis Dmitriev281221b2018-02-13 16:40:48 +020092 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@elasticsearch:server' state.sls elasticsearch.server -b 1
Dennis Dmitriev411dd102017-09-15 16:04:47 +030093 node_name: {{ HOSTNAME_CFG01 }}
94 retry: {count: 1, delay: 10}
95 skip_fail: false
96
97- description: Install kibana server
Dennis Dmitriev281221b2018-02-13 16:40:48 +020098 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@kibana:server' state.sls kibana.server -b 1
Dennis Dmitriev411dd102017-09-15 16:04:47 +030099 node_name: {{ HOSTNAME_CFG01 }}
100 retry: {count: 1, delay: 10}
101 skip_fail: false
102
103- description: Install elasticsearch client
Dennis Dmitriev281221b2018-02-13 16:40:48 +0200104 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@elasticsearch:client' state.sls elasticsearch.client
Dennis Dmitriev411dd102017-09-15 16:04:47 +0300105 node_name: {{ HOSTNAME_CFG01 }}
106 retry: {count: 1, delay: 10}
107 skip_fail: false
108
109- description: Install kibana client
Dennis Dmitriev281221b2018-02-13 16:40:48 +0200110 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@kibana:client' state.sls kibana.client
Dennis Dmitriev411dd102017-09-15 16:04:47 +0300111 node_name: {{ HOSTNAME_CFG01 }}
112 retry: {count: 1, delay: 10}
113 skip_fail: false
114
115- description: Check influix db
116 cmd: |
Dennis Dmitriev281221b2018-02-13 16:40:48 +0200117 INFLUXDB_SERVICE=`salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@influxdb:server' test.ping 1>/dev/null 2>&1 && echo true`;
Dennis Dmitriev411dd102017-09-15 16:04:47 +0300118 echo "Influxdb service presence: ${INFLUXDB_SERVICE}";
119 if [[ "$INFLUXDB_SERVICE" == "true" ]]; then
Dennis Dmitriev281221b2018-02-13 16:40:48 +0200120 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@influxdb:server' state.sls influxdb
Dennis Dmitriev411dd102017-09-15 16:04:47 +0300121 fi
122 node_name: {{ HOSTNAME_CFG01 }}
123 retry: {count: 1, delay: 5}
124 skip_fail: true
125
126# Collect grains needed to configure the services
127
128- description: Get grains
Dennis Dmitriev281221b2018-02-13 16:40:48 +0200129 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@salt:minion' state.sls salt.minion.grains
Dennis Dmitriev411dd102017-09-15 16:04:47 +0300130 node_name: {{ HOSTNAME_CFG01 }}
131 retry: {count: 1, delay: 10}
132 skip_fail: false
133
134- description: Sync modules
Dennis Dmitriev281221b2018-02-13 16:40:48 +0200135 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@salt:minion' saltutil.refresh_modules
Dennis Dmitriev411dd102017-09-15 16:04:47 +0300136 node_name: {{ HOSTNAME_CFG01 }}
137 retry: {count: 1, delay: 10}
138 skip_fail: false
139
140- description: Update mine
Dennis Dmitriev281221b2018-02-13 16:40:48 +0200141 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@salt:minion' mine.update; sleep 5;
Dennis Dmitriev411dd102017-09-15 16:04:47 +0300142 node_name: {{ HOSTNAME_CFG01 }}
143 retry: {count: 1, delay: 10}
144 skip_fail: false
145
146# Change environment configuration before deploy
147- description: Set SL docker images deploy parameters
148 cmd: |
Dennis Dmitriev386845b2017-11-21 13:11:12 +0200149 {#- For cookiecutter-generated model, use overrides.yml from environment model instead of cluster model #}
150 {%- set OVERRIDES_FILENAME='/srv/salt/reclass/classes/environment/' + ENVIRONMENT_MODEL_INVENTORY_NAME + '/overrides.yml' %}
151 {%- for sl_opt, value in config.sl_deploy.items() %}
152 {%- if value|string() %}
153 salt-call reclass.cluster_meta_set name={{ sl_opt }} value={{ value }} file_name={{ OVERRIDES_FILENAME }};
154 {%- endif %}
155 {%- endfor %}
Dennis Dmitrieva95a6d42017-10-24 15:09:04 +0300156 salt '*' saltutil.refresh_pillar;
157 sleep 10
Dennis Dmitriev411dd102017-09-15 16:04:47 +0300158 node_name: {{ HOSTNAME_CFG01 }}
159 retry: {count: 1, delay: 1}
160 skip_fail: false
161
162# Configure the services running in Docker Swarm
163- description: Install prometheus alertmanager
Dennis Dmitriev281221b2018-02-13 16:40:48 +0200164 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm' state.sls prometheus -b 1
Dennis Dmitriev411dd102017-09-15 16:04:47 +0300165 node_name: {{ HOSTNAME_CFG01 }}
166 retry: {count: 1, delay: 10}
167 skip_fail: false
168
169- description: run docker state
Dennis Dmitriev281221b2018-02-13 16:40:48 +0200170 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master' state.sls docker
Dennis Dmitriev411dd102017-09-15 16:04:47 +0300171 node_name: {{ HOSTNAME_CFG01 }}
172 retry: {count: 1, delay: 10}
173 skip_fail: false
174
175- description: docker ps
Dennis Dmitriev281221b2018-02-13 16:40:48 +0200176 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm' dockerng.ps
Dennis Dmitriev411dd102017-09-15 16:04:47 +0300177 node_name: {{ HOSTNAME_CFG01 }}
178 retry: {count: 1, delay: 10}
179 skip_fail: false
180
181- description: Configure Grafana dashboards and datasources
Dennis Dmitriev281221b2018-02-13 16:40:48 +0200182 cmd: sleep 30; salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@grafana:client' state.sls grafana.client
Dennis Dmitriev411dd102017-09-15 16:04:47 +0300183 node_name: {{ HOSTNAME_CFG01 }}
184 retry: {count: 2, delay: 10}
185 skip_fail: false
186
187- description: Run salt minion to create cert files
188 cmd: salt --hard-crash --state-output=mixed --state-verbose=False "*" state.sls salt.minion
189 node_name: {{ HOSTNAME_CFG01 }}
190 retry: {count: 1, delay: 10}
191 skip_fail: false
192