openstack-ansible/playbooks/roles/lxc_container_destroy
Shu Shen de2dc69641 Configurable lxc cache and rootfs path
The rootfs of the containers use large disk space and is defaulted to
/var/lib/lxc. It's desirable to configure an alternative rootfs directory on a
partition with large enough free space to hold the rootfs.

The rootfs of a container is hard-linked to the lxc cache when created by lxc
templates. Therefore both have to reside on the same partition and the lxc
cache shall be configurable as well as the rootfs directory.

The lxc-ubuntu template is patched by lxc-host role to use the configured lxc
cache folder. This patch should be removed once the updated upstream lxc with
support of configuring the cache path goes mainstream.

To confgiure these parameters, set the following variables in global_overrides
of openstack_user_config.yml:
    - lxc_container_directory, defaults to /var/lib/lxc
    - lxc_container_cache_path, defaults to /var/cache/lxc

Closes-Bug: #1463905
Change-Id: I9ccf0c45e0a1875644750e0d70ce613265040176
2015-06-15 20:56:13 +00:00
..
meta Convert existing roles into galaxy roles 2015-02-18 10:56:25 +00:00
tasks Configurable lxc cache and rootfs path 2015-06-15 20:56:13 +00:00
CONTRIBUTING.rst Convert existing roles into galaxy roles 2015-02-18 10:56:25 +00:00
LICENSE Convert existing roles into galaxy roles 2015-02-18 10:56:25 +00:00
README.rst Convert existing roles into galaxy roles 2015-02-18 10:56:25 +00:00

OpenStack LXC container destroy

tags

openstack, lxc, container, cloud, ansible

category

*nix

Role for destroying LXC containers. This role has been setup for use in OpenStack. This role will remove several directories on the LXC host which were used in bind mounted storage within the container.

Example Play:
- name: Destroy lxc containers
  hosts: all_containers
  gather_facts: false
  user: root
  roles:
    - { role: "lxc_container_destroy", tags: [ "lxc-container-destroy" ] }
Example Inventory:
{
    "all_containers": {
        "children": [
            "group_of_containers"
        ],
        "hosts": []
    },
    "lxc_hosts": {
        "children": [],
        "hosts": [
            "infra1"
        ]
    },
    "group_of_containers": {
        "children": [],
        "hosts": [
            "container1"
        ]
    },
    "_meta": {
        "hostvars": {
            "infra1": {
                "ansible_ssh_host": "192.168.0.1",
                "container_address": "192.168.0.1",
                "container_name": "infra1",
                "container_networks": {
                    "management_address": {
                        "bridge": "br-mgmt",
                        "interface": "eth1",
                        "netmask": "255.255.252.0",
                        "type": "veth"
                    }
                },
                "properties": {
                    "container_release": "trusty",
                    "is_metal": true
                }
            },
            "container1": {
                "ansible_ssh_host": "10.0.0.1",
                "container_address": "10.0.0.1",
                "container_name": "container1",
                "container_networks": {
                    "management_address": {
                        "address": "10.0.0.1",
                        "bridge": "br-mgmt",
                        "interface": "eth1",
                        "netmask": "255.255.252.0",
                        "type": "veth"
                    }
                },
                "physical_host": "infra1",
                "physical_host_group": "lxc_hosts",
                "properties": {
                    "container_release": "trusty",
                }
            }
        }
    }
}