blob: 06eb55ff5f414f54bbd203b55f49033e34e32fa2 [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+dVenP90xLYHcnyACg63HUVEp5foLvu1WzOdH2A4bHmsl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v8o+C1/hvrfHimG/I/rAwYRS6Dx0bZ7m49zATNxe+EVer3BV63ru34Hzel/XxxyD34ULmrDgvP3olaAKFI17gVOFQ7hCBzDRp3s4YN3ojQspPyeiO+Jt8OwVomxJWgLauAHhl7Z/XPVHpT/fssJGG/eC4oOz4RZ4jAk0BH3Yl8s63grfwrgB79H/+nr0UvBdTkBn3T5WiC4gxnm+jQQwci7/BLQsg1Z3OykfTuyftIexNyVVy/SmdsGi37RJGFKRMMovoZx+261JgaHWBoHqBJa5UpV2usi9z3Py2z avgoor@MacBook-Pro-Denis.local
131
132 - path: /etc/bash_completion.d/kaas
133 content: |
134 PATH=${PATH}:~/kaas-bootstrap/bin:/home/ubuntu/bootstrap/dev/bin
135 if [ -f ~/kubeconfig ]; then export KUBECONFIG=~/kubeconfig ; fi
136 if [ -f ~/bootstrap/dev/kubeconfig ]; then export KUBECONFIG=~/bootstrap/dev/kubeconfig; fi
137 echo "KUBECONFIG=${KUBECONFIG}"
138 echo "kubectl=$(which kubectl)"
139
140 - path: /etc/netplan/51-kaas-init.yaml
141 content: |
142 network:
143 version: 2
144 renderer: networkd
145 ethernets:
146 ens3:
147 nameservers:
148 addresses: $nameservers
149 dhcp4: false
150 dhcp6: false
151 bridges:
152 br0:
153 dhcp4: false
154 dhcp6: false
155 addresses:
156 - 172.16.180.2/23
157 mtu: 9100
158 nameservers:
159 addresses:
160 - 172.18.176.6
161 - 172.16.180.1
162 - 8.8.8.8
163 search: [ ]
164 interfaces:
165 - ens3
166 routes:
167 - to: 0.0.0.0/0
168 via: 172.16.180.1
169 parameters:
170 forward-delay: 4
171 stp: false
172 - path: /root/do_deploy.sh
173 content: |
174 set -e
175 source /root/env_vars.sh
176 while [ ! -d /root/templates ] ; do sleep 4 ; done
177 [[ "$(sed -n 693p /root/kaas-bootstrap/bootstrap.sh)" -eq "configure" ]] && sed -i "693d" /root/kaas-bootstrap/bootstrap.sh
178 /root/kaas-bootstrap/bootstrap.sh all
179 export KUBECONFIG=/root/kubeconfig
180 echo r00tme | /root/kaas-bootstrap/container-cloud bootstrap user add --username root --roles global-admin,management-admin,reader,writer,operator --kubeconfig kubeconfig --password-stdin
181 - path: /root/do_child.sh
182 content: |
183 set -e
184 while [ ! -d /root/child/templates ] ; do echo 'no child templates!' ; sleep 4 ; done
185 export KUBECONFIG=/root/kubeconfig
186 kubectl apply -f /root/child/templates/project.yaml
187 sleep 2 && kubectl -n mosk apply -f /root/child/templates/ssh_pubkeys.yaml
188 sleep 2 && kubectl -n mosk apply -f /root/child/templates/cluster.yaml
189 sleep 2 && kubectl -n mosk apply -f /root/child/templates/baremetalhosts.yaml
190 sleep 2 && kubectl -n mosk apply -f /root/child/templates/baremetalhostprofiles.yaml
191 sleep 2 && kubectl -n mosk apply -f /root/child/templates/subnets.yaml
192 sleep 2 && kubectl -n mosk apply -f /root/child/templates/l2_templates.yaml
193 sleep 2 && kubectl -n mosk apply -f /root/child/templates/metallbconfig.yaml
194 sleep 2 && kubectl -n mosk apply -f /root/child/templates/machines.yaml
195 sleep 2 && kubectl -n mosk apply -f /root/child/templates/kaascephcluster.yaml
196
197 - path: /etc/udev/rules.d/60-ssd-scheduler.rules
198 content: |
199 ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="deadline"
200
201 - path: /root/env_vars.sh
202 content: |
203 export KAAS_BM_ENABLED="true"
204 export KAAS_BM_PXE_IP="172.16.180.5"
205 export KAAS_BM_PXE_MASK="23"
206 export KAAS_BM_PXE_BRIDGE="br0"
207 export CLUSTER_NAME=kaas-mgmt
208 export OUT_DIR=/root/templates
209 - path: /root/get_child_kubeconfig.sh
210 content: |
211 /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' | tee /root/child.kubeconfig
212 export KUBECONFIG=/root/child.kubeconfig
213 - path: /root/mirantis.lic
214 content: |
215 eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9Cg.eyJleHAiOjE3MzgzOTY4MDAsImlhdCI6MTY3NTMyNDgwMCwic3ViIjoiZGV2fHNpLWRldiIsImxpY2Vuc2UiOnsiZGV2Ijp0cnVlLCJsaW1pdHMiOnsiY2x1c3RlcnMiOjAsIndvcmtlcnNfcGVyX2NsdXN0ZXIiOjB9LCJvcGVuc3RhY2siOnsiY2x1c3RlcnMiOjAsIndvcmtlcnNfcGVyX2NsdXN0ZXIiOjB9fX0K.18naIn5bHkrQJGnqsiv8BHAEhdz_mnMSR2Oz0hAKyhVTdn5Hd7ESJFvPe2agEl7IJf4n6--NPa9zqW0y9zcixnoxB_7xvMntNCaPzfAap8Lm7RSghDJicyJ1xXTj4NNf3ocnbA8rCUNkrSbh2GKFNBqiDMqZTGC7Jozee5HjBzaxFUF0Z0Nr3T0q53DrZmiAhe0P8LtbxFhMICptcMnX-c4mw_hc5TziLZdpR0TUCJk4B0Cit4PABzZWjDCt5gWpy70ZCTTG2xo5dikd-WYBp6f43U5LUroYkhKTHjLMphHnsEDDBu2qaV18ONSuFSQ-Sfg_Mg9ndS_IMTvS9IipsA
216 - path: /etc/docker/daemon.json
217 content: '{"default-address-pools": [{"base": "10.50.0.0/16","size": 24}]}'
218
219
220
221