Cloud-init is a tool used for cloud instance initialization, commonly employed in cloud computing environments like Amazon Web Services (AWS), Google Cloud, OpenStack, and others. It allows cloud users to automate various tasks such as instance configuration, package installation, and user setup when the instance boots up for the first time.
Cloud-init uses metadata from the cloud provider to initialize and configure an instance. The metadata usually includes details like the hostname, user data (scripts, configs), and networking info. Cloud-init runs at various stages of the boot process, performing tasks such as:
#cloud-config
users:
- default
- name: myuser
sudo: ALL=(ALL) NOPASSWD:ALL
groups: sudo
ssh-authorized-keys:
- ssh-rsa AAAA...your-public-key...
package_update: true
packages:
- nginx
- python3
runcmd:
- [ systemctl, start, nginx ]
This script adds a user, installs some packages, and ensures Nginx is started upon boot.
Uninstall the cloud-init package and remove the configuration files:
Debian/Ubuntu:
apt-get purge -y cloud-init
CentOS/RedHat:
yum remove -y cloud-init
Delete the files we do not need any more:
rm -fR /etc/cloud/
rm -fR /var/lib/cloud/