Jeepyb User | dd14e0b | 2017-02-28 15:19:32 +0000 | [diff] [blame^] | 1 | #!/bin/bash -x |
| 2 | exec > >(tee -i /tmp/"$(basename "$0" .sh)"_"$(date '+%Y-%m-%d_%H-%M-%S')".log) 2>&1 |
| 3 | |
| 4 | # Start by flusing Salt Mine to make sure it is clean |
| 5 | # Also clean-up the grains files to make sure that we start from a clean state |
| 6 | salt "*" mine.flush |
| 7 | salt "*" file.remove /etc/salt/grains.d/collectd |
| 8 | salt "*" file.remove /etc/salt/grains.d/grafana |
| 9 | salt "*" file.remove /etc/salt/grains.d/heka |
| 10 | salt "*" file.remove /etc/salt/grains |
| 11 | |
| 12 | # Install collectd and heka services on the nodes, this will also generate the |
| 13 | # metadata that goes into the grains and eventually into Salt Mine |
| 14 | salt "*" state.sls collectd |
| 15 | salt "*" state.sls heka |
| 16 | |
| 17 | # Gather the Grafana metadata as grains |
| 18 | salt -C 'I@grafana:collector' state.sls grafana.collector |
| 19 | |
| 20 | # Update Salt Mine |
| 21 | salt "*" state.sls salt.minion.grains |
| 22 | salt "*" saltutil.refresh_modules |
| 23 | salt "*" mine.update |
| 24 | |
| 25 | sleep 5 |
| 26 | |
| 27 | # Update Heka |
| 28 | salt -C 'I@heka:aggregator:enabled:True or I@heka:remote_collector:enabled:True' state.sls heka |
| 29 | |
| 30 | # Update collectd |
| 31 | salt -C 'I@collectd:remote_client:enabled:True' state.sls collectd |
| 32 | |
| 33 | # Update Nagios |
| 34 | salt -C 'I@nagios:server' state.sls nagios |
| 35 | # Stop the Nagios service because the package starts it by default and it will |
| 36 | # started later only on the node holding the VIP address |
| 37 | salt -C 'I@nagios:server' service.stop nagios3 |
| 38 | |
| 39 | # Finalize the configuration of Grafana (add the dashboards...) |
| 40 | salt -C 'I@grafana:client' state.sls grafana.client.service |
| 41 | salt -C 'I@grafana:client' --async service.restart salt-minion; sleep 10 |
| 42 | salt -C 'I@grafana:client' state.sls grafana.client |
| 43 | |
| 44 | # Get the StackLight monitoring VIP addres |
| 45 | vip=$(salt-call pillar.data _param:stacklight_monitor_address --out key|grep _param: |awk '{print $2}') |
| 46 | vip=${vip:=172.16.10.253} |
| 47 | |
| 48 | # (re)Start manually the services that are bound to the monitoring VIP |
| 49 | salt -G "ipv4:$vip" service.restart remote_collectd |
| 50 | salt -G "ipv4:$vip" service.restart remote_collector |
| 51 | salt -G "ipv4:$vip" service.restart aggregator |
| 52 | salt -G "ipv4:$vip" service.restart nagios3 |