blob: 32afbfa4bf6d49a3641829ee1cd1c7ae7925a647 [file] [log] [blame]
abaraniuk68c7f7c2018-08-06 16:06:29 +03001{% from 'cookied-bm-contrail40-nfv/underlay.yaml' import HOSTNAME_CFG01 with context %}
2{% from 'cookied-bm-contrail40-nfv/underlay.yaml' import LAB_CONFIG_NAME with context %}
3{% from 'cookied-bm-contrail40-nfv/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','physical-cookied-bm-contrail40-nfv') %}
10# Path to the context files used to render Cluster and Environment models
11{%- set 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
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{{ SHARED.MACRO_CONFIGURE_RECLASS(FORMULA_SERVICES='"linux" "reclass" "salt" "openssh" "ntp" "git" "nginx" "collectd" "sensu" "heka" "sphinx" "keystone" "mysql" "auditd" "grafana" "haproxy" "rsyslog" "horizon" "prometheus" "telegraf" "elasticsearch" "powerdns" "glusterfs" "xtrabackup" "maas" "backupninja" "jenkins" "fluentd" "logrotate"') }}
26
27{{ SHARED.MACRO_INSTALL_SALT_MINIONS() }}
28
29{{ SHARED.MACRO_RUN_SALT_MASTER_UNDERLAY_STATES() }}
30
31- description: "Workaround for rack01 compute generator"
32 cmd: |
33 set -e;
34 # Remove rack01 key
35 . /root/venv-reclass-tools/bin/activate;
36 reclass-tools del-key parameters.reclass.storage.node.openstack_compute_rack01 /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/config.yml;
37 # Add openstack_compute_node definition from system
38 reclass-tools add-key 'classes' 'system.reclass.storage.system.openstack_compute_multi' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/config.yml --merge;
39 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"
abaraniuk68c7f7c2018-08-06 16:06:29 +030044 cmd: |
45 set -e;
abaraniuk68c7f7c2018-08-06 16:06:29 +030046 . /root/venv-reclass-tools/bin/activate;
sgudzdcf5d552018-08-21 23:27:14 +030047 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;
48 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;
abaraniuk68c7f7c2018-08-06 16:06:29 +030049 node_name: {{ HOSTNAME_CFG01 }}
50 retry: {count: 1, delay: 10}
51 skip_fail: false
52
53- description: Temporary workaround for removing cinder-volume from CTL nodes
54 cmd: |
55 sed -i 's/\-\ system\.cinder\.volume\.single//g' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/openstack/control.yml;
56 sed -i 's/\-\ system\.cinder\.volume\.notification\.messagingv2//g' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/openstack/control.yml;
57 node_name: {{ HOSTNAME_CFG01 }}
58 retry: {count: 1, delay: 5}
59 skip_fail: true
60
61- description: Temporary WR for correct bridge name according to envoronment templates
62 cmd: |
63 sed -i 's/br\-ctl/br\_ctl/g' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/kvm.yml;
64 sed -i 's/br\-mgm/br\_mgm/g' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/kvm.yml;
65 node_name: {{ HOSTNAME_CFG01 }}
66 retry: {count: 1, delay: 10}
67 skip_fail: false
68
69{{ SHARED.MACRO_GENERATE_INVENTORY() }}
70
71{{ SHARED.MACRO_NETWORKING_WORKAROUNDS() }}
72
73- description: Update minion information
74 cmd: |
75 salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.sync_grains &&
76 salt --hard-crash --state-output=mixed --state-verbose=False '*' mine.update &&
77 salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.refresh_pillar && sleep 10
78 node_name: {{ HOSTNAME_CFG01 }}
79 retry: {count: 1, delay: 10}
80 skip_fail: false
81
82- description: Rerun openssh after env model is generated
83 cmd: |
84 salt-call state.sls openssh
85 node_name: {{ HOSTNAME_CFG01 }}
86 retry: {count: 1, delay: 10}
87 skip_fail: false
88
89- description: "WR for dpdk pci to be in correct quotes"
90 cmd: |
91 set -e;
92 . /root/venv-reclass-tools/bin/activate;
93 reclass-tools add-key parameters._param.compute_vrouter_dpdk_pci '0000:05:00.0' /srv/salt/reclass/nodes/_generated/cmp001.{{ DOMAIN_NAME }}.yml;
94 reclass-tools add-key parameters._param.compute_vrouter_dpdk_pci '0000:05:00.0' /srv/salt/reclass/nodes/_generated/cmp002.{{ DOMAIN_NAME }}.yml;
95 node_name: {{ HOSTNAME_CFG01 }}
96 retry: {count: 1, delay: 10}
97 skip_fail: false
98
99- description: Execute linux.network.host one more time after salt.minion to apply dynamically registered hosts on the cluster nodes
100 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@linux:system' state.sls linux.network.host
101 node_name: {{ HOSTNAME_CFG01 }}
102 retry: {count: 2, delay: 10}
103 skip_fail: false
104
sgudzdcf5d552018-08-21 23:27:14 +0300105- description: WR for mounting 1G hugepages before linux.state
106 cmd: |
107 salt 'cmp*' state.sls linux.system.hugepages;
108 salt 'cmp*' cmd.run "mount -o mode=775,pagesize=1G -t hugetlbfs Hugetlbfs-kvm /mnt/hugepages_1G";
109 salt 'cmp*' cmd.run "echo 16 | sudo tee /sys/kernel/mm/hugepages/hugepages-1048576kB/nr_hugepages";
110 node_name: {{ HOSTNAME_CFG01 }}
111 retry: {count: 1, delay: 10}
112 skip_fail: false
113
abaraniuk68c7f7c2018-08-06 16:06:29 +0300114{{ 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 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() }}
170
171{{SHARED.MACRO_CHECK_SALT_VERSION_SERVICES_ON_CFG()}}
172
173{{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