When configuring multiple LXD hosts, either to work alongside a remote or as isolated environments, it saves time to bypass the prompt and instead use a preseed file for LXD configuration. In this lab, we generate our preseed file, then create two identical dev environments using our newly-created file.
Learning Objectives
Successfully complete this lab by achieving the following learning objectives:
- Generate the Preseed File
Configure LXD on the first host:
lxd init
Would you like to use LXD clustering? (yes/no) [default=no]: Do you want to configure a new storage pool? (yes/no) [default=yes]: Name of the new storage pool [default=default]: Name of the storage backend to use (btrfs, ceph, dir, lvm, zfs) [default=zfs]: Create a new ZFS pool? (yes/no) [default=yes]: Would you like to use an existing block device? (yes/no) [default=no]: yes Path to the existing block device: /dev/nvme1n1 Would you like to connect to a MAAS server? (yes/no) [default=no]: Would you like to create a new local network bridge? (yes/no) [default=yes]: What should the new bridge be called? [default=lxdbr0]: What IPv4 address should be used? (CIDR subnet notation, “auto” or “none”) [default=auto]: What IPv6 address should be used? (CIDR subnet notation, “auto” or “none”) [default=auto]: Would you like LXD to be available over the network? (yes/no) [default=no]: yes Address to bind LXD to (not including port) [default=all]: Port to bind LXD to [default=8443]: Trust password for new clients: Again: Would you like stale cached images to be updated automatically? (yes/no) [default=yes] Would you like a YAML "lxd init" preseed to be printed? (yes/no) [default=no]: yes
- Copy the provided preseed output and save it to a file in the home directory called
preseed.yaml
:
vim preseed.yaml config: core.https_address: '[::]:8443' core.trust_password: pinehead networks: - config: ipv4.address: auto ipv6.address: auto description: "" managed: false name: lxdbr0 type: "" storage_pools: - config: source: /dev/nvme1n1 description: "" name: default driver: zfs profiles: - config: {} description: "" devices: eth0: name: eth0 nictype: bridged parent: lxdbr0 type: nic root: path: / pool: default type: disk name: default cluster: null
- Configure the Second Server
Copy over the preseed file:
scp cloud_user@10.0.1.100:/home/cloud_user/preseed.yaml preseed.yaml
Configure LXD:
cat preseed.yaml | lxd init --preseed
- Configure the Third Server
Repeat the steps from the second server, or try with a single command:
scp cloud_user@10.0.1.100:/home/cloud_user/preseed.yaml preseed.yaml | cat preseed.yaml | lxd init --preseed