Dennis Dmitriev | 411dd10 | 2017-09-15 16:04:47 +0300 | [diff] [blame] | 1 | {% from 'cookied-mcp-ocata-dop-sl2/underlay.yaml' import HOSTNAME_CFG01 with context %} |
Dennis Dmitriev | 386845b | 2017-11-21 13:11:12 +0200 | [diff] [blame] | 2 | {% from 'cookied-mcp-ocata-dop-sl2/salt.yaml' import ENVIRONMENT_MODEL_INVENTORY_NAME with context %} |
Dennis Dmitriev | 411dd10 | 2017-09-15 16:04:47 +0300 | [diff] [blame] | 3 | |
| 4 | # Install docker swarm |
Dennis Dmitriev | 411dd10 | 2017-09-15 16:04:47 +0300 | [diff] [blame] | 5 | - description: Configure docker service |
Dennis Dmitriev | 281221b | 2018-02-13 16:40:48 +0200 | [diff] [blame] | 6 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm' state.sls docker.host |
Dennis Dmitriev | 411dd10 | 2017-09-15 16:04:47 +0300 | [diff] [blame] | 7 | node_name: {{ HOSTNAME_CFG01 }} |
| 8 | retry: {count: 1, delay: 10} |
| 9 | skip_fail: false |
| 10 | |
| 11 | - description: Install docker swarm on master node |
Dennis Dmitriev | 281221b | 2018-02-13 16:40:48 +0200 | [diff] [blame] | 12 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master' state.sls docker.swarm |
Dennis Dmitriev | 411dd10 | 2017-09-15 16:04:47 +0300 | [diff] [blame] | 13 | node_name: {{ HOSTNAME_CFG01 }} |
| 14 | retry: {count: 1, delay: 10} |
| 15 | skip_fail: false |
| 16 | |
| 17 | - description: Send grains to the swarm slave nodes |
Dennis Dmitriev | 281221b | 2018-02-13 16:40:48 +0200 | [diff] [blame] | 18 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm' state.sls salt.minion.grains |
Dennis Dmitriev | 411dd10 | 2017-09-15 16:04:47 +0300 | [diff] [blame] | 19 | node_name: {{ HOSTNAME_CFG01 }} |
| 20 | retry: {count: 1, delay: 10} |
| 21 | skip_fail: false |
| 22 | |
| 23 | - description: Update mine |
Dennis Dmitriev | 281221b | 2018-02-13 16:40:48 +0200 | [diff] [blame] | 24 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm' mine.update |
Dennis Dmitriev | 411dd10 | 2017-09-15 16:04:47 +0300 | [diff] [blame] | 25 | node_name: {{ HOSTNAME_CFG01 }} |
| 26 | retry: {count: 1, delay: 10} |
| 27 | skip_fail: false |
| 28 | |
| 29 | - description: Refresh modules |
Dennis Dmitriev | 281221b | 2018-02-13 16:40:48 +0200 | [diff] [blame] | 30 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm' saltutil.refresh_modules; sleep 5; |
Dennis Dmitriev | 411dd10 | 2017-09-15 16:04:47 +0300 | [diff] [blame] | 31 | node_name: {{ HOSTNAME_CFG01 }} |
| 32 | retry: {count: 1, delay: 10} |
| 33 | skip_fail: false |
| 34 | |
| 35 | - description: Rerun swarm on slaves to proper token population |
Dennis Dmitriev | 281221b | 2018-02-13 16:40:48 +0200 | [diff] [blame] | 36 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master' state.sls docker.swarm |
Dennis Dmitriev | 411dd10 | 2017-09-15 16:04:47 +0300 | [diff] [blame] | 37 | node_name: {{ HOSTNAME_CFG01 }} |
| 38 | retry: {count: 1, delay: 10} |
| 39 | skip_fail: false |
| 40 | |
| 41 | - description: Configure slave nodes |
Dennis Dmitriev | 281221b | 2018-02-13 16:40:48 +0200 | [diff] [blame] | 42 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:manager' state.sls docker.swarm -b 1 |
Dennis Dmitriev | 411dd10 | 2017-09-15 16:04:47 +0300 | [diff] [blame] | 43 | node_name: {{ HOSTNAME_CFG01 }} |
| 44 | retry: {count: 1, delay: 10} |
| 45 | skip_fail: false |
| 46 | |
| 47 | - description: List registered Docker swarm nodes |
Dennis Dmitriev | 281221b | 2018-02-13 16:40:48 +0200 | [diff] [blame] | 48 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master' cmd.run 'docker node ls' |
Dennis Dmitriev | 411dd10 | 2017-09-15 16:04:47 +0300 | [diff] [blame] | 49 | node_name: {{ HOSTNAME_CFG01 }} |
| 50 | retry: {count: 1, delay: 10} |
| 51 | skip_fail: false |
| 52 | |
Dennis Dmitriev | 002c267 | 2018-03-06 18:43:27 +0200 | [diff] [blame] | 53 | - description: Install keepalived on mon nodes |
| 54 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False |
| 55 | -C 'mon*' state.sls keepalived |
| 56 | node_name: {{ HOSTNAME_CFG01 }} |
| 57 | retry: {count: 1, delay: 10} |
| 58 | skip_fail: false |
| 59 | |
Tatyana Leontovich | cdca5d9 | 2018-03-16 18:31:50 +0200 | [diff] [blame] | 60 | - description: Check the VIP on mon nodes |
Dennis Dmitriev | 002c267 | 2018-03-06 18:43:27 +0200 | [diff] [blame] | 61 | cmd: | |
Tatyana Leontovich | cdca5d9 | 2018-03-16 18:31:50 +0200 | [diff] [blame] | 62 | SL_VIP=`salt-call --out=newline_values_only pillar.get _param:stacklight_monitor_address`; |
| 63 | echo "_param:stacklight_monitor_address (vip): ${SL_VIP}"; |
Dennis Dmitriev | 002c267 | 2018-03-06 18:43:27 +0200 | [diff] [blame] | 64 | salt --hard-crash --state-output=mixed --state-verbose=False -C 'mon*' cmd.run "ip a | grep ${SL_VIP}" | grep -B1 ${SL_VIP} |
| 65 | node_name: {{ HOSTNAME_CFG01 }} |
| 66 | retry: {count: 1, delay: 5} |
| 67 | skip_fail: false |
| 68 | |
Dennis Dmitriev | 411dd10 | 2017-09-15 16:04:47 +0300 | [diff] [blame] | 69 | # Install slv2 infra |
Tatyana Leontovich | cdca5d9 | 2018-03-16 18:31:50 +0200 | [diff] [blame] | 70 | #Launch containers |
| 71 | - description: launch prometheus containers |
| 72 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master and I@prometheus:server' state.sls docker.client |
| 73 | node_name: {{ HOSTNAME_CFG01 }} |
| 74 | retry: {count: 2, delay: 10} |
| 75 | skip_fail: false |
| 76 | |
| 77 | - description: Check docker ps |
| 78 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm and I@prometheus:server' cmd.run "docker ps" |
| 79 | node_name: {{ HOSTNAME_CFG01 }} |
| 80 | retry: {count: 2, delay: 10} |
| 81 | skip_fail: false |
| 82 | |
Dennis Dmitriev | 411dd10 | 2017-09-15 16:04:47 +0300 | [diff] [blame] | 83 | - description: Install telegraf |
Dennis Dmitriev | 281221b | 2018-02-13 16:40:48 +0200 | [diff] [blame] | 84 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@telegraf:agent or I@telegraf:remote_agent' state.sls telegraf |
Dennis Dmitriev | 411dd10 | 2017-09-15 16:04:47 +0300 | [diff] [blame] | 85 | node_name: {{ HOSTNAME_CFG01 }} |
| 86 | retry: {count: 2, delay: 10} |
| 87 | skip_fail: false |
| 88 | |
| 89 | - description: Configure Prometheus exporters, if pillar 'prometheus:exporters' exists on any server |
| 90 | cmd: | |
Dennis Dmitriev | 281221b | 2018-02-13 16:40:48 +0200 | [diff] [blame] | 91 | if salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@prometheus:exporters' match.pillar 'prometheus:exporters' ; then |
| 92 | salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@prometheus:exporters' state.sls prometheus |
Dennis Dmitriev | 411dd10 | 2017-09-15 16:04:47 +0300 | [diff] [blame] | 93 | fi |
| 94 | node_name: {{ HOSTNAME_CFG01 }} |
| 95 | retry: {count: 1, delay: 10} |
| 96 | skip_fail: false |
| 97 | |
Dennis Dmitriev | 411dd10 | 2017-09-15 16:04:47 +0300 | [diff] [blame] | 98 | - description: Install elasticsearch server |
Dennis Dmitriev | 281221b | 2018-02-13 16:40:48 +0200 | [diff] [blame] | 99 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@elasticsearch:server' state.sls elasticsearch.server -b 1 |
Dennis Dmitriev | 411dd10 | 2017-09-15 16:04:47 +0300 | [diff] [blame] | 100 | node_name: {{ HOSTNAME_CFG01 }} |
| 101 | retry: {count: 1, delay: 10} |
| 102 | skip_fail: false |
| 103 | |
| 104 | - description: Install kibana server |
Dennis Dmitriev | 281221b | 2018-02-13 16:40:48 +0200 | [diff] [blame] | 105 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@kibana:server' state.sls kibana.server -b 1 |
Dennis Dmitriev | 411dd10 | 2017-09-15 16:04:47 +0300 | [diff] [blame] | 106 | node_name: {{ HOSTNAME_CFG01 }} |
| 107 | retry: {count: 1, delay: 10} |
| 108 | skip_fail: false |
| 109 | |
| 110 | - description: Install elasticsearch client |
Dennis Dmitriev | 281221b | 2018-02-13 16:40:48 +0200 | [diff] [blame] | 111 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@elasticsearch:client' state.sls elasticsearch.client |
Dennis Dmitriev | 411dd10 | 2017-09-15 16:04:47 +0300 | [diff] [blame] | 112 | node_name: {{ HOSTNAME_CFG01 }} |
| 113 | retry: {count: 1, delay: 10} |
| 114 | skip_fail: false |
| 115 | |
| 116 | - description: Install kibana client |
Dennis Dmitriev | 281221b | 2018-02-13 16:40:48 +0200 | [diff] [blame] | 117 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@kibana:client' state.sls kibana.client |
Dennis Dmitriev | 411dd10 | 2017-09-15 16:04:47 +0300 | [diff] [blame] | 118 | node_name: {{ HOSTNAME_CFG01 }} |
| 119 | retry: {count: 1, delay: 10} |
| 120 | skip_fail: false |
| 121 | |
| 122 | - description: Check influix db |
| 123 | cmd: | |
Dennis Dmitriev | 281221b | 2018-02-13 16:40:48 +0200 | [diff] [blame] | 124 | 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 Dmitriev | 411dd10 | 2017-09-15 16:04:47 +0300 | [diff] [blame] | 125 | echo "Influxdb service presence: ${INFLUXDB_SERVICE}"; |
| 126 | if [[ "$INFLUXDB_SERVICE" == "true" ]]; then |
Dennis Dmitriev | 281221b | 2018-02-13 16:40:48 +0200 | [diff] [blame] | 127 | salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@influxdb:server' state.sls influxdb |
Dennis Dmitriev | 411dd10 | 2017-09-15 16:04:47 +0300 | [diff] [blame] | 128 | fi |
| 129 | node_name: {{ HOSTNAME_CFG01 }} |
| 130 | retry: {count: 1, delay: 5} |
| 131 | skip_fail: true |
| 132 | |
Tatyana Leontovich | cdca5d9 | 2018-03-16 18:31:50 +0200 | [diff] [blame] | 133 | # Install Prometheus LTS(optional if set in model) |
| 134 | - description: Prometheus LTS(optional if set in model) |
| 135 | cmd: | |
| 136 | PROMETHEUS_SERVICE=`salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@prometheus:relay' test.ping 1>/dev/null 2>&1 && echo true`; |
| 137 | echo "PROMETHEUS rely service presence: ${PROMETHEUS_SERVICE}"; |
| 138 | if [[ "$PROMETHEUS_SERVICE" == "true" ]]; then |
| 139 | salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@prometheus:relay' state.sls prometheus |
| 140 | fi |
| 141 | node_name: {{ HOSTNAME_CFG01 }} |
| 142 | retry: {count: 1, delay: 5} |
| 143 | skip_fail: true |
| 144 | |
| 145 | # Install service for the log collection |
| 146 | - description: Configure fluentd |
| 147 | cmd: | |
| 148 | FLUENTD_SERVICE=`salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@fluentd:agent' test.ping 1>/dev/null 2>&1 && echo true`; |
| 149 | echo "Fluentd service presence: ${FLUENTD_SERVICE}"; |
Tatyana Leontovich | 88cd51b | 2018-03-17 00:05:14 +0200 | [diff] [blame] | 150 | if [[ "$FLUENTD_SERVICE" == "true" ]]; then |
Tatyana Leontovich | cdca5d9 | 2018-03-16 18:31:50 +0200 | [diff] [blame] | 151 | salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@fluentd:agent' state.sls fluentd |
| 152 | else |
| 153 | salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@heka:log_collector' state.sls heka.log_collector |
| 154 | fi |
| 155 | node_name: {{ HOSTNAME_CFG01 }} |
| 156 | retry: {count: 1, delay: 10} |
| 157 | skip_fail: false |
| 158 | |
| 159 | #Install heka ceilometer collector |
| 160 | - description: Install heka ceilometer if they exists |
| 161 | cmd: | |
| 162 | CEILO=`salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@heka:ceilometer_collector:enabled' test.ping 1>/dev/null 2>&1 && echo true`; |
| 163 | echo "Ceilometer service presence: ${CEILO}"; |
Tatyana Leontovich | 88cd51b | 2018-03-17 00:05:14 +0200 | [diff] [blame] | 164 | if [[ "$CEILO" == "true" ]]; then |
Tatyana Leontovich | cdca5d9 | 2018-03-16 18:31:50 +0200 | [diff] [blame] | 165 | salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@heka:ceilometer_collector:enabled' state.sls heka.ceilometer_collector; |
| 166 | salt --hard-crash --state-output=mixed --state-verbose=False -C '@heka:ceilometer_collector:enabled' service.restart ceilometer_collector |
| 167 | fi |
| 168 | node_name: {{ HOSTNAME_CFG01 }} |
| 169 | retry: {count: 1, delay: 10} |
| 170 | skip_fail: false |
| 171 | |
Dennis Dmitriev | 411dd10 | 2017-09-15 16:04:47 +0300 | [diff] [blame] | 172 | # Collect grains needed to configure the services |
| 173 | |
| 174 | - description: Get grains |
Dennis Dmitriev | 281221b | 2018-02-13 16:40:48 +0200 | [diff] [blame] | 175 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@salt:minion' state.sls salt.minion.grains |
Dennis Dmitriev | 411dd10 | 2017-09-15 16:04:47 +0300 | [diff] [blame] | 176 | node_name: {{ HOSTNAME_CFG01 }} |
| 177 | retry: {count: 1, delay: 10} |
| 178 | skip_fail: false |
| 179 | |
| 180 | - description: Sync modules |
Dennis Dmitriev | 281221b | 2018-02-13 16:40:48 +0200 | [diff] [blame] | 181 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@salt:minion' saltutil.refresh_modules |
Dennis Dmitriev | 411dd10 | 2017-09-15 16:04:47 +0300 | [diff] [blame] | 182 | node_name: {{ HOSTNAME_CFG01 }} |
| 183 | retry: {count: 1, delay: 10} |
| 184 | skip_fail: false |
| 185 | |
| 186 | - description: Update mine |
Dennis Dmitriev | 281221b | 2018-02-13 16:40:48 +0200 | [diff] [blame] | 187 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@salt:minion' mine.update; sleep 5; |
Dennis Dmitriev | 411dd10 | 2017-09-15 16:04:47 +0300 | [diff] [blame] | 188 | node_name: {{ HOSTNAME_CFG01 }} |
Tatyana Leontovich | cdca5d9 | 2018-03-16 18:31:50 +0200 | [diff] [blame] | 189 | retry: {count: 5, delay: 15} |
Dennis Dmitriev | 411dd10 | 2017-09-15 16:04:47 +0300 | [diff] [blame] | 190 | skip_fail: false |
| 191 | |
Dennis Dmitriev | 411dd10 | 2017-09-15 16:04:47 +0300 | [diff] [blame] | 192 | # Configure the services running in Docker Swarm |
Tatyana Leontovich | cdca5d9 | 2018-03-16 18:31:50 +0200 | [diff] [blame] | 193 | - description: Configure prometheus in docker swarm |
| 194 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm and I@prometheus:server' state.sls prometheus |
Dennis Dmitriev | 411dd10 | 2017-09-15 16:04:47 +0300 | [diff] [blame] | 195 | node_name: {{ HOSTNAME_CFG01 }} |
| 196 | retry: {count: 1, delay: 10} |
| 197 | skip_fail: false |
| 198 | |
Tatyana Leontovich | cdca5d9 | 2018-03-16 18:31:50 +0200 | [diff] [blame] | 199 | - description: Configure Remote Collector in Docker Swarm for Openstack deployments |
| 200 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm and I@prometheus:server' state.sls heka.remote_collector |
Dennis Dmitriev | 411dd10 | 2017-09-15 16:04:47 +0300 | [diff] [blame] | 201 | node_name: {{ HOSTNAME_CFG01 }} |
| 202 | retry: {count: 1, delay: 10} |
| 203 | skip_fail: false |
| 204 | |
Tatyana Leontovich | cdca5d9 | 2018-03-16 18:31:50 +0200 | [diff] [blame] | 205 | - description: Install sphinx |
| 206 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@sphinx:server' state.sls sphinx |
Dennis Dmitriev | 411dd10 | 2017-09-15 16:04:47 +0300 | [diff] [blame] | 207 | node_name: {{ HOSTNAME_CFG01 }} |
| 208 | retry: {count: 1, delay: 10} |
| 209 | skip_fail: false |
| 210 | |
Tatyana Leontovich | cdca5d9 | 2018-03-16 18:31:50 +0200 | [diff] [blame] | 211 | |
| 212 | #- description: Install prometheus alertmanager |
| 213 | # cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm' state.sls prometheus,heka.remote_collector -b 1 |
| 214 | # node_name: {{ HOSTNAME_CFG01 }} |
| 215 | # retry: {count: 1, delay: 10} |
| 216 | # skip_fail: false |
| 217 | |
| 218 | #- description: run docker state |
| 219 | # cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master' state.sls docker |
| 220 | # node_name: {{ HOSTNAME_CFG01 }} |
| 221 | # retry: {count: 1, delay: 10} |
| 222 | # skip_fail: false |
| 223 | # |
| 224 | #- description: docker ps |
| 225 | # cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm' dockerng.ps |
| 226 | # node_name: {{ HOSTNAME_CFG01 }} |
| 227 | # retry: {count: 1, delay: 10} |
| 228 | # skip_fail: false |
| 229 | |
Dennis Dmitriev | 411dd10 | 2017-09-15 16:04:47 +0300 | [diff] [blame] | 230 | - description: Configure Grafana dashboards and datasources |
Dennis Dmitriev | 281221b | 2018-02-13 16:40:48 +0200 | [diff] [blame] | 231 | cmd: sleep 30; salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@grafana:client' state.sls grafana.client |
Dennis Dmitriev | 411dd10 | 2017-09-15 16:04:47 +0300 | [diff] [blame] | 232 | node_name: {{ HOSTNAME_CFG01 }} |
| 233 | retry: {count: 2, delay: 10} |
| 234 | skip_fail: false |
| 235 | |
| 236 | - description: Run salt minion to create cert files |
| 237 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False "*" state.sls salt.minion |
| 238 | node_name: {{ HOSTNAME_CFG01 }} |
| 239 | retry: {count: 1, delay: 10} |
| 240 | skip_fail: false |
| 241 | |