blob: 1fa16cf55f886a6a77953af17aad90507086bbb6 [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
Dennis Dmitriev0f272312018-10-01 13:29:40 +03007{% set SALT_MODELS_REPOSITORY = os_env('SALT_MODELS_REPOSITORY','https://gerrit.mcp.mirantis.com/salt-models/mcp-virtual-lab') %}
sgudz8c888ec2017-10-02 15:29:23 +03008# 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
sgudz8c888ec2017-10-02 15:29:23 +030018{% import 'shared-salt.yaml' as SHARED with context %}
19
20{{ SHARED.MACRO_INSTALL_SALT_MASTER() }}
sgudz8c888ec2017-10-02 15:29:23 +030021{{ SHARED.MACRO_GENERATE_COOKIECUTTER_MODEL(CONTROL_VLAN=CONTROL_VLAN, TENANT_VLAN=TENANT_VLAN) }}
sgudz8c888ec2017-10-02 15:29:23 +030022{{ SHARED.MACRO_GENERATE_AND_ENABLE_ENVIRONMENT_MODEL() }}
Oleksii Butenkoa2fa0612018-09-20 12:01:44 +030023{{ SHARED.MACRO_CONFIGURE_RECLASS(FORMULA_SERVICES='\*') }}
sgudz8c888ec2017-10-02 15:29:23 +030024{{ SHARED.MACRO_INSTALL_SALT_MINIONS() }}
sgudz8c888ec2017-10-02 15:29:23 +030025{{ SHARED.MACRO_RUN_SALT_MASTER_UNDERLAY_STATES() }}
26
27- description: "Workaround for rack01 compute generator"
28 cmd: |
29 set -e;
30 # Remove rack01 key
Dennis Dmitrievd96ace12018-01-26 14:46:21 +020031 . /root/venv-reclass-tools/bin/activate;
abaraniukc4130bc2018-11-15 14:51:10 +020032 reclass-tools del-key parameters.reclass.storage.node.openstack_compute_rack01 /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/config.yml;
sgudz8c888ec2017-10-02 15:29:23 +030033 # Add openstack_compute_node definition from system
abaraniukc4130bc2018-11-15 14:51:10 +020034 reclass-tools add-key 'classes' 'system.reclass.storage.system.openstack_compute_multi' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/config.yml --merge;
sgudzdcf5d552018-08-21 23:27:14 +030035 node_name: {{ HOSTNAME_CFG01 }}
36 retry: {count: 1, delay: 10}
37 skip_fail: false
38
sgudz468b08a2018-07-16 12:55:33 +030039{%- if CUSTOM_VCP_TRUSTY_IMAGE_URL != '' %}
40
41- description: "Change trusty image to custom"
sgudz868f0862018-03-16 21:47:18 +020042 cmd: |
sgudz468b08a2018-07-16 12:55:33 +030043 echo "CUSTOM_TRUSTY_IMAGE is {{ CUSTOM_VCP_TRUSTY_IMAGE_URL }}";
sgudz868f0862018-03-16 21:47:18 +020044 . /root/venv-reclass-tools/bin/activate;
sgudz468b08a2018-07-16 12:55:33 +030045 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 +030046 node_name: {{ HOSTNAME_CFG01 }}
47 retry: {count: 1, delay: 10}
48 skip_fail: false
49
sgudz468b08a2018-07-16 12:55:33 +030050{%- endif %}
sgudz8c888ec2017-10-02 15:29:23 +030051
sgudz468b08a2018-07-16 12:55:33 +030052{%- if CUSTOM_VCP_XENIAL_IMAGE_URL != '' %}
sgudz8c888ec2017-10-02 15:29:23 +030053
sgudz468b08a2018-07-16 12:55:33 +030054- description: "Change xenial image to custom"
sgudz8c888ec2017-10-02 15:29:23 +030055 cmd: |
sgudz468b08a2018-07-16 12:55:33 +030056 echo "CUSTOM_XENIAL_IMAGE is {{ CUSTOM_VCP_XENIAL_IMAGE_URL }}";
57 . /root/venv-reclass-tools/bin/activate;
58 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 +030059 node_name: {{ HOSTNAME_CFG01 }}
60 retry: {count: 1, delay: 10}
61 skip_fail: false
62
sgudz468b08a2018-07-16 12:55:33 +030063{%- endif %}
sgudzcced67d2017-10-11 15:56:09 +030064
65- description: Temporary workaround for removing cinder-volume from CTL nodes
sgudz8c888ec2017-10-02 15:29:23 +030066 cmd: |
sgudzcced67d2017-10-11 15:56:09 +030067 sed -i 's/\-\ system\.cinder\.volume\.single//g' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/openstack/control.yml;
68 sed -i 's/\-\ system\.cinder\.volume\.notification\.messagingv2//g' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/openstack/control.yml;
69 node_name: {{ HOSTNAME_CFG01 }}
70 retry: {count: 1, delay: 5}
71 skip_fail: true
72
sgudz868f0862018-03-16 21:47:18 +020073- description: Temporary WR for correct bridge name according to envoronment templates
sgudzcced67d2017-10-11 15:56:09 +030074 cmd: |
sgudz868f0862018-03-16 21:47:18 +020075 sed -i 's/br\-ctl/br\_ctl/g' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/kvm.yml;
76 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 +030077 node_name: {{ HOSTNAME_CFG01 }}
78 retry: {count: 1, delay: 10}
sgudz868f0862018-03-16 21:47:18 +020079 skip_fail: false
sgudz468b08a2018-07-16 12:55:33 +030080
81{{ SHARED.MACRO_GENERATE_INVENTORY() }}
sgudz468b08a2018-07-16 12:55:33 +030082{{ SHARED.MACRO_NETWORKING_WORKAROUNDS() }}
83
84- description: Update minion information
85 cmd: |
86 salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.sync_grains &&
87 salt --hard-crash --state-output=mixed --state-verbose=False '*' mine.update &&
88 salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.refresh_pillar && sleep 10
89 node_name: {{ HOSTNAME_CFG01 }}
90 retry: {count: 1, delay: 10}
91 skip_fail: false
92
93- description: Rerun openssh after env model is generated
94 cmd: |
95 salt-call state.sls openssh
96 node_name: {{ HOSTNAME_CFG01 }}
97 retry: {count: 1, delay: 10}
98 skip_fail: false
99
100- description: Execute linux.network.host one more time after salt.minion to apply dynamically registered hosts on the cluster nodes
101 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@linux:system' state.sls linux.network.host
102 node_name: {{ HOSTNAME_CFG01 }}
103 retry: {count: 2, delay: 10}
104 skip_fail: false
105
sgudz8c888ec2017-10-02 15:29:23 +0300106{{ 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
sgudzcced67d2017-10-11 15:56:09 +0300136- description: Hack resolv.conf on VCP nodes for internal services access
137 cmd: |
sgudz468b08a2018-07-16 12:55:33 +0300138 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 +0300139 node_name: {{ HOSTNAME_CFG01 }}
140 retry: {count: 1, delay: 5}
141 skip_fail: false
142
sgudz8c888ec2017-10-02 15:29:23 +0300143- 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{{SHARED.MACRO_CHECK_SALT_VERSION_SERVICES_ON_CFG()}}
Tatyana Leontovich4453dd62018-06-26 18:44:31 +0300163{{SHARED.MACRO_CHECK_SALT_VERSION_ON_NODES()}}
sgudz468b08a2018-07-16 12:55:33 +0300164
165- description: "Lab04 workaround: Give each node root acces with key from cfg01"
166 cmd: |
167 set -e;
168 set -x;
169 key=$(ssh-keygen -y -f /root/.ssh/id_rsa);
170 salt '*' cmd.run "echo $key >> /root/.ssh/authorized_keys";
171 salt '*' cmd.run "service sshd restart"
172 node_name: {{ HOSTNAME_CFG01 }}
173 retry: {count: 1, delay: 5}
174 skip_fail: true
175
176- description: "Lab04 workaround: Control network access from cfg01 node using sshuttle via kvm01"
177 cmd: |
178 set -e;
179 set -x;
180 KVM01_DEPLOY_ADDRESS=$(salt-call --out=newline_values_only pillar.get _param:infra_kvm_node01_deploy_address);
181 apt-get install -y sshuttle;
182 sshuttle -r ${KVM01_DEPLOY_ADDRESS} 10.167.8.0/24 -D >/dev/null;
183 node_name: {{ HOSTNAME_CFG01 }}
184 retry: {count: 1, delay: 5}
185 skip_fail: true