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 | |
obutenko | 863a8ef | 2018-11-20 11:06:58 +0200 | [diff] [blame^] | 84 | - description: Setup glusterfs on other nodes |
| 85 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False |
| 86 | -C 'I@glusterfs:server' state.sls glusterfs |
| 87 | node_name: {{ HOSTNAME_CFG01 }} |
| 88 | retry: {count: 5, delay: 5} |
| 89 | skip_fail: false |
| 90 | |
ibumarskov | b521006 | 2018-08-22 16:18:15 +0400 | [diff] [blame] | 91 | - description: Check the gluster status |
| 92 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False |
| 93 | -C 'I@glusterfs:server' cmd.run 'gluster peer status && gluster volume status' -b 1 |
| 94 | node_name: {{ HOSTNAME_CFG01 }} |
| 95 | retry: {count: 1, delay: 5} |
| 96 | skip_fail: false |
Dennis Dmitriev | 8daa1e3 | 2017-12-19 02:29:48 +0200 | [diff] [blame] | 97 | |
obutenko | 863a8ef | 2018-11-20 11:06:58 +0200 | [diff] [blame^] | 98 | - description: Refresh pillar before glusterfs client |
| 99 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False |
| 100 | -C 'I@glusterfs:client' saltutil.refresh_pillar |
| 101 | node_name: {{ HOSTNAME_CFG01 }} |
| 102 | retry: {count: 1, delay: 5} |
| 103 | skip_fail: false |
| 104 | |
| 105 | - description: Setup glusterfs client |
| 106 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False |
| 107 | -C 'I@glusterfs:client' state.sls glusterfs.client |
| 108 | node_name: {{ HOSTNAME_CFG01 }} |
| 109 | retry: {count: 1, delay: 15} |
| 110 | skip_fail: false |
| 111 | |
ibumarskov | b521006 | 2018-08-22 16:18:15 +0400 | [diff] [blame] | 112 | {%- endmacro %} |
Oleksii Butenko | 81d8a7f | 2018-09-26 16:09:27 +0300 | [diff] [blame] | 113 | |
| 114 | {%- macro MACRO_INSTALL_RABBITMQ() %} |
| 115 | |
| 116 | - description: Install RabbitMQ on ctl01 |
| 117 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False |
| 118 | -C 'I@rabbitmq:server and *01*' state.sls rabbitmq |
| 119 | node_name: {{ HOSTNAME_CFG01 }} |
| 120 | retry: {count: 1, delay: 5} |
| 121 | skip_fail: false |
| 122 | |
| 123 | - description: Install RabbitMQ |
| 124 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False |
| 125 | -C 'I@rabbitmq:server' state.sls rabbitmq |
| 126 | node_name: {{ HOSTNAME_CFG01 }} |
| 127 | retry: {count: 1, delay: 5} |
| 128 | skip_fail: false |
| 129 | |
| 130 | - description: Check the rabbitmq status |
| 131 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False |
| 132 | -C 'I@rabbitmq:server' cmd.run 'rabbitmqctl cluster_status' |
| 133 | node_name: {{ HOSTNAME_CFG01 }} |
| 134 | retry: {count: 1, delay: 5} |
| 135 | skip_fail: false |
| 136 | |
| 137 | {%- endmacro %} |
| 138 | |
| 139 | {%- macro MACRO_INSTALL_GALERA() %} |
| 140 | |
| 141 | - description: Install Galera on first server |
| 142 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False |
| 143 | -C 'I@galera:master' state.sls galera |
| 144 | node_name: {{ HOSTNAME_CFG01 }} |
| 145 | retry: {count: 1, delay: 5} |
| 146 | skip_fail: false |
| 147 | |
| 148 | - description: Install Galera on other servers |
| 149 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False |
| 150 | -C 'I@galera:slave' state.sls galera -b 1 |
| 151 | node_name: {{ HOSTNAME_CFG01 }} |
| 152 | retry: {count: 1, delay: 5} |
| 153 | skip_fail: false |
| 154 | |
| 155 | - description: Check mysql status |
| 156 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False |
| 157 | -C 'I@galera:*' mysql.status | grep -A1 -e "wsrep_incoming_addresses\|wsrep_cluster_size" |
| 158 | node_name: {{ HOSTNAME_CFG01 }} |
| 159 | retry: {count: 1, delay: 5} |
| 160 | skip_fail: true |
| 161 | |
| 162 | {%- endmacro %} |
| 163 | |
| 164 | {%- macro MACRO_INSTALL_HAPROXY() %} |
| 165 | |
| 166 | - description: Install haproxy |
| 167 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False |
| 168 | -C 'I@haproxy:proxy' state.sls haproxy |
| 169 | node_name: {{ HOSTNAME_CFG01 }} |
| 170 | retry: {count: 1, delay: 5} |
| 171 | skip_fail: false |
| 172 | |
| 173 | - description: Check haproxy status |
| 174 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False |
| 175 | -C 'I@haproxy:proxy' service.status haproxy |
| 176 | node_name: {{ HOSTNAME_CFG01 }} |
| 177 | retry: {count: 1, delay: 5} |
| 178 | skip_fail: false |
| 179 | |
| 180 | - description: Restart rsyslog |
| 181 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False |
| 182 | -C 'I@haproxy:proxy' service.restart rsyslog |
| 183 | node_name: {{ HOSTNAME_CFG01 }} |
| 184 | retry: {count: 1, delay: 5} |
| 185 | skip_fail: false |
| 186 | |
| 187 | {%- endmacro %} |
| 188 | |
obutenko | 863a8ef | 2018-11-20 11:06:58 +0200 | [diff] [blame^] | 189 | {%- macro MACRO_INSTALL_NGINX() %} |
| 190 | |
| 191 | - description: Update certificate files on nginx nodes |
| 192 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False |
| 193 | -C 'I@nginx:server' state.sls salt.minion.cert |
| 194 | node_name: {{ HOSTNAME_CFG01 }} |
| 195 | retry: {count: 1, delay: 15} |
| 196 | skip_fail: false |
| 197 | |
| 198 | - description: Install nginx server |
| 199 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False |
| 200 | -C 'I@nginx:server' state.sls nginx |
| 201 | node_name: {{ HOSTNAME_CFG01 }} |
| 202 | retry: {count: 1, delay: 5} |
| 203 | skip_fail: false |
| 204 | |
| 205 | {%- endmacro %} |
| 206 | |
Oleksii Butenko | 81d8a7f | 2018-09-26 16:09:27 +0300 | [diff] [blame] | 207 | {%- macro MACRO_INSTALL_MEMCACHED() %} |
| 208 | |
| 209 | - description: Install memcached on all controllers |
| 210 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False |
| 211 | -C 'I@memcached:server' state.sls memcached |
| 212 | node_name: {{ HOSTNAME_CFG01 }} |
| 213 | retry: {count: 1, delay: 5} |
| 214 | skip_fail: false |
| 215 | |
| 216 | {%- endmacro %} |
| 217 | |
| 218 | {%- macro MACRO_CHECK_VIP() %} |
| 219 | - description: Check the VIP |
| 220 | cmd: | |
| 221 | OPENSTACK_CONTROL_ADDRESS=`salt-call --out=newline_values_only pillar.get _param:openstack_control_address`; |
| 222 | echo "_param:openstack_control_address (vip): ${OPENSTACK_CONTROL_ADDRESS}"; |
| 223 | 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} |
| 224 | node_name: {{ HOSTNAME_CFG01 }} |
| 225 | retry: {count: 3, delay: 10} |
| 226 | skip_fail: false |
| 227 | |
| 228 | {%- endmacro %} |