Simon Pasquier | d3a0b91 | 2017-05-02 15:32:20 +0200 | [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 | |
Simon Pasquier | e76e262 | 2017-05-15 15:04:47 +0200 | [diff] [blame] | 4 | CWD="$(dirname "$(readlink -f "$0")")" |
| 5 | |
| 6 | # Import common functions |
| 7 | COMMONS="$CWD"/common_functions.sh |
| 8 | if [ ! -f "$COMMONS" ]; then |
| 9 | echo "File $COMMONS does not exist" |
| 10 | exit 1 |
| 11 | fi |
| 12 | . "$COMMONS" |
| 13 | |
Simon Pasquier | f2b5a3b | 2017-06-06 17:32:21 +0200 | [diff] [blame] | 14 | INFLUXDB_SERVICE=$(salt -C 'I@influxdb:server' test.ping 1>/dev/null 2>&1 && echo true) |
| 15 | |
Simon Pasquier | d3a0b91 | 2017-05-02 15:32:20 +0200 | [diff] [blame] | 16 | # Configure Telegraf |
Simon Pasquier | 4a802be | 2017-06-29 12:54:50 +0200 | [diff] [blame] | 17 | salt -C 'I@telegraf:agent or I@telegraf:remote_agent' state.sls telegraf |
| 18 | |
| 19 | # Configure log_collector |
| 20 | salt -C 'I@heka:log_collector' state.sls heka.log_collector |
Simon Pasquier | d3a0b91 | 2017-05-02 15:32:20 +0200 | [diff] [blame] | 21 | |
| 22 | # Configure Elasticsearch/Kibana services |
| 23 | salt -C 'I@elasticsearch:server' state.sls elasticsearch.server -b 1 |
| 24 | salt -C 'I@kibana:server' state.sls kibana.server -b 1 |
Simon Pasquier | d3a0b91 | 2017-05-02 15:32:20 +0200 | [diff] [blame] | 25 | salt -C 'I@elasticsearch:client' state.sls elasticsearch.client |
| 26 | salt -C 'I@kibana:client' state.sls kibana.client |
| 27 | |
Simon Pasquier | f2b5a3b | 2017-06-06 17:32:21 +0200 | [diff] [blame] | 28 | if [[ "$INFLUXDB_SERVICE" == "true" ]]; then |
| 29 | salt -C 'I@influxdb:server' state.sls influxdb |
| 30 | fi |
| 31 | |
Simon Pasquier | d3a0b91 | 2017-05-02 15:32:20 +0200 | [diff] [blame] | 32 | # Collect grains needed to configure the services |
| 33 | salt -C 'I@salt:minion' state.sls salt.minion.grains |
| 34 | salt -C 'I@salt:minion' saltutil.refresh_modules |
| 35 | salt -C 'I@salt:minion' mine.update |
| 36 | sleep 5 |
| 37 | |
Simon Pasquier | 4a802be | 2017-06-29 12:54:50 +0200 | [diff] [blame] | 38 | # Generate the configuration for services running in Docker Swarm |
| 39 | salt -C 'I@docker:swarm' state.sls prometheus,heka.remote_collector -b 1 |
| 40 | |
| 41 | # Kick off the services in Docker Swarm |
Simon Pasquier | d3a0b91 | 2017-05-02 15:32:20 +0200 | [diff] [blame] | 42 | salt -C 'I@docker:swarm:role:master' state.sls docker |
| 43 | salt -C 'I@docker:swarm' dockerng.ps |
Simon Pasquier | f853206 | 2017-05-04 11:58:41 +0200 | [diff] [blame] | 44 | |
Simon Pasquier | 4a802be | 2017-06-29 12:54:50 +0200 | [diff] [blame] | 45 | # Configure the Grafana dashboards and datasources |
Simon Pasquier | e76e262 | 2017-05-15 15:04:47 +0200 | [diff] [blame] | 46 | stacklight_vip=$(get_param_value stacklight_monitor_address) |
| 47 | wait_for_http_service "http://${stacklight_vip}:15013/" |
Simon Pasquier | f853206 | 2017-05-04 11:58:41 +0200 | [diff] [blame] | 48 | salt -C 'I@grafana:client' state.sls grafana.client |