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