From c19c11c53c27ac57896360daeab49f2e06d7f5d1 Mon Sep 17 00:00:00 2001 From: Jonathan Rosser Date: Thu, 17 Aug 2023 13:02:00 +0100 Subject: [PATCH] Allow bind mount of types other than directory It is possible to bind mount files as well as directories. Allow this to happen in the LXC container config. Change-Id: I8b9acd2cdd8cd6e7e77f2286a2c48ed4facdcfd9 --- playbooks/common-tasks/os-lxc-container-setup.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/playbooks/common-tasks/os-lxc-container-setup.yml b/playbooks/common-tasks/os-lxc-container-setup.yml index 008d88fe06..aa698e3543 100644 --- a/playbooks/common-tasks/os-lxc-container-setup.yml +++ b/playbooks/common-tasks/os-lxc-container-setup.yml @@ -42,6 +42,8 @@ with_items: - "{{ lxc_default_bind_mounts | default([]) }}" - "{{ list_of_bind_mounts | default([]) }}" + when: + - item.create | default('dir') == 'dir' delegate_to: "{{ physical_host }}" tags: - common-lxc @@ -49,7 +51,7 @@ - name: Add bind mount configuration to container lineinfile: dest: "/var/lib/lxc/{{ inventory_hostname }}/config" - line: "lxc.mount.entry = {{ item['mount_path'] }} {{ item['bind_dir_path'].lstrip('/') }} none bind,create=dir 0 0" + line: "lxc.mount.entry = {{ item['mount_path'] }} {{ item['bind_dir_path'].lstrip('/') }} none bind,create={{ item.create | default('dir') }} 0 0" insertbefore: "^lxc.mount.entry = .*\\s{{ item['bind_dir_path'].lstrip('/') | regex_replace('/', '\/') }}.*" backup: "true" with_items: