| {% from 'virtual-mcp-ocata-cicd/underlay.yaml' import HOSTNAME_CFG01 with context %} |
| |
| # Pattern that helps salt to select Stacklight nodes |
| {% set SL_NODES_SELECTOR = os_env('SL_NODES_SELECTOR','cid*') %} |
| |
| #===================== |
| # Install docker swarm |
| #===================== |
| |
| - description: Prepare Docker host |
| cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:host and {{ SL_NODES_SELECTOR }}' state.sls docker.host |
| node_name: {{ HOSTNAME_CFG01 }} |
| retry: {count: 1, delay: 5} |
| skip_fail: false |
| |
| - description: Install Docker Swarm master |
| cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master and {{ SL_NODES_SELECTOR }}' state.sls docker.swarm |
| node_name: {{ HOSTNAME_CFG01 }} |
| retry: {count: 1, delay: 5} |
| skip_fail: false |
| |
| - description: Collect grains |
| 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 && |
| salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master and {{ SL_NODES_SELECTOR }}' mine.flush && |
| salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master and {{ SL_NODES_SELECTOR }}' mine.update && |
| salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm and {{ SL_NODES_SELECTOR }}' saltutil.refresh_modules && |
| sleep 5 |
| node_name: {{ HOSTNAME_CFG01 }} |
| retry: {count: 3, delay: 15} |
| skip_fail: false |
| |
| - description: Install Docker Swarm on other nodes |
| cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:manager and {{ SL_NODES_SELECTOR }}' state.sls docker.swarm |
| node_name: {{ HOSTNAME_CFG01 }} |
| retry: {count: 1, delay: 5} |
| skip_fail: false |
| |
| - description: Show Docker Swarm nodes |
| 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' |
| node_name: {{ HOSTNAME_CFG01 }} |
| retry: {count: 1, delay: 5} |
| skip_fail: false |
| |
| #=================== |
| # Install StackLight |
| #=================== |
| |
| # Haproxy: installed in common-services |
| #-------------------------------------- |
| |
| - description: Install telegraf |
| cmd: salt -C 'I@telegraf:agent or I@telegraf:remote_agent' state.sls telegraf |
| node_name: {{ HOSTNAME_CFG01 }} |
| retry: {count: 1, delay: 10} |
| skip_fail: false |
| |
| - description: Configure Prometheus exporters, if pillar 'prometheus:exporters' exists on any server |
| cmd: | |
| if salt -C 'I@prometheus:exporters' match.pillar 'prometheus:exporters' ; then |
| salt -C 'I@prometheus:exporters' state.sls prometheus |
| fi |
| node_name: {{ HOSTNAME_CFG01 }} |
| retry: {count: 1, delay: 10} |
| skip_fail: false |
| |
| |
| # Elasticsearch |
| - description: Waiting for Elasticsearch to come up in container... |
| cmd: timeout 60 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@elasticsearch:server' cmd.run |
| 'export CICD_CONTROL_ADDRESS=$(salt-call --out=newline_values_only pillar.get _param:cicd_control_address); |
| while true; do curl -sf http://${CICD_CONTROL_ADDRESS}:9200 && break; sleep 2; done' |
| node_name: {{ HOSTNAME_CFG01 }} |
| retry: {count: 3, delay: 30} |
| skip_fail: false |
| |
| - description: Install elasticsearch server |
| cmd: salt -C 'I@elasticsearch:server and *01*' state.sls elasticsearch.server && |
| salt -C 'I@elasticsearch:server' state.sls elasticsearch.server -b 1 |
| node_name: {{ HOSTNAME_CFG01 }} |
| retry: {count: 1, delay: 10} |
| skip_fail: false |
| |
| - description: Install kibana server |
| cmd: salt -C 'I@kibana:server and *01*' state.sls kibana.server && |
| salt -C 'I@kibana:server' state.sls kibana.server -b 1 |
| node_name: {{ HOSTNAME_CFG01 }} |
| retry: {count: 1, delay: 10} |
| skip_fail: false |
| |
| - description: Install elasticsearch client |
| cmd: salt -C 'I@elasticsearch:client' state.sls elasticsearch.client |
| node_name: {{ HOSTNAME_CFG01 }} |
| retry: {count: 1, delay: 10} |
| skip_fail: false |
| |
| - description: Install kibana client |
| cmd: salt -C 'I@kibana:client' state.sls kibana.client |
| node_name: {{ HOSTNAME_CFG01 }} |
| retry: {count: 1, delay: 10} |
| skip_fail: false |
| |
| - description: Install influixdb |
| cmd: salt -C 'I@influxdb:server' state.sls influxdb |
| node_name: {{ HOSTNAME_CFG01 }} |
| retry: {count: 1, delay: 5} |
| skip_fail: false |
| |
| |
| |
| # Collect grains. Looks like this is an excess step, but it is present in the pipeline at the moment. |
| - description: Collect grains |
| 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 && |
| salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm and {{ SL_NODES_SELECTOR }}' saltutil.refresh_modules && |
| salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master and {{ SL_NODES_SELECTOR }}' mine.flush && |
| salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master and {{ SL_NODES_SELECTOR }}' mine.update && |
| sleep 5 |
| node_name: {{ HOSTNAME_CFG01 }} |
| retry: {count: 3, delay: 15} |
| skip_fail: false |
| |
| |
| # Change environment configuration before deploy |
| - description: Set SL docker images deploy parameters |
| cmd: | |
| {% for sl_opt, value in config.sl_deploy.items() %} |
| {% if value|string() %} |
| salt-call reclass.cluster_meta_set {{ sl_opt }} {{ value }}; |
| {% endif %} |
| {% endfor %} |
| node_name: {{ HOSTNAME_CFG01 }} |
| retry: {count: 1, delay: 1} |
| skip_fail: false |
| |
| # Configure the services running in Docker Swarm |
| - description: Install prometheus alertmanager |
| cmd: salt -C 'I@docker:swarm and {{ SL_NODES_SELECTOR }}' state.sls prometheus,heka.remote_collector -b 1 |
| node_name: {{ HOSTNAME_CFG01 }} |
| retry: {count: 1, delay: 10} |
| skip_fail: false |
| |
| - description: run docker state |
| cmd: salt -C 'I@docker:swarm:role:master and {{ SL_NODES_SELECTOR }}' state.sls docker |
| node_name: {{ HOSTNAME_CFG01 }} |
| retry: {count: 1, delay: 10} |
| skip_fail: false |
| |
| - description: docker ps |
| cmd: salt -C 'I@docker:swarm and {{ SL_NODES_SELECTOR }}' dockerng.ps |
| node_name: {{ HOSTNAME_CFG01 }} |
| retry: {count: 1, delay: 10} |
| skip_fail: false |
| |
| |
| - description: Waiting for Elasticsearch to come up in container... |
| cmd: timeout 120 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm and {{ SL_NODES_SELECTOR }}' cmd.run |
| 'export CICD_CONTROL_ADDRESS=$(salt-call --out=newline_values_only pillar.get _param:cicd_control_address); |
| while true; do curl -sf http://${CICD_CONTROL_ADDRESS}:15013 && break; sleep 2; done' |
| node_name: {{ HOSTNAME_CFG01 }} |
| retry: {count: 3, delay: 30} |
| skip_fail: false |
| |
| |
| - description: Configure Grafana dashboards and datasources |
| cmd: sleep 30; salt -C 'I@grafana:client' state.sls grafana.client |
| node_name: {{ HOSTNAME_CFG01 }} |
| retry: {count: 2, delay: 10} |
| skip_fail: false |
| |
| - description: Configure collector |
| cmd: salt -C 'I@heka:log_collector' state.sls heka.log_collector |
| node_name: {{ HOSTNAME_CFG01 }} |
| retry: {count: 1, delay: 10} |
| skip_fail: false |
| |
| - description: Run salt minion to create cert files |
| cmd: salt --hard-crash --state-output=mixed --state-verbose=False "*" state.sls salt.minion |
| node_name: {{ HOSTNAME_CFG01 }} |
| retry: {count: 1, delay: 10} |
| skip_fail: false |