blob: 3a544960f775f59b3eda1230593b0282b51a973b [file] [log] [blame]
sgudz8c888ec2017-10-02 15:29:23 +03001{% from 'cookied-bm-mcp-ocata-contrail/underlay.yaml' import HOSTNAME_CFG01 with context %}
2{% from 'cookied-bm-mcp-ocata-contrail/underlay.yaml' import LAB_CONFIG_NAME with context %}
3{% from 'cookied-bm-mcp-ocata-contrail/underlay.yaml' import DOMAIN_NAME with context %}
sgudz468b08a2018-07-16 12:55:33 +03004{% from 'cookied-bm-mcp-ocata-contrail/underlay.yaml' import CUSTOM_VCP_TRUSTY_IMAGE_URL with context %}
5{% from 'cookied-bm-mcp-ocata-contrail/underlay.yaml' import CUSTOM_VCP_XENIAL_IMAGE_URL with context %}
sgudz8c888ec2017-10-02 15:29:23 +03006
7{% set SALT_MODELS_REPOSITORY = os_env('SALT_MODELS_REPOSITORY','https://gerrit.mcp.mirantis.net/salt-models/mcp-virtual-lab') %}
8# Other salt model repository parameters see in shared-salt.yaml
9
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') %}
12# Path to the context files used to render Cluster and Environment models
sgudz868f0862018-03-16 21:47:18 +020013{%- set CLUSTER_CONTEXT_NAME = 'salt-context-cookiecutter-contrail.yaml' %}
sgudz8c888ec2017-10-02 15:29:23 +030014{%- 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
19{% import 'shared-salt.yaml' as SHARED with context %}
20
21{{ SHARED.MACRO_INSTALL_SALT_MASTER() }}
22
23{{ SHARED.MACRO_GENERATE_COOKIECUTTER_MODEL(CONTROL_VLAN=CONTROL_VLAN, TENANT_VLAN=TENANT_VLAN) }}
24
25{{ SHARED.MACRO_GENERATE_AND_ENABLE_ENVIRONMENT_MODEL() }}
26
Oleksii Butenkoa2fa0612018-09-20 12:01:44 +030027{{ SHARED.MACRO_CONFIGURE_RECLASS(FORMULA_SERVICES='\*') }}
sgudz8c888ec2017-10-02 15:29:23 +030028{{ SHARED.MACRO_INSTALL_SALT_MINIONS() }}
29
30{{ SHARED.MACRO_RUN_SALT_MASTER_UNDERLAY_STATES() }}
31
32- description: "Workaround for rack01 compute generator"
33 cmd: |
34 set -e;
35 # Remove rack01 key
Dennis Dmitrievd96ace12018-01-26 14:46:21 +020036 . /root/venv-reclass-tools/bin/activate;
sgudz8c888ec2017-10-02 15:29:23 +030037 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;
sgudz868f0862018-03-16 21:47:18 +020040 node_name: {{ HOSTNAME_CFG01 }}
41 retry: {count: 1, delay: 10}
42 skip_fail: false
sgudz8c888ec2017-10-02 15:29:23 +030043
sgudzdcf5d552018-08-21 23:27:14 +030044- description: "Change path to internal storage for salt.control images"
45 cmd: |
46 set -e;
47 . /root/venv-reclass-tools/bin/activate;
48 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;
50 node_name: {{ HOSTNAME_CFG01 }}
51 retry: {count: 1, delay: 10}
52 skip_fail: false
53
sgudz468b08a2018-07-16 12:55:33 +030054{%- if CUSTOM_VCP_TRUSTY_IMAGE_URL != '' %}
55
56- description: "Change trusty image to custom"
sgudz868f0862018-03-16 21:47:18 +020057 cmd: |
sgudz468b08a2018-07-16 12:55:33 +030058 echo "CUSTOM_TRUSTY_IMAGE is {{ CUSTOM_VCP_TRUSTY_IMAGE_URL }}";
sgudz868f0862018-03-16 21:47:18 +020059 . /root/venv-reclass-tools/bin/activate;
sgudz468b08a2018-07-16 12:55:33 +030060 reclass-tools add-key parameters._param.salt_control_trusty_image "{{ CUSTOM_VCP_TRUSTY_IMAGE_URL }}" /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/init.yml;
sgudz8c888ec2017-10-02 15:29:23 +030061 node_name: {{ HOSTNAME_CFG01 }}
62 retry: {count: 1, delay: 10}
63 skip_fail: false
64
sgudz468b08a2018-07-16 12:55:33 +030065{%- endif %}
sgudz8c888ec2017-10-02 15:29:23 +030066
sgudz468b08a2018-07-16 12:55:33 +030067{%- if CUSTOM_VCP_XENIAL_IMAGE_URL != '' %}
sgudz8c888ec2017-10-02 15:29:23 +030068
sgudz468b08a2018-07-16 12:55:33 +030069- description: "Change xenial image to custom"
sgudz8c888ec2017-10-02 15:29:23 +030070 cmd: |
sgudz468b08a2018-07-16 12:55:33 +030071 echo "CUSTOM_XENIAL_IMAGE is {{ CUSTOM_VCP_XENIAL_IMAGE_URL }}";
72 . /root/venv-reclass-tools/bin/activate;
73 reclass-tools add-key parameters._param.salt_control_xenial_image "{{ CUSTOM_VCP_XENIAL_IMAGE_URL }}" /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/init.yml;
sgudz8c888ec2017-10-02 15:29:23 +030074 node_name: {{ HOSTNAME_CFG01 }}
75 retry: {count: 1, delay: 10}
76 skip_fail: false
77
sgudz468b08a2018-07-16 12:55:33 +030078{%- endif %}
sgudzcced67d2017-10-11 15:56:09 +030079
80- description: Temporary workaround for removing cinder-volume from CTL nodes
sgudz8c888ec2017-10-02 15:29:23 +030081 cmd: |
sgudzcced67d2017-10-11 15:56:09 +030082 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
sgudz868f0862018-03-16 21:47:18 +020088- description: Temporary WR for correct bridge name according to envoronment templates
sgudzcced67d2017-10-11 15:56:09 +030089 cmd: |
sgudz868f0862018-03-16 21:47:18 +020090 sed -i 's/br\-ctl/br\_ctl/g' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/kvm.yml;
91 sed -i 's/br\-mgm/br\_mgm/g' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/kvm.yml;
sgudz8c888ec2017-10-02 15:29:23 +030092 node_name: {{ HOSTNAME_CFG01 }}
93 retry: {count: 1, delay: 10}
sgudz868f0862018-03-16 21:47:18 +020094 skip_fail: false
sgudz468b08a2018-07-16 12:55:33 +030095
96{{ SHARED.MACRO_GENERATE_INVENTORY() }}
97
98{{ SHARED.MACRO_NETWORKING_WORKAROUNDS() }}
99
100- description: Update minion information
101 cmd: |
102 salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.sync_grains &&
103 salt --hard-crash --state-output=mixed --state-verbose=False '*' mine.update &&
104 salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.refresh_pillar && sleep 10
105 node_name: {{ HOSTNAME_CFG01 }}
106 retry: {count: 1, delay: 10}
107 skip_fail: false
108
109- description: Rerun openssh after env model is generated
110 cmd: |
111 salt-call state.sls openssh
112 node_name: {{ HOSTNAME_CFG01 }}
113 retry: {count: 1, delay: 10}
114 skip_fail: false
115
116- description: Execute linux.network.host one more time after salt.minion to apply dynamically registered hosts on the cluster nodes
117 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@linux:system' state.sls linux.network.host
118 node_name: {{ HOSTNAME_CFG01 }}
119 retry: {count: 2, delay: 10}
120 skip_fail: false
121
sgudz8c888ec2017-10-02 15:29:23 +0300122{{ SHARED.MACRO_BOOTSTRAP_ALL_MINIONS() }}
123
124########################################
125# Spin up Control Plane VMs on KVM nodes
126########################################
127
128- description: Execute 'libvirt' states to create necessary libvirt networks
129 cmd: salt --hard-crash --state-output=mixed --state-verbose=False 'kvm*' state.sls libvirt
130 node_name: {{ HOSTNAME_CFG01 }}
131 retry: {count: 2, delay: 10}
132 skip_fail: false
133
134- description: Create VMs for control plane
135 cmd: salt --hard-crash --state-output=mixed --state-verbose=False 'kvm*' state.sls salt.control
136 node_name: {{ HOSTNAME_CFG01 }}
137 retry: {count: 3, delay: 10}
138 skip_fail: false
139
140- description: '*Workaround* for waiting the control-plane VMs in the salt-key (instead of sleep)'
141 cmd: |
142 salt-key -l acc| sort > /tmp/current_keys.txt &&
143 salt 'kvm*' cmd.run 'virsh list --name' | grep -v 'kvm'|sort|xargs -I {} fgrep {} /tmp/current_keys.txt
144 node_name: {{ HOSTNAME_CFG01 }}
145 retry: {count: 20, delay: 30}
146 skip_fail: false
147
148#########################################
149# Configure all running salt minion nodes
150#########################################
151
sgudzcced67d2017-10-11 15:56:09 +0300152- description: Hack resolv.conf on VCP nodes for internal services access
153 cmd: |
sgudz468b08a2018-07-16 12:55:33 +0300154 salt --hard-crash --state-output=mixed --state-verbose=False -C '* and not cfg*' cmd.run "echo 'nameserver 172.18.208.44' > /etc/resolv.conf;"
sgudzcced67d2017-10-11 15:56:09 +0300155 node_name: {{ HOSTNAME_CFG01 }}
156 retry: {count: 1, delay: 5}
157 skip_fail: false
158
sgudz8c888ec2017-10-02 15:29:23 +0300159- description: Refresh pillars on all minions
160 cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.refresh_pillar
161 node_name: {{ HOSTNAME_CFG01 }}
162 retry: {count: 1, delay: 5}
163 skip_fail: false
164
165- description: Sync all salt resources
166 cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.sync_all && sleep 5
167 node_name: {{ HOSTNAME_CFG01 }}
168 retry: {count: 1, delay: 5}
169 skip_fail: false
170
171- description: Show reclass-salt --top for generated nodes
172 cmd: reclass-salt --top -u /srv/salt/reclass/nodes/_generated/
173 node_name: {{ HOSTNAME_CFG01 }}
174 retry: {count: 1, delay: 5}
175 skip_fail: false
176
177{{ SHARED.MACRO_BOOTSTRAP_ALL_MINIONS() }}
Tatyana Leontovich4453dd62018-06-26 18:44:31 +0300178
179{{SHARED.MACRO_CHECK_SALT_VERSION_SERVICES_ON_CFG()}}
180
181{{SHARED.MACRO_CHECK_SALT_VERSION_ON_NODES()}}
sgudz468b08a2018-07-16 12:55:33 +0300182
183- description: "Lab04 workaround: Give each node root acces with key from cfg01"
184 cmd: |
185 set -e;
186 set -x;
187 key=$(ssh-keygen -y -f /root/.ssh/id_rsa);
188 salt '*' cmd.run "echo $key >> /root/.ssh/authorized_keys";
189 salt '*' cmd.run "service sshd restart"
190 node_name: {{ HOSTNAME_CFG01 }}
191 retry: {count: 1, delay: 5}
192 skip_fail: true
193
194- description: "Lab04 workaround: Control network access from cfg01 node using sshuttle via kvm01"
195 cmd: |
196 set -e;
197 set -x;
198 KVM01_DEPLOY_ADDRESS=$(salt-call --out=newline_values_only pillar.get _param:infra_kvm_node01_deploy_address);
199 apt-get install -y sshuttle;
200 sshuttle -r ${KVM01_DEPLOY_ADDRESS} 10.167.8.0/24 -D >/dev/null;
201 node_name: {{ HOSTNAME_CFG01 }}
202 retry: {count: 1, delay: 5}
203 skip_fail: true