blob: 5a60b3818d8fbb8a5ee8b5edafc748a2cb1f5f84 [file] [log] [blame]
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +03001{% from 'virtual-mcp-ocata-cicd/underlay.yaml' import HOSTNAME_CFG01 with context %}
2
Dennis Dmitrievf8546172017-07-20 21:57:05 +03003# Pattern that helps salt to select Stacklight nodes
Dennis Dmitriev41f0b792017-07-27 18:08:50 +03004{% set SL_NODES_SELECTOR = os_env('SL_NODES_SELECTOR','cid*') %}
Dennis Dmitrievf8546172017-07-20 21:57:05 +03005
Dennis Dmitriev41f0b792017-07-27 18:08:50 +03006#=====================
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +03007# Install docker swarm
Dennis Dmitriev41f0b792017-07-27 18:08:50 +03008#=====================
9
Dennis Dmitrievf8546172017-07-20 21:57:05 +030010- description: Prepare Docker host
11 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:host and {{ SL_NODES_SELECTOR }}' state.sls docker.host
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +030012 node_name: {{ HOSTNAME_CFG01 }}
Dennis Dmitrievf8546172017-07-20 21:57:05 +030013 retry: {count: 1, delay: 5}
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +030014 skip_fail: false
15
Dennis Dmitrievf8546172017-07-20 21:57:05 +030016- description: Install Docker Swarm master
17 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master and {{ SL_NODES_SELECTOR }}' state.sls docker.swarm
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +030018 node_name: {{ HOSTNAME_CFG01 }}
Dennis Dmitrievf8546172017-07-20 21:57:05 +030019 retry: {count: 1, delay: 5}
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +030020 skip_fail: false
21
Dennis Dmitriev41f0b792017-07-27 18:08:50 +030022- description: Collect grains
23 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master and {{ SL_NODES_SELECTOR }}' state.sls salt.minion.grains &&
Dennis Dmitrievf8546172017-07-20 21:57:05 +030024 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master and {{ SL_NODES_SELECTOR }}' mine.flush &&
Dennis Dmitriev41f0b792017-07-27 18:08:50 +030025 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master and {{ SL_NODES_SELECTOR }}' mine.update &&
26 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm and {{ SL_NODES_SELECTOR }}' saltutil.refresh_modules &&
27 sleep 5
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +030028 node_name: {{ HOSTNAME_CFG01 }}
Dennis Dmitrievf8546172017-07-20 21:57:05 +030029 retry: {count: 3, delay: 15}
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +030030 skip_fail: false
31
Dennis Dmitrievf8546172017-07-20 21:57:05 +030032- description: Install Docker Swarm on other nodes
Dennis Dmitriev41f0b792017-07-27 18:08:50 +030033 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:manager and {{ SL_NODES_SELECTOR }}' state.sls docker.swarm
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +030034 node_name: {{ HOSTNAME_CFG01 }}
Dennis Dmitrievf8546172017-07-20 21:57:05 +030035 retry: {count: 1, delay: 5}
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +030036 skip_fail: false
37
Dennis Dmitrievf8546172017-07-20 21:57:05 +030038- description: Show Docker Swarm nodes
39 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master and {{ SL_NODES_SELECTOR }}' cmd.run 'docker node ls'
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +030040 node_name: {{ HOSTNAME_CFG01 }}
Dennis Dmitrievf8546172017-07-20 21:57:05 +030041 retry: {count: 1, delay: 5}
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +030042 skip_fail: false
43
Dennis Dmitriev41f0b792017-07-27 18:08:50 +030044#===================
45# Install StackLight
46#===================
47
48# Haproxy: installed in common-services
49#--------------------------------------
50
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +030051- description: Install telegraf
Dennis Dmitrievf8546172017-07-20 21:57:05 +030052 cmd: salt -C 'I@telegraf:agent or I@telegraf:remote_agent' state.sls telegraf
Dennis Dmitrievf512dce2017-07-18 16:45:05 +030053 node_name: {{ HOSTNAME_CFG01 }}
54 retry: {count: 1, delay: 10}
55 skip_fail: false
56
Dennis Dmitrievcc6e9b52017-09-01 11:27:58 +030057- description: Configure Prometheus exporters, if pillar 'prometheus:exporters' exists on any server
Dennis Dmitriev41f0b792017-07-27 18:08:50 +030058 cmd: |
59 if salt -C 'I@prometheus:exporters' match.pillar 'prometheus:exporters' ; then
60 salt -C 'I@prometheus:exporters' state.sls prometheus
61 fi
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +030062 node_name: {{ HOSTNAME_CFG01 }}
63 retry: {count: 1, delay: 10}
64 skip_fail: false
65
Dennis Dmitriev41f0b792017-07-27 18:08:50 +030066
Dennis Dmitriev41f0b792017-07-27 18:08:50 +030067# Elasticsearch
68- description: Waiting for Elasticsearch to come up in container...
69 cmd: timeout 60 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@elasticsearch:server' cmd.run
70 'export CICD_CONTROL_ADDRESS=$(salt-call --out=newline_values_only pillar.get _param:cicd_control_address);
71 while true; do curl -sf http://${CICD_CONTROL_ADDRESS}:9200 && break; sleep 2; done'
72 node_name: {{ HOSTNAME_CFG01 }}
73 retry: {count: 3, delay: 30}
74 skip_fail: false
75
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +030076- description: Install elasticsearch server
Dennis Dmitriev41f0b792017-07-27 18:08:50 +030077 cmd: salt -C 'I@elasticsearch:server and *01*' state.sls elasticsearch.server &&
78 salt -C 'I@elasticsearch:server' state.sls elasticsearch.server -b 1
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +030079 node_name: {{ HOSTNAME_CFG01 }}
80 retry: {count: 1, delay: 10}
81 skip_fail: false
82
83- description: Install kibana server
Dennis Dmitriev41f0b792017-07-27 18:08:50 +030084 cmd: salt -C 'I@kibana:server and *01*' state.sls kibana.server &&
85 salt -C 'I@kibana:server' state.sls kibana.server -b 1
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +030086 node_name: {{ HOSTNAME_CFG01 }}
87 retry: {count: 1, delay: 10}
88 skip_fail: false
89
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +030090- description: Install elasticsearch client
91 cmd: salt -C 'I@elasticsearch:client' state.sls elasticsearch.client
92 node_name: {{ HOSTNAME_CFG01 }}
93 retry: {count: 1, delay: 10}
94 skip_fail: false
95
96- description: Install kibana client
97 cmd: salt -C 'I@kibana:client' state.sls kibana.client
98 node_name: {{ HOSTNAME_CFG01 }}
99 retry: {count: 1, delay: 10}
100 skip_fail: false
101
Dennis Dmitriev41f0b792017-07-27 18:08:50 +0300102- description: Install influixdb
103 cmd: salt -C 'I@influxdb:server' state.sls influxdb
Dennis Dmitrievf512dce2017-07-18 16:45:05 +0300104 node_name: {{ HOSTNAME_CFG01 }}
105 retry: {count: 1, delay: 5}
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300106 skip_fail: false
107
Dennis Dmitriev41f0b792017-07-27 18:08:50 +0300108
109
110# Collect grains. Looks like this is an excess step, but it is present in the pipeline at the moment.
111- description: Collect grains
112 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master and {{ SL_NODES_SELECTOR }}' state.sls salt.minion.grains &&
113 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm and {{ SL_NODES_SELECTOR }}' saltutil.refresh_modules &&
114 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master and {{ SL_NODES_SELECTOR }}' mine.flush &&
115 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master and {{ SL_NODES_SELECTOR }}' mine.update &&
116 sleep 5
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300117 node_name: {{ HOSTNAME_CFG01 }}
Dennis Dmitriev41f0b792017-07-27 18:08:50 +0300118 retry: {count: 3, delay: 15}
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300119 skip_fail: false
120
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300121
Dennis Dmitrievf512dce2017-07-18 16:45:05 +0300122# Change environment configuration before deploy
123- description: Set SL docker images deploy parameters
124 cmd: |
125 {% for sl_opt, value in config.sl_deploy.items() %}
126 {% if value|string() %}
127 salt-call reclass.cluster_meta_set {{ sl_opt }} {{ value }};
128 {% endif %}
129 {% endfor %}
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300130 node_name: {{ HOSTNAME_CFG01 }}
131 retry: {count: 1, delay: 1}
132 skip_fail: false
133
Dennis Dmitrievf512dce2017-07-18 16:45:05 +0300134# Configure the services running in Docker Swarm
135- description: Install prometheus alertmanager
Dennis Dmitrievf8546172017-07-20 21:57:05 +0300136 cmd: salt -C 'I@docker:swarm and {{ SL_NODES_SELECTOR }}' state.sls prometheus,heka.remote_collector -b 1
Dennis Dmitrievf512dce2017-07-18 16:45:05 +0300137 node_name: {{ HOSTNAME_CFG01 }}
138 retry: {count: 1, delay: 10}
139 skip_fail: false
140
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300141- description: run docker state
Dennis Dmitrievf8546172017-07-20 21:57:05 +0300142 cmd: salt -C 'I@docker:swarm:role:master and {{ SL_NODES_SELECTOR }}' state.sls docker
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300143 node_name: {{ HOSTNAME_CFG01 }}
144 retry: {count: 1, delay: 10}
145 skip_fail: false
146
147- description: docker ps
Dennis Dmitrievf8546172017-07-20 21:57:05 +0300148 cmd: salt -C 'I@docker:swarm and {{ SL_NODES_SELECTOR }}' dockerng.ps
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300149 node_name: {{ HOSTNAME_CFG01 }}
150 retry: {count: 1, delay: 10}
151 skip_fail: false
152
Dennis Dmitriev41f0b792017-07-27 18:08:50 +0300153
154- description: Waiting for Elasticsearch to come up in container...
155 cmd: timeout 120 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm and {{ SL_NODES_SELECTOR }}' cmd.run
156 'export CICD_CONTROL_ADDRESS=$(salt-call --out=newline_values_only pillar.get _param:cicd_control_address);
157 while true; do curl -sf http://${CICD_CONTROL_ADDRESS}:15013 && break; sleep 2; done'
158 node_name: {{ HOSTNAME_CFG01 }}
159 retry: {count: 3, delay: 30}
160 skip_fail: false
161
162
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300163- description: Configure Grafana dashboards and datasources
Dennis Dmitrievf512dce2017-07-18 16:45:05 +0300164 cmd: sleep 30; salt -C 'I@grafana:client' state.sls grafana.client
165 node_name: {{ HOSTNAME_CFG01 }}
166 retry: {count: 2, delay: 10}
167 skip_fail: false
168
Dennis Dmitriev41f0b792017-07-27 18:08:50 +0300169- description: Configure collector
170 cmd: salt -C 'I@heka:log_collector' state.sls heka.log_collector
171 node_name: {{ HOSTNAME_CFG01 }}
172 retry: {count: 1, delay: 10}
173 skip_fail: false
174
Dennis Dmitrievf512dce2017-07-18 16:45:05 +0300175- description: Run salt minion to create cert files
176 cmd: salt --hard-crash --state-output=mixed --state-verbose=False "*" state.sls salt.minion
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300177 node_name: {{ HOSTNAME_CFG01 }}
178 retry: {count: 1, delay: 10}
179 skip_fail: false