From d76d4cdc8f114c13e946d7914df1f05af8cc0de7 Mon Sep 17 00:00:00 2001 From: ArchiFleKs Date: Mon, 10 Apr 2017 12:45:51 +0200 Subject: [PATCH] Enable using btrfs as a backend Enable the usage of btrfs backend. Nothing is done except not using lxd init as it only supports zfs and dir. Change-Id: Ic6390e457b80a5d38957c182f270fc9f9d52a60f --- defaults/main.yml | 6 +++++- templates/lxd-init.sh.j2 | 13 +++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/defaults/main.yml b/defaults/main.yml index 28b3e603..6e00e65d 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -534,12 +534,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: # PCI devices passthrough to nova diff --git a/templates/lxd-init.sh.j2 b/templates/lxd-init.sh.j2 index 1fa213fb..e2e51c17 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" @@ -13,3 +15,14 @@ --storage-pool={{ lxd_storage_pool }} \ {% 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