Lxd init with preseed - help needed to get it right

I’m trying to use a preseed to use with the lxd juju charm:

The file format is documented here: Non-interactive configuration via preseed YAML - LXD documentation

Like this:

juju deploy ch:lxd --num-units 1 --config snap-channel="5.0/stable" --config lxd-listen-https=true --config lxd-listen-metrics=true --config lxd-preseed="$(cat preseed.yaml)"

However, I would like to test the preseed first. So I have prepared my server:

  • I have created the br0 bridge in the host.
  • I have created the zpool default

This is my preseed.yaml:

config:
networks:
- name: br0
  type: bridge
  config:
    ipv4.address: auto
    ipv6.address: none
storage_pools:
- name: default
  driver: zfs
  config:
    source: default

When I run:

lxd init --preseed < /home/ubuntu/preseed.yaml 
Error: Failed to update local member network "br0" in project "default": Network not found

What am I doing wrong?

I need to craft a preseed to work with the juju charm…

@sdeziel

I’ve expanded the config to test if I was needing more, but no luck with this either. Same error as above.

config:
    core.trust_password: 1234
networks:
- name: br0
  type: bridge
  config:
    ipv4.address: none
    ipv6.address: none

storage_pools:
- name: default
  driver: zfs
  config:
    zfs.pool_name: default
    source: default
    volatile.initial_source: default

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

projects:
- config:
    features.images: "true"
    features.networks: "true"
    features.profiles: "true"
    features.storage.volumes: "true"
  description: Default LXD project
  name: default

If you are creating the br0 network in the host, LXD shouldn’t manage it directly. You could still make use of it by referencing it in your default profile for example.

This seemed to work, but my container doesn’t get a network from this:

$ lxc launch ubuntu:20.04 first
Creating first
                                          
The instance you are starting doesn't have any network attached to it.
  To create a new network, use: lxc network create
  To attach a network to an instance, use: lxc network attach

Starting first
$ lxc list      
+-------+---------+------+------+-----------+-----------+
| NAME  |  STATE  | IPV4 | IPV6 |   TYPE    | SNAPSHOTS |
+-------+---------+------+------+-----------+-----------+
| first | RUNNING |      |      | CONTAINER | 0         |
+-------+---------+------+------+-----------+-----------+

The network seems to be there.

$ lxc network list
+---------+----------+---------+------+------+-------------+---------+-------+
|  NAME   |   TYPE   | MANAGED | IPV4 | IPV6 | DESCRIPTION | USED BY | STATE |
+---------+----------+---------+------+------+-------------+---------+-------+
| br0     | bridge   | NO      |      |      |             | 0       |       |
+---------+----------+---------+------+------+-------------+---------+-------+
| eno1np0 | physical | NO      |      |      |             | 0       |       |
+---------+----------+---------+------+------+-------------+---------+-------+
| eno2np1 | physical | NO      |      |      |             | 0       |       |
+---------+----------+---------+------+------+-------------+---------+-------+

This is my current preseed.yaml

config:
    core.trust_password: 1234

storage_pools:
- name: default
  driver: zfs
  config:
    zfs.pool_name: default
    source: default
    volatile.initial_source: default

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

projects:
- config:
    features.images: "true"
    features.networks: "true"
    features.profiles: "true"
    features.storage.volumes: "true"
  description: Default LXD project
  name: default

Do I have to do something to reload the config or something after I run:

lxd init --preseed myconf.yaml

Is it safe to run it over and over for my testing or does lxd need something to reset the config after I run this multiple times for testing my config?

This is strange.

I tried adding the network manually via “lxd config edit default”, tested that it worked then did a “lxd init --dump > my-working-preseed.yaml”.

I then re-ran with the old preseed: “lxd init --preseed my-old-preseed.yaml” and then it also worked.

Now I’m unable to reproduce the error above.

Is this some bug?

How can I reset my lxd entirely to see if I can reproduce from a clean slate? I’m using snap.

If you don’t mind losing your instances and all config:

sudo snap remove --purge lxd
sudo snap install lxd

If you can reproduce the issue then I would like to see the output of:

  • ip a and ip r on the host and inside the instance using the profile.
  • lxc config show <instance> --expanded

I don’t mind at all losing the config as I’m testing now.

Also, I have to empty the ZFS pool used in my preseed with something like this or the preseed will complain that the pool is not empty:

zfs destroy default/*

This is useful to know for anyone trying to reset to test automation etc. OR is there a way to reuse an already existing ZFS pool? That would be good to know also.

1 Like

Yes good point. There isn’t a reuse_existing setting for ZFS pools.

1 Like