Add option to recreate containers
The `lxc_container_recreate` variable will allow for recreating already deployed containers using either a playbook or a command line argument. This option is most useful during an upgrade, where the containers are thrown away and completely rebuilt from scratch. Change-Id: I3ba35daf49111a3fdfb2e30cffddd9af23aafb28
This commit is contained in:
parent
d2b82b4cee
commit
c744a4bfaf
@ -126,3 +126,6 @@ lxc_container_network_veth_pair: "{{ lxc_container_network_veth_pair_prefix }}_{
|
|||||||
|
|
||||||
# Enable fixed mac address generation for an lxc container
|
# Enable fixed mac address generation for an lxc container
|
||||||
lxc_container_fixed_mac: false
|
lxc_container_fixed_mac: false
|
||||||
|
|
||||||
|
# Enable destroying then recreating containers
|
||||||
|
lxc_container_recreate: false
|
||||||
|
6
releasenotes/notes/recreate-option-d78bae1fd922a84d.yaml
Normal file
6
releasenotes/notes/recreate-option-d78bae1fd922a84d.yaml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- Added the ``lxc_container_recreate`` option, which will destroy then
|
||||||
|
recreate LXC containers. The container names and IP addresses will remain
|
||||||
|
the same, as will the MAC addresses of any containers using the
|
||||||
|
``lxc_container_fixed_mac`` setting.
|
26
tasks/container_destroy.yml
Normal file
26
tasks/container_destroy.yml
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
---
|
||||||
|
# Copyright 2017, Rackspace US, Inc.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
- name: Delete container from host
|
||||||
|
lxc_container:
|
||||||
|
name: "{{ inventory_hostname }}"
|
||||||
|
state: "absent"
|
||||||
|
delegate_to: "{{ physical_host }}"
|
||||||
|
|
||||||
|
- name: Destroy container service directories
|
||||||
|
file:
|
||||||
|
path: "/var/lib/lxc/{{ container_name }}"
|
||||||
|
state: "absent"
|
||||||
|
delegate_to: "{{ physical_host }}"
|
@ -48,6 +48,12 @@
|
|||||||
tags:
|
tags:
|
||||||
- always
|
- always
|
||||||
|
|
||||||
|
- include: container_destroy.yml
|
||||||
|
when:
|
||||||
|
- lxc_container_recreate | bool
|
||||||
|
tags:
|
||||||
|
- lxc-container-recreate
|
||||||
|
|
||||||
- include: container_create.yml
|
- include: container_create.yml
|
||||||
when:
|
when:
|
||||||
- physical_host is defined
|
- physical_host is defined
|
||||||
|
Loading…
Reference in New Issue
Block a user