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
This commit is contained in:
Jonathan Rosser 2023-08-17 13:02:00 +01:00
parent e3d3716b4e
commit c19c11c53c
1 changed files with 3 additions and 1 deletions

View File

@ -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: