blob: 0a0c63a46162d9a21b74b9a9c56978c80f4a3d14 [file] [log] [blame]
Dennis Dmitriev8daa1e32017-12-19 02:29:48 +02001{# 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 Butenko81d8a7f2018-09-26 16:09:27 +030050{%- 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
ibumarskovb5210062018-08-22 16:18:15 +040068{%- macro MACRO_INSTALL_GLUSTERFS() %}
Dennis Dmitriev8daa1e32017-12-19 02:29:48 +020069
ibumarskovb5210062018-08-22 16:18:15 +040070- description: Install glusterfs
71 cmd: salt --hard-crash --state-output=mixed --state-verbose=False
Pavel Glazov2f8c5ba2018-10-10 13:48:43 +040072 -C 'I@glusterfs:server' state.sls glusterfs.server.service && sleep 20
ibumarskovb5210062018-08-22 16:18:15 +040073 node_name: {{ HOSTNAME_CFG01 }}
74 retry: {count: 1, delay: 5}
75 skip_fail: false
Dennis Dmitriev8daa1e32017-12-19 02:29:48 +020076
ibumarskovb5210062018-08-22 16:18:15 +040077- description: Setup glusterfs on primary controller
78 cmd: salt --hard-crash --state-output=mixed --state-verbose=False
abaraniukf21fe7b2018-11-06 19:28:27 +020079 -C 'I@glusterfs:server:role:primary' state.sls glusterfs.server.setup -b 1
ibumarskovb5210062018-08-22 16:18:15 +040080 node_name: {{ HOSTNAME_CFG01 }}
abaraniukf21fe7b2018-11-06 19:28:27 +020081 retry: {count: 5, delay: 5}
ibumarskovb5210062018-08-22 16:18:15 +040082 skip_fail: false
Dennis Dmitriev8daa1e32017-12-19 02:29:48 +020083
ibumarskovb5210062018-08-22 16:18:15 +040084- 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 Dmitriev8daa1e32017-12-19 02:29:48 +020090
ibumarskovb5210062018-08-22 16:18:15 +040091{%- endmacro %}
Oleksii Butenko81d8a7f2018-09-26 16:09:27 +030092
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 %}