Remove packages installation from user-data

- New images for VCP don't contain iptables, so it requires
  to more complicated bootstrap process than waiting for 22 port.
  So, let's move all time-consumption commands to salt-shared.yaml

- Salt repositories used for bootstrap was from upstream, while
  should be from apt.mirantis.com

- Enable hugepages only on compute nodes for
  virtual-pike-ovs-dpdk config.

Change-Id: I4ca02c873f9594ee98d2c5f5fe8ffd7fb317ae91
diff --git a/tcp_tests/templates/shared-salt.yaml b/tcp_tests/templates/shared-salt.yaml
index 22acb9a..ccefbe1 100644
--- a/tcp_tests/templates/shared-salt.yaml
+++ b/tcp_tests/templates/shared-salt.yaml
@@ -13,13 +13,13 @@
 {% set ENVIRONMENT_TEMPLATE_REF_CHANGE = os_env('ENVIRONMENT_TEMPLATE_REF_CHANGE','') %}
 
 {% set REPOSITORY_SUITE = os_env('REPOSITORY_SUITE', 'testing') %}
-{% set FORMULA_REPOSITORY = os_env('FORMULA_REPOSITORY', 'deb [arch=amd64] http://apt.mirantis.com/xenial ' + REPOSITORY_SUITE + ' salt') %}
+{% set FORMULA_REPOSITORY = os_env('FORMULA_REPOSITORY', 'deb [arch=amd64] http://apt.mirantis.com/${DISTRIB_CODENAME} ' + REPOSITORY_SUITE + ' salt extra') %}
 {% set FORMULA_GPG = os_env('FORMULA_GPG', 'http://apt.mirantis.com/public.gpg') %}
