Move common parts of salt deployment into shared-salt.yaml
- most of common steps for bootstrapping salt moved to
shared-salt.yaml
- default value REPOSITORY_SUITE changed to 'testing'
Change-Id: I7bd66b8e84d266ddd424b788d2a1b5ff0c6ecad4
Reviewed-on: https://review.gerrithub.io/373554
Reviewed-by: Dennis Dmitriev <dis.xcom@gmail.com>
Tested-by: Dennis Dmitriev <dis.xcom@gmail.com>
diff --git a/tcp_tests/templates/virtual-mcp10-dvr/salt.yaml b/tcp_tests/templates/virtual-mcp10-dvr/salt.yaml
index 5c71b12..72d3dc8 100644
--- a/tcp_tests/templates/virtual-mcp10-dvr/salt.yaml
+++ b/tcp_tests/templates/virtual-mcp10-dvr/salt.yaml
@@ -26,90 +26,17 @@
retry: {count: 1, delay: 1}
skip_fail: false
-- description: Installing salt master on cfg01
- cmd: apt-get install -y reclass git; apt-get install -y salt-master
- node_name: {{ HOSTNAME_CFG01 }}
- retry: {count: 1, delay: 1}
- skip_fail: false
-
- description: Install common packages on cfg01
cmd: apt-get install -y python-pip wget curl tmux byobu iputils-ping traceroute htop tree
node_name: {{ HOSTNAME_CFG01 }}
retry: {count: 1, delay: 1}
skip_fail: false
-- description: Configure salt-master on cfg01
- cmd: |
- cat << 'EOF' >> /etc/salt/master.d/master.conf
- file_roots:
- base:
- - /usr/share/salt-formulas/env
- pillar_opts: False
- open_mode: True
- reclass: &reclass
- storage_type: yaml_fs
- inventory_base_uri: /srv/salt/reclass
- ext_pillar:
- - reclass: *reclass
- master_tops:
- reclass: *reclass
- EOF
- node_name: {{ HOSTNAME_CFG01 }}
- retry: {count: 1, delay: 1}
- skip_fail: false
+{{ SHARED.MACRO_INSTALL_SALT_MASTER() }}
-- description: Configure GIT settings and certificates
- cmd: touch /root/.git_trusted_certs.pem;
- for server in git.tcpcloud.eu github.com; do
- openssl s_client -showcerts -connect $server:443 </dev/null
- | openssl x509 -outform PEM
- >> /root/.git_trusted_certs.pem;
- done;
- HOME=/root git config --global http.sslCAInfo /root/.git_trusted_certs.pem;
- HOME=/root git config --global user.email "tcp-qa@example.com";
- HOME=/root git config --global user.name "TCP QA";
- node_name: {{ HOSTNAME_CFG01 }}
- retry: {count: 1, delay: 1}
- skip_fail: false
+{{ SHARED.MACRO_CLONE_RECLASS_MODELS() }}
-
-- description: Clone reclass models with submodules
- cmd: |
-{{ SHARED.MACRO_CLONE_RECLASS_MODELS() }}
- node_name: {{ HOSTNAME_CFG01 }}
- retry: {count: 1, delay: 1}
- skip_fail: false
-
-- description: Configure reclass
- cmd: |
- FORMULA_PATH=${FORMULA_PATH:-/usr/share/salt-formulas};
- FORMULA_REPOSITORY=${FORMULA_REPOSITORY:-deb [arch=amd64] http://apt.mirantis.com/xenial stable salt};
- FORMULA_GPG=${FORMULA_GPG:-http://apt.mirantis.com/public.gpg};
- which wget > /dev/null || (apt-get update; apt-get install -y wget);
- echo "${FORMULA_REPOSITORY}" > /etc/apt/sources.list.d/mcp_salt.list;
- wget -O - "${FORMULA_GPG}" | apt-key add -;
- apt-get clean; apt-get update;
- [ ! -d /srv/salt/reclass/classes/service ] && mkdir -p /srv/salt/reclass/classes/service;
- declare -a formula_services=("linux" "reclass" "salt" "openssh" "ntp" "git" "nginx" "collectd" "sensu" "heka" "sphinx" "keystone" "mysql" "grafana" "haproxy" "rsyslog" "horizon");
- echo -e "\nInstalling all required salt formulas\n";
- apt-get install -y "${formula_services[@]/#/salt-formula-}";
- for formula_service in "${formula_services[@]}"; do
- echo -e "\nLink service metadata for formula ${formula_service} ...\n";
- [ ! -L "/srv/salt/reclass/classes/service/${formula_service}" ] && ln -s ${FORMULA_PATH}/reclass/service/${formula_service} /srv/salt/reclass/classes/service/${formula_service};
- done;
- [ ! -d /srv/salt/env ] && mkdir -p /srv/salt/env;
- [ ! -L /srv/salt/env/prd ] && ln -s ${FORMULA_PATH}/env /srv/salt/env/prd;
- [ ! -d /etc/reclass ] && mkdir /etc/reclass;
-
- cat << 'EOF' >> /etc/reclass/reclass-config.yml
- storage_type: yaml_fs
- pretty_print: True
- output: yaml
- inventory_base_uri: /srv/salt/reclass
- EOF
- node_name: {{ HOSTNAME_CFG01 }}
- retry: {count: 1, delay: 1}
- skip_fail: false
+{{ SHARED.MACRO_CONFIGURE_RECLASS(FORMULA_SERVICES='"linux" "reclass" "salt" "openssh" "ntp" "git" "nginx" "collectd" "sensu" "heka" "sphinx" "keystone" "mysql" "grafana" "haproxy" "rsyslog" "horizon"') }}
- description: Configure salt-minion on cfg01
cmd: |
@@ -123,13 +50,6 @@
retry: {count: 1, delay: 1}
skip_fail: false
-- description: Configure salt adoptors on cfg01
- cmd: |
- ln -s /usr/lib/python2.7/dist-packages/reclass/adapters/salt.py /usr/local/sbin/reclass-salt;
- chmod +x /usr/lib/python2.7/dist-packages/reclass/adapters/salt.py
- node_name: {{ HOSTNAME_CFG01 }}
- retry: {count: 1, delay: 1}
- skip_fail: false
- description: Restart services
cmd: |
@@ -142,162 +62,12 @@
retry: {count: 1, delay: 5}
skip_fail: false
-# Prepare salt services and nodes settings
-- description: Run 'linux' formula on cfg01
- cmd: salt --hard-crash --state-output=mixed --state-verbose=False
- -C 'I@salt:master' state.sls linux;
- node_name: {{ HOSTNAME_CFG01 }}
- retry: {count: 1, delay: 5}
- skip_fail: false
-- description: Run 'openssh' formula on cfg01
- cmd: salt --hard-crash --state-output=mixed --state-verbose=False
- -C 'I@salt:master' state.sls openssh;
- salt --hard-crash --state-output=mixed --state-verbose=False
- -C 'I@salt:master' cmd.run "sed -i 's/PasswordAuthentication no/PasswordAuthentication
- yes/' /etc/ssh/sshd_config && service ssh restart";
- node_name: {{ HOSTNAME_CFG01 }}
- retry: {count: 3, delay: 5}
- skip_fail: false
+{{ SHARED.MACRO_RUN_SALT_MASTER_UNDERLAY_STATES() }}
-- description: '*Workaround* of the bug https://mirantis.jira.com/browse/PROD-7962'
- cmd: salt --hard-crash --state-output=mixed --state-verbose=False
- '*' cmd.run "echo ' StrictHostKeyChecking no' >> /root/.ssh/config"
- node_name: {{ HOSTNAME_CFG01 }}
- retry: {count: 1, delay: 1}
- skip_fail: false
+{{ SHARED.MACRO_GENERATE_INVENTORY() }}
-- description: Run 'reclass' formula on cfg01
- cmd: timeout 120 salt --hard-crash --state-output=mixed --state-verbose=False
- -C 'I@salt:master' reclass;
- salt-call --no-color state.sls salt.master;
- node_name: {{ HOSTNAME_CFG01 }}
- retry: {count: 1, delay: 5}
- skip_fail: true
-
-
-- description: Run 'salt' formula on cfg01
- cmd: timeout 120 salt --hard-crash --state-output=mixed --state-verbose=False
- -C 'I@salt:master' state.sls salt.master.service;
- salt-call --no-color state.sls salt.master,salt.api,salt.minion.ca;
- systemctl restart salt-minion;
- node_name: {{ HOSTNAME_CFG01 }}
- retry: {count: 1, delay: 5}
- skip_fail: true
-
-- description: Accept salt keys from all the nodes
- cmd: salt-key -A -y
- node_name: {{ HOSTNAME_CFG01 }}
- retry: {count: 1, delay: 5}
- skip_fail: false
-
-- description: Generate inventory for all the nodes to the /srv/salt/reclass/nodes/_generated
- cmd: salt --hard-crash --state-output=mixed --state-verbose=False
- -C 'I@salt:master' state.sls reclass
- node_name: {{ HOSTNAME_CFG01 }}
- retry: {count: 1, delay: 5}
- skip_fail: false
-
-- description: Refresh pillars on all minions
- cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.refresh_pillar
- node_name: {{ HOSTNAME_CFG01 }}
- retry: {count: 1, delay: 5}
- skip_fail: false
-
-- description: Sync all salt resources
- cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.sync_all
- node_name: {{ HOSTNAME_CFG01 }}
- retry: {count: 1, delay: 5}
- skip_fail: false
-
-- description: Show reclass-salt --top
- cmd: reclass-salt --top; salt-call --no-color state.sls salt.minion.cert -l info;
- node_name: {{ HOSTNAME_CFG01 }}
- retry: {count: 1, delay: 5}
- skip_fail: false
-
-
-# Bootstrap all nodes
-
-- description: Configure linux on controllers
- cmd: salt --hard-crash --state-output=mixed --state-verbose=False 'ctl*' state.sls
- linux
- node_name: {{ HOSTNAME_CFG01 }}
- retry: {count: 1, delay: 5}
- skip_fail: false
-
-- description: Configure linux on proxy
- cmd: salt --hard-crash --state-output=mixed --state-verbose=False 'prx*' state.sls
- linux
- node_name: {{ HOSTNAME_CFG01 }}
- retry: {count: 1, delay: 5}
- skip_fail: false
-
-- description: Configure linux on gtw
- cmd: salt --hard-crash --state-output=mixed --state-verbose=False 'gtw*' state.sls
- linux
- node_name: {{ HOSTNAME_CFG01 }}
- retry: {count: 3, delay: 20}
- skip_fail: false
-
-- description: Configure linux on cmp
- cmd: salt --hard-crash --state-output=mixed --state-verbose=False 'cmp*' state.sls
- linux
- node_name: {{ HOSTNAME_CFG01 }}
- retry: {count: 3, delay: 20}
- skip_fail: false
-
-- description: Configure openssh on all nodes
- cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C '* and not
- cfg*' state.sls openssh;salt --hard-crash --state-output=mixed --state-verbose=False
- -C '* and not cfg*' cmd.run "sed -i 's/PasswordAuthentication no/PasswordAuthentication
- yes/' /etc/ssh/sshd_config && service ssh restart"
- node_name: {{ HOSTNAME_CFG01 }}
- retry: {count: 1, delay: 5}
- skip_fail: false
-
-- description: Configure salt.minion on ctl
- cmd: salt --hard-crash --state-output=mixed --state-verbose=False 'ctl*' state.sls salt.minion
- node_name: {{ HOSTNAME_CFG01 }}
- retry: {count: 3, delay: 5}
- skip_fail: false
-
-- description: Configure salt.minion on prx
- cmd: salt --hard-crash --state-output=mixed --state-verbose=False 'prx*' state.sls salt.minion
- node_name: {{ HOSTNAME_CFG01 }}
- retry: {count: 3, delay: 5}
- skip_fail: false
-
-
-- description: Configure salt.minion on gtw
- cmd: salt --hard-crash --state-output=mixed --state-verbose=False 'gtw*' state.sls salt.minion
- node_name: {{ HOSTNAME_CFG01 }}
- retry: {count: 3, delay: 5}
- skip_fail: false
-
-- description: Configure salt.minion on cmp
- cmd: salt --hard-crash --state-output=mixed --state-verbose=False 'cmp*' state.sls salt.minion
- node_name: {{ HOSTNAME_CFG01 }}
- retry: {count: 3, delay: 5}
- skip_fail: false
-
-- description: Check salt minion versions on slaves
- cmd: salt '*' test.version
- node_name: {{ HOSTNAME_CFG01 }}
- retry: {count: 1, delay: 5}
- skip_fail: false
-
-- description: Check salt top states on nodes
- cmd: salt '*' state.show_top
- node_name: {{ HOSTNAME_CFG01 }}
- retry: {count: 1, delay: 5}
- skip_fail: false
-
-- description: Configure ntp and rsyslog on nodes
- cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' state.sls ntp,rsyslog
- node_name: {{ HOSTNAME_CFG01 }}
- retry: {count: 1, delay: 10}
- skip_fail: false
+{{ SHARED.MACRO_BOOTSTRAP_ALL_MINIONS() }}
- description: Hack gtw node
cmd: salt 'gtw*' cmd.run "ip addr del 172.16.10.110/24 dev ens4; ip addr flush dev ens4";