I've been reading through the LXD documentation and blogs and stackexchange answers that say LXD is supposed to have some kind of init syntax that allows you to pass cloud-config data to your containers as they're created, but none of the many examples have worked for me. I've tried following examples that set up a profile, examples that pass data in using --config
, examples that pass yaml data directly in, and examples that set the data after init but before starting. Nothing has worked. I'm pasting in what I currently have... Could someone please tell me what I'm doing wrong and how to fix it?
The most basic example I can think of:
lxc delete -f x
cat << EOF >config.yml
#cloud-config
output: {all: '| tee -a /var/log/my-cloud-init-output.log'}
package_update: true
package_upgrade: true
package_reboot_if_required: true
packages:
- tree
runcmd:
- touch /run/cloud-config-did-run
EOF
lxc launch ubuntu: x --config=user.user-data="$(cat config.yml)"
sleep 5
lxc exec x -- bash -c "ls /run"
lxc exec x -- bash -c "tree /etc"
This should output to /var/log/my-cloud-init-output.log
, install tree and also make an empty file in /run. The output to /var/log/my-cloud-init-output.log
works, but nothing else does. The logs don't show anything special.