2 ##############################################################################
3 # Copyright (c) 2018 Mirantis Inc., Enea AB and others.
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
10 CI_DEBUG=${CI_DEBUG:-0}; [[ "${CI_DEBUG}" =~ (false|0) ]] || set -x
12 source "$(dirname "${BASH_SOURCE[0]}")/../../scripts/globals.sh"
14 # Install the StackLight backends
15 notify 'Deploy Elasticsearch' 2
16 salt -C 'I@elasticsearch:server' state.sls elasticsearch.server -b 1
18 notify 'Deploy InfluxDB' 2
19 salt -C 'I@influxdb:server' state.sls influxdb -b 1
20 salt -C 'I@kibana:server' state.sls kibana.server -b 1
22 notify 'Deploy Grafana server' 2
23 salt -C 'I@grafana:server' state.sls grafana.server -b 1
25 notify 'Deploy Sensu' 2
26 salt -C 'I@nagios:server' state.sls nagios.server
27 salt -C 'I@sensu:server and I@rabbitmq:server' state.sls rabbitmq
28 salt -C 'I@sensu:server and I@rabbitmq:server' cmd.run 'rabbitmqctl cluster_status'
29 salt -C 'I@redis:cluster:role:master' state.sls redis
30 salt -C 'I@redis:server' state.sls redis
31 salt -C 'I@sensu:server' state.sls sensu -b 1
32 salt -C 'I@sensu:client' state.sls sensu
34 notify 'Configure clients to communicate with the server' 2
35 salt -C 'I@elasticsearch:client' state.sls elasticsearch.client.service
36 salt -C 'I@kibana:client' state.sls kibana.client.service
38 notify 'Restart minions on the nodes where clients are installed' 2
39 salt -C 'I@kibana:client or I@elasticsearch:client' --async service.restart salt-minion
40 sleep 10 # FIXME: no hardcoded timeouts
42 notify 'Configure elasticsearch, kibana servers' 2
43 salt -C 'I@elasticsearch:client' state.sls elasticsearch.client
44 salt -C 'I@kibana:client' state.sls kibana.client
46 # StackLight SOIP (StackLight operational insights pipeline)
47 notify 'Restart minions' 2
48 salt -C '*' --async service.restart salt-minion; sleep 15 # FIXME: no hardcoded timeouts
49 salt -C '*' mine.flush
51 notify 'Clean grains files' 2
52 salt -C '*' file.remove /etc/salt/grains.d/collectd
53 salt -C '*' file.remove /etc/salt/grains.d/grafana
54 salt -C '*' file.remove /etc/salt/grains.d/heka
55 salt -C '*' file.remove /etc/salt/grains.d/sensu
56 salt -C '*' file.remove /etc/salt/grains
58 notify 'Install collectd and heka' 2
59 salt -C '*' state.sls collectd -b 1
60 salt -C '*' state.sls heka -b 1
61 salt -C 'I@sensu:client' state.sls sensu
62 salt -C 'I@grafana:collector' state.sls grafana.collector
64 notify 'Update salt mine' 2
65 salt -C '*' state.sls salt.minion.grains -b 1
66 salt -C '*' saltutil.refresh_modules
67 salt -C '*' mine.update
71 notify 'Update heka' 2
72 salt -C 'I@heka:aggregator:enabled:True or I@heka:remote_collector:enabled:True' state.sls heka -b 1
74 notify 'Update collectd' 2
75 salt -C 'I@collectd:remote_client:enabled:True' state.sls collectd
77 notify 'Update Nagios' 2
78 salt -C 'I@nagios:server' state.sls nagios
79 salt -C 'I@nagios:server' service.stop nagios3
81 notify 'Update sensu' 2
82 salt -C 'I@sensu:server' state.sls sensu
84 notify 'Finalize the configuration of Grafana (add the dashboards)' 2
85 salt -C 'I@grafana:client' --async service.restart salt-minion; sleep 10 # FIXME
86 salt -C 'I@grafana:client' state.sls grafana.client
88 notify 'Get StackLight monitor VIP' 2
89 vip=$(salt-call pillar.data _param:stacklight_monitor_address --out key|awk '/_param:/ { print $2; }')
91 salt -G "ipv4:$vip" service.restart remote_collectd
92 salt -G "ipv4:$vip" service.restart remote_collector
93 salt -G "ipv4:$vip" service.restart aggregator
94 salt -G "ipv4:$vip" service.restart nagios3