Usage of 'lxd init --preseed'?

I try to use ‘lxd init --preseed’ to initially configure lxd. I’m on a fresh Ubuntu VMand installed lxd via snap.
Now I try to do an initial configuration via --preseed, but I get an error regarding the storage pool:

"error: The "default" storage pool doesn't exist."

My command:

# cat <<EOF | lxd init --preseed
pools:
- name: default
  driver: dir
  config:
    source: ""
networks:
- name: lxdbr0
  type: bridge
  config:
    ipv4.address: auto
    ipv6.address: auto
profiles:
- name: default
  devices:
    root:
      path: /
      pool: default
      type: disk
    eth0:
      nictype: bridged
      parent: lxdbr0
      type: nic
EOF

Sorry for the noise. I found the problem within the config. pools is named storage_pools.

@MikeBergmann even i’m facing the similar issue,could you pls share complete working preceed file …

i’ve tried below which you posted above…dint get that working…sorry but am new to this, your help will be appreciated.

should i have to created storage pool manually?

cat <<EOF | lxd init --preseed

pools:

  • name: default
    driver: dir
    config:
    source: “”
    networks:
  • name: lxdbr0
    type: bridge
    config:
    ipv4.address: auto
    ipv6.address: auto
    profiles:
  • name: default
    devices:
    root:
    path: /
    pool: default
    type: disk
    eth0:
    nictype: bridged
    parent: lxdbr0
    type: nic
    EOF

@Subham_mandal

I’m still on LXD 5.9 on my build-machines, so I don’t know if it is working with 5.21.

This is my current solution:

sed -i -e 's|source: ""|source: "/mnt/build-disk/lxd"|' "./lxd-storages.yml"
for script in storages networks profiles
do
   sudo lxd init --preseed < "./lxd-${script}.yml"
done

lxd-networks.yml

networks:
- name: lxdbr0
  type: bridge
  config:
    ipv4.address: auto
    ipv6.address: auto

lxd-storages.yml

storage_pools:
- name: default
  driver: dir
  config:
    source: ""

lxd-profiles.yml

profiles:
- name: default
  devices:
    root:
      path: /
      pool: default
      type: disk
    eth0:
      nictype: bridged
      parent: lxdbr0
      type: nic