Allow a deployer to disable container restarts

This changes allows a deployer to disable a container restart
by setting the option ``lxc_container_allow_restarts`` to ``false``.

Forward port based on:
 - https://review.openstack.org/344834
 - https://review.openstack.org/346064

Change-Id: I2c681d7e0681f8586286dc9f371d7b5e231bda68
Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
This commit is contained in:
Kevin Carter 2016-07-22 08:54:53 -05:00 committed by Jesse Pretorius
parent e2be10bc9f
commit f7fb95fbe1
4 changed files with 30 additions and 16 deletions

View File

@ -18,16 +18,15 @@ debug: False
lxc_container_config: /etc/lxc/lxc-openstack.conf
lxc_container_default_config_list:
- "lxc.start.auto=1"
- "lxc.start.delay=15"
- "lxc.group=onboot"
- "lxc.group=openstack"
- "lxc.autodev=1"
- "lxc.pts=1024"
- "lxc.kmsg=0"
- "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_overlayfs_config_list:
- "lxc.start.auto=1"
- "lxc.start.delay=15"
- "lxc.group=onboot"
- "lxc.group=openstack"
lxc_container_config_list: []
# Mappings from Ansible reported architecture to distro release architecture
@ -83,3 +82,6 @@ lxc_container_download_template_options: >
--force-cache
--server {{ lxc_image_cache_server }}
--variant={{ lxc_container_variant }}
# Toggle the restart of containers via the handler.
lxc_container_allow_restarts: yes

View File

@ -20,6 +20,7 @@
notify:
- Start Container
delegate_to: "{{ physical_host }}"
when: lxc_container_allow_restarts | bool
- name: Start Container
lxc_container:

View File

@ -0,0 +1,8 @@
---
features:
- A new variable has been added to allow a deployer to control
the restart of containers via the handler. This new option is
``lxc_container_allow_restarts`` and has a default of ``yes``.
If a deployer wishes to disable the auto-restart functionality
they can set this value to ``no`` and automatic container
restarts that are not absolutely required will be disabled.

View File

@ -68,8 +68,6 @@
fs_type: "{{ lxc_container_fs_type }}"
vg_name: "{{ lxc_container_vg_name }}"
template_options: "{{ lxc_container_download_template_options }}"
container_command: "{{ lxc_container_map.prep_commands }}"
container_config: "{{ lxc_container_default_config_list | union(lxc_container_config_list) }}"
delegate_to: "{{ physical_host }}"
when:
- lxc_container_backing_store != "overlayfs"
@ -105,20 +103,25 @@
tags:
- lxc-container-create
# Note that the first four container_config flags are normally applied through
# the lxc_container module's 'config' option, but the module doesn't support
# applying that option after the container has been created. This is a workaround
# until either that is fixed, or a better alternative is identified.
# TODO(odyssey4me): revisit this for better options some time
- name: Execute container commands and add container config (overlayfs)
- name: Write default container config
lineinfile:
dest: "/var/lib/lxc/{{ inventory_hostname }}/config"
line: "{{ item | replace('=', ' = ') | regex_replace('\\s+', ' ') }}"
backup: "true"
with_items: "{{ lxc_container_default_config_list | union(lxc_container_config_list) }}"
delegate_to: "{{ physical_host }}"
notify:
- Lxc container restart
tags:
- lxc-container-config
- name: Execute container commands
lxc_container:
name: "{{ inventory_hostname }}"
container_command: "{{ lxc_container_map.prep_commands }}"
container_config: "{{ lxc_container_default_config_list | union(lxc_container_overlayfs_config_list) | union(lxc_container_config_list) }}"
delegate_to: "{{ physical_host }}"
when: lxc_container_backing_store == "overlayfs"
tags:
- lxc-container-config
- lxc-container-commands
- name: Container network interfaces
lxc_container: