Skip to content

How To Setup Cloud-init on Proxmox

26/03/2023

:   Alexander

Information

Cloud-init is a powerful software tool that helps you automate the process of initializing cloud instances. It is used in various cloud computing platforms such as Amazon Web Services, Microsoft Azure, and Google Cloud Platform. If you are using Proxmox as your virtualization platform, you can also take advantage of cloud-init to automate the setup of your cloud instances. In this article, we will guide you on how to set up cloud-init on Proxmox.

Before we get started with the setup process, it is important to understand what cloud-init does. Cloud-init allows you to customize your cloud instances during the boot-up process. You can use cloud-init to perform various tasks such as:

  • Installing packages
  • Configuring network settings
  • Setting up SSH keys
  • Running scripts
  • And much more

Now, let's get started with the setup process. The following instructions assume that you already have a Proxmox cluster up and running.

Step 1: Install Cloud-init

Install cloud-init package First, you need to install the cloud-init package on your Proxmox host. To do this, SSH into your Proxmox host and run the following command:

apt-get install cloud-init

Step 2: Configure Cloud-init

Configure cloud-init Next, you need to configure cloud-init to your liking. The configuration file for cloud-init can be found in the following path:

/etc/cloud/cloud.cfg
Open the file using your preferred text editor. The file contains various configuration options that you can customize. Some of the important sections that you may want to modify include:

datasource_list: This section specifies the data source for cloud-init. By default, it is set to use the cloud-init metadata service. If you are using Proxmox as your hypervisor, you can leave this section as is.

password: Here, you can specify the password for the root user. It is highly recommended that you set a strong password if you decide to enable password authentication.

ssh_pwauth: This option controls whether SSH password authentication is allowed. If you set this to "false", you will need to use SSH keys for authentication.

users: This section allows you to create additional user accounts for your cloud instances. You can specify the username, password (or SSH key), and user ID.
Full Example Config

https://cloudinit.readthedocs.io/en/latest/reference/examples.html

Once you have made your changes, save the file.

Step 3: Create Cloud-init Template

Create a cloud-init template Next, you need to create a cloud-init template that Proxmox can use to create your cloud instances. To do this, log in to the Proxmox web interface and navigate to the "Templates" section. Click on "Create CT" to create a new template.

In the "General" tab, give your template a name and select the operating system that you want to use. In the "OS" tab, select the "Cloud-init" option under "Template." This will enable cloud-init for your instance.

In the "Cloud-init" tab, you can specify the cloud-init configuration file that you created earlier. You can also add additional files that you want to include in your cloud instance.

Once you have finished configuring your template, click on "Create" to create your cloud-init template.

Step 4: Create a VM / CT

Create a VM using the cloud-init template Finally, you can create a new VM using the cloud-init template that you just created. Navigate to the "Create CT" section and select the "Cloud-init template" that you just created.

In the "General" tab, give your VM a name and select the storage and network interfaces that you want to use. In the "OS" tab, select the operating system that you want to use.

In the "Cloud-init" tab, you can specify additional cloud-init data that you want to include for this specific VM. This can be useful if you want to customize individual VMs differently from the cloud-init template.

Once you have finished configuring your VM, click on "Create" to create your VM.

Conclusion

Congratulations, you have successfully set up cloud-init on Proxmox! You can now use cloud-init to automate the setup of your cloud instances.