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