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