| {# Collection of sl macroses #} |
| |
| {%- macro MACRO_INSTALL_DOCKER_SWARM() %} |
| # Install docker swarm |
| - description: Configure docker service |
| cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm' state.sls docker.host |
| node_name: {{ HOSTNAME_CFG01 }} |
| retry: {count: 1, delay: 10} |
| skip_fail: false |
| |
| - description: Install docker swarm on master node |
| cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master' state.sls docker.swarm |
| node_name: {{ HOSTNAME_CFG01 }} |
| retry: {count: 1, delay: 10} |
| skip_fail: false |
| |
| - description: Send grains to the swarm slave nodes |
| cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm' state.sls salt.minion.grains |
| node_name: {{ HOSTNAME_CFG01 }} |
| retry: {count: 1, delay: 10} |
| skip_fail: false |
| |
| - description: Update mine |
| cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm' mine.update |
| node_name: {{ HOSTNAME_CFG01 }} |
| retry: {count: 1, delay: 10} |
| skip_fail: false |
| |
| - description: Refresh modules |
| cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm' saltutil.refresh_modules; sleep 5; |
| node_name: {{ HOSTNAME_CFG01 }} |
| retry: {count: 1, delay: 10} |
| skip_fail: false |
| |
| - description: Rerun swarm on slaves to proper token population |
| cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master' state.sls docker.swarm |
| node_name: {{ HOSTNAME_CFG01 }} |
| retry: {count: 1, delay: 10} |
| skip_fail: false |
| |
| - description: Configure slave nodes |
| cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:manager' state.sls docker.swarm -b 1 |
| node_name: {{ HOSTNAME_CFG01 }} |
| retry: {count: 1, delay: 10} |
| skip_fail: false |
| |
| - description: List registered Docker swarm nodes |
| cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master' cmd.run 'docker node ls' |
| node_name: {{ HOSTNAME_CFG01 }} |
| retry: {count: 1, delay: 10} |
| skip_fail: false |
| |
| - description: Install keepalived on mon nodes |
| cmd: salt --hard-crash --state-output=mixed --state-verbose=False |
| -C 'mon*' state.sls keepalived |
| node_name: {{ HOSTNAME_CFG01 }} |
| retry: {count: 1, delay: 10} |
| skip_fail: false |
| |
| - description: Check the VIP on mon nodes |
| cmd: | |
| SL_VIP=`salt-call --out=newline_values_only pillar.get _param:stacklight_monitor_address`; |
| echo "_param:stacklight_monitor_address (vip): ${SL_VIP}"; |
| salt --hard-crash --state-output=mixed --state-verbose=False -C 'mon*' cmd.run "ip a | grep ${SL_VIP}" | grep -B1 ${SL_VIP} |
| node_name: {{ HOSTNAME_CFG01 }} |
| retry: {count: 1, delay: 5} |
| skip_fail: false |
| {%- endmacro %} |
| |
| #{#%- macro MACRO_INSTALL_GLUSTERFS_CLIENT() %#} |
| #- description: Install glusterfs client |
| # cmd: salt --hard-crash --state-output=mixed --state-verbose=False |
| # -C 'I@glusterfs:client' state.sls glusterfs.client |
| # node_name: {{ HOSTNAME_CFG01 }} |
| # retry: {count: 2, delay: 15} |
| # skip_fail: false |
| #{#%- endmacro %#} |
| |
| {%- macro MACRO_INSTALL_MONGODB() %} |
| # Install slv2 infra |
| # Install MongoDB for alerta |
| - description: Install Mongo if target matches |
| cmd: | |
| if salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@mongodb:server' match.pillar 'mongodb:server' ; then |
| salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@mongodb:server' state.sls mongodb.server |
| fi |
| node_name: {{ HOSTNAME_CFG01 }} |
| retry: {count: 1, delay: 10} |
| skip_fail: false |
| {%- endmacro %} |
| |
| {%- macro MACRO_INSTALL_MONGODB_CLUSTER() %} |
| # Create MongoDB cluster |
| - description: Install Mongo if target matches |
| cmd: | |
| if salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@mongodb:server' match.pillar 'mongodb:server' ; then |
| salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@mongodb:server' state.sls mongodb.cluster |
| fi |
| node_name: {{ HOSTNAME_CFG01 }} |
| retry: {count: 5, delay: 20} |
| skip_fail: false |
| {%- endmacro %} |
| |
| {%- macro MACRO_INSTALL_TELEGRAF_AND_PROMETHEUS() %} |
| - description: Install telegraf |
| cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@telegraf:agent or I@telegraf:remote_agent' state.sls telegraf |
| node_name: {{ HOSTNAME_CFG01 }} |
| retry: {count: 2, delay: 10} |
| skip_fail: false |
| |
| - description: Configure Prometheus exporters, if pillar 'prometheus:exporters' exists on any server |
| cmd: | |
| if salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@prometheus:exporters' match.pillar 'prometheus:exporters' ; then |
| salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@prometheus:exporters' state.sls prometheus |
| fi |
| node_name: {{ HOSTNAME_CFG01 }} |
| retry: {count: 1, delay: 10} |
| skip_fail: false |
| {%- endmacro %} |
| |
| {%- macro MACRO_INSTALL_ELASTICSEARCH_AND_KIBANA() %} |
| - description: Install elasticsearch server |
| cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@elasticsearch:server:enabled:true and *01*' state.sls elasticsearch.server |
| node_name: {{ HOSTNAME_CFG01 }} |
| retry: {count: 1, delay: 10} |
| skip_fail: false |
| |
| - description: Install elasticsearch server |
| cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@elasticsearch:server:enabled:true' state.sls elasticsearch.server |
| node_name: {{ HOSTNAME_CFG01 }} |
| retry: {count: 1, delay: 10} |
| skip_fail: false |
| |
| - description: Install kibana server |
| cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@kibana:server:enabled:true and *01*' state.sls kibana.server |
| node_name: {{ HOSTNAME_CFG01 }} |
| retry: {count: 1, delay: 10} |
| skip_fail: false |
| |
| - description: Install kibana server |
| cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@kibana:server:enabled:true' state.sls kibana.server |
| node_name: {{ HOSTNAME_CFG01 }} |
| retry: {count: 1, delay: 10} |
| skip_fail: false |
| |
| - description: Install elasticsearch client |
| cmd: sleep 30; salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@elasticsearch:client' state.sls elasticsearch.client |
| node_name: {{ HOSTNAME_CFG01 }} |
| retry: {count: 2, delay: 30} |
| skip_fail: false |
| |
| - description: Install kibana client |
| cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@kibana:client' state.sls kibana.client |
| node_name: {{ HOSTNAME_CFG01 }} |
| retry: {count: 1, delay: 10} |
| skip_fail: false |
| |
| - description: Check influix db |
| cmd: | |
| INFLUXDB_SERVICE=`salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@influxdb:server' test.ping 1>/dev/null 2>&1 && echo true`; |
| echo "Influxdb service presence: ${INFLUXDB_SERVICE}"; |
| if [[ "$INFLUXDB_SERVICE" == "true" ]]; then |
| salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@influxdb:server and *01*' state.sls influxdb; |
| salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@influxdb:server' state.sls influxdb; |
| fi |
| node_name: {{ HOSTNAME_CFG01 }} |
| retry: {count: 1, delay: 5} |
| skip_fail: false |
| {%- endmacro %} |
| |
| {%- macro MACRO_INSTALL_LOG_COLLECTION() %} |
| # Install service for the log collection |
| - description: Configure fluentd |
| cmd: | |
| FLUENTD_SERVICE=`salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@fluentd:agent' test.ping 1>/dev/null 2>&1 && echo true`; |
| echo "Fluentd service presence: ${FLUENTD_SERVICE}"; |
| if [[ "$FLUENTD_SERVICE" == "true" ]]; then |
| salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@fluentd:agent' state.sls fluentd |
| else |
| salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@heka:log_collector' state.sls heka.log_collector |
| fi |
| node_name: {{ HOSTNAME_CFG01 }} |
| retry: {count: 1, delay: 10} |
| skip_fail: false |
| {%- endmacro %} |
| |
| {%- macro MACRO_INSTALL_CEILOMETER_COLLECTOR() %} |
| # Install heka ceilometer collector |
| - description: Install heka ceilometer if they exists |
| cmd: | |
| CEILO=`salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@heka:ceilometer_collector:enabled' test.ping 1>/dev/null 2>&1 && echo true`; |
| echo "Ceilometer service presence: ${CEILO}"; |
| if [[ "$CEILO" == "true" ]]; then |
| salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@heka:ceilometer_collector:enabled' state.sls heka.ceilometer_collector; |
| salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@heka:ceilometer_collector:enabled' service.restart ceilometer_collector |
| fi |
| node_name: {{ HOSTNAME_CFG01 }} |
| retry: {count: 1, delay: 10} |
| skip_fail: false |
| {%- endmacro %} |
| |
| {%- macro MACRO_CONFIGURE_SERVICES() %} |
| # Collect grains needed to configure the services |
| - description: Collect Grains |
| cmd: | |
| salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@salt:minion' state.sls salt.minion.grains; |
| salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@salt:minion' saltutil.refresh_modules; |
| salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@salt:minion' mine.update |
| node_name: {{ HOSTNAME_CFG01 }} |
| retry: {count: 1, delay: 10} |
| skip_fail: false |
| |
| - description: Check docker ps |
| cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm and I@prometheus:server' state.sls prometheus |
| node_name: {{ HOSTNAME_CFG01 }} |
| retry: {count: 2, delay: 10} |
| skip_fail: false |
| |
| - description: Configure Remote Collector in Docker Swarm for Openstack deployments |
| cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm and I@prometheus:server' state.sls heka.remote_collector |
| node_name: {{ HOSTNAME_CFG01 }} |
| retry: {count: 1, delay: 10} |
| skip_fail: false |
| |
| - description: launch prometheus containers |
| cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm:role:master and I@prometheus:server' state.sls docker.client |
| node_name: {{ HOSTNAME_CFG01 }} |
| retry: {count: 2, delay: 10} |
| skip_fail: false |
| |
| - description: Check docker ps |
| cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm and I@prometheus:server' cmd.run "docker ps" |
| node_name: {{ HOSTNAME_CFG01 }} |
| retry: {count: 1, delay: 10} |
| skip_fail: false |
| |
| - description: "check grafana service" |
| cmd: timeout 60 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@grafana:server' cmd.run |
| 'export SL_VIP=`salt-call --out=newline_values_only pillar.get _param:stacklight_monitor_address`; |
| curl -sf http://${SL_VIP}:15013/;' |
| node_name: {{ HOSTNAME_CFG01 }} |
| retry: {count: 1, delay: 10} |
| skip_fail: true |
| |
| - description: Configure Grafana dashboards and datasources |
| cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@grafana:client' state.sls grafana.client |
| node_name: {{ HOSTNAME_CFG01 }} |
| retry: {count: 5, delay: 60} |
| skip_fail: false |
| |
| - description: "check grafana service" |
| cmd: timeout 60 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@grafana:server' cmd.run |
| 'export SL_VIP=`salt-call --out=newline_values_only pillar.get _param:stacklight_monitor_address`; |
| curl -sf http://${SL_VIP}:15013/;' |
| node_name: {{ HOSTNAME_CFG01 }} |
| retry: {count: 1, delay: 10} |
| skip_fail: true |
| |
| - description: Configure Alerta if it is exists |
| cmd: | |
| if salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@prometheus:alerta' match.pillar 'prometheus:alerta' ; then |
| salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm and I@prometheus:alerta' state.sls prometheus.alerta |
| fi |
| 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.cert |
| node_name: {{ HOSTNAME_CFG01 }} |
| retry: {count: 1, delay: 10} |
| skip_fail: true |
| {%- endmacro %} |