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 | |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | |
| 55 | |
| 56 | |