Cloud-init triggered only from last provided profile

distro: ubuntu 20.04
lxd: 4.11
lxd profile default:

config:
user.user-data: |
#cloud-config
ssh_authorized_keys:
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDjif1o4bIYq3kKVzNnFAp1/mF4TmOcfGy2OkYxW3c3FveOvq/ink32rm4uStV5t5MAWv4JUZSPLWo3EsL9d2MLVmgO2wTVytWoIQGUPWX6YUo+Tv6k3azxMgkMjLn9A1+VX9s9SnIYDfaTc8wtFgg9TQb804+GzNfXNaxIWGBuOrZwk22VvWgDCL68Pr3zuUOGIhquJLtkLYPy+9HzOY/1+G0YcXgN+w+dYoCJ8/XmCiIUkspGNc1Smk+p8FHbrbPxF4RECL/azkZgSMC9iX7TA+BuW/vffkeHbNG5eV9C4/V0pzF0LryzukLoclb0wOx/Gh0fAMUwYWAUitAo2cBL/WRcoF6x/rh0ck+l05+ANQVAsPs4/z8iCRveFlX42VWGb6A4EqHNnRFsRzm+x/cIRSZMf3jeuyZDxM85KObVMZiJ7/IsvqUBIk56n/0CrQqn7xT/qnLoNwKuFNbTVxjc12utGkDZHOCZr6tQVubtQlJ0SxiA6KmuUJduII2pjMCRyAohf1Bj0A4LRhHNH/j+w5GNZF0oanuCsulqyXCdGhpnIQssjtnd4LF8LCVcBFraZd8aOoRc5rZLjxoIlPfguv3rU3/oBdrO03fDcZB+K9dcsEDg9oWR73BedhsfTISB5nzuI+GkY5ZCdKo77iEbmWxTL3r3H/8tn4soxfWjiw== mihail
package_update: true
package_upgrade: true
package_reboot_if_required: true
disable_root: false
packages:
- wget
- openssh-server
description: Default LXD profile
devices:
eth0:
name: eth0
network: lxdbr0
type: nic
root:
path: /
pool: default
size: 30GB
type: disk
name: default

lxd profile pa:

config:
raw.idmap: both 1000 1000
user.user-data: |
#cloud-config
runcmd:
- ‘sed -i “s/; enable-shm = yes/enable-shm = no/g” /etc/pulse/client.conf’
- ‘echo export PULSE_SERVER=unix:/tmp/.pulse-native | tee --append /home/ubuntu/.profile’
packages:
- pulseaudio
description: pulseaudio LXD profile
devices:
PASocket:
path: /tmp/.pulse-native
source: /run/user/1000/pulse/native
type: disk
name: pa

So if I run:

lxc launch ubuntu:f test1 -p default -p pa

it’s run cloud-init from profile pa, if run:

lxc launch ubuntu:f test1 -p pa -p default

runs cloud-init only from profile default

Yes, LXD config keys override each other, whichever profile sets a key last wins, unless the instance has that key set directly, in which case it wins.

Cloud-init supports some basic merging through having both user.user-data and user.vendor-data, so you can have a generic profile set the vendor-data one and then have more specific profiles set the user-data one, if you need more than two, then you’re out of options :slight_smile:

Thank you. :slight_smile: