Ubuntu 20.04 - cloud-init Gotchas

1 minute read

Recently while working on my latest Packer Templates I ran into an issue with Ubuntu 20.04. The issue was related to cloud-init not being able to grow the root partition nor change the hostname. I was testing this on Proxmox using Terraform.

NOTE: terraform-provider-proxmox

Obviously these are two very important capabilities when provisioning cloud instances. So, why was this not working? Well I started Googling and of course nothing was coming up that would give me a clue. So, I started digging into logs, etc. And sure enough, I found in the log that these two capabilities were not working because of the file /etc/cloud/cloud.cfg.d/99-installer.cfg.

An example of the contents of /etc/cloud/cloud.cfg.d/99-installer.cfg:

    metadata: {instance-id: 872e2bc0-9805-4623-bdda-5e8bcca540dc}
    userdata_raw: "#cloud-config\ngrowpart: {mode: 'off'}\nlocale: en_US.UTF-8\npreserve_hostname:\
      \ true\nresize_rootfs: false\nusers:\n- gecos: packer\n  groups: [adm, cdrom,\
      \ dip, plugdev, lxd, sudo]\n  lock_passwd: false\n  name: packer\n  passwd:\
      \ $6$AA.Jw829.bXpJ4w$bf2mI99OoUo2F4/rSfnAD9vNg2vjOiJaynMSeOgZcE3PB/OMCRgYuon74mIyzgUiXBEA8/VluqEQuZBGcQq5B.\n\
      \  shell: /bin/bash\n"
datasource_list: [None]

From the above example you can see that growpart: {mode: 'off} and preserve_hostname: true are set. This right here was the cause of my issues. So, to resolve this issue. Simply delete the file and you are good to go!

Just sharing this with folks in case you ever run into this as well.



Leave a comment