mirror of
https://github.com/ansible-collections/community.docker.git
synced 2025-12-18 04:48:46 +00:00
docker_container: cgroup_parent (#59)
* Document that the Docker SDK for Python is used by the module. * Allow to specify cgroup_parent for container.
This commit is contained in:
parent
e4b747d788
commit
c7a3d9f057
@ -0,0 +1,2 @@
|
|||||||
|
minor_changes:
|
||||||
|
- "docker_container - support specifying ``cgroup_parent`` (https://github.com/ansible-collections/community.docker/issues/6, https://github.com/ansible-collections/community.docker/pull/59)."
|
||||||
@ -111,6 +111,9 @@ notes:
|
|||||||
|
|
||||||
DOCKER_PY_1_DOCUMENTATION = r'''
|
DOCKER_PY_1_DOCUMENTATION = r'''
|
||||||
options: {}
|
options: {}
|
||||||
|
notes:
|
||||||
|
- This module uses the L(Docker SDK for Python,https://docker-py.readthedocs.io/en/stable/) to
|
||||||
|
communicate with the Docker daemon.
|
||||||
requirements:
|
requirements:
|
||||||
- "Docker SDK for Python: Please note that the L(docker-py,https://pypi.org/project/docker-py/)
|
- "Docker SDK for Python: Please note that the L(docker-py,https://pypi.org/project/docker-py/)
|
||||||
Python module has been superseded by L(docker,https://pypi.org/project/docker/)
|
Python module has been superseded by L(docker,https://pypi.org/project/docker/)
|
||||||
@ -127,6 +130,9 @@ requirements:
|
|||||||
|
|
||||||
DOCKER_PY_2_DOCUMENTATION = r'''
|
DOCKER_PY_2_DOCUMENTATION = r'''
|
||||||
options: {}
|
options: {}
|
||||||
|
notes:
|
||||||
|
- This module uses the L(Docker SDK for Python,https://docker-py.readthedocs.io/en/stable/) to
|
||||||
|
communicate with the Docker daemon.
|
||||||
requirements:
|
requirements:
|
||||||
- "Python >= 2.7"
|
- "Python >= 2.7"
|
||||||
- "Docker SDK for Python: Please note that the L(docker-py,https://pypi.org/project/docker-py/)
|
- "Docker SDK for Python: Please note that the L(docker-py,https://pypi.org/project/docker-py/)
|
||||||
|
|||||||
@ -52,6 +52,11 @@ options:
|
|||||||
- List of capabilities to drop from the container.
|
- List of capabilities to drop from the container.
|
||||||
type: list
|
type: list
|
||||||
elements: str
|
elements: str
|
||||||
|
cgroup_parent:
|
||||||
|
description:
|
||||||
|
- Specify the parent cgroup for the container.
|
||||||
|
type: str
|
||||||
|
version_added: 1.1.0
|
||||||
cleanup:
|
cleanup:
|
||||||
description:
|
description:
|
||||||
- Use with I(detach=false) to remove the container after successful execution.
|
- Use with I(detach=false) to remove the container after successful execution.
|
||||||
@ -1596,6 +1601,7 @@ class TaskParameters(DockerBaseClass):
|
|||||||
publish_all_ports='publish_all_ports',
|
publish_all_ports='publish_all_ports',
|
||||||
links='links',
|
links='links',
|
||||||
privileged='privileged',
|
privileged='privileged',
|
||||||
|
cgroup_parent='cgroup_parent',
|
||||||
dns='dns_servers',
|
dns='dns_servers',
|
||||||
dns_opt='dns_opts',
|
dns_opt='dns_opts',
|
||||||
dns_search='dns_search_domains',
|
dns_search='dns_search_domains',
|
||||||
@ -2190,6 +2196,7 @@ class Container(DockerBaseClass):
|
|||||||
interactive=config.get('OpenStdin'),
|
interactive=config.get('OpenStdin'),
|
||||||
capabilities=host_config.get('CapAdd'),
|
capabilities=host_config.get('CapAdd'),
|
||||||
cap_drop=host_config.get('CapDrop'),
|
cap_drop=host_config.get('CapDrop'),
|
||||||
|
cgroup_parent=host_config.get('CgroupParent'),
|
||||||
expected_devices=host_config.get('Devices'),
|
expected_devices=host_config.get('Devices'),
|
||||||
dns_servers=host_config.get('Dns'),
|
dns_servers=host_config.get('Dns'),
|
||||||
dns_opts=host_config.get('DnsOptions'),
|
dns_opts=host_config.get('DnsOptions'),
|
||||||
@ -3389,6 +3396,7 @@ def main():
|
|||||||
blkio_weight=dict(type='int'),
|
blkio_weight=dict(type='int'),
|
||||||
capabilities=dict(type='list', elements='str'),
|
capabilities=dict(type='list', elements='str'),
|
||||||
cap_drop=dict(type='list', elements='str'),
|
cap_drop=dict(type='list', elements='str'),
|
||||||
|
cgroup_parent=dict(type='str'),
|
||||||
cleanup=dict(type='bool', default=False),
|
cleanup=dict(type='bool', default=False),
|
||||||
command=dict(type='raw'),
|
command=dict(type='raw'),
|
||||||
comparisons=dict(type='dict'),
|
comparisons=dict(type='dict'),
|
||||||
|
|||||||
@ -157,6 +157,40 @@
|
|||||||
- capabilities_3 is not changed
|
- capabilities_3 is not changed
|
||||||
- capabilities_4 is changed
|
- capabilities_4 is changed
|
||||||
|
|
||||||
|
####################################################################
|
||||||
|
## cgroup_parent ###################################################
|
||||||
|
####################################################################
|
||||||
|
|
||||||
|
- name: cgroup_parent
|
||||||
|
docker_container:
|
||||||
|
image: "{{ docker_test_image_alpine }}"
|
||||||
|
command: '/bin/sh -c "sleep 10m"'
|
||||||
|
name: "{{ cname }}"
|
||||||
|
state: started
|
||||||
|
cgroup_parent: ''
|
||||||
|
register: cgroup_parent_1
|
||||||
|
|
||||||
|
- name: cgroup_parent (idempotency)
|
||||||
|
docker_container:
|
||||||
|
image: "{{ docker_test_image_alpine }}"
|
||||||
|
command: '/bin/sh -c "sleep 10m"'
|
||||||
|
name: "{{ cname }}"
|
||||||
|
state: started
|
||||||
|
cgroup_parent: ''
|
||||||
|
register: cgroup_parent_2
|
||||||
|
|
||||||
|
- name: cleanup
|
||||||
|
docker_container:
|
||||||
|
name: "{{ cname }}"
|
||||||
|
state: absent
|
||||||
|
force_kill: yes
|
||||||
|
diff: no
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- cgroup_parent_1 is changed
|
||||||
|
- cgroup_parent_2 is not changed
|
||||||
|
|
||||||
####################################################################
|
####################################################################
|
||||||
## command #########################################################
|
## command #########################################################
|
||||||
####################################################################
|
####################################################################
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user