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 |
| 5 | - description: Install keepalived on mon nodes |
| 6 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False |
| 7 | -C 'mon*' state.sls keepalived |
| 8 | node_name: {{ HOSTNAME_CFG01 }} |
| 9 | retry: {count: 1, delay: 10} |
| 10 | skip_fail: false |
| 11 | |
| 12 | - description: Check the VIP on StackLight mon nodes |
| 13 | cmd: | |
| 14 | SL_VIP=$(salt --out=newline_values_only "mon01*" pillar.get _param:cluster_vip_address); |
| 15 | echo "_param:cluster_vip_address (vip): ${SL_VIP}"; |
| 16 | salt --hard-crash --state-output=mixed --state-verbose=False -C 'mon*' cmd.run "ip a | grep ${SL_VIP}" | grep -B1 ${SL_VIP} |
| 17 | node_name: {{ HOSTNAME_CFG01 }} |
| 18 | retry: {count: 1, delay: 5} |
| 19 | skip_fail: false |
| 20 | |
| 21 | - description: Configure docker service |
| 22 | cmd: salt -C 'I@docker:swarm' state.sls docker.host |
| 23 | node_name: {{ HOSTNAME_CFG01 }} |
| 24 | retry: {count: 1, delay: 10} |
| 25 | skip_fail: false |
| 26 | |
| 27 | - description: Install docker swarm on master node |
| 28 | cmd: salt -C 'I@docker:swarm:role:master' state.sls docker.swarm |
| 29 | node_name: {{ HOSTNAME_CFG01 }} |
| 30 | retry: {count: 1, delay: 10} |
| 31 | skip_fail: false |
| 32 | |
| 33 | - description: Send grains to the swarm slave nodes |
| 34 | cmd: salt -C 'I@docker:swarm' state.sls salt.minion.grains |
| 35 | node_name: {{ HOSTNAME_CFG01 }} |
| 36 | retry: {count: 1, delay: 10} |
| 37 | skip_fail: false |
| 38 | |
| 39 | - description: Update mine |
| 40 | cmd: salt -C 'I@docker:swarm' mine.update |
| 41 | node_name: {{ HOSTNAME_CFG01 }} |
| 42 | retry: {count: 1, delay: 10} |
| 43 | skip_fail: false |
| 44 | |
| 45 | - description: Refresh modules |
| 46 | cmd: salt -C 'I@docker:swarm' saltutil.refresh_modules; sleep 5; |
| 47 | node_name: {{ HOSTNAME_CFG01 }} |
| 48 | retry: {count: 1, delay: 10} |
| 49 | skip_fail: false |
| 50 | |
| 51 | - description: Rerun swarm on slaves to proper token population |
| 52 | cmd: salt -C 'I@docker:swarm:role:master' state.sls docker.swarm |
| 53 | node_name: {{ HOSTNAME_CFG01 }} |
| 54 | retry: {count: 1, delay: 10} |
| 55 | skip_fail: false |
| 56 | |
| 57 | - description: Configure slave nodes |
| 58 | cmd: salt -C 'I@docker:swarm:role:manager' state.sls docker.swarm -b 1 |
| 59 | node_name: {{ HOSTNAME_CFG01 }} |
| 60 | retry: {count: 1, delay: 10} |
| 61 | skip_fail: false |
| 62 | |
| 63 | - description: List registered Docker swarm nodes |
| 64 | cmd: salt -C 'I@docker:swarm:role:master' cmd.run 'docker node ls' |
| 65 | node_name: {{ HOSTNAME_CFG01 }} |
| 66 | retry: {count: 1, delay: 10} |
| 67 | skip_fail: false |
| 68 | |
| 69 | # Install slv2 infra |
| 70 | - description: Install telegraf |
| 71 | cmd: salt -C 'I@telegraf:agent or I@telegraf:remote_agent' state.sls telegraf |
| 72 | node_name: {{ HOSTNAME_CFG01 }} |
| 73 | retry: {count: 2, delay: 10} |
| 74 | skip_fail: false |
| 75 | |
| 76 | - description: Configure Prometheus exporters, if pillar 'prometheus:exporters' exists on any server |
| 77 | cmd: | |
| 78 | if salt -C 'I@prometheus:exporters' match.pillar 'prometheus:exporters' ; then |
| 79 | salt -C 'I@prometheus:exporters' state.sls prometheus |
| 80 | fi |
| 81 | node_name: {{ HOSTNAME_CFG01 }} |
| 82 | retry: {count: 1, delay: 10} |
| 83 | skip_fail: false |
| 84 | |
| 85 | - description: Configure collector |
| 86 | cmd: salt -C 'I@heka:log_collector' state.sls heka.log_collector |
| 87 | node_name: {{ HOSTNAME_CFG01 }} |
| 88 | retry: {count: 1, delay: 10} |
| 89 | skip_fail: false |
| 90 | |
| 91 | - description: Install elasticsearch server |
| 92 | cmd: salt -C 'I@elasticsearch:server' state.sls elasticsearch.server -b 1 |
| 93 | node_name: {{ HOSTNAME_CFG01 }} |
| 94 | retry: {count: 1, delay: 10} |
| 95 | skip_fail: false |
| 96 | |
| 97 | - description: Install kibana server |
| 98 | cmd: salt -C 'I@kibana:server' state.sls kibana.server -b 1 |
| 99 | node_name: {{ HOSTNAME_CFG01 }} |
| 100 | retry: {count: 1, delay: 10} |
| 101 | skip_fail: false |
| 102 | |
| 103 | - description: Install elasticsearch client |
| 104 | cmd: salt -C 'I@elasticsearch:client' state.sls elasticsearch.client |
| 105 | node_name: {{ HOSTNAME_CFG01 }} |
| 106 | retry: {count: 1, delay: 10} |
| 107 | skip_fail: false |
| 108 | |
| 109 | - description: Install kibana client |
| 110 | cmd: salt -C 'I@kibana:client' state.sls kibana.client |
| 111 | node_name: {{ HOSTNAME_CFG01 }} |
| 112 | retry: {count: 1, delay: 10} |
| 113 | skip_fail: false |
| 114 | |
| 115 | - description: Check influix db |
| 116 | cmd: | |
| 117 | INFLUXDB_SERVICE=`salt -C 'I@influxdb:server' test.ping 1>/dev/null 2>&1 && echo true`; |
| 118 | echo "Influxdb service presence: ${INFLUXDB_SERVICE}"; |
| 119 | if [[ "$INFLUXDB_SERVICE" == "true" ]]; then |
| 120 | salt -C 'I@influxdb:server' state.sls influxdb |
| 121 | fi |
| 122 | node_name: {{ HOSTNAME_CFG01 }} |
| 123 | retry: {count: 1, delay: 5} |
| 124 | skip_fail: true |
| 125 | |
| 126 | # Collect grains needed to configure the services |
| 127 | |
| 128 | - description: Get grains |
| 129 | cmd: salt -C 'I@salt:minion' state.sls salt.minion.grains |
| 130 | node_name: {{ HOSTNAME_CFG01 }} |
| 131 | retry: {count: 1, delay: 10} |
| 132 | skip_fail: false |
| 133 | |
| 134 | - description: Sync modules |
| 135 | cmd: salt -C 'I@salt:minion' saltutil.refresh_modules |
| 136 | node_name: {{ HOSTNAME_CFG01 }} |
| 137 | retry: {count: 1, delay: 10} |
| 138 | skip_fail: false |
| 139 | |
| 140 | - description: Update mine |
| 141 | cmd: salt -C 'I@salt:minion' mine.update; sleep 5; |
| 142 | node_name: {{ HOSTNAME_CFG01 }} |
| 143 | retry: {count: 1, delay: 10} |
| 144 | skip_fail: false |
| 145 | |
| 146 | # Change environment configuration before deploy |
| 147 | - description: Set SL docker images deploy parameters |
| 148 | cmd: | |
Dennis Dmitriev | 386845b | 2017-11-21 13:11:12 +0200 | [diff] [blame] | 149 | {#- For cookiecutter-generated model, use overrides.yml from environment model instead of cluster model #} |
| 150 | {%- set OVERRIDES_FILENAME='/srv/salt/reclass/classes/environment/' + ENVIRONMENT_MODEL_INVENTORY_NAME + '/overrides.yml' %} |
| 151 | {%- for sl_opt, value in config.sl_deploy.items() %} |
| 152 | {%- if value|string() %} |
| 153 | salt-call reclass.cluster_meta_set name={{ sl_opt }} value={{ value }} file_name={{ OVERRIDES_FILENAME }}; |
| 154 | {%- endif %} |
| 155 | {%- endfor %} |
Dennis Dmitriev | a95a6d4 | 2017-10-24 15:09:04 +0300 | [diff] [blame] | 156 | salt '*' saltutil.refresh_pillar; |
| 157 | sleep 10 |
Dennis Dmitriev | 411dd10 | 2017-09-15 16:04:47 +0300 | [diff] [blame] | 158 | node_name: {{ HOSTNAME_CFG01 }} |
| 159 | retry: {count: 1, delay: 1} |
| 160 | skip_fail: false |
| 161 | |
| 162 | # Configure the services running in Docker Swarm |
| 163 | - description: Install prometheus alertmanager |
| 164 | cmd: salt -C 'I@docker:swarm' state.sls prometheus,heka.remote_collector -b 1 |
| 165 | node_name: {{ HOSTNAME_CFG01 }} |
| 166 | retry: {count: 1, delay: 10} |
| 167 | skip_fail: false |
| 168 | |
| 169 | - description: run docker state |
| 170 | cmd: salt -C 'I@docker:swarm:role:master' state.sls docker |
| 171 | node_name: {{ HOSTNAME_CFG01 }} |
| 172 | retry: {count: 1, delay: 10} |
| 173 | skip_fail: false |
| 174 | |
| 175 | - description: docker ps |
| 176 | cmd: salt -C 'I@docker:swarm' dockerng.ps |
| 177 | node_name: {{ HOSTNAME_CFG01 }} |
| 178 | retry: {count: 1, delay: 10} |
| 179 | skip_fail: false |
| 180 | |
| 181 | - description: Configure Grafana dashboards and datasources |
| 182 | cmd: sleep 30; salt -C 'I@grafana:client' state.sls grafana.client |
| 183 | node_name: {{ HOSTNAME_CFG01 }} |
| 184 | retry: {count: 2, delay: 10} |
| 185 | skip_fail: false |
| 186 | |
| 187 | - description: Run salt minion to create cert files |
| 188 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False "*" state.sls salt.minion |
| 189 | node_name: {{ HOSTNAME_CFG01 }} |
| 190 | retry: {count: 1, delay: 10} |
| 191 | skip_fail: false |
| 192 | |