blob: d26a22a33e70b437f50716c36078d7e516381f0e [file] [log] [blame]
Dmitry Tyzhnenko34595f82018-06-12 19:03:12 +03001{% from 'cookied-bm-mcp-pike-k8s-contrail/underlay.yaml' import HOSTNAME_CFG01 with context %}
Dmitry Tyzhnenko34595f82018-06-12 19:03:12 +03002{% from 'cookied-bm-mcp-pike-k8s-contrail/underlay.yaml' import LAB_CONFIG_NAME with context %}
3{% from 'cookied-bm-mcp-pike-k8s-contrail/underlay.yaml' import DOMAIN_NAME with context %}
Dmitry Tyzhnenko34595f82018-06-12 19:03:12 +03004{% from 'cookied-bm-mcp-pike-k8s-contrail/underlay.yaml' import HOSTNAME_KVM01 with context %}
5{% from 'cookied-bm-mcp-pike-k8s-contrail/underlay.yaml' import HOSTNAME_KVM02 with context %}
6{% from 'cookied-bm-mcp-pike-k8s-contrail/underlay.yaml' import HOSTNAME_KVM03 with context %}
7
8{% set SALT_MODELS_REPOSITORY = os_env('SALT_MODELS_REPOSITORY','https://gerrit.mcp.mirantis.net/salt-models/mcp-virtual-lab') %}
9# Other salt model repository parameters see in shared-salt.yaml
10
11# Name of the context file (without extension, that is fixed .yaml) used to render the Environment model
12{% set ENVIRONMENT_MODEL_INVENTORY_NAME = os_env('ENVIRONMENT_MODEL_INVENTORY_NAME','bm-mcp-pike-k8s-contrail') %}
13# Path to the context files used to render Cluster and Environment models
14{%- set CLUSTER_CONTEXT_NAME = 'salt-context-cookiecutter-k8s-contrail.yaml' %}
15{%- set ENVIRONMENT_CONTEXT_NAMES = ['salt-context-environment.yaml','lab04-upgrade-physical-inventory.yaml'] %}
16{%- set CONTROL_VLAN = os_env('CONTROL_VLAN', '2410') %}
17{%- set TENANT_VLAN = os_env('TENANT_VLAN', '2411') %}
18
19
20{% import 'shared-salt.yaml' as SHARED with context %}
21
22{{ SHARED.MACRO_INSTALL_SALT_MASTER() }}
23
24{{ SHARED.MACRO_GENERATE_COOKIECUTTER_MODEL(CONTROL_VLAN=CONTROL_VLAN, TENANT_VLAN=TENANT_VLAN) }}
25
26{{ SHARED.MACRO_GENERATE_AND_ENABLE_ENVIRONMENT_MODEL() }}
27
Dmitry Tyzhnenko7c7b7d82018-07-20 15:35:07 +030028{{ 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"') }}
Dmitry Tyzhnenko34595f82018-06-12 19:03:12 +030029
30{{ SHARED.MACRO_INSTALL_SALT_MINIONS() }}
31
32{{ SHARED.MACRO_RUN_SALT_MASTER_UNDERLAY_STATES() }}
33
Dmitry Tyzhnenko34595f82018-06-12 19:03:12 +030034- description: "Workaround for rack01 compute generator"
35 cmd: |
36 set -e;
37 # Remove rack01 key
38 . /root/venv-reclass-tools/bin/activate;
39 reclass-tools del-key parameters.reclass.storage.node.kubernetes_compute_rack01 /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/config.yml;
40 node_name: {{ HOSTNAME_CFG01 }}
41 retry: {count: 1, delay: 10}
42 skip_fail: false
43
Dmitry Tyzhnenko7c7b7d82018-07-20 15:35:07 +030044- description: "Change path to internal storage for salt.control images"
Dmitry Tyzhnenko34595f82018-06-12 19:03:12 +030045 cmd: |
46 set -e;
Dmitry Tyzhnenko34595f82018-06-12 19:03:12 +030047 . /root/venv-reclass-tools/bin/activate;
Dmitry Tyzhnenko7c7b7d82018-07-20 15:35:07 +030048 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;
Dmitry Tyzhnenko34595f82018-06-12 19:03:12 +030050 node_name: {{ HOSTNAME_CFG01 }}
51 retry: {count: 1, delay: 10}
52 skip_fail: false
53
Dmitry Tyzhnenko34595f82018-06-12 19:03:12 +030054- description: Temporary WR for correct bridge name according to envoronment templates
55 cmd: |
56 sed -i 's/br\-ctl/br\_ctl/g' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/kvm.yml;
57 sed -i 's/br\-mgm/br\_mgm/g' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/kvm.yml;
58 node_name: {{ HOSTNAME_CFG01 }}
59 retry: {count: 1, delay: 10}
60 skip_fail: false
61
Dmitry Tyzhnenko7c7b7d82018-07-20 15:35:07 +030062- description: Rerun openssh after env model is generated
63 cmd: |
64 salt-call state.sls openssh
65 node_name: {{ HOSTNAME_CFG01 }}
66 retry: {count: 1, delay: 10}
67 skip_fail: false
68
69{{ SHARED.MACRO_GENERATE_INVENTORY() }}
70
71{{ SHARED.MACRO_NETWORKING_WORKAROUNDS() }}
72
73- description: "Disable kubelet_fail_on_swap"
74 cmd: |
75 set -e;
76 . /root/venv-reclass-tools/bin/activate;
77 reclass-tools add-key parameters._param.kubelet_fail_on_swap false /srv/salt/reclass/classes/system/kubernetes/common.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.network.host
100 node_name: {{ HOSTNAME_CFG01 }}
101 retry: {count: 2, delay: 10}
102 skip_fail: false
103
Dmitry Tyzhnenko34595f82018-06-12 19:03:12 +0300104{{ SHARED.MACRO_BOOTSTRAP_ALL_MINIONS() }}
105
106########################################
107# Spin up Control Plane VMs on KVM nodes
108########################################
109
110- description: Execute 'libvirt' states to create necessary libvirt networks
111 cmd: salt --hard-crash --state-output=mixed --state-verbose=False 'kvm*' state.sls libvirt
112 node_name: {{ HOSTNAME_CFG01 }}
113 retry: {count: 2, delay: 10}
114 skip_fail: false
115
116- description: Create VMs for control plane
117 cmd: salt --hard-crash --state-output=mixed --state-verbose=False 'kvm*' state.sls salt.control
118 node_name: {{ HOSTNAME_CFG01 }}
119 retry: {count: 3, delay: 10}
120 skip_fail: false
121
122- description: '*Workaround* for waiting the control-plane VMs in the salt-key (instead of sleep)'
123 cmd: |
124 salt-key -l acc| sort > /tmp/current_keys.txt &&
125 salt 'kvm*' cmd.run 'virsh list --name' | grep -v 'kvm'|sort|xargs -I {} fgrep {} /tmp/current_keys.txt
126 node_name: {{ HOSTNAME_CFG01 }}
127 retry: {count: 20, delay: 30}
128 skip_fail: false
129
Dmitry Tyzhnenko7c7b7d82018-07-20 15:35:07 +0300130{{ SHARED.MACRO_BOOTSTRAP_ALL_MINIONS() }}
131
Dmitry Tyzhnenko34595f82018-06-12 19:03:12 +0300132#########################################
133# Configure all running salt minion nodes
134#########################################
135
136- description: Hack resolv.conf on VCP nodes for internal services access
137 cmd: |
Dmitry Tyzhnenko7c7b7d82018-07-20 15:35:07 +0300138 salt --hard-crash --state-output=mixed --state-verbose=False -C '* and not cfg*' cmd.run "echo 'nameserver 172.17.41.2' > /etc/resolv.conf;"
Dmitry Tyzhnenko34595f82018-06-12 19:03:12 +0300139 node_name: {{ HOSTNAME_CFG01 }}
140 retry: {count: 1, delay: 5}
141 skip_fail: false
142
143- 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
Dmitry Tyzhnenko7c7b7d82018-07-20 15:35:07 +0300161{{SHARED.MACRO_CHECK_SALT_VERSION_SERVICES_ON_CFG()}}
162
163{{SHARED.MACRO_CHECK_SALT_VERSION_ON_NODES()}}
164
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