blob: 432590727468007e908e4f17b8ced820760d622d [file] [log] [blame]
sgudzb5d72e62018-05-31 12:20:51 +03001{% from 'cookied-bm-contrail-nfv-maas/underlay.yaml' import HOSTNAME_CFG01 with context %}
2{% from 'cookied-bm-contrail-nfv-maas/underlay.yaml' import LAB_CONFIG_NAME with context %}
3{% from 'cookied-bm-contrail-nfv-maas/underlay.yaml' import DOMAIN_NAME with context %}
4{% from 'cookied-bm-contrail-nfv-maas/underlay.yaml' import REPOSITORY_SUITE with context %}
5{% from 'cookied-bm-contrail-nfv-maas/underlay.yaml' import ETH1_IP_ADDRESS_CFG01 with context %}
6{% from 'cookied-bm-contrail-nfv-maas/underlay.yaml' import MAAS_DHCP_POOL_START with context %}
7{% from 'cookied-bm-contrail-nfv-maas/underlay.yaml' import MAAS_DHCP_POOL_END with context %}
8
9{% set SALT_MODELS_REPOSITORY = os_env('SALT_MODELS_REPOSITORY','https://gerrit.mcp.mirantis.net/salt-models/mcp-virtual-lab') %}
10# Other salt model repository parameters see in shared-salt.yaml
11
12{% set ENVIRONMENT_MODEL_INVENTORY_NAME = os_env('ENVIRONMENT_MODEL_INVENTORY_NAME','physical-cookied-bm-contrail-nfv-maas') %}
13# Path to the context files used to render Cluster and Environment models
14{%- set CLUSTER_CONTEXT_NAME = 'salt-context-cookiecutter-contrail.yaml' %}
15{%- set ENVIRONMENT_CONTEXT_NAMES = ['salt-context-environment.yaml','lab04-physical-inventory.yaml'] %}
16{%- set CONTROL_VLAN = os_env('CONTROL_VLAN', '2422') %}
17{%- set TENANT_VLAN = os_env('TENANT_VLAN', '2423') %}
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
Vladimir Jigulinf557c562018-07-30 18:30:09 +040027{{ 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"') }}
sgudzb5d72e62018-05-31 12:20:51 +030028
29{{ SHARED.MACRO_INSTALL_SALT_MINIONS() }}
30
31{{ SHARED.MACRO_RUN_SALT_MASTER_UNDERLAY_STATES() }}
32
33- description: Upload maas template
34 upload:
35 local_path: {{ config.salt_deploy.templates_dir }}{{ LAB_CONFIG_NAME }}/
36 local_filename: maas.yml
37 remote_path: /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/
38 node_name: {{ HOSTNAME_CFG01 }}
39 skip_fail: False
40
41- description: "Workaround for rack01 compute generator"
42 cmd: |
43 set -e;
44 # Remove rack01 key
45 . /root/venv-reclass-tools/bin/activate;
46 reclass-tools del-key parameters.reclass.storage.node.openstack_compute_rack01 /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/config.yml;
47 # Add openstack_compute_node definition from system
48 reclass-tools add-key 'classes' 'system.reclass.storage.system.openstack_compute_multi' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/config.yml --merge;
49 node_name: {{ HOSTNAME_CFG01 }}
50 retry: {count: 1, delay: 10}
51 skip_fail: false
52
53- description: "WR for changing image to proposed"
54 cmd: |
55 set -e;
56 # Add message_queu host for opencontrail
57 . /root/venv-reclass-tools/bin/activate;
58 reclass-tools add-key parameters._param.salt_control_xenial_image 'http://ci.mcp.mirantis.net:8085/images/ubuntu-16-04-x64-mcp{{ REPOSITORY_SUITE }}.qcow2' /srv/salt/reclass/classes/cluster//{{ LAB_CONFIG_NAME }}infra/init.yml;
59 reclass-tools add-key parameters._param.salt_control_trusty_image 'http://ci.mcp.mirantis.net:8085/images/ubuntu-14-04-x64-mcp{{ REPOSITORY_SUITE }}.qcow2' /srv/salt/reclass/classes/cluster//{{ LAB_CONFIG_NAME }}infra/init.yml;
60 node_name: {{ HOSTNAME_CFG01 }}
61 retry: {count: 1, delay: 10}
62 skip_fail: false
63
64{{ SHARED.MACRO_GENERATE_INVENTORY() }}
65
66- description: "WR for dpdk pci to be in correct quotes"
67 cmd: |
68 set -e;
69 . /root/venv-reclass-tools/bin/activate;
70 reclass-tools add-key parameters._param.compute_vrouter_dpdk_pci '0000:05:00.0' /srv/salt/reclass/nodes/_generated/cmp001.{{ DOMAIN_NAME }}.yml;
71 reclass-tools add-key parameters._param.compute_vrouter_dpdk_pci '0000:05:00.0' /srv/salt/reclass/nodes/_generated/cmp002.{{ DOMAIN_NAME }}.yml;
72 node_name: {{ HOSTNAME_CFG01 }}
73 retry: {count: 1, delay: 10}
74 skip_fail: false
75
76- description: Temporary workaround for removing cinder-volume from CTL nodes
77 cmd: |
78 sed -i 's/\-\ system\.cinder\.volume\.single//g' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/openstack/control.yml;
79 sed -i 's/\-\ system\.cinder\.volume\.notification\.messagingv2//g' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/openstack/control.yml;
80 node_name: {{ HOSTNAME_CFG01 }}
81 retry: {count: 1, delay: 5}
82 skip_fail: true
83
84- description: Temporary WR for correct bridge name according to envoronment templates
85 cmd: |
86 sed -i 's/br\-ctl/br\_ctl/g' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/kvm.yml;
87 sed -i 's/br\-mgm/br\_mgm/g' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/kvm.yml;
88 node_name: {{ HOSTNAME_CFG01 }}
89 retry: {count: 1, delay: 10}
90 skip_fail: false
91
92- description: Update minion information
93 cmd: |
94 salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.sync_grains &&
95 salt --hard-crash --state-output=mixed --state-verbose=False '*' mine.update &&
96 salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.refresh_pillar && sleep 10
97 node_name: {{ HOSTNAME_CFG01 }}
98 retry: {count: 1, delay: 10}
99 skip_fail: false
100
101- description: Rerun openssh after env model is generated
102 cmd: |
103 salt-call state.sls openssh
104 node_name: {{ HOSTNAME_CFG01 }}
105 retry: {count: 1, delay: 10}
106 skip_fail: false
107
108- description: Execute linux.network.host one more time after salt.minion to apply dynamically registered hosts on the cluster nodes
109 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@linux:system' state.sls linux
110 node_name: {{ HOSTNAME_CFG01 }}
111 retry: {count: 1, delay: 10}
112 skip_fail: false
113
114- description: Configure rsyslog on nodes
115 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@linux:system' state.sls rsyslog
116 node_name: {{ HOSTNAME_CFG01 }}
117 retry: {count: 1, delay: 10}
118 skip_fail: false
119
120- description: Configure maas.cluster
121 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@salt:master' state.sls maas.cluster
122 node_name: {{ HOSTNAME_CFG01 }}
123 retry: {count: 1, delay: 10}
124 skip_fail: false
125
126- description: Configure maas.region
127 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@salt:master' state.sls maas.region
128 node_name: {{ HOSTNAME_CFG01 }}
129 retry: {count: 3, delay: 10}
130 skip_fail: false
131
132- description: Configure dhcp for fabric
133 cmd: |
134 touch /root/API_KEY_FILE;
135 export PROFILE=mirantis;
136 export API_KEY_FILE=/root/API_KEY_FILE;
137 export MAAS_URL=http://{{ ETH1_IP_ADDRESS_CFG01 }}:5240/MAAS;
138 maas-region apikey --username=$PROFILE > $API_KEY_FILE;
139 maas login $PROFILE $MAAS_URL - < $API_KEY_FILE;
140 maas $PROFILE ipranges create type=dynamic start_ip={{ MAAS_DHCP_POOL_START }} end_ip={{ MAAS_DHCP_POOL_END }} comment='Reserved dynamic range for HW and VCP nodes'
141 maas $PROFILE ipranges create type=reserved start_ip={{ ETH1_IP_ADDRESS_CFG01 }} end_ip={{ ETH1_IP_ADDRESS_CFG01 }} comment='This is a reserved IP for cfg with maas node';
142 maas $PROFILE vlan update 51 0 dhcp_on=True primary_rack=cfg01;
143 maas $PROFILE nodes read |grep status -A 1 -B 1;
144 node_name: {{ HOSTNAME_CFG01 }}
145 retry: {count: 1, delay: 10}
146 skip_fail: false
147
148- description: Comissioning nodes
149 cmd: |
150 salt-call state.apply maas.machines;
151 salt-call state.apply maas.machines.wait_for_ready;
152 node_name: {{ HOSTNAME_CFG01 }}
153 retry: {count: 1, delay: 10}
154 skip_fail: false
155
156- description: Assign IPs
157 cmd: |
158 salt-call state.sls maas.machines.assign_ip;
159 node_name: {{ HOSTNAME_CFG01 }}
160 retry: {count: 1, delay: 10}
161 skip_fail: false
162
163- description: Deploying BM nodes
164 cmd: |
165 salt-call maas.deploy_machines || true
166 salt-call state.apply maas.machines.wait_for_deployed;
167 node_name: {{ HOSTNAME_CFG01 }}
168 retry: {count: 1, delay: 10}
169 skip_fail: false
170
171- description: Configure ntp on all nodes
172 cmd: |
173 salt '*' state.sls ntp;
174 node_name: {{ HOSTNAME_CFG01 }}
175 retry: {count: 1, delay: 10}
176 skip_fail: false
177
178{{ SHARED.MACRO_NETWORKING_WORKAROUNDS() }}
179
180{{ SHARED.MACRO_BOOTSTRAP_ALL_MINIONS() }}
181
182########################################
183# Spin up Control Plane VMs on KVM nodes
184########################################
185
186- description: Execute 'libvirt' states to create necessary libvirt networks
187 cmd: salt --hard-crash --state-output=mixed --state-verbose=False 'kvm*' state.sls libvirt
188 node_name: {{ HOSTNAME_CFG01 }}
189 retry: {count: 2, delay: 10}
190 skip_fail: false
191
192- description: Syncing before salt control state
193 cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.sync_all;
194 node_name: {{ HOSTNAME_CFG01 }}
195 retry: {count: 1, delay: 10}
196 skip_fail: false
197
198- description: Create VMs for control plane
199 cmd: salt --hard-crash --state-output=mixed --state-verbose=False 'kvm*' state.sls salt.control
200 node_name: {{ HOSTNAME_CFG01 }}
201 retry: {count: 3, delay: 10}
202 skip_fail: false
203
204- description: '*Workaround* for waiting the control-plane VMs in the salt-key (instead of sleep)'
205 cmd: |
206 salt-key -l acc| sort > /tmp/current_keys.txt &&
207 salt 'kvm*' cmd.run 'virsh list --name' | grep -v 'kvm'|sort|xargs -I {} fgrep {} /tmp/current_keys.txt
208 node_name: {{ HOSTNAME_CFG01 }}
209 retry: {count: 20, delay: 30}
210 skip_fail: false
211
212#########################################
213# Configure all running salt minion nodes
214#########################################
215
216- description: Hack resolv.conf on VCP nodes for internal services access
217 cmd: |
218 salt --hard-crash --state-output=mixed --state-verbose=False -C '*' cmd.run "echo 'nameserver 172.18.208.44' > /etc/resolv.conf;"
219 node_name: {{ HOSTNAME_CFG01 }}
220 retry: {count: 1, delay: 5}
221 skip_fail: false
222
223- description: Refresh pillars on all minions
224 cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.refresh_pillar
225 node_name: {{ HOSTNAME_CFG01 }}
226 retry: {count: 1, delay: 5}
227 skip_fail: false
228
229- description: Sync all salt resources
230 cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.sync_all && sleep 5
231 node_name: {{ HOSTNAME_CFG01 }}
232 retry: {count: 1, delay: 5}
233 skip_fail: false
234
235- description: Show reclass-salt --top for generated nodes
236 cmd: reclass-salt --top -u /srv/salt/reclass/nodes/_generated/
237 node_name: {{ HOSTNAME_CFG01 }}
238 retry: {count: 1, delay: 5}
239 skip_fail: false
240
241{{ SHARED.MACRO_BOOTSTRAP_ALL_MINIONS() }}
Tatyana Leontovich4453dd62018-06-26 18:44:31 +0300242
243{{SHARED.MACRO_CHECK_SALT_VERSION_SERVICES_ON_CFG()}}
244
245{{SHARED.MACRO_CHECK_SALT_VERSION_ON_NODES()}}