blob: 159ad04bd5083584d9bdcc0b4d5c99880938d560 [file] [log] [blame]
Jeepyb Userdd14e0b2017-02-28 15:19:32 +00001#!/bin/bash -x
2exec > >(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
6salt "*" mine.flush
7salt "*" file.remove /etc/salt/grains.d/collectd
8salt "*" file.remove /etc/salt/grains.d/grafana
9salt "*" file.remove /etc/salt/grains.d/heka
10salt "*" 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
14salt "*" state.sls collectd
15salt "*" state.sls heka
16
17# Gather the Grafana metadata as grains
18salt -C 'I@grafana:collector' state.sls grafana.collector
19
20# Update Salt Mine
21salt "*" state.sls salt.minion.grains
22salt "*" saltutil.refresh_modules
23salt "*" mine.update
24
25sleep 5
26
27# Update Heka
28salt -C 'I@heka:aggregator:enabled:True or I@heka:remote_collector:enabled:True' state.sls heka
29
30# Update collectd
31salt -C 'I@collectd:remote_client:enabled:True' state.sls collectd
32
33# Update Nagios
34salt -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
37salt -C 'I@nagios:server' service.stop nagios3
38
39# Finalize the configuration of Grafana (add the dashboards...)
40salt -C 'I@grafana:client' state.sls grafana.client.service
41salt -C 'I@grafana:client' --async service.restart salt-minion; sleep 10
42salt -C 'I@grafana:client' state.sls grafana.client
43
44# Get the StackLight monitoring VIP addres
45vip=$(salt-call pillar.data _param:stacklight_monitor_address --out key|grep _param: |awk '{print $2}')
46vip=${vip:=172.16.10.253}
47
48# (re)Start manually the services that are bound to the monitoring VIP
49salt -G "ipv4:$vip" service.restart remote_collectd
50salt -G "ipv4:$vip" service.restart remote_collector
51salt -G "ipv4:$vip" service.restart aggregator
52salt -G "ipv4:$vip" service.restart nagios3