blob: d277c56905a6c09468984aa852764f12004a2d70 [file] [log] [blame]
Tatyana Leontovich09b7b012017-07-10 12:53:45 +03001{% from 'virtual-mcp11-k8s-contrail/underlay.yaml' import HOSTNAME_CFG01 with context %}
Sergii Golovatiuk17ef1492017-05-29 19:54:03 +02002
3# Install docker swarm
4- description: Configure docker service
5 cmd: salt -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 -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 -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 -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 -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
Tatyana Leontovich2fec09a2017-08-22 13:52:11 +030034- description: Rerun swarm on slaves to proper token population
35 cmd: salt -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
Sergii Golovatiuk17ef1492017-05-29 19:54:03 +020040- description: Configure slave nodes
41 cmd: salt -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 -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
52# Install slv2 infra
53- description: Install telegraf
Tatyana Leontovich09b7b012017-07-10 12:53:45 +030054 cmd: salt -C 'I@telegraf:agentor or I@telegraf:remote_agent' state.sls telegraf
55 node_name: {{ HOSTNAME_CFG01 }}
Tatyana Leontovich2fec09a2017-08-22 13:52:11 +030056 retry: {count: 2, delay: 10}
57 skip_fail: false
58
Dennis Dmitrievcc6e9b52017-09-01 11:27:58 +030059- description: Configure Prometheus exporters, if pillar 'prometheus:exporters' exists on any server
60 cmd: |
61 if salt -C 'I@prometheus:exporters' match.pillar 'prometheus:exporters' ; then
62 salt -C 'I@prometheus:exporters' state.sls prometheus
63 fi
Tatyana Leontovich2fec09a2017-08-22 13:52:11 +030064 node_name: {{ HOSTNAME_CFG01 }}
Tatyana Leontovich09b7b012017-07-10 12:53:45 +030065 retry: {count: 1, delay: 10}
66 skip_fail: false
67
68- description: Configure collector
69 cmd: salt -C 'I@heka:log_collector' state.sls heka.log_collector
Sergii Golovatiuk17ef1492017-05-29 19:54:03 +020070 node_name: {{ HOSTNAME_CFG01 }}
71 retry: {count: 1, delay: 10}
72 skip_fail: false
73
74- description: Install elasticsearch server
75 cmd: salt -C 'I@elasticsearch:server' state.sls elasticsearch.server -b 1
76 node_name: {{ HOSTNAME_CFG01 }}
77 retry: {count: 1, delay: 10}
78 skip_fail: false
79
80- description: Install kibana server
81 cmd: salt -C 'I@kibana:server' state.sls kibana.server -b 1
82 node_name: {{ HOSTNAME_CFG01 }}
83 retry: {count: 1, delay: 10}
84 skip_fail: false
85
Sergii Golovatiuk17ef1492017-05-29 19:54:03 +020086- description: Install elasticsearch client
87 cmd: salt -C 'I@elasticsearch:client' state.sls elasticsearch.client
88 node_name: {{ HOSTNAME_CFG01 }}
89 retry: {count: 1, delay: 10}
90 skip_fail: false
91
92- description: Install kibana client
93 cmd: salt -C 'I@kibana:client' state.sls kibana.client
94 node_name: {{ HOSTNAME_CFG01 }}
95 retry: {count: 1, delay: 10}
96 skip_fail: false
97
Tatyana Leontovich09b7b012017-07-10 12:53:45 +030098- description: Check influix db
99 cmd: |
100 INFLUXDB_SERVICE=`salt -C 'I@influxdb:server' test.ping 1>/dev/null 2>&1 && echo true`;
101 echo "Influxdb service presence: ${INFLUXDB_SERVICE}";
102 if [[ "$INFLUXDB_SERVICE" == "true" ]]; then
103 salt -C 'I@influxdb:server' state.sls influxdb
104 fi
105 node_name: {{ HOSTNAME_CFG01 }}
106 retry: {count: 1, delay: 5}
107 skip_fail: true
108
Sergii Golovatiuk17ef1492017-05-29 19:54:03 +0200109# Collect grains needed to configure the services
110
111- description: Get grains
112 cmd: salt -C 'I@salt:minion' state.sls salt.minion.grains
113 node_name: {{ HOSTNAME_CFG01 }}
114 retry: {count: 1, delay: 10}
115 skip_fail: false
116
117- description: Sync modules
118 cmd: salt -C 'I@salt:minion' saltutil.refresh_modules
119 node_name: {{ HOSTNAME_CFG01 }}
120 retry: {count: 1, delay: 10}
121 skip_fail: false
122
123- description: Update mine
124 cmd: salt -C 'I@salt:minion' mine.update; sleep 5;
125 node_name: {{ HOSTNAME_CFG01 }}
126 retry: {count: 1, delay: 10}
127 skip_fail: false
128
Tatyana Leontovich09b7b012017-07-10 12:53:45 +0300129# Change environment configuration before deploy
130- description: Set SL docker images deploy parameters
131 cmd: |
132 {% for sl_opt, value in config.sl_deploy.items() %}
133 {% if value|string() %}
134 salt-call reclass.cluster_meta_set {{ sl_opt }} {{ value }};
135 {% endif %}
136 {% endfor %}
Sergii Golovatiuk17ef1492017-05-29 19:54:03 +0200137 node_name: {{ HOSTNAME_CFG01 }}
138 retry: {count: 1, delay: 1}
139 skip_fail: false
140
Tatyana Leontovich09b7b012017-07-10 12:53:45 +0300141# Configure the services running in Docker Swarm
142- description: Install prometheus alertmanager
143 cmd: salt -C 'I@docker:swarm' state.sls prometheus,heka.remote_collector -b 1
144 node_name: {{ HOSTNAME_CFG01 }}
145 retry: {count: 1, delay: 10}
146 skip_fail: false
147
Sergii Golovatiuk17ef1492017-05-29 19:54:03 +0200148- description: run docker state
149 cmd: salt -C 'I@docker:swarm:role:master' state.sls docker
150 node_name: {{ HOSTNAME_CFG01 }}
151 retry: {count: 1, delay: 10}
152 skip_fail: false
153
154- description: docker ps
155 cmd: salt -C 'I@docker:swarm' dockerng.ps
156 node_name: {{ HOSTNAME_CFG01 }}
157 retry: {count: 1, delay: 10}
158 skip_fail: false
159
Tatyana Leontovich6c696e62017-07-31 16:39:16 +0300160- description: Restart keepalived service
161 cmd: salt -C 'mon*' cmd.run "systemctl restart keepalived"
162 node_name: {{ HOSTNAME_CFG01 }}
163 retry: {count: 1, delay: 10}
164 skip_fail: false
165
166- description: Check the VIP
167 cmd: |
168 SL_MONITOR_ADDRESS=`salt-call --out=newline_values_only pillar.get _param:stacklight_monitor_address`;
169 echo "_param:stacklight_monitor_address (vip): ${SL_MONITOR_ADDRESS}";
170 salt --hard-crash --state-output=mixed --state-verbose=False -C 'mon*' cmd.run "ip a | grep ${SL_MONITOR_ADDRESS}" | grep -B1 ${SL_MONITOR_ADDRESS}
171 node_name: {{ HOSTNAME_CFG01 }}
172 retry: {count: 1, delay: 5}
173 skip_fail: false
174
Sergii Golovatiuk17ef1492017-05-29 19:54:03 +0200175- description: Configure Grafana dashboards and datasources
Tatyana Leontovich572f7492017-07-14 13:36:11 +0300176 cmd: sleep 30; salt -C 'I@grafana:client' state.sls grafana.client
Sergii Golovatiuk17ef1492017-05-29 19:54:03 +0200177 node_name: {{ HOSTNAME_CFG01 }}
Tatyana Leontovich572f7492017-07-14 13:36:11 +0300178 retry: {count: 2, delay: 10}
Sergii Golovatiuk17ef1492017-05-29 19:54:03 +0200179 skip_fail: false
Tatyana Leontovichea450642017-07-11 18:56:11 +0300180
181- description: Run salt minion to create cert files
182 cmd: salt --hard-crash --state-output=mixed --state-verbose=False "*" state.sls salt.minion
183 node_name: {{ HOSTNAME_CFG01 }}
184 retry: {count: 1, delay: 10}
185 skip_fail: false