Commit 9cc5f436 authored by Jocelyn Delalande's avatar Jocelyn Delalande

lxc-host: Add an option to delete a container

parent ab258608
......@@ -87,3 +87,12 @@ Restart it (so that ssh & co starts properly)
lxc-stop -n ${myhostname} -r
New host is now ready to be added to the inventory and ansibled!
Deleting a container
--------------------
Simply list containers names in `deleted_dmz_hosts`
lxc_host_deleted_containers:
- old_container_name
lxc_host_deleted_containers: []
- name: Install lxc package
apt: pkg=lxc state=installed
- name: Install lxc packages
# Only jessie-backports offers both lxc and python-lxc
apt: pkg={{ item }} state=installed default_release=jessie-backports
with_items:
- lxc
- python-lxc
- name : Put containers config
template: src=base.j2 dest="/var/lib/lxc/{{ item.name }}/config"
with_items: dmz_hosts
with_items: "{{ dmz_hosts }}"
when: item.lxc | default(None)
tags: [lxc]
- name : Patch jessie containers system
copy: src=system dest="/var/lib/lxc/{{ item.name }}/rootfs/etc/systemd/system"
with_items: dmz_hosts
with_items: "{{ dmz_hosts }}"
when: item.lxc | default(None) and item.lxc.version == 'jessie'
tags: [lxc]
- name : Remove /dev/kmsg from jessie containers
file: state=absent path="/var/lib/lxc/{{ item.name }}/rootfs.dev/kmsg"
with_items: dmz_hosts
with_items: "{{ dmz_hosts }}"
when: item.lxc | default(None) and item.lxc.version == 'jessie'
tags: [lxc]
- name: Remove deleted containers config
lxc_container: name={{ item }} state=absent
with_items: "{{ lxc_host_deleted_containers }}"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment