bento
bento copied to clipboard
cloud init not working
Version
v5.0.0 (2025-10-27)
Environment
VirtualBox: 7.2.4 r170995 Host OS: Arch Linux
Scenario
Start a Vagrant VM with the official bento/ubuntu-24.04 box and create an additional user (user1) via cloud-init.
Steps to Reproduce
Vagrantfile
Vagrant.configure("2") do |config|
config.vm.box = "bento/ubuntu-24.04"
config.vm.provider "virtualbox" do |v|
v.name = "node1"
v.memory = 1024
v.cpus = 2
end
config.vm.cloud_init :user_data do |cloud_init|
cloud_init.content_type = "text/cloud-config"
cloud_init.path = "cloud.cfg"
end
end
cloud.cfg
#cloud-config
users:
- name: user1
sudo: "ALL=(ALL) NOPASSWD:ALL"
plain_text_passwd: 123456
lock_passwd: false
- Create the Vagrantfile and cloud.cfg as shown above.
- run
vagrant up - After the VM is up, run
vagrant ssh - Run cat /etc/passwd | grep user1 or id user1, check if user1 is exists.
Expected Result
cloud-init processes the provided cloud.cfg file during first boot and creates the user user1.
Actual Result
No user user1 is created.
Did this work previously?
I'm not sure if this worked in previous versions. This was my initial attempt to use it.
cloud-init is disabled by default (cat /etc/cloud/cloud-init.disabled), so you need to enable it and then reboot.
Vagrant.configure("2") do |config|
config.vm.cloud_init :user_data do |cloud_init|
cloud_init.content_type = "text/cloud-config"
cloud_init.inline = <<-EOF
#cloud-config
users:
- name: issue1655
shell: /bin/bash
EOF
end
hosts = [
{ name: "noble", box: "bento/ubuntu-24.04" },
]
hosts.each do |host|
config.vm.define host[:name] do |node|
node.vm.box = host[:box]
node.ssh.insert_key = true
node.ssh.key_type = "ed25519"
node.vm.hostname = host[:name]
node.vm.boot_timeout = 600
node.vm.provision "shell",
inline: <<-SHELL
cloud-init clean --machine-id
SHELL
end
end
end