Merge branch 'add_1_0' of https://github.com/Mirantis/tcp-qa into add_1_0
diff --git a/tcp_tests/templates/salt/virtual_mcp10_ovs-salt.yaml b/tcp_tests/templates/salt/virtual_mcp10_ovs-salt.yaml
index d4264f0..de72542 100644
--- a/tcp_tests/templates/salt/virtual_mcp10_ovs-salt.yaml
+++ b/tcp_tests/templates/salt/virtual_mcp10_ovs-salt.yaml
@@ -4,36 +4,30 @@
- description: Configure tcpcloud repository on the cfg01 node
- cmd: echo 'deb [arch=amd64] http://apt.tcpcloud.eu/nightly/ xenial main security extra tcp tcp-salt' > /etc/apt/sources.list;
- echo 'deb [arch=amd64] http://apt.tcpcloud.eu/nightly/ trusty tcp-salt' >> /etc/apt/sources.list;
- wget -O - http://apt.tcpcloud.eu/public.gpg | apt-key add -;
+ cmd: echo "deb [arch=amd64] http://apt-mk.mirantis.com/xenial nightly salt extra" > /etc/apt/sources.list.d/mcp_salt.list;
+ wget -O - http://apt-mk.mirantis.com/public.gpg | apt-key add -;
echo "deb http://repo.saltstack.com/apt/ubuntu/16.04/amd64/2016.3 xenial main" > /etc/apt/sources.list.d/saltstack.list;
wget -O - https://repo.saltstack.com/apt/ubuntu/16.04/amd64/2016.3/SALTSTACK-GPG-KEY.pub | apt-key add -;
- #echo "deb http://repo.saltstack.com/apt/ubuntu/16.04/amd64/latest xenial main" > /etc/apt/sources.list.d/saltstack.list;
- #wget -O - https://repo.saltstack.com/apt/ubuntu/16.04/amd64/latest/SALTSTACK-GPG-KEY.pub | apt-key add -;
node_name: {{ HOSTNAME_CFG01 }}
retry: {count: 1, delay: 1}
skip_fail: false
-#- description: Configure tcpcloud and saltstack repositories on the rest of nodes
-# cmd: echo 'deb [arch=amd64] http://apt.tcpcloud.eu/nightly/ trusty main security extra tcp tcp-salt' > /etc/apt/sources.list;
-# wget -O - http://apt.tcpcloud.eu/public.gpg | apt-key add - ;
-# echo 'deb http://repo.saltstack.com/apt/ubuntu/14.04/amd64/latest trusty main' > /etc/apt/sources.list.d/saltstack.list;
-# wget -O - https://repo.saltstack.com/apt/ubuntu/14.04/amd64/latest/SALTSTACK-GPG-KEY.pub | apt-key add -
-# node_name: ***
-# retry: {count: 1, delay: 1}
-# skip_fail: false
-
- description: Update packages on cfg01
- cmd: apt-get clean; apt-get update && apt-get -y upgrade
+ cmd: apt-get clean; apt-get update
node_name: {{ HOSTNAME_CFG01 }}
- retry: {count: 3, delay: 10}
+ 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: 3, delay: 10}
+ 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: Install salt formulas, master and minion on cfg01
@@ -42,6 +36,7 @@
salt-master
salt-minion
reclass
+ git
salt-formula-linux
salt-formula-reclass
salt-formula-salt
@@ -58,7 +53,7 @@
salt-formula-grafana
salt-formula-haproxy
node_name: {{ HOSTNAME_CFG01 }}
- retry: {count: 3, delay: 10}
+ retry: {count: 1, delay: 1}
skip_fail: false
- description: Configure salt-master on cfg01
@@ -81,22 +76,9 @@
retry: {count: 1, delay: 1}
skip_fail: false
-- 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
-
-- description: Clone reclass models and perform a workaround for https://mirantis.jira.com/browse/PROD-8078
+- description: Clone reclass models with submodules
cmd: |
+ ssh-keyscan -H github.com >> ~/.ssh/known_hosts;
git clone --recurse-submodules https://gerrit.mcp.mirantis.net/salt-models/mcp-virtual-lab /srv/salt/reclass;
cd /srv/salt/reclass;
git checkout master;
@@ -106,10 +88,23 @@
- description: Configure reclass
cmd: |
- mkdir -p /srv/salt/reclass/classes/service;
- for i in /usr/share/salt-formulas/reclass/service/*; do
- ln -s $i /srv/salt/reclass/classes/service/;
+ FORMULA_PATH=${FORMULA_PATH:-/usr/share/salt-formulas};
+ FORMULA_REPOSITORY=${FORMULA_REPOSITORY:-deb [arch=amd64] http://apt.tcpcloud.eu/nightly xenial tcp-salt};
+ FORMULA_GPG=${FORMULA_GPG:-http://apt.tcpcloud.eu/public.gpg};
+ which wget > /dev/null || (apt-get update; apt-get install -y wget);
+ echo "${FORMULA_REPOSITORY}" > /etc/apt/sources.list.d/tcpcloud_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 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
@@ -128,22 +123,33 @@
id: {{ HOSTNAME_CFG01 }}
master: localhost
EOF
+ apt-get install -y salt-minion;
node_name: {{ HOSTNAME_CFG01 }}
retry: {count: 1, delay: 1}
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
+- description: Restart services
+ cmd: |
+ systemctl restart salt-master;
+ systemctl restart salt-minion;
+ echo "Showing system info and metadata ...";
+ salt-call --no-color grains.items;
+ salt-call --no-color pillar.data;
node_name: {{ HOSTNAME_CFG01 }}
retry: {count: 3, delay: 5}
skip_fail: false
-- description: Run 'openssh' formula on cfg01
+# Prepare salt services and nodes settings
+- description: Run 'linux' and openssh formula on cfg01
cmd: salt --hard-crash --state-output=mixed --state-verbose=False
- -C 'I@salt:master' state.sls openssh;
+ -C 'I@salt:master' state.sls linux,openssh;
+ node_name: {{ HOSTNAME_CFG01 }}
+ retry: {count: 3, delay: 5}
+ skip_fail: false
+
+- description: Run 'reclass' formula on cfg01
+ cmd: salt --hard-crash --state-output=mixed --state-verbose=False
+ -C 'I@salt:master' state.sls reclass;
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";
@@ -151,16 +157,10 @@
retry: {count: 3, delay: 5}
skip_fail: false
-- 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
-
- 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
+ -C 'I@salt:master' state.sls salt.master.service;
+ salt-call --no-color state.sls salt.master,salt.api,salt.minion.ca -l info;
node_name: {{ HOSTNAME_CFG01 }}
retry: {count: 3, delay: 5}
skip_fail: true
@@ -190,6 +190,12 @@
retry: {count: 3, delay: 5}
skip_fail: false
+- description: Show reclass-salt --top
+ cmd: salt-call --no-color state.sls salt.minion.cert -l info
+ node_name: {{ HOSTNAME_CFG01 }}
+ retry: {count: 3, delay: 5}
+ skip_fail: false
+
# Bootstrap all nodes