|
|
@ -21,7 +21,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
DOCUMENTATION = """
|
|
|
|
DOCUMENTATION = """
|
|
|
|
---
|
|
|
|
---
|
|
|
|
module: lxc-container
|
|
|
|
module: lxc_container
|
|
|
|
short_description: Manage LXC Containers
|
|
|
|
short_description: Manage LXC Containers
|
|
|
|
version_added: 1.8.0
|
|
|
|
version_added: 1.8.0
|
|
|
|
description:
|
|
|
|
description:
|
|
|
@ -174,7 +174,7 @@ notes:
|
|
|
|
|
|
|
|
|
|
|
|
EXAMPLES = """
|
|
|
|
EXAMPLES = """
|
|
|
|
- name: Create a started container
|
|
|
|
- name: Create a started container
|
|
|
|
lxc-container:
|
|
|
|
lxc_container:
|
|
|
|
name: test-container-started
|
|
|
|
name: test-container-started
|
|
|
|
container_log: true
|
|
|
|
container_log: true
|
|
|
|
template: ubuntu
|
|
|
|
template: ubuntu
|
|
|
@ -182,7 +182,7 @@ EXAMPLES = """
|
|
|
|
template_options: --release trusty
|
|
|
|
template_options: --release trusty
|
|
|
|
|
|
|
|
|
|
|
|
- name: Create a stopped container
|
|
|
|
- name: Create a stopped container
|
|
|
|
lxc-container:
|
|
|
|
lxc_container:
|
|
|
|
name: test-container-stopped
|
|
|
|
name: test-container-stopped
|
|
|
|
container_log: true
|
|
|
|
container_log: true
|
|
|
|
template: ubuntu
|
|
|
|
template: ubuntu
|
|
|
@ -190,7 +190,7 @@ EXAMPLES = """
|
|
|
|
template_options: --release trusty
|
|
|
|
template_options: --release trusty
|
|
|
|
|
|
|
|
|
|
|
|
- name: Create a frozen container
|
|
|
|
- name: Create a frozen container
|
|
|
|
lxc-container:
|
|
|
|
lxc_container:
|
|
|
|
name: test-container-frozen
|
|
|
|
name: test-container-frozen
|
|
|
|
container_log: true
|
|
|
|
container_log: true
|
|
|
|
template: ubuntu
|
|
|
|
template: ubuntu
|
|
|
@ -201,7 +201,7 @@ EXAMPLES = """
|
|
|
|
|
|
|
|
|
|
|
|
# Create filesystem container, configure it, and archive it, and start it.
|
|
|
|
# Create filesystem container, configure it, and archive it, and start it.
|
|
|
|
- name: Create filesystem container
|
|
|
|
- name: Create filesystem container
|
|
|
|
lxc-container:
|
|
|
|
lxc_container:
|
|
|
|
name: test-container-config
|
|
|
|
name: test-container-config
|
|
|
|
container_log: true
|
|
|
|
container_log: true
|
|
|
|
template: ubuntu
|
|
|
|
template: ubuntu
|
|
|
@ -217,7 +217,7 @@ EXAMPLES = """
|
|
|
|
# configuration to it, create an archive of it, and finally leave the container
|
|
|
|
# configuration to it, create an archive of it, and finally leave the container
|
|
|
|
# in a frozen state. The container archive will be compressed using bzip2
|
|
|
|
# in a frozen state. The container archive will be compressed using bzip2
|
|
|
|
- name: Create an lvm container
|
|
|
|
- name: Create an lvm container
|
|
|
|
lxc-container:
|
|
|
|
lxc_container:
|
|
|
|
name: test-container-lvm
|
|
|
|
name: test-container-lvm
|
|
|
|
container_log: true
|
|
|
|
container_log: true
|
|
|
|
template: ubuntu
|
|
|
|
template: ubuntu
|
|
|
@ -242,7 +242,7 @@ EXAMPLES = """
|
|
|
|
debug: var=lvm_container_info
|
|
|
|
debug: var=lvm_container_info
|
|
|
|
|
|
|
|
|
|
|
|
- name: Get information on a given container.
|
|
|
|
- name: Get information on a given container.
|
|
|
|
lxc-container:
|
|
|
|
lxc_container:
|
|
|
|
name: test-container-config
|
|
|
|
name: test-container-config
|
|
|
|
register: config_container_info
|
|
|
|
register: config_container_info
|
|
|
|
|
|
|
|
|
|
|
@ -250,33 +250,33 @@ EXAMPLES = """
|
|
|
|
debug: var=config_container_info
|
|
|
|
debug: var=config_container_info
|
|
|
|
|
|
|
|
|
|
|
|
- name: Run a command in a container and ensure its in a "stopped" state.
|
|
|
|
- name: Run a command in a container and ensure its in a "stopped" state.
|
|
|
|
lxc-container:
|
|
|
|
lxc_container:
|
|
|
|
name: test-container-started
|
|
|
|
name: test-container-started
|
|
|
|
state: stopped
|
|
|
|
state: stopped
|
|
|
|
container_command: |
|
|
|
|
container_command: |
|
|
|
|
echo 'hello world.' | tee /opt/stopped
|
|
|
|
echo 'hello world.' | tee /opt/stopped
|
|
|
|
|
|
|
|
|
|
|
|
- name: Run a command in a container and ensure its it in a "frozen" state.
|
|
|
|
- name: Run a command in a container and ensure its it in a "frozen" state.
|
|
|
|
lxc-container:
|
|
|
|
lxc_container:
|
|
|
|
name: test-container-stopped
|
|
|
|
name: test-container-stopped
|
|
|
|
state: frozen
|
|
|
|
state: frozen
|
|
|
|
container_command: |
|
|
|
|
container_command: |
|
|
|
|
echo 'hello world.' | tee /opt/frozen
|
|
|
|
echo 'hello world.' | tee /opt/frozen
|
|
|
|
|
|
|
|
|
|
|
|
- name: Start a container.
|
|
|
|
- name: Start a container.
|
|
|
|
lxc-container:
|
|
|
|
lxc_container:
|
|
|
|
name: test-container-stopped
|
|
|
|
name: test-container-stopped
|
|
|
|
state: started
|
|
|
|
state: started
|
|
|
|
|
|
|
|
|
|
|
|
- name: Run a command in a container and then restart it.
|
|
|
|
- name: Run a command in a container and then restart it.
|
|
|
|
lxc-container:
|
|
|
|
lxc_container:
|
|
|
|
name: test-container-started
|
|
|
|
name: test-container-started
|
|
|
|
state: restarted
|
|
|
|
state: restarted
|
|
|
|
container_command: |
|
|
|
|
container_command: |
|
|
|
|
echo 'hello world.' | tee /opt/restarted
|
|
|
|
echo 'hello world.' | tee /opt/restarted
|
|
|
|
|
|
|
|
|
|
|
|
- name: Run a complex command within a "running" container.
|
|
|
|
- name: Run a complex command within a "running" container.
|
|
|
|
lxc-container:
|
|
|
|
lxc_container:
|
|
|
|
name: test-container-started
|
|
|
|
name: test-container-started
|
|
|
|
container_command: |
|
|
|
|
container_command: |
|
|
|
|
apt-get update
|
|
|
|
apt-get update
|
|
|
@ -289,14 +289,14 @@ EXAMPLES = """
|
|
|
|
# Create an archive of an existing container, save the archive to a defined
|
|
|
|
# Create an archive of an existing container, save the archive to a defined
|
|
|
|
# path and then destroy it.
|
|
|
|
# path and then destroy it.
|
|
|
|
- name: Archive container
|
|
|
|
- name: Archive container
|
|
|
|
lxc-container:
|
|
|
|
lxc_container:
|
|
|
|
name: test-container-started
|
|
|
|
name: test-container-started
|
|
|
|
state: absent
|
|
|
|
state: absent
|
|
|
|
archive: true
|
|
|
|
archive: true
|
|
|
|
archive_path: /opt/archives
|
|
|
|
archive_path: /opt/archives
|
|
|
|
|
|
|
|
|
|
|
|
- name: Destroy a container.
|
|
|
|
- name: Destroy a container.
|
|
|
|
lxc-container:
|
|
|
|
lxc_container:
|
|
|
|
name: "{{ item }}"
|
|
|
|
name: "{{ item }}"
|
|
|
|
state: absent
|
|
|
|
state: absent
|
|
|
|
with_items:
|
|
|
|
with_items:
|
|
|
|