blob: 74e54a146005404a85babf3b583fe456e420bc0f [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)
Dmitry Kalashnik4eb5e8f2018-07-03 18:06:33 +040015PROMETHEUS_LTS_SERVICE=$(salt -C 'I@prometheus:relay' test.ping 1>/dev/null 2>&1 && echo true)
Simon Pasquierf2b5a3b2017-06-06 17:32:21 +020016
Simon Pasquierd3a0b912017-05-02 15:32:20 +020017# Configure Telegraf
Simon Pasquier4a802be2017-06-29 12:54:50 +020018salt -C 'I@telegraf:agent or I@telegraf:remote_agent' state.sls telegraf
19
Dmitry Kalashnik35af3542017-07-13 14:09:39 +040020# Configure Prometheus exporters
21salt -C 'I@prometheus:exporters' state.sls prometheus
22
Ildar Svetlovf9490372018-02-08 16:41:22 +040023# Configure fluentd
24salt -C 'I@fluentd:agent' state.sls fluentd
Simon Pasquierd3a0b912017-05-02 15:32:20 +020025
26# Configure Elasticsearch/Kibana services
27salt -C 'I@elasticsearch:server' state.sls elasticsearch.server -b 1
28salt -C 'I@kibana:server' state.sls kibana.server -b 1
Simon Pasquierd3a0b912017-05-02 15:32:20 +020029salt -C 'I@elasticsearch:client' state.sls elasticsearch.client
30salt -C 'I@kibana:client' state.sls kibana.client
31
Simon Pasquierf2b5a3b2017-06-06 17:32:21 +020032if [[ "$INFLUXDB_SERVICE" == "true" ]]; then
33 salt -C 'I@influxdb:server' state.sls influxdb
34fi
35
Dmitry Kalashnik4eb5e8f2018-07-03 18:06:33 +040036if [[ "$PROMETHEUS_LTS_SERVICE" == "true" ]]; then
37 salt -C 'I@prometheus:relay' state.sls prometheus
38fi
39
40# Install mongodb for Alerta
41salt -C "I@mongodb:server" state.sls mongodb
42
Simon Pasquierd3a0b912017-05-02 15:32:20 +020043# Collect grains needed to configure the services
44salt -C 'I@salt:minion' state.sls salt.minion.grains
45salt -C 'I@salt:minion' saltutil.refresh_modules
46salt -C 'I@salt:minion' mine.update
47sleep 5
48
Ildar Svetlovf9490372018-02-08 16:41:22 +040049# Generate the configuration for prometheus running in Docker Swarm
50salt -C 'I@docker:swarm' state.sls prometheus -b 1
Simon Pasquier4a802be2017-06-29 12:54:50 +020051
Ildar Svetlov669aaee2018-02-15 10:33:35 +040052# Generate the configuration for remote_collector running in Docker Swarm
53salt -C 'I@docker:swarm' state.sls heka.remote_collector -b 1
54
Simon Pasquier4a802be2017-06-29 12:54:50 +020055# Kick off the services in Docker Swarm
Simon Pasquierd3a0b912017-05-02 15:32:20 +020056salt -C 'I@docker:swarm:role:master' state.sls docker
57salt -C 'I@docker:swarm' dockerng.ps
Simon Pasquierf8532062017-05-04 11:58:41 +020058
Simon Pasquier4a802be2017-06-29 12:54:50 +020059# Configure the Grafana dashboards and datasources
Simon Pasquiere76e2622017-05-15 15:04:47 +020060stacklight_vip=$(get_param_value stacklight_monitor_address)
61wait_for_http_service "http://${stacklight_vip}:15013/"
Simon Pasquierf8532062017-05-04 11:58:41 +020062salt -C 'I@grafana:client' state.sls grafana.client