Dennis Dmitriev | 8daa1e3 | 2017-12-19 02:29:48 +0200 | [diff] [blame] | 1 | {# Collection of common macroses shared across different deployments #} |
| 2 | |
| 3 | {%- macro MACRO_INSTALL_SMTP_ALERTS_RECEIVER() %} |
| 4 | - description: Install exim4 on {{ HOSTNAME_CFG01 }} |
| 5 | cmd: apt -y install exim4-daemon-light |
| 6 | node_name: {{ HOSTNAME_CFG01 }} |
| 7 | retry: {count: 1, delay: 1} |
| 8 | skip_fail: false |
| 9 | |
| 10 | - description: Configure exim4 to receive emails to the ~/Maildir for local users |
| 11 | cmd: | |
| 12 | sed -i "s/dc_other_hostnames=.*/dc_other_hostnames='*'/g" /etc/exim4/update-exim4.conf.conf |
| 13 | sed -i "s/dc_local_interfaces=.*/dc_local_interfaces=''/g" /etc/exim4/update-exim4.conf.conf |
| 14 | sed -i "s/dc_localdelivery=.*/dc_localdelivery='maildir_home'/g" /etc/exim4/update-exim4.conf.conf |
| 15 | update-exim4.conf |
| 16 | service exim4 restart |
| 17 | node_name: {{ HOSTNAME_CFG01 }} |
| 18 | retry: {count: 1, delay: 1} |
| 19 | skip_fail: false |
| 20 | |
| 21 | - description: Create a special user to receive alerts |
| 22 | cmd: useradd _alertsreceiver -m |
| 23 | node_name: {{ HOSTNAME_CFG01 }} |
| 24 | retry: {count: 1, delay: 1} |
| 25 | skip_fail: false |
| 26 | |
| 27 | - description: Modify SL pillars to send alerts to SMTP server on {{ HOSTNAME_CFG01 }} |
| 28 | cmd: | |
| 29 | # Remove existing definitions for email alerting |
| 30 | export REPLACE_DIR="/srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}" |
| 31 | find ${REPLACE_DIR} -type f -exec sed -i '/pushkin_smtp_host:.*/d' {} + |
| 32 | find ${REPLACE_DIR} -type f -exec sed -i '/pushkin_smtp_port:.*/d' {} + |
| 33 | find ${REPLACE_DIR} -type f -exec sed -i '/pushkin_email_sender_password:.*/d' {} + |
| 34 | find ${REPLACE_DIR} -type f -exec sed -i '/webhook_from:.*/d' {} + |
| 35 | find ${REPLACE_DIR} -type f -exec sed -i '/webhook_recipients:.*/d' {} + |
| 36 | |
| 37 | salt-call reclass.cluster_meta_set name='pushkin_smtp_host' value='${_param:salt_master_host}' file_name=${REPLACE_DIR}/stacklight/init.yml |
| 38 | salt-call reclass.cluster_meta_set name='pushkin_smtp_port' value='25' file_name=${REPLACE_DIR}/stacklight/init.yml |
| 39 | salt-call reclass.cluster_meta_set name='pushkin_email_sender_password' value='""' file_name=${REPLACE_DIR}/stacklight/init.yml |
| 40 | salt-call reclass.cluster_meta_set name='webhook_from' value='monitoring@{{ LAB_CONFIG_NAME }}.local' file_name=${REPLACE_DIR}/stacklight/init.yml |
| 41 | salt-call reclass.cluster_meta_set name='webhook_recipients' value='alerts@integration.ci.local' file_name=${REPLACE_DIR}/stacklight/init.yml |
| 42 | |
| 43 | salt '*' saltutil.refresh_pillar |
| 44 | node_name: {{ HOSTNAME_CFG01 }} |
| 45 | retry: {count: 1, delay: 1} |
| 46 | skip_fail: false |
| 47 | |
| 48 | {%- endmacro %} |
| 49 | |
Oleksii Butenko | 81d8a7f | 2018-09-26 16:09:27 +0300 | [diff] [blame] | 50 | {%- macro MACRO_INSTALL_KEEPALIVED() %} |
| 51 | |
| 52 | - description: Install keepalived on ctl01 |
| 53 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False |
| 54 | -C 'I@keepalived:cluster and *01*' state.sls keepalived |
| 55 | node_name: {{ HOSTNAME_CFG01 }} |
| 56 | retry: {count: 1, delay: 10} |
| 57 | skip_fail: true |
| 58 | |
| 59 | - description: Install keepalived |
| 60 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False |
| 61 | -C 'I@keepalived:cluster' state.sls keepalived |
| 62 | node_name: {{ HOSTNAME_CFG01 }} |
| 63 | retry: {count: 1, delay: 10} |
| 64 | skip_fail: true |
| 65 | |
| 66 | {%- endmacro %} |
| 67 | |
ibumarskov | b521006 | 2018-08-22 16:18:15 +0400 | [diff] [blame] | 68 | {%- macro MACRO_INSTALL_GLUSTERFS() %} |
Dennis Dmitriev | 8daa1e3 | 2017-12-19 02:29:48 +0200 | [diff] [blame] | 69 | |
ibumarskov | b521006 | 2018-08-22 16:18:15 +0400 | [diff] [blame] | 70 | - description: Install glusterfs |
| 71 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False |
Pavel Glazov | 2f8c5ba | 2018-10-10 13:48:43 +0400 | [diff] [blame] | 72 | -C 'I@glusterfs:server' state.sls glusterfs.server.service && sleep 20 |
ibumarskov | b521006 | 2018-08-22 16:18:15 +0400 | [diff] [blame] | 73 | node_name: {{ HOSTNAME_CFG01 }} |
| 74 | retry: {count: 1, delay: 5} |
| 75 | skip_fail: false |
Dennis Dmitriev | 8daa1e3 | 2017-12-19 02:29:48 +0200 | [diff] [blame] | 76 | |
ibumarskov | b521006 | 2018-08-22 16:18:15 +0400 | [diff] [blame] | 77 | - description: Setup glusterfs on primary controller |
| 78 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False |
abaraniuk | f21fe7b | 2018-11-06 19:28:27 +0200 | [diff] [blame] | 79 | -C 'I@glusterfs:server:role:primary' state.sls glusterfs.server.setup -b 1 |
ibumarskov | b521006 | 2018-08-22 16:18:15 +0400 | [diff] [blame] | 80 | node_name: {{ HOSTNAME_CFG01 }} |
abaraniuk | f21fe7b | 2018-11-06 19:28:27 +0200 | [diff] [blame] | 81 | retry: {count: 5, delay: 5} |
ibumarskov | b521006 | 2018-08-22 16:18:15 +0400 | [diff] [blame] | 82 | skip_fail: false |
Dennis Dmitriev | 8daa1e3 | 2017-12-19 02:29:48 +0200 | [diff] [blame] | 83 | |
ibumarskov | b521006 | 2018-08-22 16:18:15 +0400 | [diff] [blame] | 84 | - description: Check the gluster status |
| 85 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False |
| 86 | -C 'I@glusterfs:server' cmd.run 'gluster peer status && gluster volume status' -b 1 |
| 87 | node_name: {{ HOSTNAME_CFG01 }} |
| 88 | retry: {count: 1, delay: 5} |
| 89 | skip_fail: false |
Dennis Dmitriev | 8daa1e3 | 2017-12-19 02:29:48 +0200 | [diff] [blame] | 90 | |
ibumarskov | b521006 | 2018-08-22 16:18:15 +0400 | [diff] [blame] | 91 | {%- endmacro %} |
Oleksii Butenko | 81d8a7f | 2018-09-26 16:09:27 +0300 | [diff] [blame] | 92 | |
| 93 | {%- macro MACRO_INSTALL_RABBITMQ() %} |
| 94 | |
| 95 | - description: Install RabbitMQ on ctl01 |
| 96 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False |
| 97 | -C 'I@rabbitmq:server and *01*' state.sls rabbitmq |
| 98 | node_name: {{ HOSTNAME_CFG01 }} |
| 99 | retry: {count: 1, delay: 5} |
| 100 | skip_fail: false |
| 101 | |
| 102 | - description: Install RabbitMQ |
| 103 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False |
| 104 | -C 'I@rabbitmq:server' state.sls rabbitmq |
| 105 | node_name: {{ HOSTNAME_CFG01 }} |
| 106 | retry: {count: 1, delay: 5} |
| 107 | skip_fail: false |
| 108 | |
| 109 | - description: Check the rabbitmq status |
| 110 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False |
| 111 | -C 'I@rabbitmq:server' cmd.run 'rabbitmqctl cluster_status' |
| 112 | node_name: {{ HOSTNAME_CFG01 }} |
| 113 | retry: {count: 1, delay: 5} |
| 114 | skip_fail: false |
| 115 | |
| 116 | {%- endmacro %} |
| 117 | |
| 118 | {%- macro MACRO_INSTALL_GALERA() %} |
| 119 | |
| 120 | - description: Install Galera on first server |
| 121 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False |
| 122 | -C 'I@galera:master' state.sls galera |
| 123 | node_name: {{ HOSTNAME_CFG01 }} |
| 124 | retry: {count: 1, delay: 5} |
| 125 | skip_fail: false |
| 126 | |
| 127 | - description: Install Galera on other servers |
| 128 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False |
| 129 | -C 'I@galera:slave' state.sls galera -b 1 |
| 130 | node_name: {{ HOSTNAME_CFG01 }} |
| 131 | retry: {count: 1, delay: 5} |
| 132 | skip_fail: false |
| 133 | |
| 134 | - description: Check mysql status |
| 135 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False |
| 136 | -C 'I@galera:*' mysql.status | grep -A1 -e "wsrep_incoming_addresses\|wsrep_cluster_size" |
| 137 | node_name: {{ HOSTNAME_CFG01 }} |
| 138 | retry: {count: 1, delay: 5} |
| 139 | skip_fail: true |
| 140 | |
| 141 | {%- endmacro %} |
| 142 | |
| 143 | {%- macro MACRO_INSTALL_HAPROXY() %} |
| 144 | |
| 145 | - description: Install haproxy |
| 146 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False |
| 147 | -C 'I@haproxy:proxy' state.sls haproxy |
| 148 | node_name: {{ HOSTNAME_CFG01 }} |
| 149 | retry: {count: 1, delay: 5} |
| 150 | skip_fail: false |
| 151 | |
| 152 | - description: Check haproxy status |
| 153 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False |
| 154 | -C 'I@haproxy:proxy' service.status haproxy |
| 155 | node_name: {{ HOSTNAME_CFG01 }} |
| 156 | retry: {count: 1, delay: 5} |
| 157 | skip_fail: false |
| 158 | |
| 159 | - description: Restart rsyslog |
| 160 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False |
| 161 | -C 'I@haproxy:proxy' service.restart rsyslog |
| 162 | node_name: {{ HOSTNAME_CFG01 }} |
| 163 | retry: {count: 1, delay: 5} |
| 164 | skip_fail: false |
| 165 | |
| 166 | {%- endmacro %} |
| 167 | |
| 168 | {%- macro MACRO_INSTALL_MEMCACHED() %} |
| 169 | |
| 170 | - description: Install memcached on all controllers |
| 171 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False |
| 172 | -C 'I@memcached:server' state.sls memcached |
| 173 | node_name: {{ HOSTNAME_CFG01 }} |
| 174 | retry: {count: 1, delay: 5} |
| 175 | skip_fail: false |
| 176 | |
| 177 | {%- endmacro %} |
| 178 | |
| 179 | {%- macro MACRO_CHECK_VIP() %} |
| 180 | - description: Check the VIP |
| 181 | cmd: | |
| 182 | OPENSTACK_CONTROL_ADDRESS=`salt-call --out=newline_values_only pillar.get _param:openstack_control_address`; |
| 183 | echo "_param:openstack_control_address (vip): ${OPENSTACK_CONTROL_ADDRESS}"; |
| 184 | salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@keepalived:cluster' cmd.run "ip a | grep ${OPENSTACK_CONTROL_ADDRESS}" | grep -B1 ${OPENSTACK_CONTROL_ADDRESS} |
| 185 | node_name: {{ HOSTNAME_CFG01 }} |
| 186 | retry: {count: 3, delay: 10} |
| 187 | skip_fail: false |
| 188 | |
| 189 | {%- endmacro %} |