Open psolymos opened 6 months ago
Hello,
I had the same problem and spent yesterday the whole day trying to figure out why it just wouldn't work.
In the cloud-init issue tracker on GitHub, I found something interesting from a Canonical employee. They mentioned that the return value of sh
has been extended, meaning that not only 0 is considered a success, but now also 2. You can read about it in the commit description here.
Fortunately, the return value is not fixed in Packer, and you can set your own value(s):
{
"type": "shell",
"inline": [
"cloud-init status --wait"
],
"valid_exit_codes": [0, 2]
}
With this small fix now everything works again.
I plan to update and convert the whole droplet-1-clicks repository to the new .pkr.hcl
format. The benefits of converting from JSON to PKR.HCL (HashiCorp Configuration Language) include several key advantages related to readability, maintainability, and functionality in the context of using HashiCorp Packer:
This is a game changer and i hope somone from digitalocean will accept my pull request.
Best regards Sascha
in case its not clear, https://github.com/canonical/cloud-init/commit/a061e81dab009b43d07fd08ad4d83ddb0d7d2ec4 is a workaround, but the reason the error code is 2 is due to strict validation errors somewhere with noble's cloud-init. so likely also a bug on their end. the output of cloud-init schema --system
shows which validations errors are the root cause
Yes but the published images from DO itself have the same error: root@lemponubuntu2204-s-1vcpu-1gb-amd-nyc1-01:~# cloud-init schema --system Found cloud-config data types: user-data, vendor-data, network-config
user-data at /var/lib/cloud/instances/428845611/cloud-config.txt: Empty 'cloud-config' found at /var/lib/cloud/instances/428845611/cloud-config.txt. Nothing to validate.
vendor-data at /var/lib/cloud/instances/428845611/vendor-cloud-config.txt: Invalid vendor-data /var/lib/cloud/instances/428845611/vendor-cloud-config.txt Error: Cloud config schema errors: system_info: Additional properties are not allowed ('system_info' was unexpected)
network-config at /var/lib/cloud/instances/428845611/network-config.json: Invalid network-config /var/lib/cloud/instances/428845611/network-config.json Error: Cloud config schema errors: config.0.subnets.0: Additional properties are not allowed ('ipv4' was unexpected), config.0.subnets.1: Additional properties are not allowed ('ipv4' was unexpected), config.1.subnets.0: Additional properties are not allowed ('ipv4' was unexpected)
Error: Invalid schema: vendor-data, network-config
And this happens on ubuntu 22.04 so i think this is not the problem
I'm also seeing the same thing as @ThinkBIG-Company in the release pipeline for Dokku. Link here.
Is this a bug in the generated cloud config, or a bug in cloud-init?
The first shell provisioner fails with
cloud-init status --wait
onubuntu-24-04-x64
image, but runs fine with theubuntu-22-04-x64
image.