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 | |
| 4 | RABBITMQ_SERVICE=$(salt -C 'I@rabbitmq:server' test.ping 1>/dev/null 2>&1 && echo true) |
| 5 | GALERA_SERVICE=$(salt -C 'I@galera:master or I@galera:slave' test.ping 1>/dev/null 2>&1 && echo true) |
| 6 | MEMCACHED_SERVICE=$(salt -C 'I@memcached:server' test.ping 1>/dev/null 2>&1 && echo true) |
| 7 | NGINX_SERVICE=$(salt -C 'I@nginx:server' test.ping 1>/dev/null 2>&1 && echo true) |
| 8 | |
| 9 | # Install keepaliveds |
| 10 | salt -C 'I@keepalived:cluster' state.sls keepalived -b 1 |
| 11 | # Check the VIPs |
| 12 | salt -C 'I@keepalived:cluster' cmd.run "ip a | grep 172.16.10.2" |
| 13 | |
| 14 | # Install gluster services |
| 15 | salt -C 'I@glusterfs:server' state.sls glusterfs.server.service |
| 16 | salt -C 'I@glusterfs:server' state.sls glusterfs.server.setup -b 1 |
| 17 | # Check the gluster status |
| 18 | salt -C 'I@glusterfs:server' cmd.run "gluster peer status; gluster volume status" -b 1 |
| 19 | # Configure gluster clients |
| 20 | salt -C 'I@glusterfs:client' state.sls glusterfs.client |
| 21 | |
| 22 | if [[ "$RABBITMQ_SERVICE" == "true" ]]; then |
| 23 | # Install rabbitmq |
| 24 | salt -C 'I@rabbitmq:server' state.sls rabbitmq |
| 25 | # Check the rabbitmq status |
| 26 | salt -C 'I@rabbitmq:server' cmd.run "rabbitmqctl cluster_status" |
| 27 | fi |
| 28 | |
| 29 | if [[ "$GALERA_SERVICE" == "true" ]]; then |
| 30 | # Install galera |
| 31 | salt -C 'I@galera:master' state.sls galera |
| 32 | salt -C 'I@galera:slave' state.sls galera |
| 33 | # Check galera status |
| 34 | salt -C 'I@galera:master' mysql.status | grep -A1 wsrep_cluster_size |
| 35 | salt -C 'I@galera:slave' mysql.status | grep -A1 wsrep_cluster_size |
| 36 | fi |
| 37 | |
| 38 | # Install haproxy |
| 39 | salt -C 'I@haproxy:proxy' state.sls haproxy |
| 40 | salt -C 'I@haproxy:proxy' service.status haproxy |
| 41 | salt -I 'haproxy:proxy' service.restart rsyslog |
| 42 | |
| 43 | if [[ "$MEMCACHED_SERVICE" == "true" ]]; then |
| 44 | # Install memcached |
| 45 | salt -C 'I@memcached:server' state.sls memcached |
| 46 | fi |
| 47 | |
| 48 | if [[ "$NGINX_SERVICE" == "true" ]]; then |
| 49 | # Install memcached |
| 50 | salt -C 'I@nginx:server' state.sls nginx |
| 51 | fi |