blob: 54d129890a5aedff2c37ac42c9998afb7bbf7e2b [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
Tatyana Leontovicheedbd852018-07-10 11:29:38 +030027{{ 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" ') }}
sgudz8c888ec2017-10-02 15:29:23 +030028
sgudz8c888ec2017-10-02 15:29:23 +030029{{ SHARED.MACRO_INSTALL_SALT_MINIONS() }}
30
31{{ SHARED.MACRO_RUN_SALT_MASTER_UNDERLAY_STATES() }}
32
33- description: "Workaround for rack01 compute generator"
34 cmd: |
35 set -e;
36 # Remove rack01 key
Dennis Dmitrievd96ace12018-01-26 14:46:21 +020037 . /root/venv-reclass-tools/bin/activate;
sgudz8c888ec2017-10-02 15:29:23 +030038 reclass-tools del-key parameters.reclass.storage.node.openstack_compute_rack01 /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/config.yml;
39 # Add openstack_compute_node definition from system
40 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 +020041 node_name: {{ HOSTNAME_CFG01 }}
42 retry: {count: 1, delay: 10}
43 skip_fail: false
sgudz8c888ec2017-10-02 15:29:23 +030044
sgudz468b08a2018-07-16 12:55:33 +030045{%- if CUSTOM_VCP_TRUSTY_IMAGE_URL != '' %}
46
47- description: "Change trusty image to custom"
sgudz868f0862018-03-16 21:47:18 +020048 cmd: |
sgudz468b08a2018-07-16 12:55:33 +030049 echo "CUSTOM_TRUSTY_IMAGE is {{ CUSTOM_VCP_TRUSTY_IMAGE_URL }}";
sgudz868f0862018-03-16 21:47:18 +020050 . /root/venv-reclass-tools/bin/activate;
sgudz468b08a2018-07-16 12:55:33 +030051 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 +030052 node_name: {{ HOSTNAME_CFG01 }}
53 retry: {count: 1, delay: 10}
54 skip_fail: false
55
sgudz468b08a2018-07-16 12:55:33 +030056{%- endif %}
sgudz8c888ec2017-10-02 15:29:23 +030057
sgudz468b08a2018-07-16 12:55:33 +030058{%- if CUSTOM_VCP_XENIAL_IMAGE_URL != '' %}
sgudz8c888ec2017-10-02 15:29:23 +030059
sgudz468b08a2018-07-16 12:55:33 +030060- description: "Change xenial image to custom"
sgudz8c888ec2017-10-02 15:29:23 +030061 cmd: |
sgudz468b08a2018-07-16 12:55:33 +030062 echo "CUSTOM_XENIAL_IMAGE is {{ CUSTOM_VCP_XENIAL_IMAGE_URL }}";
63 . /root/venv-reclass-tools/bin/activate;
64 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 +030065 node_name: {{ HOSTNAME_CFG01 }}
66 retry: {count: 1, delay: 10}
67 skip_fail: false
68
sgudz468b08a2018-07-16 12:55:33 +030069{%- endif %}
sgudzcced67d2017-10-11 15:56:09 +030070
71- description: Temporary workaround for removing cinder-volume from CTL nodes
sgudz8c888ec2017-10-02 15:29:23 +030072 cmd: |
sgudzcced67d2017-10-11 15:56:09 +030073 sed -i 's/\-\ system\.cinder\.volume\.single//g' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/openstack/control.yml;
74 sed -i 's/\-\ system\.cinder\.volume\.notification\.messagingv2//g' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/openstack/control.yml;
75 node_name: {{ HOSTNAME_CFG01 }}
76 retry: {count: 1, delay: 5}
77 skip_fail: true
78
sgudz868f0862018-03-16 21:47:18 +020079- description: Temporary WR for correct bridge name according to envoronment templates
sgudzcced67d2017-10-11 15:56:09 +030080 cmd: |
sgudz868f0862018-03-16 21:47:18 +020081 sed -i 's/br\-ctl/br\_ctl/g' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/kvm.yml;
82 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 +030083 node_name: {{ HOSTNAME_CFG01 }}
84 retry: {count: 1, delay: 10}
sgudz868f0862018-03-16 21:47:18 +020085 skip_fail: false
sgudz468b08a2018-07-16 12:55:33 +030086
87{{ SHARED.MACRO_GENERATE_INVENTORY() }}
88
89{{ SHARED.MACRO_NETWORKING_WORKAROUNDS() }}
90
91- description: Update minion information
92 cmd: |
93 salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.sync_grains &&
94 salt --hard-crash --state-output=mixed --state-verbose=False '*' mine.update &&
95 salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.refresh_pillar && sleep 10
96 node_name: {{ HOSTNAME_CFG01 }}
97 retry: {count: 1, delay: 10}
98 skip_fail: false
99
100- description: Rerun openssh after env model is generated
101 cmd: |
102 salt-call state.sls openssh
103 node_name: {{ HOSTNAME_CFG01 }}
104 retry: {count: 1, delay: 10}
105 skip_fail: false
106
107- description: Execute linux.network.host one more time after salt.minion to apply dynamically registered hosts on the cluster nodes
108 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@linux:system' state.sls linux.network.host
109 node_name: {{ HOSTNAME_CFG01 }}
110 retry: {count: 2, delay: 10}
111 skip_fail: false
112
sgudz8c888ec2017-10-02 15:29:23 +0300113{{ SHARED.MACRO_BOOTSTRAP_ALL_MINIONS() }}
114
115########################################
116# Spin up Control Plane VMs on KVM nodes
117########################################
118
119- description: Execute 'libvirt' states to create necessary libvirt networks
120 cmd: salt --hard-crash --state-output=mixed --state-verbose=False 'kvm*' state.sls libvirt
121 node_name: {{ HOSTNAME_CFG01 }}
122 retry: {count: 2, delay: 10}
123 skip_fail: false
124
125- description: Create VMs for control plane
126 cmd: salt --hard-crash --state-output=mixed --state-verbose=False 'kvm*' state.sls salt.control
127 node_name: {{ HOSTNAME_CFG01 }}
128 retry: {count: 3, delay: 10}
129 skip_fail: false
130
131- description: '*Workaround* for waiting the control-plane VMs in the salt-key (instead of sleep)'
132 cmd: |
133 salt-key -l acc| sort > /tmp/current_keys.txt &&
134 salt 'kvm*' cmd.run 'virsh list --name' | grep -v 'kvm'|sort|xargs -I {} fgrep {} /tmp/current_keys.txt
135 node_name: {{ HOSTNAME_CFG01 }}
136 retry: {count: 20, delay: 30}
137 skip_fail: false
138
139#########################################
140# Configure all running salt minion nodes
141#########################################
142
sgudzcced67d2017-10-11 15:56:09 +0300143- description: Hack resolv.conf on VCP nodes for internal services access
144 cmd: |
sgudz468b08a2018-07-16 12:55:33 +0300145 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 +0300146 node_name: {{ HOSTNAME_CFG01 }}
147 retry: {count: 1, delay: 5}
148 skip_fail: false
149
sgudz8c888ec2017-10-02 15:29:23 +0300150- description: Refresh pillars on all minions
151 cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.refresh_pillar
152 node_name: {{ HOSTNAME_CFG01 }}
153 retry: {count: 1, delay: 5}
154 skip_fail: false
155
156- description: Sync all salt resources
157 cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.sync_all && sleep 5
158 node_name: {{ HOSTNAME_CFG01 }}
159 retry: {count: 1, delay: 5}
160 skip_fail: false
161
162- description: Show reclass-salt --top for generated nodes
163 cmd: reclass-salt --top -u /srv/salt/reclass/nodes/_generated/
164 node_name: {{ HOSTNAME_CFG01 }}
165 retry: {count: 1, delay: 5}
166 skip_fail: false
167
168{{ SHARED.MACRO_BOOTSTRAP_ALL_MINIONS() }}
Tatyana Leontovich4453dd62018-06-26 18:44:31 +0300169
170{{SHARED.MACRO_CHECK_SALT_VERSION_SERVICES_ON_CFG()}}
171
172{{SHARED.MACRO_CHECK_SALT_VERSION_ON_NODES()}}
sgudz468b08a2018-07-16 12:55:33 +0300173
174- description: "Lab04 workaround: Give each node root acces with key from cfg01"
175 cmd: |
176 set -e;
177 set -x;
178 key=$(ssh-keygen -y -f /root/.ssh/id_rsa);
179 salt '*' cmd.run "echo $key >> /root/.ssh/authorized_keys";
180 salt '*' cmd.run "service sshd restart"
181 node_name: {{ HOSTNAME_CFG01 }}
182 retry: {count: 1, delay: 5}
183 skip_fail: true
184
185- description: "Lab04 workaround: Control network access from cfg01 node using sshuttle via kvm01"
186 cmd: |
187 set -e;
188 set -x;
189 KVM01_DEPLOY_ADDRESS=$(salt-call --out=newline_values_only pillar.get _param:infra_kvm_node01_deploy_address);
190 apt-get install -y sshuttle;
191 sshuttle -r ${KVM01_DEPLOY_ADDRESS} 10.167.8.0/24 -D >/dev/null;
192 node_name: {{ HOSTNAME_CFG01 }}
193 retry: {count: 1, delay: 5}
194 skip_fail: true