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