Tatyana Leontovich | d85357d | 2017-08-02 15:28:37 +0300 | [diff] [blame] | 1 | {% from 'virtual-mcp-ocata-dvr/underlay.yaml' import HOSTNAME_CFG01 with context %} |
| 2 | |
| 3 | # Restart keepalived |
| 4 | - description: Restart keepalived on mon and ctl nodes |
| 5 | cmd: salt -C 'mon* and ctl*' cmd.run "systemctl restart keepalived" |
| 6 | node_name: {{ HOSTNAME_CFG01 }} |
| 7 | retry: {count: 1, delay: 10} |
| 8 | skip_fail: false |
| 9 | |
| 10 | # Install docker swarm |
| 11 | - description: Configure docker service |
| 12 | cmd: salt -C 'I@docker:swarm' state.sls docker.host |
| 13 | node_name: {{ HOSTNAME_CFG01 }} |
| 14 | retry: {count: 1, delay: 10} |
| 15 | skip_fail: false |
| 16 | |
| 17 | - description: Install docker swarm on master node |
| 18 | cmd: salt -C 'I@docker:swarm:role:master' state.sls docker.swarm |
| 19 | node_name: {{ HOSTNAME_CFG01 }} |
| 20 | retry: {count: 1, delay: 10} |
| 21 | skip_fail: false |
| 22 | |
| 23 | - description: Send grains to the swarm slave nodes |
| 24 | cmd: salt -C 'I@docker:swarm' state.sls salt.minion.grains |
| 25 | node_name: {{ HOSTNAME_CFG01 }} |
| 26 | retry: {count: 1, delay: 10} |
| 27 | skip_fail: false |
| 28 | |
| 29 | - description: Update mine |
| 30 | cmd: salt -C 'I@docker:swarm' mine.update |
| 31 | node_name: {{ HOSTNAME_CFG01 }} |
| 32 | retry: {count: 1, delay: 10} |
| 33 | skip_fail: false |
| 34 | |
| 35 | - description: Refresh modules |
| 36 | cmd: salt -C 'I@docker:swarm' saltutil.refresh_modules; sleep 5; |
| 37 | node_name: {{ HOSTNAME_CFG01 }} |
| 38 | retry: {count: 1, delay: 10} |
| 39 | skip_fail: false |
| 40 | |
| 41 | - description: Configure slave nodes |
| 42 | cmd: salt -C 'I@docker:swarm:role:manager' state.sls docker.swarm -b 1 |
| 43 | node_name: {{ HOSTNAME_CFG01 }} |
| 44 | retry: {count: 1, delay: 10} |
| 45 | skip_fail: false |
| 46 | |
| 47 | - description: List registered Docker swarm nodes |
| 48 | cmd: salt -C 'I@docker:swarm:role:master' cmd.run 'docker node ls' |
| 49 | node_name: {{ HOSTNAME_CFG01 }} |
| 50 | retry: {count: 1, delay: 10} |
| 51 | skip_fail: false |
| 52 | |
| 53 | # Install slv2 infra |
| 54 | - description: Install telegraf |
| 55 | cmd: salt -C 'I@telegraf:agent or I@telegraf:remote_agent' state.sls telegraf |
| 56 | node_name: {{ HOSTNAME_CFG01 }} |
| 57 | retry: {count: 1, delay: 10} |
| 58 | skip_fail: false |
| 59 | |
| 60 | - description: Configure collector |
| 61 | cmd: salt -C 'I@heka:log_collector' state.sls heka.log_collector |
| 62 | node_name: {{ HOSTNAME_CFG01 }} |
| 63 | retry: {count: 1, delay: 10} |
| 64 | skip_fail: false |
| 65 | |
| 66 | - description: Install elasticsearch server |
| 67 | cmd: salt -C 'I@elasticsearch:server' state.sls elasticsearch.server -b 1 |
| 68 | node_name: {{ HOSTNAME_CFG01 }} |
| 69 | retry: {count: 1, delay: 10} |
| 70 | skip_fail: false |
| 71 | |
| 72 | - description: Install kibana server |
| 73 | cmd: salt -C 'I@kibana:server' state.sls kibana.server -b 1 |
| 74 | node_name: {{ HOSTNAME_CFG01 }} |
| 75 | retry: {count: 1, delay: 10} |
| 76 | skip_fail: false |
| 77 | |
| 78 | - description: Install elasticsearch client |
| 79 | cmd: salt -C 'I@elasticsearch:client' state.sls elasticsearch.client |
| 80 | node_name: {{ HOSTNAME_CFG01 }} |
| 81 | retry: {count: 1, delay: 10} |
| 82 | skip_fail: false |
| 83 | |
| 84 | - description: Install kibana client |
| 85 | cmd: salt -C 'I@kibana:client' state.sls kibana.client |
| 86 | node_name: {{ HOSTNAME_CFG01 }} |
| 87 | retry: {count: 1, delay: 10} |
| 88 | skip_fail: false |
| 89 | |
| 90 | - description: Check influix db |
| 91 | cmd: | |
| 92 | INFLUXDB_SERVICE=`salt -C 'I@influxdb:server' test.ping 1>/dev/null 2>&1 && echo true`; |
| 93 | echo "Influxdb service presence: ${INFLUXDB_SERVICE}"; |
| 94 | if [[ "$INFLUXDB_SERVICE" == "true" ]]; then |
| 95 | salt -C 'I@influxdb:server' state.sls influxdb |
| 96 | fi |
| 97 | node_name: {{ HOSTNAME_CFG01 }} |
| 98 | retry: {count: 1, delay: 5} |
| 99 | skip_fail: true |
| 100 | |
| 101 | # Collect grains needed to configure the services |
| 102 | |
| 103 | - description: Get grains |
| 104 | cmd: salt -C 'I@salt:minion' state.sls salt.minion.grains |
| 105 | node_name: {{ HOSTNAME_CFG01 }} |
| 106 | retry: {count: 1, delay: 10} |
| 107 | skip_fail: false |
| 108 | |
| 109 | - description: Sync modules |
| 110 | cmd: salt -C 'I@salt:minion' saltutil.refresh_modules |
| 111 | node_name: {{ HOSTNAME_CFG01 }} |
| 112 | retry: {count: 1, delay: 10} |
| 113 | skip_fail: false |
| 114 | |
| 115 | - description: Update mine |
| 116 | cmd: salt -C 'I@salt:minion' mine.update; sleep 5; |
| 117 | node_name: {{ HOSTNAME_CFG01 }} |
| 118 | retry: {count: 1, delay: 10} |
| 119 | skip_fail: false |
| 120 | |
| 121 | # Change environment configuration before deploy |
| 122 | - description: Set SL docker images deploy parameters |
| 123 | cmd: | |
| 124 | {% for sl_opt, value in config.sl_deploy.items() %} |
| 125 | {% if value|string() %} |
| 126 | salt-call reclass.cluster_meta_set {{ sl_opt }} {{ value }}; |
| 127 | {% endif %} |
| 128 | {% endfor %} |
| 129 | node_name: {{ HOSTNAME_CFG01 }} |
| 130 | retry: {count: 1, delay: 1} |
| 131 | skip_fail: false |
| 132 | |
| 133 | # Configure the services running in Docker Swarm |
| 134 | - description: Install prometheus alertmanager |
| 135 | cmd: salt -C 'I@docker:swarm' state.sls prometheus,heka.remote_collector -b 1 |
| 136 | node_name: {{ HOSTNAME_CFG01 }} |
| 137 | retry: {count: 1, delay: 10} |
| 138 | skip_fail: false |
| 139 | |
| 140 | - description: run docker state |
| 141 | cmd: salt -C 'I@docker:swarm:role:master' state.sls docker |
| 142 | node_name: {{ HOSTNAME_CFG01 }} |
| 143 | retry: {count: 1, delay: 10} |
| 144 | skip_fail: false |
| 145 | |
| 146 | - description: docker ps |
| 147 | cmd: salt -C 'I@docker:swarm' dockerng.ps |
| 148 | node_name: {{ HOSTNAME_CFG01 }} |
| 149 | retry: {count: 1, delay: 10} |
| 150 | skip_fail: false |
| 151 | |
| 152 | - description: Configure Grafana dashboards and datasources |
| 153 | cmd: sleep 30; salt -C 'I@grafana:client' state.sls grafana.client |
| 154 | node_name: {{ HOSTNAME_CFG01 }} |
| 155 | retry: {count: 2, delay: 10} |
| 156 | skip_fail: false |
| 157 | |
| 158 | - description: Run salt minion to create cert files |
| 159 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False "*" state.sls salt.minion |
| 160 | node_name: {{ HOSTNAME_CFG01 }} |
| 161 | retry: {count: 1, delay: 10} |
| 162 | skip_fail: false |
| 163 | |