blob: 8c470b11a30629fe319b08ad4cc705ac3494aa8e [file] [log] [blame]
sgudzf5a51222018-05-11 14:20:50 +03001{% from 'cookied-bm-contrail-maas/underlay.yaml' import HOSTNAME_CFG01 with context %}
2{% from 'cookied-bm-contrail-maas/underlay.yaml' import LAB_CONFIG_NAME with context %}
3{% from 'cookied-bm-contrail-maas/underlay.yaml' import DOMAIN_NAME with context %}
4{% from 'cookied-bm-contrail-maas/underlay.yaml' import REPOSITORY_SUITE with context %}
5{% from 'cookied-bm-contrail-maas/underlay.yaml' import ETH1_IP_ADDRESS_CFG01 with context %}
6{% from 'cookied-bm-contrail-maas/underlay.yaml' import MAAS_DHCP_POOL_START with context %}
7{% from 'cookied-bm-contrail-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-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
27{{ 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"') }}
28
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: Temporary workaround for removing cinder-volume from CTL nodes
67 cmd: |
68 sed -i 's/\-\ system\.cinder\.volume\.single//g' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/openstack/control.yml;
69 sed -i 's/\-\ system\.cinder\.volume\.notification\.messagingv2//g' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/openstack/control.yml;
70 node_name: {{ HOSTNAME_CFG01 }}
71 retry: {count: 1, delay: 5}
72 skip_fail: true
73
74- description: Temporary WR for correct bridge name according to envoronment templates
75 cmd: |
76 sed -i 's/br\-ctl/br\_ctl/g' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/kvm.yml;
77 sed -i 's/br\-mgm/br\_mgm/g' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/kvm.yml;
78 node_name: {{ HOSTNAME_CFG01 }}
79 retry: {count: 1, delay: 10}
80 skip_fail: false
81
82- description: Update minion information
83 cmd: |
84 salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.sync_grains &&
85 salt --hard-crash --state-output=mixed --state-verbose=False '*' mine.update &&
86 salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.refresh_pillar && sleep 10
87 node_name: {{ HOSTNAME_CFG01 }}
88 retry: {count: 1, delay: 10}
89 skip_fail: false
90
91- description: Rerun openssh after env model is generated
92 cmd: |
93 salt-call state.sls openssh
94 node_name: {{ HOSTNAME_CFG01 }}
95 retry: {count: 1, delay: 10}
96 skip_fail: false
97
98- description: Execute linux.network.host one more time after salt.minion to apply dynamically registered hosts on the cluster nodes
99 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@linux:system' state.sls linux
100 node_name: {{ HOSTNAME_CFG01 }}
101 retry: {count: 1, delay: 10}
102 skip_fail: false
103
104- description: Configure rsyslog on nodes
105 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@linux:system' state.sls rsyslog
106 node_name: {{ HOSTNAME_CFG01 }}
107 retry: {count: 1, delay: 10}
108 skip_fail: false
109
110- description: Configure maas.cluster
111 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@salt:master' state.sls maas.cluster
112 node_name: {{ HOSTNAME_CFG01 }}
113 retry: {count: 1, delay: 10}
114 skip_fail: false
115
116- description: Configure maas.region
117 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@salt:master' state.sls maas.region
118 node_name: {{ HOSTNAME_CFG01 }}
119 retry: {count: 3, delay: 10}
120 skip_fail: false
121
122- description: Configure dhcp for fabric
123 cmd: |
124 touch /root/API_KEY_FILE;
125 export PROFILE=mirantis;
126 export API_KEY_FILE=/root/API_KEY_FILE;
127 export MAAS_URL=http://{{ ETH1_IP_ADDRESS_CFG01 }}:5240/MAAS;
128 maas-region apikey --username=$PROFILE > $API_KEY_FILE;
129 maas login $PROFILE $MAAS_URL - < $API_KEY_FILE;
130 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'
131 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';
132 maas $PROFILE vlan update 51 0 dhcp_on=True primary_rack=cfg01;
133 maas $PROFILE nodes read |grep status -A 1 -B 1;
134 node_name: {{ HOSTNAME_CFG01 }}
135 retry: {count: 1, delay: 10}
136 skip_fail: false
137
138- description: Comissioning nodes
139 cmd: |
140 salt-call state.apply maas.machines;
141 salt-call state.apply maas.machines.wait_for_ready;
142 node_name: {{ HOSTNAME_CFG01 }}
143 retry: {count: 1, delay: 10}
144 skip_fail: false
145
146- description: Assign IPs
147 cmd: |
148 salt-call state.sls maas.machines.assign_ip;
149 node_name: {{ HOSTNAME_CFG01 }}
150 retry: {count: 1, delay: 10}
151 skip_fail: false
152
153- description: Deploying BM nodes
154 cmd: |
155 salt-call maas.deploy_machines || true
156 salt-call state.apply maas.machines.wait_for_deployed;
157 node_name: {{ HOSTNAME_CFG01 }}
158 retry: {count: 1, delay: 10}
159 skip_fail: false
160
161- description: Configure ntp on all nodes
162 cmd: |
163 salt '*' state.sls ntp;
164 node_name: {{ HOSTNAME_CFG01 }}
165 retry: {count: 1, delay: 10}
166 skip_fail: false
167
168{{ SHARED.MACRO_NETWORKING_WORKAROUNDS() }}
169
170{{ SHARED.MACRO_BOOTSTRAP_ALL_MINIONS() }}
171
172########################################
173# Spin up Control Plane VMs on KVM nodes
174########################################
175
176- description: Execute 'libvirt' states to create necessary libvirt networks
177 cmd: salt --hard-crash --state-output=mixed --state-verbose=False 'kvm*' state.sls libvirt
178 node_name: {{ HOSTNAME_CFG01 }}
179 retry: {count: 2, delay: 10}
180 skip_fail: false
181
182- description: Syncing before salt control state
183 cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.sync_all;
184 node_name: {{ HOSTNAME_CFG01 }}
185 retry: {count: 1, delay: 10}
186 skip_fail: false
187
188- description: Create VMs for control plane
189 cmd: salt --hard-crash --state-output=mixed --state-verbose=False 'kvm*' state.sls salt.control
190 node_name: {{ HOSTNAME_CFG01 }}
191 retry: {count: 3, delay: 10}
192 skip_fail: false
193
194- description: '*Workaround* for waiting the control-plane VMs in the salt-key (instead of sleep)'
195 cmd: |
196 salt-key -l acc| sort > /tmp/current_keys.txt &&
197 salt 'kvm*' cmd.run 'virsh list --name' | grep -v 'kvm'|sort|xargs -I {} fgrep {} /tmp/current_keys.txt
198 node_name: {{ HOSTNAME_CFG01 }}
199 retry: {count: 20, delay: 30}
200 skip_fail: false
201
202#########################################
203# Configure all running salt minion nodes
204#########################################
205
206- description: Hack resolv.conf on VCP nodes for internal services access
207 cmd: |
208 salt --hard-crash --state-output=mixed --state-verbose=False -C '*' cmd.run "echo 'nameserver 172.18.208.44' > /etc/resolv.conf;"
209 node_name: {{ HOSTNAME_CFG01 }}
210 retry: {count: 1, delay: 5}
211 skip_fail: false
212
213- description: Refresh pillars on all minions
214 cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.refresh_pillar
215 node_name: {{ HOSTNAME_CFG01 }}
216 retry: {count: 1, delay: 5}
217 skip_fail: false
218
219- description: Sync all salt resources
220 cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.sync_all && sleep 5
221 node_name: {{ HOSTNAME_CFG01 }}
222 retry: {count: 1, delay: 5}
223 skip_fail: false
224
225- description: Show reclass-salt --top for generated nodes
226 cmd: reclass-salt --top -u /srv/salt/reclass/nodes/_generated/
227 node_name: {{ HOSTNAME_CFG01 }}
228 retry: {count: 1, delay: 5}
229 skip_fail: false
230
231{{ SHARED.MACRO_BOOTSTRAP_ALL_MINIONS() }}
Tatyana Leontovich4453dd62018-06-26 18:44:31 +0300232
233{{SHARED.MACRO_CHECK_SALT_VERSION_SERVICES_ON_CFG()}}
234
235{{SHARED.MACRO_CHECK_SALT_VERSION_ON_NODES()}}