blob: e381c85ace237bda9d328cfffb1421e4ed54caaf [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
sgudz4fce07a2018-08-15 16:49:24 +030044- description: "WR for changing VCP images path to internal storage"
45 cmd: |
46 set -e;
47 . /root/venv-reclass-tools/bin/activate;
48 reclass-tools add-key parameters._param.salt_control_xenial_image 'http://ci.mcp.mirantis.net:8085/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 'http://ci.mcp.mirantis.net:8085/images/ubuntu-14-04-x64-mcp{{ SHARED.REPOSITORY_SUITE }}.qcow2' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/init.yml;
50 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
89- description: Temporary WR for correct bridge name according to envoronment templates
90 cmd: |
91 sed -i 's/br\-ctl/br\_ctl/g' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/kvm.yml;
92 sed -i 's/br\-mgm/br\_mgm/g' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/kvm.yml;
93 node_name: {{ HOSTNAME_CFG01 }}
94 retry: {count: 1, delay: 10}
95 skip_fail: false
96
97- description: "WR for correct opencontrail_compute_iface value. Cookiecutter context doesn't have such parameter"
98 cmd: |
99 set -e;
100 . /root/venv-reclass-tools/bin/activate;
101 reclass-tools add-key parameters._param.opencontrail_compute_iface 'enp5s0f0' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/opencontrail/init.yml;
102 node_name: {{ HOSTNAME_CFG01 }}
103 retry: {count: 1, delay: 10}
104 skip_fail: false
105
106{{ SHARED.MACRO_BOOTSTRAP_ALL_MINIONS() }}
107
108########################################
109# Spin up Control Plane VMs on KVM nodes
110########################################
111
112- description: Execute 'libvirt' states to create necessary libvirt networks
113 cmd: salt --hard-crash --state-output=mixed --state-verbose=False 'kvm*' state.sls libvirt
114 node_name: {{ HOSTNAME_CFG01 }}
115 retry: {count: 2, delay: 10}
116 skip_fail: false
117
118- description: Create VMs for control plane
119 cmd: salt --hard-crash --state-output=mixed --state-verbose=False 'kvm*' state.sls salt.control
120 node_name: {{ HOSTNAME_CFG01 }}
121 retry: {count: 3, delay: 10}
122 skip_fail: false
123
124- description: '*Workaround* for waiting the control-plane VMs in the salt-key (instead of sleep)'
125 cmd: |
126 salt-key -l acc| sort > /tmp/current_keys.txt &&
127 salt 'kvm*' cmd.run 'virsh list --name' | grep -v 'kvm'|sort|xargs -I {} fgrep {} /tmp/current_keys.txt
128 node_name: {{ HOSTNAME_CFG01 }}
129 retry: {count: 20, delay: 30}
130 skip_fail: false
131
132#########################################
133# Configure all running salt minion nodes
134#########################################
135
136- description: Hack resolv.conf on VCP nodes for internal services access
137 cmd: |
138 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;"
139 node_name: {{ HOSTNAME_CFG01 }}
140 retry: {count: 1, delay: 5}
141 skip_fail: false
142
143- description: Refresh pillars on all minions
144 cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.refresh_pillar
145 node_name: {{ HOSTNAME_CFG01 }}
146 retry: {count: 1, delay: 5}
147 skip_fail: false
148
149- description: Sync all salt resources
150 cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.sync_all && sleep 5
151 node_name: {{ HOSTNAME_CFG01 }}
152 retry: {count: 1, delay: 5}
153 skip_fail: false
154
155- description: Show reclass-salt --top for generated nodes
156 cmd: reclass-salt --top -u /srv/salt/reclass/nodes/_generated/
157 node_name: {{ HOSTNAME_CFG01 }}
158 retry: {count: 1, delay: 5}
159 skip_fail: false
160
161{{ SHARED.MACRO_BOOTSTRAP_ALL_MINIONS() }}
Tatyana Leontovich4453dd62018-06-26 18:44:31 +0300162
163{{SHARED.MACRO_CHECK_SALT_VERSION_SERVICES_ON_CFG()}}
164
sgudz10168512018-08-06 15:20:50 +0300165{{SHARED.MACRO_CHECK_SALT_VERSION_ON_NODES()}}
166
167- description: "Lab04 workaround: Give each node root acces with key from cfg01"
168 cmd: |
169 set -e;
170 set -x;
171 key=$(ssh-keygen -y -f /root/.ssh/id_rsa);
172 salt '*' cmd.run "echo $key >> /root/.ssh/authorized_keys";
173 salt '*' cmd.run "service sshd restart"
174 node_name: {{ HOSTNAME_CFG01 }}
175 retry: {count: 1, delay: 5}
176 skip_fail: true
177
178- description: "Lab04 workaround: Control network access from cfg01 node using sshuttle via kvm01"
179 cmd: |
180 set -e;
181 set -x;
182 KVM01_DEPLOY_ADDRESS=$(salt-call --out=newline_values_only pillar.get _param:infra_kvm_node01_deploy_address);
183 apt-get install -y sshuttle;
184 sshuttle -r ${KVM01_DEPLOY_ADDRESS} 10.167.8.0/24 -D >/dev/null;
185 node_name: {{ HOSTNAME_CFG01 }}
186 retry: {count: 1, delay: 5}
187 skip_fail: true