abaraniuk | e46fea5 | 2018-10-04 16:13:22 +0300 | [diff] [blame] | 1 | {% from 'cookied-bm-oc40-queens/underlay.yaml' import HOSTNAME_CFG01 with context %} |
| 2 | {% from 'cookied-bm-oc40-queens/underlay.yaml' import LAB_CONFIG_NAME with context %} |
| 3 | {% from 'cookied-bm-oc40-queens/underlay.yaml' import DOMAIN_NAME with context %} |
| 4 | |
| 5 | {% set SALT_MODELS_REPOSITORY = os_env('SALT_MODELS_REPOSITORY','https://gerrit.mcp.mirantis.com/salt-models/mcp-virtual-lab') %} |
| 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-oc40-queens') %} |
| 10 | # Path to the context files used to render Cluster and Environment models |
| 11 | {%- set CLUSTER_CONTEXT_NAME = os_env('CLUSTER_CONTEXT_NAME', 'salt-context-cookiecutter-contrail.yaml') %} |
| 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 | {% import 'shared-salt.yaml' as SHARED with context %} |
| 17 | |
| 18 | {{ SHARED.MACRO_INSTALL_SALT_MASTER() }} |
| 19 | |
| 20 | {{ SHARED.MACRO_GENERATE_COOKIECUTTER_MODEL(CONTROL_VLAN=CONTROL_VLAN, TENANT_VLAN=TENANT_VLAN) }} |
| 21 | |
| 22 | {{ SHARED.MACRO_GENERATE_AND_ENABLE_ENVIRONMENT_MODEL() }} |
| 23 | |
| 24 | {{ SHARED.MACRO_CONFIGURE_RECLASS(FORMULA_SERVICES='\*') }} |
| 25 | |
| 26 | {{ SHARED.MACRO_INSTALL_SALT_MINIONS() }} |
| 27 | |
| 28 | {{ SHARED.MACRO_RUN_SALT_MASTER_UNDERLAY_STATES() }} |
| 29 | |
| 30 | - description: "Change path to internal storage for salt.control images" |
| 31 | cmd: | |
| 32 | set -e; |
| 33 | . /root/venv-reclass-tools/bin/activate; |
| 34 | 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; |
| 35 | 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; |
| 36 | node_name: {{ HOSTNAME_CFG01 }} |
| 37 | retry: {count: 1, delay: 10} |
| 38 | skip_fail: false |
| 39 | |
| 40 | - description: Temporary workaround for removing cinder-volume from CTL nodes |
| 41 | cmd: | |
| 42 | sed -i 's/\-\ system\.cinder\.volume\.single//g' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/openstack/control.yml; |
| 43 | sed -i 's/\-\ system\.cinder\.volume\.notification\.messagingv2//g' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/openstack/control.yml; |
| 44 | node_name: {{ HOSTNAME_CFG01 }} |
| 45 | retry: {count: 1, delay: 5} |
| 46 | skip_fail: true |
| 47 | |
| 48 | - description: Temporary WR for correct bridge name according to envoronment templates |
| 49 | cmd: | |
| 50 | sed -i 's/br\-ctl/br\_ctl/g' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/kvm.yml; |
| 51 | sed -i 's/br\-mgm/br\_mgm/g' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/kvm.yml; |
| 52 | node_name: {{ HOSTNAME_CFG01 }} |
| 53 | retry: {count: 1, delay: 10} |
| 54 | skip_fail: false |
| 55 | |
| 56 | {{ SHARED.MACRO_GENERATE_INVENTORY() }} |
| 57 | |
| 58 | {{ SHARED.MACRO_NETWORKING_WORKAROUNDS() }} |
| 59 | |
| 60 | - description: Update minion information |
| 61 | cmd: | |
| 62 | salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.sync_all && |
| 63 | salt --hard-crash --state-output=mixed --state-verbose=False '*' mine.update && |
| 64 | salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.refresh_pillar && sleep 10 |
| 65 | node_name: {{ HOSTNAME_CFG01 }} |
| 66 | retry: {count: 1, delay: 10} |
| 67 | skip_fail: false |
| 68 | |
| 69 | - description: Rerun openssh after env model is generated |
| 70 | cmd: | |
| 71 | salt-call state.sls openssh |
| 72 | node_name: {{ HOSTNAME_CFG01 }} |
| 73 | retry: {count: 1, delay: 10} |
| 74 | skip_fail: false |
| 75 | |
| 76 | - description: Execute linux.network.host one more time after salt.minion to apply dynamically registered hosts on the cluster nodes |
| 77 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@linux:system' state.sls linux.network.host |
| 78 | node_name: {{ HOSTNAME_CFG01 }} |
| 79 | retry: {count: 2, delay: 10} |
| 80 | skip_fail: false |
| 81 | |
| 82 | {{ SHARED.MACRO_BOOTSTRAP_ALL_MINIONS() }} |
| 83 | |
| 84 | ######################################## |
| 85 | # Spin up Control Plane VMs on KVM nodes |
| 86 | ######################################## |
| 87 | |
| 88 | - description: Execute 'libvirt' states to create necessary libvirt networks |
| 89 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False 'kvm*' state.sls libvirt |
| 90 | node_name: {{ HOSTNAME_CFG01 }} |
| 91 | retry: {count: 2, delay: 10} |
| 92 | skip_fail: false |
| 93 | |
| 94 | - description: Create VMs for control plane |
| 95 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False 'kvm*' state.sls salt.control |
| 96 | node_name: {{ HOSTNAME_CFG01 }} |
| 97 | retry: {count: 3, delay: 10} |
| 98 | skip_fail: false |
| 99 | |
| 100 | - description: '*Workaround* for waiting the control-plane VMs in the salt-key (instead of sleep)' |
| 101 | cmd: | |
| 102 | salt-key -l acc| sort > /tmp/current_keys.txt && |
| 103 | salt 'kvm*' cmd.run 'virsh list --name' | grep -v 'kvm'|sort|xargs -I {} fgrep {} /tmp/current_keys.txt |
| 104 | node_name: {{ HOSTNAME_CFG01 }} |
| 105 | retry: {count: 20, delay: 30} |
| 106 | skip_fail: false |
| 107 | |
| 108 | ######################################### |
| 109 | # Configure all running salt minion nodes |
| 110 | ######################################### |
| 111 | |
| 112 | - description: Hack resolv.conf on VCP nodes for internal services access |
| 113 | cmd: | |
| 114 | salt --hard-crash --state-output=mixed --state-verbose=False -C '* and not cfg*' cmd.run "echo 'nameserver 172.18.208.44' > /etc/resolv.conf;" |
| 115 | node_name: {{ HOSTNAME_CFG01 }} |
| 116 | retry: {count: 1, delay: 5} |
| 117 | skip_fail: false |
| 118 | |
| 119 | - description: Refresh pillars on all minions |
| 120 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.refresh_pillar |
| 121 | node_name: {{ HOSTNAME_CFG01 }} |
| 122 | retry: {count: 1, delay: 5} |
| 123 | skip_fail: false |
| 124 | |
| 125 | - description: Sync all salt resources |
| 126 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.sync_all && sleep 5 |
| 127 | node_name: {{ HOSTNAME_CFG01 }} |
| 128 | retry: {count: 1, delay: 5} |
| 129 | skip_fail: false |
| 130 | |
| 131 | - description: Show reclass-salt --top for generated nodes |
| 132 | cmd: reclass-salt --top -u /srv/salt/reclass/nodes/_generated/ |
| 133 | node_name: {{ HOSTNAME_CFG01 }} |
| 134 | retry: {count: 1, delay: 5} |
| 135 | skip_fail: false |
| 136 | |
| 137 | {{ SHARED.MACRO_BOOTSTRAP_ALL_MINIONS() }} |
| 138 | |
| 139 | {{SHARED.MACRO_CHECK_SALT_VERSION_SERVICES_ON_CFG()}} |
| 140 | |
| 141 | {{SHARED.MACRO_CHECK_SALT_VERSION_ON_NODES()}} |
| 142 | |
| 143 | - description: "Lab04 workaround: Give each node root acces with key from cfg01" |
| 144 | cmd: | |
| 145 | set -e; |
| 146 | set -x; |
| 147 | key=$(ssh-keygen -y -f /root/.ssh/id_rsa); |
| 148 | salt '*' cmd.run "echo $key >> /root/.ssh/authorized_keys"; |
| 149 | salt '*' cmd.run "service sshd restart" |
| 150 | node_name: {{ HOSTNAME_CFG01 }} |
| 151 | retry: {count: 1, delay: 5} |
| 152 | skip_fail: true |