Dennis Dmitriev | eac3aab | 2017-07-12 16:36:41 +0300 | [diff] [blame] | 1 | {% from 'virtual-mcp-ocata-cicd/underlay.yaml' import HOSTNAME_CFG01 with context %} |
| 2 | |
Dennis Dmitriev | f854617 | 2017-07-20 21:57:05 +0300 | [diff] [blame] | 3 | # Pattern that helps salt to select Stacklight nodes |
| 4 | {% set SL_NODES_SELECTOR = os_env('SL_NODES_SELECTOR','mon*') %} |
| 5 | |
Dennis Dmitriev | eac3aab | 2017-07-12 16:36:41 +0300 | [diff] [blame] | 6 | # Install docker swarm |
Dennis Dmitriev | f854617 | 2017-07-20 21:57:05 +0300 | [diff] [blame] | 7 | - 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 Dmitriev | eac3aab | 2017-07-12 16:36:41 +0300 | [diff] [blame] | 9 | node_name: {{ HOSTNAME_CFG01 }} |
Dennis Dmitriev | f854617 | 2017-07-20 21:57:05 +0300 | [diff] [blame] | 10 | retry: {count: 1, delay: 5} |
Dennis Dmitriev | eac3aab | 2017-07-12 16:36:41 +0300 | [diff] [blame] | 11 | skip_fail: false |
| 12 | |
Dennis Dmitriev | f854617 | 2017-07-20 21:57:05 +0300 | [diff] [blame] | 13 | - 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 Dmitriev | eac3aab | 2017-07-12 16:36:41 +0300 | [diff] [blame] | 15 | node_name: {{ HOSTNAME_CFG01 }} |
Dennis Dmitriev | f854617 | 2017-07-20 21:57:05 +0300 | [diff] [blame] | 16 | retry: {count: 1, delay: 5} |
Dennis Dmitriev | eac3aab | 2017-07-12 16:36:41 +0300 | [diff] [blame] | 17 | skip_fail: false |
| 18 | |
Dennis Dmitriev | f854617 | 2017-07-20 21:57:05 +0300 | [diff] [blame] | 19 | - 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 Dmitriev | eac3aab | 2017-07-12 16:36:41 +0300 | [diff] [blame] | 23 | node_name: {{ HOSTNAME_CFG01 }} |
Dennis Dmitriev | f854617 | 2017-07-20 21:57:05 +0300 | [diff] [blame] | 24 | retry: {count: 3, delay: 15} |
Dennis Dmitriev | eac3aab | 2017-07-12 16:36:41 +0300 | [diff] [blame] | 25 | skip_fail: false |
| 26 | |
Dennis Dmitriev | f854617 | 2017-07-20 21:57:05 +0300 | [diff] [blame] | 27 | - 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 Dmitriev | eac3aab | 2017-07-12 16:36:41 +0300 | [diff] [blame] | 29 | node_name: {{ HOSTNAME_CFG01 }} |
Dennis Dmitriev | f854617 | 2017-07-20 21:57:05 +0300 | [diff] [blame] | 30 | retry: {count: 1, delay: 5} |
Dennis Dmitriev | eac3aab | 2017-07-12 16:36:41 +0300 | [diff] [blame] | 31 | skip_fail: false |
| 32 | |
Dennis Dmitriev | f854617 | 2017-07-20 21:57:05 +0300 | [diff] [blame] | 33 | - 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 Dmitriev | eac3aab | 2017-07-12 16:36:41 +0300 | [diff] [blame] | 35 | node_name: {{ HOSTNAME_CFG01 }} |
Dennis Dmitriev | f854617 | 2017-07-20 21:57:05 +0300 | [diff] [blame] | 36 | retry: {count: 1, delay: 5} |
Dennis Dmitriev | eac3aab | 2017-07-12 16:36:41 +0300 | [diff] [blame] | 37 | skip_fail: false |
| 38 | |
| 39 | # Install slv2 infra |
| 40 | - description: Install telegraf |
Dennis Dmitriev | f854617 | 2017-07-20 21:57:05 +0300 | [diff] [blame] | 41 | cmd: salt -C 'I@telegraf:agent or I@telegraf:remote_agent' state.sls telegraf |
Dennis Dmitriev | f512dce | 2017-07-18 16:45:05 +0300 | [diff] [blame] | 42 | 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 Dmitriev | eac3aab | 2017-07-12 16:36:41 +0300 | [diff] [blame] | 48 | 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 Dmitriev | eac3aab | 2017-07-12 16:36:41 +0300 | [diff] [blame] | 64 | - 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 Dmitriev | f512dce | 2017-07-18 16:45:05 +0300 | [diff] [blame] | 76 | - 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 Dmitriev | eac3aab | 2017-07-12 16:36:41 +0300 | [diff] [blame] | 87 | # 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 Dmitriev | f512dce | 2017-07-18 16:45:05 +0300 | [diff] [blame] | 107 | # 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 Dmitriev | eac3aab | 2017-07-12 16:36:41 +0300 | [diff] [blame] | 115 | node_name: {{ HOSTNAME_CFG01 }} |
| 116 | retry: {count: 1, delay: 1} |
| 117 | skip_fail: false |
| 118 | |
Dennis Dmitriev | f512dce | 2017-07-18 16:45:05 +0300 | [diff] [blame] | 119 | # Configure the services running in Docker Swarm |
| 120 | - description: Install prometheus alertmanager |
Dennis Dmitriev | f854617 | 2017-07-20 21:57:05 +0300 | [diff] [blame] | 121 | cmd: salt -C 'I@docker:swarm and {{ SL_NODES_SELECTOR }}' state.sls prometheus,heka.remote_collector -b 1 |
Dennis Dmitriev | f512dce | 2017-07-18 16:45:05 +0300 | [diff] [blame] | 122 | node_name: {{ HOSTNAME_CFG01 }} |
| 123 | retry: {count: 1, delay: 10} |
| 124 | skip_fail: false |
| 125 | |
Dennis Dmitriev | eac3aab | 2017-07-12 16:36:41 +0300 | [diff] [blame] | 126 | - description: run docker state |
Dennis Dmitriev | f854617 | 2017-07-20 21:57:05 +0300 | [diff] [blame] | 127 | cmd: salt -C 'I@docker:swarm:role:master and {{ SL_NODES_SELECTOR }}' state.sls docker |
Dennis Dmitriev | eac3aab | 2017-07-12 16:36:41 +0300 | [diff] [blame] | 128 | node_name: {{ HOSTNAME_CFG01 }} |
| 129 | retry: {count: 1, delay: 10} |
| 130 | skip_fail: false |
| 131 | |
| 132 | - description: docker ps |
Dennis Dmitriev | f854617 | 2017-07-20 21:57:05 +0300 | [diff] [blame] | 133 | cmd: salt -C 'I@docker:swarm and {{ SL_NODES_SELECTOR }}' dockerng.ps |
Dennis Dmitriev | eac3aab | 2017-07-12 16:36:41 +0300 | [diff] [blame] | 134 | node_name: {{ HOSTNAME_CFG01 }} |
| 135 | retry: {count: 1, delay: 10} |
| 136 | skip_fail: false |
| 137 | |
| 138 | - description: Configure Grafana dashboards and datasources |
Dennis Dmitriev | f512dce | 2017-07-18 16:45:05 +0300 | [diff] [blame] | 139 | 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 Dmitriev | eac3aab | 2017-07-12 16:36:41 +0300 | [diff] [blame] | 146 | node_name: {{ HOSTNAME_CFG01 }} |
| 147 | retry: {count: 1, delay: 10} |
| 148 | skip_fail: false |