blob: 0caab9baaa2420c9dc093f06024c51f2bd3679ce [file] [log] [blame]
Simon Pasquierd3a0b912017-05-02 15:32:20 +02001#!/bin/bash -x
2exec > >(tee -i /tmp/"$(basename "$0" .sh)"_"$(date '+%Y-%m-%d_%H-%M-%S')".log) 2>&1
3
Simon Pasquiere76e2622017-05-15 15:04:47 +02004CWD="$(dirname "$(readlink -f "$0")")"
5
6# Import common functions
7COMMONS="$CWD"/common_functions.sh
8if [ ! -f "$COMMONS" ]; then
9 echo "File $COMMONS does not exist"
10 exit 1
11fi
12. "$COMMONS"
13
Simon Pasquierf2b5a3b2017-06-06 17:32:21 +020014INFLUXDB_SERVICE=$(salt -C 'I@influxdb:server' test.ping 1>/dev/null 2>&1 && echo true)
15
Simon Pasquierd3a0b912017-05-02 15:32:20 +020016# Configure Telegraf
Simon Pasquier4a802be2017-06-29 12:54:50 +020017salt -C 'I@telegraf:agent or I@telegraf:remote_agent' state.sls telegraf
18
Dmitry Kalashnik35af3542017-07-13 14:09:39 +040019# Configure Prometheus exporters
20salt -C 'I@prometheus:exporters' state.sls prometheus
21
Ildar Svetlovf9490372018-02-08 16:41:22 +040022# Configure fluentd
23salt -C 'I@fluentd:agent' state.sls fluentd
Simon Pasquierd3a0b912017-05-02 15:32:20 +020024
25# Configure Elasticsearch/Kibana services
26salt -C 'I@elasticsearch:server' state.sls elasticsearch.server -b 1
27salt -C 'I@kibana:server' state.sls kibana.server -b 1
Simon Pasquierd3a0b912017-05-02 15:32:20 +020028salt -C 'I@elasticsearch:client' state.sls elasticsearch.client
29salt -C 'I@kibana:client' state.sls kibana.client
30
Simon Pasquierf2b5a3b2017-06-06 17:32:21 +020031if [[ "$INFLUXDB_SERVICE" == "true" ]]; then
32 salt -C 'I@influxdb:server' state.sls influxdb
33fi
34
Simon Pasquierd3a0b912017-05-02 15:32:20 +020035# Collect grains needed to configure the services
36salt -C 'I@salt:minion' state.sls salt.minion.grains
37salt -C 'I@salt:minion' saltutil.refresh_modules
38salt -C 'I@salt:minion' mine.update
39sleep 5
40
Ildar Svetlovf9490372018-02-08 16:41:22 +040041# Generate the configuration for prometheus running in Docker Swarm
42salt -C 'I@docker:swarm' state.sls prometheus -b 1
Simon Pasquier4a802be2017-06-29 12:54:50 +020043
Ildar Svetlov669aaee2018-02-15 10:33:35 +040044# Generate the configuration for remote_collector running in Docker Swarm
45salt -C 'I@docker:swarm' state.sls heka.remote_collector -b 1
46
Simon Pasquier4a802be2017-06-29 12:54:50 +020047# Kick off the services in Docker Swarm
Simon Pasquierd3a0b912017-05-02 15:32:20 +020048salt -C 'I@docker:swarm:role:master' state.sls docker
49salt -C 'I@docker:swarm' dockerng.ps
Simon Pasquierf8532062017-05-04 11:58:41 +020050
Simon Pasquier4a802be2017-06-29 12:54:50 +020051# Configure the Grafana dashboards and datasources
Simon Pasquiere76e2622017-05-15 15:04:47 +020052stacklight_vip=$(get_param_value stacklight_monitor_address)
53wait_for_http_service "http://${stacklight_vip}:15013/"
Simon Pasquierf8532062017-05-04 11:58:41 +020054salt -C 'I@grafana:client' state.sls grafana.client