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