sgudz | 33280bd | 2018-11-01 14:32:05 +0200 | [diff] [blame] | 1 | {% from 'cookied-bm-k8s-contrail/underlay.yaml' import HOSTNAME_CFG01 with context %} |
| 2 | {% from 'cookied-bm-k8s-contrail/underlay.yaml' import LAB_CONFIG_NAME with context %} |
| 3 | {% from 'cookied-bm-k8s-contrail/underlay.yaml' import DOMAIN_NAME with context %} |
| 4 | {% from 'cookied-bm-k8s-contrail/underlay.yaml' import HOSTNAME_KVM01 with context %} |
| 5 | {% from 'cookied-bm-k8s-contrail/underlay.yaml' import HOSTNAME_KVM02 with context %} |
| 6 | {% from 'cookied-bm-k8s-contrail/underlay.yaml' import HOSTNAME_KVM03 with context %} |
Dmitry Tyzhnenko | 34595f8 | 2018-06-12 19:03:12 +0300 | [diff] [blame] | 7 | |
Dennis Dmitriev | 0f27231 | 2018-10-01 13:29:40 +0300 | [diff] [blame] | 8 | {% set SALT_MODELS_REPOSITORY = os_env('SALT_MODELS_REPOSITORY','https://gerrit.mcp.mirantis.com/salt-models/mcp-virtual-lab') %} |
Dmitry Tyzhnenko | 34595f8 | 2018-06-12 19:03:12 +0300 | [diff] [blame] | 9 | # Other salt model repository parameters see in shared-salt.yaml |
| 10 | |
| 11 | # Name of the context file (without extension, that is fixed .yaml) used to render the Environment model |
| 12 | {% set ENVIRONMENT_MODEL_INVENTORY_NAME = os_env('ENVIRONMENT_MODEL_INVENTORY_NAME','bm-mcp-pike-k8s-contrail') %} |
| 13 | # Path to the context files used to render Cluster and Environment models |
| 14 | {%- set CLUSTER_CONTEXT_NAME = 'salt-context-cookiecutter-k8s-contrail.yaml' %} |
| 15 | {%- set ENVIRONMENT_CONTEXT_NAMES = ['salt-context-environment.yaml','lab04-upgrade-physical-inventory.yaml'] %} |
| 16 | {%- set CONTROL_VLAN = os_env('CONTROL_VLAN', '2410') %} |
| 17 | {%- set TENANT_VLAN = os_env('TENANT_VLAN', '2411') %} |
| 18 | |
| 19 | |
| 20 | {% import 'shared-salt.yaml' as SHARED with context %} |
| 21 | |
| 22 | {{ SHARED.MACRO_INSTALL_SALT_MASTER() }} |
| 23 | |
sgudz | fc5b22f | 2018-08-23 17:45:04 +0300 | [diff] [blame] | 24 | {{ SHARED.MACRO_GENERATE_COOKIECUTTER_MODEL(CONTROL_VLAN=CONTROL_VLAN, TENANT_VLAN=TENANT_VLAN, CLUSTER_PRODUCT_MODELS='cicd infra kubernetes opencontrail stacklight2') }} |
Dmitry Tyzhnenko | 34595f8 | 2018-06-12 19:03:12 +0300 | [diff] [blame] | 25 | |
| 26 | {{ SHARED.MACRO_GENERATE_AND_ENABLE_ENVIRONMENT_MODEL() }} |
| 27 | |
Oleksii Butenko | a2fa061 | 2018-09-20 12:01:44 +0300 | [diff] [blame] | 28 | {{ SHARED.MACRO_CONFIGURE_RECLASS(FORMULA_SERVICES='\*') }} |
Dmitry Tyzhnenko | 34595f8 | 2018-06-12 19:03:12 +0300 | [diff] [blame] | 29 | {{ SHARED.MACRO_INSTALL_SALT_MINIONS() }} |
| 30 | |
| 31 | {{ SHARED.MACRO_RUN_SALT_MASTER_UNDERLAY_STATES() }} |
| 32 | |
Dmitry Tyzhnenko | 7c7b7d8 | 2018-07-20 15:35:07 +0300 | [diff] [blame] | 33 | - description: "Change path to internal storage for salt.control images" |
Dmitry Tyzhnenko | 34595f8 | 2018-06-12 19:03:12 +0300 | [diff] [blame] | 34 | cmd: | |
| 35 | set -e; |
Dmitry Tyzhnenko | 34595f8 | 2018-06-12 19:03:12 +0300 | [diff] [blame] | 36 | . /root/venv-reclass-tools/bin/activate; |
Dennis Dmitriev | e15a4f4 | 2018-10-30 13:11:56 +0200 | [diff] [blame] | 37 | reclass-tools add-key parameters._param.salt_control_xenial_image 'http://images.mcp.mirantis.net/ubuntu-16-04-x64-mcp{{ SHARED.REPOSITORY_SUITE }}.qcow2' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/init.yml; |
| 38 | reclass-tools add-key parameters._param.salt_control_trusty_image 'http://images.mcp.mirantis.net/ubuntu-14-04-x64-mcp{{ SHARED.REPOSITORY_SUITE }}.qcow2' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/init.yml; |
Dmitry Tyzhnenko | 34595f8 | 2018-06-12 19:03:12 +0300 | [diff] [blame] | 39 | node_name: {{ HOSTNAME_CFG01 }} |
| 40 | retry: {count: 1, delay: 10} |
| 41 | skip_fail: false |
| 42 | |
sgudz | fc5b22f | 2018-08-23 17:45:04 +0300 | [diff] [blame] | 43 | - description: Delete proxy inclusion from kvm |
| 44 | cmd: | |
| 45 | sed -i 's/- system.salt.control.cluster.kubernetes_proxy_cluster//g' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/kvm.yml; |
| 46 | node_name: {{ HOSTNAME_CFG01 }} |
| 47 | retry: {count: 1, delay: 10} |
| 48 | skip_fail: false |
| 49 | |
Dmitry Tyzhnenko | 34595f8 | 2018-06-12 19:03:12 +0300 | [diff] [blame] | 50 | - description: Temporary WR for correct bridge name according to envoronment templates |
| 51 | cmd: | |
| 52 | sed -i 's/br\-ctl/br\_ctl/g' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/kvm.yml; |
| 53 | sed -i 's/br\-mgm/br\_mgm/g' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/kvm.yml; |
| 54 | node_name: {{ HOSTNAME_CFG01 }} |
| 55 | retry: {count: 1, delay: 10} |
| 56 | skip_fail: false |
| 57 | |
sgudz | fc5b22f | 2018-08-23 17:45:04 +0300 | [diff] [blame] | 58 | - description: "Excluding tenant network from cluster" |
| 59 | cmd: | |
| 60 | set -e; |
| 61 | . /root/venv-reclass-tools/bin/activate; |
| 62 | reclass-tools add-key parameters._param.opencontrail_compute_address '${_param:single_address}' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/opencontrail/compute.yml; |
| 63 | node_name: {{ HOSTNAME_CFG01 }} |
| 64 | retry: {count: 1, delay: 10} |
| 65 | skip_fail: false |
| 66 | |
| 67 | - description: "Use correct compute interface" |
| 68 | cmd: | |
| 69 | set -e; |
| 70 | . /root/venv-reclass-tools/bin/activate; |
| 71 | reclass-tools add-key parameters._param.opencontrail_compute_iface 'ens11f1.${_param:control_vlan}' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/opencontrail/init.yml; |
| 72 | node_name: {{ HOSTNAME_CFG01 }} |
| 73 | retry: {count: 1, delay: 10} |
| 74 | skip_fail: false |
| 75 | |
Dmitry Tyzhnenko | 7c7b7d8 | 2018-07-20 15:35:07 +0300 | [diff] [blame] | 76 | - description: Rerun openssh after env model is generated |
| 77 | cmd: | |
| 78 | salt-call state.sls openssh |
| 79 | node_name: {{ HOSTNAME_CFG01 }} |
| 80 | retry: {count: 1, delay: 10} |
| 81 | skip_fail: false |
| 82 | |
| 83 | {{ SHARED.MACRO_GENERATE_INVENTORY() }} |
| 84 | |
| 85 | {{ SHARED.MACRO_NETWORKING_WORKAROUNDS() }} |
| 86 | |
| 87 | - description: "Disable kubelet_fail_on_swap" |
| 88 | cmd: | |
| 89 | set -e; |
| 90 | . /root/venv-reclass-tools/bin/activate; |
| 91 | reclass-tools add-key parameters._param.kubelet_fail_on_swap false /srv/salt/reclass/classes/system/kubernetes/common.yml; |
| 92 | node_name: {{ HOSTNAME_CFG01 }} |
| 93 | retry: {count: 1, delay: 10} |
| 94 | skip_fail: false |
| 95 | |
| 96 | - description: Update minion information |
| 97 | cmd: | |
sgudz | fc5b22f | 2018-08-23 17:45:04 +0300 | [diff] [blame] | 98 | salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.sync_all && |
Dmitry Tyzhnenko | 7c7b7d8 | 2018-07-20 15:35:07 +0300 | [diff] [blame] | 99 | salt --hard-crash --state-output=mixed --state-verbose=False '*' mine.update && |
| 100 | salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.refresh_pillar && sleep 10 |
| 101 | node_name: {{ HOSTNAME_CFG01 }} |
| 102 | retry: {count: 1, delay: 10} |
| 103 | skip_fail: false |
| 104 | |
| 105 | - description: Rerun openssh after env model is generated |
| 106 | cmd: | |
| 107 | salt-call state.sls openssh |
| 108 | node_name: {{ HOSTNAME_CFG01 }} |
| 109 | retry: {count: 1, delay: 10} |
| 110 | skip_fail: false |
| 111 | |
| 112 | - description: Execute linux.network.host one more time after salt.minion to apply dynamically registered hosts on the cluster nodes |
| 113 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@linux:system' state.sls linux.network.host |
| 114 | node_name: {{ HOSTNAME_CFG01 }} |
| 115 | retry: {count: 2, delay: 10} |
| 116 | skip_fail: false |
| 117 | |
Dmitry Tyzhnenko | 34595f8 | 2018-06-12 19:03:12 +0300 | [diff] [blame] | 118 | {{ SHARED.MACRO_BOOTSTRAP_ALL_MINIONS() }} |
| 119 | |
| 120 | ######################################## |
| 121 | # Spin up Control Plane VMs on KVM nodes |
| 122 | ######################################## |
| 123 | |
| 124 | - description: Execute 'libvirt' states to create necessary libvirt networks |
| 125 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False 'kvm*' state.sls libvirt |
| 126 | node_name: {{ HOSTNAME_CFG01 }} |
| 127 | retry: {count: 2, delay: 10} |
| 128 | skip_fail: false |
| 129 | |
| 130 | - description: Create VMs for control plane |
| 131 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False 'kvm*' state.sls salt.control |
| 132 | node_name: {{ HOSTNAME_CFG01 }} |
| 133 | retry: {count: 3, delay: 10} |
| 134 | skip_fail: false |
| 135 | |
| 136 | - description: '*Workaround* for waiting the control-plane VMs in the salt-key (instead of sleep)' |
| 137 | cmd: | |
| 138 | salt-key -l acc| sort > /tmp/current_keys.txt && |
| 139 | salt 'kvm*' cmd.run 'virsh list --name' | grep -v 'kvm'|sort|xargs -I {} fgrep {} /tmp/current_keys.txt |
| 140 | node_name: {{ HOSTNAME_CFG01 }} |
| 141 | retry: {count: 20, delay: 30} |
| 142 | skip_fail: false |
| 143 | |
Dmitry Tyzhnenko | 7c7b7d8 | 2018-07-20 15:35:07 +0300 | [diff] [blame] | 144 | {{ SHARED.MACRO_BOOTSTRAP_ALL_MINIONS() }} |
| 145 | |
Dmitry Tyzhnenko | 34595f8 | 2018-06-12 19:03:12 +0300 | [diff] [blame] | 146 | ######################################### |
| 147 | # Configure all running salt minion nodes |
| 148 | ######################################### |
| 149 | |
| 150 | - description: Hack resolv.conf on VCP nodes for internal services access |
| 151 | cmd: | |
Dmitry Tyzhnenko | 7c7b7d8 | 2018-07-20 15:35:07 +0300 | [diff] [blame] | 152 | salt --hard-crash --state-output=mixed --state-verbose=False -C '* and not cfg*' cmd.run "echo 'nameserver 172.17.41.2' > /etc/resolv.conf;" |
Dmitry Tyzhnenko | 34595f8 | 2018-06-12 19:03:12 +0300 | [diff] [blame] | 153 | node_name: {{ HOSTNAME_CFG01 }} |
| 154 | retry: {count: 1, delay: 5} |
| 155 | skip_fail: false |
| 156 | |
| 157 | - description: Refresh pillars on all minions |
| 158 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.refresh_pillar |
| 159 | node_name: {{ HOSTNAME_CFG01 }} |
| 160 | retry: {count: 1, delay: 5} |
| 161 | skip_fail: false |
| 162 | |
| 163 | - description: Sync all salt resources |
| 164 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.sync_all && sleep 5 |
| 165 | node_name: {{ HOSTNAME_CFG01 }} |
| 166 | retry: {count: 1, delay: 5} |
| 167 | skip_fail: false |
| 168 | |
| 169 | - description: Show reclass-salt --top for generated nodes |
| 170 | cmd: reclass-salt --top -u /srv/salt/reclass/nodes/_generated/ |
| 171 | node_name: {{ HOSTNAME_CFG01 }} |
| 172 | retry: {count: 1, delay: 5} |
| 173 | skip_fail: false |
| 174 | |
Dmitry Tyzhnenko | 7c7b7d8 | 2018-07-20 15:35:07 +0300 | [diff] [blame] | 175 | {{SHARED.MACRO_CHECK_SALT_VERSION_SERVICES_ON_CFG()}} |
| 176 | |
| 177 | {{SHARED.MACRO_CHECK_SALT_VERSION_ON_NODES()}} |
| 178 | |
| 179 | - description: "Lab04 workaround: Give each node root acces with key from cfg01" |
| 180 | cmd: | |
| 181 | set -e; |
| 182 | set -x; |
| 183 | key=$(ssh-keygen -y -f /root/.ssh/id_rsa); |
| 184 | salt '*' cmd.run "echo $key >> /root/.ssh/authorized_keys"; |
| 185 | salt '*' cmd.run "service sshd restart" |
| 186 | node_name: {{ HOSTNAME_CFG01 }} |
| 187 | retry: {count: 1, delay: 5} |
| 188 | skip_fail: true |
| 189 | |
| 190 | - description: "Lab04 workaround: Control network access from cfg01 node using sshuttle via kvm01" |
| 191 | cmd: | |
| 192 | set -e; |
| 193 | set -x; |
| 194 | KVM01_DEPLOY_ADDRESS=$(salt-call --out=newline_values_only pillar.get _param:infra_kvm_node01_deploy_address); |
| 195 | apt-get install -y sshuttle; |
| 196 | sshuttle -r ${KVM01_DEPLOY_ADDRESS} 10.167.8.0/24 -D >/dev/null; |
| 197 | node_name: {{ HOSTNAME_CFG01 }} |
| 198 | retry: {count: 1, delay: 5} |
| 199 | skip_fail: true |