sgudz | f5a5122 | 2018-05-11 14:20:50 +0300 | [diff] [blame] | 1 | {% from 'cookied-bm-contrail-maas/underlay.yaml' import HOSTNAME_CFG01 with context %} |
| 2 | {% from 'cookied-bm-contrail-maas/underlay.yaml' import LAB_CONFIG_NAME with context %} |
| 3 | {% from 'cookied-bm-contrail-maas/underlay.yaml' import DOMAIN_NAME with context %} |
| 4 | {% from 'cookied-bm-contrail-maas/underlay.yaml' import REPOSITORY_SUITE with context %} |
| 5 | {% from 'cookied-bm-contrail-maas/underlay.yaml' import ETH1_IP_ADDRESS_CFG01 with context %} |
| 6 | {% from 'cookied-bm-contrail-maas/underlay.yaml' import MAAS_DHCP_POOL_START with context %} |
| 7 | {% from 'cookied-bm-contrail-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 | f5a5122 | 2018-05-11 14:20:50 +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-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 | f5a5122 | 2018-05-11 14:20:50 +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; |
Tatyana Leontovich | 70e3713 | 2018-10-29 18:13:12 +0200 | [diff] [blame] | 45 | reclass-tools del-key parameters.reclass.storage.node.openstack_compute_rack01 /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/config/init.yml; |
sgudz | f5a5122 | 2018-05-11 14:20:50 +0300 | [diff] [blame] | 46 | # Add openstack_compute_node definition from system |
Tatyana Leontovich | 70e3713 | 2018-10-29 18:13:12 +0200 | [diff] [blame] | 47 | 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 | f5a5122 | 2018-05-11 14:20:50 +0300 | [diff] [blame] | 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: Temporary workaround for removing cinder-volume from CTL nodes |
| 66 | cmd: | |
| 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 | |
| 73 | - description: Temporary WR for correct bridge name according to envoronment templates |
| 74 | cmd: | |
| 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; |
| 77 | node_name: {{ HOSTNAME_CFG01 }} |
| 78 | retry: {count: 1, delay: 10} |
| 79 | skip_fail: false |
| 80 | |
| 81 | - description: Update minion information |
| 82 | cmd: | |
| 83 | salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.sync_grains && |
| 84 | salt --hard-crash --state-output=mixed --state-verbose=False '*' mine.update && |
| 85 | salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.refresh_pillar && sleep 10 |
| 86 | node_name: {{ HOSTNAME_CFG01 }} |
| 87 | retry: {count: 1, delay: 10} |
| 88 | skip_fail: false |
| 89 | |
| 90 | - description: Rerun openssh after env model is generated |
| 91 | cmd: | |
| 92 | salt-call state.sls openssh |
| 93 | node_name: {{ HOSTNAME_CFG01 }} |
| 94 | retry: {count: 1, delay: 10} |
| 95 | skip_fail: false |
| 96 | |
| 97 | - description: Execute linux.network.host one more time after salt.minion to apply dynamically registered hosts on the cluster nodes |
| 98 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@linux:system' state.sls linux |
| 99 | node_name: {{ HOSTNAME_CFG01 }} |
| 100 | retry: {count: 1, delay: 10} |
| 101 | skip_fail: false |
| 102 | |
| 103 | - description: Configure rsyslog on nodes |
| 104 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@linux:system' state.sls rsyslog |
| 105 | node_name: {{ HOSTNAME_CFG01 }} |
| 106 | retry: {count: 1, delay: 10} |
| 107 | skip_fail: false |
| 108 | |
| 109 | - description: Configure maas.cluster |
| 110 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@salt:master' state.sls maas.cluster |
| 111 | node_name: {{ HOSTNAME_CFG01 }} |
| 112 | retry: {count: 1, delay: 10} |
| 113 | skip_fail: false |
| 114 | |
| 115 | - description: Configure maas.region |
| 116 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@salt:master' state.sls maas.region |
| 117 | node_name: {{ HOSTNAME_CFG01 }} |
| 118 | retry: {count: 3, delay: 10} |
| 119 | skip_fail: false |
| 120 | |
| 121 | - description: Configure dhcp for fabric |
| 122 | cmd: | |
| 123 | touch /root/API_KEY_FILE; |
| 124 | export PROFILE=mirantis; |
| 125 | export API_KEY_FILE=/root/API_KEY_FILE; |
| 126 | export MAAS_URL=http://{{ ETH1_IP_ADDRESS_CFG01 }}:5240/MAAS; |
| 127 | maas-region apikey --username=$PROFILE > $API_KEY_FILE; |
| 128 | maas login $PROFILE $MAAS_URL - < $API_KEY_FILE; |
| 129 | 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' |
| 130 | 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'; |
| 131 | maas $PROFILE vlan update 51 0 dhcp_on=True primary_rack=cfg01; |
| 132 | maas $PROFILE nodes read |grep status -A 1 -B 1; |
| 133 | node_name: {{ HOSTNAME_CFG01 }} |
| 134 | retry: {count: 1, delay: 10} |
| 135 | skip_fail: false |
| 136 | |
| 137 | - description: Comissioning nodes |
| 138 | cmd: | |
| 139 | salt-call state.apply maas.machines; |
| 140 | salt-call state.apply maas.machines.wait_for_ready; |
| 141 | node_name: {{ HOSTNAME_CFG01 }} |
| 142 | retry: {count: 1, delay: 10} |
| 143 | skip_fail: false |
| 144 | |
| 145 | - description: Assign IPs |
| 146 | cmd: | |
| 147 | salt-call state.sls maas.machines.assign_ip; |
| 148 | node_name: {{ HOSTNAME_CFG01 }} |
| 149 | retry: {count: 1, delay: 10} |
| 150 | skip_fail: false |
| 151 | |
| 152 | - description: Deploying BM nodes |
| 153 | cmd: | |
| 154 | salt-call maas.deploy_machines || true |
| 155 | salt-call state.apply maas.machines.wait_for_deployed; |
| 156 | node_name: {{ HOSTNAME_CFG01 }} |
| 157 | retry: {count: 1, delay: 10} |
| 158 | skip_fail: false |
| 159 | |
| 160 | - description: Configure ntp on all nodes |
| 161 | cmd: | |
| 162 | salt '*' state.sls ntp; |
| 163 | node_name: {{ HOSTNAME_CFG01 }} |
| 164 | retry: {count: 1, delay: 10} |
| 165 | skip_fail: false |
| 166 | |
| 167 | {{ SHARED.MACRO_NETWORKING_WORKAROUNDS() }} |
| 168 | |
| 169 | {{ SHARED.MACRO_BOOTSTRAP_ALL_MINIONS() }} |
| 170 | |
| 171 | ######################################## |
| 172 | # Spin up Control Plane VMs on KVM nodes |
| 173 | ######################################## |
| 174 | |
| 175 | - description: Execute 'libvirt' states to create necessary libvirt networks |
| 176 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False 'kvm*' state.sls libvirt |
| 177 | node_name: {{ HOSTNAME_CFG01 }} |
| 178 | retry: {count: 2, delay: 10} |
| 179 | skip_fail: false |
| 180 | |
| 181 | - description: Syncing before salt control state |
| 182 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.sync_all; |
| 183 | node_name: {{ HOSTNAME_CFG01 }} |
| 184 | retry: {count: 1, delay: 10} |
| 185 | skip_fail: false |
| 186 | |
| 187 | - description: Create VMs for control plane |
| 188 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False 'kvm*' state.sls salt.control |
| 189 | node_name: {{ HOSTNAME_CFG01 }} |
| 190 | retry: {count: 3, delay: 10} |
| 191 | skip_fail: false |
| 192 | |
| 193 | - description: '*Workaround* for waiting the control-plane VMs in the salt-key (instead of sleep)' |
| 194 | cmd: | |
| 195 | salt-key -l acc| sort > /tmp/current_keys.txt && |
| 196 | salt 'kvm*' cmd.run 'virsh list --name' | grep -v 'kvm'|sort|xargs -I {} fgrep {} /tmp/current_keys.txt |
| 197 | node_name: {{ HOSTNAME_CFG01 }} |
| 198 | retry: {count: 20, delay: 30} |
| 199 | skip_fail: false |
| 200 | |
| 201 | ######################################### |
| 202 | # Configure all running salt minion nodes |
| 203 | ######################################### |
| 204 | |
| 205 | - description: Hack resolv.conf on VCP nodes for internal services access |
| 206 | cmd: | |
| 207 | salt --hard-crash --state-output=mixed --state-verbose=False -C '*' cmd.run "echo 'nameserver 172.18.208.44' > /etc/resolv.conf;" |
| 208 | node_name: {{ HOSTNAME_CFG01 }} |
| 209 | retry: {count: 1, delay: 5} |
| 210 | skip_fail: false |
| 211 | |
| 212 | - description: Refresh pillars on all minions |
| 213 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.refresh_pillar |
| 214 | node_name: {{ HOSTNAME_CFG01 }} |
| 215 | retry: {count: 1, delay: 5} |
| 216 | skip_fail: false |
| 217 | |
| 218 | - description: Sync all salt resources |
| 219 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.sync_all && sleep 5 |
| 220 | node_name: {{ HOSTNAME_CFG01 }} |
| 221 | retry: {count: 1, delay: 5} |
| 222 | skip_fail: false |
| 223 | |
| 224 | - description: Show reclass-salt --top for generated nodes |
| 225 | cmd: reclass-salt --top -u /srv/salt/reclass/nodes/_generated/ |
| 226 | node_name: {{ HOSTNAME_CFG01 }} |
| 227 | retry: {count: 1, delay: 5} |
| 228 | skip_fail: false |
| 229 | |
| 230 | {{ SHARED.MACRO_BOOTSTRAP_ALL_MINIONS() }} |
Tatyana Leontovich | 4453dd6 | 2018-06-26 18:44:31 +0300 | [diff] [blame] | 231 | |
| 232 | {{SHARED.MACRO_CHECK_SALT_VERSION_SERVICES_ON_CFG()}} |
| 233 | |
| 234 | {{SHARED.MACRO_CHECK_SALT_VERSION_ON_NODES()}} |