blob: 90651381fbdcbebd9aa97be0078fe74ea26b8ca7 [file] [log] [blame]
Dennis Dmitriev492813e2017-08-09 15:08:58 +03001{# Collection of common macroses shared across different deployments #}
2
Sergii Golovatiuk50f91892017-08-04 18:11:06 +02003{% set SALT_MODELS_BRANCH = os_env('SALT_MODELS_BRANCH','master') %}
4{% set SALT_MODELS_COMMIT = os_env('SALT_MODELS_COMMIT','master') %}
5{# Reference to a patch that should be applied to the model if required, for example: export SALT_MODELS_REF_CHANGE=refs/changes/19/7219/12 #}
6{% set SALT_MODELS_REF_CHANGE = os_env('SALT_MODELS_REF_CHANGE', '') %}
7{# Pin to a specified commit in salt-models/reclass-system #}
Dmitry Tyzhnenko778515f2017-08-25 14:52:54 +03008{% set SALT_MODELS_SYSTEM_REPOSITORY = os_env('SALT_MODELS_SYSTEM_REPOSITORY','https://gerrit.mcp.mirantis.net/salt-models/reclass-system') %}
Sergii Golovatiuk50f91892017-08-04 18:11:06 +02009{% set SALT_MODELS_SYSTEM_COMMIT = os_env('SALT_MODELS_SYSTEM_COMMIT','') %}
Dmitry Tyzhnenko778515f2017-08-25 14:52:54 +030010{% set SALT_MODELS_SYSTEM_REF_CHANGE = os_env('SALT_MODELS_SYSTEM_REF_CHANGE','') %}
Sergii Golovatiuk50f91892017-08-04 18:11:06 +020011
Dennis Dmitriev492813e2017-08-09 15:08:58 +030012{% set REPOSITORY_SUITE = os_env('REPOSITORY_SUITE', 'testing') %}
13
Sergii Golovatiuk50f91892017-08-04 18:11:06 +020014{# Address pools for reclass cluster model are taken in the following order:
15 # 1. environment variables,
16 # 2. config.underlay.address_pools based on fuel-devops address pools
17 # (see generated '.ini' file after underlay is created),
18 # 3. defaults #}
19{% set address_pools = config.underlay.address_pools %}
20{% set IPV4_NET_ADMIN = os_env('IPV4_NET_ADMIN', address_pools.get('admin-pool01', '192.168.10.0/24')) %}
21{% set IPV4_NET_CONTROL = os_env('IPV4_NET_CONTROL', address_pools.get('private-pool01', '172.16.10.0/24')) %}
22{% set IPV4_NET_TENANT = os_env('IPV4_NET_TENANT', address_pools.get('tenant-pool01', '10.1.0.0/24')) %}
23{% set IPV4_NET_EXTERNAL = os_env('IPV4_NET_EXTERNAL', address_pools.get('external-pool01', '10.16.0.0/24')) %}
24{% set IPV4_NET_ADMIN_PREFIX = '.'.join(IPV4_NET_ADMIN.split('.')[0:3]) %}
25{% set IPV4_NET_CONTROL_PREFIX = '.'.join(IPV4_NET_CONTROL.split('.')[0:3]) %}
26{% set IPV4_NET_TENANT_PREFIX = '.'.join(IPV4_NET_TENANT.split('.')[0:3]) %}
27{% set IPV4_NET_EXTERNAL_PREFIX = '.'.join(IPV4_NET_EXTERNAL.split('.')[0:3]) %}
28
Victor Ryzhenkin4e077ad2017-08-10 13:42:11 +040029{# Format for formula replacement:
30 # space separated string:
31 # export SALT_FORMULAS_REFS='apache:refs/changes/xxxx kubernetes:refs/changes/xxxx' #}
32
33{% set SALT_FORMULAS_REFS = os_env('SALT_FORMULAS_REFS', '') %}
34{% set SALT_FORMULAS_REPO = os_env('SALT_FORMULAS_REPO', 'https://gerrit.mcp.mirantis.net/salt-formulas') %}
35
Dennis Dmitriev492813e2017-08-09 15:08:58 +030036
37{%- macro MACRO_INSTALL_SALT_MASTER() %}
38{######################################}
39- description: Installing salt master on cfg01
40 cmd: eatmydata apt-get install -y reclass git salt-master
41 node_name: {{ HOSTNAME_CFG01 }}
42 retry: {count: 1, delay: 1}
43 skip_fail: false
44
45- description: Configure salt-master on cfg01
46 cmd: |
47 cat << 'EOF' >> /etc/salt/master.d/master.conf
48 file_roots:
49 base:
50 - /usr/share/salt-formulas/env
51 pillar_opts: False
52 open_mode: True
53 reclass: &reclass
54 storage_type: yaml_fs
55 inventory_base_uri: /srv/salt/reclass
56 ext_pillar:
57 - reclass: *reclass
58 master_tops:
59 reclass: *reclass
60 EOF
61 node_name: {{ HOSTNAME_CFG01 }}
62 retry: {count: 1, delay: 1}
63 skip_fail: false
64
65- description: Configure GIT settings and certificates
Dennis Dmitriev3e731a42017-08-30 17:12:59 +030066 cmd: |
67 set -e;
68 touch /root/.git_trusted_certs.pem;
69 for server in github.com; do \
70 openssl s_client -showcerts -connect $server:443 </dev/null \
71 | openssl x509 -outform PEM \
Dennis Dmitriev492813e2017-08-09 15:08:58 +030072 >> /root/.git_trusted_certs.pem;
73 done;
74 HOME=/root git config --global http.sslCAInfo /root/.git_trusted_certs.pem;
75 HOME=/root git config --global user.email "tcp-qa@example.com";
76 HOME=/root git config --global user.name "TCP QA";
77 node_name: {{ HOSTNAME_CFG01 }}
78 retry: {count: 1, delay: 1}
79 skip_fail: false
80{%- endmacro %}
81
82
83{%- macro MACRO_CLONE_RECLASS_MODELS(IS_CONTRAIL_LAB=false) %}
84{############################################################}
85- description: Clone reclass models with submodules
86 cmd: |
Dennis Dmitriev3e731a42017-08-30 17:12:59 +030087 set -e;
Sergii Golovatiuk50f91892017-08-04 18:11:06 +020088 ssh-keyscan -H github.com >> ~/.ssh/known_hosts;
Tatyana Leontovich44162732017-08-28 12:36:00 +030089 export GIT_SSL_NO_VERIFY=true; git clone -b {{ SALT_MODELS_BRANCH }} --recurse-submodules {{ SALT_MODELS_REPOSITORY }} /srv/salt/reclass;
Sergii Golovatiuk50f91892017-08-04 18:11:06 +020090 pushd /srv/salt/reclass && \
91 {%- if SALT_MODELS_REF_CHANGE != '' %}
92 {%- for item in SALT_MODELS_REF_CHANGE.split(" ") %}
93 git fetch {{ SALT_MODELS_REPOSITORY }} {{ item }} && git cherry-pick FETCH_HEAD && \
94 {%- endfor %}
95 {%- elif SALT_MODELS_COMMIT != 'master' %}
96 git checkout {{ SALT_MODELS_COMMIT }} && \
97 {%- endif %}
98 {%- if SALT_MODELS_SYSTEM_COMMIT != '' %}
99 pushd classes/system/ && \
100 git checkout {{ SALT_MODELS_SYSTEM_COMMIT }} && \
101 popd && \
Dmitry Tyzhnenko778515f2017-08-25 14:52:54 +0300102 {%- elif SALT_MODELS_SYSTEM_REF_CHANGE != '' -%}
103 pushd classes/system/ && \
104 {%- for item in SALT_MODELS_SYSTEM_REF_CHANGE.split(" ") %}
105 git fetch {{ SALT_MODELS_SYSTEM_REPOSITORY }} {{ item }} && git cherry-pick FETCH_HEAD && \
106 {%- endfor %}
107 popd && \
Sergii Golovatiuk50f91892017-08-04 18:11:06 +0200108 {%- else %}
109 git submodule update --init --recursive && \
110 {%- endif %}
111 popd;
112 mkdir -p /srv/salt/reclass/classes/service;
113
114 # Replace firstly to an intermediate value to avoid intersection between
115 # already replaced and replacing networks.
116 # For example, if generated IPV4_NET_ADMIN_PREFIX=10.16.0 , then there is a risk of replacing twice:
117 # 192.168.10 -> 10.16.0 (generated network for admin)
118 # 10.16.0 -> <external network>
119 # So let's replace constant networks to the keywords, and then keywords to the desired networks.
Dennis Dmitriev9d9ba9f2017-09-13 17:34:03 +0300120 export REPLACE_DIRS="/srv/salt/reclass/classes/ /srv/salt/reclass/nodes/"
121 find ${REPLACE_DIRS} -type f -exec sed -i 's/192\.168\.10\./==IPV4_NET_ADMIN_PREFIX==/g' {} +
122 find ${REPLACE_DIRS} -type f -exec sed -i 's/172\.16\.10\./==IPV4_NET_CONTROL_PREFIX==/g' {} +
123 find ${REPLACE_DIRS} -type f -exec sed -i 's/10\.1\.0\./==IPV4_NET_TENANT_PREFIX==/g' {} +
124 find ${REPLACE_DIRS} -type f -exec sed -i 's/10\.16\.0\./==IPV4_NET_EXTERNAL_PREFIX==/g' {} +
Sergii Golovatiuk50f91892017-08-04 18:11:06 +0200125
Dennis Dmitriev9d9ba9f2017-09-13 17:34:03 +0300126 find ${REPLACE_DIRS} -type f -exec sed -i 's/==IPV4_NET_ADMIN_PREFIX==/{{ IPV4_NET_ADMIN_PREFIX }}./g' {} +
127 find ${REPLACE_DIRS} -type f -exec sed -i 's/==IPV4_NET_CONTROL_PREFIX==/{{ IPV4_NET_CONTROL_PREFIX }}./g' {} +
128 find ${REPLACE_DIRS} -type f -exec sed -i 's/==IPV4_NET_TENANT_PREFIX==/{{ IPV4_NET_TENANT_PREFIX }}./g' {} +
129 find ${REPLACE_DIRS} -type f -exec sed -i 's/==IPV4_NET_EXTERNAL_PREFIX==/{{ IPV4_NET_EXTERNAL_PREFIX }}./g' {} +
Sergii Golovatiuk50f91892017-08-04 18:11:06 +0200130
Dennis Dmitriev9d9ba9f2017-09-13 17:34:03 +0300131 find ${REPLACE_DIRS} -type f -exec sed -i 's/apt_mk_version:.*/apt_mk_version: {{ REPOSITORY_SUITE }}/g' {} +
Sergii Golovatiuk50f91892017-08-04 18:11:06 +0200132
Dennis Dmitriev492813e2017-08-09 15:08:58 +0300133 {%- if IS_CONTRAIL_LAB %}
134 # vSRX IPs for tcp-qa images have 172.16.10.90 hardcoded
Dennis Dmitriev9d9ba9f2017-09-13 17:34:03 +0300135 find ${REPLACE_DIRS} -type f -exec sed -i 's/opencontrail_router01_address:.*/opencontrail_router01_address: 172.16.10.90/g' {} +
Tatyana Leontovich3424bf62017-09-15 12:13:54 +0300136 find ${REPLACE_DIRS} -type f -exec sed -i 's/infra_config_deploy_address: 1.*/infra_config_deploy_address: {{ IPV4_NET_ADMIN_PREFIX }}.15/g' {} +
Dennis Dmitriev492813e2017-08-09 15:08:58 +0300137 {%- endif %}
138
Sergii Golovatiuk50f91892017-08-04 18:11:06 +0200139 # Disable checkouting the model from remote repository
140 cat << 'EOF' >> /srv/salt/reclass/nodes/{{ HOSTNAME_CFG01 }}.yml
141 # local storage
142 reclass:
143 storage:
144 data_source:
145 engine: local
146 EOF
Dennis Dmitriev492813e2017-08-09 15:08:58 +0300147
148 # Show the changes to the console
149 cd /srv/salt/reclass/; git diff
150 node_name: {{ HOSTNAME_CFG01 }}
151 retry: {count: 1, delay: 1}
152 skip_fail: false
153{%- endmacro %}
154
155
156{%- macro MACRO_CONFIGURE_RECLASS(FORMULA_SERVICES='') %}
157{#######################################################}
158- description: Configure reclass
159 cmd: |
Dennis Dmitriev3e731a42017-08-30 17:12:59 +0300160 set -e;
Dennis Dmitriev492813e2017-08-09 15:08:58 +0300161 FORMULA_PATH=${FORMULA_PATH:-/usr/share/salt-formulas};
162 FORMULA_REPOSITORY=${FORMULA_REPOSITORY:-deb [arch=amd64] http://apt.mirantis.com/xenial {{ REPOSITORY_SUITE }} salt};
163 FORMULA_GPG=${FORMULA_GPG:-http://apt.mirantis.com/public.gpg};
164 which wget > /dev/null || (apt-get update; apt-get install -y wget);
165 echo "${FORMULA_REPOSITORY}" > /etc/apt/sources.list.d/mcp_salt.list;
166 wget -O - "${FORMULA_GPG}" | apt-key add -;
167 apt-get clean; apt-get update;
168 [ ! -d /srv/salt/reclass/classes/service ] && mkdir -p /srv/salt/reclass/classes/service;
169 declare -a formula_services=({{ FORMULA_SERVICES }});
170 echo -e "\nInstalling all required salt formulas\n";
171 eatmydata apt-get install -y "${formula_services[@]/#/salt-formula-}";
172 for formula_service in "${formula_services[@]}"; do
173 echo -e "\nLink service metadata for formula ${formula_service} ...\n";
174 [ ! -L "/srv/salt/reclass/classes/service/${formula_service}" ] && ln -s ${FORMULA_PATH}/reclass/service/${formula_service} /srv/salt/reclass/classes/service/${formula_service};
175 done;
176 [ ! -d /srv/salt/env ] && mkdir -p /srv/salt/env;
177 [ ! -L /srv/salt/env/prd ] && ln -s ${FORMULA_PATH}/env /srv/salt/env/prd;
178 [ ! -d /etc/reclass ] && mkdir /etc/reclass;
179
180 cat << 'EOF' >> /etc/reclass/reclass-config.yml
181 storage_type: yaml_fs
182 pretty_print: True
183 output: yaml
184 inventory_base_uri: /srv/salt/reclass
185 EOF
186 node_name: {{ HOSTNAME_CFG01 }}
187 retry: {count: 1, delay: 1}
188 skip_fail: false
189
190- description: "*Workaround* remove all cfg01 nodes except {{ HOSTNAME_CFG01 }} to not depend on other clusters in 'reclass --top'"
191 cmd: |
192 # Remove all other nodes except {{ HOSTNAME_CFG01 }} to not rely on them for 'reclass --top'
193 find /srv/salt/reclass/nodes/ -type f -not -name {{ HOSTNAME_CFG01 }}.yml -delete
194 node_name: {{ HOSTNAME_CFG01 }}
195 retry: {count: 1, delay: 5}
196 skip_fail: false
197
198- description: Configure salt adoptors on cfg01
199 cmd: |
200 ln -s /usr/lib/python2.7/dist-packages/reclass/adapters/salt.py /usr/local/sbin/reclass-salt;
201 chmod +x /usr/lib/python2.7/dist-packages/reclass/adapters/salt.py
202 node_name: {{ HOSTNAME_CFG01 }}
203 retry: {count: 1, delay: 1}
204 skip_fail: false
205
206- description: Show reclass-salt --top for cfg01 node
207 cmd: reclass-salt --top
208 node_name: {{ HOSTNAME_CFG01 }}
209 retry: {count: 1, delay: 5}
210 skip_fail: false
211
212- description: Restart salt-master service
213 cmd: systemctl restart salt-master;
214 node_name: {{ HOSTNAME_CFG01 }}
215 retry: {count: 1, delay: 5}
216 skip_fail: false
217{%- endmacro %}
218
219
220{%- macro MACRO_INSTALL_SALT_MINIONS() %}
221{#######################################}
222{% for ssh in config.underlay.ssh %}
223- description: Configure salt-minion on {{ ssh['node_name'] }}
224 cmd: |
225 [ ! -d /etc/salt/minion.d ] && mkdir -p /etc/salt/minion.d;
226 cat << "EOF" >> /etc/salt/minion.d/minion.conf
227 id: {{ ssh['node_name'] }}
228 master: {{ config.salt.salt_master_host }}
229 EOF
230 eatmydata apt-get install -y salt-minion;
Dennis Dmitriev3e731a42017-08-30 17:12:59 +0300231 service salt-minion restart; # For case if salt-minion was already installed
Dennis Dmitriev492813e2017-08-09 15:08:58 +0300232 node_name: {{ ssh['node_name'] }}
233 retry: {count: 1, delay: 1}
234 skip_fail: false
235{% endfor %}
236
237
238- description: Accept salt keys from all the nodes
239 cmd: salt-key -A -y
240 node_name: {{ HOSTNAME_CFG01 }}
241 retry: {count: 1, delay: 5}
242 skip_fail: true
243{%- endmacro %}
244
245
246{%- macro MACRO_RUN_SALT_MASTER_UNDERLAY_STATES() %}
247{##################################################}
248
249{# Prepare salt services and nodes settings #}
250
251- description: Run 'linux' formula on cfg01
252 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@salt:master' state.sls linux;
253 node_name: {{ HOSTNAME_CFG01 }}
254 retry: {count: 3, delay: 5}
255 skip_fail: false
256
257- description: Run 'openssh' formula on cfg01
258 cmd: salt --hard-crash --state-output=mixed --state-verbose=False
Dennis Dmitriev3e731a42017-08-30 17:12:59 +0300259 -C 'I@salt:master' state.sls openssh &&
Dennis Dmitriev492813e2017-08-09 15:08:58 +0300260 salt --hard-crash --state-output=mixed --state-verbose=False
261 -C 'I@salt:master' cmd.run "sed -i 's/PasswordAuthentication no/PasswordAuthentication
Dennis Dmitriev3e731a42017-08-30 17:12:59 +0300262 yes/' /etc/ssh/sshd_config && service ssh reload"
Dennis Dmitriev492813e2017-08-09 15:08:58 +0300263 node_name: {{ HOSTNAME_CFG01 }}
264 retry: {count: 3, delay: 5}
265 skip_fail: false
266
267- description: '*Workaround* of the bug https://mirantis.jira.com/browse/PROD-7962'
268 cmd: salt --hard-crash --state-output=mixed --state-verbose=False
269 '*' cmd.run "echo ' StrictHostKeyChecking no' >> /root/.ssh/config"
270 node_name: {{ HOSTNAME_CFG01 }}
271 retry: {count: 1, delay: 1}
272 skip_fail: false
273
274- description: Run 'salt.master' formula on cfg01
275 cmd: timeout 120 salt --timeout=120 --hard-crash --state-output=mixed --state-verbose=False -C 'I@salt:master' state.sls salt.master;
276 node_name: {{ HOSTNAME_CFG01 }}
277 retry: {count: 2, delay: 5}
278 skip_fail: false
279
Victor Ryzhenkin4e077ad2017-08-10 13:42:11 +0400280{%- if SALT_FORMULAS_REFS != '' %}
281- description: Replace needed formulas to desired version
282 cmd: |
283 set -e;
284 {%- for formula in SALT_FORMULAS_REFS.split(' ') %}
285 {% set formula_name = formula.0 %}
286 {% set formula_ref = formula.1 %}
Dennis Dmitrievbc57b802017-08-16 18:10:57 +0300287 {% set formula_dir = '/tmp/salt-formula-' + formula_name %}
Victor Ryzhenkin4e077ad2017-08-10 13:42:11 +0400288 git clone {{ SALT_FORMULAS_REPO }}/{{ formula_name }} {{ formula_dir }} &&
289 pushd {{ formula_dir }} &&
290 git fetch {{ SALT_FORMULAS_REPO }}/{{ formula_name }} {{ formula_ref }} &&
291 git checkout FETCH_HEAD &&
292 popd &&
293 if [ -d "{{ formula_dir }}" ]; then
294 echo "Going to replace packaged formula {{ formula_name }}" &&
295 rm -rfv /usr/share/salt-formulas/{env,reclass/service}/{{ formula_name }} &&
296 ln -v -s \"{{ formula_dir }}/{{ formula_name }}\" \"/usr/share/salt-formulas/env/{{ formula_name }}\" &&
297 ln -v -s \"{{ formula_dir }}/metadata/service/\" \"/usr/share/salt-formulas/reclass/service/{{ formula_name }}\";
298 else
299 echo "Stopped, directory /root/salt-formula-{{ formula_name }} does not exist!";
300 fi
301 {%- endfor %}
302 node_name: {{ HOSTNAME_CFG01 }}
303 retry: {count: 1, delay: 10}
304 skip_fail: false
305{%- endif %}
Dennis Dmitriev492813e2017-08-09 15:08:58 +0300306
307- description: Refresh pillars on salt-master minion
308 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@salt:master' saltutil.refresh_pillar
309 node_name: {{ HOSTNAME_CFG01 }}
310 retry: {count: 1, delay: 5}
311 skip_fail: false
312
Dennis Dmitriev3e731a42017-08-30 17:12:59 +0300313- description: Show reclass-salt --top for salt-master node
Dennis Dmitriev492813e2017-08-09 15:08:58 +0300314 cmd: reclass-salt --top
315 node_name: {{ HOSTNAME_CFG01 }}
316 retry: {count: 1, delay: 5}
317 skip_fail: false
318
319- description: Sync all salt resources on salt-master minion
Dennis Dmitriev9a6cacc2017-08-14 00:08:41 +0300320 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@salt:master' saltutil.sync_all && sleep 5
Dennis Dmitriev492813e2017-08-09 15:08:58 +0300321 node_name: {{ HOSTNAME_CFG01 }}
322 retry: {count: 1, delay: 5}
323 skip_fail: false
324
325- description: Configure linux on master
326 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@salt:master' state.sls 'linux.system'
327 node_name: {{ HOSTNAME_CFG01 }}
328 retry: {count: 1, delay: 5}
329 skip_fail: false
330
331- description: Configure salt.minion on master
332 cmd: salt --timeout=120 --hard-crash --state-output=mixed --state-verbose=False
333 -C 'I@salt:master' state.sls salt.minion && sleep 10
334 node_name: {{ HOSTNAME_CFG01 }}
335 retry: {count: 3, delay: 10}
336 skip_fail: false
337
338- description: Run state 'salt' on master (for salt.api, etc)
339 cmd: salt --hard-crash --state-output=mixed --state-verbose=False
340 -C 'I@salt:master' state.sls salt
341 node_name: {{ HOSTNAME_CFG01 }}
342 retry: {count: 3, delay: 10}
343 skip_fail: false
344{%- endmacro %}
345
346{%- macro MACRO_GENERATE_INVENTORY() %}
347{#####################################}
348- description: Generate inventory for all the nodes to the /srv/salt/reclass/nodes/_generated
349 cmd: salt --hard-crash --state-output=mixed --state-verbose=False
350 -C 'I@salt:master' state.sls reclass
351 node_name: {{ HOSTNAME_CFG01 }}
352 retry: {count: 1, delay: 5}
353 skip_fail: false
354
355- description: Refresh pillars on all minions
356 cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.refresh_pillar
357 node_name: {{ HOSTNAME_CFG01 }}
358 retry: {count: 1, delay: 5}
359 skip_fail: false
360
Dennis Dmitriev3e731a42017-08-30 17:12:59 +0300361- description: Show reclass-salt --top for all generated nodes
Dennis Dmitriev4386a072017-09-04 13:58:02 +0300362 cmd: |
363 set -e
364 if salt-call sys.doc reclass.validate_node_params | grep -q reclass.validate_node_params ; then salt-call reclass.validate_nodes_params ; fi
365 if salt-call sys.doc reclass.validate_pillar | grep -q reclass.validate_pillar ; then salt-call reclass.validate_pillar ; fi
366 reclass-salt --top
Dennis Dmitriev492813e2017-08-09 15:08:58 +0300367 node_name: {{ HOSTNAME_CFG01 }}
368 retry: {count: 1, delay: 5}
369 skip_fail: false
370
371- description: Sync all salt resources
Dennis Dmitriev9a6cacc2017-08-14 00:08:41 +0300372 cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.sync_all && sleep 5
Dennis Dmitriev492813e2017-08-09 15:08:58 +0300373 node_name: {{ HOSTNAME_CFG01 }}
374 retry: {count: 1, delay: 5}
375 skip_fail: false
376{%- endmacro %}
377
378
379{%- macro MACRO_BOOTSTRAP_ALL_MINIONS() %}
380{########################################}
381# Bootstrap all nodes
382- description: Configure linux on other nodes
383 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@linux:system' state.sls linux
384 node_name: {{ HOSTNAME_CFG01 }}
385 retry: {count: 5, delay: 10}
386 skip_fail: false
387
388- description: Configure openssh on all nodes
Dennis Dmitriev3e731a42017-08-30 17:12:59 +0300389 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@linux:system and not cfg01*' state.sls openssh &&
Dennis Dmitriev492813e2017-08-09 15:08:58 +0300390 salt --hard-crash --state-output=mixed --state-verbose=False
391 -C 'I@linux:system and not cfg01*' cmd.run "sed -i 's/PasswordAuthentication no/PasswordAuthentication
392 yes/' /etc/ssh/sshd_config && service ssh reload"
393 node_name: {{ HOSTNAME_CFG01 }}
394 retry: {count: 1, delay: 5}
395 skip_fail: false
396
397- description: Configure salt.minion on other nodes
398 cmd: salt --timeout=120 --hard-crash --state-output=mixed --state-verbose=False -C 'I@linux:system and not cfg01*' state.sls salt.minion &&
399 sleep 10
400 node_name: {{ HOSTNAME_CFG01 }}
401 retry: {count: 3, delay: 15}
402 skip_fail: false
403
404- description: Check salt minion versions on slaves
405 cmd: salt '*' test.version
406 node_name: {{ HOSTNAME_CFG01 }}
407 retry: {count: 3, delay: 15}
408 skip_fail: false
409
410- description: Check salt top states on nodes
411 cmd: salt '*' state.show_top
412 node_name: {{ HOSTNAME_CFG01 }}
413 retry: {count: 1, delay: 5}
414 skip_fail: false
415
416- description: Configure ntp and rsyslog on nodes
417 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@linux:system' state.sls ntp,rsyslog
418 node_name: {{ HOSTNAME_CFG01 }}
419 retry: {count: 1, delay: 10}
420 skip_fail: false
Sergii Golovatiuk50f91892017-08-04 18:11:06 +0200421{%- endmacro %}
Dennis Dmitriev9dada8a2017-08-30 17:38:55 +0300422
423
424{%- macro MACRO_NETWORKING_WORKAROUNDS() %}
425{#########################################}
426
427- description: '*Workaround 1/2* of the bug PROD-9576 to get bond0-connectivity *without* rebooting nodes'
428 cmd: salt-call --hard-crash --state-output=mixed --state-verbose=False cmd.run
429 "mkdir -p /tmp/PROD-9576; cd /tmp/PROD-9576; git clone https://gerrit.mcp.mirantis.net/salt-formulas/linux; cd linux;
Dennis Dmitrievec2bba62017-09-21 17:01:16 +0300430 git fetch https://gerrit.mcp.mirantis.net/salt-formulas/linux refs/changes/54/2354/16 && git checkout FETCH_HEAD;
Dennis Dmitriev9dada8a2017-08-30 17:38:55 +0300431 cp -f linux/network/interface.sls /srv/salt/env/prd/linux/network/;
432 cp -f linux/map.jinja /srv/salt/env/prd/linux/;"
433 node_name: {{ HOSTNAME_CFG01 }}
434 retry: {count: 1, delay: 5}
435 skip_fail: false
436
437- description: '*Workaround: Load bonding module before call state.linux'
438 cmd: salt -C "I@linux:network:interface:*:type:bond" cmd.run 'modprobe bonding'
439 node_name: {{ HOSTNAME_CFG01 }}
440 retry: {count: 1, delay: 5}
Dennis Dmitriev0496eb72017-09-05 21:42:10 +0300441 skip_fail: true
Dennis Dmitriev9dada8a2017-08-30 17:38:55 +0300442
443- description: '*Workaround* install bridge-utils before running linux formula'
444 # The formula removes default route and then tries to install the package, fails.
445 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C '* and not
446 cfg01*' cmd.run 'sudo apt-get install -y bridge-utils'
447 node_name: {{ HOSTNAME_CFG01 }}
448 retry: {count: 1, delay: 5}
449 skip_fail: false
450
451{%- endmacro %}