-{% set SALT_REPOSITORY = os_env('SALT_REPOSITORY', "deb http://repo.saltstack.local.test/apt/ubuntu/16.04/amd64/2016.3 xenial main") %}
-{% set SALT_GPG = os_env('SALT_GPG', 'http://repo.saltstack.local.test/apt/ubuntu/16.04/amd64/2016.3/SALTSTACK-GPG-KEY.pub') %}
-{% set UBUNTU_REPOSITORY = os_env('UBUNTU_REPOSITORY', "deb http://archive.ubuntu.com/ubuntu/ xenial main universe restricted") %}
-{% set UBUNTU_UPDATES_REPOSITORY = os_env('UBUNTU_UPDATES_REPOSITORY', "deb http://archive.ubuntu.com/ubuntu/ xenial-updates main universe restricted") %}
-{% set UBUNTU_SECURITY_REPOSITORY = os_env('UBUNTU_SECURITY_REPOSITORY', "deb http://archive.ubuntu.com/ubuntu/ xenial-security main universe restricted") %}
+{% set SALT_REPOSITORY = os_env('SALT_REPOSITORY', "deb [arch=amd64] http://apt.mirantis.com/${DISTRIB_CODENAME}/salt/2016.3 " + REPOSITORY_SUITE + " main") %}
+{% set SALT_GPG = os_env('SALT_GPG', 'http://apt.mirantis.com/public.gpg') %}
+{% set UBUNTU_REPOSITORY = os_env('UBUNTU_REPOSITORY', "deb [arch=amd64] http://mirror.mirantis.com/" + REPOSITORY_SUITE + "/ubuntu/ ${DISTRIB_CODENAME} main restricted universe") %}
+{% set UBUNTU_UPDATES_REPOSITORY = os_env('UBUNTU_UPDATES_REPOSITORY', "deb [arch=amd64] http://mirror.mirantis.com/" + REPOSITORY_SUITE + "/ubuntu/ ${DISTRIB_CODENAME}-updates main restricted universe") %}
+{% set UBUNTU_SECURITY_REPOSITORY = os_env('UBUNTU_SECURITY_REPOSITORY', "deb [arch=amd64] http://mirror.mirantis.com/" + REPOSITORY_SUITE + "/ubuntu/ ${DISTRIB_CODENAME}-security main restricted universe") %}
 
 {# Address pools for reclass cluster model are taken in the following order:
  # 1. environment variables,
@@ -54,6 +54,7 @@
   cmd: |
     rm -rf trusted* ;
     rm -rf /etc/apt/sources.list ;
+    . /etc/lsb-release;  # Get DISTRIB_CODENAME variable
     echo "{{ FORMULA_REPOSITORY }}" > /etc/apt/sources.list.d/mcp_salt.list;
     wget -O - "{{ FORMULA_GPG }}" | apt-key add -;
     echo "{{ SALT_REPOSITORY }}" > /etc/apt/sources.list.d/mcp_saltstack.list;
@@ -72,7 +73,26 @@
 {%- macro MACRO_INSTALL_SALT_MASTER() %}
 {######################################}
 - description: Installing salt master on cfg01
-  cmd:  eatmydata apt-get install -y --allow-unauthenticated reclass git salt-master
+  cmd: |
+    which wget >/dev/null || (apt-get update; apt-get install -y wget);
+    # Configure ubuntu and salt repositories
+    . /etc/lsb-release;  # Get DISTRIB_CODENAME variable
+    echo "{{ UBUNTU_REPOSITORY }}" > /etc/apt/sources.list
+    echo "{{ UBUNTU_UPDATES_REPOSITORY }}" >> /etc/apt/sources.list
+    echo "{{ UBUNTU_SECURITY_REPOSITORY }}" >> /etc/apt/sources.list
+
+    echo "{{ FORMULA_REPOSITORY }}" > /etc/apt/sources.list.d/mcp_salt.list;
+    wget -O - {{ FORMULA_GPG }} | apt-key add -;
+    echo "{{ SALT_REPOSITORY }}" > /etc/apt/sources.list.d/mcp_saltstack.list;
+    wget -O - {{ SALT_GPG }} | apt-key add -;
+
+    apt-get clean
+    apt-get update
+
+    # Install salt-master and reclass
+    eatmydata apt-get install -y --allow-unauthenticated reclass salt-master
+    # Install common packages
+    eatmydata apt-get install -y python-pip git curl tmux byobu iputils-ping traceroute htop tree mc
   node_name: {{ HOSTNAME_CFG01 }}
   retry: {count: 1, delay: 1}
   skip_fail: false
@@ -417,6 +437,7 @@
     set -e;
     FORMULA_PATH=${FORMULA_PATH:-/usr/share/salt-formulas};
     which wget > /dev/null || (apt-get update; apt-get install -y wget);
+    . /etc/lsb-release;  # Get DISTRIB_CODENAME variable
     echo "{{ FORMULA_REPOSITORY }}" > /etc/apt/sources.list.d/mcp_salt.list;
     wget -O - "{{ FORMULA_GPG }}" | apt-key add -;
     apt-get clean; apt-get update;
@@ -482,8 +503,28 @@
     id: {{ ssh['node_name'] }}
     master: {{ config.salt.salt_master_host }}
     EOF
+
+    # Configure ubuntu and salt repositories
+    which wget >/dev/null || (apt-get update; apt-get install -y wget);
+
+    . /etc/lsb-release;  # Get DISTRIB_CODENAME variable
+    echo "{{ UBUNTU_REPOSITORY }}" > /etc/apt/sources.list
+    echo "{{ UBUNTU_UPDATES_REPOSITORY }}" >> /etc/apt/sources.list
+    echo "{{ UBUNTU_SECURITY_REPOSITORY }}" >> /etc/apt/sources.list
+
+    echo "{{ SALT_REPOSITORY }}" > /etc/apt/sources.list.d/mcp_saltstack.list;
+    wget -O - {{ SALT_GPG }} | apt-key add -;
+
+    apt-get clean
+    apt-get update
+
+    # Install salt-minion
     eatmydata apt-get install -y salt-minion;
-    service salt-minion restart;  # For case if salt-minion was already installed
+    # Install common packages
+    eatmydata apt-get install -y python-pip git curl tmux byobu iputils-ping traceroute htop tree mc
+
+    # Restart salt-minion if it was already installed
+    service salt-minion restart
   node_name: {{ ssh['node_name'] }}
   retry: {count: 1, delay: 1}
   skip_fail: false