blob: 7e0faf319ab1266d2064f335c10f8188050ca14b [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
4{% set SL_NODES_SELECTOR = os_env('SL_NODES_SELECTOR','mon*') %}
5
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +03006# Install docker swarm
Dennis Dmitrievf8546172017-07-20 21:57:05 +03007- description: Prepare Docker host
8 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 +03009 node_name: {{ HOSTNAME_CFG01 }}
Dennis Dmitrievf8546172017-07-20 21:57:05 +030010 retry: {count: 1, delay: 5}
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +030011 skip_fail: false
12
Dennis Dmitrievf8546172017-07-20 21:57:05 +030013- description: Install Docker Swarm master
14 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 +030015 node_name: {{ HOSTNAME_CFG01 }}
Dennis Dmitrievf8546172017-07-20 21:57:05 +030016 retry: {count: 1, delay: 5}
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +030017 skip_fail: false
18
Dennis Dmitrievf8546172017-07-20 21:57:05 +030019- description: Setup salt-minion on docker swarm master
20 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master and {{ SL_NODES_SELECTOR }}' state.sls salt &&
21 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master and {{ SL_NODES_SELECTOR }}' mine.flush &&
22 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master and {{ SL_NODES_SELECTOR }}' mine.update
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +030023 node_name: {{ HOSTNAME_CFG01 }}
Dennis Dmitrievf8546172017-07-20 21:57:05 +030024 retry: {count: 3, delay: 15}
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +030025 skip_fail: false
26
Dennis Dmitrievf8546172017-07-20 21:57:05 +030027- description: Install Docker Swarm on other nodes
28 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm and {{ SL_NODES_SELECTOR }}' state.sls docker.swarm
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +030029 node_name: {{ HOSTNAME_CFG01 }}
Dennis Dmitrievf8546172017-07-20 21:57:05 +030030 retry: {count: 1, delay: 5}
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +030031 skip_fail: false
32
Dennis Dmitrievf8546172017-07-20 21:57:05 +030033- description: Show Docker Swarm nodes
34 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 +030035 node_name: {{ HOSTNAME_CFG01 }}
Dennis Dmitrievf8546172017-07-20 21:57:05 +030036 retry: {count: 1, delay: 5}
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +030037 skip_fail: false
38
39# Install slv2 infra
40- description: Install telegraf
Dennis Dmitrievf8546172017-07-20 21:57:05 +030041 cmd: salt -C 'I@telegraf:agent or I@telegraf:remote_agent' state.sls telegraf
Dennis Dmitrievf512dce2017-07-18 16:45:05 +030042 node_name: {{ HOSTNAME_CFG01 }}
43 retry: {count: 1, delay: 10}
44 skip_fail: false
45
46- description: Configure collector
47 cmd: salt -C 'I@heka:log_collector' state.sls heka.log_collector
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +030048 node_name: {{ HOSTNAME_CFG01 }}
49 retry: {count: 1, delay: 10}
50 skip_fail: false
51
52- description: Install elasticsearch server
53 cmd: salt -C 'I@elasticsearch:server' state.sls elasticsearch.server -b 1
54 node_name: {{ HOSTNAME_CFG01 }}
55 retry: {count: 1, delay: 10}
56 skip_fail: false
57
58- description: Install kibana server
59 cmd: salt -C 'I@kibana:server' state.sls kibana.server -b 1
60 node_name: {{ HOSTNAME_CFG01 }}
61 retry: {count: 1, delay: 10}
62 skip_fail: false
63
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +030064- description: Install elasticsearch client
65 cmd: salt -C 'I@elasticsearch:client' state.sls elasticsearch.client
66 node_name: {{ HOSTNAME_CFG01 }}
67 retry: {count: 1, delay: 10}
68 skip_fail: false
69
70- description: Install kibana client
71 cmd: salt -C 'I@kibana:client' state.sls kibana.client
72 node_name: {{ HOSTNAME_CFG01 }}
73 retry: {count: 1, delay: 10}
74 skip_fail: false
75
Dennis Dmitrievf512dce2017-07-18 16:45:05 +030076- description: Check influix db
77 cmd: |
78 INFLUXDB_SERVICE=`salt -C 'I@influxdb:server' test.ping 1>/dev/null 2>&1 && echo true`;
79 echo "Influxdb service presence: ${INFLUXDB_SERVICE}";
80 if [[ "$INFLUXDB_SERVICE" == "true" ]]; then
81 salt -C 'I@influxdb:server' state.sls influxdb
82 fi
83 node_name: {{ HOSTNAME_CFG01 }}
84 retry: {count: 1, delay: 5}
85 skip_fail: true
86
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +030087# Collect grains needed to configure the services
88
89- description: Get grains
90 cmd: salt -C 'I@salt:minion' state.sls salt.minion.grains
91 node_name: {{ HOSTNAME_CFG01 }}
92 retry: {count: 1, delay: 10}
93 skip_fail: false
94
95- description: Sync modules
96 cmd: salt -C 'I@salt:minion' saltutil.refresh_modules
97 node_name: {{ HOSTNAME_CFG01 }}
98 retry: {count: 1, delay: 10}
99 skip_fail: false
100
101- description: Update mine
102 cmd: salt -C 'I@salt:minion' mine.update; sleep 5;
103 node_name: {{ HOSTNAME_CFG01 }}
104 retry: {count: 1, delay: 10}
105 skip_fail: false
106
Dennis Dmitrievf512dce2017-07-18 16:45:05 +0300107# Change environment configuration before deploy
108- description: Set SL docker images deploy parameters
109 cmd: |
110 {% for sl_opt, value in config.sl_deploy.items() %}
111 {% if value|string() %}
112 salt-call reclass.cluster_meta_set {{ sl_opt }} {{ value }};
113 {% endif %}
114 {% endfor %}
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300115 node_name: {{ HOSTNAME_CFG01 }}
116 retry: {count: 1, delay: 1}
117 skip_fail: false
118
Dennis Dmitrievf512dce2017-07-18 16:45:05 +0300119# Configure the services running in Docker Swarm
120- description: Install prometheus alertmanager
Dennis Dmitrievf8546172017-07-20 21:57:05 +0300121 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 +0300122 node_name: {{ HOSTNAME_CFG01 }}
123 retry: {count: 1, delay: 10}
124 skip_fail: false
125
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300126- description: run docker state
Dennis Dmitrievf8546172017-07-20 21:57:05 +0300127 cmd: salt -C 'I@docker:swarm:role:master and {{ SL_NODES_SELECTOR }}' state.sls docker
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300128 node_name: {{ HOSTNAME_CFG01 }}
129 retry: {count: 1, delay: 10}
130 skip_fail: false
131
132- description: docker ps
Dennis Dmitrievf8546172017-07-20 21:57:05 +0300133 cmd: salt -C 'I@docker:swarm and {{ SL_NODES_SELECTOR }}' dockerng.ps
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300134 node_name: {{ HOSTNAME_CFG01 }}
135 retry: {count: 1, delay: 10}
136 skip_fail: false
137
138- description: Configure Grafana dashboards and datasources
Dennis Dmitrievf512dce2017-07-18 16:45:05 +0300139 cmd: sleep 30; salt -C 'I@grafana:client' state.sls grafana.client
140 node_name: {{ HOSTNAME_CFG01 }}
141 retry: {count: 2, delay: 10}
142 skip_fail: false
143
144- description: Run salt minion to create cert files
145 cmd: salt --hard-crash --state-output=mixed --state-verbose=False "*" state.sls salt.minion
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300146 node_name: {{ HOSTNAME_CFG01 }}
147 retry: {count: 1, delay: 10}
148 skip_fail: false