sgudz | d7f8ec9 | 2018-04-19 16:22:47 +0300 | [diff] [blame] | 1 | {% from 'cookied-bm-mcp-ocata-contrail-nfv/underlay.yaml' import HOSTNAME_CFG01 with context %} |
| 2 | {% from 'cookied-bm-mcp-ocata-contrail-nfv/underlay.yaml' import LAB_CONFIG_NAME with context %} |
| 3 | {% from 'cookied-bm-mcp-ocata-contrail-nfv/underlay.yaml' import DOMAIN_NAME with context %} |
| 4 | {% from 'cookied-bm-mcp-ocata-contrail-nfv/underlay.yaml' import HOSTNAME_KVM01 with context %} |
| 5 | {% from 'cookied-bm-mcp-ocata-contrail-nfv/underlay.yaml' import HOSTNAME_KVM02 with context %} |
| 6 | {% from 'cookied-bm-mcp-ocata-contrail-nfv/underlay.yaml' import HOSTNAME_KVM03 with context %} |
| 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') %} |
sgudz | d7f8ec9 | 2018-04-19 16:22:47 +0300 | [diff] [blame] | 9 | # Other salt model repository parameters see in shared-salt.yaml |
| 10 | # Name of the context file (without extension, that is fixed .yaml) used to render the Environment model |
| 11 | {% set ENVIRONMENT_MODEL_INVENTORY_NAME = os_env('ENVIRONMENT_MODEL_INVENTORY_NAME','physical-cookied-bm-mcp-ocata-contrail-nfv') %} |
| 12 | # Path to the context files used to render Cluster and Environment models |
| 13 | {%- set CLUSTER_CONTEXT_NAME = 'salt-context-cookiecutter-contrail-dpdk.yaml' %} |
| 14 | {%- set ENVIRONMENT_CONTEXT_NAMES = ['salt-context-environment.yaml','lab04-physical-inventory.yaml'] %} |
| 15 | {%- set CONTROL_VLAN = os_env('CONTROL_VLAN', '2422') %} |
| 16 | {%- set TENANT_VLAN = os_env('TENANT_VLAN', '2423') %} |
| 17 | |
| 18 | {% import 'shared-salt.yaml' as SHARED with context %} |
| 19 | |
| 20 | {{ SHARED.MACRO_INSTALL_SALT_MASTER() }} |
| 21 | |
| 22 | {{ SHARED.MACRO_GENERATE_COOKIECUTTER_MODEL(CONTROL_VLAN=CONTROL_VLAN, TENANT_VLAN=TENANT_VLAN) }} |
| 23 | |
| 24 | {{ SHARED.MACRO_GENERATE_AND_ENABLE_ENVIRONMENT_MODEL() }} |
| 25 | |
Oleksii Butenko | a2fa061 | 2018-09-20 12:01:44 +0300 | [diff] [blame] | 26 | {{ SHARED.MACRO_CONFIGURE_RECLASS(FORMULA_SERVICES='\*') }} |
sgudz | d7f8ec9 | 2018-04-19 16:22:47 +0300 | [diff] [blame] | 27 | {{ SHARED.MACRO_INSTALL_SALT_MINIONS() }} |
| 28 | |
| 29 | {{ SHARED.MACRO_RUN_SALT_MASTER_UNDERLAY_STATES() }} |
| 30 | |
sgudz | d7f8ec9 | 2018-04-19 16:22:47 +0300 | [diff] [blame] | 31 | - description: "Workaround for rack01 compute generator" |
| 32 | cmd: | |
| 33 | set -e; |
| 34 | # Remove rack01 key |
| 35 | . /root/venv-reclass-tools/bin/activate; |
Tatyana Leontovich | 70e3713 | 2018-10-29 18:13:12 +0200 | [diff] [blame] | 36 | reclass-tools del-key parameters.reclass.storage.node.openstack_compute_rack01 /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/config/init.yml; |
sgudz | d7f8ec9 | 2018-04-19 16:22:47 +0300 | [diff] [blame] | 37 | # Add openstack_compute_node definition from system |
Tatyana Leontovich | 70e3713 | 2018-10-29 18:13:12 +0200 | [diff] [blame] | 38 | reclass-tools add-key 'classes' 'system.reclass.storage.system.openstack_compute_multi' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/config/init.yml --merge; |
sgudz | d7f8ec9 | 2018-04-19 16:22:47 +0300 | [diff] [blame] | 39 | node_name: {{ HOSTNAME_CFG01 }} |
| 40 | retry: {count: 1, delay: 10} |
| 41 | skip_fail: false |
| 42 | |
sgudz | dcf5d55 | 2018-08-21 23:27:14 +0300 | [diff] [blame] | 43 | - description: "Change path to internal storage for salt.control images" |
sgudz | 4fce07a | 2018-08-15 16:49:24 +0300 | [diff] [blame] | 44 | cmd: | |
| 45 | set -e; |
| 46 | . /root/venv-reclass-tools/bin/activate; |
Dennis Dmitriev | e15a4f4 | 2018-10-30 13:11:56 +0200 | [diff] [blame] | 47 | 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; |
| 48 | 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; |
sgudz | 4fce07a | 2018-08-15 16:49:24 +0300 | [diff] [blame] | 49 | node_name: {{ HOSTNAME_CFG01 }} |
| 50 | retry: {count: 1, delay: 10} |
| 51 | skip_fail: false |
| 52 | |
sgudz | d7f8ec9 | 2018-04-19 16:22:47 +0300 | [diff] [blame] | 53 | {{ SHARED.MACRO_GENERATE_INVENTORY() }} |
| 54 | |
| 55 | - description: "WR for dpdk pci to be in correct quotes" |
| 56 | cmd: | |
| 57 | set -e; |
| 58 | . /root/venv-reclass-tools/bin/activate; |
| 59 | reclass-tools add-key parameters._param.compute_vrouter_dpdk_pci '0000:05:00.0' /srv/salt/reclass/nodes/_generated/cmp001.{{ DOMAIN_NAME }}.yml; |
| 60 | reclass-tools add-key parameters._param.compute_vrouter_dpdk_pci '0000:05:00.0' /srv/salt/reclass/nodes/_generated/cmp002.{{ DOMAIN_NAME }}.yml; |
| 61 | node_name: {{ HOSTNAME_CFG01 }} |
| 62 | retry: {count: 1, delay: 10} |
| 63 | skip_fail: false |
| 64 | |
| 65 | {{ SHARED.MACRO_NETWORKING_WORKAROUNDS() }} |
| 66 | |
sgudz | 1016851 | 2018-08-06 15:20:50 +0300 | [diff] [blame] | 67 | - description: Rerun openssh after env model is generated |
sgudz | d7f8ec9 | 2018-04-19 16:22:47 +0300 | [diff] [blame] | 68 | cmd: | |
sgudz | 1016851 | 2018-08-06 15:20:50 +0300 | [diff] [blame] | 69 | salt-call state.sls openssh |
sgudz | d7f8ec9 | 2018-04-19 16:22:47 +0300 | [diff] [blame] | 70 | node_name: {{ HOSTNAME_CFG01 }} |
| 71 | retry: {count: 1, delay: 10} |
| 72 | skip_fail: false |
| 73 | |
sgudz | 1016851 | 2018-08-06 15:20:50 +0300 | [diff] [blame] | 74 | - description: Execute linux.network.host one more time after salt.minion to apply dynamically registered hosts on the cluster nodes |
| 75 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@linux:system' state.sls linux.network.host |
| 76 | node_name: {{ HOSTNAME_CFG01 }} |
| 77 | retry: {count: 2, delay: 10} |
| 78 | skip_fail: false |
| 79 | |
sgudz | d7f8ec9 | 2018-04-19 16:22:47 +0300 | [diff] [blame] | 80 | - description: Temporary workaround for removing cinder-volume from CTL nodes |
| 81 | cmd: | |
| 82 | sed -i 's/\-\ system\.cinder\.volume\.single//g' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/openstack/control.yml; |
| 83 | sed -i 's/\-\ system\.cinder\.volume\.notification\.messagingv2//g' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/openstack/control.yml; |
| 84 | node_name: {{ HOSTNAME_CFG01 }} |
| 85 | retry: {count: 1, delay: 5} |
| 86 | skip_fail: true |
| 87 | |
sgudz | dcf5d55 | 2018-08-21 23:27:14 +0300 | [diff] [blame] | 88 | - description: WR for mounting 1G hugepages before linux.state |
| 89 | cmd: | |
| 90 | salt 'cmp*' state.sls linux.system.hugepages; |
| 91 | salt 'cmp*' cmd.run "mount -o mode=775,pagesize=1G -t hugetlbfs Hugetlbfs-kvm /mnt/hugepages_1G"; |
| 92 | salt 'cmp*' cmd.run "echo 16 | sudo tee /sys/kernel/mm/hugepages/hugepages-1048576kB/nr_hugepages"; |
| 93 | node_name: {{ HOSTNAME_CFG01 }} |
| 94 | retry: {count: 1, delay: 10} |
| 95 | skip_fail: false |
| 96 | |
sgudz | d7f8ec9 | 2018-04-19 16:22:47 +0300 | [diff] [blame] | 97 | - description: Temporary WR for correct bridge name according to envoronment templates |
| 98 | cmd: | |
| 99 | sed -i 's/br\-ctl/br\_ctl/g' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/kvm.yml; |
| 100 | sed -i 's/br\-mgm/br\_mgm/g' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/kvm.yml; |
| 101 | node_name: {{ HOSTNAME_CFG01 }} |
| 102 | retry: {count: 1, delay: 10} |
| 103 | skip_fail: false |
| 104 | |
| 105 | - description: "WR for correct opencontrail_compute_iface value. Cookiecutter context doesn't have such parameter" |
| 106 | cmd: | |
| 107 | set -e; |
| 108 | . /root/venv-reclass-tools/bin/activate; |
| 109 | reclass-tools add-key parameters._param.opencontrail_compute_iface 'enp5s0f0' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/opencontrail/init.yml; |
| 110 | node_name: {{ HOSTNAME_CFG01 }} |
| 111 | retry: {count: 1, delay: 10} |
| 112 | skip_fail: false |
| 113 | |
| 114 | {{ SHARED.MACRO_BOOTSTRAP_ALL_MINIONS() }} |
| 115 | |
| 116 | ######################################## |
| 117 | # Spin up Control Plane VMs on KVM nodes |
| 118 | ######################################## |
| 119 | |
| 120 | - description: Execute 'libvirt' states to create necessary libvirt networks |
| 121 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False 'kvm*' state.sls libvirt |
| 122 | node_name: {{ HOSTNAME_CFG01 }} |
| 123 | retry: {count: 2, delay: 10} |
| 124 | skip_fail: false |
| 125 | |
| 126 | - description: Create VMs for control plane |
| 127 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False 'kvm*' state.sls salt.control |
| 128 | node_name: {{ HOSTNAME_CFG01 }} |
| 129 | retry: {count: 3, delay: 10} |
| 130 | skip_fail: false |
| 131 | |
| 132 | - description: '*Workaround* for waiting the control-plane VMs in the salt-key (instead of sleep)' |
| 133 | cmd: | |
| 134 | salt-key -l acc| sort > /tmp/current_keys.txt && |
| 135 | salt 'kvm*' cmd.run 'virsh list --name' | grep -v 'kvm'|sort|xargs -I {} fgrep {} /tmp/current_keys.txt |
| 136 | node_name: {{ HOSTNAME_CFG01 }} |
| 137 | retry: {count: 20, delay: 30} |
| 138 | skip_fail: false |
| 139 | |
| 140 | ######################################### |
| 141 | # Configure all running salt minion nodes |
| 142 | ######################################### |
| 143 | |
| 144 | - description: Hack resolv.conf on VCP nodes for internal services access |
| 145 | cmd: | |
| 146 | salt --hard-crash --state-output=mixed --state-verbose=False -C '* and not kvm* and not cmp* and not gtw* and not cfg*' cmd.run "echo 'nameserver 172.18.208.44' > /etc/resolv.conf;" |
| 147 | node_name: {{ HOSTNAME_CFG01 }} |
| 148 | retry: {count: 1, delay: 5} |
| 149 | skip_fail: false |
| 150 | |
| 151 | - description: Refresh pillars on all minions |
| 152 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.refresh_pillar |
| 153 | node_name: {{ HOSTNAME_CFG01 }} |
| 154 | retry: {count: 1, delay: 5} |
| 155 | skip_fail: false |
| 156 | |
| 157 | - description: Sync all salt resources |
| 158 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.sync_all && sleep 5 |
| 159 | node_name: {{ HOSTNAME_CFG01 }} |
| 160 | retry: {count: 1, delay: 5} |
| 161 | skip_fail: false |
| 162 | |
| 163 | - description: Show reclass-salt --top for generated nodes |
| 164 | cmd: reclass-salt --top -u /srv/salt/reclass/nodes/_generated/ |
| 165 | node_name: {{ HOSTNAME_CFG01 }} |
| 166 | retry: {count: 1, delay: 5} |
| 167 | skip_fail: false |
| 168 | |
| 169 | {{ SHARED.MACRO_BOOTSTRAP_ALL_MINIONS() }} |
Tatyana Leontovich | 4453dd6 | 2018-06-26 18:44:31 +0300 | [diff] [blame] | 170 | |
| 171 | {{SHARED.MACRO_CHECK_SALT_VERSION_SERVICES_ON_CFG()}} |
| 172 | |
sgudz | 1016851 | 2018-08-06 15:20:50 +0300 | [diff] [blame] | 173 | {{SHARED.MACRO_CHECK_SALT_VERSION_ON_NODES()}} |
| 174 | |
| 175 | - description: "Lab04 workaround: Give each node root acces with key from cfg01" |
| 176 | cmd: | |
| 177 | set -e; |
| 178 | set -x; |
| 179 | key=$(ssh-keygen -y -f /root/.ssh/id_rsa); |
| 180 | salt '*' cmd.run "echo $key >> /root/.ssh/authorized_keys"; |
| 181 | salt '*' cmd.run "service sshd restart" |
| 182 | node_name: {{ HOSTNAME_CFG01 }} |
| 183 | retry: {count: 1, delay: 5} |
| 184 | skip_fail: true |
| 185 | |
| 186 | - description: "Lab04 workaround: Control network access from cfg01 node using sshuttle via kvm01" |
| 187 | cmd: | |
| 188 | set -e; |
| 189 | set -x; |
| 190 | KVM01_DEPLOY_ADDRESS=$(salt-call --out=newline_values_only pillar.get _param:infra_kvm_node01_deploy_address); |
| 191 | apt-get install -y sshuttle; |
| 192 | sshuttle -r ${KVM01_DEPLOY_ADDRESS} 10.167.8.0/24 -D >/dev/null; |
| 193 | node_name: {{ HOSTNAME_CFG01 }} |
| 194 | retry: {count: 1, delay: 5} |
| 195 | skip_fail: true |