blob: 77980d0e0b88729a2ca325fbf186361b90d5cc75 [file] [log] [blame]
sgudzd7f8ec92018-04-19 16:22:47 +03001{% from 'cookied-bm-mcp-ocata-contrail-nfv/underlay.yaml' import HOSTNAME_CFG01 with context %}
2{% from 'cookied-bm-mcp-ocata-contrail-nfv/underlay.yaml' import LAB_CONFIG_NAME with context %}
3{% from 'cookied-bm-mcp-ocata-contrail-nfv/underlay.yaml' import DOMAIN_NAME with context %}
4{% from 'cookied-bm-mcp-ocata-contrail-nfv/underlay.yaml' import HOSTNAME_KVM01 with context %}
5{% from 'cookied-bm-mcp-ocata-contrail-nfv/underlay.yaml' import HOSTNAME_KVM02 with context %}
6{% from 'cookied-bm-mcp-ocata-contrail-nfv/underlay.yaml' import HOSTNAME_KVM03 with context %}
7
Dennis Dmitriev0f272312018-10-01 13:29:40 +03008{% set SALT_MODELS_REPOSITORY = os_env('SALT_MODELS_REPOSITORY','https://gerrit.mcp.mirantis.com/salt-models/mcp-virtual-lab') %}
sgudzd7f8ec92018-04-19 16:22:47 +03009# Other salt model repository parameters see in shared-salt.yaml
10# Name of the context file (without extension, that is fixed .yaml) used to render the Environment model
11{% set ENVIRONMENT_MODEL_INVENTORY_NAME = os_env('ENVIRONMENT_MODEL_INVENTORY_NAME','physical-cookied-bm-mcp-ocata-contrail-nfv') %}
12# Path to the context files used to render Cluster and Environment models
13{%- set CLUSTER_CONTEXT_NAME = 'salt-context-cookiecutter-contrail-dpdk.yaml' %}
14{%- set ENVIRONMENT_CONTEXT_NAMES = ['salt-context-environment.yaml','lab04-physical-inventory.yaml'] %}
15{%- set CONTROL_VLAN = os_env('CONTROL_VLAN', '2422') %}
16{%- set TENANT_VLAN = os_env('TENANT_VLAN', '2423') %}
17
18{% import 'shared-salt.yaml' as SHARED with context %}
19
20{{ SHARED.MACRO_INSTALL_SALT_MASTER() }}
21
22{{ SHARED.MACRO_GENERATE_COOKIECUTTER_MODEL(CONTROL_VLAN=CONTROL_VLAN, TENANT_VLAN=TENANT_VLAN) }}
23
24{{ SHARED.MACRO_GENERATE_AND_ENABLE_ENVIRONMENT_MODEL() }}
25
Oleksii Butenkoa2fa0612018-09-20 12:01:44 +030026{{ SHARED.MACRO_CONFIGURE_RECLASS(FORMULA_SERVICES='\*') }}
sgudzd7f8ec92018-04-19 16:22:47 +030027{{ SHARED.MACRO_INSTALL_SALT_MINIONS() }}
28
29{{ SHARED.MACRO_RUN_SALT_MASTER_UNDERLAY_STATES() }}
30
sgudzd7f8ec92018-04-19 16:22:47 +030031- description: "Workaround for rack01 compute generator"
32 cmd: |
33 set -e;
34 # Remove rack01 key
35 . /root/venv-reclass-tools/bin/activate;
Tatyana Leontovich70e37132018-10-29 18:13:12 +020036 reclass-tools del-key parameters.reclass.storage.node.openstack_compute_rack01 /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/config/init.yml;
sgudzd7f8ec92018-04-19 16:22:47 +030037 # Add openstack_compute_node definition from system
Tatyana Leontovich70e37132018-10-29 18:13:12 +020038 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;
sgudzd7f8ec92018-04-19 16:22:47 +030039 node_name: {{ HOSTNAME_CFG01 }}
40 retry: {count: 1, delay: 10}
41 skip_fail: false
42
sgudzdcf5d552018-08-21 23:27:14 +030043- description: "Change path to internal storage for salt.control images"
sgudz4fce07a2018-08-15 16:49:24 +030044 cmd: |
45 set -e;
46 . /root/venv-reclass-tools/bin/activate;
Dennis Dmitrieve15a4f42018-10-30 13:11:56 +020047 reclass-tools add-key parameters._param.salt_control_xenial_image 'http://images.mcp.mirantis.net/ubuntu-16-04-x64-mcp{{ SHARED.REPOSITORY_SUITE }}.qcow2' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/init.yml;
48 reclass-tools add-key parameters._param.salt_control_trusty_image 'http://images.mcp.mirantis.net/ubuntu-14-04-x64-mcp{{ SHARED.REPOSITORY_SUITE }}.qcow2' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/init.yml;
sgudz4fce07a2018-08-15 16:49:24 +030049 node_name: {{ HOSTNAME_CFG01 }}
50 retry: {count: 1, delay: 10}
51 skip_fail: false
52
sgudzd7f8ec92018-04-19 16:22:47 +030053{{ SHARED.MACRO_GENERATE_INVENTORY() }}
54
55- description: "WR for dpdk pci to be in correct quotes"
56 cmd: |
57 set -e;
58 . /root/venv-reclass-tools/bin/activate;
59 reclass-tools add-key parameters._param.compute_vrouter_dpdk_pci '0000:05:00.0' /srv/salt/reclass/nodes/_generated/cmp001.{{ DOMAIN_NAME }}.yml;
60 reclass-tools add-key parameters._param.compute_vrouter_dpdk_pci '0000:05:00.0' /srv/salt/reclass/nodes/_generated/cmp002.{{ DOMAIN_NAME }}.yml;
61 node_name: {{ HOSTNAME_CFG01 }}
62 retry: {count: 1, delay: 10}
63 skip_fail: false
64
65{{ SHARED.MACRO_NETWORKING_WORKAROUNDS() }}
66
sgudz10168512018-08-06 15:20:50 +030067- description: Rerun openssh after env model is generated
sgudzd7f8ec92018-04-19 16:22:47 +030068 cmd: |
sgudz10168512018-08-06 15:20:50 +030069 salt-call state.sls openssh
sgudzd7f8ec92018-04-19 16:22:47 +030070 node_name: {{ HOSTNAME_CFG01 }}
71 retry: {count: 1, delay: 10}
72 skip_fail: false
73
sgudz10168512018-08-06 15:20:50 +030074- description: Execute linux.network.host one more time after salt.minion to apply dynamically registered hosts on the cluster nodes
75 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@linux:system' state.sls linux.network.host
76 node_name: {{ HOSTNAME_CFG01 }}
77 retry: {count: 2, delay: 10}
78 skip_fail: false
79
sgudzd7f8ec92018-04-19 16:22:47 +030080- description: Temporary workaround for removing cinder-volume from CTL nodes
81 cmd: |
82 sed -i 's/\-\ system\.cinder\.volume\.single//g' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/openstack/control.yml;
83 sed -i 's/\-\ system\.cinder\.volume\.notification\.messagingv2//g' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/openstack/control.yml;
84 node_name: {{ HOSTNAME_CFG01 }}
85 retry: {count: 1, delay: 5}
86 skip_fail: true
87
sgudzdcf5d552018-08-21 23:27:14 +030088- description: WR for mounting 1G hugepages before linux.state
89 cmd: |
90 salt 'cmp*' state.sls linux.system.hugepages;
91 salt 'cmp*' cmd.run "mount -o mode=775,pagesize=1G -t hugetlbfs Hugetlbfs-kvm /mnt/hugepages_1G";
92 salt 'cmp*' cmd.run "echo 16 | sudo tee /sys/kernel/mm/hugepages/hugepages-1048576kB/nr_hugepages";
93 node_name: {{ HOSTNAME_CFG01 }}
94 retry: {count: 1, delay: 10}
95 skip_fail: false
96
sgudzd7f8ec92018-04-19 16:22:47 +030097- description: Temporary WR for correct bridge name according to envoronment templates
98 cmd: |
99 sed -i 's/br\-ctl/br\_ctl/g' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/kvm.yml;
100 sed -i 's/br\-mgm/br\_mgm/g' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/kvm.yml;
101 node_name: {{ HOSTNAME_CFG01 }}
102 retry: {count: 1, delay: 10}
103 skip_fail: false
104
105- description: "WR for correct opencontrail_compute_iface value. Cookiecutter context doesn't have such parameter"
106 cmd: |
107 set -e;
108 . /root/venv-reclass-tools/bin/activate;
109 reclass-tools add-key parameters._param.opencontrail_compute_iface 'enp5s0f0' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/opencontrail/init.yml;
110 node_name: {{ HOSTNAME_CFG01 }}
111 retry: {count: 1, delay: 10}
112 skip_fail: false
113
114{{ SHARED.MACRO_BOOTSTRAP_ALL_MINIONS() }}
115
116########################################
117# Spin up Control Plane VMs on KVM nodes
118########################################
119
120- description: Execute 'libvirt' states to create necessary libvirt networks
121 cmd: salt --hard-crash --state-output=mixed --state-verbose=False 'kvm*' state.sls libvirt
122 node_name: {{ HOSTNAME_CFG01 }}
123 retry: {count: 2, delay: 10}
124 skip_fail: false
125
126- description: Create VMs for control plane
127 cmd: salt --hard-crash --state-output=mixed --state-verbose=False 'kvm*' state.sls salt.control
128 node_name: {{ HOSTNAME_CFG01 }}
129 retry: {count: 3, delay: 10}
130 skip_fail: false
131
132- description: '*Workaround* for waiting the control-plane VMs in the salt-key (instead of sleep)'
133 cmd: |
134 salt-key -l acc| sort > /tmp/current_keys.txt &&
135 salt 'kvm*' cmd.run 'virsh list --name' | grep -v 'kvm'|sort|xargs -I {} fgrep {} /tmp/current_keys.txt
136 node_name: {{ HOSTNAME_CFG01 }}
137 retry: {count: 20, delay: 30}
138 skip_fail: false
139
140#########################################
141# Configure all running salt minion nodes
142#########################################
143
144- description: Hack resolv.conf on VCP nodes for internal services access
145 cmd: |
146 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.18.208.44' > /etc/resolv.conf;"
147 node_name: {{ HOSTNAME_CFG01 }}
148 retry: {count: 1, delay: 5}
149 skip_fail: false
150
151- description: Refresh pillars on all minions
152 cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.refresh_pillar
153 node_name: {{ HOSTNAME_CFG01 }}
154 retry: {count: 1, delay: 5}
155 skip_fail: false
156
157- description: Sync all salt resources
158 cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.sync_all && sleep 5
159 node_name: {{ HOSTNAME_CFG01 }}
160 retry: {count: 1, delay: 5}
161 skip_fail: false
162
163- description: Show reclass-salt --top for generated nodes
164 cmd: reclass-salt --top -u /srv/salt/reclass/nodes/_generated/
165 node_name: {{ HOSTNAME_CFG01 }}
166 retry: {count: 1, delay: 5}
167 skip_fail: false
168
169{{ SHARED.MACRO_BOOTSTRAP_ALL_MINIONS() }}
Tatyana Leontovich4453dd62018-06-26 18:44:31 +0300170
171{{SHARED.MACRO_CHECK_SALT_VERSION_SERVICES_ON_CFG()}}
172
sgudz10168512018-08-06 15:20:50 +0300173{{SHARED.MACRO_CHECK_SALT_VERSION_ON_NODES()}}
174
175- description: "Lab04 workaround: Give each node root acces with key from cfg01"
176 cmd: |
177 set -e;
178 set -x;
179 key=$(ssh-keygen -y -f /root/.ssh/id_rsa);
180 salt '*' cmd.run "echo $key >> /root/.ssh/authorized_keys";
181 salt '*' cmd.run "service sshd restart"
182 node_name: {{ HOSTNAME_CFG01 }}
183 retry: {count: 1, delay: 5}
184 skip_fail: true
185
186- description: "Lab04 workaround: Control network access from cfg01 node using sshuttle via kvm01"
187 cmd: |
188 set -e;
189 set -x;
190 KVM01_DEPLOY_ADDRESS=$(salt-call --out=newline_values_only pillar.get _param:infra_kvm_node01_deploy_address);
191 apt-get install -y sshuttle;
192 sshuttle -r ${KVM01_DEPLOY_ADDRESS} 10.167.8.0/24 -D >/dev/null;
193 node_name: {{ HOSTNAME_CFG01 }}
194 retry: {count: 1, delay: 5}
195 skip_fail: true