✓ Solved

cloud-init/config not working when creating new node

I have tried a couple of times but it seems the cloud-config stuff isn't working. I've tried to just update/upgrade packages to doing a little more. Although none of them seem to be working. I read through the linode pages about using cloud-config and I must have missed something. I pulled all of these from the examples at https://cloudinit.readthedocs.io/en/latest/index.html

Comments?
*edit: I'm using the Cloud Manager UI and adding the below to the 'User Data' section.

#cloud-config
ssh_pwauth: false
users:
- name: ansible
  gecos: Ansible User
  groups: users,admin,wheel
  sudo: ALL=(ALL) NOPASSWD:ALL
  shell: /bin/bash
  lock_passwd: true
  ssh_authorized_keys:
    - "ssh-ed25519 [---]"
hostname: my-cool-node
create_hostname_file: true
prefer_fqdn_over_hostname: false
preserve_hostname: true
package_update: true
package_upgrade: true

3 Replies

✓ Best Answer

Are you receiving any specific errors when this fails, or is the instance just being created without the specified parameters?

If it is the latter, have you run through the first steps listed here?
https://cloudinit.readthedocs.io/en/latest/tutorial/qemu.html#verify-that-cloud-init-ran-successfully

Regardless, just in case you did not see the below resources, I wanted to share them because they give a pretty detailed rundown as to how to utilize the Cloud-init functionality:

How to config & secure a compute instance:
https://www.linode.com/docs/guides/configure-and-secure-servers-with-cloud-init/

How to add user data:
https://www.linode.com/docs/products/compute/compute-instances/guides/create/#add-user-data

How to add metadata:
https://www.linode.com/docs/products/compute/compute-instances/guides/metadata/

Links to several other guides that relate to cloud-init:
https://www.linode.com/docs/guides/applications/configuration-management/cloud-init/

I hope that helps!

-Micah

@mtcotton846 thank you for the reply. After reading your post, I created another nano ubuntu 22.04 with the following

#cloud-config
package_update: true
package_upgrade: true
hostname: examplehost

The hostname was set and packages and been updated/upgraded. I didn't see any errors (also I wasn't seeing errors before). The default user "ubuntu" with default password "password" was not created. As per the verify that cloud init ran. Also, this time I did not connect a VPC or Firewall. So I'm going to do some more testing adding those items and trying to create a new user.

Thanks,
Jason

@mtcotton846 well it was me, I didn't pay attention to the groups key. It had the wrong groups.

Thanks,
Jason

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct