53 lines
1.2 KiB
Bash
Executable File
53 lines
1.2 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
lxc="lxc"
|
|
lxc_exec="lxc exec"
|
|
series="noble"
|
|
image="ubuntu:${series}"
|
|
inst_name="${series}-sunbeam"
|
|
|
|
SUNBEAM_VERSION="2024.1/stable"
|
|
|
|
${lxc} delete ${inst_name} --force
|
|
${lxc} launch ${image} ${inst_name} --vm -c limits.cpu=6 -c limits.memory=16GiB -d root,size=80GiB -s virtual
|
|
|
|
echo -n "Checking VM status of ${inst_name} "
|
|
|
|
while true ; do
|
|
num_of_procs=$(${lxc} info ${inst_name} | yq .Resources.Processes)
|
|
[[ ${num_of_procs} -gt 0 ]] && break
|
|
sleep 3
|
|
echo -n "."
|
|
done
|
|
|
|
echo done
|
|
|
|
echo -n "Checking cloud-init status of ${inst_name} "
|
|
|
|
while true ; do
|
|
status=$(${lxc_exec} ${inst_name} -- cloud-init status | grep status | awk '{print $2}')
|
|
[[ "${status}" == "done" ]] && break
|
|
[[ "${status}" == "error" ]] && break
|
|
sleep 3
|
|
echo -n "."
|
|
done
|
|
|
|
echo done
|
|
|
|
cat > initialise.sh << EOF
|
|
#!/bin/bash
|
|
|
|
# Waiting 10 seconds
|
|
sleep 10
|
|
|
|
SUNBEAM_VERSION=$SUNBEAM_VERSION
|
|
sudo snap install openstack --channel \$SUNBEAM_VERSION
|
|
sudo sunbeam prepare-node-script --bootstrap | sudo -i -u ubuntu bash -x
|
|
sudo -i -u ubuntu -- sunbeam -v cluster bootstrap --accept-defaults
|
|
EOF
|
|
|
|
${lxc} file push initialise.sh ${inst_name}/root/
|
|
|
|
${lxc_exec} ${inst_name} -- chmod +x /root/initialise.sh
|
|
${lxc_exec} ${inst_name} -- /root/initialise.sh
|