Ubuntu 22.04 Cloud-Init vSphere vCD Customization Hell
This article about who want to still continute to have cloud-init with Ubuntu 22.04 and want to make customization when using VMware Cloud Director.
This article also could show some very simple things also show what is it ? and why i’m doing this things.
Everything started with How i could make customization with Ubuntu 22.04 without uninstall cloud-init.
Main problem is you will feel like everyting will work after customization but cloud-init will set to DHCP after next reboot kb 71264 !
Please read this links without getting bored 1 , 2 Somehow cloud-init feels need to recustomize vm and because of there is no input that time from VMware cloud-init will try to recustomize network settings and set to DHCP π
First link of course from VMware, always need to query about Guest OS Customization, use this link and related os and vCenter versions. For Ubuntu 22.04 support links contents are not enough.
Short before customization what you should do;
Activated root password and root password based logging before execute each commands next and deleted installation time created user. To delete installation time created use after activate root, i rebooted server and then delete it.
sudo password root
sudo sed -i ‘s/#PermitRootLogin prohibit-password/PermitRootLogin yes/’ /etc/ssh/sshd_config
sudo systemctl restart ssh
You would like to disable ipv6, actually i did but for me sysctl way did not work and i chosed GRUB way !
Edit /etc/default/grub and modify such lines GRUB_CMDLINE_LINUX_DEFAULT and GRUB_CMDLINE_LINUX with ipv6.disable=1and then from shell execute order 66 π sorry of course not its is update-grub2 π
Then reboot the server
Delete installation time user
deluser –remove-home -f <username>
I installed Ubuntu server not minimal and perl, open-vm-tools already installed, if not you can install such packages.
apt update -y && apt upgrade -y && apt dist-upgrade -y && apt autoremove -y
apt install dnsutils traceroute -y
We can decide customization with cloud-init or not. Because of we are using cloud-init in this article we should say to vmware choose cloud-init for customization
Edit /etc/cloud/cloud.cfg and write down the line below top of file. You can imagine default is true.
disable_vmware_customization: false
We came to most important part, because of cloud-init after each restart will try to reconfigure our networking we should say to it , hey ! You do not need to do that , trust your customizatiom config and do not delete it each restart.
echo “manual_cache_clean: True ” > /etc/cloud/cloud.cfg.d/99-manual.cfg
rm -rf /etc/cloud/cloud.cfg.d/subiquity-disable-cloudinit-networking.cfg
rm -rf /etc/cloud/cloud.cfg.d/99-installer.cfg
Some of people also delete then machine-id for customization manually , actually no need that , cloud-init clear can do that
Now, to delete all things with log what come from manuel installation for cloud-init we should delete it
cloud-init clean –logs –machine-id
Delete all netplan files, if not you will get an error like this
rm /etc/netplan/*.yaml
Delete History
cat /dev/null > ~/.bash_history && history -c
Delete Temps
rm -rf /tmp/* && rm -rf /var/tmp/*
Stop rsyslogd and delete its contents
systemctl stop syslog.socket rsyslog.service
truncate -s0 /var/log/wtmp
truncate -s0 /var/log/lastlog
What are these files ;
/etc/cloud/cloud.cfg.d/99-installer.cfg
This is datasource(configuration data) for clout-init which we do not need it because of this we are deleting such file, vmware will be the datasource
/etc/cloud/cloud.cfg.d/subiquity-disable-cloudinit-networking.cfg
This is created by Subiquity because inside you can see that its disabling cloud-init network configuration because Ubuntu is making this change directly to netplan file, but vmware point of view we should delete it.
Shutdown VM for templating and upload it to vCD under Template Sharing Org Catalog
shutdown -h now
No need to ;
Delete or truncate hostname file
Delete or truncate machine-id
Delete or regenerate ssh_host_* files cloud-init making it for you
Preserve hostname because default is false and we want vmware update it for us
Too many people disabled swap, maybe they are preparing image for K8s, its not the case for me
Use for debug ;
/var/log/cloud-init-output.log
Maybe you interest about such funny things ;
Ubuntu use half or up to 100 GB disk space for root partition
Subiquity only provisions half of available space for root logical volume
https://bugs.launchpad.net/subiquity/+bug/1907128
subiquity is the Ubuntu Server installer π
https://bugs.launchpad.net/ubuntu/+source/cloud-init/+bug/1871975
You do not need always to have /etc/machine-id , somewhere else still there is an machine-id !
/var/lib/dbus/machine-id
https://bugs.launchpad.net/ubuntu/+source/cloud-init/+bug/1563951
Hope, all are meaningful !
Posted on 09/12/2022, in Guest OS Customization and tagged Cloud-init, Guest OS Customization, subiquity, Ubuntu 22.04 Cloud-init, Ubuntu 22.04 VMware Customization. Bookmark the permalink. Leave a comment.
Leave a comment
Comments 0