Dmitry Tyzhnenko | 34595f8 | 2018-06-12 19:03:12 +0300 | [diff] [blame] | 1 | {% from 'cookied-bm-mcp-pike-k8s-contrail/underlay.yaml' import HOSTNAME_CFG01 with context %} |
| 2 | {% from 'cookied-bm-mcp-pike-k8s-contrail/underlay.yaml' import HOSTNAME_CMP001 with context %} |
| 3 | {% from 'cookied-bm-mcp-pike-k8s-contrail/underlay.yaml' import LAB_CONFIG_NAME with context %} |
| 4 | {% from 'cookied-bm-mcp-pike-k8s-contrail/underlay.yaml' import DOMAIN_NAME with context %} |
| 5 | {% from 'cookied-bm-mcp-pike-k8s-contrail/underlay.yaml' import ETH0_IP_ADDRESS_CFG01 with context %} |
| 6 | {% from 'cookied-bm-mcp-pike-k8s-contrail/underlay.yaml' import ETH0_IP_ADDRESS_CMP001 with context %} |
| 7 | {% from 'cookied-bm-mcp-pike-k8s-contrail/underlay.yaml' import HOSTNAME_KVM01 with context %} |
| 8 | {% from 'cookied-bm-mcp-pike-k8s-contrail/underlay.yaml' import HOSTNAME_KVM02 with context %} |
| 9 | {% from 'cookied-bm-mcp-pike-k8s-contrail/underlay.yaml' import HOSTNAME_KVM03 with context %} |
| 10 | |
| 11 | {% set SALT_MODELS_REPOSITORY = os_env('SALT_MODELS_REPOSITORY','https://gerrit.mcp.mirantis.net/salt-models/mcp-virtual-lab') %} |
| 12 | # Other salt model repository parameters see in shared-salt.yaml |
| 13 | |
| 14 | # Name of the context file (without extension, that is fixed .yaml) used to render the Environment model |
| 15 | {% set ENVIRONMENT_MODEL_INVENTORY_NAME = os_env('ENVIRONMENT_MODEL_INVENTORY_NAME','bm-mcp-pike-k8s-contrail') %} |
| 16 | # Path to the context files used to render Cluster and Environment models |
| 17 | {%- set CLUSTER_CONTEXT_NAME = 'salt-context-cookiecutter-k8s-contrail.yaml' %} |
| 18 | {%- set ENVIRONMENT_CONTEXT_NAMES = ['salt-context-environment.yaml','lab04-upgrade-physical-inventory.yaml'] %} |
| 19 | {%- set CONTROL_VLAN = os_env('CONTROL_VLAN', '2410') %} |
| 20 | {%- set TENANT_VLAN = os_env('TENANT_VLAN', '2411') %} |
| 21 | |
| 22 | |
| 23 | {% import 'shared-salt.yaml' as SHARED with context %} |
| 24 | |
| 25 | {{ SHARED.MACRO_INSTALL_SALT_MASTER() }} |
| 26 | |
| 27 | {{ SHARED.MACRO_GENERATE_COOKIECUTTER_MODEL(CONTROL_VLAN=CONTROL_VLAN, TENANT_VLAN=TENANT_VLAN) }} |
| 28 | |
| 29 | {{ SHARED.MACRO_GENERATE_AND_ENABLE_ENVIRONMENT_MODEL() }} |
| 30 | |
| 31 | {{ 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" "backupninja" "jenkins" "fluentd" "auditd"') }} |
| 32 | |
| 33 | {{ SHARED.MACRO_INSTALL_SALT_MINIONS() }} |
| 34 | |
| 35 | {{ SHARED.MACRO_RUN_SALT_MASTER_UNDERLAY_STATES() }} |
| 36 | |
| 37 | {{ SHARED.ADJUST_SL_OPTS(OVERRIDES_FILENAME='/srv/salt/reclass/classes/environment/' + ENVIRONMENT_MODEL_INVENTORY_NAME + '/overrides.yml') }} |
| 38 | |
| 39 | |
| 40 | # - description: "Registration cmp001 node" |
| 41 | # cmd: | |
| 42 | # salt-call event.send "reclass/minion/classify" \ |
| 43 | # "{\"node_master_ip\": \"{{ ETH0_IP_ADDRESS_CFG01 }}\", \ |
| 44 | # \"node_deploy_ip\": \"{{ ETH0_IP_ADDRESS_CMP001 }}\", \ |
| 45 | # \"node_control_ip\": \"10.167.8.101\", \ |
| 46 | # \"node_tenant_ipcontrol_ip\": \"10.167.8.101\", \ |
| 47 | # \"node_os\": \"xenial\", \ |
| 48 | # \"node_domain\": \"{{ DOMAIN_NAME }}\", \ |
| 49 | # \"node_cluster\": \"{{ LAB_CONFIG_NAME }}\", |
| 50 | # \"node_hostname\": \"$(hostname -s)\"}" |
| 51 | # node_name: {{ HOSTNAME_CMP001 }} |
| 52 | # retry: {count: 1, delay: 10} |
| 53 | # skip_fail: false |
| 54 | # |
| 55 | - description: "Workaround for rack01 compute generator" |
| 56 | cmd: | |
| 57 | set -e; |
| 58 | # Remove rack01 key |
| 59 | . /root/venv-reclass-tools/bin/activate; |
| 60 | reclass-tools del-key parameters.reclass.storage.node.kubernetes_compute_rack01 /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/config.yml; |
| 61 | node_name: {{ HOSTNAME_CFG01 }} |
| 62 | retry: {count: 1, delay: 10} |
| 63 | skip_fail: false |
| 64 | |
| 65 | # - description: "WR for changing image to proposed" |
| 66 | # cmd: | |
| 67 | # set -e; |
| 68 | # # Add message_queu host for opencontrail |
| 69 | # . /root/venv-reclass-tools/bin/activate; |
| 70 | # reclass-tools add-key parameters._param.salt_control_xenial_image 'http://ci.mcp.mirantis.net:8085/images/ubuntu-16-04-x64-mcpproposed.qcow2' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/init.yml; |
| 71 | # reclass-tools add-key parameters._param.salt_control_trusty_image 'http://ci.mcp.mirantis.net:8085/images/ubuntu-14-04-x64-mcpproposed.qcow2' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/init.yml; |
| 72 | # node_name: {{ HOSTNAME_CFG01 }} |
| 73 | # retry: {count: 1, delay: 10} |
| 74 | # skip_fail: false |
| 75 | |
| 76 | - description: "Workaround for xenial images" |
| 77 | cmd: | |
| 78 | set -e; |
| 79 | # Add tenant and single addresses for computes |
| 80 | set -e; |
| 81 | # Add message_queu host for opencontrail |
| 82 | . /root/venv-reclass-tools/bin/activate; |
| 83 | reclass-tools add-key parameters.salt.control.cluster.internal.node.nal01.image '${_param:salt_control_xenial_image}' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/kvm.yml; |
| 84 | reclass-tools add-key parameters.salt.control.cluster.internal.node.nal02.image '${_param:salt_control_xenial_image}' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/kvm.yml; |
| 85 | reclass-tools add-key parameters.salt.control.cluster.internal.node.nal03.image '${_param:salt_control_xenial_image}' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/kvm.yml; |
| 86 | reclass-tools add-key parameters.salt.control.cluster.internal.node.ntw01.image '${_param:salt_control_xenial_image}' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/kvm.yml; |
| 87 | reclass-tools add-key parameters.salt.control.cluster.internal.node.ntw02.image '${_param:salt_control_xenial_image}' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/kvm.yml; |
| 88 | reclass-tools add-key parameters.salt.control.cluster.internal.node.ntw03.image '${_param:salt_control_xenial_image}' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/kvm.yml; |
| 89 | reclass-tools add-key parameters.salt.control.cluster.internal.node.prx01.image '${_param:salt_control_xenial_image}' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/kvm.yml; |
| 90 | reclass-tools add-key parameters.salt.control.cluster.internal.node.prx02.image '${_param:salt_control_xenial_image}' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/kvm.yml; |
| 91 | node_name: {{ HOSTNAME_CFG01 }} |
| 92 | retry: {count: 1, delay: 10} |
| 93 | skip_fail: false |
| 94 | |
| 95 | |
| 96 | {{ SHARED.MACRO_GENERATE_INVENTORY() }} |
| 97 | |
| 98 | {{ SHARED.MACRO_NETWORKING_WORKAROUNDS() }} |
| 99 | |
| 100 | |
| 101 | - description: "Workaround for PROD-14060" |
| 102 | cmd: | |
| 103 | set -e; |
| 104 | # Add tenant and single addresses for computes |
| 105 | salt-call reclass.cluster_meta_set deploy_address 172.17.41.7 /srv/salt/reclass/nodes/_generated/cmp001.cookied-bm-mcp-ocata-contrail.local.yml |
| 106 | salt-call reclass.cluster_meta_set tenant_address 192.168.0.101 /srv/salt/reclass/nodes/_generated/cmp001.cookied-bm-mcp-ocata-contrail.local.yml |
| 107 | salt-call reclass.cluster_meta_set single_address 10.167.8.101 /srv/salt/reclass/nodes/_generated/cmp001.cookied-bm-mcp-ocata-contrail.local.yml |
| 108 | |
| 109 | # salt-call reclass.cluster_meta_set deploy_address 172.16.49.74 /srv/salt/reclass/nodes/_generated/cmp002.cookied-bm-mcp-ocata-contrail.local.yml |
| 110 | # salt-call reclass.cluster_meta_set tenant_address 192.168.0.102 /srv/salt/reclass/nodes/_generated/cmp002.cookied-bm-mcp-ocata-contrail.local.yml |
| 111 | # salt-call reclass.cluster_meta_set single_address 10.167.8.102 /srv/salt/reclass/nodes/_generated/cmp002.cookied-bm-mcp-ocata-contrail.local.yml |
| 112 | |
| 113 | node_name: {{ HOSTNAME_CFG01 }} |
| 114 | retry: {count: 1, delay: 10} |
| 115 | skip_fail: false |
| 116 | |
| 117 | |
| 118 | - description: Temporary workaround for removing cinder-volume from CTL nodes |
| 119 | cmd: | |
| 120 | sed -i 's/\-\ system\.cinder\.volume\.single//g' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/openstack/control.yml; |
| 121 | sed -i 's/\-\ system\.cinder\.volume\.notification\.messagingv2//g' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/openstack/control.yml; |
| 122 | node_name: {{ HOSTNAME_CFG01 }} |
| 123 | retry: {count: 1, delay: 5} |
| 124 | skip_fail: true |
| 125 | |
| 126 | - description: Temporary WR for correct bridge name according to envoronment templates |
| 127 | cmd: | |
| 128 | sed -i 's/br\-ctl/br\_ctl/g' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/kvm.yml; |
| 129 | sed -i 's/br\-mgm/br\_mgm/g' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/kvm.yml; |
| 130 | node_name: {{ HOSTNAME_CFG01 }} |
| 131 | retry: {count: 1, delay: 10} |
| 132 | skip_fail: false |
| 133 | |
| 134 | {{ SHARED.MACRO_BOOTSTRAP_ALL_MINIONS() }} |
| 135 | |
| 136 | ######################################## |
| 137 | # Spin up Control Plane VMs on KVM nodes |
| 138 | ######################################## |
| 139 | |
| 140 | - description: Execute 'libvirt' states to create necessary libvirt networks |
| 141 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False 'kvm*' state.sls libvirt |
| 142 | node_name: {{ HOSTNAME_CFG01 }} |
| 143 | retry: {count: 2, delay: 10} |
| 144 | skip_fail: false |
| 145 | |
| 146 | - description: Create VMs for control plane |
| 147 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False 'kvm*' state.sls salt.control |
| 148 | node_name: {{ HOSTNAME_CFG01 }} |
| 149 | retry: {count: 3, delay: 10} |
| 150 | skip_fail: false |
| 151 | |
| 152 | - description: '*Workaround* for waiting the control-plane VMs in the salt-key (instead of sleep)' |
| 153 | cmd: | |
| 154 | salt-key -l acc| sort > /tmp/current_keys.txt && |
| 155 | salt 'kvm*' cmd.run 'virsh list --name' | grep -v 'kvm'|sort|xargs -I {} fgrep {} /tmp/current_keys.txt |
| 156 | node_name: {{ HOSTNAME_CFG01 }} |
| 157 | retry: {count: 20, delay: 30} |
| 158 | skip_fail: false |
| 159 | |
| 160 | ######################################### |
| 161 | # Configure all running salt minion nodes |
| 162 | ######################################### |
| 163 | |
| 164 | - description: Hack resolv.conf on VCP nodes for internal services access |
| 165 | cmd: | |
| 166 | salt --hard-crash --state-output=mixed --state-verbose=False -C '* and not kvm* and not cmp* and not gtw* and not cfg*' cmd.run "echo 'nameserver 172.17.41.2' > /etc/resolv.conf;" |
| 167 | node_name: {{ HOSTNAME_CFG01 }} |
| 168 | retry: {count: 1, delay: 5} |
| 169 | skip_fail: false |
| 170 | |
| 171 | - description: Refresh pillars on all minions |
| 172 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.refresh_pillar |
| 173 | node_name: {{ HOSTNAME_CFG01 }} |
| 174 | retry: {count: 1, delay: 5} |
| 175 | skip_fail: false |
| 176 | |
| 177 | - description: Sync all salt resources |
| 178 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.sync_all && sleep 5 |
| 179 | node_name: {{ HOSTNAME_CFG01 }} |
| 180 | retry: {count: 1, delay: 5} |
| 181 | skip_fail: false |
| 182 | |
| 183 | - description: Show reclass-salt --top for generated nodes |
| 184 | cmd: reclass-salt --top -u /srv/salt/reclass/nodes/_generated/ |
| 185 | node_name: {{ HOSTNAME_CFG01 }} |
| 186 | retry: {count: 1, delay: 5} |
| 187 | skip_fail: false |
| 188 | |
| 189 | {{ SHARED.MACRO_BOOTSTRAP_ALL_MINIONS() }} |