blob: f3d07fc5c2c7490281434a8c7a0cb0b0737dc8a4 [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 Dmitriev41f0b792017-07-27 18:08:50 +030057- description: Install Prometheus exporters, if pillar 'prometheus:exporters' exists on any server
58 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
67
68
69# Elasticsearch
70- description: Waiting for Elasticsearch to come up in container...
71 cmd: timeout 60 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@elasticsearch:server' cmd.run
72 'export CICD_CONTROL_ADDRESS=$(salt-call --out=newline_values_only pillar.get _param:cicd_control_address);
73 while true; do curl -sf http://${CICD_CONTROL_ADDRESS}:9200 && break; sleep 2; done'
74 node_name: {{ HOSTNAME_CFG01 }}
75 retry: {count: 3, delay: 30}
76 skip_fail: false
77
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +030078- description: Install elasticsearch server
Dennis Dmitriev41f0b792017-07-27 18:08:50 +030079 cmd: salt -C 'I@elasticsearch:server and *01*' state.sls elasticsearch.server &&
80 salt -C 'I@elasticsearch:server' state.sls elasticsearch.server -b 1
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +030081 node_name: {{ HOSTNAME_CFG01 }}
82 retry: {count: 1, delay: 10}
83 skip_fail: false
84
85- description: Install kibana server
Dennis Dmitriev41f0b792017-07-27 18:08:50 +030086 cmd: salt -C 'I@kibana:server and *01*' state.sls kibana.server &&
87 salt -C 'I@kibana:server' state.sls kibana.server -b 1
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +030088 node_name: {{ HOSTNAME_CFG01 }}
89 retry: {count: 1, delay: 10}
90 skip_fail: false
91
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +030092- description: Install elasticsearch client
93 cmd: salt -C 'I@elasticsearch:client' state.sls elasticsearch.client
94 node_name: {{ HOSTNAME_CFG01 }}
95 retry: {count: 1, delay: 10}
96 skip_fail: false
97
98- description: Install kibana client
99 cmd: salt -C 'I@kibana:client' state.sls kibana.client
100 node_name: {{ HOSTNAME_CFG01 }}
101 retry: {count: 1, delay: 10}
102 skip_fail: false
103
Dennis Dmitriev41f0b792017-07-27 18:08:50 +0300104- description: Install influixdb
105 cmd: salt -C 'I@influxdb:server' state.sls influxdb
Dennis Dmitrievf512dce2017-07-18 16:45:05 +0300106 node_name: {{ HOSTNAME_CFG01 }}
107 retry: {count: 1, delay: 5}
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300108 skip_fail: false
109
Dennis Dmitriev41f0b792017-07-27 18:08:50 +0300110
111
112# Collect grains. Looks like this is an excess step, but it is present in the pipeline at the moment.
113- description: Collect grains
114 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 &&
115 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm and {{ SL_NODES_SELECTOR }}' saltutil.refresh_modules &&
116 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master and {{ SL_NODES_SELECTOR }}' mine.flush &&
117 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master and {{ SL_NODES_SELECTOR }}' mine.update &&
118 sleep 5
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300119 node_name: {{ HOSTNAME_CFG01 }}
Dennis Dmitriev41f0b792017-07-27 18:08:50 +0300120 retry: {count: 3, delay: 15}
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300121 skip_fail: false
122
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300123
Dennis Dmitrievf512dce2017-07-18 16:45:05 +0300124# Change environment configuration before deploy
125- description: Set SL docker images deploy parameters
126 cmd: |
127 {% for sl_opt, value in config.sl_deploy.items() %}
128 {% if value|string() %}
129 salt-call reclass.cluster_meta_set {{ sl_opt }} {{ value }};
130 {% endif %}
131 {% endfor %}
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300132 node_name: {{ HOSTNAME_CFG01 }}
133 retry: {count: 1, delay: 1}
134 skip_fail: false
135
Dennis Dmitrievf512dce2017-07-18 16:45:05 +0300136# Configure the services running in Docker Swarm
137- description: Install prometheus alertmanager
Dennis Dmitrievf8546172017-07-20 21:57:05 +0300138 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 +0300139 node_name: {{ HOSTNAME_CFG01 }}
140 retry: {count: 1, delay: 10}
141 skip_fail: false
142
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300143- description: run docker state
Dennis Dmitrievf8546172017-07-20 21:57:05 +0300144 cmd: salt -C 'I@docker:swarm:role:master and {{ SL_NODES_SELECTOR }}' state.sls docker
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300145 node_name: {{ HOSTNAME_CFG01 }}
146 retry: {count: 1, delay: 10}
147 skip_fail: false
148
149- description: docker ps
Dennis Dmitrievf8546172017-07-20 21:57:05 +0300150 cmd: salt -C 'I@docker:swarm and {{ SL_NODES_SELECTOR }}' dockerng.ps
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300151 node_name: {{ HOSTNAME_CFG01 }}
152 retry: {count: 1, delay: 10}
153 skip_fail: false
154
Dennis Dmitriev41f0b792017-07-27 18:08:50 +0300155
156- description: Waiting for Elasticsearch to come up in container...
157 cmd: timeout 120 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm and {{ SL_NODES_SELECTOR }}' cmd.run
158 'export CICD_CONTROL_ADDRESS=$(salt-call --out=newline_values_only pillar.get _param:cicd_control_address);
159 while true; do curl -sf http://${CICD_CONTROL_ADDRESS}:15013 && break; sleep 2; done'
160 node_name: {{ HOSTNAME_CFG01 }}
161 retry: {count: 3, delay: 30}
162 skip_fail: false
163
164
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300165- description: Configure Grafana dashboards and datasources
Dennis Dmitrievf512dce2017-07-18 16:45:05 +0300166 cmd: sleep 30; salt -C 'I@grafana:client' state.sls grafana.client
167 node_name: {{ HOSTNAME_CFG01 }}
168 retry: {count: 2, delay: 10}
169 skip_fail: false
170
Dennis Dmitriev41f0b792017-07-27 18:08:50 +0300171- description: Configure collector
172 cmd: salt -C 'I@heka:log_collector' state.sls heka.log_collector
173 node_name: {{ HOSTNAME_CFG01 }}
174 retry: {count: 1, delay: 10}
175 skip_fail: false
176
Dennis Dmitrievf512dce2017-07-18 16:45:05 +0300177- description: Run salt minion to create cert files
178 cmd: salt --hard-crash --state-output=mixed --state-verbose=False "*" state.sls salt.minion
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300179 node_name: {{ HOSTNAME_CFG01 }}
180 retry: {count: 1, delay: 10}
181 skip_fail: false