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 |
Dennis Dmitriev | 41f0b79 | 2017-07-27 18:08:50 +0300 | [diff] [blame] | 4 | {% set SL_NODES_SELECTOR = os_env('SL_NODES_SELECTOR','cid*') %} |
Dennis Dmitriev | f854617 | 2017-07-20 21:57:05 +0300 | [diff] [blame] | 5 | |
Dennis Dmitriev | 41f0b79 | 2017-07-27 18:08:50 +0300 | [diff] [blame] | 6 | #===================== |
Dennis Dmitriev | eac3aab | 2017-07-12 16:36:41 +0300 | [diff] [blame] | 7 | # Install docker swarm |
Dennis Dmitriev | 41f0b79 | 2017-07-27 18:08:50 +0300 | [diff] [blame] | 8 | #===================== |
| 9 | |
Dennis Dmitriev | f854617 | 2017-07-20 21:57:05 +0300 | [diff] [blame] | 10 | - description: Prepare Docker host |
| 11 | 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] | 12 | node_name: {{ HOSTNAME_CFG01 }} |
Dennis Dmitriev | f854617 | 2017-07-20 21:57:05 +0300 | [diff] [blame] | 13 | retry: {count: 1, delay: 5} |
Dennis Dmitriev | eac3aab | 2017-07-12 16:36:41 +0300 | [diff] [blame] | 14 | skip_fail: false |
| 15 | |
Dennis Dmitriev | f854617 | 2017-07-20 21:57:05 +0300 | [diff] [blame] | 16 | - description: Install Docker Swarm master |
| 17 | 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] | 18 | node_name: {{ HOSTNAME_CFG01 }} |
Dennis Dmitriev | f854617 | 2017-07-20 21:57:05 +0300 | [diff] [blame] | 19 | retry: {count: 1, delay: 5} |
Dennis Dmitriev | eac3aab | 2017-07-12 16:36:41 +0300 | [diff] [blame] | 20 | skip_fail: false |
| 21 | |
Dennis Dmitriev | 41f0b79 | 2017-07-27 18:08:50 +0300 | [diff] [blame] | 22 | - description: Collect grains |
| 23 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master and {{ SL_NODES_SELECTOR }}' state.sls salt.minion.grains && |
Dennis Dmitriev | f854617 | 2017-07-20 21:57:05 +0300 | [diff] [blame] | 24 | salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master and {{ SL_NODES_SELECTOR }}' mine.flush && |
Dennis Dmitriev | 41f0b79 | 2017-07-27 18:08:50 +0300 | [diff] [blame] | 25 | salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master and {{ SL_NODES_SELECTOR }}' mine.update && |
| 26 | salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm and {{ SL_NODES_SELECTOR }}' saltutil.refresh_modules && |
| 27 | sleep 5 |
Dennis Dmitriev | eac3aab | 2017-07-12 16:36:41 +0300 | [diff] [blame] | 28 | node_name: {{ HOSTNAME_CFG01 }} |
Dennis Dmitriev | f854617 | 2017-07-20 21:57:05 +0300 | [diff] [blame] | 29 | retry: {count: 3, delay: 15} |
Dennis Dmitriev | eac3aab | 2017-07-12 16:36:41 +0300 | [diff] [blame] | 30 | skip_fail: false |
| 31 | |
Dennis Dmitriev | f854617 | 2017-07-20 21:57:05 +0300 | [diff] [blame] | 32 | - description: Install Docker Swarm on other nodes |
Dennis Dmitriev | 41f0b79 | 2017-07-27 18:08:50 +0300 | [diff] [blame] | 33 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:manager and {{ SL_NODES_SELECTOR }}' state.sls docker.swarm |
Dennis Dmitriev | eac3aab | 2017-07-12 16:36:41 +0300 | [diff] [blame] | 34 | node_name: {{ HOSTNAME_CFG01 }} |
Dennis Dmitriev | f854617 | 2017-07-20 21:57:05 +0300 | [diff] [blame] | 35 | retry: {count: 1, delay: 5} |
Dennis Dmitriev | eac3aab | 2017-07-12 16:36:41 +0300 | [diff] [blame] | 36 | skip_fail: false |
| 37 | |
Dennis Dmitriev | f854617 | 2017-07-20 21:57:05 +0300 | [diff] [blame] | 38 | - description: Show Docker Swarm nodes |
| 39 | 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] | 40 | node_name: {{ HOSTNAME_CFG01 }} |
Dennis Dmitriev | f854617 | 2017-07-20 21:57:05 +0300 | [diff] [blame] | 41 | retry: {count: 1, delay: 5} |
Dennis Dmitriev | eac3aab | 2017-07-12 16:36:41 +0300 | [diff] [blame] | 42 | skip_fail: false |
| 43 | |
Dennis Dmitriev | 41f0b79 | 2017-07-27 18:08:50 +0300 | [diff] [blame] | 44 | #=================== |
| 45 | # Install StackLight |
| 46 | #=================== |
| 47 | |
| 48 | # Haproxy: installed in common-services |
| 49 | #-------------------------------------- |
| 50 | |
Dennis Dmitriev | eac3aab | 2017-07-12 16:36:41 +0300 | [diff] [blame] | 51 | - description: Install telegraf |
Dennis Dmitriev | f854617 | 2017-07-20 21:57:05 +0300 | [diff] [blame] | 52 | 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] | 53 | node_name: {{ HOSTNAME_CFG01 }} |
| 54 | retry: {count: 1, delay: 10} |
| 55 | skip_fail: false |
| 56 | |
Dennis Dmitriev | cc6e9b5 | 2017-09-01 11:27:58 +0300 | [diff] [blame^] | 57 | - description: Configure Prometheus exporters, if pillar 'prometheus:exporters' exists on any server |
Dennis Dmitriev | 41f0b79 | 2017-07-27 18:08:50 +0300 | [diff] [blame] | 58 | cmd: | |
| 59 | if salt -C 'I@prometheus:exporters' match.pillar 'prometheus:exporters' ; then |
| 60 | salt -C 'I@prometheus:exporters' state.sls prometheus |
| 61 | fi |
Dennis Dmitriev | eac3aab | 2017-07-12 16:36:41 +0300 | [diff] [blame] | 62 | node_name: {{ HOSTNAME_CFG01 }} |
| 63 | retry: {count: 1, delay: 10} |
| 64 | skip_fail: false |
| 65 | |
Dennis Dmitriev | 41f0b79 | 2017-07-27 18:08:50 +0300 | [diff] [blame] | 66 | |
Dennis Dmitriev | 41f0b79 | 2017-07-27 18:08:50 +0300 | [diff] [blame] | 67 | # Elasticsearch |
| 68 | - description: Waiting for Elasticsearch to come up in container... |
| 69 | cmd: timeout 60 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@elasticsearch:server' cmd.run |
| 70 | 'export CICD_CONTROL_ADDRESS=$(salt-call --out=newline_values_only pillar.get _param:cicd_control_address); |
| 71 | while true; do curl -sf http://${CICD_CONTROL_ADDRESS}:9200 && break; sleep 2; done' |
| 72 | node_name: {{ HOSTNAME_CFG01 }} |
| 73 | retry: {count: 3, delay: 30} |
| 74 | skip_fail: false |
| 75 | |
Dennis Dmitriev | eac3aab | 2017-07-12 16:36:41 +0300 | [diff] [blame] | 76 | - description: Install elasticsearch server |
Dennis Dmitriev | 41f0b79 | 2017-07-27 18:08:50 +0300 | [diff] [blame] | 77 | cmd: salt -C 'I@elasticsearch:server and *01*' state.sls elasticsearch.server && |
| 78 | salt -C 'I@elasticsearch:server' state.sls elasticsearch.server -b 1 |
Dennis Dmitriev | eac3aab | 2017-07-12 16:36:41 +0300 | [diff] [blame] | 79 | node_name: {{ HOSTNAME_CFG01 }} |
| 80 | retry: {count: 1, delay: 10} |
| 81 | skip_fail: false |
| 82 | |
| 83 | - description: Install kibana server |
Dennis Dmitriev | 41f0b79 | 2017-07-27 18:08:50 +0300 | [diff] [blame] | 84 | cmd: salt -C 'I@kibana:server and *01*' state.sls kibana.server && |
| 85 | salt -C 'I@kibana:server' state.sls kibana.server -b 1 |
Dennis Dmitriev | eac3aab | 2017-07-12 16:36:41 +0300 | [diff] [blame] | 86 | node_name: {{ HOSTNAME_CFG01 }} |
| 87 | retry: {count: 1, delay: 10} |
| 88 | skip_fail: false |
| 89 | |
Dennis Dmitriev | eac3aab | 2017-07-12 16:36:41 +0300 | [diff] [blame] | 90 | - description: Install elasticsearch client |
| 91 | cmd: salt -C 'I@elasticsearch:client' state.sls elasticsearch.client |
| 92 | node_name: {{ HOSTNAME_CFG01 }} |
| 93 | retry: {count: 1, delay: 10} |
| 94 | skip_fail: false |
| 95 | |
| 96 | - description: Install kibana client |
| 97 | cmd: salt -C 'I@kibana:client' state.sls kibana.client |
| 98 | node_name: {{ HOSTNAME_CFG01 }} |
| 99 | retry: {count: 1, delay: 10} |
| 100 | skip_fail: false |
| 101 | |
Dennis Dmitriev | 41f0b79 | 2017-07-27 18:08:50 +0300 | [diff] [blame] | 102 | - description: Install influixdb |
| 103 | cmd: salt -C 'I@influxdb:server' state.sls influxdb |
Dennis Dmitriev | f512dce | 2017-07-18 16:45:05 +0300 | [diff] [blame] | 104 | node_name: {{ HOSTNAME_CFG01 }} |
| 105 | retry: {count: 1, delay: 5} |
Dennis Dmitriev | eac3aab | 2017-07-12 16:36:41 +0300 | [diff] [blame] | 106 | skip_fail: false |
| 107 | |
Dennis Dmitriev | 41f0b79 | 2017-07-27 18:08:50 +0300 | [diff] [blame] | 108 | |
| 109 | |
| 110 | # Collect grains. Looks like this is an excess step, but it is present in the pipeline at the moment. |
| 111 | - description: Collect grains |
| 112 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master and {{ SL_NODES_SELECTOR }}' state.sls salt.minion.grains && |
| 113 | salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm and {{ SL_NODES_SELECTOR }}' saltutil.refresh_modules && |
| 114 | salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master and {{ SL_NODES_SELECTOR }}' mine.flush && |
| 115 | salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master and {{ SL_NODES_SELECTOR }}' mine.update && |
| 116 | sleep 5 |
Dennis Dmitriev | eac3aab | 2017-07-12 16:36:41 +0300 | [diff] [blame] | 117 | node_name: {{ HOSTNAME_CFG01 }} |
Dennis Dmitriev | 41f0b79 | 2017-07-27 18:08:50 +0300 | [diff] [blame] | 118 | retry: {count: 3, delay: 15} |
Dennis Dmitriev | eac3aab | 2017-07-12 16:36:41 +0300 | [diff] [blame] | 119 | skip_fail: false |
| 120 | |
Dennis Dmitriev | eac3aab | 2017-07-12 16:36:41 +0300 | [diff] [blame] | 121 | |
Dennis Dmitriev | f512dce | 2017-07-18 16:45:05 +0300 | [diff] [blame] | 122 | # Change environment configuration before deploy |
| 123 | - description: Set SL docker images deploy parameters |
| 124 | cmd: | |
| 125 | {% for sl_opt, value in config.sl_deploy.items() %} |
| 126 | {% if value|string() %} |
| 127 | salt-call reclass.cluster_meta_set {{ sl_opt }} {{ value }}; |
| 128 | {% endif %} |
| 129 | {% endfor %} |
Dennis Dmitriev | eac3aab | 2017-07-12 16:36:41 +0300 | [diff] [blame] | 130 | node_name: {{ HOSTNAME_CFG01 }} |
| 131 | retry: {count: 1, delay: 1} |
| 132 | skip_fail: false |
| 133 | |
Dennis Dmitriev | f512dce | 2017-07-18 16:45:05 +0300 | [diff] [blame] | 134 | # Configure the services running in Docker Swarm |
| 135 | - description: Install prometheus alertmanager |
Dennis Dmitriev | f854617 | 2017-07-20 21:57:05 +0300 | [diff] [blame] | 136 | 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] | 137 | node_name: {{ HOSTNAME_CFG01 }} |
| 138 | retry: {count: 1, delay: 10} |
| 139 | skip_fail: false |
| 140 | |
Dennis Dmitriev | eac3aab | 2017-07-12 16:36:41 +0300 | [diff] [blame] | 141 | - description: run docker state |
Dennis Dmitriev | f854617 | 2017-07-20 21:57:05 +0300 | [diff] [blame] | 142 | 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] | 143 | node_name: {{ HOSTNAME_CFG01 }} |
| 144 | retry: {count: 1, delay: 10} |
| 145 | skip_fail: false |
| 146 | |
| 147 | - description: docker ps |
Dennis Dmitriev | f854617 | 2017-07-20 21:57:05 +0300 | [diff] [blame] | 148 | cmd: salt -C 'I@docker:swarm and {{ SL_NODES_SELECTOR }}' dockerng.ps |
Dennis Dmitriev | eac3aab | 2017-07-12 16:36:41 +0300 | [diff] [blame] | 149 | node_name: {{ HOSTNAME_CFG01 }} |
| 150 | retry: {count: 1, delay: 10} |
| 151 | skip_fail: false |
| 152 | |
Dennis Dmitriev | 41f0b79 | 2017-07-27 18:08:50 +0300 | [diff] [blame] | 153 | |
| 154 | - description: Waiting for Elasticsearch to come up in container... |
| 155 | cmd: timeout 120 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm and {{ SL_NODES_SELECTOR }}' cmd.run |
| 156 | 'export CICD_CONTROL_ADDRESS=$(salt-call --out=newline_values_only pillar.get _param:cicd_control_address); |
| 157 | while true; do curl -sf http://${CICD_CONTROL_ADDRESS}:15013 && break; sleep 2; done' |
| 158 | node_name: {{ HOSTNAME_CFG01 }} |
| 159 | retry: {count: 3, delay: 30} |
| 160 | skip_fail: false |
| 161 | |
| 162 | |
Dennis Dmitriev | eac3aab | 2017-07-12 16:36:41 +0300 | [diff] [blame] | 163 | - description: Configure Grafana dashboards and datasources |
Dennis Dmitriev | f512dce | 2017-07-18 16:45:05 +0300 | [diff] [blame] | 164 | cmd: sleep 30; salt -C 'I@grafana:client' state.sls grafana.client |
| 165 | node_name: {{ HOSTNAME_CFG01 }} |
| 166 | retry: {count: 2, delay: 10} |
| 167 | skip_fail: false |
| 168 | |
Dennis Dmitriev | 41f0b79 | 2017-07-27 18:08:50 +0300 | [diff] [blame] | 169 | - description: Configure collector |
| 170 | cmd: salt -C 'I@heka:log_collector' state.sls heka.log_collector |
| 171 | node_name: {{ HOSTNAME_CFG01 }} |
| 172 | retry: {count: 1, delay: 10} |
| 173 | skip_fail: false |
| 174 | |
Dennis Dmitriev | f512dce | 2017-07-18 16:45:05 +0300 | [diff] [blame] | 175 | - description: Run salt minion to create cert files |
| 176 | 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] | 177 | node_name: {{ HOSTNAME_CFG01 }} |
| 178 | retry: {count: 1, delay: 10} |
| 179 | skip_fail: false |