sgudz | b5d72e6 | 2018-05-31 12:20:51 +0300 | [diff] [blame] | 1 | {% from 'cookied-bm-contrail-nfv-maas/underlay.yaml' import HOSTNAME_CFG01 with context %} |
| 2 | {% from 'cookied-bm-contrail-nfv-maas/underlay.yaml' import LAB_CONFIG_NAME with context %} |
| 3 | {% from 'cookied-bm-contrail-nfv-maas/underlay.yaml' import DOMAIN_NAME with context %} |
| 4 | {% from 'cookied-bm-contrail-nfv-maas/underlay.yaml' import REPOSITORY_SUITE with context %} |
| 5 | {% from 'cookied-bm-contrail-nfv-maas/underlay.yaml' import ETH1_IP_ADDRESS_CFG01 with context %} |
| 6 | {% from 'cookied-bm-contrail-nfv-maas/underlay.yaml' import MAAS_DHCP_POOL_START with context %} |
| 7 | {% from 'cookied-bm-contrail-nfv-maas/underlay.yaml' import MAAS_DHCP_POOL_END with context %} |
| 8 | |
Dennis Dmitriev | 0f27231 | 2018-10-01 13:29:40 +0300 | [diff] [blame^] | 9 | {% set SALT_MODELS_REPOSITORY = os_env('SALT_MODELS_REPOSITORY','https://gerrit.mcp.mirantis.com/salt-models/mcp-virtual-lab') %} |
sgudz | b5d72e6 | 2018-05-31 12:20:51 +0300 | [diff] [blame] | 10 | # Other salt model repository parameters see in shared-salt.yaml |
| 11 | |
| 12 | {% set ENVIRONMENT_MODEL_INVENTORY_NAME = os_env('ENVIRONMENT_MODEL_INVENTORY_NAME','physical-cookied-bm-contrail-nfv-maas') %} |
| 13 | # Path to the context files used to render Cluster and Environment models |
| 14 | {%- set CLUSTER_CONTEXT_NAME = 'salt-context-cookiecutter-contrail.yaml' %} |
| 15 | {%- set ENVIRONMENT_CONTEXT_NAMES = ['salt-context-environment.yaml','lab04-physical-inventory.yaml'] %} |
| 16 | {%- set CONTROL_VLAN = os_env('CONTROL_VLAN', '2422') %} |
| 17 | {%- set TENANT_VLAN = os_env('TENANT_VLAN', '2423') %} |
| 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 | b5d72e6 | 2018-05-31 12:20:51 +0300 | [diff] [blame] | 28 | {{ SHARED.MACRO_INSTALL_SALT_MINIONS() }} |
| 29 | |
| 30 | {{ SHARED.MACRO_RUN_SALT_MASTER_UNDERLAY_STATES() }} |
| 31 | |
| 32 | - description: Upload maas template |
| 33 | upload: |
| 34 | local_path: {{ config.salt_deploy.templates_dir }}{{ LAB_CONFIG_NAME }}/ |
| 35 | local_filename: maas.yml |
| 36 | remote_path: /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/ |
| 37 | node_name: {{ HOSTNAME_CFG01 }} |
| 38 | skip_fail: False |
| 39 | |
| 40 | - description: "Workaround for rack01 compute generator" |
| 41 | cmd: | |
| 42 | set -e; |
| 43 | # Remove rack01 key |
| 44 | . /root/venv-reclass-tools/bin/activate; |
| 45 | reclass-tools del-key parameters.reclass.storage.node.openstack_compute_rack01 /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/config.yml; |
| 46 | # Add openstack_compute_node definition from system |
| 47 | reclass-tools add-key 'classes' 'system.reclass.storage.system.openstack_compute_multi' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/config.yml --merge; |
| 48 | node_name: {{ HOSTNAME_CFG01 }} |
| 49 | retry: {count: 1, delay: 10} |
| 50 | skip_fail: false |
| 51 | |
| 52 | - description: "WR for changing image to proposed" |
| 53 | cmd: | |
| 54 | set -e; |
| 55 | # Add message_queu host for opencontrail |
| 56 | . /root/venv-reclass-tools/bin/activate; |
| 57 | reclass-tools add-key parameters._param.salt_control_xenial_image 'http://ci.mcp.mirantis.net:8085/images/ubuntu-16-04-x64-mcp{{ REPOSITORY_SUITE }}.qcow2' /srv/salt/reclass/classes/cluster//{{ LAB_CONFIG_NAME }}infra/init.yml; |
| 58 | reclass-tools add-key parameters._param.salt_control_trusty_image 'http://ci.mcp.mirantis.net:8085/images/ubuntu-14-04-x64-mcp{{ REPOSITORY_SUITE }}.qcow2' /srv/salt/reclass/classes/cluster//{{ LAB_CONFIG_NAME }}infra/init.yml; |
| 59 | node_name: {{ HOSTNAME_CFG01 }} |
| 60 | retry: {count: 1, delay: 10} |
| 61 | skip_fail: false |
| 62 | |
| 63 | {{ SHARED.MACRO_GENERATE_INVENTORY() }} |
| 64 | |
| 65 | - description: "WR for dpdk pci to be in correct quotes" |
| 66 | cmd: | |
| 67 | set -e; |
| 68 | . /root/venv-reclass-tools/bin/activate; |
| 69 | reclass-tools add-key parameters._param.compute_vrouter_dpdk_pci '0000:05:00.0' /srv/salt/reclass/nodes/_generated/cmp001.{{ DOMAIN_NAME }}.yml; |
| 70 | reclass-tools add-key parameters._param.compute_vrouter_dpdk_pci '0000:05:00.0' /srv/salt/reclass/nodes/_generated/cmp002.{{ DOMAIN_NAME }}.yml; |
| 71 | node_name: {{ HOSTNAME_CFG01 }} |
| 72 | retry: {count: 1, delay: 10} |
| 73 | skip_fail: false |
| 74 | |
| 75 | - description: Temporary workaround for removing cinder-volume from CTL nodes |
| 76 | cmd: | |
| 77 | sed -i 's/\-\ system\.cinder\.volume\.single//g' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/openstack/control.yml; |
| 78 | sed -i 's/\-\ system\.cinder\.volume\.notification\.messagingv2//g' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/openstack/control.yml; |
| 79 | node_name: {{ HOSTNAME_CFG01 }} |
| 80 | retry: {count: 1, delay: 5} |
| 81 | skip_fail: true |
| 82 | |
| 83 | - description: Temporary WR for correct bridge name according to envoronment templates |
| 84 | cmd: | |
| 85 | sed -i 's/br\-ctl/br\_ctl/g' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/kvm.yml; |
| 86 | sed -i 's/br\-mgm/br\_mgm/g' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/kvm.yml; |
| 87 | node_name: {{ HOSTNAME_CFG01 }} |
| 88 | retry: {count: 1, delay: 10} |
| 89 | skip_fail: false |
| 90 | |
| 91 | - description: Update minion information |
| 92 | cmd: | |
| 93 | salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.sync_grains && |
| 94 | salt --hard-crash --state-output=mixed --state-verbose=False '*' mine.update && |
| 95 | salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.refresh_pillar && sleep 10 |
| 96 | node_name: {{ HOSTNAME_CFG01 }} |
| 97 | retry: {count: 1, delay: 10} |
| 98 | skip_fail: false |
| 99 | |
| 100 | - description: Rerun openssh after env model is generated |
| 101 | cmd: | |
| 102 | salt-call state.sls openssh |
| 103 | node_name: {{ HOSTNAME_CFG01 }} |
| 104 | retry: {count: 1, delay: 10} |
| 105 | skip_fail: false |
| 106 | |
| 107 | - description: Execute linux.network.host one more time after salt.minion to apply dynamically registered hosts on the cluster nodes |
| 108 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@linux:system' state.sls linux |
| 109 | node_name: {{ HOSTNAME_CFG01 }} |
| 110 | retry: {count: 1, delay: 10} |
| 111 | skip_fail: false |
| 112 | |
| 113 | - description: Configure rsyslog on nodes |
| 114 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@linux:system' state.sls rsyslog |
| 115 | node_name: {{ HOSTNAME_CFG01 }} |
| 116 | retry: {count: 1, delay: 10} |
| 117 | skip_fail: false |
| 118 | |
| 119 | - description: Configure maas.cluster |
| 120 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@salt:master' state.sls maas.cluster |
| 121 | node_name: {{ HOSTNAME_CFG01 }} |
| 122 | retry: {count: 1, delay: 10} |
| 123 | skip_fail: false |
| 124 | |
| 125 | - description: Configure maas.region |
| 126 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@salt:master' state.sls maas.region |
| 127 | node_name: {{ HOSTNAME_CFG01 }} |
| 128 | retry: {count: 3, delay: 10} |
| 129 | skip_fail: false |
| 130 | |
| 131 | - description: Configure dhcp for fabric |
| 132 | cmd: | |
| 133 | touch /root/API_KEY_FILE; |
| 134 | export PROFILE=mirantis; |
| 135 | export API_KEY_FILE=/root/API_KEY_FILE; |
| 136 | export MAAS_URL=http://{{ ETH1_IP_ADDRESS_CFG01 }}:5240/MAAS; |
| 137 | maas-region apikey --username=$PROFILE > $API_KEY_FILE; |
| 138 | maas login $PROFILE $MAAS_URL - < $API_KEY_FILE; |
| 139 | maas $PROFILE ipranges create type=dynamic start_ip={{ MAAS_DHCP_POOL_START }} end_ip={{ MAAS_DHCP_POOL_END }} comment='Reserved dynamic range for HW and VCP nodes' |
| 140 | maas $PROFILE ipranges create type=reserved start_ip={{ ETH1_IP_ADDRESS_CFG01 }} end_ip={{ ETH1_IP_ADDRESS_CFG01 }} comment='This is a reserved IP for cfg with maas node'; |
| 141 | maas $PROFILE vlan update 51 0 dhcp_on=True primary_rack=cfg01; |
| 142 | maas $PROFILE nodes read |grep status -A 1 -B 1; |
| 143 | node_name: {{ HOSTNAME_CFG01 }} |
| 144 | retry: {count: 1, delay: 10} |
| 145 | skip_fail: false |
| 146 | |
| 147 | - description: Comissioning nodes |
| 148 | cmd: | |
| 149 | salt-call state.apply maas.machines; |
| 150 | salt-call state.apply maas.machines.wait_for_ready; |
| 151 | node_name: {{ HOSTNAME_CFG01 }} |
| 152 | retry: {count: 1, delay: 10} |
| 153 | skip_fail: false |
| 154 | |
| 155 | - description: Assign IPs |
| 156 | cmd: | |
| 157 | salt-call state.sls maas.machines.assign_ip; |
| 158 | node_name: {{ HOSTNAME_CFG01 }} |
| 159 | retry: {count: 1, delay: 10} |
| 160 | skip_fail: false |
| 161 | |
| 162 | - description: Deploying BM nodes |
| 163 | cmd: | |
| 164 | salt-call maas.deploy_machines || true |
| 165 | salt-call state.apply maas.machines.wait_for_deployed; |
| 166 | node_name: {{ HOSTNAME_CFG01 }} |
| 167 | retry: {count: 1, delay: 10} |
| 168 | skip_fail: false |
| 169 | |
| 170 | - description: Configure ntp on all nodes |
| 171 | cmd: | |
| 172 | salt '*' state.sls ntp; |
| 173 | node_name: {{ HOSTNAME_CFG01 }} |
| 174 | retry: {count: 1, delay: 10} |
| 175 | skip_fail: false |
| 176 | |
| 177 | {{ SHARED.MACRO_NETWORKING_WORKAROUNDS() }} |
| 178 | |
| 179 | {{ SHARED.MACRO_BOOTSTRAP_ALL_MINIONS() }} |
| 180 | |
| 181 | ######################################## |
| 182 | # Spin up Control Plane VMs on KVM nodes |
| 183 | ######################################## |
| 184 | |
| 185 | - description: Execute 'libvirt' states to create necessary libvirt networks |
| 186 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False 'kvm*' state.sls libvirt |
| 187 | node_name: {{ HOSTNAME_CFG01 }} |
| 188 | retry: {count: 2, delay: 10} |
| 189 | skip_fail: false |
| 190 | |
| 191 | - description: Syncing before salt control state |
| 192 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.sync_all; |
| 193 | node_name: {{ HOSTNAME_CFG01 }} |
| 194 | retry: {count: 1, delay: 10} |
| 195 | skip_fail: false |
| 196 | |
| 197 | - description: Create VMs for control plane |
| 198 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False 'kvm*' state.sls salt.control |
| 199 | node_name: {{ HOSTNAME_CFG01 }} |
| 200 | retry: {count: 3, delay: 10} |
| 201 | skip_fail: false |
| 202 | |
| 203 | - description: '*Workaround* for waiting the control-plane VMs in the salt-key (instead of sleep)' |
| 204 | cmd: | |
| 205 | salt-key -l acc| sort > /tmp/current_keys.txt && |
| 206 | salt 'kvm*' cmd.run 'virsh list --name' | grep -v 'kvm'|sort|xargs -I {} fgrep {} /tmp/current_keys.txt |
| 207 | node_name: {{ HOSTNAME_CFG01 }} |
| 208 | retry: {count: 20, delay: 30} |
| 209 | skip_fail: false |
| 210 | |
| 211 | ######################################### |
| 212 | # Configure all running salt minion nodes |
| 213 | ######################################### |
| 214 | |
| 215 | - description: Hack resolv.conf on VCP nodes for internal services access |
| 216 | cmd: | |
| 217 | salt --hard-crash --state-output=mixed --state-verbose=False -C '*' cmd.run "echo 'nameserver 172.18.208.44' > /etc/resolv.conf;" |
| 218 | node_name: {{ HOSTNAME_CFG01 }} |
| 219 | retry: {count: 1, delay: 5} |
| 220 | skip_fail: false |
| 221 | |
| 222 | - description: Refresh pillars on all minions |
| 223 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.refresh_pillar |
| 224 | node_name: {{ HOSTNAME_CFG01 }} |
| 225 | retry: {count: 1, delay: 5} |
| 226 | skip_fail: false |
| 227 | |
| 228 | - description: Sync all salt resources |
| 229 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.sync_all && sleep 5 |
| 230 | node_name: {{ HOSTNAME_CFG01 }} |
| 231 | retry: {count: 1, delay: 5} |
| 232 | skip_fail: false |
| 233 | |
| 234 | - description: Show reclass-salt --top for generated nodes |
| 235 | cmd: reclass-salt --top -u /srv/salt/reclass/nodes/_generated/ |
| 236 | node_name: {{ HOSTNAME_CFG01 }} |
| 237 | retry: {count: 1, delay: 5} |
| 238 | skip_fail: false |
| 239 | |
| 240 | {{ SHARED.MACRO_BOOTSTRAP_ALL_MINIONS() }} |
Tatyana Leontovich | 4453dd6 | 2018-06-26 18:44:31 +0300 | [diff] [blame] | 241 | |
| 242 | {{SHARED.MACRO_CHECK_SALT_VERSION_SERVICES_ON_CFG()}} |
| 243 | |
| 244 | {{SHARED.MACRO_CHECK_SALT_VERSION_ON_NODES()}} |