blob: f30331e0c86674bff6f81592547433df592dcc64 [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
8{% set SALT_MODELS_REPOSITORY = os_env('SALT_MODELS_REPOSITORY','https://gerrit.mcp.mirantis.net/salt-models/mcp-virtual-lab') %}
9# 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
Vladimir Jigulinf557c562018-07-30 18:30:09 +040026{{ 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" "logrotate"') }}
sgudzd7f8ec92018-04-19 16:22:47 +030027
28{{ SHARED.MACRO_INSTALL_SALT_MINIONS() }}
29
30{{ SHARED.MACRO_RUN_SALT_MASTER_UNDERLAY_STATES() }}
31
sgudzd7f8ec92018-04-19 16:22:47 +030032- description: "Workaround for rack01 compute generator"
33 cmd: |
34 set -e;
35 # Remove rack01 key
36 . /root/venv-reclass-tools/bin/activate;
37 reclass-tools del-key parameters.reclass.storage.node.openstack_compute_rack01 /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/config.yml;
38 # Add openstack_compute_node definition from system
39 reclass-tools add-key 'classes' 'system.reclass.storage.system.openstack_compute_multi' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/config.yml --merge;
40 node_name: {{ HOSTNAME_CFG01 }}
41 retry: {count: 1, delay: 10}
42 skip_fail: false
43
sgudzdcf5d552018-08-21 23:27:14 +030044- description: "Change path to internal storage for salt.control images"
sgudz4fce07a2018-08-15 16:49:24 +030045 cmd: |
46 set -e;
47 . /root/venv-reclass-tools/bin/activate;
sgudzdcf5d552018-08-21 23:27:14 +030048 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;
49 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;
sgudz4fce07a2018-08-15 16:49:24 +030050 node_name: {{ HOSTNAME_CFG01 }}
51 retry: {count: 1, delay: 10}
52 skip_fail: false
53
sgudzd7f8ec92018-04-19 16:22:47 +030054{{ SHARED.MACRO_GENERATE_INVENTORY() }}
55
56- description: "WR for dpdk pci to be in correct quotes"
57 cmd: |
58 set -e;
59 . /root/venv-reclass-tools/bin/activate;
60 reclass-tools add-key parameters._param.compute_vrouter_dpdk_pci '0000:05:00.0' /srv/salt/reclass/nodes/_generated/cmp001.{{ DOMAIN_NAME }}.yml;
61 reclass-tools add-key parameters._param.compute_vrouter_dpdk_pci '0000:05:00.0' /srv/salt/reclass/nodes/_generated/cmp002.{{ DOMAIN_NAME }}.yml;
62 node_name: {{ HOSTNAME_CFG01 }}
63 retry: {count: 1, delay: 10}
64 skip_fail: false
65
66{{ SHARED.MACRO_NETWORKING_WORKAROUNDS() }}
67
sgudz10168512018-08-06 15:20:50 +030068- description: Rerun openssh after env model is generated
sgudzd7f8ec92018-04-19 16:22:47 +030069 cmd: |
sgudz10168512018-08-06 15:20:50 +030070 salt-call state.sls openssh
sgudzd7f8ec92018-04-19 16:22:47 +030071 node_name: {{ HOSTNAME_CFG01 }}
72 retry: {count: 1, delay: 10}
73 skip_fail: false
74
sgudz10168512018-08-06 15:20:50 +030075- description: Execute linux.network.host one more time after salt.minion to apply dynamically registered hosts on the cluster nodes
76 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@linux:system' state.sls linux.network.host
77 node_name: {{ HOSTNAME_CFG01 }}
78 retry: {count: 2, delay: 10}
79 skip_fail: false
80
sgudzd7f8ec92018-04-19 16:22:47 +030081- description: Temporary workaround for removing cinder-volume from CTL nodes
82 cmd: |
83 sed -i 's/\-\ system\.cinder\.volume\.single//g' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/openstack/control.yml;
84 sed -i 's/\-\ system\.cinder\.volume\.notification\.messagingv2//g' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/openstack/control.yml;
85 node_name: {{ HOSTNAME_CFG01 }}
86 retry: {count: 1, delay: 5}
87 skip_fail: true
88
sgudzdcf5d552018-08-21 23:27:14 +030089- description: WR for mounting 1G hugepages before linux.state
90 cmd: |
91 salt 'cmp*' state.sls linux.system.hugepages;
92 salt 'cmp*' cmd.run "mount -o mode=775,pagesize=1G -t hugetlbfs Hugetlbfs-kvm /mnt/hugepages_1G";
93 salt 'cmp*' cmd.run "echo 16 | sudo tee /sys/kernel/mm/hugepages/hugepages-1048576kB/nr_hugepages";
94 node_name: {{ HOSTNAME_CFG01 }}
95 retry: {count: 1, delay: 10}
96 skip_fail: false
97
sgudzd7f8ec92018-04-19 16:22:47 +030098- description: Temporary WR for correct bridge name according to envoronment templates
99 cmd: |
100 sed -i 's/br\-ctl/br\_ctl/g' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/kvm.yml;
101 sed -i 's/br\-mgm/br\_mgm/g' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/kvm.yml;
102 node_name: {{ HOSTNAME_CFG01 }}
103 retry: {count: 1, delay: 10}
104 skip_fail: false
105
106- description: "WR for correct opencontrail_compute_iface value. Cookiecutter context doesn't have such parameter"
107 cmd: |
108 set -e;
109 . /root/venv-reclass-tools/bin/activate;
110 reclass-tools add-key parameters._param.opencontrail_compute_iface 'enp5s0f0' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/opencontrail/init.yml;
111 node_name: {{ HOSTNAME_CFG01 }}
112 retry: {count: 1, delay: 10}
113 skip_fail: false
114
115{{ SHARED.MACRO_BOOTSTRAP_ALL_MINIONS() }}
116
117########################################
118# Spin up Control Plane VMs on KVM nodes
119########################################
120
121- description: Execute 'libvirt' states to create necessary libvirt networks
122 cmd: salt --hard-crash --state-output=mixed --state-verbose=False 'kvm*' state.sls libvirt
123 node_name: {{ HOSTNAME_CFG01 }}
124 retry: {count: 2, delay: 10}
125 skip_fail: false
126
127- description: Create VMs for control plane
128 cmd: salt --hard-crash --state-output=mixed --state-verbose=False 'kvm*' state.sls salt.control
129 node_name: {{ HOSTNAME_CFG01 }}
130 retry: {count: 3, delay: 10}
131 skip_fail: false
132
133- description: '*Workaround* for waiting the control-plane VMs in the salt-key (instead of sleep)'
134 cmd: |
135 salt-key -l acc| sort > /tmp/current_keys.txt &&
136 salt 'kvm*' cmd.run 'virsh list --name' | grep -v 'kvm'|sort|xargs -I {} fgrep {} /tmp/current_keys.txt
137 node_name: {{ HOSTNAME_CFG01 }}
138 retry: {count: 20, delay: 30}
139 skip_fail: false
140
141#########################################
142# Configure all running salt minion nodes
143#########################################
144
145- description: Hack resolv.conf on VCP nodes for internal services access
146 cmd: |
147 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;"
148 node_name: {{ HOSTNAME_CFG01 }}
149 retry: {count: 1, delay: 5}
150 skip_fail: false
151
152- description: Refresh pillars on all minions
153 cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.refresh_pillar
154 node_name: {{ HOSTNAME_CFG01 }}
155 retry: {count: 1, delay: 5}
156 skip_fail: false
157
158- description: Sync all salt resources
159 cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.sync_all && sleep 5
160 node_name: {{ HOSTNAME_CFG01 }}
161 retry: {count: 1, delay: 5}
162 skip_fail: false
163
164- description: Show reclass-salt --top for generated nodes
165 cmd: reclass-salt --top -u /srv/salt/reclass/nodes/_generated/
166 node_name: {{ HOSTNAME_CFG01 }}
167 retry: {count: 1, delay: 5}
168 skip_fail: false
169
170{{ SHARED.MACRO_BOOTSTRAP_ALL_MINIONS() }}
Tatyana Leontovich4453dd62018-06-26 18:44:31 +0300171
172{{SHARED.MACRO_CHECK_SALT_VERSION_SERVICES_ON_CFG()}}
173
sgudz10168512018-08-06 15:20:50 +0300174{{SHARED.MACRO_CHECK_SALT_VERSION_ON_NODES()}}
175
176- description: "Lab04 workaround: Give each node root acces with key from cfg01"
177 cmd: |
178 set -e;
179 set -x;
180 key=$(ssh-keygen -y -f /root/.ssh/id_rsa);
181 salt '*' cmd.run "echo $key >> /root/.ssh/authorized_keys";
182 salt '*' cmd.run "service sshd restart"
183 node_name: {{ HOSTNAME_CFG01 }}
184 retry: {count: 1, delay: 5}
185 skip_fail: true
186
187- description: "Lab04 workaround: Control network access from cfg01 node using sshuttle via kvm01"
188 cmd: |
189 set -e;
190 set -x;
191 KVM01_DEPLOY_ADDRESS=$(salt-call --out=newline_values_only pillar.get _param:infra_kvm_node01_deploy_address);
192 apt-get install -y sshuttle;
193 sshuttle -r ${KVM01_DEPLOY_ADDRESS} 10.167.8.0/24 -D >/dev/null;
194 node_name: {{ HOSTNAME_CFG01 }}
195 retry: {count: 1, delay: 5}
196 skip_fail: true