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