Dennis Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame] | 1 | {# Collection of common macroses shared across different deployments #} |
| 2 | |
Sergii Golovatiuk | 50f9189 | 2017-08-04 18:11:06 +0200 | [diff] [blame] | 3 | {% set SALT_MODELS_BRANCH = os_env('SALT_MODELS_BRANCH','master') %} |
Tatyana Leontovich | 8ac26d7 | 2019-05-15 23:33:38 +0300 | [diff] [blame] | 4 | {% set JENKINS_PIPELINE_BRANCH = os_env('JENKINS_PIPELINE_BRANCH','') %} |
Sergii Golovatiuk | 50f9189 | 2017-08-04 18:11:06 +0200 | [diff] [blame] | 5 | {% set SALT_MODELS_COMMIT = os_env('SALT_MODELS_COMMIT','master') %} |
| 6 | {# 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 #} |
| 7 | {% set SALT_MODELS_REF_CHANGE = os_env('SALT_MODELS_REF_CHANGE', '') %} |
| 8 | {# Pin to a specified commit in salt-models/reclass-system #} |
Dennis Dmitriev | 3d0ed0a | 2018-11-23 11:02:52 +0000 | [diff] [blame] | 9 | {% set SALT_MODELS_SYSTEM_REPOSITORY = os_env('SALT_MODELS_SYSTEM_REPOSITORY','https://gerrit.mcp.mirantis.com/salt-models/reclass-system') %} |
| 10 | {% set SALT_MODELS_SYSTEM_COMMIT = os_env('SALT_MODELS_SYSTEM_COMMIT','') %} |
| 11 | {% set SALT_MODELS_SYSTEM_REF_CHANGE = os_env('SALT_MODELS_SYSTEM_REF_CHANGE','') %} |
| 12 | {% set SALT_MODELS_SYSTEM_TAG = os_env('SALT_MODELS_SYSTEM_TAG','') %} |
Dennis Dmitriev | 0697944 | 2018-10-24 18:53:49 +0300 | [diff] [blame] | 13 | {% set COOKIECUTTER_TEMPLATES_REPOSITORY_USER = os_env('COOKIECUTTER_TEMPLATES_REPOSITORY_USER','mcp-gerrit') %} |
| 14 | {% set COOKIECUTTER_TEMPLATES_REPOSITORY_KEY_PATH = os_env('COOKIECUTTER_TEMPLATES_REPOSITORY_KEY_PATH','') %} |
| 15 | {% set COOKIECUTTER_TEMPLATES_REPOSITORY = os_env('COOKIECUTTER_TEMPLATES_REPOSITORY','ssh://' + COOKIECUTTER_TEMPLATES_REPOSITORY_USER +'@gerrit.mcp.mirantis.com:29418/mk/cookiecutter-templates') %} |
sgudz | 4d816eb | 2017-11-13 11:58:05 +0200 | [diff] [blame] | 16 | {% set COOKIECUTTER_REF_CHANGE = os_env('COOKIECUTTER_REF_CHANGE','') %} |
Tatyana Leontovich | 819a6c8 | 2018-06-04 12:05:16 +0300 | [diff] [blame] | 17 | {% set COOKIECUTTER_TAG = os_env('COOKIECUTTER_TAG','') %} |
sgudz | a399dc7 | 2018-01-18 17:13:48 +0200 | [diff] [blame] | 18 | {% set COOKIECUTTER_TEMPLATE_COMMIT = os_env('COOKIECUTTER_TEMPLATE_COMMIT','') %} |
Vladimir Khlyunev | f337c90 | 2018-12-06 12:29:24 +0400 | [diff] [blame] | 19 | {% set ENVIRONMENT_TEMPLATE_COMMIT = os_env('ENVIRONMENT_TEMPLATE_COMMIT','') %} |
sgudz | cced67d | 2017-10-11 15:56:09 +0300 | [diff] [blame] | 20 | {% set ENVIRONMENT_TEMPLATE_REF_CHANGE = os_env('ENVIRONMENT_TEMPLATE_REF_CHANGE','') %} |
Tatyana Leontovich | 4453dd6 | 2018-06-26 18:44:31 +0300 | [diff] [blame] | 21 | # Currently we support 2 salt version that can be set over bellow var |
Tatyana Leontovich | 14e201d | 2018-07-05 13:28:54 +0300 | [diff] [blame] | 22 | {% set SALT_VERSION = os_env('SALT_VERSION','2017.7') %} |
Dennis Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame] | 23 | {% set REPOSITORY_SUITE = os_env('REPOSITORY_SUITE', 'testing') %} |
Tatyana Leontovich | 3fb5341 | 2019-05-24 00:46:12 +0300 | [diff] [blame] | 24 | {% set UPDATE_REPO_CUSTOM_TAG = os_env('UPDATE_REPO_CUSTOM_TAG', '') %} |
| 25 | {% set UPDATE_VERSION = os_env('UPDATE_VERSION', 'proposed') %} |
Dennis Dmitriev | d9168b5 | 2018-12-19 18:53:52 +0200 | [diff] [blame] | 26 | {# set FORMULA_REPOSITORY = os_env('FORMULA_REPOSITORY', 'deb [arch=amd64] http://apt.mirantis.com/${DISTRIB_CODENAME} ' + REPOSITORY_SUITE + ' salt extra') #} |
obutenko | b600635 | 2018-12-20 10:46:44 +0200 | [diff] [blame] | 27 | {% set FORMULA_REPOSITORY = os_env('FORMULA_REPOSITORY', "deb [arch=amd64] http://mirror.mirantis.com/" + REPOSITORY_SUITE + "/salt-formulas"+"/${DISTRIB_CODENAME} ${DISTRIB_CODENAME} main") %} |
Tatyana Leontovich | 3fb5341 | 2019-05-24 00:46:12 +0300 | [diff] [blame] | 28 | {% set UPDATE_FORMULA_REPOSITORY = os_env('UPDATE_FORMULA_REPOSITORY', "deb [arch=amd64] http://mirror.mirantis.com/update/" + UPDATE_VERSION + "/salt-formulas"+"/${DISTRIB_CODENAME} ${DISTRIB_CODENAME} main") %} |
Dennis Dmitriev | d9168b5 | 2018-12-19 18:53:52 +0200 | [diff] [blame] | 29 | {# set FORMULA_GPG = os_env('FORMULA_GPG', 'http://apt.mirantis.com/public.gpg') #} |
obutenko | b600635 | 2018-12-20 10:46:44 +0200 | [diff] [blame] | 30 | {% set FORMULA_GPG = os_env('FORMULA_GPG', "http://mirror.mirantis.com/" + REPOSITORY_SUITE + "/salt-formulas/xenial/archive-salt-formulas.key") %} |
Dennis Dmitriev | d9168b5 | 2018-12-19 18:53:52 +0200 | [diff] [blame] | 31 | {# set SALT_REPOSITORY = os_env('SALT_REPOSITORY', "deb [arch=amd64] http://apt.mirantis.com/${DISTRIB_CODENAME}/salt/2016.3 " + REPOSITORY_SUITE + " main") #} |
Tatyana Leontovich | 4453dd6 | 2018-06-26 18:44:31 +0300 | [diff] [blame] | 32 | # Note repo is changed so new one looks like defined bellow |
| 33 | {% set SALT_REPOSITORY = os_env('SALT_REPOSITORY', "deb [arch=amd64] http://mirror.mirantis.com/" + REPOSITORY_SUITE+ "/saltstack-" + SALT_VERSION+ "/${DISTRIB_CODENAME} ${DISTRIB_CODENAME} main") %} |
Dennis Dmitriev | d9168b5 | 2018-12-19 18:53:52 +0200 | [diff] [blame] | 34 | {# set SALT_GPG = os_env('SALT_GPG', 'http://apt.mirantis.com/public.gpg') #} |
obutenko | b600635 | 2018-12-20 10:46:44 +0200 | [diff] [blame] | 35 | {% set SALT_GPG = os_env('SALT_GPG', "http://mirror.mirantis.com/" + REPOSITORY_SUITE + "/salt-formulas/xenial/archive-salt-formulas.key") %} |
Dennis Dmitriev | cf77780 | 2018-02-14 18:09:55 +0200 | [diff] [blame] | 36 | {% set UBUNTU_REPOSITORY = os_env('UBUNTU_REPOSITORY', "deb [arch=amd64] http://mirror.mirantis.com/" + REPOSITORY_SUITE + "/ubuntu/ ${DISTRIB_CODENAME} main restricted universe") %} |
| 37 | {% 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") %} |
| 38 | {% 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") %} |
Dennis Dmitriev | 9a532a5 | 2018-05-07 13:55:27 +0300 | [diff] [blame] | 39 | {% set UBUNTU_KEY_SERVER = os_env('UBUNTU_KEY_SERVER', 'keyserver.ubuntu.com') %} |
Tatyana Leontovich | 908ab93 | 2018-04-27 01:25:09 +0300 | [diff] [blame] | 40 | {% set UBUNTU_KEY_ID = os_env('UBUNTU_KEY_ID', '0E08A149DE57BFBE') %} |
Dennis Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame] | 41 | |
Sergii Golovatiuk | 50f9189 | 2017-08-04 18:11:06 +0200 | [diff] [blame] | 42 | {# Address pools for reclass cluster model are taken in the following order: |
| 43 | # 1. environment variables, |
| 44 | # 2. config.underlay.address_pools based on fuel-devops address pools |
| 45 | # (see generated '.ini' file after underlay is created), |
| 46 | # 3. defaults #} |
| 47 | {% set address_pools = config.underlay.address_pools %} |
| 48 | {% set IPV4_NET_ADMIN = os_env('IPV4_NET_ADMIN', address_pools.get('admin-pool01', '192.168.10.0/24')) %} |
| 49 | {% set IPV4_NET_CONTROL = os_env('IPV4_NET_CONTROL', address_pools.get('private-pool01', '172.16.10.0/24')) %} |
| 50 | {% set IPV4_NET_TENANT = os_env('IPV4_NET_TENANT', address_pools.get('tenant-pool01', '10.1.0.0/24')) %} |
| 51 | {% set IPV4_NET_EXTERNAL = os_env('IPV4_NET_EXTERNAL', address_pools.get('external-pool01', '10.16.0.0/24')) %} |
| 52 | {% set IPV4_NET_ADMIN_PREFIX = '.'.join(IPV4_NET_ADMIN.split('.')[0:3]) %} |
| 53 | {% set IPV4_NET_CONTROL_PREFIX = '.'.join(IPV4_NET_CONTROL.split('.')[0:3]) %} |
| 54 | {% set IPV4_NET_TENANT_PREFIX = '.'.join(IPV4_NET_TENANT.split('.')[0:3]) %} |
| 55 | {% set IPV4_NET_EXTERNAL_PREFIX = '.'.join(IPV4_NET_EXTERNAL.split('.')[0:3]) %} |
| 56 | |
Victor Ryzhenkin | 4e077ad | 2017-08-10 13:42:11 +0400 | [diff] [blame] | 57 | {# Format for formula replacement: |
| 58 | # space separated string: |
| 59 | # export SALT_FORMULAS_REFS='apache:refs/changes/xxxx kubernetes:refs/changes/xxxx' #} |
| 60 | |
| 61 | {% set SALT_FORMULAS_REFS = os_env('SALT_FORMULAS_REFS', '') %} |
Tatyana Leontovich | 1c10131 | 2018-04-18 20:33:08 +0300 | [diff] [blame] | 62 | {% set TEMPEST_PATTERN = os_env('TEMPEST_PATTERN', 'tempest') %} |
Tatyana Leontovich | 6970071 | 2018-04-23 12:26:57 +0300 | [diff] [blame] | 63 | {% set EXCLUDE_TEST_ARGS = os_env('EXCLUDE_TEST_ARGS', '') %} |
Dennis Dmitriev | 0f27231 | 2018-10-01 13:29:40 +0300 | [diff] [blame] | 64 | {% set SALT_FORMULAS_REPO = os_env('SALT_FORMULAS_REPO', 'https://gerrit.mcp.mirantis.com/salt-formulas') %} |
Victor Ryzhenkin | 4e077ad | 2017-08-10 13:42:11 +0400 | [diff] [blame] | 65 | |
Victor Ryzhenkin | 66593e9 | 2017-11-28 19:38:33 +0400 | [diff] [blame] | 66 | # Needed for using different models in different templates |
Dennis Dmitriev | bdb2b9b | 2017-12-22 18:00:18 +0200 | [diff] [blame] | 67 | {% set CLUSTER_NAME = os_env('CLUSTER_NAME', LAB_CONFIG_NAME) %} |
Victor Ryzhenkin | 66593e9 | 2017-11-28 19:38:33 +0400 | [diff] [blame] | 68 | |
Dennis Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame] | 69 | |
Dennis Dmitriev | 3fbbc7f | 2017-12-21 15:42:14 +0200 | [diff] [blame] | 70 | {%- macro MACRO_INSTALL_PACKAGES_ON_NODES(NODE_NAME) %} |
| 71 | {#####################################################} |
| 72 | |
| 73 | - description: 'Configure key on nodes and install packages' |
| 74 | cmd: | |
| 75 | rm -rf trusted* ; |
| 76 | rm -rf /etc/apt/sources.list ; |
Dennis Dmitriev | cf77780 | 2018-02-14 18:09:55 +0200 | [diff] [blame] | 77 | . /etc/lsb-release; # Get DISTRIB_CODENAME variable |
Dennis Dmitriev | 3fbbc7f | 2017-12-21 15:42:14 +0200 | [diff] [blame] | 78 | echo "{{ FORMULA_REPOSITORY }}" > /etc/apt/sources.list.d/mcp_salt.list; |
| 79 | wget -O - "{{ FORMULA_GPG }}" | apt-key add -; |
| 80 | echo "{{ SALT_REPOSITORY }}" > /etc/apt/sources.list.d/mcp_saltstack.list; |
Tatyana Leontovich | 908ab93 | 2018-04-27 01:25:09 +0300 | [diff] [blame] | 81 | apt-key adv --keyserver "{{UBUNTU_KEY_SERVER}}" --recv-keys "{{ UBUNTU_KEY_ID}}" |
Dennis Dmitriev | 3fbbc7f | 2017-12-21 15:42:14 +0200 | [diff] [blame] | 82 | echo "{{ UBUNTU_REPOSITORY }}" > /etc/apt/sources.list.d/ubuntu.list |
| 83 | echo "{{ UBUNTU_UPDATES_REPOSITORY }}" > /etc/apt/sources.list.d/ubuntu_updates.list |
| 84 | echo "{{ UBUNTU_SECURITY_REPOSITORY }}" > /etc/apt/sources.list.d/ubuntu_security.list |
Dennis Dmitriev | f4e6efc | 2018-03-26 06:15:10 -0500 | [diff] [blame] | 85 | eatmydata apt-get clean; |
| 86 | apt-get update; |
Dennis Dmitriev | 01d5e37 | 2018-03-15 23:29:29 +0200 | [diff] [blame] | 87 | sync; |
Dennis Dmitriev | 3fbbc7f | 2017-12-21 15:42:14 +0200 | [diff] [blame] | 88 | node_name: {{ NODE_NAME }} |
| 89 | retry: {count: 1, delay: 5} |
| 90 | skip_fail: false |
| 91 | |
| 92 | {%- endmacro %} |
| 93 | |
| 94 | |
Tatyana Leontovich | 3fb5341 | 2019-05-24 00:46:12 +0300 | [diff] [blame] | 95 | {%- macro MACRO_INSTALL_FORMULAS_FROM_UPDATE() %} |
| 96 | {#####################################################} |
| 97 | |
| 98 | - description: 'Configure key on nodes and install packages' |
| 99 | cmd: | |
| 100 | rm -rf trusted* ; |
| 101 | rm -rf /etc/apt/sources.list ; |
| 102 | . /etc/lsb-release; # Get DISTRIB_CODENAME variable |
| 103 | echo "{{ UPDATE_FORMULA_REPOSITORY }}" > /etc/apt/sources.list.d/mcp_update_salt.list; |
| 104 | wget -O - "{{ FORMULA_GPG }}" | apt-key add -; |
| 105 | eatmydata apt-get clean; |
| 106 | apt-get update; |
| 107 | sync; |
| 108 | node_name: {{ HOSTNAME_CFG01 }} |
| 109 | retry: {count: 1, delay: 5} |
| 110 | skip_fail: false |
| 111 | |
| 112 | {%- endmacro %} |
| 113 | |
Dennis Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame] | 114 | {%- macro MACRO_INSTALL_SALT_MASTER() %} |
| 115 | {######################################} |
| 116 | - description: Installing salt master on cfg01 |
Dennis Dmitriev | cf77780 | 2018-02-14 18:09:55 +0200 | [diff] [blame] | 117 | cmd: | |
| 118 | which wget >/dev/null || (apt-get update; apt-get install -y wget); |
| 119 | # Configure ubuntu and salt repositories |
| 120 | . /etc/lsb-release; # Get DISTRIB_CODENAME variable |
| 121 | echo "{{ UBUNTU_REPOSITORY }}" > /etc/apt/sources.list |
| 122 | echo "{{ UBUNTU_UPDATES_REPOSITORY }}" >> /etc/apt/sources.list |
| 123 | echo "{{ UBUNTU_SECURITY_REPOSITORY }}" >> /etc/apt/sources.list |
| 124 | |
| 125 | echo "{{ FORMULA_REPOSITORY }}" > /etc/apt/sources.list.d/mcp_salt.list; |
| 126 | wget -O - {{ FORMULA_GPG }} | apt-key add -; |
| 127 | echo "{{ SALT_REPOSITORY }}" > /etc/apt/sources.list.d/mcp_saltstack.list; |
Tatyana Leontovich | 908ab93 | 2018-04-27 01:25:09 +0300 | [diff] [blame] | 128 | apt-key adv --keyserver "{{UBUNTU_KEY_SERVER}}" --recv-keys "{{ UBUNTU_KEY_ID}}" |
| 129 | |
Dennis Dmitriev | cf77780 | 2018-02-14 18:09:55 +0200 | [diff] [blame] | 130 | |
| 131 | apt-get clean |
| 132 | apt-get update |
| 133 | |
| 134 | # Install salt-master and reclass |
| 135 | eatmydata apt-get install -y --allow-unauthenticated reclass salt-master |
| 136 | # Install common packages |
Dennis Dmitriev | f88fc7d | 2018-02-20 15:40:08 +0200 | [diff] [blame] | 137 | eatmydata apt-get install -y python-pip git curl at tmux byobu iputils-ping traceroute htop tree mc |
Dennis Dmitriev | 01d5e37 | 2018-03-15 23:29:29 +0200 | [diff] [blame] | 138 | sync; |
Dennis Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame] | 139 | node_name: {{ HOSTNAME_CFG01 }} |
| 140 | retry: {count: 1, delay: 1} |
| 141 | skip_fail: false |
| 142 | |
Dennis Dmitriev | da9be46 | 2018-01-24 21:20:09 +0200 | [diff] [blame] | 143 | - description: Remove any existing minion keys |
| 144 | cmd: salt-key -y -D || true |
| 145 | node_name: {{ HOSTNAME_CFG01 }} |
| 146 | retry: {count: 1, delay: 1} |
| 147 | skip_fail: false |
| 148 | |
Dennis Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame] | 149 | - description: Configure salt-master on cfg01 |
| 150 | cmd: | |
Dennis Dmitriev | a578c77 | 2018-01-24 21:02:15 +0200 | [diff] [blame] | 151 | cat << 'EOF' > /etc/salt/master.d/master.conf |
Dennis Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame] | 152 | file_roots: |
| 153 | base: |
| 154 | - /usr/share/salt-formulas/env |
| 155 | pillar_opts: False |
| 156 | open_mode: True |
| 157 | reclass: &reclass |
| 158 | storage_type: yaml_fs |
| 159 | inventory_base_uri: /srv/salt/reclass |
| 160 | ext_pillar: |
| 161 | - reclass: *reclass |
| 162 | master_tops: |
| 163 | reclass: *reclass |
| 164 | EOF |
| 165 | node_name: {{ HOSTNAME_CFG01 }} |
| 166 | retry: {count: 1, delay: 1} |
| 167 | skip_fail: false |
| 168 | |
| 169 | - description: Configure GIT settings and certificates |
Dennis Dmitriev | 3e731a4 | 2017-08-30 17:12:59 +0300 | [diff] [blame] | 170 | cmd: | |
| 171 | set -e; |
Dennis Dmitriev | 3fbbc7f | 2017-12-21 15:42:14 +0200 | [diff] [blame] | 172 | #touch /root/.git_trusted_certs.pem; |
| 173 | #for server in github.com; do \ |
| 174 | # openssl s_client -showcerts -connect $server:443 </dev/null \ |
| 175 | # | openssl x509 -outform PEM \ |
| 176 | # >> /root/.git_trusted_certs.pem; |
| 177 | #done; |
| 178 | #HOME=/root git config --global http.sslCAInfo /root/.git_trusted_certs.pem; |
| 179 | HOME=/root git config --global user.email "mcp-integration-qa@example.com"; |
| 180 | HOME=/root git config --global user.name "MCP Integration QA"; |
Dennis Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame] | 181 | node_name: {{ HOSTNAME_CFG01 }} |
| 182 | retry: {count: 1, delay: 1} |
| 183 | skip_fail: false |
| 184 | {%- endmacro %} |
| 185 | |
Dmitry Tyzhnenko | 35413c0 | 2018-03-05 14:12:37 +0200 | [diff] [blame] | 186 | |
| 187 | {%- macro MACRO_CONFIG_DAY01_SALT_MASTER() %} |
| 188 | {######################################} |
| 189 | |
| 190 | - description: Remove /etc/update-motd.d/52-info |
| 191 | cmd: rm -vf /etc/update-motd.d/52-info |
| 192 | node_name: {{ HOSTNAME_CFG01 }} |
| 193 | retry: {count: 1, delay: 10} |
| 194 | skip_fail: false |
| 195 | |
| 196 | - description: Set up static interface config |
| 197 | cmd: | |
| 198 | kill $(pidof /sbin/dhclient) || /bin/true |
| 199 | cat << 'EOF' > /etc/network/interfaces |
| 200 | # This file describes the network interfaces available on your system |
| 201 | # and how to activate them. For more information, see interfaces(5). |
| 202 | |
| 203 | # The loopback network interface |
| 204 | auto lo |
| 205 | iface lo inet loopback |
| 206 | |
| 207 | # The primary network interface |
| 208 | auto ens3 |
| 209 | iface ens3 inet static |
| 210 | address {{ IPV4_NET_ADMIN_PREFIX }}.90 |
| 211 | netmask 255.255.255.0 |
| 212 | gateway {{ IPV4_NET_ADMIN_PREFIX }}.1 |
| 213 | EOF |
| 214 | node_name: {{ HOSTNAME_CFG01 }} |
| 215 | retry: {count: 1, delay: 10} |
| 216 | skip_fail: false |
| 217 | |
| 218 | - description: Install common packages on cfg01 |
| 219 | cmd: eatmydata apt-get update && apt-get install -y python-pip git curl at tmux byobu iputils-ping traceroute htop tree wget jq ntpdate |
| 220 | node_name: {{ HOSTNAME_CFG01 }} |
| 221 | retry: {count: 1, delay: 1} |
| 222 | skip_fail: false |
| 223 | |
| 224 | - description: Remove any existing minion keys |
| 225 | cmd: salt-key -y -D || true |
| 226 | node_name: {{ HOSTNAME_CFG01 }} |
| 227 | retry: {count: 1, delay: 1} |
| 228 | skip_fail: false |
| 229 | |
| 230 | - description: Configure GIT settings and certificates |
| 231 | cmd: | |
| 232 | set -e; |
| 233 | #touch /root/.git_trusted_certs.pem; |
| 234 | #for server in github.com; do \ |
| 235 | # openssl s_client -showcerts -connect $server:443 </dev/null \ |
| 236 | # | openssl x509 -outform PEM \ |
| 237 | # >> /root/.git_trusted_certs.pem; |
| 238 | #done; |
| 239 | #HOME=/root git config --global http.sslCAInfo /root/.git_trusted_certs.pem; |
| 240 | HOME=/root git config --global user.email "mcp-integration-qa@example.com"; |
| 241 | HOME=/root git config --global user.name "MCP Integration QA"; |
| 242 | node_name: {{ HOSTNAME_CFG01 }} |
| 243 | retry: {count: 1, delay: 1} |
| 244 | skip_fail: false |
| 245 | {%- endmacro %} |
| 246 | |
| 247 | |
Dmitry Tyzhnenko | 1fe62a8 | 2018-06-01 12:54:26 +0300 | [diff] [blame] | 248 | {%- macro MACRO_CLONE_RECLASS_MODELS(IS_CONTRAIL_LAB=false, WITH_MAAS=false) %} |
Dennis Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame] | 249 | {############################################################} |
Dennis Dmitriev | a5f38e4 | 2017-09-21 21:52:25 +0300 | [diff] [blame] | 250 | {# Creates a 'cluster' model from cookiecutter-templates and 'environment' model from uploaded template #} |
| 251 | |
Dennis Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame] | 252 | - description: Clone reclass models with submodules |
| 253 | cmd: | |
Dennis Dmitriev | 3e731a4 | 2017-08-30 17:12:59 +0300 | [diff] [blame] | 254 | set -e; |
Dennis Dmitriev | 75776c5 | 2017-12-26 18:22:53 +0200 | [diff] [blame] | 255 | set -x; |
Dennis Dmitriev | 3fbbc7f | 2017-12-21 15:42:14 +0200 | [diff] [blame] | 256 | #ssh-keyscan -H github.com >> ~/.ssh/known_hosts; |
Dennis Dmitriev | f00a384 | 2018-01-24 16:44:26 +0200 | [diff] [blame] | 257 | |
| 258 | # In the day01 image, /srv/salt/reclass directory is already exists, so clone the model into the reclass.tmp directory |
| 259 | export GIT_SSL_NO_VERIFY=true; git clone -b {{ SALT_MODELS_BRANCH }} {{ SALT_MODELS_REPOSITORY }} /srv/salt/reclass.tmp; |
Dennis Dmitriev | 70dd306 | 2018-01-24 20:45:49 +0200 | [diff] [blame] | 260 | rsync -a /srv/salt/reclass.tmp/ /srv/salt/reclass; |
Dennis Dmitriev | f00a384 | 2018-01-24 16:44:26 +0200 | [diff] [blame] | 261 | |
Dennis Dmitriev | 55ddd79 | 2017-12-22 16:35:57 +0200 | [diff] [blame] | 262 | pushd /srv/salt/reclass; |
| 263 | git config submodule."classes/system".url "{{ SALT_MODELS_SYSTEM_REPOSITORY }}"; |
| 264 | git submodule update --init --recursive; |
Sergii Golovatiuk | 50f9189 | 2017-08-04 18:11:06 +0200 | [diff] [blame] | 265 | {%- if SALT_MODELS_REF_CHANGE != '' %} |
| 266 | {%- for item in SALT_MODELS_REF_CHANGE.split(" ") %} |
Dennis Dmitriev | 55ddd79 | 2017-12-22 16:35:57 +0200 | [diff] [blame] | 267 | git fetch {{ SALT_MODELS_REPOSITORY }} {{ item }} && git cherry-pick FETCH_HEAD; |
Sergii Golovatiuk | 50f9189 | 2017-08-04 18:11:06 +0200 | [diff] [blame] | 268 | {%- endfor %} |
| 269 | {%- elif SALT_MODELS_COMMIT != 'master' %} |
Dennis Dmitriev | 55ddd79 | 2017-12-22 16:35:57 +0200 | [diff] [blame] | 270 | git checkout {{ SALT_MODELS_COMMIT }}; |
Sergii Golovatiuk | 50f9189 | 2017-08-04 18:11:06 +0200 | [diff] [blame] | 271 | {%- endif %} |
Dennis Dmitriev | 5f9cf2e | 2018-07-03 10:36:00 +0300 | [diff] [blame] | 272 | |
Dennis Dmitriev | ee5ef23 | 2018-08-31 13:53:18 +0300 | [diff] [blame] | 273 | {%- if SALT_MODELS_SYSTEM_REF_CHANGE != '' %} |
Dmitry Tyzhnenko | 778515f | 2017-08-25 14:52:54 +0300 | [diff] [blame] | 274 | pushd classes/system/ && \ |
| 275 | {%- for item in SALT_MODELS_SYSTEM_REF_CHANGE.split(" ") %} |
Dennis Dmitriev | 55ddd79 | 2017-12-22 16:35:57 +0200 | [diff] [blame] | 276 | git fetch {{ SALT_MODELS_SYSTEM_REPOSITORY }} {{ item }} && git cherry-pick FETCH_HEAD; |
Dmitry Tyzhnenko | 778515f | 2017-08-25 14:52:54 +0300 | [diff] [blame] | 277 | {%- endfor %} |
Dennis Dmitriev | 55ddd79 | 2017-12-22 16:35:57 +0200 | [diff] [blame] | 278 | popd; |
Dennis Dmitriev | ee5ef23 | 2018-08-31 13:53:18 +0300 | [diff] [blame] | 279 | {%- elif SALT_MODELS_SYSTEM_COMMIT != '' %} |
| 280 | pushd classes/system/; |
| 281 | git checkout {{ SALT_MODELS_SYSTEM_COMMIT }}; |
| 282 | popd; |
Dennis Dmitriev | 5f9cf2e | 2018-07-03 10:36:00 +0300 | [diff] [blame] | 283 | {%- elif SALT_MODELS_SYSTEM_TAG != '' %} |
| 284 | pushd classes/system/; |
| 285 | git fetch --all --tags --prune |
| 286 | git checkout tags/{{ SALT_MODELS_SYSTEM_TAG }}; |
| 287 | popd; |
Sergii Golovatiuk | 50f9189 | 2017-08-04 18:11:06 +0200 | [diff] [blame] | 288 | {%- endif %} |
Dennis Dmitriev | 5f9cf2e | 2018-07-03 10:36:00 +0300 | [diff] [blame] | 289 | |
Sergii Golovatiuk | 50f9189 | 2017-08-04 18:11:06 +0200 | [diff] [blame] | 290 | popd; |
| 291 | mkdir -p /srv/salt/reclass/classes/service; |
Dennis Dmitriev | b2e78be | 2017-09-26 23:25:24 +0300 | [diff] [blame] | 292 | mkdir -p /srv/salt/reclass/nodes/_generated/; |
Sergii Golovatiuk | 50f9189 | 2017-08-04 18:11:06 +0200 | [diff] [blame] | 293 | |
| 294 | # Replace firstly to an intermediate value to avoid intersection between |
| 295 | # already replaced and replacing networks. |
| 296 | # For example, if generated IPV4_NET_ADMIN_PREFIX=10.16.0 , then there is a risk of replacing twice: |
| 297 | # 192.168.10 -> 10.16.0 (generated network for admin) |
| 298 | # 10.16.0 -> <external network> |
| 299 | # So let's replace constant networks to the keywords, and then keywords to the desired networks. |
Dennis Dmitriev | 9d9ba9f | 2017-09-13 17:34:03 +0300 | [diff] [blame] | 300 | export REPLACE_DIRS="/srv/salt/reclass/classes/ /srv/salt/reclass/nodes/" |
Dennis Dmitriev | 806f3b5 | 2018-02-26 18:04:24 +0200 | [diff] [blame] | 301 | find ${REPLACE_DIRS} -type f -exec sed -i 's/192\.168\.10/==IPV4_NET_ADMIN_PREFIX==/g' {} + |
| 302 | find ${REPLACE_DIRS} -type f -exec sed -i 's/172\.16\.10/==IPV4_NET_CONTROL_PREFIX==/g' {} + |
| 303 | find ${REPLACE_DIRS} -type f -exec sed -i 's/10\.1\.0/==IPV4_NET_TENANT_PREFIX==/g' {} + |
| 304 | find ${REPLACE_DIRS} -type f -exec sed -i 's/10\.16\.0/==IPV4_NET_EXTERNAL_PREFIX==/g' {} + |
Tatyana Leontovich | 2675691 | 2018-06-06 20:11:05 +0300 | [diff] [blame] | 305 | find ${REPLACE_DIRS} -type f -exec sed -i 's/10\.60\.0/==IPV4_NET_CONTROL_PREFIX==/g' {} + |
| 306 | find ${REPLACE_DIRS} -type f -exec sed -i 's/10\.70\.0/==IPV4_NET_ADMIN_PREFIX==/g' {} + |
Sergii Golovatiuk | 50f9189 | 2017-08-04 18:11:06 +0200 | [diff] [blame] | 307 | |
Dennis Dmitriev | 806f3b5 | 2018-02-26 18:04:24 +0200 | [diff] [blame] | 308 | find ${REPLACE_DIRS} -type f -exec sed -i 's/==IPV4_NET_ADMIN_PREFIX==/{{ IPV4_NET_ADMIN_PREFIX }}/g' {} + |
| 309 | find ${REPLACE_DIRS} -type f -exec sed -i 's/==IPV4_NET_CONTROL_PREFIX==/{{ IPV4_NET_CONTROL_PREFIX }}/g' {} + |
| 310 | find ${REPLACE_DIRS} -type f -exec sed -i 's/==IPV4_NET_TENANT_PREFIX==/{{ IPV4_NET_TENANT_PREFIX }}/g' {} + |
| 311 | find ${REPLACE_DIRS} -type f -exec sed -i 's/==IPV4_NET_EXTERNAL_PREFIX==/{{ IPV4_NET_EXTERNAL_PREFIX }}/g' {} + |
Sergii Golovatiuk | 50f9189 | 2017-08-04 18:11:06 +0200 | [diff] [blame] | 312 | |
Dennis Dmitriev | 9d9ba9f | 2017-09-13 17:34:03 +0300 | [diff] [blame] | 313 | find ${REPLACE_DIRS} -type f -exec sed -i 's/apt_mk_version:.*/apt_mk_version: {{ REPOSITORY_SUITE }}/g' {} + |
Victor Ryzhenkin | e784bbf | 2018-12-21 03:58:00 +0400 | [diff] [blame] | 314 | find ${REPLACE_DIRS} -type f -exec sed -i 's/mcp_version:.*/mcp_version: {{ REPOSITORY_SUITE }}/g' {} + |
Sergii Golovatiuk | 50f9189 | 2017-08-04 18:11:06 +0200 | [diff] [blame] | 315 | |
Tatyana Leontovich | a4a96b2 | 2018-04-25 14:30:24 +0300 | [diff] [blame] | 316 | {%- if IS_CONTRAIL_LAB %} |
Dennis Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame] | 317 | # vSRX IPs for tcp-qa images have 172.16.10.90 hardcoded |
Dennis Dmitriev | 9d9ba9f | 2017-09-13 17:34:03 +0300 | [diff] [blame] | 318 | find ${REPLACE_DIRS} -type f -exec sed -i 's/opencontrail_router01_address:.*/opencontrail_router01_address: 172.16.10.90/g' {} + |
Tatyana Leontovich | 3424bf6 | 2017-09-15 12:13:54 +0300 | [diff] [blame] | 319 | 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 Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame] | 320 | {%- endif %} |
| 321 | |
Dennis Dmitriev | f5bef57 | 2017-12-24 17:52:41 +0200 | [diff] [blame] | 322 | # Override some context parameters |
| 323 | {%- set CLUSTER_PATH = '/srv/salt/reclass/classes/cluster/' + CLUSTER_NAME %} |
| 324 | find {{ CLUSTER_PATH }} -type f -exec sed -i 's/cluster_name: .*/cluster_name: {{ CLUSTER_NAME }}/g' {} + |
| 325 | find {{ CLUSTER_PATH }} -type f -exec sed -i 's/cluster_domain: .*/cluster_domain: {{ DOMAIN_NAME }}/g' {} + |
| 326 | |
Dennis Dmitriev | 97e78e2 | 2018-02-23 21:51:49 +0200 | [diff] [blame] | 327 | # Create the cfg01 inventory file or use existing |
| 328 | export CFG01_INVENTORY_FILE="/srv/salt/reclass/nodes/_generated/cfg01.{{ DOMAIN_NAME }}.yml" |
| 329 | [ -f ${CFG01_INVENTORY_FILE} ] || cat << 'EOF' > ${CFG01_INVENTORY_FILE} |
Dennis Dmitriev | b2e78be | 2017-09-26 23:25:24 +0300 | [diff] [blame] | 330 | classes: |
Victor Ryzhenkin | 66593e9 | 2017-11-28 19:38:33 +0400 | [diff] [blame] | 331 | - cluster.{{ CLUSTER_NAME }}.infra.config |
Dmitry Tyzhnenko | 1fe62a8 | 2018-06-01 12:54:26 +0300 | [diff] [blame] | 332 | {%- if WITH_MAAS %} |
Dmitry Tyzhnenko | 35413c0 | 2018-03-05 14:12:37 +0200 | [diff] [blame] | 333 | - cluster.{{ CLUSTER_NAME }}.infra.maas |
| 334 | - cluster.{{ CLUSTER_NAME }}.infra.maas-machines |
Dmitry Tyzhnenko | 1fe62a8 | 2018-06-01 12:54:26 +0300 | [diff] [blame] | 335 | {%- endif %} |
Dennis Dmitriev | b2e78be | 2017-09-26 23:25:24 +0300 | [diff] [blame] | 336 | parameters: |
| 337 | _param: |
| 338 | linux_system_codename: xenial |
| 339 | reclass_data_revision: master |
| 340 | linux: |
| 341 | system: |
| 342 | name: cfg01 |
| 343 | domain: {{ DOMAIN_NAME }} |
Sergii Golovatiuk | 50f9189 | 2017-08-04 18:11:06 +0200 | [diff] [blame] | 344 | reclass: |
| 345 | storage: |
| 346 | data_source: |
| 347 | engine: local |
| 348 | EOF |
Dennis Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame] | 349 | |
| 350 | # Show the changes to the console |
| 351 | cd /srv/salt/reclass/; git diff |
| 352 | node_name: {{ HOSTNAME_CFG01 }} |
| 353 | retry: {count: 1, delay: 1} |
| 354 | skip_fail: false |
| 355 | {%- endmacro %} |
| 356 | |
Dmitry Tyzhnenko | fcb4dab | 2019-03-05 20:11:59 +0200 | [diff] [blame] | 357 | {%- macro MACRO_UPLOAD_AND_IMPORT_GPG_ENCRYPTION_KEY() %} |
| 358 | {%- set KEY_FILE_NAME = 'encryption-key.asc' %} |
| 359 | - description: "Upload gpg encruption key" |
| 360 | upload: |
| 361 | local_path: {{ config.salt_deploy.templates_dir }}{{ LAB_CONFIG_NAME }}/ |
| 362 | local_filename: {{ KEY_FILE_NAME }} |
| 363 | remote_path: /root/ |
| 364 | node_name: {{ HOSTNAME_CFG01 }} |
| 365 | |
| 366 | - description: Import encryption key |
| 367 | cmd: | |
Tatyana Leontovich | 1192aa4 | 2019-03-25 14:11:27 +0200 | [diff] [blame] | 368 | set -ex; |
| 369 | mkdir -p /etc/salt/gpgkeys |
| 370 | chmod 0700 /etc/salt/gpgkeys |
| 371 | export GNUPGHOME=/etc/salt/gpgkeys |
Dmitry Tyzhnenko | fcb4dab | 2019-03-05 20:11:59 +0200 | [diff] [blame] | 372 | gpg --import {{ KEY_FILE_NAME }} |
| 373 | gpg --list-keys |
| 374 | node_name: {{ HOSTNAME_CFG01 }} |
| 375 | retry: {count: 1, delay: 1} |
| 376 | skip_fail: false |
| 377 | |
| 378 | - description: Put encryption key to reclass folder |
| 379 | cmd: | |
| 380 | set -e; |
| 381 | set -x; |
| 382 | mkdir -p /srv/salt/reclass |
| 383 | cp /root/{{ KEY_FILE_NAME }} /srv/salt/reclass/ |
| 384 | node_name: {{ HOSTNAME_CFG01 }} |
| 385 | retry: {count: 1, delay: 1} |
| 386 | skip_fail: false |
| 387 | |
| 388 | {%- endmacro %} |
| 389 | |
Dennis Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame] | 390 | |
sgudz | 160b730 | 2017-12-22 17:01:10 +0200 | [diff] [blame] | 391 | {%- macro MACRO_GENERATE_COOKIECUTTER_MODEL(IS_CONTRAIL_LAB=false, CONTROL_VLAN=None, TENANT_VLAN=None, CLUSTER_PRODUCT_MODELS='') %} |
Dennis Dmitriev | 9f141af | 2017-09-28 17:21:01 +0300 | [diff] [blame] | 392 | {###################################################################} |
Dennis Dmitriev | 30841c3 | 2018-07-19 20:12:07 +0300 | [diff] [blame] | 393 | {%- set CLUSTER_CONTEXT_PATH = '/root/' + CLUSTER_CONTEXT_NAME %} |
Dennis Dmitriev | 92295c0 | 2018-02-02 13:18:25 +0200 | [diff] [blame] | 394 | - description: "[EXPERIMENTAL] Upload cookiecutter-templates context to cfg01.{{ DOMAIN_NAME }}" |
Dennis Dmitriev | ccdc87a | 2017-09-28 17:43:54 +0300 | [diff] [blame] | 395 | upload: |
| 396 | local_path: {{ config.salt_deploy.templates_dir }}{{ LAB_CONFIG_NAME }}/ |
| 397 | local_filename: {{ CLUSTER_CONTEXT_NAME }} |
Dennis Dmitriev | 30841c3 | 2018-07-19 20:12:07 +0300 | [diff] [blame] | 398 | remote_path: /root/ |
Dennis Dmitriev | ccdc87a | 2017-09-28 17:43:54 +0300 | [diff] [blame] | 399 | node_name: {{ HOSTNAME_CFG01 }} |
| 400 | |
Dennis Dmitriev | bcf94f8 | 2018-07-03 10:06:06 +0300 | [diff] [blame] | 401 | - description: "Show options enabled in the context file for model generation" |
| 402 | cmd: | |
| 403 | echo "===== Options enabled in the context for generation the model {{ LAB_CONFIG_NAME }} =====" |
| 404 | fgrep "True" {{ CLUSTER_CONTEXT_PATH }} |
| 405 | echo "===== Sources for model generation =====" |
| 406 | echo "# mcp_version: {{ REPOSITORY_SUITE }}" |
| 407 | echo "COOKIECUTTER_TEMPLATES_REPOSITORY={{ COOKIECUTTER_TEMPLATES_REPOSITORY }}" |
| 408 | {%- if CLUSTER_PRODUCT_MODELS != '' %} |
| 409 | echo "CLUSTER_PRODUCT_MODELS={{ CLUSTER_PRODUCT_MODELS }}" |
| 410 | {%- endif %} |
Dennis Dmitriev | ee5ef23 | 2018-08-31 13:53:18 +0300 | [diff] [blame] | 411 | {%- if COOKIECUTTER_REF_CHANGE != '' %} |
Dennis Dmitriev | bcf94f8 | 2018-07-03 10:06:06 +0300 | [diff] [blame] | 412 | echo "COOKIECUTTER_REF_CHANGE={{ COOKIECUTTER_REF_CHANGE }}" |
Dennis Dmitriev | ee5ef23 | 2018-08-31 13:53:18 +0300 | [diff] [blame] | 413 | {%- elif COOKIECUTTER_TEMPLATE_COMMIT != '' %} |
| 414 | echo "COOKIECUTTER_TEMPLATE_COMMIT={{ COOKIECUTTER_TEMPLATE_COMMIT }}" |
Dennis Dmitriev | 713dce2 | 2018-07-03 11:47:46 +0300 | [diff] [blame] | 415 | {%- elif COOKIECUTTER_TAG != '' %} |
Dennis Dmitriev | bcf94f8 | 2018-07-03 10:06:06 +0300 | [diff] [blame] | 416 | echo "COOKIECUTTER_TAG={{ COOKIECUTTER_TAG }}" |
| 417 | {%- endif %} |
| 418 | echo "SALT_MODELS_SYSTEM_REPOSITORY={{ SALT_MODELS_SYSTEM_REPOSITORY }}" |
Dennis Dmitriev | ee5ef23 | 2018-08-31 13:53:18 +0300 | [diff] [blame] | 419 | {%- if SALT_MODELS_SYSTEM_REF_CHANGE != '' %} |
Dennis Dmitriev | bcf94f8 | 2018-07-03 10:06:06 +0300 | [diff] [blame] | 420 | echo "SALT_MODELS_SYSTEM_REF_CHANGE={{ SALT_MODELS_SYSTEM_REF_CHANGE }}" |
Dennis Dmitriev | ee5ef23 | 2018-08-31 13:53:18 +0300 | [diff] [blame] | 421 | {%- elif SALT_MODELS_SYSTEM_COMMIT != '' %} |
| 422 | echo "SALT_MODELS_SYSTEM_COMMIT={{ SALT_MODELS_SYSTEM_COMMIT }}" |
Dennis Dmitriev | 5f9cf2e | 2018-07-03 10:36:00 +0300 | [diff] [blame] | 423 | {%- elif SALT_MODELS_SYSTEM_TAG != '' %} |
| 424 | echo "SALT_MODELS_SYSTEM_TAG={{ SALT_MODELS_SYSTEM_TAG }}" |
Dennis Dmitriev | bcf94f8 | 2018-07-03 10:06:06 +0300 | [diff] [blame] | 425 | {%- endif %} |
Tatyana Leontovich | 8ac26d7 | 2019-05-15 23:33:38 +0300 | [diff] [blame] | 426 | {%- if JENKINS_PIPELINE_BRANCH != '' %} |
| 427 | echo "JENKINS_PIPELINE_BRANCH={{ JENKINS_PIPELINE_BRANCH }}" |
| 428 | {%- endif %} |
Dennis Dmitriev | bcf94f8 | 2018-07-03 10:06:06 +0300 | [diff] [blame] | 429 | echo "=======================================" |
| 430 | node_name: {{ HOSTNAME_CFG01 }} |
| 431 | retry: {count: 1, delay: 1} |
| 432 | skip_fail: false |
| 433 | |
Dennis Dmitriev | 0697944 | 2018-10-24 18:53:49 +0300 | [diff] [blame] | 434 | - description: "Upload {{ COOKIECUTTER_TEMPLATES_REPOSITORY_USER }} key" |
| 435 | upload: |
| 436 | local_path: {{ COOKIECUTTER_TEMPLATES_REPOSITORY_KEY_PATH | dirname }}/ |
| 437 | local_filename: {{ COOKIECUTTER_TEMPLATES_REPOSITORY_KEY_PATH | basename }} |
| 438 | remote_path: /tmp/ |
| 439 | node_name: {{ HOSTNAME_CFG01 }} |
| 440 | |
Dennis Dmitriev | a5f38e4 | 2017-09-21 21:52:25 +0300 | [diff] [blame] | 441 | - description: Create cluster model from cookiecutter templates |
| 442 | cmd: | |
| 443 | set -e; |
Dennis Dmitriev | 468ce35 | 2018-08-14 13:23:31 +0300 | [diff] [blame] | 444 | set -x; |
Tatyana Leontovich | 1ef6095 | 2018-12-19 00:36:50 +0200 | [diff] [blame] | 445 | sudo apt-get install virtualenv -y |
Dmitry Tyzhnenko | 1fe62a8 | 2018-06-01 12:54:26 +0300 | [diff] [blame] | 446 | sudo apt-get install python-setuptools -y |
Dennis Dmitriev | b4b7403 | 2018-12-18 21:53:23 +0200 | [diff] [blame] | 447 | |
| 448 | [[ -d /root/venv-reclass-tools ]] || virtualenv /root/venv-reclass-tools; |
| 449 | . /root/venv-reclass-tools/bin/activate; |
| 450 | pip install -U pip |
| 451 | |
Dennis Dmitriev | a5f38e4 | 2017-09-21 21:52:25 +0300 | [diff] [blame] | 452 | pip install cookiecutter |
Dennis Dmitriev | 0697944 | 2018-10-24 18:53:49 +0300 | [diff] [blame] | 453 | |
| 454 | chmod 0600 /tmp/{{ COOKIECUTTER_TEMPLATES_REPOSITORY_KEY_PATH | basename }} |
| 455 | eval $(ssh-agent) |
| 456 | ssh-add /tmp/{{ COOKIECUTTER_TEMPLATES_REPOSITORY_KEY_PATH | basename }} |
Hanna Arhipova | 894a768 | 2021-09-27 14:11:53 +0300 | [diff] [blame] | 457 | |
| 458 | git config --global user.name {{ HOSTNAME_CFG01 }} |
| 459 | git config --global user.email {{ HOSTNAME_CFG01 }}@example.com |
| 460 | |
Dennis Dmitriev | 30841c3 | 2018-07-19 20:12:07 +0300 | [diff] [blame] | 461 | export GIT_SSL_NO_VERIFY=true; git clone {{ COOKIECUTTER_TEMPLATES_REPOSITORY }} /root/cookiecutter-templates |
sgudz | 4d816eb | 2017-11-13 11:58:05 +0200 | [diff] [blame] | 462 | |
Dennis Dmitriev | ee5ef23 | 2018-08-31 13:53:18 +0300 | [diff] [blame] | 463 | {%- if COOKIECUTTER_REF_CHANGE != '' %} |
Dennis Dmitriev | 30841c3 | 2018-07-19 20:12:07 +0300 | [diff] [blame] | 464 | pushd /root/cookiecutter-templates |
Dennis Dmitriev | bcf94f8 | 2018-07-03 10:06:06 +0300 | [diff] [blame] | 465 | git fetch {{ COOKIECUTTER_TEMPLATES_REPOSITORY }} {{ COOKIECUTTER_REF_CHANGE }} && git checkout FETCH_HEAD |
sgudz | 4d816eb | 2017-11-13 11:58:05 +0200 | [diff] [blame] | 466 | popd |
Dennis Dmitriev | ee5ef23 | 2018-08-31 13:53:18 +0300 | [diff] [blame] | 467 | {%- elif COOKIECUTTER_TEMPLATE_COMMIT != '' %} |
| 468 | pushd /root/cookiecutter-templates |
| 469 | git checkout {{ COOKIECUTTER_TEMPLATE_COMMIT }} |
| 470 | popd |
Dennis Dmitriev | 713dce2 | 2018-07-03 11:47:46 +0300 | [diff] [blame] | 471 | {%- elif COOKIECUTTER_TAG != '' %} |
Dennis Dmitriev | 30841c3 | 2018-07-19 20:12:07 +0300 | [diff] [blame] | 472 | pushd /root/cookiecutter-templates |
Tatyana Leontovich | 819a6c8 | 2018-06-04 12:05:16 +0300 | [diff] [blame] | 473 | git fetch --all --tags --prune |
| 474 | git checkout tags/{{ COOKIECUTTER_TAG }} |
| 475 | popd |
| 476 | {%- endif %} |
| 477 | |
Dennis Dmitriev | ddcea2f | 2018-12-18 21:21:11 +0200 | [diff] [blame] | 478 | if [ -f /root/cookiecutter-templates/requirements.txt ]; then |
| 479 | pip install -r /root/cookiecutter-templates/requirements.txt |
| 480 | fi |
| 481 | |
Dennis Dmitriev | a5f38e4 | 2017-09-21 21:52:25 +0300 | [diff] [blame] | 482 | mkdir -p /srv/salt/reclass/classes/cluster/ |
| 483 | mkdir -p /srv/salt/reclass/classes/system/ |
| 484 | mkdir -p /srv/salt/reclass/classes/service/ |
| 485 | mkdir -p /srv/salt/reclass/nodes/_generated |
| 486 | |
| 487 | # Override some context parameters |
Dennis Dmitriev | f5bef57 | 2017-12-24 17:52:41 +0200 | [diff] [blame] | 488 | sed -i 's/cluster_name: .*/cluster_name: {{ CLUSTER_NAME }}/g' {{ CLUSTER_CONTEXT_PATH }} |
| 489 | sed -i 's/cluster_domain: .*/cluster_domain: {{ DOMAIN_NAME }}/g' {{ CLUSTER_CONTEXT_PATH }} |
Dennis Dmitriev | 862f775 | 2018-01-19 17:12:11 +0200 | [diff] [blame] | 490 | sed -i 's/mcp_version:.*/mcp_version: {{ REPOSITORY_SUITE }}/g' {{ CLUSTER_CONTEXT_PATH }} |
Tatyana Leontovich | 8ac26d7 | 2019-05-15 23:33:38 +0300 | [diff] [blame] | 491 | {%- if JENKINS_PIPELINE_BRANCH != '' %} |
Hanna Arhipova | c2965a4 | 2020-01-21 12:27:33 +0200 | [diff] [blame] | 492 | # Escape / with \/ |
Dmitriy Kruglov | 402ef3b | 2020-01-29 23:52:12 +0100 | [diff] [blame] | 493 | escaped_branch=$(echo {{ JENKINS_PIPELINE_BRANCH }} | sed s'/\//\\\//g') |
| 494 | sed -i "s/jenkins_pipelines_branch:.*/jenkins_pipelines_branch: '$escaped_branch'/g" {{ CLUSTER_CONTEXT_PATH }} |
Tatyana Leontovich | 8ac26d7 | 2019-05-15 23:33:38 +0300 | [diff] [blame] | 495 | {%- endif %} |
sgudz | 8c888ec | 2017-10-02 15:29:23 +0300 | [diff] [blame] | 496 | {%- if CONTROL_VLAN %} |
Dennis Dmitriev | f5bef57 | 2017-12-24 17:52:41 +0200 | [diff] [blame] | 497 | sed -i 's/control_vlan: .*/control_vlan: {{ CONTROL_VLAN }}/g' {{ CLUSTER_CONTEXT_PATH }} |
sgudz | 8c888ec | 2017-10-02 15:29:23 +0300 | [diff] [blame] | 498 | {%- endif %} |
| 499 | {%- if TENANT_VLAN %} |
Dennis Dmitriev | f5bef57 | 2017-12-24 17:52:41 +0200 | [diff] [blame] | 500 | sed -i 's/tenant_vlan: .*/tenant_vlan: {{ TENANT_VLAN }}/g' {{ CLUSTER_CONTEXT_PATH }} |
sgudz | 8c888ec | 2017-10-02 15:29:23 +0300 | [diff] [blame] | 501 | {%- endif %} |
Dennis Dmitriev | a5f38e4 | 2017-09-21 21:52:25 +0300 | [diff] [blame] | 502 | |
Dennis Dmitriev | a5f38e4 | 2017-09-21 21:52:25 +0300 | [diff] [blame] | 503 | # Replace firstly to an intermediate value to avoid intersection between |
| 504 | # already replaced and replacing networks. |
| 505 | # For example, if generated IPV4_NET_ADMIN_PREFIX=10.16.0 , then there is a risk of replacing twice: |
| 506 | # 192.168.10 -> 10.16.0 (generated network for admin) |
| 507 | # 10.16.0 -> <external network> |
| 508 | # So let's replace constant networks to the keywords, and then keywords to the desired networks. |
Dennis Dmitriev | 30841c3 | 2018-07-19 20:12:07 +0300 | [diff] [blame] | 509 | export REPLACE_DIRS="{{ CLUSTER_CONTEXT_PATH }} /root/cookiecutter-templates" |
Dennis Dmitriev | 0f624a8 | 2018-06-11 12:57:13 +0300 | [diff] [blame] | 510 | find ${REPLACE_DIRS} -type f -exec sed -i 's/10\.167\.5/==IPV4_NET_ADMIN_PREFIX==/g' {} + |
| 511 | find ${REPLACE_DIRS} -type f -exec sed -i 's/10\.167\.4/==IPV4_NET_CONTROL_PREFIX==/g' {} + |
| 512 | find ${REPLACE_DIRS} -type f -exec sed -i 's/10\.167\.6/==IPV4_NET_TENANT_PREFIX==/g' {} + |
| 513 | find ${REPLACE_DIRS} -type f -exec sed -i 's/172\.17\.16/==IPV4_NET_EXTERNAL_PREFIX==/g' {} + |
Dennis Dmitriev | a5f38e4 | 2017-09-21 21:52:25 +0300 | [diff] [blame] | 514 | |
Dennis Dmitriev | 0f624a8 | 2018-06-11 12:57:13 +0300 | [diff] [blame] | 515 | find ${REPLACE_DIRS} -type f -exec sed -i 's/==IPV4_NET_ADMIN_PREFIX==/{{ IPV4_NET_ADMIN_PREFIX }}/g' {} + |
| 516 | find ${REPLACE_DIRS} -type f -exec sed -i 's/==IPV4_NET_CONTROL_PREFIX==/{{ IPV4_NET_CONTROL_PREFIX }}/g' {} + |
| 517 | find ${REPLACE_DIRS} -type f -exec sed -i 's/==IPV4_NET_TENANT_PREFIX==/{{ IPV4_NET_TENANT_PREFIX }}/g' {} + |
| 518 | find ${REPLACE_DIRS} -type f -exec sed -i 's/==IPV4_NET_EXTERNAL_PREFIX==/{{ IPV4_NET_EXTERNAL_PREFIX }}/g' {} + |
Dennis Dmitriev | a5f38e4 | 2017-09-21 21:52:25 +0300 | [diff] [blame] | 519 | |
Dennis Dmitriev | 30841c3 | 2018-07-19 20:12:07 +0300 | [diff] [blame] | 520 | {% set items = CLUSTER_PRODUCT_MODELS or '$(ls /root/cookiecutter-templates/cluster_product/)' %} |
Dmitry Tyzhnenko | fcb4dab | 2019-03-05 20:11:59 +0200 | [diff] [blame] | 521 | mkdir -p /tmp/output /srv/salt/reclass/classes/cluster/{{ CLUSTER_NAME }}/ |
Tatyana Leontovich | 1192aa4 | 2019-03-25 14:11:27 +0200 | [diff] [blame] | 522 | # Allow to use encryption keys |
| 523 | export GNUPGHOME=/etc/salt/gpgkeys |
sgudz | 160b730 | 2017-12-22 17:01:10 +0200 | [diff] [blame] | 524 | for item in {{ items }}; do |
Dmitry Tyzhnenko | fcb4dab | 2019-03-05 20:11:59 +0200 | [diff] [blame] | 525 | [ "$item" = "stacklight2" ] && continue; |
Dennis Dmitriev | 30841c3 | 2018-07-19 20:12:07 +0300 | [diff] [blame] | 526 | python /root/cookiecutter-templates/generate.py \ |
| 527 | --template /root/cookiecutter-templates/cluster_product/$item \ |
Dennis Dmitriev | a5f38e4 | 2017-09-21 21:52:25 +0300 | [diff] [blame] | 528 | --config-file {{ CLUSTER_CONTEXT_PATH }} \ |
Dmitry Tyzhnenko | fcb4dab | 2019-03-05 20:11:59 +0200 | [diff] [blame] | 529 | --output-dir /tmp/output/$item/; |
| 530 | mv -v /tmp/output/$item/{{ CLUSTER_NAME }}/$item /srv/salt/reclass/classes/cluster/{{ CLUSTER_NAME }}/; |
Dennis Dmitriev | a5f38e4 | 2017-09-21 21:52:25 +0300 | [diff] [blame] | 531 | done |
| 532 | |
Dennis Dmitriev | 96e1020 | 2018-07-03 09:55:56 +0300 | [diff] [blame] | 533 | export GIT_SSL_NO_VERIFY=true; git clone {{ SALT_MODELS_SYSTEM_REPOSITORY }} /srv/salt/reclass/classes/system/ |
Dennis Dmitriev | a5f38e4 | 2017-09-21 21:52:25 +0300 | [diff] [blame] | 534 | |
Dennis Dmitriev | 97e78e2 | 2018-02-23 21:51:49 +0200 | [diff] [blame] | 535 | # Create the cfg01 inventory file or use existing |
| 536 | export CFG01_INVENTORY_FILE="/srv/salt/reclass/nodes/_generated/cfg01.{{ DOMAIN_NAME }}.yml" |
| 537 | [ -f ${CFG01_INVENTORY_FILE} ] || cat << 'EOF' > ${CFG01_INVENTORY_FILE} |
Dennis Dmitriev | a5f38e4 | 2017-09-21 21:52:25 +0300 | [diff] [blame] | 538 | classes: |
| 539 | - system.openssh.server.team.all |
Dennis Dmitriev | bdb2b9b | 2017-12-22 18:00:18 +0200 | [diff] [blame] | 540 | - cluster.{{ CLUSTER_NAME }}.infra.config |
Dennis Dmitriev | a5f38e4 | 2017-09-21 21:52:25 +0300 | [diff] [blame] | 541 | EOF |
| 542 | |
| 543 | node_name: {{ HOSTNAME_CFG01 }} |
| 544 | retry: {count: 1, delay: 1} |
| 545 | skip_fail: false |
| 546 | |
Dennis Dmitriev | a5f38e4 | 2017-09-21 21:52:25 +0300 | [diff] [blame] | 547 | - description: Modify generated model and reclass-system if necessary |
| 548 | cmd: | |
| 549 | set -e; |
Dennis Dmitriev | 468ce35 | 2018-08-14 13:23:31 +0300 | [diff] [blame] | 550 | set -x; |
Hanna Arhipova | 7b2e81b | 2021-09-27 14:11:53 +0300 | [diff] [blame] | 551 | |
| 552 | {%- if SALT_MODELS_SYSTEM_COMMIT != '' %} |
Dennis Dmitriev | ee5ef23 | 2018-08-31 13:53:18 +0300 | [diff] [blame] | 553 | pushd /srv/salt/reclass/classes/system/ |
| 554 | git checkout {{ SALT_MODELS_SYSTEM_COMMIT }}; |
| 555 | popd; |
Dennis Dmitriev | 5f9cf2e | 2018-07-03 10:36:00 +0300 | [diff] [blame] | 556 | {%- elif SALT_MODELS_SYSTEM_TAG != '' %} |
| 557 | pushd /srv/salt/reclass/classes/system/ |
| 558 | git fetch --all --tags --prune |
| 559 | git checkout tags/{{ SALT_MODELS_SYSTEM_TAG }}; |
| 560 | popd; |
Dennis Dmitriev | a5f38e4 | 2017-09-21 21:52:25 +0300 | [diff] [blame] | 561 | {%- endif %} |
| 562 | |
Hanna Arhipova | 7b2e81b | 2021-09-27 14:11:53 +0300 | [diff] [blame] | 563 | {%- if SALT_MODELS_SYSTEM_REF_CHANGE != '' %} |
| 564 | pushd /srv/salt/reclass/classes/system/ && \ |
| 565 | {%- for item in SALT_MODELS_SYSTEM_REF_CHANGE.split(" ") %} |
| 566 | git fetch {{ SALT_MODELS_SYSTEM_REPOSITORY }} {{ item }} && git cherry-pick FETCH_HEAD; |
| 567 | {%- endfor %} |
| 568 | popd; |
| 569 | {%- endif %} |
| 570 | |
Dennis Dmitriev | a5f38e4 | 2017-09-21 21:52:25 +0300 | [diff] [blame] | 571 | {%- if IS_CONTRAIL_LAB %} |
Dennis Dmitriev | 862f775 | 2018-01-19 17:12:11 +0200 | [diff] [blame] | 572 | export REPLACE_DIRS="/srv/salt/reclass/classes/ /srv/salt/reclass/nodes/" |
Dennis Dmitriev | a5f38e4 | 2017-09-21 21:52:25 +0300 | [diff] [blame] | 573 | # vSRX IPs for tcp-qa images have 172.16.10.90 hardcoded |
| 574 | find ${REPLACE_DIRS} -type f -exec sed -i 's/opencontrail_router01_address:.*/opencontrail_router01_address: 172.16.10.90/g' {} + |
| 575 | find ${REPLACE_DIRS} -type f -exec sed -i 's/infra_config_deploy_address: 1.*/infra_config_deploy_address: {{ IPV4_NET_ADMIN_PREFIX }}.15/g' {} + |
| 576 | {%- endif %} |
| 577 | |
| 578 | node_name: {{ HOSTNAME_CFG01 }} |
| 579 | retry: {count: 1, delay: 1} |
| 580 | skip_fail: false |
Tatyana Leontovich | 4453dd6 | 2018-06-26 18:44:31 +0300 | [diff] [blame] | 581 | |
| 582 | - description: Restart salt-api |
| 583 | cmd: | |
| 584 | set -e; |
| 585 | systemctl restart salt-api |
| 586 | |
| 587 | node_name: {{ HOSTNAME_CFG01 }} |
| 588 | retry: {count: 1, delay: 1} |
| 589 | skip_fail: false |
Dennis Dmitriev | a5f38e4 | 2017-09-21 21:52:25 +0300 | [diff] [blame] | 590 | {%- endmacro %} |
| 591 | |
| 592 | |
Taras Khlivnyak | b68630b | 2021-04-26 23:24:56 +0300 | [diff] [blame] | 593 | {%- macro MACRO_GENERATE_AND_ENABLE_ENVIRONMENT_MODEL(KNOWN_HOST_AUTOPOPULATION=true) %} |
Dennis Dmitriev | 9f141af | 2017-09-28 17:21:01 +0300 | [diff] [blame] | 594 | {########################################################} |
Dennis Dmitriev | ccdc87a | 2017-09-28 17:43:54 +0300 | [diff] [blame] | 595 | |
Dennis Dmitriev | 92295c0 | 2018-02-02 13:18:25 +0200 | [diff] [blame] | 596 | - description: "[EXPERIMENTAL] Clone 'environment-template' repository to cfg01.{{ DOMAIN_NAME }}" |
Dennis Dmitriev | 9e18de7 | 2017-10-11 18:14:36 +0300 | [diff] [blame] | 597 | cmd: | |
| 598 | set -e; |
Dennis Dmitriev | 30841c3 | 2018-07-19 20:12:07 +0300 | [diff] [blame] | 599 | mkdir -p /root/environment/; |
Hanna Arhipova | 5173aad | 2019-11-11 12:42:31 +0200 | [diff] [blame] | 600 | export GIT_SSL_NO_VERIFY=true; git clone https://gerrit.mcp.mirantis.com/mcp/tcp-qa-environment-template /root/environment/environment_template |
Dennis Dmitriev | 9f141af | 2017-09-28 17:21:01 +0300 | [diff] [blame] | 601 | |
Vladimir Khlyunev | f337c90 | 2018-12-06 12:29:24 +0400 | [diff] [blame] | 602 | {%- if ENVIRONMENT_TEMPLATE_REF_CHANGE != '' %} |
Dennis Dmitriev | 30841c3 | 2018-07-19 20:12:07 +0300 | [diff] [blame] | 603 | pushd /root/environment/environment_template && |
Hanna Arhipova | e635722 | 2020-01-08 19:55:27 +0200 | [diff] [blame] | 604 | git fetch https://gerrit.mcp.mirantis.com/mcp/tcp-qa-environment-template {{ ENVIRONMENT_TEMPLATE_REF_CHANGE }} && |
sgudz | cced67d | 2017-10-11 15:56:09 +0300 | [diff] [blame] | 605 | git checkout FETCH_HEAD && |
| 606 | popd |
Vladimir Khlyunev | f337c90 | 2018-12-06 12:29:24 +0400 | [diff] [blame] | 607 | {%- elif ENVIRONMENT_TEMPLATE_COMMIT != '' %} |
| 608 | pushd /root/environment/environment_template |
| 609 | git checkout {{ ENVIRONMENT_TEMPLATE_COMMIT }} |
| 610 | popd |
| 611 | {%- endif %} |
| 612 | |
sgudz | cced67d | 2017-10-11 15:56:09 +0300 | [diff] [blame] | 613 | node_name: {{ HOSTNAME_CFG01 }} |
| 614 | skip_fail: false |
sgudz | cced67d | 2017-10-11 15:56:09 +0300 | [diff] [blame] | 615 | |
Dennis Dmitriev | ccdc87a | 2017-09-28 17:43:54 +0300 | [diff] [blame] | 616 | {%- for ENVIRONMENT_CONTEXT_NAME in ENVIRONMENT_CONTEXT_NAMES %} |
Dennis Dmitriev | 92295c0 | 2018-02-02 13:18:25 +0200 | [diff] [blame] | 617 | - description: "[EXPERIMENTAL] Upload environment inventory to cfg01.{{ DOMAIN_NAME }}" |
Dennis Dmitriev | 9f141af | 2017-09-28 17:21:01 +0300 | [diff] [blame] | 618 | upload: |
| 619 | local_path: {{ config.salt_deploy.templates_dir }}{{ LAB_CONFIG_NAME }}/ |
| 620 | local_filename: {{ ENVIRONMENT_CONTEXT_NAME }} |
Dennis Dmitriev | 30841c3 | 2018-07-19 20:12:07 +0300 | [diff] [blame] | 621 | remote_path: /root/environment/ |
Dennis Dmitriev | 9f141af | 2017-09-28 17:21:01 +0300 | [diff] [blame] | 622 | node_name: {{ HOSTNAME_CFG01 }} |
Dennis Dmitriev | ccdc87a | 2017-09-28 17:43:54 +0300 | [diff] [blame] | 623 | {%- endfor %} |
Dennis Dmitriev | 9f141af | 2017-09-28 17:21:01 +0300 | [diff] [blame] | 624 | |
Dennis Dmitriev | 1ddf647 | 2018-11-25 22:30:12 +0200 | [diff] [blame] | 625 | - description: "Replace template addresses to actual environment addresses" |
| 626 | cmd: | |
| 627 | set -ex; |
| 628 | # Replace firstly to an intermediate value to avoid intersection between |
| 629 | # already replaced and replacing networks. |
| 630 | # For example, if generated IPV4_NET_ADMIN_PREFIX=10.16.0 , then there is a risk of replacing twice: |
| 631 | # 192.168.10 -> 10.16.0 (generated network for admin) |
| 632 | # 10.16.0 -> <external network> |
| 633 | # So let's replace constant networks to the keywords, and then keywords to the desired networks. |
| 634 | export REPLACE_DIRS="/root/environment/" |
| 635 | find ${REPLACE_DIRS} -type f -exec sed -i 's/10\.167\.5/==IPV4_NET_ADMIN_PREFIX==/g' {} + |
| 636 | find ${REPLACE_DIRS} -type f -exec sed -i 's/10\.167\.4/==IPV4_NET_CONTROL_PREFIX==/g' {} + |
| 637 | find ${REPLACE_DIRS} -type f -exec sed -i 's/10\.167\.6/==IPV4_NET_TENANT_PREFIX==/g' {} + |
| 638 | find ${REPLACE_DIRS} -type f -exec sed -i 's/172\.17\.16/==IPV4_NET_EXTERNAL_PREFIX==/g' {} + |
| 639 | |
| 640 | find ${REPLACE_DIRS} -type f -exec sed -i 's/==IPV4_NET_ADMIN_PREFIX==/{{ IPV4_NET_ADMIN_PREFIX }}/g' {} + |
| 641 | find ${REPLACE_DIRS} -type f -exec sed -i 's/==IPV4_NET_CONTROL_PREFIX==/{{ IPV4_NET_CONTROL_PREFIX }}/g' {} + |
| 642 | find ${REPLACE_DIRS} -type f -exec sed -i 's/==IPV4_NET_TENANT_PREFIX==/{{ IPV4_NET_TENANT_PREFIX }}/g' {} + |
| 643 | find ${REPLACE_DIRS} -type f -exec sed -i 's/==IPV4_NET_EXTERNAL_PREFIX==/{{ IPV4_NET_EXTERNAL_PREFIX }}/g' {} + |
| 644 | node_name: {{ HOSTNAME_CFG01 }} |
| 645 | retry: {count: 1, delay: 5} |
| 646 | skip_fail: false |
| 647 | |
Dennis Dmitriev | 9f141af | 2017-09-28 17:21:01 +0300 | [diff] [blame] | 648 | - description: "[EXPERIMENTAL] Remove linux.network.interface object from the cluster/system models and use fixed 'environment' model instead" |
| 649 | cmd: | |
| 650 | set -e; |
Dennis Dmitriev | 468ce35 | 2018-08-14 13:23:31 +0300 | [diff] [blame] | 651 | set -x; |
Dennis Dmitriev | 9f141af | 2017-09-28 17:21:01 +0300 | [diff] [blame] | 652 | apt-get -y install python-virtualenv python-pip build-essential python-dev libssl-dev; |
Dennis Dmitriev | d96ace1 | 2018-01-26 14:46:21 +0200 | [diff] [blame] | 653 | [[ -d /root/venv-reclass-tools ]] || virtualenv /root/venv-reclass-tools; |
| 654 | . /root/venv-reclass-tools/bin/activate; |
Hanna Arhipova | d33353e | 2021-02-15 23:14:51 +0200 | [diff] [blame] | 655 | pip install git+https://gerrit.mcp.mirantis.com/mcp/tcp-qa-reclass-tools; |
Dennis Dmitriev | 9f141af | 2017-09-28 17:21:01 +0300 | [diff] [blame] | 656 | reclass-tools del-key parameters.linux.network.interface /srv/salt/reclass/classes/cluster/; |
| 657 | reclass-tools del-key parameters.linux.network.interface /srv/salt/reclass/classes/system/; |
| 658 | reclass-tools del-key parameters.linux.network.interface /usr/share/salt-formulas/reclass/; |
| 659 | |
Dennis Dmitriev | 6368f08 | 2018-02-23 13:30:30 -0500 | [diff] [blame] | 660 | if ! reclass-tools get-key 'classes' /srv/salt/reclass/nodes/_generated/cfg01.{{ DOMAIN_NAME }}.yml | grep -q "environment.{{ ENVIRONMENT_MODEL_INVENTORY_NAME }}$"; then |
| 661 | reclass-tools add-key 'classes' 'environment.{{ ENVIRONMENT_MODEL_INVENTORY_NAME }}.reclass_datasource_local' /srv/salt/reclass/nodes/_generated/cfg01.{{ DOMAIN_NAME }}.yml --merge ; |
| 662 | reclass-tools add-key 'classes' 'environment.{{ ENVIRONMENT_MODEL_INVENTORY_NAME }}' /srv/salt/reclass/nodes/_generated/cfg01.{{ DOMAIN_NAME }}.yml --merge ; |
Dennis Dmitriev | 9f141af | 2017-09-28 17:21:01 +0300 | [diff] [blame] | 663 | fi; |
| 664 | |
| 665 | node_name: {{ HOSTNAME_CFG01 }} |
| 666 | retry: {count: 1, delay: 5} |
| 667 | skip_fail: false |
| 668 | |
Dennis Dmitriev | 222ba8e | 2017-11-11 00:06:02 +0200 | [diff] [blame] | 669 | - description: "Workaround for PROD-15923: all keepalive instances must be named 'VIP'" |
Dennis Dmitriev | 9f141af | 2017-09-28 17:21:01 +0300 | [diff] [blame] | 670 | cmd: | |
| 671 | set -e; |
Dennis Dmitriev | 222ba8e | 2017-11-11 00:06:02 +0200 | [diff] [blame] | 672 | find /srv/salt/reclass/classes/{system,cluster}/ -name '*.yml' -type f -exec sed -ri '/^ keepalived:/{:1;N;/\n instance:/!b1 {N; /\n [[:graph:]]+:/ { s/\n instance:\n [[:graph:]]+:/\n instance:\n VIP:/ } } }' {} + |
Dennis Dmitriev | 9f141af | 2017-09-28 17:21:01 +0300 | [diff] [blame] | 673 | |
| 674 | node_name: {{ HOSTNAME_CFG01 }} |
| 675 | retry: {count: 1, delay: 5} |
| 676 | skip_fail: false |
| 677 | |
| 678 | - description: "[EXPERIMENTAL] Create environment model for virtual environment" |
| 679 | cmd: | |
| 680 | set -e; |
Dennis Dmitriev | 468ce35 | 2018-08-14 13:23:31 +0300 | [diff] [blame] | 681 | set -x; |
Dennis Dmitriev | d96ace1 | 2018-01-26 14:46:21 +0200 | [diff] [blame] | 682 | . /root/venv-reclass-tools/bin/activate; |
Dennis Dmitriev | 30841c3 | 2018-07-19 20:12:07 +0300 | [diff] [blame] | 683 | reclass-tools render --template-dir /root/environment/environment_template/ \ |
Dennis Dmitriev | 9f141af | 2017-09-28 17:21:01 +0300 | [diff] [blame] | 684 | --output-dir /srv/salt/reclass/classes/environment/ \ |
Dennis Dmitriev | 30841c3 | 2018-07-19 20:12:07 +0300 | [diff] [blame] | 685 | {% for ENVIRONMENT_CONTEXT_NAME in ENVIRONMENT_CONTEXT_NAMES %} --context /root/environment/{{ENVIRONMENT_CONTEXT_NAME}}{% endfor %} \ |
Dennis Dmitriev | 9f141af | 2017-09-28 17:21:01 +0300 | [diff] [blame] | 686 | --env-name {{ ENVIRONMENT_MODEL_INVENTORY_NAME }} |
| 687 | node_name: {{ HOSTNAME_CFG01 }} |
| 688 | retry: {count: 1, delay: 5} |
| 689 | skip_fail: false |
sgudz | 8c888ec | 2017-10-02 15:29:23 +0300 | [diff] [blame] | 690 | |
Taras Khlivnyak | b68630b | 2021-04-26 23:24:56 +0300 | [diff] [blame] | 691 | - description: "[EXPERIMENTAL] Disable known_host_autopopulation if its not enabled" |
| 692 | cmd: | |
| 693 | {%- if not KNOWN_HOST_AUTOPOPULATION %} |
| 694 | set -e; |
| 695 | set -x; |
| 696 | . /root/venv-reclass-tools/bin/activate; |
| 697 | reclass-tools add-bool-key parameters.reclass.storage.node.infra_config_node01.parameters.openssh.client.known_hosts_autopopulation false /srv/salt/reclass/classes/environment/{{ ENVIRONMENT_MODEL_INVENTORY_NAME }}/init.yml |
| 698 | {%- endif %} |
| 699 | node_name: {{ HOSTNAME_CFG01 }} |
| 700 | retry: {count: 1, delay: 5} |
| 701 | skip_fail: false |
| 702 | |
sgudz | 8c888ec | 2017-10-02 15:29:23 +0300 | [diff] [blame] | 703 | - description: Modify generated model and reclass-system |
| 704 | cmd: | |
| 705 | export REPLACE_DIRS="/srv/salt/reclass/classes/ /srv/salt/reclass/nodes/" |
| 706 | find ${REPLACE_DIRS} -type f -exec sed -i 's/apt_mk_version:.*/apt_mk_version: {{ REPOSITORY_SUITE }}/g' {} + |
Victor Ryzhenkin | e784bbf | 2018-12-21 03:58:00 +0400 | [diff] [blame] | 707 | find ${REPLACE_DIRS} -type f -exec sed -i 's/mcp_version:.*/mcp_version: {{ REPOSITORY_SUITE }}/g' {} + |
sgudz | 8c888ec | 2017-10-02 15:29:23 +0300 | [diff] [blame] | 708 | node_name: {{ HOSTNAME_CFG01 }} |
| 709 | retry: {count: 1, delay: 1} |
| 710 | skip_fail: false |
| 711 | |
sgudz | b795338 | 2019-02-18 17:59:30 +0200 | [diff] [blame] | 712 | {%- if UPDATE_REPO_CUSTOM_TAG != '' %} |
Hanna Arhipova | aad914c | 2020-04-13 17:10:20 +0300 | [diff] [blame] | 713 | - description: "[EXPERIMENTAL] Change update repos tag according to defined in job" |
sgudz | b795338 | 2019-02-18 17:59:30 +0200 | [diff] [blame] | 714 | cmd: | |
| 715 | . /root/venv-reclass-tools/bin/activate; |
| 716 | reclass-tools add-key parameters._param.linux_system_repo_update_url 'http://mirror.mirantis.com/update/{{ UPDATE_REPO_CUSTOM_TAG }}/' /srv/salt/reclass/classes/cluster/{{ CLUSTER_NAME }}/openstack/init.yml; |
sgudz | b795338 | 2019-02-18 17:59:30 +0200 | [diff] [blame] | 717 | node_name: {{ HOSTNAME_CFG01 }} |
| 718 | retry: {count: 1, delay: 5} |
| 719 | skip_fail: false |
| 720 | {%- endif %} |
| 721 | |
Dennis Dmitriev | 9f141af | 2017-09-28 17:21:01 +0300 | [diff] [blame] | 722 | {%- endmacro %} |
| 723 | |
| 724 | |
Dennis Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame] | 725 | {%- macro MACRO_CONFIGURE_RECLASS(FORMULA_SERVICES='') %} |
| 726 | {#######################################################} |
| 727 | - description: Configure reclass |
| 728 | cmd: | |
Dennis Dmitriev | 3e731a4 | 2017-08-30 17:12:59 +0300 | [diff] [blame] | 729 | set -e; |
Dennis Dmitriev | 468ce35 | 2018-08-14 13:23:31 +0300 | [diff] [blame] | 730 | set -x; |
Dennis Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame] | 731 | FORMULA_PATH=${FORMULA_PATH:-/usr/share/salt-formulas}; |
Dennis Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame] | 732 | which wget > /dev/null || (apt-get update; apt-get install -y wget); |
Dennis Dmitriev | cf77780 | 2018-02-14 18:09:55 +0200 | [diff] [blame] | 733 | . /etc/lsb-release; # Get DISTRIB_CODENAME variable |
Dennis Dmitriev | 3fbbc7f | 2017-12-21 15:42:14 +0200 | [diff] [blame] | 734 | echo "{{ FORMULA_REPOSITORY }}" > /etc/apt/sources.list.d/mcp_salt.list; |
| 735 | wget -O - "{{ FORMULA_GPG }}" | apt-key add -; |
Dennis Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame] | 736 | apt-get clean; apt-get update; |
| 737 | [ ! -d /srv/salt/reclass/classes/service ] && mkdir -p /srv/salt/reclass/classes/service; |
| 738 | declare -a formula_services=({{ FORMULA_SERVICES }}); |
| 739 | echo -e "\nInstalling all required salt formulas\n"; |
Dennis Dmitriev | 01d5e37 | 2018-03-15 23:29:29 +0200 | [diff] [blame] | 740 | apt-get install -y "${formula_services[@]/#/salt-formula-}"; |
Dennis Dmitriev | 3d28aa3 | 2018-07-04 16:14:59 +0300 | [diff] [blame] | 741 | for formula_service in $(ls -1 ${FORMULA_PATH}/reclass/service); do |
Dennis Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame] | 742 | echo -e "\nLink service metadata for formula ${formula_service} ...\n"; |
| 743 | [ ! -L "/srv/salt/reclass/classes/service/${formula_service}" ] && ln -s ${FORMULA_PATH}/reclass/service/${formula_service} /srv/salt/reclass/classes/service/${formula_service}; |
| 744 | done; |
| 745 | [ ! -d /srv/salt/env ] && mkdir -p /srv/salt/env; |
| 746 | [ ! -L /srv/salt/env/prd ] && ln -s ${FORMULA_PATH}/env /srv/salt/env/prd; |
| 747 | [ ! -d /etc/reclass ] && mkdir /etc/reclass; |
| 748 | |
Dennis Dmitriev | a578c77 | 2018-01-24 21:02:15 +0200 | [diff] [blame] | 749 | cat << 'EOF' > /etc/reclass/reclass-config.yml |
Dennis Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame] | 750 | storage_type: yaml_fs |
| 751 | pretty_print: True |
| 752 | output: yaml |
| 753 | inventory_base_uri: /srv/salt/reclass |
| 754 | EOF |
| 755 | node_name: {{ HOSTNAME_CFG01 }} |
| 756 | retry: {count: 1, delay: 1} |
| 757 | skip_fail: false |
| 758 | |
Dennis Dmitriev | 92295c0 | 2018-02-02 13:18:25 +0200 | [diff] [blame] | 759 | - description: "*Workaround* remove all cfg01 nodes except cfg01.{{ DOMAIN_NAME }} to not depend on other clusters in 'reclass --top'" |
Dennis Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame] | 760 | cmd: | |
Dennis Dmitriev | 92295c0 | 2018-02-02 13:18:25 +0200 | [diff] [blame] | 761 | # Remove all other nodes except cfg01.{{ DOMAIN_NAME }} to not rely on them for 'reclass --top' |
| 762 | find /srv/salt/reclass/nodes/ -type f -not -name cfg01.{{ DOMAIN_NAME }}.yml -delete |
Dennis Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame] | 763 | node_name: {{ HOSTNAME_CFG01 }} |
| 764 | retry: {count: 1, delay: 5} |
| 765 | skip_fail: false |
| 766 | |
| 767 | - description: Configure salt adoptors on cfg01 |
| 768 | cmd: | |
| 769 | ln -s /usr/lib/python2.7/dist-packages/reclass/adapters/salt.py /usr/local/sbin/reclass-salt; |
| 770 | chmod +x /usr/lib/python2.7/dist-packages/reclass/adapters/salt.py |
| 771 | node_name: {{ HOSTNAME_CFG01 }} |
| 772 | retry: {count: 1, delay: 1} |
| 773 | skip_fail: false |
| 774 | |
| 775 | - description: Show reclass-salt --top for cfg01 node |
| 776 | cmd: reclass-salt --top |
| 777 | node_name: {{ HOSTNAME_CFG01 }} |
| 778 | retry: {count: 1, delay: 5} |
| 779 | skip_fail: false |
| 780 | |
| 781 | - description: Restart salt-master service |
ibumarskov | 712a687 | 2018-04-25 09:22:15 +0400 | [diff] [blame] | 782 | cmd: service salt-master restart; |
Dennis Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame] | 783 | node_name: {{ HOSTNAME_CFG01 }} |
| 784 | retry: {count: 1, delay: 5} |
| 785 | skip_fail: false |
| 786 | {%- endmacro %} |
| 787 | |
| 788 | |
| 789 | {%- macro MACRO_INSTALL_SALT_MINIONS() %} |
| 790 | {#######################################} |
Dennis Dmitriev | 5bcbdc5 | 2018-03-23 18:05:10 +0200 | [diff] [blame] | 791 | {%- for ssh in config.underlay.ssh %} |
| 792 | {%- set salt_roles = [] %} |
| 793 | {%- for role in ssh['roles'] %} |
| 794 | {%- if role in config.salt_deploy.salt_roles %} |
| 795 | {%- set _ = salt_roles.append(role) %} |
| 796 | {%- endif %} |
| 797 | {%- endfor %} |
| 798 | |
| 799 | {%- if salt_roles %} |
Dennis Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame] | 800 | - description: Configure salt-minion on {{ ssh['node_name'] }} |
| 801 | cmd: | |
Dennis Dmitriev | 468ce35 | 2018-08-14 13:23:31 +0300 | [diff] [blame] | 802 | set -ex; |
Dennis Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame] | 803 | [ ! -d /etc/salt/minion.d ] && mkdir -p /etc/salt/minion.d; |
Dennis Dmitriev | 3fe24dd | 2018-07-20 18:38:57 +0300 | [diff] [blame] | 804 | cat << EOF > /etc/salt/minion.d/minion.conf |
| 805 | id: $(hostname -s).{{ DOMAIN_NAME }} |
Dennis Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame] | 806 | master: {{ config.salt.salt_master_host }} |
| 807 | EOF |
Dennis Dmitriev | cf77780 | 2018-02-14 18:09:55 +0200 | [diff] [blame] | 808 | |
| 809 | # Configure ubuntu and salt repositories |
| 810 | which wget >/dev/null || (apt-get update; apt-get install -y wget); |
| 811 | |
| 812 | . /etc/lsb-release; # Get DISTRIB_CODENAME variable |
| 813 | echo "{{ UBUNTU_REPOSITORY }}" > /etc/apt/sources.list |
| 814 | echo "{{ UBUNTU_UPDATES_REPOSITORY }}" >> /etc/apt/sources.list |
| 815 | echo "{{ UBUNTU_SECURITY_REPOSITORY }}" >> /etc/apt/sources.list |
| 816 | |
| 817 | echo "{{ SALT_REPOSITORY }}" > /etc/apt/sources.list.d/mcp_saltstack.list; |
Tatyana Leontovich | 908ab93 | 2018-04-27 01:25:09 +0300 | [diff] [blame] | 818 | apt-key adv --keyserver "{{UBUNTU_KEY_SERVER}}" --recv-keys "{{ UBUNTU_KEY_ID}}" |
| 819 | |
Dennis Dmitriev | cf77780 | 2018-02-14 18:09:55 +0200 | [diff] [blame] | 820 | |
| 821 | apt-get clean |
| 822 | apt-get update |
| 823 | |
| 824 | # Install salt-minion |
Tatyana Leontovich | 4770855 | 2018-12-19 16:36:09 +0200 | [diff] [blame] | 825 | apt-get install eatmydata -y; |
Dennis Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame] | 826 | eatmydata apt-get install -y salt-minion; |
Dennis Dmitriev | cf77780 | 2018-02-14 18:09:55 +0200 | [diff] [blame] | 827 | # Install common packages |
| 828 | eatmydata apt-get install -y python-pip git curl tmux byobu iputils-ping traceroute htop tree mc |
Dennis Dmitriev | 01d5e37 | 2018-03-15 23:29:29 +0200 | [diff] [blame] | 829 | sync |
Dennis Dmitriev | cf77780 | 2018-02-14 18:09:55 +0200 | [diff] [blame] | 830 | # Restart salt-minion if it was already installed |
| 831 | service salt-minion restart |
Dennis Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame] | 832 | node_name: {{ ssh['node_name'] }} |
Hanna Arhipova | 79ae9ec | 2020-01-27 14:32:17 +0200 | [diff] [blame] | 833 | retry: {count: 3, delay: 10} |
Dennis Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame] | 834 | skip_fail: false |
Dennis Dmitriev | 5bcbdc5 | 2018-03-23 18:05:10 +0200 | [diff] [blame] | 835 | {%- else %} |
| 836 | - description: Check SSH connectivity to non-salt-minion node {{ ssh['node_name'] }} |
| 837 | cmd: echo "SSH to $(hostname -f) passed" |
| 838 | node_name: {{ ssh['node_name'] }} |
Hanna Arhipova | 79ae9ec | 2020-01-27 14:32:17 +0200 | [diff] [blame] | 839 | retry: {count: 3, delay: 10} |
Dennis Dmitriev | 5bcbdc5 | 2018-03-23 18:05:10 +0200 | [diff] [blame] | 840 | skip_fail: false |
| 841 | {%- endif %} |
Dennis Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame] | 842 | |
Dennis Dmitriev | 5bcbdc5 | 2018-03-23 18:05:10 +0200 | [diff] [blame] | 843 | {%- endfor %} |
Dennis Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame] | 844 | |
| 845 | - description: Accept salt keys from all the nodes |
| 846 | cmd: salt-key -A -y |
| 847 | node_name: {{ HOSTNAME_CFG01 }} |
| 848 | retry: {count: 1, delay: 5} |
| 849 | skip_fail: true |
Hanna Arhipova | 54fec80 | 2020-10-30 12:45:46 +0200 | [diff] [blame] | 850 | |
Dennis Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame] | 851 | {%- endmacro %} |
| 852 | |
| 853 | |
Hanna Arhipova | 54fec80 | 2020-10-30 12:45:46 +0200 | [diff] [blame] | 854 | |
| 855 | {%- macro DISABLE_EMPTY_NODE() %} |
| 856 | {#######################################} |
| 857 | {%- for ssh in config.underlay.ssh %} |
| 858 | {%- set none_roles = [] %} |
| 859 | {%- for role in ssh['roles'] %} |
| 860 | {%- if role == "none" %} |
| 861 | {%- set _ = none_roles.append(role) %} |
| 862 | {%- endif %} |
| 863 | {%- endfor %} |
| 864 | |
| 865 | {%- if none_roles %} |
| 866 | - description: Move non-product node out of Salt Cluster ( {{ ssh['node_name'] }} ) |
| 867 | cmd: | |
| 868 | set -ex; |
| 869 | # Use salt-key -a {{ ssh['node_name'] }} --include-all -y command to return node back |
| 870 | salt-key -r {{ ssh['node_name'] }} --include-all -y |
| 871 | node_name: {{ HOSTNAME_CFG01 }} |
| 872 | retry: { count: 1, delay: 5 } |
| 873 | skip_fail: true |
| 874 | {%- endif %} |
| 875 | {%- endfor %} |
| 876 | {%- endmacro %} |
| 877 | |
| 878 | |
| 879 | |
Dmitry Tyzhnenko | 35413c0 | 2018-03-05 14:12:37 +0200 | [diff] [blame] | 880 | {%- macro MACRO_INSTALL_FORMULAS(FORMULA_SERVICES='') %} |
| 881 | {#######################################################} |
Dennis Dmitriev | 3d28aa3 | 2018-07-04 16:14:59 +0300 | [diff] [blame] | 882 | - description: Install salt formulas |
Dmitry Tyzhnenko | 35413c0 | 2018-03-05 14:12:37 +0200 | [diff] [blame] | 883 | cmd: | |
| 884 | set -e; |
Dennis Dmitriev | 468ce35 | 2018-08-14 13:23:31 +0300 | [diff] [blame] | 885 | set -x; |
Dmitry Tyzhnenko | 35413c0 | 2018-03-05 14:12:37 +0200 | [diff] [blame] | 886 | FORMULA_PATH=${FORMULA_PATH:-/usr/share/salt-formulas}; |
| 887 | which wget > /dev/null || (apt-get update; apt-get install -y wget); |
| 888 | . /etc/lsb-release; # Get DISTRIB_CODENAME variable |
| 889 | # echo "{{ FORMULA_REPOSITORY }}" > /etc/apt/sources.list.d/mcp_salt.list; |
| 890 | # wget -O - "{{ FORMULA_GPG }}" | apt-key add -; |
| 891 | apt-get clean; apt-get update; |
| 892 | [ ! -d /srv/salt/reclass/classes/service ] && mkdir -p /srv/salt/reclass/classes/service; |
| 893 | declare -a formula_services=({{ FORMULA_SERVICES }}); |
| 894 | echo -e "\nInstalling all required salt formulas\n"; |
| 895 | eatmydata apt-get install -y "${formula_services[@]/#/salt-formula-}"; |
Dennis Dmitriev | 3d28aa3 | 2018-07-04 16:14:59 +0300 | [diff] [blame] | 896 | for formula_service in $(ls -1 ${FORMULA_PATH}/reclass/service); do |
Dmitry Tyzhnenko | 35413c0 | 2018-03-05 14:12:37 +0200 | [diff] [blame] | 897 | echo -e "\nLink service metadata for formula ${formula_service} ...\n"; |
| 898 | [ ! -L "/srv/salt/reclass/classes/service/${formula_service}" ] && ln -s ${FORMULA_PATH}/reclass/service/${formula_service} /srv/salt/reclass/classes/service/${formula_service}; |
| 899 | done; |
| 900 | node_name: {{ HOSTNAME_CFG01 }} |
| 901 | retry: {count: 1, delay: 1} |
| 902 | skip_fail: false |
Dennis Dmitriev | 010f029 | 2018-07-28 23:33:48 +0300 | [diff] [blame] | 903 | |
| 904 | - description: Sync all salt resources on salt-master minion |
| 905 | cmd: salt-call saltutil.sync_all && sleep 5 |
| 906 | node_name: {{ HOSTNAME_CFG01 }} |
| 907 | retry: {count: 1, delay: 5} |
| 908 | skip_fail: false |
Dmitry Tyzhnenko | 35413c0 | 2018-03-05 14:12:37 +0200 | [diff] [blame] | 909 | {%- endmacro %} |
| 910 | |
| 911 | {%- macro MACRO_CONFIG_DAY01_SALT_MINION() %} |
| 912 | {#######################################} |
| 913 | - description: Configure salt-minion on {{ HOSTNAME_CFG01 }} |
| 914 | cmd: | |
Dennis Dmitriev | 468ce35 | 2018-08-14 13:23:31 +0300 | [diff] [blame] | 915 | set -ex; |
Dmitry Tyzhnenko | 35413c0 | 2018-03-05 14:12:37 +0200 | [diff] [blame] | 916 | export SALT_MASTER_MINION_ID={{ HOSTNAME_CFG01 }} |
| 917 | envsubst < /root/minion.conf > /etc/salt/minion.d/minion.conf |
| 918 | service salt-minion restart |
| 919 | |
| 920 | while true; do |
| 921 | salt-key | grep "$SALT_MASTER_MINION_ID" && break |
| 922 | sleep 5 |
| 923 | done |
| 924 | |
| 925 | sleep 5 |
| 926 | |
| 927 | for i in `salt-key -l accepted | grep -v Accepted | grep -v "$SALT_MASTER_MINION_ID"`; do |
| 928 | salt-key -d $i -y |
| 929 | done |
| 930 | node_name: {{ HOSTNAME_CFG01 }} |
| 931 | retry: {count: 1, delay: 1} |
| 932 | skip_fail: false |
| 933 | {%- endmacro %} |
| 934 | |
| 935 | |
Dennis Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame] | 936 | {%- macro MACRO_RUN_SALT_MASTER_UNDERLAY_STATES() %} |
| 937 | {##################################################} |
| 938 | |
| 939 | {# Prepare salt services and nodes settings #} |
| 940 | |
sgudz | 6e79756 | 2018-10-22 12:27:09 +0300 | [diff] [blame] | 941 | - description: '*Workaround* of harcoded host from day01 grains' |
| 942 | cmd: salt-key -d cfg01.mcp-day01.local -y |
| 943 | node_name: {{ HOSTNAME_CFG01 }} |
| 944 | retry: {count: 1, delay: 1} |
| 945 | skip_fail: true |
| 946 | |
Dennis Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame] | 947 | - description: Run 'linux' formula on cfg01 |
| 948 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@salt:master' state.sls linux; |
| 949 | node_name: {{ HOSTNAME_CFG01 }} |
| 950 | retry: {count: 3, delay: 5} |
| 951 | skip_fail: false |
| 952 | |
| 953 | - description: Run 'openssh' formula on cfg01 |
| 954 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False |
Dennis Dmitriev | 3e731a4 | 2017-08-30 17:12:59 +0300 | [diff] [blame] | 955 | -C 'I@salt:master' state.sls openssh && |
Dennis Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame] | 956 | salt --hard-crash --state-output=mixed --state-verbose=False |
| 957 | -C 'I@salt:master' cmd.run "sed -i 's/PasswordAuthentication no/PasswordAuthentication |
Dennis Dmitriev | d260451 | 2018-06-04 05:34:44 +0300 | [diff] [blame] | 958 | yes/' /etc/ssh/sshd_config && service ssh reload" |
Dennis Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame] | 959 | node_name: {{ HOSTNAME_CFG01 }} |
| 960 | retry: {count: 3, delay: 5} |
| 961 | skip_fail: false |
| 962 | |
| 963 | - description: '*Workaround* of the bug https://mirantis.jira.com/browse/PROD-7962' |
| 964 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False |
| 965 | '*' cmd.run "echo ' StrictHostKeyChecking no' >> /root/.ssh/config" |
| 966 | node_name: {{ HOSTNAME_CFG01 }} |
| 967 | retry: {count: 1, delay: 1} |
| 968 | skip_fail: false |
| 969 | |
| 970 | - description: Run 'salt.master' formula on cfg01 |
Dennis Dmitriev | e575e98 | 2017-10-21 21:50:45 +0300 | [diff] [blame] | 971 | cmd: timeout 600 salt-call -l info --hard-crash --state-output=mixed --state-verbose=False state.sls salt.master; |
Dennis Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame] | 972 | node_name: {{ HOSTNAME_CFG01 }} |
Dennis Dmitriev | e575e98 | 2017-10-21 21:50:45 +0300 | [diff] [blame] | 973 | retry: {count: 2, delay: 30} |
Dennis Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame] | 974 | skip_fail: false |
| 975 | |
Victor Ryzhenkin | 4e077ad | 2017-08-10 13:42:11 +0400 | [diff] [blame] | 976 | {%- if SALT_FORMULAS_REFS != '' %} |
| 977 | - description: Replace needed formulas to desired version |
| 978 | cmd: | |
| 979 | set -e; |
Dennis Dmitriev | 468ce35 | 2018-08-14 13:23:31 +0300 | [diff] [blame] | 980 | set -x; |
Victor Ryzhenkin | c791368 | 2017-10-11 15:14:40 +0400 | [diff] [blame] | 981 | {%- for formula_set in SALT_FORMULAS_REFS.split(' ') %} |
| 982 | {% set formula = formula_set.split(':') %} |
| 983 | {% set formula_name = formula[0] %} |
| 984 | {% set formula_ref = formula[1] %} |
Dennis Dmitriev | bc57b80 | 2017-08-16 18:10:57 +0300 | [diff] [blame] | 985 | {% set formula_dir = '/tmp/salt-formula-' + formula_name %} |
Victor Ryzhenkin | 4e077ad | 2017-08-10 13:42:11 +0400 | [diff] [blame] | 986 | git clone {{ SALT_FORMULAS_REPO }}/{{ formula_name }} {{ formula_dir }} && |
| 987 | pushd {{ formula_dir }} && |
| 988 | git fetch {{ SALT_FORMULAS_REPO }}/{{ formula_name }} {{ formula_ref }} && |
| 989 | git checkout FETCH_HEAD && |
| 990 | popd && |
| 991 | if [ -d "{{ formula_dir }}" ]; then |
| 992 | echo "Going to replace packaged formula {{ formula_name }}" && |
| 993 | rm -rfv /usr/share/salt-formulas/{env,reclass/service}/{{ formula_name }} && |
Victor Ryzhenkin | c791368 | 2017-10-11 15:14:40 +0400 | [diff] [blame] | 994 | ln -v -s "{{ formula_dir }}/{{ formula_name }}" "/usr/share/salt-formulas/env/{{ formula_name }}" && |
| 995 | ln -v -s "{{ formula_dir }}/metadata/service/" "/usr/share/salt-formulas/reclass/service/{{ formula_name }}"; |
Victor Ryzhenkin | 4e077ad | 2017-08-10 13:42:11 +0400 | [diff] [blame] | 996 | else |
| 997 | echo "Stopped, directory /root/salt-formula-{{ formula_name }} does not exist!"; |
| 998 | fi |
| 999 | {%- endfor %} |
| 1000 | node_name: {{ HOSTNAME_CFG01 }} |
| 1001 | retry: {count: 1, delay: 10} |
| 1002 | skip_fail: false |
| 1003 | {%- endif %} |
Dennis Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame] | 1004 | |
| 1005 | - description: Refresh pillars on salt-master minion |
| 1006 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@salt:master' saltutil.refresh_pillar |
| 1007 | node_name: {{ HOSTNAME_CFG01 }} |
| 1008 | retry: {count: 1, delay: 5} |
| 1009 | skip_fail: false |
| 1010 | |
Dennis Dmitriev | 3e731a4 | 2017-08-30 17:12:59 +0300 | [diff] [blame] | 1011 | - description: Show reclass-salt --top for salt-master node |
Dennis Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame] | 1012 | cmd: reclass-salt --top |
| 1013 | node_name: {{ HOSTNAME_CFG01 }} |
| 1014 | retry: {count: 1, delay: 5} |
| 1015 | skip_fail: false |
| 1016 | |
| 1017 | - description: Sync all salt resources on salt-master minion |
Dennis Dmitriev | 9a6cacc | 2017-08-14 00:08:41 +0300 | [diff] [blame] | 1018 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@salt:master' saltutil.sync_all && sleep 5 |
Dennis Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame] | 1019 | node_name: {{ HOSTNAME_CFG01 }} |
| 1020 | retry: {count: 1, delay: 5} |
| 1021 | skip_fail: false |
| 1022 | |
| 1023 | - description: Configure linux on master |
| 1024 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@salt:master' state.sls 'linux.system' |
| 1025 | node_name: {{ HOSTNAME_CFG01 }} |
| 1026 | retry: {count: 1, delay: 5} |
| 1027 | skip_fail: false |
| 1028 | |
| 1029 | - description: Configure salt.minion on master |
| 1030 | cmd: salt --timeout=120 --hard-crash --state-output=mixed --state-verbose=False |
| 1031 | -C 'I@salt:master' state.sls salt.minion && sleep 10 |
| 1032 | node_name: {{ HOSTNAME_CFG01 }} |
| 1033 | retry: {count: 3, delay: 10} |
| 1034 | skip_fail: false |
| 1035 | |
| 1036 | - description: Run state 'salt' on master (for salt.api, etc) |
| 1037 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False |
| 1038 | -C 'I@salt:master' state.sls salt |
| 1039 | node_name: {{ HOSTNAME_CFG01 }} |
| 1040 | retry: {count: 3, delay: 10} |
| 1041 | skip_fail: false |
Tatyana Leontovich | 4453dd6 | 2018-06-26 18:44:31 +0300 | [diff] [blame] | 1042 | |
| 1043 | - description: Restart salt-api after states |
| 1044 | cmd: systemctl restart salt-api |
| 1045 | node_name: {{ HOSTNAME_CFG01 }} |
| 1046 | retry: {count: 3, delay: 10} |
| 1047 | skip_fail: false |
| 1048 | |
Dennis Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame] | 1049 | {%- endmacro %} |
| 1050 | |
Dennis Dmitriev | 8555996 | 2018-01-30 15:35:51 +0200 | [diff] [blame] | 1051 | {%- macro MACRO_GENERATE_INVENTORY(RERUN_SALTMASTER_STATE=false) %} |
| 1052 | {#################################################################} |
| 1053 | |
| 1054 | - description: Refresh pillars before generating nodes |
| 1055 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.refresh_pillar |
| 1056 | node_name: {{ HOSTNAME_CFG01 }} |
| 1057 | retry: {count: 1, delay: 5} |
| 1058 | skip_fail: false |
| 1059 | |
Dennis Dmitriev | e1160fe | 2018-03-01 01:20:27 +0200 | [diff] [blame] | 1060 | - description: Validate pillar on salt master node |
Dennis Dmitriev | 54a1300 | 2018-03-01 11:37:04 +0200 | [diff] [blame] | 1061 | cmd: | |
| 1062 | set -e |
Dennis Dmitriev | 468ce35 | 2018-08-14 13:23:31 +0300 | [diff] [blame] | 1063 | set -x; |
Dennis Dmitriev | 54a1300 | 2018-03-01 11:37:04 +0200 | [diff] [blame] | 1064 | if salt-call sys.doc reclass.validate_node_params | grep -q reclass.validate_node_params ; then salt-call reclass.validate_nodes_params ; fi |
| 1065 | if salt-call sys.doc reclass.validate_pillar | grep -q reclass.validate_pillar ; then salt-call reclass.validate_pillar ; fi |
Dennis Dmitriev | e1160fe | 2018-03-01 01:20:27 +0200 | [diff] [blame] | 1066 | node_name: {{ HOSTNAME_CFG01 }} |
| 1067 | retry: {count: 1, delay: 5} |
| 1068 | skip_fail: false |
| 1069 | |
Dennis Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame] | 1070 | - description: Generate inventory for all the nodes to the /srv/salt/reclass/nodes/_generated |
| 1071 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False |
| 1072 | -C 'I@salt:master' state.sls reclass |
| 1073 | node_name: {{ HOSTNAME_CFG01 }} |
| 1074 | retry: {count: 1, delay: 5} |
| 1075 | skip_fail: false |
| 1076 | |
Dennis Dmitriev | 8555996 | 2018-01-30 15:35:51 +0200 | [diff] [blame] | 1077 | {%- if RERUN_SALTMASTER_STATE %} |
| 1078 | - description: Regenerate salt.master states for the newly uploaded/created model |
| 1079 | cmd: | |
| 1080 | # Need to refresh installed formulas that are required in the model |
| 1081 | salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.refresh_pillar; sleep 5; |
| 1082 | salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@salt:master' state.sls salt.master; |
| 1083 | node_name: {{ HOSTNAME_CFG01 }} |
| 1084 | retry: {count: 1, delay: 5} |
| 1085 | skip_fail: false |
| 1086 | {%- endif %} |
| 1087 | |
Dennis Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame] | 1088 | - description: Refresh pillars on all minions |
Dennis Dmitriev | 8555996 | 2018-01-30 15:35:51 +0200 | [diff] [blame] | 1089 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.refresh_pillar; sleep 5 |
Dennis Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame] | 1090 | node_name: {{ HOSTNAME_CFG01 }} |
| 1091 | retry: {count: 1, delay: 5} |
| 1092 | skip_fail: false |
| 1093 | |
Dennis Dmitriev | 3e731a4 | 2017-08-30 17:12:59 +0300 | [diff] [blame] | 1094 | - description: Show reclass-salt --top for all generated nodes |
Dennis Dmitriev | 4386a07 | 2017-09-04 13:58:02 +0300 | [diff] [blame] | 1095 | cmd: | |
| 1096 | set -e |
Dennis Dmitriev | 468ce35 | 2018-08-14 13:23:31 +0300 | [diff] [blame] | 1097 | set -x; |
Dennis Dmitriev | 4386a07 | 2017-09-04 13:58:02 +0300 | [diff] [blame] | 1098 | if salt-call sys.doc reclass.validate_node_params | grep -q reclass.validate_node_params ; then salt-call reclass.validate_nodes_params ; fi |
| 1099 | if salt-call sys.doc reclass.validate_pillar | grep -q reclass.validate_pillar ; then salt-call reclass.validate_pillar ; fi |
| 1100 | reclass-salt --top |
Dennis Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame] | 1101 | node_name: {{ HOSTNAME_CFG01 }} |
| 1102 | retry: {count: 1, delay: 5} |
| 1103 | skip_fail: false |
| 1104 | |
| 1105 | - description: Sync all salt resources |
Dennis Dmitriev | 9a6cacc | 2017-08-14 00:08:41 +0300 | [diff] [blame] | 1106 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.sync_all && sleep 5 |
Dennis Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame] | 1107 | node_name: {{ HOSTNAME_CFG01 }} |
| 1108 | retry: {count: 1, delay: 5} |
| 1109 | skip_fail: false |
| 1110 | {%- endmacro %} |
| 1111 | |
| 1112 | |
| 1113 | {%- macro MACRO_BOOTSTRAP_ALL_MINIONS() %} |
| 1114 | {########################################} |
| 1115 | # Bootstrap all nodes |
Dennis Dmitriev | 8ed2788 | 2018-01-31 23:23:19 +0200 | [diff] [blame] | 1116 | |
| 1117 | - description: Get linux kernel version from all minions |
| 1118 | cmd: | |
| 1119 | salt --hard-crash --state-output=mixed --state-verbose=False --out=txt '*' cmd.run 'uname -r' | sort |
| 1120 | salt --hard-crash --state-output=mixed --state-verbose=False --out=txt '*' cmd.run 'dpkg -l|grep "linux-image-.*-generic"' | sort |
| 1121 | node_name: {{ HOSTNAME_CFG01 }} |
| 1122 | retry: {count: 5, delay: 10} |
| 1123 | skip_fail: false |
| 1124 | |
Dennis Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame] | 1125 | - description: Configure linux on other nodes |
| 1126 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@linux:system' state.sls linux |
| 1127 | node_name: {{ HOSTNAME_CFG01 }} |
| 1128 | retry: {count: 5, delay: 10} |
| 1129 | skip_fail: false |
| 1130 | |
| 1131 | - description: Configure openssh on all nodes |
Dennis Dmitriev | 3e731a4 | 2017-08-30 17:12:59 +0300 | [diff] [blame] | 1132 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@linux:system and not cfg01*' state.sls openssh && |
Dennis Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame] | 1133 | salt --hard-crash --state-output=mixed --state-verbose=False |
| 1134 | -C 'I@linux:system and not cfg01*' cmd.run "sed -i 's/PasswordAuthentication no/PasswordAuthentication |
Dennis Dmitriev | d260451 | 2018-06-04 05:34:44 +0300 | [diff] [blame] | 1135 | yes/' /etc/ssh/sshd_config && service ssh reload" |
Dennis Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame] | 1136 | node_name: {{ HOSTNAME_CFG01 }} |
| 1137 | retry: {count: 1, delay: 5} |
| 1138 | skip_fail: false |
| 1139 | |
| 1140 | - description: Configure salt.minion on other nodes |
| 1141 | cmd: salt --timeout=120 --hard-crash --state-output=mixed --state-verbose=False -C 'I@linux:system and not cfg01*' state.sls salt.minion && |
Victor Ryzhenkin | 93b49ff | 2018-03-06 15:59:51 +0400 | [diff] [blame] | 1142 | sleep 30 |
Dennis Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame] | 1143 | node_name: {{ HOSTNAME_CFG01 }} |
| 1144 | retry: {count: 3, delay: 15} |
| 1145 | skip_fail: false |
| 1146 | |
Victor Ryzhenkin | 93b49ff | 2018-03-06 15:59:51 +0400 | [diff] [blame] | 1147 | - description: Wait for salt-minions wake up after restart |
Victor Ryzhenkin | 21bae99 | 2018-03-06 17:28:41 +0400 | [diff] [blame] | 1148 | cmd: salt --timeout=30 --hard-crash --state-output=mixed --state-verbose=False '*' test.ping |
Victor Ryzhenkin | 93b49ff | 2018-03-06 15:59:51 +0400 | [diff] [blame] | 1149 | node_name: {{ HOSTNAME_CFG01 }} |
Victor Ryzhenkin | 21bae99 | 2018-03-06 17:28:41 +0400 | [diff] [blame] | 1150 | retry: {count: 25, delay: 30} |
Victor Ryzhenkin | 93b49ff | 2018-03-06 15:59:51 +0400 | [diff] [blame] | 1151 | skip_fail: false |
| 1152 | |
Victor Ryzhenkin | a06443e | 2018-03-15 17:25:19 +0400 | [diff] [blame] | 1153 | - description: Update minion information |
Dennis Dmitriev | ea291ee | 2018-03-16 12:27:43 +0200 | [diff] [blame] | 1154 | cmd: | |
| 1155 | salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.sync_grains && |
Dmitry Tyzhnenko | 34595f8 | 2018-06-12 19:03:12 +0300 | [diff] [blame] | 1156 | salt --hard-crash --state-output=mixed --state-verbose=False '*' mine.update && sleep 60 |
Victor Ryzhenkin | a06443e | 2018-03-15 17:25:19 +0400 | [diff] [blame] | 1157 | node_name: {{ HOSTNAME_CFG01 }} |
| 1158 | retry: {count: 1, delay: 10} |
| 1159 | skip_fail: false |
| 1160 | |
Dennis Dmitriev | 14183db | 2018-03-01 15:14:12 +0200 | [diff] [blame] | 1161 | - description: Execute linux.network.host one more time after salt.minion to apply dynamically registered hosts on the cluster nodes |
| 1162 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@linux:system' state.sls linux.network.host |
| 1163 | node_name: {{ HOSTNAME_CFG01 }} |
| 1164 | retry: {count: 1, delay: 10} |
| 1165 | skip_fail: false |
| 1166 | |
Dennis Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame] | 1167 | - description: Check salt minion versions on slaves |
Victor Ryzhenkin | 42e2423 | 2017-11-15 08:01:20 -0400 | [diff] [blame] | 1168 | cmd: salt --timeout=60 '*' test.version |
Dennis Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame] | 1169 | node_name: {{ HOSTNAME_CFG01 }} |
| 1170 | retry: {count: 3, delay: 15} |
| 1171 | skip_fail: false |
| 1172 | |
| 1173 | - description: Check salt top states on nodes |
Victor Ryzhenkin | 42e2423 | 2017-11-15 08:01:20 -0400 | [diff] [blame] | 1174 | cmd: salt --timeout=60 '*' state.show_top |
Dennis Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame] | 1175 | node_name: {{ HOSTNAME_CFG01 }} |
Victor Ryzhenkin | 42e2423 | 2017-11-15 08:01:20 -0400 | [diff] [blame] | 1176 | retry: {count: 3, delay: 15} |
Dennis Dmitriev | 492813e | 2017-08-09 15:08:58 +0300 | [diff] [blame] | 1177 | skip_fail: false |
| 1178 | |
| 1179 | - description: Configure ntp and rsyslog on nodes |
| 1180 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@linux:system' state.sls ntp,rsyslog |
| 1181 | node_name: {{ HOSTNAME_CFG01 }} |
| 1182 | retry: {count: 1, delay: 10} |
| 1183 | skip_fail: false |
Tatyana Leontovich | 529e405 | 2018-07-09 18:30:48 +0300 | [diff] [blame] | 1184 | |
| 1185 | - description: Install and configure iptables if it is in pillar |
| 1186 | cmd: | |
| 1187 | if salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@iptables:service' match.pillar 'iptables:service' ; then |
| 1188 | salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@iptables:service' state.sls iptables |
| 1189 | fi |
| 1190 | node_name: {{ HOSTNAME_CFG01 }} |
| 1191 | retry: {count: 1, delay: 10} |
| 1192 | skip_fail: false |
| 1193 | |
| 1194 | |
| 1195 | - description: Install and configure logrotate if it is in pillar |
| 1196 | cmd: | |
| 1197 | if salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@logrotate:server' match.pillar 'logrotate:server' ; then |
| 1198 | salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@logrotate:server' state.sls logrotate |
| 1199 | fi |
| 1200 | node_name: {{ HOSTNAME_CFG01 }} |
| 1201 | retry: {count: 1, delay: 10} |
| 1202 | skip_fail: false |
| 1203 | |
| 1204 | - description: Install and configure auditd if it is enabled |
| 1205 | cmd: | |
| 1206 | if salt --hard-crash --state-output=mixed --state-verbose=False -C "I@auditd:service" match.pillar 'auditd:service'; then |
| 1207 | salt --hard-crash --state-output=mixed --state-verbose=False -C "I@auditd:service" state.sls auditd |
| 1208 | fi |
| 1209 | node_name: {{ HOSTNAME_CFG01 }} |
| 1210 | retry: {count: 1, delay: 10} |
| 1211 | skip_fail: false |
| 1212 | |
Sergii Golovatiuk | 50f9189 | 2017-08-04 18:11:06 +0200 | [diff] [blame] | 1213 | {%- endmacro %} |
Dennis Dmitriev | 9dada8a | 2017-08-30 17:38:55 +0300 | [diff] [blame] | 1214 | |
| 1215 | |
| 1216 | {%- macro MACRO_NETWORKING_WORKAROUNDS() %} |
| 1217 | {#########################################} |
| 1218 | |
Dennis Dmitriev | 9dada8a | 2017-08-30 17:38:55 +0300 | [diff] [blame] | 1219 | - description: '*Workaround: Load bonding module before call state.linux' |
| 1220 | cmd: salt -C "I@linux:network:interface:*:type:bond" cmd.run 'modprobe bonding' |
| 1221 | node_name: {{ HOSTNAME_CFG01 }} |
| 1222 | retry: {count: 1, delay: 5} |
Dennis Dmitriev | 0496eb7 | 2017-09-05 21:42:10 +0300 | [diff] [blame] | 1223 | skip_fail: true |
Dennis Dmitriev | 9dada8a | 2017-08-30 17:38:55 +0300 | [diff] [blame] | 1224 | |
| 1225 | - description: '*Workaround* install bridge-utils before running linux formula' |
| 1226 | # The formula removes default route and then tries to install the package, fails. |
| 1227 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C '* and not |
| 1228 | cfg01*' cmd.run 'sudo apt-get install -y bridge-utils' |
| 1229 | node_name: {{ HOSTNAME_CFG01 }} |
| 1230 | retry: {count: 1, delay: 5} |
| 1231 | skip_fail: false |
| 1232 | |
| 1233 | {%- endmacro %} |
Victor Ryzhenkin | 9cc824c | 2017-10-12 19:02:23 +0400 | [diff] [blame] | 1234 | |
Dennis Dmitriev | 257a938 | 2018-02-15 04:00:46 +0200 | [diff] [blame] | 1235 | |
Victor Ryzhenkin | 9cc824c | 2017-10-12 19:02:23 +0400 | [diff] [blame] | 1236 | {%- macro ADJUST_K8S_OPTS() %} |
Dennis Dmitriev | 257a938 | 2018-02-15 04:00:46 +0200 | [diff] [blame] | 1237 | {############################} |
Victor Ryzhenkin | 9cc824c | 2017-10-12 19:02:23 +0400 | [diff] [blame] | 1238 | |
| 1239 | - description: Set k8s deploy parameters |
| 1240 | cmd: | |
| 1241 | {% for k8s_opt, value in config.k8s_deploy.items() %} |
| 1242 | {% if value|string() %} |
| 1243 | salt-call reclass.cluster_meta_set name={{ k8s_opt }} value={{ value }}; |
| 1244 | {% endif %} |
| 1245 | {% endfor %} |
| 1246 | node_name: {{ HOSTNAME_CFG01 }} |
| 1247 | retry: {count: 1, delay: 1} |
| 1248 | skip_fail: false |
| 1249 | |
| 1250 | {%- endmacro %} |
Victor Ryzhenkin | 42e2423 | 2017-11-15 08:01:20 -0400 | [diff] [blame] | 1251 | |
Dennis Dmitriev | 257a938 | 2018-02-15 04:00:46 +0200 | [diff] [blame] | 1252 | |
| 1253 | {%- macro ADJUST_SL_OPTS(OVERRIDES_FILENAME='') %} |
| 1254 | {#############################################} |
| 1255 | - description: Set SL docker images deploy parameters |
| 1256 | cmd: | |
| 1257 | {#- For cookiecutter-generated model, use overrides.yml from environment model instead of cluster model #} |
| 1258 | {%- for sl_opt, value in config.sl_deploy.items() %} |
| 1259 | {%- if value|string() %} |
| 1260 | {%- if OVERRIDES_FILENAME %} |
| 1261 | salt-call reclass.cluster_meta_set name={{ sl_opt }} value={{ value }} file_name={{ OVERRIDES_FILENAME }}; |
| 1262 | {%- else %} |
| 1263 | salt-call reclass.cluster_meta_set name={{ sl_opt }} value={{ value }}; |
| 1264 | {%- endif %} |
| 1265 | {%- endif %} |
| 1266 | {%- endfor %} |
| 1267 | salt '*' saltutil.refresh_pillar; |
| 1268 | sleep 10 |
| 1269 | node_name: {{ HOSTNAME_CFG01 }} |
| 1270 | retry: {count: 1, delay: 1} |
| 1271 | skip_fail: false |
| 1272 | {%- endmacro %} |
| 1273 | |
| 1274 | |
Victor Ryzhenkin | 42e2423 | 2017-11-15 08:01:20 -0400 | [diff] [blame] | 1275 | {%- macro REGISTER_COMPUTE_NODES() %} |
Dennis Dmitriev | 257a938 | 2018-02-15 04:00:46 +0200 | [diff] [blame] | 1276 | {###################################} |
Victor Ryzhenkin | 42e2423 | 2017-11-15 08:01:20 -0400 | [diff] [blame] | 1277 | |
| 1278 | {% for ssh in config.underlay.ssh %} |
| 1279 | {% if ssh["node_name"].startswith("cmp") %} |
| 1280 | {% set node_hostname = ssh["node_name"].split('.')[0] %} |
| 1281 | - description: Register compute {{ ssh['node_name'] }} |
| 1282 | cmd: | |
| 1283 | exec > >(tee -i /tmp/cloud-init-bootstrap.log) 2>&1 |
| 1284 | export network01_prefix={{ IPV4_NET_ADMIN_PREFIX }} |
| 1285 | export network02_prefix={{ IPV4_NET_CONTROL_PREFIX }} |
Victor Ryzhenkin | 66593e9 | 2017-11-28 19:38:33 +0400 | [diff] [blame] | 1286 | export cluster_name={{ CLUSTER_NAME }} |
Victor Ryzhenkin | 42e2423 | 2017-11-15 08:01:20 -0400 | [diff] [blame] | 1287 | export config_host={{ config.salt.salt_master_host }} |
| 1288 | export node_domain={{ DOMAIN_NAME }} |
| 1289 | export nodes_os="xenial" |
| 1290 | export node_hostname={{ node_hostname }} |
Tatyana Leontovich | 4453dd6 | 2018-06-26 18:44:31 +0300 | [diff] [blame] | 1291 | export saltversion={{ SALT_VERSION }} |
Victor Ryzhenkin | 42e2423 | 2017-11-15 08:01:20 -0400 | [diff] [blame] | 1292 | set -xe |
| 1293 | export BOOTSTRAP_SCRIPT_URL=$bootstrap_script_url |
| 1294 | export BOOTSTRAP_SCRIPT_URL=${BOOTSTRAP_SCRIPT_URL:-https://raw.githubusercontent.com/salt-formulas/salt-formulas-scripts/master/bootstrap.sh} |
| 1295 | export DISTRIB_REVISION={{ REPOSITORY_SUITE }} |
| 1296 | export DISTRIB_REVISION=${DISTRIB_REVISION:-nightly} |
| 1297 | |
| 1298 | # Add wrapper to apt-get to avoid race conditions |
| 1299 | # with cron jobs running 'unattended-upgrades' script |
| 1300 | aptget_wrapper() { |
| 1301 | local apt_wrapper_timeout=300 |
| 1302 | local start_time=$(date '+%s') |
| 1303 | local fin_time=$((start_time + apt_wrapper_timeout)) |
| 1304 | while true; do |
| 1305 | if (( "$(date '+%s')" > fin_time )); then |
| 1306 | msg="Timeout exceeded ${apt_wrapper_timeout} s. Lock files are still not released. Terminating..." |
| 1307 | fi |
| 1308 | if fuser /var/lib/apt/lists/lock >/dev/null 2>&1 || fuser /var/lib/dpkg/lock >/dev/null 2>&1; then |
| 1309 | echo "Waiting while another apt/dpkg process releases locks ..." |
| 1310 | sleep 30 |
| 1311 | continue |
| 1312 | else |
| 1313 | apt-get $@ |
| 1314 | break |
| 1315 | fi |
| 1316 | done |
| 1317 | } |
| 1318 | |
| 1319 | # Set default salt version |
| 1320 | if [ -z "$saltversion" ]; then |
Tatyana Leontovich | 14e201d | 2018-07-05 13:28:54 +0300 | [diff] [blame] | 1321 | saltversion="2017.7" |
Victor Ryzhenkin | 42e2423 | 2017-11-15 08:01:20 -0400 | [diff] [blame] | 1322 | fi |
| 1323 | echo "Using Salt version $saltversion" |
| 1324 | |
| 1325 | echo "Preparing base OS ..." |
| 1326 | |
| 1327 | case "$node_os" in |
| 1328 | trusty) |
| 1329 | # workaround for old cloud-init only configuring the first iface |
| 1330 | iface_config_dir="/etc/network/interfaces" |
| 1331 | ifaces=$(ip a | awk '/^[1-9]:/ {print $2}' | grep -v "lo:" | rev | cut -c2- | rev) |
| 1332 | |
| 1333 | for iface in $ifaces; do |
| 1334 | grep $iface $iface_config_dir &> /dev/null || (echo -e "\nauto $iface\niface $iface inet dhcp" >> $iface_config_dir && ifup $iface) |
| 1335 | done |
| 1336 | |
| 1337 | which wget > /dev/null || (aptget_wrapper update; aptget_wrapper install -y wget) |
| 1338 | |
| 1339 | # SUGGESTED UPDATE: |
| 1340 | #export MASTER_IP="$config_host" MINION_ID="$node_hostname.$node_domain" SALT_VERSION=$saltversion |
| 1341 | #source <(curl -qL ${BOOTSTRAP_SCRIPT_URL}) |
| 1342 | ## Update BOOTSTRAP_SALTSTACK_OPTS, as by default they contain "-dX" not to start service |
| 1343 | #BOOTSTRAP_SALTSTACK_OPTS=" stable $SALT_VERSION " |
| 1344 | #install_salt_minion_pkg |
| 1345 | |
| 1346 | # DEPRECATED: |
| 1347 | echo "deb [arch=amd64] http://apt-mk.mirantis.com/trusty ${DISTRIB_REVISION} salt extra" > /etc/apt/sources.list.d/mcp_salt.list |
| 1348 | wget -O - http://apt-mk.mirantis.com/public.gpg | apt-key add - |
| 1349 | |
| 1350 | echo "deb http://repo.saltstack.com/apt/ubuntu/14.04/amd64/$saltversion trusty main" > /etc/apt/sources.list.d/saltstack.list |
| 1351 | wget -O - "https://repo.saltstack.com/apt/ubuntu/14.04/amd64/$saltversion/SALTSTACK-GPG-KEY.pub" | apt-key add - |
| 1352 | |
| 1353 | aptget_wrapper clean |
| 1354 | aptget_wrapper update |
| 1355 | aptget_wrapper install -y salt-common |
| 1356 | aptget_wrapper install -y salt-minion |
| 1357 | ;; |
| 1358 | xenial) |
| 1359 | |
| 1360 | # workaround for new cloud-init setting all interfaces statically |
| 1361 | which resolvconf > /dev/null 2>&1 && systemctl restart resolvconf |
| 1362 | |
| 1363 | which wget > /dev/null || (aptget_wrapper update; aptget_wrapper install -y wget) |
| 1364 | |
| 1365 | # SUGGESTED UPDATE: |
| 1366 | #export MASTER_IP="$config_host" MINION_ID="$node_hostname.$node_domain" SALT_VERSION=$saltversion |
| 1367 | #source <(curl -qL ${BOOTSTRAP_SCRIPT_URL}) |
| 1368 | ## Update BOOTSTRAP_SALTSTACK_OPTS, as by default they contain "-dX" not to start service |
| 1369 | #BOOTSTRAP_SALTSTACK_OPTS=" stable $SALT_VERSION " |
| 1370 | #install_salt_minion_pkg |
| 1371 | |
| 1372 | # DEPRECATED: |
| 1373 | echo "deb [arch=amd64] http://apt-mk.mirantis.com/xenial ${DISTRIB_REVISION} salt extra" > /etc/apt/sources.list.d/mcp_salt.list |
| 1374 | wget -O - http://apt-mk.mirantis.com/public.gpg | apt-key add - |
| 1375 | |
| 1376 | echo "deb http://repo.saltstack.com/apt/ubuntu/16.04/amd64/$saltversion xenial main" > /etc/apt/sources.list.d/saltstack.list |
| 1377 | wget -O - "https://repo.saltstack.com/apt/ubuntu/16.04/amd64/$saltversion/SALTSTACK-GPG-KEY.pub" | apt-key add - |
| 1378 | |
| 1379 | aptget_wrapper clean |
| 1380 | aptget_wrapper update |
| 1381 | aptget_wrapper install -y salt-minion |
| 1382 | ;; |
| 1383 | rhel|centos|centos7|centos7|rhel6|rhel7) |
| 1384 | yum install -y git |
| 1385 | export MASTER_IP="$config_host" MINION_ID="$node_hostname.$node_domain" SALT_VERSION=$saltversion |
| 1386 | source <(curl -qL ${BOOTSTRAP_SCRIPT_URL}) |
| 1387 | # Update BOOTSTRAP_SALTSTACK_OPTS, as by default they contain "-dX" not to start service |
| 1388 | BOOTSTRAP_SALTSTACK_OPTS=" stable $SALT_VERSION " |
| 1389 | install_salt_minion_pkg |
| 1390 | ;; |
| 1391 | *) |
| 1392 | msg="OS '$node_os' is not supported." |
| 1393 | esac |
| 1394 | |
| 1395 | echo "Configuring Salt minion ..." |
| 1396 | [ ! -d /etc/salt/minion.d ] && mkdir -p /etc/salt/minion.d |
| 1397 | echo -e "id: $node_hostname.$node_domain\nmaster: $config_host" > /etc/salt/minion.d/minion.conf |
| 1398 | |
| 1399 | service salt-minion restart || wait_condition_send "FAILURE" "Failed to restart salt-minion service." |
| 1400 | |
| 1401 | sleep 1 |
| 1402 | |
| 1403 | echo "Classifying node ..." |
| 1404 | os_codename=$(salt-call grains.item oscodename --out key | awk '/oscodename/ {print $2}') |
| 1405 | node_network01_ip="$(ip a | awk -v prefix="^ inet $network01_prefix[.]" '$0 ~ prefix {split($2, a, "/"); print a[1]}')" |
| 1406 | node_network02_ip="$(ip a | awk -v prefix="^ inet $network02_prefix[.]" '$0 ~ prefix {split($2, a, "/"); print a[1]}')" |
| 1407 | node_network03_ip="$(ip a | awk -v prefix="^ inet $network03_prefix[.]" '$0 ~ prefix {split($2, a, "/"); print a[1]}')" |
| 1408 | node_network04_ip="$(ip a | awk -v prefix="^ inet $network04_prefix[.]" '$0 ~ prefix {split($2, a, "/"); print a[1]}')" |
| 1409 | node_network05_ip="$(ip a | awk -v prefix="^ inet $network05_prefix[.]" '$0 ~ prefix {split($2, a, "/"); print a[1]}')" |
| 1410 | |
| 1411 | node_network01_iface="$(ip a | awk -v prefix="^ inet $network01_prefix[.]" '$0 ~ prefix {split($7, a, "/"); print a[1]}')" |
| 1412 | node_network02_iface="$(ip a | awk -v prefix="^ inet $network02_prefix[.]" '$0 ~ prefix {split($7, a, "/"); print a[1]}')" |
| 1413 | node_network03_iface="$(ip a | awk -v prefix="^ inet $network03_prefix[.]" '$0 ~ prefix {split($7, a, "/"); print a[1]}')" |
| 1414 | node_network04_iface="$(ip a | awk -v prefix="^ inet $network04_prefix[.]" '$0 ~ prefix {split($7, a, "/"); print a[1]}')" |
| 1415 | node_network05_iface="$(ip a | awk -v prefix="^ inet $network05_prefix[.]" '$0 ~ prefix {split($7, a, "/"); print a[1]}')" |
| 1416 | |
| 1417 | if [ "$node_network05_iface" != "" ]; then |
| 1418 | node_network05_hwaddress="$(cat /sys/class/net/$node_network05_iface/address)" |
| 1419 | fi |
| 1420 | |
| 1421 | # find more parameters (every env starting param_) |
| 1422 | more_params=$(env | grep "^param_" | sed -e 's/=/":"/g' -e 's/^/"/g' -e 's/$/",/g' | tr "\n" " " | sed 's/, $//g') |
| 1423 | if [ "$more_params" != "" ]; then |
| 1424 | echo "Additional params: $more_params" |
| 1425 | more_params=", $more_params" |
| 1426 | fi |
| 1427 | |
| 1428 | salt-call event.send "reclass/minion/classify" "{\"node_master_ip\": \"$config_host\", \"node_os\": \"${os_codename}\", \"node_deploy_ip\": \"${node_network01_ip}\", \"node_deploy_iface\": \"${node_network01_iface}\", \"node_control_ip\": \"${node_network02_ip}\", \"node_control_iface\": \"${node_network02_iface}\", \"node_tenant_ip\": \"${node_network03_ip}\", \"node_tenant_iface\": \"${node_network03_iface}\", \"node_external_ip\": \"${node_network04_ip}\", \"node_external_iface\": \"${node_network04_iface}\", \"node_baremetal_ip\": \"${node_network05_ip}\", \"node_baremetal_iface\": \"${node_network05_iface}\", \"node_baremetal_hwaddress\": \"${node_network05_hwaddress}\", \"node_domain\": \"$node_domain\", \"node_cluster\": \"$cluster_name\", \"node_hostname\": \"$node_hostname\"${more_params}}" |
| 1429 | |
| 1430 | sleep 5 |
| 1431 | |
| 1432 | salt-call saltutil.sync_all |
| 1433 | salt-call mine.flush |
| 1434 | salt-call mine.update |
| 1435 | node_name: {{ ssh['node_name'] }} |
| 1436 | retry: {count: 1, delay: 1} |
| 1437 | skip_fail: false |
| 1438 | {%- endif %} |
| 1439 | {%- endfor %} |
| 1440 | |
| 1441 | - description: Refresh pillars on all minions |
| 1442 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.refresh_pillar |
| 1443 | node_name: {{ HOSTNAME_CFG01 }} |
| 1444 | retry: {count: 1, delay: 5} |
| 1445 | skip_fail: false |
| 1446 | |
| 1447 | - description: Sync all salt resources |
| 1448 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.sync_all && sleep 5 |
| 1449 | node_name: {{ HOSTNAME_CFG01 }} |
| 1450 | retry: {count: 1, delay: 5} |
| 1451 | skip_fail: false |
| 1452 | |
sgudz | 160b730 | 2017-12-22 17:01:10 +0200 | [diff] [blame] | 1453 | {%- endmacro %} |
sgudz | 09e9aa9 | 2018-04-12 12:31:53 +0300 | [diff] [blame] | 1454 | |
| 1455 | {%- macro RUN_NEW_TEMPEST() %} |
| 1456 | {###################################} |
| 1457 | |
| 1458 | - description: Upload tempest template |
| 1459 | upload: |
| 1460 | local_path: {{ config.salt_deploy.templates_dir }} |
| 1461 | local_filename: runtest.yml |
| 1462 | remote_path: /srv/salt/reclass/classes/cluster/{{ CLUSTER_NAME }}/infra/ |
| 1463 | node_name: {{ HOSTNAME_CFG01 }} |
| 1464 | skip_fail: False |
| 1465 | |
| 1466 | - description: Include class with tempest template into cfg node |
| 1467 | cmd: | |
| 1468 | sed -i 's/classes\:/classes\:\n- cluster.{{ CLUSTER_NAME }}.infra.runtest/g' /srv/salt/reclass/nodes/_generated/cfg01.{{ DOMAIN_NAME }}.yml; |
| 1469 | salt 'cfg01*' saltutil.refresh_pillar; |
| 1470 | salt 'cfg01*' saltutil.sync_all; |
| 1471 | node_name: {{ HOSTNAME_CFG01 }} |
| 1472 | retry: {count: 1, delay: 10} |
| 1473 | skip_fail: false |
| 1474 | |
Oleksii Butenko | 2e8e8ee | 2018-06-21 11:10:13 +0300 | [diff] [blame] | 1475 | - description: Execute salt.minion on config node |
| 1476 | cmd: salt-call --hard-crash --state-output=mixed --state-verbose=False state.sls salt.minion; |
| 1477 | node_name: {{ HOSTNAME_CFG01 }} |
| 1478 | retry: {count: 1, delay: 5} |
| 1479 | skip_fail: false |
| 1480 | |
| 1481 | - description: Test ping |
| 1482 | cmd: salt-call --hard-crash --state-output=mixed --state-verbose=False test.ping; |
| 1483 | node_name: {{ HOSTNAME_CFG01 }} |
| 1484 | retry: {count: 1, delay: 5} |
| 1485 | skip_fail: false |
| 1486 | |
sgudz | 09e9aa9 | 2018-04-12 12:31:53 +0300 | [diff] [blame] | 1487 | - description: Create flavors for tests |
| 1488 | cmd: | |
| 1489 | salt 'cfg01*' state.sls nova.client; |
| 1490 | node_name: {{ HOSTNAME_CFG01 }} |
| 1491 | retry: {count: 1, delay: 5} |
| 1492 | skip_fail: false |
| 1493 | |
| 1494 | - description: Create networks for tests |
| 1495 | cmd: | |
| 1496 | salt 'cfg01*' state.sls neutron.client; |
| 1497 | node_name: {{ HOSTNAME_CFG01 }} |
| 1498 | retry: {count: 1, delay: 5} |
| 1499 | skip_fail: false |
| 1500 | |
| 1501 | - description: Upload cirros image |
| 1502 | cmd: | |
| 1503 | salt 'cfg01*' state.sls glance.client; |
| 1504 | node_name: {{ HOSTNAME_CFG01 }} |
| 1505 | retry: {count: 1, delay: 5} |
| 1506 | skip_fail: false |
| 1507 | |
| 1508 | - description: Generate tempest config |
| 1509 | cmd: | |
| 1510 | salt 'cfg01*' state.sls runtest; |
| 1511 | node_name: {{ HOSTNAME_CFG01 }} |
| 1512 | retry: {count: 1, delay: 5} |
| 1513 | skip_fail: false |
| 1514 | |
| 1515 | - description: Run tempest from new docker image |
| 1516 | cmd: | |
Oleksii Butenko | 71d76f3 | 2018-06-05 17:46:34 +0300 | [diff] [blame] | 1517 | docker run -e ARGS="-r {{TEMPEST_PATTERN }} -w 2 {{ EXCLUDE_TEST_ARGS }}" -v /root/test/tempest.conf:/etc/tempest/tempest.conf -v /tmp/:/tmp/ -v /root/test:/root/tempest -v /etc/ssl/certs/:/etc/ssl/certs/ --rm docker-prod-virtual.docker.mirantis.net/mirantis/cicd/ci-tempest:pike /bin/bash -c "run-tempest" |
sgudz | 09e9aa9 | 2018-04-12 12:31:53 +0300 | [diff] [blame] | 1518 | node_name: {{ HOSTNAME_GTW01 }} |
| 1519 | retry: {count: 1, delay: 30} |
| 1520 | skip_fail: true |
| 1521 | |
| 1522 | - description: Download xml results |
| 1523 | download: |
| 1524 | remote_path: /root/test/ |
| 1525 | remote_filename: "report_*.xml" |
| 1526 | local_path: {{ os_env('PWD') }} |
| 1527 | node_name: {{ HOSTNAME_GTW01 }} |
| 1528 | skip_fail: true |
| 1529 | |
| 1530 | {%- endmacro %} |
Oleksii Butenko | 5cd0a16 | 2018-06-14 18:18:10 +0300 | [diff] [blame] | 1531 | |
| 1532 | {%- macro INSTALL_DOCKER_ON_GTW() %} |
| 1533 | {###################################} |
| 1534 | |
| 1535 | - description: Install docker.io on gtw |
| 1536 | cmd: salt-call cmd.run 'apt-get install docker.io -y' |
| 1537 | node_name: {{ HOSTNAME_GTW01 }} |
| 1538 | retry: {count: 1, delay: 30} |
| 1539 | skip_fail: false |
| 1540 | |
| 1541 | - description: Enable forward policy |
| 1542 | cmd: iptables --policy FORWARD ACCEPT |
| 1543 | node_name: {{ HOSTNAME_GTW01 }} |
| 1544 | retry: {count: 1, delay: 30} |
| 1545 | skip_fail: false |
| 1546 | |
| 1547 | {%- endmacro %} |
Tatyana Leontovich | 4453dd6 | 2018-06-26 18:44:31 +0300 | [diff] [blame] | 1548 | |
| 1549 | {%- macro MACRO_CHECK_SALT_VERSION_ON_NODES() %} |
| 1550 | {#####################################################} |
| 1551 | |
| 1552 | {%- for ssh in config.underlay.ssh %} |
| 1553 | {%- set salt_roles = [] %} |
| 1554 | {%- for role in ssh['roles'] %} |
| 1555 | {%- if role in config.salt_deploy.salt_roles %} |
| 1556 | {%- set _ = salt_roles.append(role) %} |
| 1557 | {%- endif %} |
| 1558 | {%- endfor %} |
| 1559 | |
| 1560 | {%- if salt_roles %} |
| 1561 | - description: 'Check salt version is as expected' |
| 1562 | cmd: salt-call test.version | grep {{ SALT_VERSION }} |
| 1563 | node_name: {{ ssh['node_name'] }} |
| 1564 | retry: {count: 1, delay: 1} |
| 1565 | skip_fail: false |
| 1566 | {%- endif %} |
| 1567 | |
| 1568 | {%- endfor %} |
| 1569 | {%- endmacro %} |
| 1570 | |
| 1571 | {%- macro MACRO_CHECK_SALT_VERSION_SERVICES_ON_CFG() %} |
| 1572 | {#####################################################} |
| 1573 | |
| 1574 | - description: 'Check salt-api, salt-master and salt-minion version' |
| 1575 | cmd: | |
| 1576 | salt-master --version | grep {{ SALT_VERSION }}; |
| 1577 | salt-minion --version | grep {{ SALT_VERSION }}; |
| 1578 | salt-api --version | grep {{ SALT_VERSION }}; |
| 1579 | node_name: {{ HOSTNAME_CFG01 }} |
| 1580 | retry: {count: 1, delay: 5} |
| 1581 | skip_fail: false |
| 1582 | |
Dmitry Tyzhnenko | 34595f8 | 2018-06-12 19:03:12 +0300 | [diff] [blame] | 1583 | {%- endmacro %} |
Andrew Baraniuk | 2c06e51 | 2019-05-30 17:22:48 +0300 | [diff] [blame] | 1584 | |
| 1585 | {%- macro MACRO_IPFLUSH_TENANTS_IFACES() %} |
| 1586 | {######################################} |
| 1587 | - description: WR Flush addresses on tenant and external ifaces |
| 1588 | cmd: | |
| 1589 | salt -C 'gtw* or cmp*' cmd.run 'ip address flush dev ens5'; |
| 1590 | salt -C 'gtw* or cmp*' cmd.run 'ip address flush dev ens6'; |
| 1591 | node_name: {{ HOSTNAME_CFG01 }} |
| 1592 | retry: {count: 1, delay: 1} |
| 1593 | skip_fail: false |
| 1594 | |
| 1595 | {%- endmacro %} |