Oleksii Butenko | 7c48def | 2017-10-03 12:41:05 +0300 | [diff] [blame^] | 1 | {% from 'cookied-bm-mcp-ocata-dvr-vxlan/underlay.yaml' import HOSTNAME_CFG01 with context %} |
| 2 | {% from 'cookied-bm-mcp-ocata-dvr-vxlan/underlay.yaml' import LAB_CONFIG_NAME with context %} |
| 3 | {% from 'cookied-bm-mcp-ocata-dvr-vxlan/underlay.yaml' import DOMAIN_NAME with context %} |
| 4 | |
| 5 | {% set SALT_MODELS_REPOSITORY = os_env('SALT_MODELS_REPOSITORY','https://gerrit.mcp.mirantis.net/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','cookied-bm-mcp-ocata-dvr-vxlan') %} |
| 10 | # Path to the context files used to render Cluster and Environment models |
| 11 | {%- set CLUSTER_CONTEXT_NAME = 'salt-context-cookiecutter-openstack_ovs_dvr_vxlan.yaml' %} |
| 12 | {%- set ENVIRONMENT_CONTEXT_NAMES = ['salt-context-vcp-environment.yaml', 'salt-context-lab03-environment.yaml'] %} |
| 13 | |
| 14 | {%- set CONTROL_VLAN = os_env('CONTROL_VLAN', '2416') %} |
| 15 | {%- set TENANT_VLAN = os_env('TENANT_VLAN', '2417') %} |
| 16 | |
| 17 | {% import 'shared-salt.yaml' as SHARED with context %} |
| 18 | |
| 19 | {{ SHARED.MACRO_INSTALL_SALT_MASTER() }} |
| 20 | |
| 21 | {{ SHARED.MACRO_GENERATE_COOKIECUTTER_MODEL(CONTROL_VLAN=CONTROL_VLAN, TENANT_VLAN=TENANT_VLAN) }} |
| 22 | |
| 23 | {{ SHARED.MACRO_GENERATE_AND_ENABLE_ENVIRONMENT_MODEL() }} |
| 24 | |
| 25 | - description: "Lab03 workaround: Control network access from cfg01 node using sshuttle via kvm01" |
| 26 | cmd: | |
| 27 | set -e; |
| 28 | KVM01_DEPLOY_ADDRESS=`salt-call --out=newline_values_only pillar.get _param:infra_kvm_node01_deploy_address`; |
| 29 | apt-get install sshuttle -y; |
| 30 | sshuttle -r ${KVM01_DEPLOY_ADDRESS} {{ SHARED.IPV4_NET_CONTROL }} -D |
| 31 | node_name: {{ HOSTNAME_CFG01 }} |
| 32 | retry: {count: 1, delay: 5} |
| 33 | skip_fail: false |
| 34 | |
| 35 | - description: "Workaround for PROD-15405: remove OpenStack telemetry nodes from the cluster" |
| 36 | cmd: | |
| 37 | set -e; |
| 38 | sed -i '/system.salt.control.cluster.openstack_telemetry_cluster/d' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/kvm.yml; |
| 39 | sed -i '/system.reclass.storage.system.openstack_telemetry_cluster/d' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/config.yml; |
| 40 | reclass-tools del-key parameters.reclass.storage.node.openstack_telemetry_node01 /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/config.yml; |
| 41 | reclass-tools del-key parameters.reclass.storage.node.openstack_telemetry_node02 /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/config.yml; |
| 42 | reclass-tools del-key parameters.reclass.storage.node.openstack_telemetry_node03 /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/config.yml; |
| 43 | reclass-tools del-key parameters.salt.control.cluster.internal.node.mdb01 /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/kvm.yml; |
| 44 | reclass-tools del-key parameters.salt.control.cluster.internal.node.mdb02 /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/kvm.yml; |
| 45 | reclass-tools del-key parameters.salt.control.cluster.internal.node.mdb03 /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/kvm.yml; |
| 46 | |
| 47 | node_name: {{ HOSTNAME_CFG01 }} |
| 48 | retry: {count: 1, delay: 10} |
| 49 | skip_fail: false |
| 50 | |
| 51 | - description: "Workaround for rack01 compute generator" |
| 52 | cmd: | |
| 53 | set -e; |
| 54 | # Remove rack01 key |
| 55 | reclass-tools del-key parameters.reclass.storage.node.openstack_compute_rack01 /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/config.yml; |
| 56 | |
| 57 | # Add openstack_compute_node definition from system |
| 58 | reclass-tools add-key 'classes' 'system.reclass.storage.system.openstack_compute_multi' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/config.yml --merge; |
| 59 | |
| 60 | # Set ipaddresses for our nodes |
| 61 | reclass-tools add-key parameters._param.openstack_compute_node01_control_address {{ SHARED.IPV4_NET_CONTROL_PREFIX }}.101 /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/config.yml; |
| 62 | reclass-tools add-key parameters._param.openstack_compute_node02_control_address {{ SHARED.IPV4_NET_CONTROL_PREFIX }}.102 /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/config.yml; |
| 63 | reclass-tools add-key parameters._param.openstack_compute_node01_tenant_address {{ SHARED.IPV4_NET_TENANT_PREFIX }}.101 /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/config.yml; |
| 64 | reclass-tools add-key parameters._param.openstack_compute_node02_tenant_address {{ SHARED.IPV4_NET_TENANT_PREFIX }}.102 /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/config.yml; |
| 65 | node_name: {{ HOSTNAME_CFG01 }} |
| 66 | retry: {count: 1, delay: 10} |
| 67 | skip_fail: false |
| 68 | |
| 69 | {{ SHARED.MACRO_CONFIGURE_RECLASS(FORMULA_SERVICES='"linux" "reclass" "salt" "openssh" "ntp" "git" "nginx" "collectd" "sensu" "heka" "sphinx" "keystone" "mysql" "grafana" "haproxy" "rsyslog" "horizon" "prometheus" "telegraf" "elasticsearch" "powerdns" "glusterfs" "xtrabackup" "maas"') }} |
| 70 | |
| 71 | {{ SHARED.MACRO_INSTALL_SALT_MINIONS() }} |
| 72 | |
| 73 | {{ SHARED.MACRO_RUN_SALT_MASTER_UNDERLAY_STATES() }} |
| 74 | |
| 75 | |
| 76 | {{ SHARED.MACRO_GENERATE_INVENTORY() }} |
| 77 | |
| 78 | {{ SHARED.MACRO_NETWORKING_WORKAROUNDS() }} |
| 79 | |
| 80 | {{ SHARED.MACRO_BOOTSTRAP_ALL_MINIONS() }} |
| 81 | |
| 82 | ######################################## |
| 83 | # Spin up Control Plane VMs on KVM nodes |
| 84 | ######################################## |
| 85 | |
| 86 | - description: Execute 'libvirt' states to create necessary libvirt networks |
| 87 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False 'kvm*' state.sls libvirt |
| 88 | node_name: {{ HOSTNAME_CFG01 }} |
| 89 | retry: {count: 2, delay: 10} |
| 90 | skip_fail: false |
| 91 | |
| 92 | - description: Create VMs for control plane |
| 93 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False 'kvm*' state.sls salt.control |
| 94 | node_name: {{ HOSTNAME_CFG01 }} |
| 95 | retry: {count: 3, delay: 10} |
| 96 | skip_fail: false |
| 97 | |
| 98 | - description: '*Workaround* for waiting the control-plane VMs in the salt-key (instead of sleep)' |
| 99 | cmd: | |
| 100 | salt-key -l acc| sort > /tmp/current_keys.txt && |
| 101 | salt 'kvm*' cmd.run 'virsh list --name' | grep -v 'kvm'|sort|xargs -I {} fgrep {} /tmp/current_keys.txt |
| 102 | node_name: {{ HOSTNAME_CFG01 }} |
| 103 | retry: {count: 20, delay: 30} |
| 104 | skip_fail: false |
| 105 | |
| 106 | ######################################### |
| 107 | # Configure all running salt minion nodes |
| 108 | ######################################### |
| 109 | |
| 110 | - description: Refresh pillars on all minions |
| 111 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.refresh_pillar |
| 112 | node_name: {{ HOSTNAME_CFG01 }} |
| 113 | retry: {count: 1, delay: 5} |
| 114 | skip_fail: false |
| 115 | |
| 116 | - description: Sync all salt resources |
| 117 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.sync_all && sleep 5 |
| 118 | node_name: {{ HOSTNAME_CFG01 }} |
| 119 | retry: {count: 1, delay: 5} |
| 120 | skip_fail: false |
| 121 | |
| 122 | - description: Show reclass-salt --top for generated nodes |
| 123 | cmd: reclass-salt --top -u /srv/salt/reclass/nodes/_generated/ |
| 124 | node_name: {{ HOSTNAME_CFG01 }} |
| 125 | retry: {count: 1, delay: 5} |
| 126 | skip_fail: false |
| 127 | |
| 128 | {{ SHARED.MACRO_BOOTSTRAP_ALL_MINIONS() }} |