blob: 17292d186552677843af7a2316dba8f0920e1020 [file] [log] [blame]
Vladimir Khlyunevcc648af2024-04-25 19:56:40 +04001#cloud-config
2output : { all : '| tee -a /var/log/cloud-init-output.log' }
3
4ssh_pwauth: True
5
6disable_root: false
7chpasswd:
8 list: |
9 ubuntu:qalab
10 root:r00tme
11 expire: False
12
13ntp:
14 enabled: true
15 servers:
16 - 0.pool.ntp.org
17 - 1.pool.ntp.org
18 - 2.pool.ntp.org
19 - 3.pool.ntp.org
20
21# this would disable apt:submodule to refresh already overwritten (below) sources.list.
22apt:
23 preserve_sources_list: true
24package_update: false
25package_upgrade: false
26package_reboot_if_required: false
27
28instance_boot:
29 - &instance_boot |
30 service="apt-daily-upgrade.service apt-daily.service apt-daily-upgrade.timer apt-daily.timer
31 kerneloops snapd snapd.socket cups-browsed.service cups apport.service apport-forward.socket motd-news.service motd-news.timer unattended-upgrades.service
32 ua-messaging.timer ua-messaging.service ua-timer.timer"
33 for r in ${service} ; do
34 systemctl disable ${r} || true
35 systemctl mask ${r} || true
36 systemctl stop ${r} || true
37 done
38
39 export DEBIAN_FRONTEND=noninteractive
40 export DEBCONF_NONINTERACTIVE_SEEN=true
41 APT_OPTS="-o APT::Install-Suggests=0 -o APT::Install-Recommends=0 -o Dpkg::Options::=--force-confold -o Dpkg::Options::=--force-confdef"
42 apt-get ${APT_OPTS} -y remove --purge unattended-upgrades || true
43
44 function wait_condition_send() {
45 local status=${1:-SUCCESS}
46 local reason=${2:-empty}
47 local data_binary="{\"status\": \"$status\", \"reason\": \"$reason\"}"
48 echo "Sending signal to wait condition: $data_binary"
49 $wait_condition_notify -k --data-binary "$data_binary"
50 if [ "$status" == "FAILURE" ]; then
51 exit 1
52 fi
53 }
54
55 # Re-pin repo, just to cleanup src\and etc metadata download
56 source /etc/lsb-release
57 cat << EOF > /etc/apt/sources.list
58 deb [arch=amd64] https://mirror.mirantis.com/nightly/ubuntu/ ${DISTRIB_CODENAME} main restricted universe
59 deb [arch=amd64] https://mirror.mirantis.com/nightly/ubuntu/ ${DISTRIB_CODENAME}-updates main restricted universe
60 EOF
61
62 # Remove 50command-not-found and update cache
63 rm -f /etc/apt/apt.conf.d/50command-not-found
64 apt-get update
65
66 if [[ -n "$hack_tuning_enabled" ]]; then
67 echo "Add dirty hacks in system"
68 sysctl -w vm.dirty_ratio=40
69 sysctl -w vm.dirty_background_ratio=20
70 echo 0 > /sys/block/vda/queue/rotational || true
71 echo 32768 > /sys/block/vda/queue/read_ahead_kb || true
72 GRUB_CMDLINE_LINUX_DEFAULT="console=tty1 console=ttyS0 noibrs noibpb nopti nospectre_v2 nospectre_v1 l1tf=off nospec_store_bypass_disable no_stf_barrier mds=off tsx=on tsx_async_abort=off mitigations=off"
73 if ! [[ $(cat /proc/cmdline) =~ $GRUB_CMDLINE_LINUX_DEFAULT ]]; then
74 echo "Update mount options for / partition"
75 sed -i '/rootfs/s/defaults\t/rw,noatime,nodiratime,lazytime,nobarrier,commit=240,data=ordered\t/' /etc/fstab
76 echo "Update kernel cmdline in grub and reboot"
77 echo "GRUB_CMDLINE_LINUX_DEFAULT=\"${GRUB_CMDLINE_LINUX_DEFAULT}\"" > /etc/default/grub.d/60-make-linux-fast-again.cfg
78 update-grub2
79 cloud-init clean --reboot # clean cloud-init cache and reboot so it emulates first boot
80 fi
81 fi
82
83 netplan --debug apply
84 # NOTE(vsaienko): the netplan apply is asyncronous, there is no guarantee
85 # that changes are applied when command exited. Pause some time to make
86 # sure we call next check when network is reconfigured.
87 sleep 15
88
89 echo "Checking connectivity to mirror.mirantis.com"
90 wait_time=0
91 until $( timeout 30s curl -s mirror.mirantis.com >> /dev/null ); do
92 if [[ $wait_time -gt 5 ]]; then
93 echo "FAILURE: unable to access mirror.mirantis.com (network check)"
94 wait_condition_send "FAILURE" "mirror.mirantis.com is unreachable"
95 exit 1
96 fi
97 sleep $(( 3 * wait_time++ ))
98 done
99
100 echo "Configuring regional user for clean-seed scenarios"
101 sudo groupadd docker
102 sudo groupadd regional
103 sudo useradd -g regional -G users,admin,docker -s /bin/bash -m regional
104 echo -e "\nregional ALL=(ALL) NOPASSWD: ALL\n" | sudo tee -a /etc/sudoers
105 sudo mkdir -p /home/regional/.ssh
106 sudo cp /home/ubuntu/.ssh/authorized_keys /home/regional/.ssh/authorized_keys
107 sudo chmod 600 /home/regional/.ssh/authorized_keys
108 sudo chown -R regional:regional /home/regional
109 apt-get ${APT_OPTS} -y install bridge-utils docker.io ipmitool wget golang-cfssl jq
110 usermod -aG docker ubuntu
111 cd /root/
112 wget https://binary.mirantis.com/releases/get_container_cloud.sh
113 chmod 0755 get_container_cloud.sh
114 ./get_container_cloud.sh
115 cp /root/mirantis.lic kaas-bootstrap/
116
117 echo "Sending wait_condition signal"
118 wait_condition_send "SUCCESS" "Instance is UP and running"
119
120runcmd:
121 - [bash, -cex, *instance_boot]
122
123write_files:
124 - path: /root/.ssh/authorized_keys
125 content: |
126 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDeGiSOs0zAwcxuc9y6BzidYFXQXLOLcBKSoW1tPYJ+bVGRwNRVh63/+/X+eOPbBp6xTNNHVyOpYHt1WUbIHsAqAx/XbzBp+j3/4+8+ucvWR3X9TTxK7Q+oB3SSy2iEeimiJmxfjiHu1hfcgN8L9YvXVquGC/EZbk/r27j7Gcxli7zesr9/kBBhigDSQeehJBJZ0ux3luVkjWSDYTeKqZhNNPFoD6eWmOfsAKNMhe/8IRD9e0zY4MsELi1tZl2zoQ69249e4M1aCuGxm+t+tHLzywX0tVZmM1yX7TDuszHbiii8HrjNwB1/K80HRwRrwVIne9P7wFSlC2exLkdfWd2D vkhlyunev
127 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDci6MBY68s3FJ9V1OP5vdtVo/daJnkNXCPSPYbCX8/d0E3UJKgE81YvsxfuKp3r1rUNwTuGnkq+VUWcbIgpQNy69OuKxQkoGsRgYTA8n4ZZcuWz+dVenP90xLYHcnyACg63HUVEp5foLvu1WzOdH2A4bHmsl0ePM5I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/hvrfHimG/I/rAwYRS6Dx0bZ7m49zATNxe+EVer3BV63ru34Hzel/XxxyD34ULmrDgvP3olaAKFI17gVOFQ7hCBzDRp3s4YN3ojQspPyeiO+Jt8OwVomxJWgLauAHhl7Z/XPVHpT/fssJGG/eC4oOz4RZ4jAk0BH3Yl8s63grfwrgB79H/+nr0UvBdTkBn3T5WiC4gxnm+jQQwci7/BLQsg1Z3OykfTuyftIexNyVVy/SmdsGi37RJGFKRMMovoZx+261JgaHWBoHqBJa5UpV2usi9z3Py2z avgoor@MacBook-Pro-Denis.local
Vladimir Khlyuneve03b04f2024-04-26 02:57:02 +0400131 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDjL5X8RdcYhxsd6j43p5Clk8hzq/IjfRvekD+xPy6DhD2kyKTnAR1FjtTeFtH1mC+lD+nUnswR1A5dR+5eHemKxz0IkWuDeL8+YdMpOy+bbQyA+tlTukGriPcIUCHOxn7u2u4zV4a+AcZha5obR1zv91nkGaWAfbjDHTl2f4IB3Rx3rJwd/3r7ge1MA0qIRqr1k+FY99477zd+nbYVP8n84+uY7DoaFHtzEWTXqc2CwdEO+5uzMzdWWRUwU1vwe4Ac9i1NtsA33pa1VVMKny2S2k2JcvNpkKDo7x4ezH2fOuHiDTOk4CqUjg7TlpsdMbT8ugj5YE8H/O3Kh25t3Fkn maintenance-ci-robot
Vladimir Khlyunevcc648af2024-04-25 19:56:40 +0400132
133 - path: /etc/bash_completion.d/kaas
134 content: |
135 PATH=${PATH}:~/kaas-bootstrap/bin:/home/ubuntu/bootstrap/dev/bin
136 if [ -f ~/kubeconfig ]; then export KUBECONFIG=~/kubeconfig ; fi
137 if [ -f ~/bootstrap/dev/kubeconfig ]; then export KUBECONFIG=~/bootstrap/dev/kubeconfig; fi
138 echo "KUBECONFIG=${KUBECONFIG}"
139 echo "kubectl=$(which kubectl)"
140
141 - path: /etc/netplan/51-kaas-init.yaml
142 content: |
143 network:
144 version: 2
145 renderer: networkd
146 ethernets:
147 ens3:
148 nameservers:
149 addresses: $nameservers
150 dhcp4: false
151 dhcp6: false
152 bridges:
153 br0:
154 dhcp4: false
155 dhcp6: false
156 addresses:
157 - 172.16.180.2/23
158 mtu: 9100
159 nameservers:
160 addresses:
161 - 172.18.176.6
162 - 172.16.180.1
163 - 8.8.8.8
164 search: [ ]
165 interfaces:
166 - ens3
167 routes:
168 - to: 0.0.0.0/0
169 via: 172.16.180.1
170 parameters:
171 forward-delay: 4
172 stp: false
Vladimir Khlyuneve03b04f2024-04-26 02:57:02 +0400173 - path: /root/do_deploy_mcc_mgmt.sh
Vladimir Khlyunevcc648af2024-04-25 19:56:40 +0400174 content: |
175 set -e
176 source /root/env_vars.sh
Vladimir Khlyuneve03b04f2024-04-26 02:57:02 +0400177 while [ ! -d "${OUT_DIR}" ] ; do sleep 4 ; done
Vladimir Khlyunevcc648af2024-04-25 19:56:40 +0400178 [[ "$(sed -n 693p /root/kaas-bootstrap/bootstrap.sh)" -eq "configure" ]] && sed -i "693d" /root/kaas-bootstrap/bootstrap.sh
Vladimir Khlyunev9de85ff2024-07-31 23:42:16 +0400179 # PROD-44779
180 set +e -o pipefail
181 /root/kaas-bootstrap/bootstrap.sh all 2>&1 | tee deploy_mcc_mgmt_output.log
182 retcode=$?
183 set -e
184 if [[ $retcode -ne 0 ]] ; then
185 grep "Keycloak service is unavailable" deploy_mcc_mgmt_output.log && echo "PRODX-44779 is still there, ignoring" || exit $retcode
186 else
187 echo 'REMOVE PRODX-44779 WORKAROUND'
188 fi
Vladimir Khlyunevcc648af2024-04-25 19:56:40 +0400189 export KUBECONFIG=/root/kubeconfig
190 echo r00tme | /root/kaas-bootstrap/container-cloud bootstrap user add --username root --roles global-admin,management-admin,reader,writer,operator --kubeconfig kubeconfig --password-stdin
Vladimir Khlyuneve03b04f2024-04-26 02:57:02 +0400191 - path: /root/do_deploy_child.sh
Vladimir Khlyunevcc648af2024-04-25 19:56:40 +0400192 content: |
193 set -e
Vladimir Khlyuneve03b04f2024-04-26 02:57:02 +0400194 while [ ! -d /root/bm_mcc_mosk/child/cluster ] ; do echo 'no child templates!' ; sleep 4 ; done
Vladimir Khlyunevcc648af2024-04-25 19:56:40 +0400195 export KUBECONFIG=/root/kubeconfig
Vladimir Khlyuneve03b04f2024-04-26 02:57:02 +0400196 /root/kaas-bootstrap/bin/kubectl apply -f /root/bm_mcc_mosk/child/cluster/project.yaml
197 sleep 2 && /root/kaas-bootstrap/bin/kubectl -n mosk apply -f /root/bm_mcc_mosk/child/cluster/ssh_pubkeys.yaml
198 sleep 2 && /root/kaas-bootstrap/bin/kubectl -n mosk apply -f /root/bm_mcc_mosk/child/cluster/cluster.yaml
199 sleep 2 && /root/kaas-bootstrap/bin/kubectl -n mosk apply -f /root/bm_mcc_mosk/child/cluster/baremetalhosts.yaml
200 sleep 2 && /root/kaas-bootstrap/bin/kubectl -n mosk apply -f /root/bm_mcc_mosk/child/cluster/baremetalhostprofiles.yaml
201 sleep 2 && /root/kaas-bootstrap/bin/kubectl -n mosk apply -f /root/bm_mcc_mosk/child/cluster/subnets.yaml
202 sleep 2 && /root/kaas-bootstrap/bin/kubectl -n mosk apply -f /root/bm_mcc_mosk/child/cluster/l2_templates.yaml
203 sleep 2 && /root/kaas-bootstrap/bin/kubectl -n mosk apply -f /root/bm_mcc_mosk/child/cluster/metallbconfig.yaml
204 sleep 2 && /root/kaas-bootstrap/bin/kubectl -n mosk apply -f /root/bm_mcc_mosk/child/cluster/machines.yaml
205 sleep 2 && /root/kaas-bootstrap/bin/kubectl -n mosk apply -f /root/bm_mcc_mosk/child/cluster/kaascephcluster.yaml
Vladimir Khlyunevcc648af2024-04-25 19:56:40 +0400206
207 - path: /etc/udev/rules.d/60-ssd-scheduler.rules
208 content: |
209 ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="deadline"
210
211 - path: /root/env_vars.sh
212 content: |
213 export KAAS_BM_ENABLED="true"
214 export KAAS_BM_PXE_IP="172.16.180.5"
215 export KAAS_BM_PXE_MASK="23"
216 export KAAS_BM_PXE_BRIDGE="br0"
217 export CLUSTER_NAME=kaas-mgmt
Vladimir Khlyuneve03b04f2024-04-26 02:57:02 +0400218 export OUT_DIR=/root/bm_mcc_mosk/kaas-mgmt/
219 export KAAS_BOOTSTRAP_INFINITE_TIMEOUT=true
Vladimir Khlyunevcc648af2024-04-25 19:56:40 +0400220 - path: /root/get_child_kubeconfig.sh
221 content: |
Vladimir Khlyuneve03b04f2024-04-26 02:57:02 +0400222 /root/kaas-bootstrap/bin/kubectl --kubeconfig /root/kubeconfig -n mosk get secrets mosk-kubeconfig -o jsonpath='{.data.admin\.conf}' | base64 -d | sed 's/:5443/:443/g' > /root/child.kubeconfig
Vladimir Khlyunevcc648af2024-04-25 19:56:40 +0400223 export KUBECONFIG=/root/child.kubeconfig
224 - path: /root/mirantis.lic
225 content: |
226 eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9Cg.eyJleHAiOjE3MzgzOTY4MDAsImlhdCI6MTY3NTMyNDgwMCwic3ViIjoiZGV2fHNpLWRldiIsImxpY2Vuc2UiOnsiZGV2Ijp0cnVlLCJsaW1pdHMiOnsiY2x1c3RlcnMiOjAsIndvcmtlcnNfcGVyX2NsdXN0ZXIiOjB9LCJvcGVuc3RhY2siOnsiY2x1c3RlcnMiOjAsIndvcmtlcnNfcGVyX2NsdXN0ZXIiOjB9fX0K.18naIn5bHkrQJGnqsiv8BHAEhdz_mnMSR2Oz0hAKyhVTdn5Hd7ESJFvPe2agEl7IJf4n6--NPa9zqW0y9zcixnoxB_7xvMntNCaPzfAap8Lm7RSghDJicyJ1xXTj4NNf3ocnbA8rCUNkrSbh2GKFNBqiDMqZTGC7Jozee5HjBzaxFUF0Z0Nr3T0q53DrZmiAhe0P8LtbxFhMICptcMnX-c4mw_hc5TziLZdpR0TUCJk4B0Cit4PABzZWjDCt5gWpy70ZCTTG2xo5dikd-WYBp6f43U5LUroYkhKTHjLMphHnsEDDBu2qaV18ONSuFSQ-Sfg_Mg9ndS_IMTvS9IipsA
227 - path: /etc/docker/daemon.json
228 content: '{"default-address-pools": [{"base": "10.50.0.0/16","size": 24}]}'
229
230
231
232