Fix the bind mount options to match integrated repo

",create=dir" was added to the integrated repo in
I29be91b4dca5abe1bb8307429a86c06dbd3ef7aa to ensure that LXC handles
the bind mount directory creation inside the container.

Also a bug is fixed where bind mounts defined as part of the container
configuration list replace all '=' within the string as ' = '. To fix
this only the first = is padded with whitespace.

Change-Id: Ieed33a413ed9abec98e46cd519c18a95d5b6bd75
This commit is contained in:
Logan V 2017-04-14 08:24:03 -05:00
parent c39125aefe
commit c82c7a60e9
3 changed files with 5 additions and 5 deletions

View File

@ -166,7 +166,7 @@
- name: Write default container config
lineinfile:
dest: "/var/lib/lxc/{{ inventory_hostname }}/config"
line: "{{ item | replace('=', ' = ') | regex_replace('\\s+', ' ') }}"
line: "{{ item | replace('=', ' = ', 1) | regex_replace('\\s+', ' ') }}"
backup: "true"
with_items: "{{ lxc_container_default_config_list | union(lxc_container_config_list) }}"
delegate_to: "{{ physical_host }}"
@ -186,7 +186,7 @@
- name: Add bind mount configuration to container
lineinfile:
dest: "/var/lib/lxc/{{ inventory_hostname }}/config"
line: "lxc.mount.entry = {{ item['host_directory'] }} {{ item['container_directory'].lstrip('/') }} none bind 0 0"
line: "lxc.mount.entry = {{ item['host_directory'] }} {{ item['container_directory'].lstrip('/') }} none bind,create=dir 0 0"
backup: "true"
with_items: "{{ lxc_container_default_bind_mounts | union(lxc_container_bind_mounts) }}"
delegate_to: "{{ physical_host }}"

View File

@ -4,7 +4,7 @@ ansible_become: True
ansible_user: root
lxc_container_config_list:
- "lxc.aa_profile=lxc-openstack"
- "lxc.mount.entry=/openstack/{{ inventory_hostname }} opt/test1 none bind 0 0"
- "lxc.mount.entry=/openstack/{{ inventory_hostname }} opt/test1 none bind,create=dir 0 0"
lxc_container_commands: |
if [[ ! -d "/opt/test1" ]]; then

View File

@ -50,10 +50,10 @@
failed_when: container3_profile.rc == 0
- name: Check for the presence of the right bound mount for container1
command: grep "lxc.mount.entry = /openstack/container1 opt/test1 none bind 0 0" /var/lib/lxc/container1/config
command: grep "lxc.mount.entry = /openstack/container1 opt/test1 none bind,create=dir 0 0" /var/lib/lxc/container1/config
- name: Check for the presence of the right bound mount for container2
command: grep "lxc.mount.entry = {{ development_repo_directory }} {{ development_repo_directory | relpath('/') }} none bind 0 0" /var/lib/lxc/container2/config
command: grep "lxc.mount.entry = {{ development_repo_directory }} {{ development_repo_directory | relpath('/') }} none bind,create=dir 0 0" /var/lib/lxc/container2/config
- name: Check for the presence of the default bound mount for container3
command: grep "lxc.mount.entry = /openstack/backup/container3" /var/lib/lxc/container3/config