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) |
Dmitry Kalashnik | 4eb5e8f | 2018-07-03 18:06:33 +0400 | [diff] [blame] | 15 | PROMETHEUS_LTS_SERVICE=$(salt -C 'I@prometheus:relay' test.ping 1>/dev/null 2>&1 && echo true) |
Simon Pasquier | f2b5a3b | 2017-06-06 17:32:21 +0200 | [diff] [blame] | 16 | |
Simon Pasquier | d3a0b91 | 2017-05-02 15:32:20 +0200 | [diff] [blame] | 17 | # Configure Telegraf |
Simon Pasquier | 4a802be | 2017-06-29 12:54:50 +0200 | [diff] [blame] | 18 | salt -C 'I@telegraf:agent or I@telegraf:remote_agent' state.sls telegraf |
| 19 | |
Dmitry Kalashnik | 35af354 | 2017-07-13 14:09:39 +0400 | [diff] [blame] | 20 | # Configure Prometheus exporters |
| 21 | salt -C 'I@prometheus:exporters' state.sls prometheus |
| 22 | |
Ildar Svetlov | f949037 | 2018-02-08 16:41:22 +0400 | [diff] [blame] | 23 | # Configure fluentd |
| 24 | salt -C 'I@fluentd:agent' state.sls fluentd |
Simon Pasquier | d3a0b91 | 2017-05-02 15:32:20 +0200 | [diff] [blame] | 25 | |
| 26 | # Configure Elasticsearch/Kibana services |
| 27 | salt -C 'I@elasticsearch:server' state.sls elasticsearch.server -b 1 |
| 28 | salt -C 'I@kibana:server' state.sls kibana.server -b 1 |
Simon Pasquier | d3a0b91 | 2017-05-02 15:32:20 +0200 | [diff] [blame] | 29 | salt -C 'I@elasticsearch:client' state.sls elasticsearch.client |
| 30 | salt -C 'I@kibana:client' state.sls kibana.client |
| 31 | |
Simon Pasquier | f2b5a3b | 2017-06-06 17:32:21 +0200 | [diff] [blame] | 32 | if [[ "$INFLUXDB_SERVICE" == "true" ]]; then |
| 33 | salt -C 'I@influxdb:server' state.sls influxdb |
| 34 | fi |
| 35 | |
Dmitry Kalashnik | 4eb5e8f | 2018-07-03 18:06:33 +0400 | [diff] [blame] | 36 | if [[ "$PROMETHEUS_LTS_SERVICE" == "true" ]]; then |
| 37 | salt -C 'I@prometheus:relay' state.sls prometheus |
| 38 | fi |
| 39 | |
| 40 | # Install mongodb for Alerta |
| 41 | salt -C "I@mongodb:server" state.sls mongodb |
| 42 | |
Simon Pasquier | d3a0b91 | 2017-05-02 15:32:20 +0200 | [diff] [blame] | 43 | # Collect grains needed to configure the services |
| 44 | salt -C 'I@salt:minion' state.sls salt.minion.grains |
| 45 | salt -C 'I@salt:minion' saltutil.refresh_modules |
| 46 | salt -C 'I@salt:minion' mine.update |
| 47 | sleep 5 |
| 48 | |
Ildar Svetlov | f949037 | 2018-02-08 16:41:22 +0400 | [diff] [blame] | 49 | # Generate the configuration for prometheus running in Docker Swarm |
| 50 | salt -C 'I@docker:swarm' state.sls prometheus -b 1 |
Simon Pasquier | 4a802be | 2017-06-29 12:54:50 +0200 | [diff] [blame] | 51 | |
Ildar Svetlov | 669aaee | 2018-02-15 10:33:35 +0400 | [diff] [blame] | 52 | # Generate the configuration for remote_collector running in Docker Swarm |
| 53 | salt -C 'I@docker:swarm' state.sls heka.remote_collector -b 1 |
| 54 | |
Simon Pasquier | 4a802be | 2017-06-29 12:54:50 +0200 | [diff] [blame] | 55 | # Kick off the services in Docker Swarm |
Simon Pasquier | d3a0b91 | 2017-05-02 15:32:20 +0200 | [diff] [blame] | 56 | salt -C 'I@docker:swarm:role:master' state.sls docker |
| 57 | salt -C 'I@docker:swarm' dockerng.ps |
Simon Pasquier | f853206 | 2017-05-04 11:58:41 +0200 | [diff] [blame] | 58 | |
Simon Pasquier | 4a802be | 2017-06-29 12:54:50 +0200 | [diff] [blame] | 59 | # Configure the Grafana dashboards and datasources |
Simon Pasquier | e76e262 | 2017-05-15 15:04:47 +0200 | [diff] [blame] | 60 | stacklight_vip=$(get_param_value stacklight_monitor_address) |
| 61 | wait_for_http_service "http://${stacklight_vip}:15013/" |
Simon Pasquier | f853206 | 2017-05-04 11:58:41 +0200 | [diff] [blame] | 62 | salt -C 'I@grafana:client' state.sls grafana.client |