diff --git a/defaults/main.yml b/defaults/main.yml index f82aba0d..b9510828 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -535,12 +535,16 @@ nova_compute_powervm_pip_packages: lxd_bind_address: 0.0.0.0 lxd_bind_port: 8443 + +# Supported backends are 'zfs', 'dir' and 'btrfs' for now. +# To use btrfs, a btrfs filesystem must be mounted in /var/lib/lxd +# during compute node configuration. lxd_storage_backend: dir # This needs to be set in the user_secrets.yml file. #lxd_trust_password: # This variable should be used with lxd when using a -# storage backend that utilizes storage pools +# storage backend that utilizes storage pools (zfs) #lxd_storage_pool: # This variable should be used with lxd when using a # storage backend that utilizes storage pool if you diff --git a/templates/lxd-init.sh.j2 b/templates/lxd-init.sh.j2 index b2c70328..0f9f835a 100644 --- a/templates/lxd-init.sh.j2 +++ b/templates/lxd-init.sh.j2 @@ -1,6 +1,8 @@ #!/bin/bash # {{ ansible_managed }} +{% if (lxd_storage_backend == "zfs" or lxd_storage_backend == "dir") %} + # This is a script to configure lxd system settings. # "/usr/bin/lxd init" @@ -16,3 +18,14 @@ --storage-create-device={{ lxd_storage_create_device }} \ {% endif %} --trust-password={{ lxd_trust_password }} + +{% elif (lxd_storage_backend == "btrfs") %} + +# Check if filesystem if mounted as btrfs. +# If not nothing happens and storage will still be set to dir by default + +if [ $(findmnt /var/lib/lxd -o FSTYPE -n) == "btrfs" ]; then + systemctl restart lxd +fi + +{% endif %} \ No newline at end of file