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