Ensure that the default bind mounts are complete
This patch implements the use of the facility introduced in https://review.openstack.org/348242 to ensure that the default bind mounts are properly set up. Change-Id: I76af6ea46cd96e4c1e50d7f49711c73267b723fc
This commit is contained in:
parent
4d154ae1ad
commit
ec1a9c7ce4
|
@ -29,7 +29,6 @@ lxc_container_default_config_list:
|
||||||
- "lxc.pts=1024"
|
- "lxc.pts=1024"
|
||||||
- "lxc.kmsg=0"
|
- "lxc.kmsg=0"
|
||||||
- "lxc.hook.autodev=/var/lib/lxc/{{ inventory_hostname }}/autodev"
|
- "lxc.hook.autodev=/var/lib/lxc/{{ inventory_hostname }}/autodev"
|
||||||
- "lxc.mount.entry=/openstack/backup/{{ inventory_hostname }} var/backup none defaults,bind,rw 0 0"
|
|
||||||
lxc_container_config_list: []
|
lxc_container_config_list: []
|
||||||
lxc_container_commands: ""
|
lxc_container_commands: ""
|
||||||
|
|
||||||
|
@ -39,6 +38,10 @@ lxc_container_commands: ""
|
||||||
# container_directory: "/opt/mydirectory"
|
# container_directory: "/opt/mydirectory"
|
||||||
lxc_container_bind_mounts: []
|
lxc_container_bind_mounts: []
|
||||||
|
|
||||||
|
lxc_container_default_bind_mounts:
|
||||||
|
- host_directory: "/openstack/backup/{{ inventory_hostname }}"
|
||||||
|
container_directory: "/var/backup"
|
||||||
|
|
||||||
# Mappings from Ansible reported architecture to distro release architecture
|
# Mappings from Ansible reported architecture to distro release architecture
|
||||||
lxc_architecture_mapping:
|
lxc_architecture_mapping:
|
||||||
x86_64: amd64
|
x86_64: amd64
|
||||||
|
|
|
@ -129,7 +129,7 @@
|
||||||
file:
|
file:
|
||||||
path: "{{ item['host_directory'] }}"
|
path: "{{ item['host_directory'] }}"
|
||||||
state: "directory"
|
state: "directory"
|
||||||
with_items: "{{ lxc_container_bind_mounts }}"
|
with_items: "{{ lxc_container_default_bind_mounts | union(lxc_container_bind_mounts) }}"
|
||||||
delegate_to: "{{ physical_host }}"
|
delegate_to: "{{ physical_host }}"
|
||||||
|
|
||||||
- name: Ensure container directories exist
|
- name: Ensure container directories exist
|
||||||
|
@ -137,7 +137,7 @@
|
||||||
name: "{{ inventory_hostname }}"
|
name: "{{ inventory_hostname }}"
|
||||||
container_command: |
|
container_command: |
|
||||||
[[ ! -d "{{ item['container_directory'] }}" ]] && mkdir -p "{{ item['container_directory'] }}"
|
[[ ! -d "{{ item['container_directory'] }}" ]] && mkdir -p "{{ item['container_directory'] }}"
|
||||||
with_items: "{{ lxc_container_bind_mounts }}"
|
with_items: "{{ lxc_container_default_bind_mounts | union(lxc_container_bind_mounts) }}"
|
||||||
delegate_to: "{{ physical_host }}"
|
delegate_to: "{{ physical_host }}"
|
||||||
|
|
||||||
- name: Add bind mount configuration to container
|
- name: Add bind mount configuration to container
|
||||||
|
@ -145,7 +145,7 @@
|
||||||
dest: "/var/lib/lxc/{{ inventory_hostname }}/config"
|
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 0 0"
|
||||||
backup: "true"
|
backup: "true"
|
||||||
with_items: "{{ lxc_container_bind_mounts }}"
|
with_items: "{{ lxc_container_default_bind_mounts | union(lxc_container_bind_mounts) }}"
|
||||||
delegate_to: "{{ physical_host }}"
|
delegate_to: "{{ physical_host }}"
|
||||||
notify:
|
notify:
|
||||||
- Lxc container restart
|
- Lxc container restart
|
||||||
|
|
|
@ -53,10 +53,8 @@
|
||||||
- name: Check for the presence of the right bound mount for container2
|
- name: Check for the presence of the right bound mount for container2
|
||||||
command: grep "lxc.mount.entry = /openstack/container2/test2 var/log/test2 none bind 0 0" /var/lib/lxc/container2/config
|
command: grep "lxc.mount.entry = /openstack/container2/test2 var/log/test2 none bind 0 0" /var/lib/lxc/container2/config
|
||||||
|
|
||||||
- name: Check for the lack of presence of any bound mount (except the backup bind mount) for container3
|
- name: Check for the presence of the default bound mount for container3
|
||||||
command: grep "lxc.mount.entry = /openstack/container" /var/lib/lxc/container3/config
|
command: grep "lxc.mount.entry = /openstack/backup/container3" /var/lib/lxc/container3/config
|
||||||
register: container1_bind_mount
|
|
||||||
failed_when: container1_bind_mount.rc == 0
|
|
||||||
|
|
||||||
- name: Check for the bind mount in container1
|
- name: Check for the bind mount in container1
|
||||||
hosts: container1
|
hosts: container1
|
||||||
|
|
Loading…
Reference in New Issue