From f383b018ceb6db1ede94c0479ea6fcb9629eceac Mon Sep 17 00:00:00 2001 From: Kienan Stewart Date: Thu, 8 Aug 2024 13:01:55 -0400 Subject: [PATCH] ansible: Set images and backups storage volumes on hosts By placing images and backups in the default (zfs) storage, the root partition won't get filled with that. Change-Id: I617cc6d1b82d28e65f8a848567e634f4a5a2516f Signed-off-by: Kienan Stewart --- automation/ansible/roles/lxd/tasks/main.yml | 25 +++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/automation/ansible/roles/lxd/tasks/main.yml b/automation/ansible/roles/lxd/tasks/main.yml index d4a5ff4..0a3c58b 100644 --- a/automation/ansible/roles/lxd/tasks/main.yml +++ b/automation/ansible/roles/lxd/tasks/main.yml @@ -45,3 +45,28 @@ - ansible.builtin.shell: cmd: 'lxd init --preseed=true < /etc/lxd/lxd_init.yml' when: lxd_init_template.changed +- name: Check for images volume configuration + ansible.builtin.command: + argv: ['lxc', 'config', "--target={{lxd_cluster['server_name']|default(ansible_hostname)}}", 'get', 'storage.images_volume'] + register: images_volume_conf +- name: Configure images volume + when: images_volume_conf.stdout|trim != "default/storage-images" + block: + - name: Create volume + ansible.builtin.command: + argv: ['lxc', 'storage', 'volume', 'create', '--target', "{{lxd_cluster['server_name']|default(ansible_hostname)}}", 'default', 'storage-images'] + - ansible.builtin.command: + argv: ['lxc', 'config', 'set', '--target', "{{lxd_cluster['server_name']|default(ansible_hostname)}}", 'storage.images_volume', 'default/storage-images'] + +- name: Check for backups volume configuration + ansible.builtin.command: + argv: ['lxc', 'config', "--target={{lxd_cluster['server_name']|default(ansible_hostname)}}", 'get', 'storage.backups_volume'] + register: backups_volume_conf +- name: Configure backups volume + when: backups_volume_conf.stdout|trim != "default/storage-backups" + block: + - name: Create volume + ansible.builtin.command: + argv: ['lxc', 'storage', 'volume', 'create', '--target', "{{lxd_cluster['server_name']|default(ansible_hostname)}}", 'default', 'storage-backups'] + - ansible.builtin.command: + argv: ['lxc', 'config', 'set', '--target', "{{lxd_cluster['server_name']|default(ansible_hostname)}}", 'storage.backups_volume', 'default/storage-backups'] -- 2.34.1