Using lxd profile to change my containers configuration dynamically

Hello y’all,

I’m a bit lazy :sleepy: and I’d prefer to use the user.vendor-data cloud-config rather than, say, ansible to manage aspects of my containers such as packages or network configuration.

It seems that the #cloud-config sections of the profiles are not “reapplied” to a container when it is updated in the profile after the container creation.

Nevertheless, this looks like a perfect solution to add a package to all containers already running.

Can you confirm that the user.vendor-data cloud-config is only applied at launch?
If so, would Ansible be one correct solution or are there any lxd built-in solutions to address this kind of questions?

Thanks a lot.

P.S.: lxd rocks so much! :heart:

Right, cloud-init is by design meant only for init, so it’s only run on initial boot of the container and if the container changes name. There are tricks you could do to force it to re-run (set volatile.apply_template to create and clear /var/lib/cloud in the container should do it) but cloud-init may also get confused if things you’re telling it to do have already been done.

Ansible will indeed work fine. For simple tasks, scripting around lxc exec may also be sufficient.

1 Like

Merci Stéphane :slight_smile:
I will do my best to configure cloud-init at best before going in production and I’ll use Ansible for the rest…

Have a nice day.