Reformat documentation with 'andebox yaml-doc' (#1020)

* Reformat documentation with 'andebox yaml-doc'.

* Revert unwanted changes.

* Fix too long lines.

* Fix broken quotes.

* Forgot two line breaks.
This commit is contained in:
Felix Fontein
2024-12-28 16:40:50 +01:00
committed by GitHub
parent f69536ef3b
commit 769d15de63
46 changed files with 2017 additions and 2469 deletions
+6 -15
View File
@@ -10,7 +10,7 @@
from __future__ import (absolute_import, division, print_function) from __future__ import (absolute_import, division, print_function)
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = r"""
author: author:
- Lorin Hochestein (!UNKNOWN) - Lorin Hochestein (!UNKNOWN)
- Leendert Brouwer (!UNKNOWN) - Leendert Brouwer (!UNKNOWN)
@@ -18,9 +18,8 @@ name: docker
short_description: Run tasks in docker containers short_description: Run tasks in docker containers
description: description:
- Run commands or put/fetch files to an existing docker container. - Run commands or put/fetch files to an existing docker container.
- Uses the Docker CLI to execute commands in the container. If you prefer - Uses the Docker CLI to execute commands in the container. If you prefer to directly connect to the Docker daemon, use
to directly connect to the Docker daemon, use the the P(community.docker.docker_api#connection) connection plugin.
P(community.docker.docker_api#connection) connection plugin.
options: options:
remote_addr: remote_addr:
description: description:
@@ -78,16 +77,8 @@ options:
extra_env: extra_env:
description: description:
- Provide extra environment variables to set when running commands in the Docker container. - Provide extra environment variables to set when running commands in the Docker container.
- This option can currently only be provided as Ansible variables due to limitations of - This option can currently only be provided as Ansible variables due to limitations of ansible-core's configuration
ansible-core's configuration manager. manager.
# env:
# - name: ANSIBLE_DOCKER_EXTRA_ENV
# ini:
# - key: extra_env
# section: docker_connection
# ansible-core's config manager does NOT support converting JSON strings (or other things) to dictionaries,
# it only accepts actual dictionaries (which do not happen to come from env and ini vars). So there's no way
# to actually provide this parameter from env and ini sources... :-(
vars: vars:
- name: ansible_docker_extra_env - name: ansible_docker_extra_env
type: dict type: dict
@@ -119,7 +110,7 @@ options:
type: boolean type: boolean
default: false default: false
version_added: 3.12.0 version_added: 3.12.0
''' """
import fcntl import fcntl
import os import os
+6 -15
View File
@@ -5,7 +5,7 @@
from __future__ import (absolute_import, division, print_function) from __future__ import (absolute_import, division, print_function)
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = r"""
author: author:
- Felix Fontein (@felixfontein) - Felix Fontein (@felixfontein)
name: docker_api name: docker_api
@@ -13,9 +13,8 @@ short_description: Run tasks in docker containers
version_added: 1.1.0 version_added: 1.1.0
description: description:
- Run commands or put/fetch files to an existing docker container. - Run commands or put/fetch files to an existing docker container.
- Uses the L(requests library,https://pypi.org/project/requests/) to interact - Uses the L(requests library,https://pypi.org/project/requests/) to interact directly with the Docker daemon instead of
directly with the Docker daemon instead of using the Docker CLI. Use the using the Docker CLI. Use the P(community.docker.docker#connection) connection plugin if you want to use the Docker CLI.
P(community.docker.docker#connection) connection plugin if you want to use the Docker CLI.
notes: notes:
- Does B(not work with TCP TLS sockets)! This is caused by the inability to send C(close_notify) without closing the connection - Does B(not work with TCP TLS sockets)! This is caused by the inability to send C(close_notify) without closing the connection
with Python's C(SSLSocket)s. See U(https://github.com/ansible-collections/community.docker/issues/605) for more information. with Python's C(SSLSocket)s. See U(https://github.com/ansible-collections/community.docker/issues/605) for more information.
@@ -71,16 +70,8 @@ options:
extra_env: extra_env:
description: description:
- Provide extra environment variables to set when running commands in the Docker container. - Provide extra environment variables to set when running commands in the Docker container.
- This option can currently only be provided as Ansible variables due to limitations of - This option can currently only be provided as Ansible variables due to limitations of ansible-core's configuration
ansible-core's configuration manager. manager.
# env:
# - name: ANSIBLE_DOCKER_EXTRA_ENV
# ini:
# - key: extra_env
# section: docker_connection
# ansible-core's config manager does NOT support converting JSON strings (or other things) to dictionaries,
# it only accepts actual dictionaries (which do not happen to come from env and ini vars). So there's no way
# to actually provide this parameter from env and ini sources... :-(
vars: vars:
- name: ansible_docker_extra_env - name: ansible_docker_extra_env
type: dict type: dict
@@ -112,7 +103,7 @@ options:
type: boolean type: boolean
default: false default: false
version_added: 3.12.0 version_added: 3.12.0
''' """
import os import os
import os.path import os.path
+10 -13
View File
@@ -8,17 +8,16 @@
from __future__ import (absolute_import, division, print_function) from __future__ import (absolute_import, division, print_function)
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = r"""
name: nsenter name: nsenter
short_description: execute on host running controller container short_description: execute on host running controller container
version_added: 1.9.0 version_added: 1.9.0
description: description:
- This connection plugin allows Ansible, running in a privileged container, to execute tasks on the container - This connection plugin allows Ansible, running in a privileged container, to execute tasks on the container host instead
host instead of in the container itself. of in the container itself.
- This is useful for running Ansible in a pull model, while still keeping the Ansible control node - This is useful for running Ansible in a pull model, while still keeping the Ansible control node containerized.
containerized. - It relies on having privileged access to run C(nsenter) in the host's PID namespace, allowing it to enter the namespaces
- It relies on having privileged access to run C(nsenter) in the host's PID namespace, allowing it to enter the of the provided PID (default PID 1, or init/systemd).
namespaces of the provided PID (default PID 1, or init/systemd).
author: Jeff Goldschrafe (@jgoldschrafe) author: Jeff Goldschrafe (@jgoldschrafe)
options: options:
nsenter_pid: nsenter_pid:
@@ -36,12 +35,10 @@ options:
key: nsenter_pid key: nsenter_pid
notes: notes:
- The remote user is ignored; this plugin always runs as root. - The remote user is ignored; this plugin always runs as root.
- >- - "This plugin requires the Ansible controller container to be launched in the following way: (1) The container image contains
This plugin requires the Ansible controller container to be launched in the following way: the C(nsenter) program; (2) The container is launched in privileged mode; (3) The container is launched in the host's
(1) The container image contains the C(nsenter) program; PID namespace (C(--pid host))."
(2) The container is launched in privileged mode; """
(3) The container is launched in the host's PID namespace (C(--pid host)).
'''
import os import os
import pty import pty
+10 -10
View File
@@ -11,14 +11,14 @@ __metaclass__ = type
class ModuleDocFragment(object): class ModuleDocFragment(object):
# Standard documentation fragment # Standard documentation fragment
DOCUMENTATION = r''' DOCUMENTATION = r"""
options: {} options: {}
attributes: attributes:
check_mode: check_mode:
description: Can run in C(check_mode) and return changed status prediction without modifying target. description: Can run in C(check_mode) and return changed status prediction without modifying target.
diff_mode: diff_mode:
description: Will return details on what has changed (or possibly needs changing in C(check_mode)), when in diff mode. description: Will return details on what has changed (or possibly needs changing in C(check_mode)), when in diff mode.
''' """
# Should be used together with the standard fragment # Should be used together with the standard fragment
INFO_MODULE = r''' INFO_MODULE = r'''
@@ -45,7 +45,7 @@ attributes:
- docker - docker
''' '''
CONN = r''' CONN = r"""
options: {} options: {}
attributes: attributes:
become: become:
@@ -54,14 +54,14 @@ attributes:
description: Uses the target's configured connection information to execute code on it. description: Uses the target's configured connection information to execute code on it.
delegation: delegation:
description: Can be used in conjunction with C(delegate_to) and related keywords. description: Can be used in conjunction with C(delegate_to) and related keywords.
''' """
FACTS = r''' FACTS = r"""
options: {} options: {}
attributes: attributes:
facts: facts:
description: Action returns an C(ansible_facts) dictionary that will update existing host facts. description: Action returns an C(ansible_facts) dictionary that will update existing host facts.
''' """
# Should be used together with the standard fragment and the FACTS fragment # Should be used together with the standard fragment and the FACTS fragment
FACTS_MODULE = r''' FACTS_MODULE = r'''
@@ -79,18 +79,18 @@ attributes:
support: full support: full
''' '''
FILES = r''' FILES = r"""
options: {} options: {}
attributes: attributes:
safe_file_operations: safe_file_operations:
description: Uses Ansible's strict file operation functions to ensure proper permissions and avoid data corruption. description: Uses Ansible's strict file operation functions to ensure proper permissions and avoid data corruption.
''' """
FLOW = r''' FLOW = r"""
options: {} options: {}
attributes: attributes:
action: action:
description: Indicates this has a corresponding action plugin so some parts of the options can be executed on the controller. description: Indicates this has a corresponding action plugin so some parts of the options can be executed on the controller.
async: async:
description: Supports being used with the C(async) keyword. description: Supports being used with the C(async) keyword.
''' """
+9 -13
View File
@@ -11,12 +11,11 @@ __metaclass__ = type
class ModuleDocFragment(object): class ModuleDocFragment(object):
# Docker doc fragment # Docker doc fragment
DOCUMENTATION = r''' DOCUMENTATION = r"""
options: options:
project_src: project_src:
description: description:
- Path to a directory containing a Compose file - Path to a directory containing a Compose file (C(compose.yml), C(compose.yaml), C(docker-compose.yml), or C(docker-compose.yaml)).
(C(compose.yml), C(compose.yaml), C(docker-compose.yml), or C(docker-compose.yaml)).
- If O(files) is provided, will look for these files in this directory instead. - If O(files) is provided, will look for these files in this directory instead.
- Mutually exclusive with O(definition). One of O(project_src) and O(definition) must be provided. - Mutually exclusive with O(definition). One of O(project_src) and O(definition) must be provided.
type: path type: path
@@ -27,8 +26,8 @@ options:
type: str type: str
files: files:
description: description:
- List of Compose file names relative to O(project_src) to be used instead of the main Compose file - List of Compose file names relative to O(project_src) to be used instead of the main Compose file (C(compose.yml),
(C(compose.yml), C(compose.yaml), C(docker-compose.yml), or C(docker-compose.yaml)). C(compose.yaml), C(docker-compose.yml), or C(docker-compose.yaml)).
- Files are loaded and merged in the order given. - Files are loaded and merged in the order given.
- Mutually exclusive with O(definition). - Mutually exclusive with O(definition).
type: list type: list
@@ -57,12 +56,10 @@ options:
elements: str elements: str
check_files_existing: check_files_existing:
description: description:
- If set to V(false), the module will not check whether one of the files - If set to V(false), the module will not check whether one of the files C(compose.yaml), C(compose.yml), C(docker-compose.yaml),
C(compose.yaml), C(compose.yml), C(docker-compose.yaml), or C(docker-compose.yml) or C(docker-compose.yml) exists in O(project_src) if O(files) is not provided.
exists in O(project_src) if O(files) is not provided. - This can be useful if environment files with C(COMPOSE_FILE) are used to configure a different filename. The module
- This can be useful if environment files with C(COMPOSE_FILE) are used to configure a different currently does not check for C(COMPOSE_FILE) in environment files or the current environment.
filename. The module currently does not check for C(COMPOSE_FILE) in environment files or the
current environment.
type: bool type: bool
default: true default: true
version_added: 3.9.0 version_added: 3.9.0
@@ -73,10 +70,9 @@ notes:
The Docker compose CLI plugin has no stable output format (see for example U(https://github.com/docker/compose/issues/10872)), The Docker compose CLI plugin has no stable output format (see for example U(https://github.com/docker/compose/issues/10872)),
and for the main operations also no machine friendly output format. The module tries to accomodate this with various and for the main operations also no machine friendly output format. The module tries to accomodate this with various
version-dependent behavior adjustments and with testing older and newer versions of the Docker compose CLI plugin. version-dependent behavior adjustments and with testing older and newer versions of the Docker compose CLI plugin.
Currently the module is tested with multiple plugin versions between 2.18.1 and 2.23.3. The exact list of plugin versions Currently the module is tested with multiple plugin versions between 2.18.1 and 2.23.3. The exact list of plugin versions
will change over time. New releases of the Docker compose CLI plugin can break this module at any time. will change over time. New releases of the Docker compose CLI plugin can break this module at any time.
''' """
# The following needs to be kept in sync with the compose_v2 module utils # The following needs to be kept in sync with the compose_v2 module utils
MINIMUM_VERSION = r''' MINIMUM_VERSION = r'''
+38 -39
View File
@@ -11,72 +11,72 @@ __metaclass__ = type
class ModuleDocFragment(object): class ModuleDocFragment(object):
# Docker doc fragment # Docker doc fragment
DOCUMENTATION = r''' DOCUMENTATION = r"""
options: options:
docker_host: docker_host:
description: description:
- The URL or Unix socket path used to connect to the Docker API. To connect to a remote host, provide the - The URL or Unix socket path used to connect to the Docker API. To connect to a remote host, provide the TCP connection
TCP connection string. For example, V(tcp://192.0.2.23:2376). If TLS is used to encrypt the connection, string. For example, V(tcp://192.0.2.23:2376). If TLS is used to encrypt the connection, the module will automatically
the module will automatically replace C(tcp) in the connection URL with C(https). replace C(tcp) in the connection URL with C(https).
- If the value is not specified in the task, the value of environment variable E(DOCKER_HOST) will be used - If the value is not specified in the task, the value of environment variable E(DOCKER_HOST) will be used instead.
instead. If the environment variable is not set, the default value will be used. If the environment variable is not set, the default value will be used.
type: str type: str
default: unix:///var/run/docker.sock default: unix:///var/run/docker.sock
aliases: [docker_url] aliases: [docker_url]
tls_hostname: tls_hostname:
description: description:
- When verifying the authenticity of the Docker Host server, provide the expected name of the server. - When verifying the authenticity of the Docker Host server, provide the expected name of the server.
- If the value is not specified in the task, the value of environment variable E(DOCKER_TLS_HOSTNAME) will - If the value is not specified in the task, the value of environment variable E(DOCKER_TLS_HOSTNAME) will be used instead.
be used instead. If the environment variable is not set, the default value will be used. If the environment variable is not set, the default value will be used.
- Note that this option had a default value V(localhost) in older versions. It was removed in community.docker 3.0.0. - Note that this option had a default value V(localhost) in older versions. It was removed in community.docker 3.0.0.
- B(Note:) this option is no longer supported for Docker SDK for Python 7.0.0+. Specifying it with Docker SDK for - B(Note:) this option is no longer supported for Docker SDK for Python 7.0.0+. Specifying it with Docker SDK for Python
Python 7.0.0 or newer will lead to an error. 7.0.0 or newer will lead to an error.
type: str type: str
api_version: api_version:
description: description:
- The version of the Docker API running on the Docker Host. - The version of the Docker API running on the Docker Host.
- Defaults to the latest version of the API supported by Docker SDK for Python and the docker daemon. - Defaults to the latest version of the API supported by Docker SDK for Python and the docker daemon.
- If the value is not specified in the task, the value of environment variable E(DOCKER_API_VERSION) will be - If the value is not specified in the task, the value of environment variable E(DOCKER_API_VERSION) will be used instead.
used instead. If the environment variable is not set, the default value will be used. If the environment variable is not set, the default value will be used.
type: str type: str
default: auto default: auto
aliases: [docker_api_version] aliases: [docker_api_version]
timeout: timeout:
description: description:
- The maximum amount of time in seconds to wait on a response from the API. - The maximum amount of time in seconds to wait on a response from the API.
- If the value is not specified in the task, the value of environment variable E(DOCKER_TIMEOUT) will be used - If the value is not specified in the task, the value of environment variable E(DOCKER_TIMEOUT) will be used instead.
instead. If the environment variable is not set, the default value will be used. If the environment variable is not set, the default value will be used.
type: int type: int
default: 60 default: 60
ca_path: ca_path:
description: description:
- Use a CA certificate when performing server verification by providing the path to a CA certificate file. - Use a CA certificate when performing server verification by providing the path to a CA certificate file.
- If the value is not specified in the task and the environment variable E(DOCKER_CERT_PATH) is set, - If the value is not specified in the task and the environment variable E(DOCKER_CERT_PATH) is set, the file C(ca.pem)
the file C(ca.pem) from the directory specified in the environment variable E(DOCKER_CERT_PATH) will be used. from the directory specified in the environment variable E(DOCKER_CERT_PATH) will be used.
- This option was called O(ca_cert) and got renamed to O(ca_path) in community.docker 3.6.0. The old name has - This option was called O(ca_cert) and got renamed to O(ca_path) in community.docker 3.6.0. The old name has been added
been added as an alias and can still be used. as an alias and can still be used.
type: path type: path
aliases: [ca_cert, tls_ca_cert, cacert_path] aliases: [ca_cert, tls_ca_cert, cacert_path]
client_cert: client_cert:
description: description:
- Path to the client's TLS certificate file. - Path to the client's TLS certificate file.
- If the value is not specified in the task and the environment variable E(DOCKER_CERT_PATH) is set, - If the value is not specified in the task and the environment variable E(DOCKER_CERT_PATH) is set, the file C(cert.pem)
the file C(cert.pem) from the directory specified in the environment variable E(DOCKER_CERT_PATH) will be used. from the directory specified in the environment variable E(DOCKER_CERT_PATH) will be used.
type: path type: path
aliases: [tls_client_cert, cert_path] aliases: [tls_client_cert, cert_path]
client_key: client_key:
description: description:
- Path to the client's TLS key file. - Path to the client's TLS key file.
- If the value is not specified in the task and the environment variable E(DOCKER_CERT_PATH) is set, - If the value is not specified in the task and the environment variable E(DOCKER_CERT_PATH) is set, the file C(key.pem)
the file C(key.pem) from the directory specified in the environment variable E(DOCKER_CERT_PATH) will be used. from the directory specified in the environment variable E(DOCKER_CERT_PATH) will be used.
type: path type: path
aliases: [tls_client_key, key_path] aliases: [tls_client_key, key_path]
tls: tls:
description: description:
- Secure the connection to the API by using TLS without verifying the authenticity of the Docker host - Secure the connection to the API by using TLS without verifying the authenticity of the Docker host server. Note that
server. Note that if O(validate_certs) is set to V(true) as well, it will take precedence. if O(validate_certs) is set to V(true) as well, it will take precedence.
- If the value is not specified in the task, the value of environment variable E(DOCKER_TLS) will be used - If the value is not specified in the task, the value of environment variable E(DOCKER_TLS) will be used instead. If
instead. If the environment variable is not set, the default value will be used. the environment variable is not set, the default value will be used.
type: bool type: bool
default: false default: false
use_ssh_client: use_ssh_client:
@@ -89,29 +89,28 @@ options:
validate_certs: validate_certs:
description: description:
- Secure the connection to the API by using TLS and verifying the authenticity of the Docker host server. - Secure the connection to the API by using TLS and verifying the authenticity of the Docker host server.
- If the value is not specified in the task, the value of environment variable E(DOCKER_TLS_VERIFY) will be - If the value is not specified in the task, the value of environment variable E(DOCKER_TLS_VERIFY) will be used instead.
used instead. If the environment variable is not set, the default value will be used. If the environment variable is not set, the default value will be used.
type: bool type: bool
default: false default: false
aliases: [tls_verify] aliases: [tls_verify]
debug: debug:
description: description:
- Debug mode - Debug mode.
type: bool type: bool
default: false default: false
notes: notes:
- Connect to the Docker daemon by providing parameters with each task or by defining environment variables. - Connect to the Docker daemon by providing parameters with each task or by defining environment variables. You can define
You can define E(DOCKER_HOST), E(DOCKER_TLS_HOSTNAME), E(DOCKER_API_VERSION), E(DOCKER_CERT_PATH), E(DOCKER_HOST), E(DOCKER_TLS_HOSTNAME), E(DOCKER_API_VERSION), E(DOCKER_CERT_PATH), E(DOCKER_TLS), E(DOCKER_TLS_VERIFY)
E(DOCKER_TLS), E(DOCKER_TLS_VERIFY) and E(DOCKER_TIMEOUT). If you are using docker machine, run the script shipped and E(DOCKER_TIMEOUT). If you are using docker machine, run the script shipped with the product that sets up the environment.
with the product that sets up the environment. It will set these variables for you. See It will set these variables for you. See U(https://docs.docker.com/machine/reference/env/) for more details.
U(https://docs.docker.com/machine/reference/env/) for more details. - When connecting to Docker daemon with TLS, you might need to install additional Python packages. For the Docker SDK for
- When connecting to Docker daemon with TLS, you might need to install additional Python packages. Python, version 2.4 or newer, this can be done by installing C(docker[tls]) with M(ansible.builtin.pip).
For the Docker SDK for Python, version 2.4 or newer, this can be done by installing C(docker[tls]) with M(ansible.builtin.pip).
- Note that the Docker SDK for Python only allows to specify the path to the Docker configuration for very few functions. - Note that the Docker SDK for Python only allows to specify the path to the Docker configuration for very few functions.
In general, it will use C($HOME/.docker/config.json) if the E(DOCKER_CONFIG) environment variable is not specified, In general, it will use C($HOME/.docker/config.json) if the E(DOCKER_CONFIG) environment variable is not specified, and
and use C($DOCKER_CONFIG/config.json) otherwise. use C($DOCKER_CONFIG/config.json) otherwise.
''' """
# For plugins: allow to define common options with Ansible variables # For plugins: allow to define common options with Ansible variables
+28 -30
View File
@@ -12,7 +12,7 @@ from __future__ import (absolute_import, division, print_function)
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = r''' DOCUMENTATION = r"""
name: docker_containers name: docker_containers
short_description: Ansible dynamic inventory plugin for Docker containers short_description: Ansible dynamic inventory plugin for Docker containers
version_added: 1.1.0 version_added: 1.1.0
@@ -26,14 +26,13 @@ description:
- Reads inventories from the Docker API. - Reads inventories from the Docker API.
- Uses a YAML configuration file that ends with V(docker.(yml|yaml\)). - Uses a YAML configuration file that ends with V(docker.(yml|yaml\)).
notes: notes:
- The configuration file must be a YAML file whose filename ends with V(docker.yml) or V(docker.yaml). - The configuration file must be a YAML file whose filename ends with V(docker.yml) or V(docker.yaml). Other filenames will
Other filenames will not be accepted. not be accepted.
options: options:
plugin: plugin:
description: description:
- The name of this plugin, it should always be set to V(community.docker.docker_containers) - The name of this plugin, it should always be set to V(community.docker.docker_containers) for this plugin to recognize
for this plugin to recognize it as its own. it as its own.
type: str type: str
required: true required: true
choices: [community.docker.docker_containers] choices: [community.docker.docker_containers]
@@ -41,12 +40,12 @@ options:
connection_type: connection_type:
description: description:
- Which connection type to use the containers. - Which connection type to use the containers.
- One way to connect to containers is to use SSH (V(ssh)). For this, the options O(default_ip) and - One way to connect to containers is to use SSH (V(ssh)). For this, the options O(default_ip) and O(private_ssh_port)
O(private_ssh_port) are used. This requires that a SSH daemon is running inside the containers. are used. This requires that a SSH daemon is running inside the containers.
- Alternatively, V(docker-cli) selects the P(community.docker.docker#connection) connection plugin, - Alternatively, V(docker-cli) selects the P(community.docker.docker#connection) connection plugin, and V(docker-api)
and V(docker-api) (default) selects the P(community.docker.docker_api#connection) connection plugin. (default) selects the P(community.docker.docker_api#connection) connection plugin.
- When V(docker-api) is used, all Docker daemon configuration values are passed from the inventory plugin - When V(docker-api) is used, all Docker daemon configuration values are passed from the inventory plugin to the connection
to the connection plugin. This can be controlled with O(configure_docker_daemon). plugin. This can be controlled with O(configure_docker_daemon).
- Note that the P(community.docker.docker_api#connection) does B(not work with TCP TLS sockets)! - Note that the P(community.docker.docker_api#connection) does B(not work with TCP TLS sockets)!
See U(https://github.com/ansible-collections/community.docker/issues/605) for more information. See U(https://github.com/ansible-collections/community.docker/issues/605) for more information.
type: str type: str
@@ -67,8 +66,8 @@ options:
verbose_output: verbose_output:
description: description:
- Toggle to (not) include all available inspection metadata. - Toggle to (not) include all available inspection metadata.
- Note that all top-level keys will be transformed to the format C(docker_xxx). - Note that all top-level keys will be transformed to the format C(docker_xxx). For example, C(HostConfig) is converted
For example, C(HostConfig) is converted to C(docker_hostconfig). to C(docker_hostconfig).
- If this is V(false), these values can only be used during O(compose), O(groups), and O(keyed_groups). - If this is V(false), these values can only be used during O(compose), O(groups), and O(keyed_groups).
- The C(docker) inventory script always added these variables, so for compatibility set this to V(true). - The C(docker) inventory script always added these variables, so for compatibility set this to V(true).
type: bool type: bool
@@ -76,8 +75,7 @@ options:
default_ip: default_ip:
description: description:
- The IP address to assign to ansible_host when the container's SSH port is mapped to interface - The IP address to assign to ansible_host when the container's SSH port is mapped to interface '0.0.0.0'.
'0.0.0.0'.
- Only used if O(connection_type) is V(ssh). - Only used if O(connection_type) is V(ssh).
type: str type: str
default: 127.0.0.1 default: 127.0.0.1
@@ -91,25 +89,25 @@ options:
add_legacy_groups: add_legacy_groups:
description: description:
- "Add the same groups as the C(docker) inventory script does. These are the following:" - 'Add the same groups as the C(docker) inventory script does. These are the following:'
- "C(<container id>): contains the container of this ID." - 'C(<container id>): contains the container of this ID.'
- "C(<container name>): contains the container that has this name." - 'C(<container name>): contains the container that has this name.'
- "C(<container short id>): contains the containers that have this short ID (first 13 letters of ID)." - 'C(<container short id>): contains the containers that have this short ID (first 13 letters of ID).'
- "C(image_<image name>): contains the containers that have the image C(<image name>)." - 'C(image_<image name>): contains the containers that have the image C(<image name>).'
- "C(stack_<stack name>): contains the containers that belong to the stack C(<stack name>)." - 'C(stack_<stack name>): contains the containers that belong to the stack C(<stack name>).'
- "C(service_<service name>): contains the containers that belong to the service C(<service name>)" - 'C(service_<service name>): contains the containers that belong to the service C(<service name>).'
- "C(<docker_host>): contains the containers which belong to the Docker daemon O(docker_host). - 'C(<docker_host>): contains the containers which belong to the Docker daemon O(docker_host). Useful if you run this
Useful if you run this plugin against multiple Docker daemons." plugin against multiple Docker daemons.'
- "C(running): contains all containers that are running." - 'C(running): contains all containers that are running.'
- "C(stopped): contains all containers that are not running." - 'C(stopped): contains all containers that are not running.'
- If this is not set to V(true), you should use keyed groups to add the containers to groups. - If this is not set to V(true), you should use keyed groups to add the containers to groups. See the examples for how
See the examples for how to do that. to do that.
type: bool type: bool
default: false default: false
filters: filters:
version_added: 3.5.0 version_added: 3.5.0
''' """
EXAMPLES = ''' EXAMPLES = '''
# Minimal example using local Docker daemon # Minimal example using local Docker daemon
+11 -12
View File
@@ -6,7 +6,7 @@
from __future__ import (absolute_import, division, print_function) from __future__ import (absolute_import, division, print_function)
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = r''' DOCUMENTATION = r"""
name: docker_machine name: docker_machine
author: Ximon Eighteen (@ximon18) author: Ximon Eighteen (@ximon18)
short_description: Docker Machine inventory source short_description: Docker Machine inventory source
@@ -21,21 +21,20 @@ DOCUMENTATION = r'''
- The plugin sets standard host variables C(ansible_host), C(ansible_port), C(ansible_user) and C(ansible_ssh_private_key). - The plugin sets standard host variables C(ansible_host), C(ansible_port), C(ansible_user) and C(ansible_ssh_private_key).
- The plugin stores the Docker Machine 'env' output variables in C(dm_) prefixed host variables. - The plugin stores the Docker Machine 'env' output variables in C(dm_) prefixed host variables.
notes: notes:
- The configuration file must be a YAML file whose filename ends with V(docker_machine.yml) or V(docker_machine.yaml). - The configuration file must be a YAML file whose filename ends with V(docker_machine.yml) or V(docker_machine.yaml). Other
Other filenames will not be accepted. filenames will not be accepted.
options: options:
plugin: plugin:
description: token that ensures this is a source file for the C(docker_machine) plugin. description: Token that ensures this is a source file for the C(docker_machine) plugin.
required: true required: true
choices: ['docker_machine', 'community.docker.docker_machine'] choices: ['docker_machine', 'community.docker.docker_machine']
daemon_env: daemon_env:
description: description:
- Whether docker daemon connection environment variables should be fetched, and how to behave if they cannot be fetched. - Whether docker daemon connection environment variables should be fetched, and how to behave if they cannot be fetched.
- With V(require) and V(require-silently), fetch them and skip any host for which they cannot be fetched. - With V(require) and V(require-silently), fetch them and skip any host for which they cannot be fetched. A warning
A warning will be issued for any skipped host if the choice is V(require). will be issued for any skipped host if the choice is V(require).
- With V(optional) and V(optional-silently), fetch them and not skip hosts for which they cannot be fetched. - With V(optional) and V(optional-silently), fetch them and not skip hosts for which they cannot be fetched. A warning
A warning will be issued for hosts where they cannot be fetched if the choice is V(optional). will be issued for hosts where they cannot be fetched if the choice is V(optional).
- With V(skip), do not attempt to fetch the docker daemon connection environment variables. - With V(skip), do not attempt to fetch the docker daemon connection environment variables.
- If fetched successfully, the variables will be prefixed with C(dm_) and stored as host variables. - If fetched successfully, the variables will be prefixed with C(dm_) and stored as host variables.
type: str type: str
@@ -53,13 +52,13 @@ DOCUMENTATION = r'''
default: true default: true
verbose_output: verbose_output:
description: description:
- When V(true), include all available nodes metadata (for example C(Image), C(Region), C(Size)) as a JSON object - When V(true), include all available nodes metadata (for example C(Image), C(Region), C(Size)) as a JSON object named
named C(docker_machine_node_attributes). C(docker_machine_node_attributes).
type: bool type: bool
default: true default: true
filters: filters:
version_added: 3.5.0 version_added: 3.5.0
''' """
EXAMPLES = ''' EXAMPLES = '''
# Minimal example # Minimal example
+20 -26
View File
@@ -8,11 +8,11 @@ from __future__ import (absolute_import, division, print_function)
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = r''' DOCUMENTATION = r"""
name: docker_swarm name: docker_swarm
author: author:
- Stefan Heitmüller (@morph027) <stefan.heitmueller@gmx.com> - Stefan Heitmüller (@morph027) <stefan.heitmueller@gmx.com>
short_description: Ansible dynamic inventory plugin for Docker swarm nodes. short_description: Ansible dynamic inventory plugin for Docker swarm nodes
requirements: requirements:
- python >= 2.7 - python >= 2.7
- L(Docker SDK for Python,https://docker-py.readthedocs.io/en/stable/) >= 1.10.0 - L(Docker SDK for Python,https://docker-py.readthedocs.io/en/stable/) >= 1.10.0
@@ -22,30 +22,27 @@ DOCUMENTATION = r'''
description: description:
- Reads inventories from the Docker swarm API. - Reads inventories from the Docker swarm API.
- Uses a YAML configuration file that ends with V(docker_swarm.(yml|yaml\)). - Uses a YAML configuration file that ends with V(docker_swarm.(yml|yaml\)).
- "The plugin returns following groups of swarm nodes: C(all) - all hosts; C(workers) - all worker nodes; - 'The plugin returns following groups of swarm nodes: C(all) - all hosts; C(workers) - all worker nodes; C(managers) -
C(managers) - all manager nodes; C(leader) - the swarm leader node; all manager nodes; C(leader) - the swarm leader node; C(nonleaders) - all nodes except the swarm leader.'
C(nonleaders) - all nodes except the swarm leader."
notes: notes:
- The configuration file must be a YAML file whose filename ends with V(docker_swarm.yml) or V(docker_swarm.yaml). - The configuration file must be a YAML file whose filename ends with V(docker_swarm.yml) or V(docker_swarm.yaml). Other
Other filenames will not be accepted. filenames will not be accepted.
options: options:
plugin: plugin:
description: The name of this plugin, it should always be set to V(community.docker.docker_swarm) description: The name of this plugin, it should always be set to V(community.docker.docker_swarm) for this plugin to recognize
for this plugin to recognize it as its own. it as its own.
type: str type: str
required: true required: true
choices: [docker_swarm, community.docker.docker_swarm] choices: [docker_swarm, community.docker.docker_swarm]
docker_host: docker_host:
description: description:
- Socket of a Docker swarm manager node (C(tcp), C(unix)). - Socket of a Docker swarm manager node (C(tcp), C(unix)).
- "Use V(unix:///var/run/docker.sock) to connect via local socket." - Use V(unix:///var/run/docker.sock) to connect via local socket.
type: str type: str
required: true required: true
aliases: [docker_url] aliases: [docker_url]
verbose_output: verbose_output:
description: Toggle to (not) include all available nodes metadata (for example C(Platform), C(Architecture), C(OS), description: Toggle to (not) include all available nodes metadata (for example C(Platform), C(Architecture), C(OS), C(EngineVersion)).
C(EngineVersion)).
type: bool type: bool
default: true default: true
tls: tls:
@@ -53,8 +50,7 @@ DOCUMENTATION = r'''
type: bool type: bool
default: false default: false
validate_certs: validate_certs:
description: Toggle if connecting using TLS with or without verifying the authenticity of the Docker description: Toggle if connecting using TLS with or without verifying the authenticity of the Docker host server.
host server.
type: bool type: bool
default: false default: false
aliases: [tls_verify] aliases: [tls_verify]
@@ -65,8 +61,8 @@ DOCUMENTATION = r'''
ca_path: ca_path:
description: description:
- Use a CA certificate when performing server verification by providing the path to a CA certificate file. - Use a CA certificate when performing server verification by providing the path to a CA certificate file.
- This option was called O(ca_cert) and got renamed to O(ca_path) in community.docker 3.6.0. The old name has - This option was called O(ca_cert) and got renamed to O(ca_path) in community.docker 3.6.0. The old name has been added
been added as an alias and can still be used. as an alias and can still be used.
type: path type: path
aliases: [ca_cert, tls_ca_cert, cacert_path] aliases: [ca_cert, tls_ca_cert, cacert_path]
client_cert: client_cert:
@@ -74,8 +70,7 @@ DOCUMENTATION = r'''
type: path type: path
aliases: [tls_client_cert, cert_path] aliases: [tls_client_cert, cert_path]
tls_hostname: tls_hostname:
description: When verifying the authenticity of the Docker host server, provide the expected name of description: When verifying the authenticity of the Docker host server, provide the expected name of the server.
the server.
type: str type: str
api_version: api_version:
description: description:
@@ -86,8 +81,8 @@ DOCUMENTATION = r'''
timeout: timeout:
description: description:
- The maximum amount of time in seconds to wait on a response from the API. - The maximum amount of time in seconds to wait on a response from the API.
- If the value is not specified in the task, the value of environment variable E(DOCKER_TIMEOUT). - If the value is not specified in the task, the value of environment variable E(DOCKER_TIMEOUT). will be used instead.
will be used instead. If the environment variable is not set, the default value will be used. If the environment variable is not set, the default value will be used.
type: int type: int
default: 60 default: 60
aliases: [time_out] aliases: [time_out]
@@ -99,10 +94,9 @@ DOCUMENTATION = r'''
default: false default: false
version_added: 1.5.0 version_added: 1.5.0
include_host_uri: include_host_uri:
description: Toggle to return the additional attribute C(ansible_host_uri) which contains the URI of the description: Toggle to return the additional attribute C(ansible_host_uri) which contains the URI of the swarm leader
swarm leader in format of V(tcp://172.16.0.1:2376). This value may be used without additional in format of V(tcp://172.16.0.1:2376). This value may be used without additional modification as value of option O(docker_host)
modification as value of option O(docker_host) in Docker Swarm modules when connecting via API. in Docker Swarm modules when connecting via API. The port always defaults to V(2376).
The port always defaults to V(2376).
type: bool type: bool
default: false default: false
include_host_uri_port: include_host_uri_port:
@@ -110,7 +104,7 @@ DOCUMENTATION = r'''
type: int type: int
filters: filters:
version_added: 3.5.0 version_added: 3.5.0
''' """
EXAMPLES = ''' EXAMPLES = '''
# Minimal example using local docker # Minimal example using local docker
+13 -13
View File
@@ -9,25 +9,23 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = r''' DOCUMENTATION = r"""
---
module: current_container_facts module: current_container_facts
short_description: Return facts about whether the module runs in a container short_description: Return facts about whether the module runs in a container
version_added: 1.1.0 version_added: 1.1.0
description: description:
- Return facts about whether the module runs in a Docker or podman container. - Return facts about whether the module runs in a Docker or podman container.
- This module attempts a best-effort detection. There might be special cases where - This module attempts a best-effort detection. There might be special cases where it does not work; if you encounter one,
it does not work; if you encounter one, L(please file an issue, L(please file an issue, https://github.com/ansible-collections/community.docker/issues/new?assignees=&labels=&template=bug_report.md).
https://github.com/ansible-collections/community.docker/issues/new?assignees=&labels=&template=bug_report.md).
author: author:
- Felix Fontein (@felixfontein) - Felix Fontein (@felixfontein)
extends_documentation_fragment: extends_documentation_fragment:
- community.docker.attributes - community.docker.attributes
- community.docker.attributes.facts - community.docker.attributes.facts
- community.docker.attributes.facts_module - community.docker.attributes.facts_module
''' """
EXAMPLES = ''' EXAMPLES = r"""
- name: Get facts on current container - name: Get facts on current container
community.docker.current_container_facts: community.docker.current_container_facts:
@@ -35,11 +33,11 @@ EXAMPLES = '''
ansible.builtin.debug: ansible.builtin.debug:
msg: "Container ID is {{ ansible_module_container_id }}" msg: "Container ID is {{ ansible_module_container_id }}"
when: ansible_module_running_in_container when: ansible_module_running_in_container
''' """
RETURN = r''' RETURN = r"""
ansible_facts: ansible_facts:
description: Ansible facts returned by the module description: Ansible facts returned by the module.
type: dict type: dict
returned: always returned: always
contains: contains:
@@ -60,8 +58,10 @@ ansible_facts:
- Contains an empty string if no container was detected, or a non-empty string identifying the container environment. - Contains an empty string if no container was detected, or a non-empty string identifying the container environment.
- V(docker) indicates that the module ran inside a regular Docker container. - V(docker) indicates that the module ran inside a regular Docker container.
- V(azure_pipelines) indicates that the module ran on Azure Pipelines. This seems to no longer be reported. - V(azure_pipelines) indicates that the module ran on Azure Pipelines. This seems to no longer be reported.
- V(github_actions) indicates that the module ran inside a Docker container on GitHub Actions. It is supported since community.docker 2.4.0. - V(github_actions) indicates that the module ran inside a Docker container on GitHub Actions. It is supported since
- V(podman) indicates that the module ran inside a regular Podman container. It is supported since community.docker 3.3.0. community.docker 2.4.0.
- V(podman) indicates that the module ran inside a regular Podman container. It is supported since community.docker
3.3.0.
returned: always returned: always
type: str type: str
choices: choices:
@@ -70,7 +70,7 @@ ansible_facts:
- azure_pipelines - azure_pipelines
- github_actions - github_actions
- podman - podman
''' """
import os import os
import re import re
+18 -17
View File
@@ -10,8 +10,7 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = r"""
module: docker_compose_v2 module: docker_compose_v2
short_description: Manage multi-container Docker applications with Docker Compose CLI plugin short_description: Manage multi-container Docker applications with Docker Compose CLI plugin
@@ -20,7 +19,6 @@ version_added: 3.6.0
description: description:
- Uses Docker Compose to start or shutdown services. - Uses Docker Compose to start or shutdown services.
extends_documentation_fragment: extends_documentation_fragment:
- community.docker.compose_v2 - community.docker.compose_v2
- community.docker.compose_v2.minimum_version - community.docker.compose_v2.minimum_version
@@ -56,7 +54,8 @@ options:
- Whether to pull images before running. This is used when C(docker compose up) is run. - Whether to pull images before running. This is used when C(docker compose up) is run.
- V(always) ensures that the images are always pulled, even when already present on the Docker daemon. - V(always) ensures that the images are always pulled, even when already present on the Docker daemon.
- V(missing) only pulls them when they are not present on the Docker daemon. - V(missing) only pulls them when they are not present on the Docker daemon.
- V(never) never pulls images. If they are not present, the module will fail when trying to create the containers that need them. - V(never) never pulls images. If they are not present, the module will fail when trying to create the containers that
need them.
- V(policy) use the Compose file's C(pull_policy) defined for the service to figure out what to do. - V(policy) use the Compose file's C(pull_policy) defined for the service to figure out what to do.
type: str type: str
choices: choices:
@@ -68,8 +67,10 @@ options:
build: build:
description: description:
- Whether to build images before starting containers. This is used when C(docker compose up) is run. - Whether to build images before starting containers. This is used when C(docker compose up) is run.
- V(always) always builds before starting containers. This is equivalent to the C(--build) option of C(docker compose up). - V(always) always builds before starting containers. This is equivalent to the C(--build) option of C(docker compose
- V(never) never builds before starting containers. This is equivalent to the C(--no-build) option of C(docker compose up). up).
- V(never) never builds before starting containers. This is equivalent to the C(--no-build) option of C(docker compose
up).
- V(policy) uses the policy as defined in the Compose file. - V(policy) uses the policy as defined in the Compose file.
type: str type: str
choices: choices:
@@ -85,10 +86,10 @@ options:
ignore_build_events: ignore_build_events:
description: description:
- Ignores image building events for change detection. - Ignores image building events for change detection.
- If O(state=present) and O(ignore_build_events=true) and O(build=always), a rebuild that does - If O(state=present) and O(ignore_build_events=true) and O(build=always), a rebuild that does not trigger a container
not trigger a container restart no longer results in RV(ignore:changed=true). restart no longer results in RV(ignore:changed=true).
- Note that Docker Compose 2.31.0 is the first Compose 2.x version to emit build events. - Note that Docker Compose 2.31.0 is the first Compose 2.x version to emit build events. For older versions, the behavior
For older versions, the behavior is always as if O(ignore_build_events=true). is always as if O(ignore_build_events=true).
type: bool type: bool
default: true default: true
version_added: 4.2.0 version_added: 4.2.0
@@ -139,8 +140,8 @@ options:
scale: scale:
description: description:
- Define how to scale services when running C(docker compose up). - Define how to scale services when running C(docker compose up).
- Provide a dictionary of key/value pairs where the key is the name of the service - Provide a dictionary of key/value pairs where the key is the name of the service and the value is an integer count
and the value is an integer count for the number of containers. for the number of containers.
type: dict type: dict
version_added: 3.7.0 version_added: 3.7.0
wait: wait:
@@ -161,9 +162,9 @@ author:
seealso: seealso:
- module: community.docker.docker_compose_v2_pull - module: community.docker.docker_compose_v2_pull
''' """
EXAMPLES = ''' EXAMPLES = r"""
# Examples use the django example at https://docs.docker.com/compose/django. Follow it to create the # Examples use the django example at https://docs.docker.com/compose/django. Follow it to create the
# flask directory # flask directory
@@ -238,9 +239,9 @@ EXAMPLES = '''
{{ output.containers | selectattr("Service", "equalto", "web") | first }} {{ output.containers | selectattr("Service", "equalto", "web") | first }}
db_container: >- db_container: >-
{{ output.containers | selectattr("Service", "equalto", "db") | first }} {{ output.containers | selectattr("Service", "equalto", "db") | first }}
''' """
RETURN = ''' RETURN = r"""
containers: containers:
description: description:
- A list of containers associated to the service. - A list of containers associated to the service.
@@ -420,7 +421,7 @@ actions:
- Recreating - Recreating
- Pulling - Pulling
- Building - Building
''' """
import traceback import traceback
+15 -17
View File
@@ -8,8 +8,7 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = r"""
module: docker_compose_v2_exec module: docker_compose_v2_exec
short_description: Run command in a container of a Compose service short_description: Run command in a container of a Compose service
@@ -18,9 +17,7 @@ version_added: 3.13.0
description: description:
- Uses Docker Compose to run a command in a service's container. - Uses Docker Compose to run a command in a service's container.
- This can be used to run one-off commands in an existing service's container, - This can be used to run one-off commands in an existing service's container, and encapsulates C(docker compose exec).
and encapsulates C(docker compose exec).
extends_documentation_fragment: extends_documentation_fragment:
- community.docker.compose_v2 - community.docker.compose_v2
- community.docker.compose_v2.minimum_version - community.docker.compose_v2.minimum_version
@@ -63,8 +60,7 @@ options:
detach: detach:
description: description:
- Whether to run the command synchronously (O(detach=false), default) or asynchronously (O(detach=true)). - Whether to run the command synchronously (O(detach=false), default) or asynchronously (O(detach=true)).
- If set to V(true), O(stdin) cannot be provided, and the return values RV(stdout), RV(stderr), and - If set to V(true), O(stdin) cannot be provided, and the return values RV(stdout), RV(stderr), and RV(rc) are not returned.
RV(rc) are not returned.
type: bool type: bool
default: false default: false
user: user:
@@ -99,9 +95,11 @@ options:
env: env:
description: description:
- Dictionary of environment variables with their respective values to be passed to the command ran inside the container. - Dictionary of environment variables with their respective values to be passed to the command ran inside the container.
- Values which might be parsed as numbers, booleans or other types by the YAML parser must be quoted (for example V("true")) in order to avoid data loss. - Values which might be parsed as numbers, booleans or other types by the YAML parser must be quoted (for example V("true"))
- Please note that if you are passing values in with Jinja2 templates, like V("{{ value }}"), you need to add V(| string) to prevent Ansible to in order to avoid data loss.
convert strings such as V("true") back to booleans. The correct way is to use V("{{ value | string }}"). - Please note that if you are passing values in with Jinja2 templates, like V("{{ value }}"), you need to add V(| string)
to prevent Ansible to convert strings such as V("true") back to booleans. The correct way is to use V("{{ value |
string }}").
type: dict type: dict
author: author:
@@ -111,11 +109,11 @@ seealso:
- module: community.docker.docker_compose_v2 - module: community.docker.docker_compose_v2
notes: notes:
- If you need to evaluate environment variables of the container in O(command) or O(argv), you need to pass the command through a shell, - If you need to evaluate environment variables of the container in O(command) or O(argv), you need to pass the command
like O(command=/bin/sh -c "echo $ENV_VARIABLE"). through a shell, like O(command=/bin/sh -c "echo $ENV_VARIABLE").
''' """
EXAMPLES = ''' EXAMPLES = r"""
- name: Run a simple command (command) - name: Run a simple command (command)
community.docker.docker_compose_v2_exec: community.docker.docker_compose_v2_exec:
service: foo service: foo
@@ -140,9 +138,9 @@ EXAMPLES = '''
- name: Print stderr lines - name: Print stderr lines
ansible.builtin.debug: ansible.builtin.debug:
var: result.stderr_lines var: result.stderr_lines
''' """
RETURN = ''' RETURN = r"""
stdout: stdout:
type: str type: str
returned: success and O(detach=false) returned: success and O(detach=false)
@@ -159,7 +157,7 @@ rc:
sample: 0 sample: 0
description: description:
- The exit code of the command. - The exit code of the command.
''' """
import shlex import shlex
import traceback import traceback
+10 -12
View File
@@ -8,8 +8,7 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = r"""
module: docker_compose_v2_pull module: docker_compose_v2_pull
short_description: Pull a Docker compose project short_description: Pull a Docker compose project
@@ -18,7 +17,6 @@ version_added: 3.6.0
description: description:
- Uses Docker Compose to pull images for a project. - Uses Docker Compose to pull images for a project.
extends_documentation_fragment: extends_documentation_fragment:
- community.docker.compose_v2 - community.docker.compose_v2
- community.docker.compose_v2.minimum_version - community.docker.compose_v2.minimum_version
@@ -30,9 +28,8 @@ attributes:
check_mode: check_mode:
support: full support: full
details: details:
- If O(policy=always), the module will always indicate a change. - If O(policy=always), the module will always indicate a change. Docker Compose does not give any information whether
Docker Compose does not give any information whether pulling would pulling would update the image or not.
update the image or not.
diff_mode: diff_mode:
support: none support: none
@@ -41,7 +38,8 @@ options:
description: description:
- Whether to pull images before running. This is used when C(docker compose up) is ran. - Whether to pull images before running. This is used when C(docker compose up) is ran.
- V(always) ensures that the images are always pulled, even when already present on the Docker daemon. - V(always) ensures that the images are always pulled, even when already present on the Docker daemon.
- V(missing) only pulls them when they are not present on the Docker daemon. This is only supported since Docker Compose 2.22.0. - V(missing) only pulls them when they are not present on the Docker daemon. This is only supported since Docker Compose
2.22.0.
type: str type: str
choices: choices:
- always - always
@@ -72,15 +70,15 @@ author:
seealso: seealso:
- module: community.docker.docker_compose_v2 - module: community.docker.docker_compose_v2
''' """
EXAMPLES = ''' EXAMPLES = r"""
- name: Pull images for flask project - name: Pull images for flask project
community.docker.docker_compose_v2_pull: community.docker.docker_compose_v2_pull:
project_src: /path/to/flask project_src: /path/to/flask
''' """
RETURN = ''' RETURN = r"""
actions: actions:
description: description:
- A list of actions that have been applied. - A list of actions that have been applied.
@@ -108,7 +106,7 @@ actions:
sample: Pulling sample: Pulling
choices: choices:
- Pulling - Pulling
''' """
import traceback import traceback
+15 -15
View File
@@ -8,8 +8,7 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = r"""
module: docker_compose_v2_run module: docker_compose_v2_run
short_description: Run command in a new container of a Compose service short_description: Run command in a new container of a Compose service
@@ -19,7 +18,6 @@ version_added: 3.13.0
description: description:
- Uses Docker Compose to run a command in a new container for a service. - Uses Docker Compose to run a command in a new container for a service.
- This encapsulates C(docker compose run). - This encapsulates C(docker compose run).
extends_documentation_fragment: extends_documentation_fragment:
- community.docker.compose_v2 - community.docker.compose_v2
- community.docker.compose_v2.minimum_version - community.docker.compose_v2.minimum_version
@@ -134,8 +132,8 @@ options:
detach: detach:
description: description:
- Whether to run the command synchronously (O(detach=false), default) or asynchronously (O(detach=true)). - Whether to run the command synchronously (O(detach=false), default) or asynchronously (O(detach=true)).
- If set to V(true), O(stdin) cannot be provided, and the return values RV(stdout), RV(stderr), and - If set to V(true), O(stdin) cannot be provided, and the return values RV(stdout), RV(stderr), and RV(rc) are not returned.
RV(rc) are not returned. Instead, the return value RV(container_id) is provided. Instead, the return value RV(container_id) is provided.
type: bool type: bool
default: false default: false
user: user:
@@ -165,9 +163,11 @@ options:
env: env:
description: description:
- Dictionary of environment variables with their respective values to be passed to the command ran inside the container. - Dictionary of environment variables with their respective values to be passed to the command ran inside the container.
- Values which might be parsed as numbers, booleans or other types by the YAML parser must be quoted (for example V("true")) in order to avoid data loss. - Values which might be parsed as numbers, booleans or other types by the YAML parser must be quoted (for example V("true"))
- Please note that if you are passing values in with Jinja2 templates, like V("{{ value }}"), you need to add V(| string) to prevent Ansible to in order to avoid data loss.
convert strings such as V("true") back to booleans. The correct way is to use V("{{ value | string }}"). - Please note that if you are passing values in with Jinja2 templates, like V("{{ value }}"), you need to add V(| string)
to prevent Ansible to convert strings such as V("true") back to booleans. The correct way is to use V("{{ value |
string }}").
type: dict type: dict
author: author:
@@ -177,11 +177,11 @@ seealso:
- module: community.docker.docker_compose_v2 - module: community.docker.docker_compose_v2
notes: notes:
- If you need to evaluate environment variables of the container in O(command) or O(argv), you need to pass the command through a shell, - If you need to evaluate environment variables of the container in O(command) or O(argv), you need to pass the command
like O(command=/bin/sh -c "echo $ENV_VARIABLE"). through a shell, like O(command=/bin/sh -c "echo $ENV_VARIABLE").
''' """
EXAMPLES = ''' EXAMPLES = r"""
- name: Run a simple command (command) - name: Run a simple command (command)
community.docker.docker_compose_v2_run: community.docker.docker_compose_v2_run:
service: foo service: foo
@@ -206,9 +206,9 @@ EXAMPLES = '''
- name: Print stderr lines - name: Print stderr lines
ansible.builtin.debug: ansible.builtin.debug:
var: result.stderr_lines var: result.stderr_lines
''' """
RETURN = ''' RETURN = r"""
container_id: container_id:
type: str type: str
returned: success and O(detach=true) returned: success and O(detach=true)
@@ -230,7 +230,7 @@ rc:
sample: 0 sample: 0
description: description:
- The exit code of the command. - The exit code of the command.
''' """
import shlex import shlex
import traceback import traceback
+15 -19
View File
@@ -8,19 +8,17 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = r"""
---
module: docker_config module: docker_config
short_description: Manage docker configs. short_description: Manage docker configs
description: description:
- Create and remove Docker configs in a Swarm environment. Similar to C(docker config create) and C(docker config rm). - Create and remove Docker configs in a Swarm environment. Similar to C(docker config create) and C(docker config rm).
- Adds to the metadata of new configs 'ansible_key', an encrypted hash representation of the data, which is then used - Adds to the metadata of new configs 'ansible_key', an encrypted hash representation of the data, which is then used in
in future runs to test if a config has changed. If 'ansible_key' is not present, then a config will not be updated future runs to test if a config has changed. If 'ansible_key' is not present, then a config will not be updated unless
unless the O(force) option is set. the O(force) option is set.
- Updates to configs are performed by removing the config and creating it again. - Updates to configs are performed by removing the config and creating it again.
extends_documentation_fragment: extends_documentation_fragment:
- community.docker.docker - community.docker.docker
- community.docker.docker.docker_py_2_documentation - community.docker.docker.docker_py_2_documentation
@@ -41,10 +39,8 @@ options:
type: str type: str
data_is_b64: data_is_b64:
description: description:
- If set to V(true), the data is assumed to be Base64 encoded and will be - If set to V(true), the data is assumed to be Base64 encoded and will be decoded before being used.
decoded before being used. - To use binary O(data), it is better to keep it Base64 encoded and let it be decoded by this option.
- To use binary O(data), it is better to keep it Base64 encoded and let it
be decoded by this option.
type: bool type: bool
default: false default: false
data_src: data_src:
@@ -55,8 +51,9 @@ options:
version_added: 1.10.0 version_added: 1.10.0
labels: labels:
description: description:
- "A map of key:value meta data, where both the C(key) and C(value) are expected to be a string." - A map of key:value meta data, where both the C(key) and C(value) are expected to be a string.
- If new meta data is provided, or existing meta data is modified, the config will be updated by removing it and creating it again. - If new meta data is provided, or existing meta data is modified, the config will be updated by removing it and creating
it again.
type: dict type: dict
force: force:
description: description:
@@ -107,10 +104,9 @@ requirements:
author: author:
- Chris Houseknecht (@chouseknecht) - Chris Houseknecht (@chouseknecht)
- John Hu (@ushuz) - John Hu (@ushuz)
''' """
EXAMPLES = '''
EXAMPLES = r"""
- name: Create config foo (from a file on the control machine) - name: Create config foo (from a file on the control machine)
community.docker.docker_config: community.docker.docker_config:
name: foo name: foo
@@ -177,9 +173,9 @@ EXAMPLES = '''
community.docker.docker_config: community.docker.docker_config:
name: foo name: foo
state: absent state: absent
''' """
RETURN = ''' RETURN = r"""
config_id: config_id:
description: description:
- The ID assigned by Docker to the config object. - The ID assigned by Docker to the config object.
@@ -193,7 +189,7 @@ config_name:
type: str type: str
sample: 'awesome_config' sample: 'awesome_config'
version_added: 2.2.0 version_added: 2.2.0
''' """
import base64 import base64
import hashlib import hashlib
+222 -280
View File
@@ -8,8 +8,7 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = r"""
---
module: docker_container module: docker_container
short_description: manage Docker containers short_description: manage Docker containers
@@ -17,15 +16,13 @@ short_description: manage Docker containers
description: description:
- Manage the life cycle of Docker containers. - Manage the life cycle of Docker containers.
- Supports check mode. Run with C(--check) and C(--diff) to view config difference and list of actions to be taken. - Supports check mode. Run with C(--check) and C(--diff) to view config difference and list of actions to be taken.
notes: notes:
- For most config changes, the container needs to be recreated. This means that the existing container has to be destroyed and - For most config changes, the container needs to be recreated. This means that the existing container has to be destroyed
a new one created. This can cause unexpected data loss and downtime. You can use the O(comparisons) option to and a new one created. This can cause unexpected data loss and downtime. You can use the O(comparisons) option to prevent
prevent this. this.
- If the module needs to recreate the container, it will only use the options provided to the module to create the - If the module needs to recreate the container, it will only use the options provided to the module to create the new container
new container (except O(image)). Therefore, always specify B(all) options relevant to the container. (except O(image)). Therefore, always specify B(all) options relevant to the container.
- When O(restart) is set to V(true), the module will only restart the container if no config changes are detected. - When O(restart) is set to V(true), the module will only restart the container if no config changes are detected.
extends_documentation_fragment: extends_documentation_fragment:
- community.docker.docker.api_documentation - community.docker.docker.api_documentation
- community.docker.attributes - community.docker.attributes
@@ -35,7 +32,8 @@ attributes:
check_mode: check_mode:
support: partial support: partial
details: details:
- When trying to pull an image, the module assumes this is never changed in check mode except when the image is not present on the Docker daemon. - When trying to pull an image, the module assumes this is never changed in check mode except when the image is not
present on the Docker daemon.
- This behavior can be configured with O(pull_check_mode_behavior). - This behavior can be configured with O(pull_check_mode_behavior).
diff_mode: diff_mode:
support: full support: full
@@ -88,34 +86,29 @@ options:
type: raw type: raw
comparisons: comparisons:
description: description:
- Allows to specify how properties of existing containers are compared with - Allows to specify how properties of existing containers are compared with module options to decide whether the container
module options to decide whether the container should be recreated / updated should be recreated / updated or not.
or not. - Only options which correspond to the state of a container as handled by the Docker daemon can be specified, as well
- Only options which correspond to the state of a container as handled by the as O(networks).
Docker daemon can be specified, as well as O(networks). - Must be a dictionary specifying for an option one of the keys V(strict), V(ignore) and V(allow_more_present).
- Must be a dictionary specifying for an option one of the keys V(strict), V(ignore) - If V(strict) is specified, values are tested for equality, and changes always result in updating or restarting. If
and V(allow_more_present). V(ignore) is specified, changes are ignored.
- If V(strict) is specified, values are tested for equality, and changes always - V(allow_more_present) is allowed only for lists, sets and dicts. If it is specified for lists or sets, the container
result in updating or restarting. If V(ignore) is specified, changes are ignored. will only be updated or restarted if the module option contains a value which is not present in the container's options.
- V(allow_more_present) is allowed only for lists, sets and dicts. If it is If the option is specified for a dict, the container will only be updated or restarted if the module option contains
specified for lists or sets, the container will only be updated or restarted if a key which is not present in the container's option, or if the value of a key present differs.
the module option contains a value which is not present in the container's - The wildcard option C(*) can be used to set one of the default values V(strict) or V(ignore) to I(all) comparisons
options. If the option is specified for a dict, the container will only be updated which are not explicitly set to other values.
or restarted if the module option contains a key which is not present in the
container's option, or if the value of a key present differs.
- The wildcard option C(*) can be used to set one of the default values V(strict)
or V(ignore) to I(all) comparisons which are not explicitly set to other values.
- See the examples for details. - See the examples for details.
type: dict type: dict
container_default_behavior: container_default_behavior:
description: description:
- In older versions of this module, various module options used to have default values. - In older versions of this module, various module options used to have default values. This caused problems with containers
This caused problems with containers which use different values for these options. which use different values for these options.
- The default value is now V(no_defaults). To restore the old behavior, set it to - The default value is now V(no_defaults). To restore the old behavior, set it to V(compatibility), which will ensure
V(compatibility), which will ensure that the default values are used when the values that the default values are used when the values are not explicitly specified by the user.
are not explicitly specified by the user. - This affects the O(auto_remove), O(detach), O(init), O(interactive), O(memory), O(paused), O(privileged), O(read_only),
- This affects the O(auto_remove), O(detach), O(init), O(interactive), O(memory), and O(tty) options.
O(paused), O(privileged), O(read_only), and O(tty) options.
type: str type: str
choices: choices:
- compatibility - compatibility
@@ -123,17 +116,16 @@ options:
default: no_defaults default: no_defaults
command_handling: command_handling:
description: description:
- The default behavior for O(command) (when provided as a list) and O(entrypoint) is to - The default behavior for O(command) (when provided as a list) and O(entrypoint) is to convert them to strings without
convert them to strings without considering shell quoting rules. (For comparing idempotency, considering shell quoting rules. (For comparing idempotency, the resulting string is split considering shell quoting
the resulting string is split considering shell quoting rules.) rules).
- Also, setting O(command) to an empty list of string, and setting O(entrypoint) to an empty - Also, setting O(command) to an empty list of string, and setting O(entrypoint) to an empty list will be handled as
list will be handled as if these options are not specified. This is different from idempotency if these options are not specified. This is different from idempotency handling for other container-config related
handling for other container-config related options. options.
- When this is set to V(compatibility), which was the default until community.docker 3.0.0, the - When this is set to V(compatibility), which was the default until community.docker 3.0.0, the current behavior will
current behavior will be kept. be kept.
- When this is set to V(correct), these options are kept as lists, and an empty value or empty - When this is set to V(correct), these options are kept as lists, and an empty value or empty list will be handled
list will be handled correctly for idempotency checks. This has been the default since correctly for idempotency checks. This has been the default since community.docker 3.0.0.
community.docker 3.0.0.
type: str type: str
choices: choices:
- compatibility - compatibility
@@ -172,12 +164,11 @@ options:
description: description:
- Define the default host IP to use. - Define the default host IP to use.
- Must be an empty string, an IPv4 address, or an IPv6 address. - Must be an empty string, an IPv4 address, or an IPv6 address.
- With Docker 20.10.2 or newer, this should be set to an empty string (V("")) to avoid the - With Docker 20.10.2 or newer, this should be set to an empty string (V("")) to avoid the port bindings without an
port bindings without an explicit IP address to only bind to IPv4. explicit IP address to only bind to IPv4. See U(https://github.com/ansible-collections/community.docker/issues/70)
See U(https://github.com/ansible-collections/community.docker/issues/70) for details. for details.
- By default, the module will try to auto-detect this value from the C(bridge) network's - By default, the module will try to auto-detect this value from the C(bridge) network's C(com.docker.network.bridge.host_binding_ipv4)
C(com.docker.network.bridge.host_binding_ipv4) option. If it cannot auto-detect it, it option. If it cannot auto-detect it, it will fall back to V(0.0.0.0).
will fall back to V(0.0.0.0).
type: str type: str
version_added: 1.2.0 version_added: 1.2.0
detach: detach:
@@ -189,12 +180,12 @@ options:
devices: devices:
description: description:
- List of host device bindings to add to the container. - List of host device bindings to add to the container.
- "Each binding is a mapping expressed in the format C(<path_on_host>:<path_in_container>:<cgroup_permissions>)." - Each binding is a mapping expressed in the format C(<path_on_host>:<path_in_container>:<cgroup_permissions>).
type: list type: list
elements: str elements: str
device_read_bps: device_read_bps:
description: description:
- "List of device path and read rate (bytes per second) from device." - List of device path and read rate (bytes per second) from device.
type: list type: list
elements: dict elements: dict
suboptions: suboptions:
@@ -205,15 +196,15 @@ options:
required: true required: true
rate: rate:
description: description:
- "Device read limit in format C(<number>[<unit>])." - Device read limit in format C(<number>[<unit>]).
- "Number is a positive integer. Unit can be one of V(B) (byte), V(K) (kibibyte, 1024B), V(M) (mebibyte), V(G) (gibibyte), - Number is a positive integer. Unit can be one of V(B) (byte), V(K) (kibibyte, 1024B), V(M) (mebibyte), V(G) (gibibyte),
V(T) (tebibyte), or V(P) (pebibyte)." V(T) (tebibyte), or V(P) (pebibyte).
- "Omitting the unit defaults to bytes." - Omitting the unit defaults to bytes.
type: str type: str
required: true required: true
device_write_bps: device_write_bps:
description: description:
- "List of device and write rate (bytes per second) to device." - List of device and write rate (bytes per second) to device.
type: list type: list
elements: dict elements: dict
suboptions: suboptions:
@@ -224,15 +215,15 @@ options:
required: true required: true
rate: rate:
description: description:
- "Device read limit in format C(<number>[<unit>])." - Device read limit in format C(<number>[<unit>]).
- "Number is a positive integer. Unit can be one of V(B) (byte), V(K) (kibibyte, 1024B), V(M) (mebibyte), V(G) (gibibyte), - Number is a positive integer. Unit can be one of V(B) (byte), V(K) (kibibyte, 1024B), V(M) (mebibyte), V(G) (gibibyte),
V(T) (tebibyte), or V(P) (pebibyte)." V(T) (tebibyte), or V(P) (pebibyte).
- "Omitting the unit defaults to bytes." - Omitting the unit defaults to bytes.
type: str type: str
required: true required: true
device_read_iops: device_read_iops:
description: description:
- "List of device and read rate (IO per second) from device." - List of device and read rate (IO per second) from device.
type: list type: list
elements: dict elements: dict
suboptions: suboptions:
@@ -243,13 +234,13 @@ options:
required: true required: true
rate: rate:
description: description:
- "Device read limit." - Device read limit.
- "Must be a positive integer." - Must be a positive integer.
type: int type: int
required: true required: true
device_write_iops: device_write_iops:
description: description:
- "List of device and write rate (IO per second) to device." - List of device and write rate (IO per second) to device.
type: list type: list
elements: dict elements: dict
suboptions: suboptions:
@@ -260,8 +251,8 @@ options:
required: true required: true
rate: rate:
description: description:
- "Device read limit." - Device read limit.
- "Must be a positive integer." - Must be a positive integer.
type: int type: int
required: true required: true
device_requests: device_requests:
@@ -273,11 +264,10 @@ options:
capabilities: capabilities:
description: description:
- List of lists of strings to request capabilities. - List of lists of strings to request capabilities.
- The top-level list entries are combined by OR, and for every list entry, - The top-level list entries are combined by OR, and for every list entry, the entries in the list it contains are
the entries in the list it contains are combined by AND. combined by AND.
- The driver tries to satisfy one of the sub-lists. - The driver tries to satisfy one of the sub-lists.
- Available capabilities for the C(nvidia) driver can be found at - Available capabilities for the C(nvidia) driver can be found at U(https://github.com/NVIDIA/nvidia-container-runtime).
U(https://github.com/NVIDIA/nvidia-container-runtime).
type: list type: list
elements: list elements: list
count: count:
@@ -327,9 +317,11 @@ options:
env: env:
description: description:
- Dictionary of key,value pairs. - Dictionary of key,value pairs.
- Values which might be parsed as numbers, booleans or other types by the YAML parser must be quoted (for example V("true")) in order to avoid data loss. - Values which might be parsed as numbers, booleans or other types by the YAML parser must be quoted (for example V("true"))
- Please note that if you are passing values in with Jinja2 templates, like V("{{ value }}"), you need to add V(| string) to prevent Ansible to in order to avoid data loss.
convert strings such as V("true") back to booleans. The correct way is to use V("{{ value | string }}"). - Please note that if you are passing values in with Jinja2 templates, like V("{{ value }}"), you need to add V(| string)
to prevent Ansible to convert strings such as V("true") back to booleans. The correct way is to use V("{{ value |
string }}").
type: dict type: dict
env_file: env_file:
description: description:
@@ -344,18 +336,16 @@ options:
elements: str elements: str
etc_hosts: etc_hosts:
description: description:
- Dict of host-to-IP mappings, where each host name is a key in the dictionary. - Dict of host-to-IP mappings, where each host name is a key in the dictionary. Each host name will be added to the
Each host name will be added to the container's C(/etc/hosts) file. container's C(/etc/hosts) file.
- Instead of an IP address, the special value V(host-gateway) can also be used, which - Instead of an IP address, the special value V(host-gateway) can also be used, which resolves to the host's gateway
resolves to the host's gateway IP and allows containers to connect to services running IP and allows containers to connect to services running on the host.
on the host.
type: dict type: dict
exposed_ports: exposed_ports:
description: description:
- List of additional container ports which informs Docker that the container - List of additional container ports which informs Docker that the container listens on the specified network ports
listens on the specified network ports at runtime. at runtime.
- If the port is already exposed using C(EXPOSE) in a Dockerfile, it does not - If the port is already exposed using C(EXPOSE) in a Dockerfile, it does not need to be exposed again.
need to be exposed again.
type: list type: list
elements: str elements: str
aliases: aliases:
@@ -376,11 +366,11 @@ options:
healthcheck: healthcheck:
description: description:
- Configure a check that is run to determine whether or not containers for this service are "healthy". - Configure a check that is run to determine whether or not containers for this service are "healthy".
- "See the docs for the L(HEALTHCHECK Dockerfile instruction,https://docs.docker.com/engine/reference/builder/#healthcheck) - See the docs for the L(HEALTHCHECK Dockerfile instruction,https://docs.docker.com/engine/reference/builder/#healthcheck)
for details on how healthchecks work." for details on how healthchecks work.
- "O(healthcheck.interval), O(healthcheck.timeout), O(healthcheck.start_period), and O(healthcheck.start_interval) are specified as durations. - 'O(healthcheck.interval), O(healthcheck.timeout), O(healthcheck.start_period), and O(healthcheck.start_interval) are
They accept duration as a string in a format that look like: V(5h34m56s), V(1m30s), and so on. specified as durations. They accept duration as a string in a format that look like: V(5h34m56s), V(1m30s), and so
The supported units are V(us), V(ms), V(s), V(m) and V(h)." on. The supported units are V(us), V(ms), V(s), V(m) and V(h).'
- See also O(state=healthy). - See also O(state=healthy).
type: dict type: dict
suboptions: suboptions:
@@ -392,10 +382,10 @@ options:
test_cli_compatible: test_cli_compatible:
description: description:
- If set to V(true), omitting O(healthcheck.test) while providing O(healthcheck) does not disable healthchecks, - If set to V(true), omitting O(healthcheck.test) while providing O(healthcheck) does not disable healthchecks,
but simply overwrites the image's values by the ones specified in O(healthcheck). This is but simply overwrites the image's values by the ones specified in O(healthcheck). This is the behavior used by
the behavior used by the Docker CLI. the Docker CLI.
- If set to V(false), omitting O(healthcheck.test) will disable the container's health check. - If set to V(false), omitting O(healthcheck.test) will disable the container's health check. This is the classical
This is the classical behavior of the module and currently the default behavior. behavior of the module and currently the default behavior.
default: false default: false
type: bool type: bool
version_added: 3.10.0 version_added: 3.10.0
@@ -431,17 +421,17 @@ options:
type: str type: str
image: image:
description: description:
- Repository path and tag used to create the container. If an image is not found or pull is true, the image - Repository path and tag used to create the container. If an image is not found or pull is true, the image will be
will be pulled from the registry. If no tag is included, V(latest) will be used. pulled from the registry. If no tag is included, V(latest) will be used.
- Can also be an image ID. If this is the case, the image is assumed to be available locally. - Can also be an image ID. If this is the case, the image is assumed to be available locally. The O(pull) option is
The O(pull) option is ignored for this case. ignored for this case.
type: str type: str
image_comparison: image_comparison:
description: description:
- Determines which image to use for idempotency checks that depend on image parameters. - Determines which image to use for idempotency checks that depend on image parameters.
- The default, V(desired-image), will use the image that is provided to the module via the O(image) parameter. - The default, V(desired-image), will use the image that is provided to the module via the O(image) parameter.
- V(current-image) will use the image that the container is currently using, if the container exists. It - V(current-image) will use the image that the container is currently using, if the container exists. It falls back
falls back to the image that is provided in case the container does not yet exist. to the image that is provided in case the container does not yet exist.
- This affects the O(env), O(env_file), O(exposed_ports), O(labels), and O(volumes) options. - This affects the O(env), O(env_file), O(exposed_ports), O(labels), and O(volumes) options.
type: str type: str
choices: choices:
@@ -452,13 +442,11 @@ options:
image_label_mismatch: image_label_mismatch:
description: description:
- How to handle labels inherited from the image that are not set explicitly. - How to handle labels inherited from the image that are not set explicitly.
- When V(ignore), labels that are present in the image but not specified in O(labels) will be - When V(ignore), labels that are present in the image but not specified in O(labels) will be ignored. This is useful
ignored. This is useful to avoid having to specify the image labels in O(labels) while keeping to avoid having to specify the image labels in O(labels) while keeping labels O(comparisons) V(strict).
labels O(comparisons) V(strict). - When V(fail), if there are labels present in the image which are not set from O(labels), the module will fail. This
- When V(fail), if there are labels present in the image which are not set from O(labels), the prevents introducing unexpected labels from the base image.
module will fail. This prevents introducing unexpected labels from the base image. - 'B(Warning:) This option is ignored unless C(labels: strict) or C(*: strict) is specified in the O(comparisons) option.'
- "B(Warning:) This option is ignored unless C(labels: strict) or C(*: strict) is specified in
the O(comparisons) option."
type: str type: str
choices: choices:
- 'ignore' - 'ignore'
@@ -467,9 +455,9 @@ options:
version_added: 2.6.0 version_added: 2.6.0
image_name_mismatch: image_name_mismatch:
description: description:
- Determines what the module does if the image matches, but the image name in the container's configuration - Determines what the module does if the image matches, but the image name in the container's configuration does not
does not match the image name provided to the module. match the image name provided to the module.
- "This is ignored if C(image: ignore) is set in O(comparisons)." - 'This is ignored if C(image: ignore) is set in O(comparisons).'
- If set to V(recreate) (default) the container will be recreated. - If set to V(recreate) (default) the container will be recreated.
- If set to V(ignore) the container will not be recreated because of this. It might still get recreated for other reasons. - If set to V(ignore) the container will not be recreated because of this. It might still get recreated for other reasons.
This has been the default behavior of the module for a long time, but might not be what users expect. This has been the default behavior of the module for a long time, but might not be what users expect.
@@ -493,8 +481,8 @@ options:
ipc_mode: ipc_mode:
description: description:
- Set the IPC mode for the container. - Set the IPC mode for the container.
- Can be one of V(container:<name|id>) to reuse another container's IPC namespace or V(host) to use - Can be one of V(container:<name|id>) to reuse another container's IPC namespace or V(host) to use the host's IPC namespace
the host's IPC namespace within the container. within the container.
type: str type: str
keep_volumes: keep_volumes:
description: description:
@@ -507,9 +495,8 @@ options:
type: str type: str
kernel_memory: kernel_memory:
description: description:
- "Kernel memory limit in format C(<number>[<unit>]). Number is a positive integer. - Kernel memory limit in format C(<number>[<unit>]). Number is a positive integer. Unit can be V(B) (byte), V(K) (kibibyte,
Unit can be V(B) (byte), V(K) (kibibyte, 1024B), V(M) (mebibyte), V(G) (gibibyte), 1024B), V(M) (mebibyte), V(G) (gibibyte), V(T) (tebibyte), or V(P) (pebibyte). Minimum is V(4M).
V(T) (tebibyte), or V(P) (pebibyte). Minimum is V(4M)."
- Omitting the unit defaults to bytes. - Omitting the unit defaults to bytes.
type: str type: str
labels: labels:
@@ -544,32 +531,29 @@ options:
type: str type: str
memory: memory:
description: description:
- "Memory limit in format C(<number>[<unit>]). Number is a positive integer. - Memory limit in format C(<number>[<unit>]). Number is a positive integer. Unit can be V(B) (byte), V(K) (kibibyte,
Unit can be V(B) (byte), V(K) (kibibyte, 1024B), V(M) (mebibyte), V(G) (gibibyte), 1024B), V(M) (mebibyte), V(G) (gibibyte), V(T) (tebibyte), or V(P) (pebibyte).
V(T) (tebibyte), or V(P) (pebibyte)."
- Omitting the unit defaults to bytes. - Omitting the unit defaults to bytes.
- If O(container_default_behavior=compatibility), this option has a default of V("0"). - If O(container_default_behavior=compatibility), this option has a default of V("0").
type: str type: str
memory_reservation: memory_reservation:
description: description:
- "Memory soft limit in format C(<number>[<unit>]). Number is a positive integer. - Memory soft limit in format C(<number>[<unit>]). Number is a positive integer. Unit can be V(B) (byte), V(K) (kibibyte,
Unit can be V(B) (byte), V(K) (kibibyte, 1024B), V(M) (mebibyte), V(G) (gibibyte), 1024B), V(M) (mebibyte), V(G) (gibibyte), V(T) (tebibyte), or V(P) (pebibyte).
V(T) (tebibyte), or V(P) (pebibyte)."
- Omitting the unit defaults to bytes. - Omitting the unit defaults to bytes.
type: str type: str
memory_swap: memory_swap:
description: description:
- "Total memory limit (memory + swap) in format C(<number>[<unit>]), or - Total memory limit (memory + swap) in format C(<number>[<unit>]), or the special values V(unlimited) or V(-1) for
the special values V(unlimited) or V(-1) for unlimited swap usage. unlimited swap usage. Number is a positive integer. Unit can be V(B) (byte), V(K) (kibibyte, 1024B), V(M) (mebibyte),
Number is a positive integer. Unit can be V(B) (byte), V(K) (kibibyte, 1024B), V(G) (gibibyte), V(T) (tebibyte), or V(P) (pebibyte).
V(M) (mebibyte), V(G) (gibibyte), V(T) (tebibyte), or V(P) (pebibyte)."
- Omitting the unit defaults to bytes. - Omitting the unit defaults to bytes.
type: str type: str
memory_swappiness: memory_swappiness:
description: description:
- Tune a container's memory swappiness behavior. Accepts an integer between 0 and 100. - Tune a container's memory swappiness behavior. Accepts an integer between 0 and 100.
- If not set, the value will be remain the same if container exists and will be inherited - If not set, the value will be remain the same if container exists and will be inherited from the host machine if it
from the host machine if it is (re-)created. is (re-)created.
type: int type: int
mounts: mounts:
type: list type: list
@@ -639,15 +623,15 @@ options:
type: str type: str
volume_options: volume_options:
description: description:
- Dictionary of options specific to the chosen volume_driver. See - Dictionary of options specific to the chosen volume_driver. See L(here,https://docs.docker.com/storage/volumes/#use-a-volume-driver)
L(here,https://docs.docker.com/storage/volumes/#use-a-volume-driver) for details. for details.
type: dict type: dict
tmpfs_size: tmpfs_size:
description: description:
- "The size for the tmpfs mount in bytes in format <number>[<unit>]." - The size for the tmpfs mount in bytes in format <number>[<unit>].
- "Number is a positive integer. Unit can be one of V(B) (byte), V(K) (kibibyte, 1024B), V(M) (mebibyte), V(G) (gibibyte), - Number is a positive integer. Unit can be one of V(B) (byte), V(K) (kibibyte, 1024B), V(M) (mebibyte), V(G) (gibibyte),
V(T) (tebibyte), or V(P) (pebibyte)." V(T) (tebibyte), or V(P) (pebibyte).
- "Omitting the unit defaults to bytes." - Omitting the unit defaults to bytes.
type: str type: str
tmpfs_mode: tmpfs_mode:
description: description:
@@ -661,11 +645,12 @@ options:
required: true required: true
network_mode: network_mode:
description: description:
- Connect the container to a network. Choices are V(bridge), V(host), V(none), C(container:<name|id>), C(<network_name>) or V(default). - Connect the container to a network. Choices are V(bridge), V(host), V(none), C(container:<name|id>), C(<network_name>)
- "Since community.docker 2.0.0, if O(networks_cli_compatible=true) and O(networks) contains at least one network, or V(default).
the default value for O(network_mode) is the name of the first network in the O(networks) list. You can prevent this - Since community.docker 2.0.0, if O(networks_cli_compatible=true) and O(networks) contains at least one network, the
by explicitly specifying a value for O(network_mode), like the default value V(default) which will be used by Docker if default value for O(network_mode) is the name of the first network in the O(networks) list. You can prevent this by
O(network_mode) is not specified." explicitly specifying a value for O(network_mode), like the default value V(default) which will be used by Docker
if O(network_mode) is not specified.
type: str type: str
userns_mode: userns_mode:
description: description:
@@ -675,10 +660,11 @@ options:
description: description:
- List of networks the container belongs to. - List of networks the container belongs to.
- For examples of the data structure and usage see EXAMPLES below. - For examples of the data structure and usage see EXAMPLES below.
- "To remove a container from one or more networks, use C(networks: strict) in the O(comparisons) option." - 'To remove a container from one or more networks, use C(networks: strict) in the O(comparisons) option.'
- "If O(networks_cli_compatible=false), this will not remove the default network if O(networks) is specified. - 'If O(networks_cli_compatible=false), this will not remove the default network if O(networks) is specified. This is
This is different from the behavior of C(docker run ...). You need to explicitly use C(networks: strict) in O(comparisons) different from the behavior of C(docker run ...). You need to explicitly use C(networks: strict) in O(comparisons)
to enforce the removal of the default network (and all other networks not explicitly mentioned in O(networks)) in that case." to enforce the removal of the default network (and all other networks not explicitly mentioned in O(networks)) in
that case.'
type: list type: list
elements: dict elements: dict
suboptions: suboptions:
@@ -702,30 +688,26 @@ options:
elements: str elements: str
aliases: aliases:
description: description:
- List of aliases for this container in this network. These names - List of aliases for this container in this network. These names can be used in the network to reach this container.
can be used in the network to reach this container.
type: list type: list
elements: str elements: str
mac_address: mac_address:
description: description:
- Endpoint MAC address (for example, V(92:d0:c6:0a:29:33)). - Endpoint MAC address (for example, V(92:d0:c6:0a:29:33)).
- This is only available for Docker API version 1.44 and later. - This is only available for Docker API version 1.44 and later.
- Please note that when a container is attached to a network after creation, - Please note that when a container is attached to a network after creation, this is currently ignored by the Docker
this is currently ignored by the Docker Daemon at least in some cases. Daemon at least in some cases. When passed on creation, this seems to work better.
When passed on creation, this seems to work better.
type: str type: str
version_added: 3.6.0 version_added: 3.6.0
networks_cli_compatible: networks_cli_compatible:
description: description:
- "If O(networks_cli_compatible=true) (default), this module will behave as - If O(networks_cli_compatible=true) (default), this module will behave as C(docker run --network) and will B(not) add
C(docker run --network) and will B(not) add the default network if O(networks) is the default network if O(networks) is specified. If O(networks) is not specified, the default network will be attached.
specified. If O(networks) is not specified, the default network will be attached." - 'When O(networks_cli_compatible=false) and networks are provided to the module via the O(networks) option, the module
- "When O(networks_cli_compatible=false) and networks are provided to the module behaves differently than C(docker run --network): C(docker run --network other) will create a container with network
via the O(networks) option, the module behaves differently than C(docker run --network): C(other) attached, but the default network not attached. This module with O(networks) set to C({name: other}) will
C(docker run --network other) will create a container with network C(other) attached, create a container with both C(default) and C(other) attached. If C(networks: strict) or C(*: strict) is set in O(comparisons),
but the default network not attached. This module with O(networks) set to C({name: other}) will the C(default) network will be removed afterwards.'
create a container with both C(default) and C(other) attached. If C(networks: strict)
or C(*: strict) is set in O(comparisons), the C(default) network will be removed afterwards."
type: bool type: bool
default: true default: true
oom_killer: oom_killer:
@@ -734,8 +716,7 @@ options:
type: bool type: bool
oom_score_adj: oom_score_adj:
description: description:
- An integer value containing the score given to the container in order to tune - An integer value containing the score given to the container in order to tune OOM killer preferences.
OOM killer preferences.
type: int type: int
output_logs: output_logs:
description: description:
@@ -760,12 +741,12 @@ options:
platform: platform:
description: description:
- Platform for the container in the format C(os[/arch[/variant]]). - Platform for the container in the format C(os[/arch[/variant]]).
- "Note that since community.docker 3.5.0, the module uses both the image's metadata and the Docker - "Note that since community.docker 3.5.0, the module uses both the image's metadata and the Docker daemon's information
daemon's information to normalize platform strings similarly to how Docker itself is doing this. to normalize platform strings similarly to how Docker itself is doing this. If you notice idempotency problems, L(please
If you notice idempotency problems, L(please create an issue in the community.docker GitHub repository, create an issue in the community.docker GitHub repository,
https://github.com/ansible-collections/community.docker/issues/new?assignees=&labels=&projects=&template=bug_report.md). https://github.com/ansible-collections/community.docker/issues/new?assignees=&labels=&projects=&template=bug_report.md).
For older community.docker versions, you can use the O(comparisons) option with C(platform: ignore) For older community.docker versions, you can use the O(comparisons) option with C(platform: ignore) to prevent accidental
to prevent accidental recreation of the container due to this." recreation of the container due to this."
type: str type: str
version_added: 3.0.0 version_added: 3.0.0
privileged: privileged:
@@ -782,39 +763,35 @@ options:
published_ports: published_ports:
description: description:
- List of ports to publish from the container to the host. - List of ports to publish from the container to the host.
- "Use docker CLI syntax: V(8000), V(9000:8000), or V(0.0.0.0:9000:8000), where 8000 is a - 'Use docker CLI syntax: V(8000), V(9000:8000), or V(0.0.0.0:9000:8000), where 8000 is a container port, 9000 is a
container port, 9000 is a host port, and 0.0.0.0 is a host interface." host port, and 0.0.0.0 is a host interface.'
- Port ranges can be used for source and destination ports. If two ranges with - Port ranges can be used for source and destination ports. If two ranges with different lengths are specified, the
different lengths are specified, the shorter range will be used. shorter range will be used. Since community.general 0.2.0, if the source port range has length 1, the port will not
Since community.general 0.2.0, if the source port range has length 1, the port will not be assigned be assigned to the first port of the destination range, but to a free port in that range. This is the same behavior
to the first port of the destination range, but to a free port in that range. This is the as for C(docker) command line utility.
same behavior as for C(docker) command line utility. - Bind addresses must be either IPv4 or IPv6 addresses. Hostnames are B(not) allowed. This is different from the C(docker)
- "Bind addresses must be either IPv4 or IPv6 addresses. Hostnames are B(not) allowed. This command line utility. Use the P(community.general.dig#lookup) lookup to resolve hostnames.
is different from the C(docker) command line utility. Use the P(community.general.dig#lookup) lookup - If O(networks) parameter is provided, will inspect each network to see if there exists a bridge network with optional
to resolve hostnames." parameter C(com.docker.network.bridge.host_binding_ipv4). If such a network is found, then published ports where no
- If O(networks) parameter is provided, will inspect each network to see if there exists host IP address is specified will be bound to the host IP pointed to by C(com.docker.network.bridge.host_binding_ipv4).
a bridge network with optional parameter C(com.docker.network.bridge.host_binding_ipv4). Note that the first bridge network with a C(com.docker.network.bridge.host_binding_ipv4) value encountered in the
If such a network is found, then published ports where no host IP address is specified list of O(networks) is the one that will be used.
will be bound to the host IP pointed to by C(com.docker.network.bridge.host_binding_ipv4). - The value V(all) was allowed in earlier versions of this module. Support for it was removed in community.docker 3.0.0.
Note that the first bridge network with a C(com.docker.network.bridge.host_binding_ipv4) Use the O(publish_all_ports) option instead.
value encountered in the list of O(networks) is the one that will be used.
- The value V(all) was allowed in earlier versions of this module. Support for it was removed in
community.docker 3.0.0. Use the O(publish_all_ports) option instead.
type: list type: list
elements: str elements: str
aliases: aliases:
- ports - ports
pull: pull:
description: description:
- If set to V(never), will never try to pull an image. Will fail if the image is not available - If set to V(never), will never try to pull an image. Will fail if the image is not available on the Docker daemon.
on the Docker daemon. - If set to V(missing) or V(false), only pull the image if it is not available on the Docker daemon. This is the default
- If set to V(missing) or V(false), only pull the image if it is not available on the Docker behavior.
daemon. This is the default behavior.
- If set to V(always) or V(true), always try to pull the latest version of the image. - If set to V(always) or V(true), always try to pull the latest version of the image.
- "B(Note:) images are only pulled when specified by name. If the image is specified - B(Note:) images are only pulled when specified by name. If the image is specified as a image ID (hash), it cannot
as a image ID (hash), it cannot be pulled, and this option is ignored." be pulled, and this option is ignored.
- "B(Note:) the values V(never), V(missing), and V(always) are only available since - B(Note:) the values V(never), V(missing), and V(always) are only available since community.docker 3.8.0. Earlier versions
community.docker 3.8.0. Earlier versions only support V(true) and V(false)." only support V(true) and V(false).
type: raw type: raw
choices: choices:
- never - never
@@ -826,9 +803,8 @@ options:
pull_check_mode_behavior: pull_check_mode_behavior:
description: description:
- Allows to adjust the behavior when O(pull=always) or O(pull=true) in check mode. - Allows to adjust the behavior when O(pull=always) or O(pull=true) in check mode.
- Since the Docker daemon does not expose any functionality to test whether a pull will result - Since the Docker daemon does not expose any functionality to test whether a pull will result in a changed image, the
in a changed image, the module by default acts like O(pull=always) only results in a change when module by default acts like O(pull=always) only results in a change when the image is not present.
the image is not present.
- If set to V(image_not_present) (default), only report changes in check mode when the image is not present. - If set to V(image_not_present) (default), only report changes in check mode when the image is not present.
- If set to V(always), always report changes in check mode. - If set to V(always), always report changes in check mode.
type: str type: str
@@ -849,13 +825,11 @@ options:
default: false default: false
removal_wait_timeout: removal_wait_timeout:
description: description:
- When removing an existing container, the docker daemon API call exists after the container - When removing an existing container, the docker daemon API call exists after the container is scheduled for removal.
is scheduled for removal. Removal usually is very fast, but it can happen that during high I/O Removal usually is very fast, but it can happen that during high I/O load, removal can take longer. By default, the
load, removal can take longer. By default, the module will wait until the container has been module will wait until the container has been removed before trying to (re-)create it, however long this takes.
removed before trying to (re-)create it, however long this takes. - By setting this option, the module will wait at most this many seconds for the container to be removed. If the container
- By setting this option, the module will wait at most this many seconds for the container to be is still in the removal phase after this many seconds, the module will fail.
removed. If the container is still in the removal phase after this many seconds, the module will
fail.
type: float type: float
restart: restart:
description: description:
@@ -882,9 +856,8 @@ options:
type: str type: str
shm_size: shm_size:
description: description:
- "Size of C(/dev/shm) in format C(<number>[<unit>]). Number is positive integer. - Size of C(/dev/shm) in format C(<number>[<unit>]). Number is positive integer. Unit can be V(B) (byte), V(K) (kibibyte,
Unit can be V(B) (byte), V(K) (kibibyte, 1024B), V(M) (mebibyte), V(G) (gibibyte), 1024B), V(M) (mebibyte), V(G) (gibibyte), V(T) (tebibyte), or V(P) (pebibyte).
V(T) (tebibyte), or V(P) (pebibyte)."
- Omitting the unit defaults to bytes. If you omit the size entirely, Docker daemon uses V(64M). - Omitting the unit defaults to bytes. If you omit the size entirely, Docker daemon uses V(64M).
type: str type: str
security_opts: security_opts:
@@ -894,26 +867,26 @@ options:
elements: str elements: str
state: state:
description: description:
- 'V(absent) - A container matching the specified name will be stopped and removed. Use O(force_kill) to kill the container - V(absent) - A container matching the specified name will be stopped and removed. Use O(force_kill) to kill the container
rather than stopping it. Use O(keep_volumes) to retain anonymous volumes associated with the removed container.' rather than stopping it. Use O(keep_volumes) to retain anonymous volumes associated with the removed container.
- 'V(present) - Asserts the existence of a container matching the name and any provided configuration parameters. If no - V(present) - Asserts the existence of a container matching the name and any provided configuration parameters. If
container matches the name, a container will be created. If a container matches the name but the provided configuration no container matches the name, a container will be created. If a container matches the name but the provided configuration
does not match, the container will be updated, if it can be. If it cannot be updated, it will be removed and re-created does not match, the container will be updated, if it can be. If it cannot be updated, it will be removed and re-created
with the requested config.' with the requested config.
- 'V(started) - Asserts that the container is first V(present), and then if the container is not running moves it to a running - V(started) - Asserts that the container is first V(present), and then if the container is not running moves it to
state. Use O(restart) to force a matching container to be stopped and restarted.' a running state. Use O(restart) to force a matching container to be stopped and restarted.
- V(healthy) - Asserts that the container is V(present) and V(started), and is actually healthy as well. - V(healthy) - Asserts that the container is V(present) and V(started), and is actually healthy as well. This means
This means that the conditions defined in O(healthcheck) respectively in the image's C(HEALTHCHECK) that the conditions defined in O(healthcheck) respectively in the image's C(HEALTHCHECK) (L(Docker reference for HEALTHCHECK,
(L(Docker reference for HEALTHCHECK, https://docs.docker.com/reference/dockerfile/#healthcheck)) https://docs.docker.com/reference/dockerfile/#healthcheck)) are satisfied. The time waited can be controlled with
are satisfied. O(healthy_wait_timeout). This state has been added in community.docker 3.11.0.
The time waited can be controlled with O(healthy_wait_timeout). This state has been added in community.docker 3.11.0. - V(stopped) - Asserts that the container is first V(present), and then if the container is running moves it to a stopped
- 'V(stopped) - Asserts that the container is first V(present), and then if the container is running moves it to a stopped state.
state.' - 'To control what will be taken into account when comparing configuration, see the O(comparisons) option. To avoid
- "To control what will be taken into account when comparing configuration, see the O(comparisons) option. To avoid that the that the image version will be taken into account, you can also use the V(image: ignore) in the O(comparisons) option.'
image version will be taken into account, you can also use the V(image: ignore) in the O(comparisons) option."
- Use the O(recreate) option to always force re-creation of a matching container, even if it is running. - Use the O(recreate) option to always force re-creation of a matching container, even if it is running.
- If the container should be killed instead of stopped in case it needs to be stopped for recreation, or because O(state) is - If the container should be killed instead of stopped in case it needs to be stopped for recreation, or because O(state)
V(stopped), please use the O(force_kill) option. Use O(keep_volumes) to retain anonymous volumes associated with a removed container. is V(stopped), please use the O(force_kill) option. Use O(keep_volumes) to retain anonymous volumes associated with
a removed container.
- Use O(keep_volumes) to retain anonymous volumes associated with a removed container. - Use O(keep_volumes) to retain anonymous volumes associated with a removed container.
type: str type: str
default: started default: started
@@ -929,24 +902,21 @@ options:
type: str type: str
healthy_wait_timeout: healthy_wait_timeout:
description: description:
- When waiting for the container to become healthy if O(state=healthy), this option controls how long - When waiting for the container to become healthy if O(state=healthy), this option controls how long the module waits
the module waits until the container state becomes healthy. until the container state becomes healthy.
- The timeout is specified in seconds. The default, V(300), is 5 minutes. - The timeout is specified in seconds. The default, V(300), is 5 minutes.
- Set this to 0 or a negative value to wait indefinitely. - Set this to 0 or a negative value to wait indefinitely. Note that depending on the container this can result in the
Note that depending on the container this can result in the module not terminating. module not terminating.
default: 300 default: 300
type: float type: float
version_added: 3.11.0 version_added: 3.11.0
stop_timeout: stop_timeout:
description: description:
- Number of seconds to wait for the container to stop before sending C(SIGKILL). - Number of seconds to wait for the container to stop before sending C(SIGKILL). When the container is created by this
When the container is created by this module, its C(StopTimeout) configuration module, its C(StopTimeout) configuration will be set to this value.
will be set to this value. - When the container is stopped, will be used as a timeout for stopping the container. In case the container has a custom
- When the container is stopped, will be used as a timeout for stopping the C(StopTimeout) configuration, the behavior depends on the version of the docker daemon. New versions of the docker
container. In case the container has a custom C(StopTimeout) configuration, daemon will always use the container's configured C(StopTimeout) value if it has been configured.
the behavior depends on the version of the docker daemon. New versions of
the docker daemon will always use the container's configured C(StopTimeout)
value if it has been configured.
type: int type: int
storage_opts: storage_opts:
description: description:
@@ -965,7 +935,7 @@ options:
type: bool type: bool
ulimits: ulimits:
description: description:
- "List of ulimit options. A ulimit is specified as V(nofile:262144:262144)." - List of ulimit options. A ulimit is specified as V(nofile:262144:262144).
type: list type: list
elements: str elements: str
sysctls: sysctls:
@@ -975,7 +945,7 @@ options:
user: user:
description: description:
- Sets the username or UID used and optionally the groupname or GID for the specified command. - Sets the username or UID used and optionally the groupname or GID for the specified command.
- "Can be of the forms C(user), C(user:group), C(uid), C(uid:gid), C(user:gid) or C(uid:group)." - Can be of the forms C(user), C(user:group), C(uid), C(uid:gid), C(user:gid) or C(uid:group).
type: str type: str
uts: uts:
description: description:
@@ -984,13 +954,12 @@ options:
volumes: volumes:
description: description:
- List of volumes to mount within the container. - List of volumes to mount within the container.
- "Use docker CLI-style syntax: C(/host:/container[:mode])" - 'Use docker CLI-style syntax: C(/host:/container[:mode]).'
- "Mount modes can be a comma-separated list of various modes such as V(ro), V(rw), V(consistent), - Mount modes can be a comma-separated list of various modes such as V(ro), V(rw), V(consistent), V(delegated), V(cached),
V(delegated), V(cached), V(rprivate), V(private), V(rshared), V(shared), V(rslave), V(slave), and V(rprivate), V(private), V(rshared), V(shared), V(rslave), V(slave), and V(nocopy). Note that the docker daemon might
V(nocopy). Note that the docker daemon might not support all modes and combinations of such modes." not support all modes and combinations of such modes.
- SELinux hosts can additionally use V(z) or V(Z) to use a shared or private label for the volume. - SELinux hosts can additionally use V(z) or V(Z) to use a shared or private label for the volume.
- "Note that Ansible 2.7 and earlier only supported one mode, which had to be one of V(ro), V(rw), - Note that Ansible 2.7 and earlier only supported one mode, which had to be one of V(ro), V(rw), V(z), and V(Z).
V(z), and V(Z)."
type: list type: list
elements: str elements: str
volume_driver: volume_driver:
@@ -1020,9 +989,9 @@ author:
requirements: requirements:
- "Docker API >= 1.25" - "Docker API >= 1.25"
''' """
EXAMPLES = ''' EXAMPLES = r"""
- name: Create a data container - name: Create a data container
community.docker.docker_container: community.docker.docker_container:
name: mydata name: mydata
@@ -1262,12 +1231,12 @@ EXAMPLES = '''
image: ubuntu:18.04 image: ubuntu:18.04
state: started state: started
device_requests: device_requests:
- # Add some specific devices to this container # Add some specific devices to this container
device_ids: - device_ids:
- '0' - '0'
- 'GPU-3a23c669-1f69-c64e-cf85-44e9b07e7a2a' - 'GPU-3a23c669-1f69-c64e-cf85-44e9b07e7a2a'
- # Add nVidia GPUs to this container # Add nVidia GPUs to this container
driver: nvidia - driver: nvidia
count: -1 # this means we want all count: -1 # this means we want all
capabilities: capabilities:
# We have one OR condition: 'gpu' AND 'utility' # We have one OR condition: 'gpu' AND 'utility'
@@ -1285,9 +1254,9 @@ EXAMPLES = '''
# Limit root filesystem to 12 MB - note that this requires special storage backends # Limit root filesystem to 12 MB - note that this requires special storage backends
# (https://fabianlee.org/2020/01/15/docker-use-overlay2-with-an-xfs-backing-filesystem-to-limit-rootfs-size/) # (https://fabianlee.org/2020/01/15/docker-use-overlay2-with-an-xfs-backing-filesystem-to-limit-rootfs-size/)
size: 12m size: 12m
''' """
RETURN = ''' RETURN = r"""
container: container:
description: description:
- Facts representing the current state of the container. Matches the docker inspection output. - Facts representing the current state of the container. Matches the docker inspection output.
@@ -1295,38 +1264,11 @@ container:
- If O(detach=false), will include C(Output) attribute containing any output from container run. - If O(detach=false), will include C(Output) attribute containing any output from container run.
returned: success; or when O(state=started) and O(detach=false), and when waiting for the container result did not fail returned: success; or when O(state=started) and O(detach=false), and when waiting for the container result did not fail
type: dict type: dict
sample: '{ sample: '{ "AppArmorProfile": "", "Args": [], "Config": { "AttachStderr": false, "AttachStdin": false, "AttachStdout": false,
"AppArmorProfile": "", "Cmd": [ "/usr/bin/supervisord" ], "Domainname": "", "Entrypoint": null, "Env": [ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
"Args": [], ], "ExposedPorts": { "443/tcp": {}, "80/tcp": {} }, "Hostname": "8e47bf643eb9", "Image": "lnmp_nginx:v1", "Labels": {},
"Config": { "OnBuild": null, "OpenStdin": false, "StdinOnce": false, "Tty": false, "User": "", "Volumes": { "/tmp/lnmp/nginx-sites/logs/":
"AttachStderr": false, {} }, ... }'
"AttachStdin": false,
"AttachStdout": false,
"Cmd": [
"/usr/bin/supervisord"
],
"Domainname": "",
"Entrypoint": null,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"ExposedPorts": {
"443/tcp": {},
"80/tcp": {}
},
"Hostname": "8e47bf643eb9",
"Image": "lnmp_nginx:v1",
"Labels": {},
"OnBuild": null,
"OpenStdin": false,
"StdinOnce": false,
"Tty": false,
"User": "",
"Volumes": {
"/tmp/lnmp/nginx-sites/logs/": {}
},
...
}'
status: status:
description: description:
- In case a container is started without detaching, this contains the exit code of the process in the container. - In case a container is started without detaching, this contains the exit code of the process in the container.
@@ -1334,7 +1276,7 @@ status:
returned: when O(state=started) and O(detach=false), and when waiting for the container result did not fail returned: when O(state=started) and O(detach=false), and when waiting for the container result did not fail
type: int type: int
sample: 0 sample: 0
''' """
from ansible_collections.community.docker.plugins.module_utils.module_container.docker_api import ( from ansible_collections.community.docker.plugins.module_utils.module_container.docker_api import (
DockerAPIEngineDriver, DockerAPIEngineDriver,
+23 -26
View File
@@ -8,8 +8,7 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = r"""
---
module: docker_container_copy_into module: docker_container_copy_into
short_description: Copy a file into a Docker container short_description: Copy a file into a Docker container
@@ -19,9 +18,8 @@ version_added: 3.4.0
description: description:
- Copy a file into a Docker container. - Copy a file into a Docker container.
- Similar to C(docker cp). - Similar to C(docker cp).
- To copy files in a non-running container, you must provide the O(owner_id) and O(group_id) options. - To copy files in a non-running container, you must provide the O(owner_id) and O(group_id) options. This is also necessary
This is also necessary if the container does not contain a C(/bin/sh) shell with an C(id) tool. if the container does not contain a C(/bin/sh) shell with an C(id) tool.
attributes: attributes:
check_mode: check_mode:
support: full support: full
@@ -29,8 +27,8 @@ attributes:
support: full support: full
details: details:
- Additional data will need to be transferred to compute diffs. - Additional data will need to be transferred to compute diffs.
- The module uses R(the MAX_FILE_SIZE_FOR_DIFF ansible-core configuration,MAX_FILE_SIZE_FOR_DIFF) - The module uses R(the MAX_FILE_SIZE_FOR_DIFF ansible-core configuration,MAX_FILE_SIZE_FOR_DIFF) to determine for how
to determine for how large files diffs should be computed. large files diffs should be computed.
options: options:
container: container:
@@ -51,11 +49,9 @@ options:
type: str type: str
content_is_b64: content_is_b64:
description: description:
- If set to V(true), the content in O(content) is assumed to be Base64 encoded and - If set to V(true), the content in O(content) is assumed to be Base64 encoded and will be decoded before being used.
will be decoded before being used. - To use binary O(content), it is better to keep it Base64 encoded and let it be decoded by this option. Otherwise you
- To use binary O(content), it is better to keep it Base64 encoded and let it risk the data to be interpreted as UTF-8 and corrupted.
be decoded by this option. Otherwise you risk the data to be interpreted as
UTF-8 and corrupted.
type: bool type: bool
default: false default: false
container_path: container_path:
@@ -71,24 +67,25 @@ options:
default: false default: false
local_follow: local_follow:
description: description:
- This flag indicates that filesystem links in the source tree (where the module is executed), if they exist, should be followed. - This flag indicates that filesystem links in the source tree (where the module is executed), if they exist, should
be followed.
type: bool type: bool
default: true default: true
owner_id: owner_id:
description: description:
- The owner ID to use when writing the file to disk. - The owner ID to use when writing the file to disk.
- If provided, O(group_id) must also be provided. - If provided, O(group_id) must also be provided.
- If not provided, the module will try to determine the user and group ID for the current user in the container. - If not provided, the module will try to determine the user and group ID for the current user in the container. This
This will only work if C(/bin/sh) is present in the container and the C(id) binary or shell builtin is available. will only work if C(/bin/sh) is present in the container and the C(id) binary or shell builtin is available. Also
Also the container must be running. the container must be running.
type: int type: int
group_id: group_id:
description: description:
- The group ID to use when writing the file to disk. - The group ID to use when writing the file to disk.
- If provided, O(owner_id) must also be provided. - If provided, O(owner_id) must also be provided.
- If not provided, the module will try to determine the user and group ID for the current user in the container. - If not provided, the module will try to determine the user and group ID for the current user in the container. This
This will only work if C(/bin/sh) is present in the container and the C(id) binary or shell builtin is available. will only work if C(/bin/sh) is present in the container and the C(id) binary or shell builtin is available. Also
Also the container must be running. the container must be running.
type: int type: int
mode: mode:
description: description:
@@ -98,8 +95,8 @@ options:
force: force:
description: description:
- If set to V(true), force writing the file (without performing any idempotency checks). - If set to V(true), force writing the file (without performing any idempotency checks).
- If set to V(false), only write the file if it does not exist on the target. If a filesystem object exists at - If set to V(false), only write the file if it does not exist on the target. If a filesystem object exists at the destination,
the destination, the module will not do any change. the module will not do any change.
- If this option is not specified, the module will be idempotent. To verify idempotency, it will try to get information - If this option is not specified, the module will be idempotent. To verify idempotency, it will try to get information
on the filesystem object in the container, and if everything seems to match will download the file from the container on the filesystem object in the container, and if everything seems to match will download the file from the container
to compare it to the file to upload. to compare it to the file to upload.
@@ -115,9 +112,9 @@ author:
requirements: requirements:
- "Docker API >= 1.25" - "Docker API >= 1.25"
''' """
EXAMPLES = ''' EXAMPLES = r"""
- name: Copy a file into the container - name: Copy a file into the container
community.docker.docker_container_copy_into: community.docker.docker_container_copy_into:
container: mydata container: mydata
@@ -132,16 +129,16 @@ EXAMPLES = '''
owner_id: 0 # root owner_id: 0 # root
group_id: 0 # root group_id: 0 # root
mode: 0755 # readable and executable by all users, writable by root mode: 0755 # readable and executable by all users, writable by root
''' """
RETURN = ''' RETURN = r"""
container_path: container_path:
description: description:
- The actual path in the container. - The actual path in the container.
- Can only be different from O(container_path) when O(follow=true). - Can only be different from O(container_path) when O(follow=true).
type: str type: str
returned: success returned: success
''' """
import base64 import base64
import io import io
+17 -17
View File
@@ -8,8 +8,7 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = r"""
---
module: docker_container_exec module: docker_container_exec
short_description: Execute command in a docker container short_description: Execute command in a docker container
@@ -18,7 +17,6 @@ version_added: 1.5.0
description: description:
- Executes a command in a Docker container. - Executes a command in a Docker container.
extends_documentation_fragment: extends_documentation_fragment:
- community.docker.docker.api_documentation - community.docker.docker.api_documentation
- community.docker.attributes - community.docker.attributes
@@ -55,8 +53,7 @@ options:
detach: detach:
description: description:
- Whether to run the command synchronously (O(detach=false), default) or asynchronously (O(detach=true)). - Whether to run the command synchronously (O(detach=false), default) or asynchronously (O(detach=true)).
- If set to V(true), O(stdin) cannot be provided, and the return values RV(stdout), RV(stderr), and - If set to V(true), O(stdin) cannot be provided, and the return values RV(stdout), RV(stderr), and RV(rc) are not returned.
RV(rc) are not returned.
type: bool type: bool
default: false default: false
version_added: 2.1.0 version_added: 2.1.0
@@ -87,25 +84,28 @@ options:
env: env:
description: description:
- Dictionary of environment variables with their respective values to be passed to the command ran inside the container. - Dictionary of environment variables with their respective values to be passed to the command ran inside the container.
- Values which might be parsed as numbers, booleans or other types by the YAML parser must be quoted (for example V("true")) in order to avoid data loss. - Values which might be parsed as numbers, booleans or other types by the YAML parser must be quoted (for example V("true"))
- Please note that if you are passing values in with Jinja2 templates, like V("{{ value }}"), you need to add V(| string) to prevent Ansible to in order to avoid data loss.
convert strings such as V("true") back to booleans. The correct way is to use V("{{ value | string }}"). - Please note that if you are passing values in with Jinja2 templates, like V("{{ value }}"), you need to add V(| string)
to prevent Ansible to convert strings such as V("true") back to booleans. The correct way is to use V("{{ value |
string }}").
type: dict type: dict
version_added: 2.1.0 version_added: 2.1.0
notes: notes:
- Does B(not work with TCP TLS sockets) when using O(stdin). This is caused by the inability to send C(close_notify) without closing the connection - Does B(not work with TCP TLS sockets) when using O(stdin). This is caused by the inability to send C(close_notify) without
with Python's C(SSLSocket)s. See U(https://github.com/ansible-collections/community.docker/issues/605) for more information. closing the connection with Python's C(SSLSocket)s. See U(https://github.com/ansible-collections/community.docker/issues/605)
- If you need to evaluate environment variables of the container in O(command) or O(argv), you need to pass the command through a shell, for more information.
like O(command=/bin/sh -c "echo $ENV_VARIABLE"). - If you need to evaluate environment variables of the container in O(command) or O(argv), you need to pass the command
through a shell, like O(command=/bin/sh -c "echo $ENV_VARIABLE").
author: author:
- "Felix Fontein (@felixfontein)" - "Felix Fontein (@felixfontein)"
requirements: requirements:
- "Docker API >= 1.25" - "Docker API >= 1.25"
''' """
EXAMPLES = ''' EXAMPLES = r"""
- name: Run a simple command (command) - name: Run a simple command (command)
community.docker.docker_container_exec: community.docker.docker_container_exec:
container: foo container: foo
@@ -130,9 +130,9 @@ EXAMPLES = '''
- name: Print stderr lines - name: Print stderr lines
ansible.builtin.debug: ansible.builtin.debug:
var: result.stderr_lines var: result.stderr_lines
''' """
RETURN = ''' RETURN = r"""
stdout: stdout:
type: str type: str
returned: success and O(detach=false) returned: success and O(detach=false)
@@ -156,7 +156,7 @@ exec_id:
description: description:
- The execution ID of the command. - The execution ID of the command.
version_added: 2.1.0 version_added: 2.1.0
''' """
import shlex import shlex
import traceback import traceback
+13 -42
View File
@@ -8,17 +8,15 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = r"""
---
module: docker_container_info module: docker_container_info
short_description: Retrieves facts about docker container short_description: Retrieves facts about docker container
description: description:
- Retrieves facts about a docker container. - Retrieves facts about a docker container.
- Essentially returns the output of C(docker inspect <name>), similar to what M(community.docker.docker_container) - Essentially returns the output of C(docker inspect <name>), similar to what M(community.docker.docker_container) returns
returns for a non-absent container. for a non-absent container.
extends_documentation_fragment: extends_documentation_fragment:
- community.docker.docker.api_documentation - community.docker.docker.api_documentation
- community.docker.attributes - community.docker.attributes
@@ -38,9 +36,9 @@ author:
requirements: requirements:
- "Docker API >= 1.25" - "Docker API >= 1.25"
''' """
EXAMPLES = ''' EXAMPLES = r"""
- name: Get infos on container - name: Get infos on container
community.docker.docker_container_info: community.docker.docker_container_info:
name: mydata name: mydata
@@ -54,9 +52,9 @@ EXAMPLES = '''
ansible.builtin.debug: ansible.builtin.debug:
var: result.container var: result.container
when: result.exists when: result.exists
''' """
RETURN = ''' RETURN = r"""
exists: exists:
description: description:
- Returns whether the container exists. - Returns whether the container exists.
@@ -69,39 +67,12 @@ container:
- Will be V(none) if container does not exist. - Will be V(none) if container does not exist.
returned: always returned: always
type: dict type: dict
sample: '{ sample: '{ "AppArmorProfile": "", "Args": [], "Config": { "AttachStderr": false, "AttachStdin": false, "AttachStdout": false,
"AppArmorProfile": "", "Cmd": [ "/usr/bin/supervisord" ], "Domainname": "", "Entrypoint": null, "Env": [ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
"Args": [], ], "ExposedPorts": { "443/tcp": {}, "80/tcp": {} }, "Hostname": "8e47bf643eb9", "Image": "lnmp_nginx:v1", "Labels": {},
"Config": { "OnBuild": null, "OpenStdin": false, "StdinOnce": false, "Tty": false, "User": "", "Volumes": { "/tmp/lnmp/nginx-sites/logs/":
"AttachStderr": false, {} }, ... }'
"AttachStdin": false, """
"AttachStdout": false,
"Cmd": [
"/usr/bin/supervisord"
],
"Domainname": "",
"Entrypoint": null,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"ExposedPorts": {
"443/tcp": {},
"80/tcp": {}
},
"Hostname": "8e47bf643eb9",
"Image": "lnmp_nginx:v1",
"Labels": {},
"OnBuild": null,
"OpenStdin": false,
"StdinOnce": false,
"Tty": false,
"User": "",
"Volumes": {
"/tmp/lnmp/nginx-sites/logs/": {}
},
...
}'
'''
import traceback import traceback
+43 -52
View File
@@ -8,21 +8,18 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = r"""
---
module: docker_host_info module: docker_host_info
short_description: Retrieves facts about docker host and lists of objects of the services. short_description: Retrieves facts about docker host and lists of objects of the services
description: description:
- Retrieves facts about a docker host. - Retrieves facts about a docker host.
- Essentially returns the output of C(docker system info). - Essentially returns the output of C(docker system info).
- The module also allows to list object names for containers, images, networks and volumes. - The module also allows to list object names for containers, images, networks and volumes. It also allows to query information
It also allows to query information on disk usage. on disk usage.
- The output differs depending on API version of the docker daemon. - The output differs depending on API version of the docker daemon.
- If the docker daemon cannot be contacted or does not meet the API version requirements, - If the docker daemon cannot be contacted or does not meet the API version requirements, the module will fail.
the module will fail.
extends_documentation_fragment: extends_documentation_fragment:
- community.docker.docker.api_documentation - community.docker.docker.api_documentation
- community.docker.attributes - community.docker.attributes
@@ -54,11 +51,11 @@ options:
containers_filters: containers_filters:
description: description:
- A dictionary of filter values used for selecting containers to list. - A dictionary of filter values used for selecting containers to list.
- "For example, C(until: 24h)." - 'For example, C(until: 24h).'
- C(label) is a special case of filter which can be a string C(<key>) matching when a label is present, a string - C(label) is a special case of filter which can be a string C(<key>) matching when a label is present, a string C(<key>=<value>)
C(<key>=<value>) matching when a label has a particular value, or a list of strings C(<key>)/C(<key>=<value). matching when a label has a particular value, or a list of strings C(<key>)/C(<key>=<value).
- See L(the docker documentation,https://docs.docker.com/engine/reference/commandline/container_prune/#filtering) - See L(the docker documentation,https://docs.docker.com/engine/reference/commandline/container_prune/#filtering) for
for more information on possible filters. more information on possible filters.
type: dict type: dict
images: images:
description: description:
@@ -68,11 +65,11 @@ options:
images_filters: images_filters:
description: description:
- A dictionary of filter values used for selecting images to list. - A dictionary of filter values used for selecting images to list.
- "For example, C(dangling: true)." - 'For example, C(dangling: true).'
- C(label) is a special case of filter which can be a string C(<key>) matching when a label is present, a string - C(label) is a special case of filter which can be a string C(<key>) matching when a label is present, a string C(<key>=<value>)
C(<key>=<value>) matching when a label has a particular value, or a list of strings C(<key>)/C(<key>=<value). matching when a label has a particular value, or a list of strings C(<key>)/C(<key>=<value).
- See L(the docker documentation,https://docs.docker.com/engine/reference/commandline/image_prune/#filtering) - See L(the docker documentation,https://docs.docker.com/engine/reference/commandline/image_prune/#filtering) for more
for more information on possible filters. information on possible filters.
type: dict type: dict
networks: networks:
description: description:
@@ -82,10 +79,10 @@ options:
networks_filters: networks_filters:
description: description:
- A dictionary of filter values used for selecting networks to list. - A dictionary of filter values used for selecting networks to list.
- C(label) is a special case of filter which can be a string C(<key>) matching when a label is present, a string - C(label) is a special case of filter which can be a string C(<key>) matching when a label is present, a string C(<key>=<value>)
C(<key>=<value>) matching when a label has a particular value, or a list of strings C(<key>)/C(<key>=<value). matching when a label has a particular value, or a list of strings C(<key>)/C(<key>=<value).
- See L(the docker documentation,https://docs.docker.com/engine/reference/commandline/network_prune/#filtering) - See L(the docker documentation,https://docs.docker.com/engine/reference/commandline/network_prune/#filtering) for
for more information on possible filters. more information on possible filters.
type: dict type: dict
volumes: volumes:
description: description:
@@ -95,10 +92,10 @@ options:
volumes_filters: volumes_filters:
description: description:
- A dictionary of filter values used for selecting volumes to list. - A dictionary of filter values used for selecting volumes to list.
- C(label) is a special case of filter which can be a string C(<key>) matching when a label is present, a string - C(label) is a special case of filter which can be a string C(<key>) matching when a label is present, a string C(<key>=<value>)
C(<key>=<value>) matching when a label has a particular value, or a list of strings C(<key>)/C(<key>=<value). matching when a label has a particular value, or a list of strings C(<key>)/C(<key>=<value).
- See L(the docker documentation,https://docs.docker.com/engine/reference/commandline/volume_prune/#filtering) - See L(the docker documentation,https://docs.docker.com/engine/reference/commandline/volume_prune/#filtering) for more
for more information on possible filters. information on possible filters.
type: dict type: dict
disk_usage: disk_usage:
description: description:
@@ -108,11 +105,11 @@ options:
default: false default: false
verbose_output: verbose_output:
description: description:
- When set to V(true) and O(networks), O(volumes), O(images), O(containers), or O(disk_usage) is set to V(true) - When set to V(true) and O(networks), O(volumes), O(images), O(containers), or O(disk_usage) is set to V(true) then
then output will contain verbose information about objects matching the full output of API method. output will contain verbose information about objects matching the full output of API method. For details see the
For details see the documentation of your version of Docker API at U(https://docs.docker.com/engine/api/). documentation of your version of Docker API at U(https://docs.docker.com/engine/api/).
- The verbose output in this module contains only subset of information returned by this module - The verbose output in this module contains only subset of information returned by this module for each type of the
for each type of the objects. objects.
type: bool type: bool
default: false default: false
@@ -121,9 +118,9 @@ author:
requirements: requirements:
- "Docker API >= 1.25" - "Docker API >= 1.25"
''' """
EXAMPLES = ''' EXAMPLES = r"""
- name: Get info on docker host - name: Get info on docker host
community.docker.docker_host_info: community.docker.docker_host_info:
register: result register: result
@@ -163,10 +160,9 @@ EXAMPLES = '''
- name: Show host information - name: Show host information
ansible.builtin.debug: ansible.builtin.debug:
var: result.host_info var: result.host_info
"""
''' RETURN = r"""
RETURN = '''
can_talk_to_docker: can_talk_to_docker:
description: description:
- Will be V(true) if the module can talk to the docker daemon. - Will be V(true) if the module can talk to the docker daemon.
@@ -180,44 +176,39 @@ host_info:
type: dict type: dict
volumes: volumes:
description: description:
- List of dict objects containing the basic information about each volume. - List of dict objects containing the basic information about each volume. Keys matches the C(docker volume ls) output
Keys matches the C(docker volume ls) output unless O(verbose_output=true). unless O(verbose_output=true). See description for O(verbose_output).
See description for O(verbose_output).
returned: When O(volumes=true) returned: When O(volumes=true)
type: list type: list
elements: dict elements: dict
networks: networks:
description: description:
- List of dict objects containing the basic information about each network. - List of dict objects containing the basic information about each network. Keys matches the C(docker network ls) output
Keys matches the C(docker network ls) output unless O(verbose_output=true). unless O(verbose_output=true). See description for O(verbose_output).
See description for O(verbose_output).
returned: When O(networks=true) returned: When O(networks=true)
type: list type: list
elements: dict elements: dict
containers: containers:
description: description:
- List of dict objects containing the basic information about each container. - List of dict objects containing the basic information about each container. Keys matches the C(docker container ls)
Keys matches the C(docker container ls) output unless O(verbose_output=true). output unless O(verbose_output=true). See description for O(verbose_output).
See description for O(verbose_output).
returned: When O(containers=true) returned: When O(containers=true)
type: list type: list
elements: dict elements: dict
images: images:
description: description:
- List of dict objects containing the basic information about each image. - List of dict objects containing the basic information about each image. Keys matches the C(docker image ls) output unless
Keys matches the C(docker image ls) output unless O(verbose_output=true). O(verbose_output=true). See description for O(verbose_output).
See description for O(verbose_output).
returned: When O(images=true) returned: When O(images=true)
type: list type: list
elements: dict elements: dict
disk_usage: disk_usage:
description: description:
- Information on summary disk usage by images, containers and volumes on docker host - Information on summary disk usage by images, containers and volumes on docker host unless O(verbose_output=true). See
unless O(verbose_output=true). See description for O(verbose_output). description for O(verbose_output).
returned: When O(disk_usage=true) returned: When O(disk_usage=true)
type: dict type: dict
"""
'''
import traceback import traceback
+49 -61
View File
@@ -8,20 +8,17 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = r"""
---
module: docker_image module: docker_image
short_description: Manage docker images short_description: Manage docker images
description: description:
- Build, load or pull an image, making the image available for creating containers. Also supports tagging - Build, load or pull an image, making the image available for creating containers. Also supports tagging an image, pushing
an image, pushing an image, and archiving an image to a C(.tar) file. an image, and archiving an image to a C(.tar) file.
notes: notes:
- Building images is done using Docker daemon's API. It is not possible to use BuildKit / buildx this way. - Building images is done using Docker daemon's API. It is not possible to use BuildKit / buildx this way. Use M(community.docker.docker_image_build)
Use M(community.docker.docker_image_build) to build images with BuildKit. to build images with BuildKit.
extends_documentation_fragment: extends_documentation_fragment:
- community.docker.docker.api_documentation - community.docker.docker.api_documentation
- community.docker.attributes - community.docker.attributes
@@ -38,14 +35,12 @@ attributes:
options: options:
source: source:
description: description:
- "Determines where the module will try to retrieve the image from." - Determines where the module will try to retrieve the image from.
- "Use V(build) to build the image from a C(Dockerfile). O(build.path) must - Use V(build) to build the image from a C(Dockerfile). O(build.path) must be specified when this value is used.
be specified when this value is used." - Use V(load) to load the image from a C(.tar) file. O(load_path) must be specified when this value is used.
- "Use V(load) to load the image from a C(.tar) file. O(load_path) must - Use V(pull) to pull the image from a registry.
be specified when this value is used." - Use V(local) to make sure that the image is already available on the local docker daemon. This means that the module
- "Use V(pull) to pull the image from a registry." does not try to build, pull or load the image.
- "Use V(local) to make sure that the image is already available on the local
docker daemon. This means that the module does not try to build, pull or load the image."
type: str type: str
choices: choices:
- build - build
@@ -54,7 +49,7 @@ options:
- local - local
build: build:
description: description:
- "Specifies options used for building images." - Specifies options used for building images.
type: dict type: dict
suboptions: suboptions:
cache_from: cache_from:
@@ -64,7 +59,8 @@ options:
elements: str elements: str
dockerfile: dockerfile:
description: description:
- Use with O(state=present) and O(source=build) to provide an alternate name for the Dockerfile to use when building an image. - Use with O(state=present) and O(source=build) to provide an alternate name for the Dockerfile to use when building
an image.
- This can also include a relative path (relative to O(build.path)). - This can also include a relative path (relative to O(build.path)).
type: str type: str
http_timeout: http_timeout:
@@ -74,8 +70,8 @@ options:
type: int type: int
path: path:
description: description:
- Use with state 'present' to build an image. Will be the path to a directory containing the context and - Use with state 'present' to build an image. Will be the path to a directory containing the context and Dockerfile
Dockerfile for building an image. for building an image.
type: path type: path
required: true required: true
pull: pull:
@@ -100,9 +96,8 @@ options:
etc_hosts: etc_hosts:
description: description:
- Extra hosts to add to C(/etc/hosts) in building containers, as a mapping of hostname to IP address. - Extra hosts to add to C(/etc/hosts) in building containers, as a mapping of hostname to IP address.
- Instead of an IP address, the special value V(host-gateway) can also be used, which - Instead of an IP address, the special value V(host-gateway) can also be used, which resolves to the host's gateway
resolves to the host's gateway IP and allows building containers to connect to services running IP and allows building containers to connect to services running on the host.
on the host.
type: dict type: dict
args: args:
description: description:
@@ -116,18 +111,16 @@ options:
suboptions: suboptions:
memory: memory:
description: description:
- "Memory limit for build in format C(<number>[<unit>]). Number is a positive integer. - Memory limit for build in format C(<number>[<unit>]). Number is a positive integer. Unit can be V(B) (byte),
Unit can be V(B) (byte), V(K) (kibibyte, 1024B), V(M) (mebibyte), V(G) (gibibyte), V(K) (kibibyte, 1024B), V(M) (mebibyte), V(G) (gibibyte), V(T) (tebibyte), or V(P) (pebibyte).
V(T) (tebibyte), or V(P) (pebibyte)."
- Omitting the unit defaults to bytes. - Omitting the unit defaults to bytes.
- Before community.docker 3.6.0, no units were allowed. - Before community.docker 3.6.0, no units were allowed.
type: str type: str
memswap: memswap:
description: description:
- "Total memory limit (memory + swap) for build in format C(<number>[<unit>]), or - Total memory limit (memory + swap) for build in format C(<number>[<unit>]), or the special values V(unlimited)
the special values V(unlimited) or V(-1) for unlimited swap usage. or V(-1) for unlimited swap usage. Number is a positive integer. Unit can be V(B) (byte), V(K) (kibibyte,
Number is a positive integer. Unit can be V(B) (byte), V(K) (kibibyte, 1024B), 1024B), V(M) (mebibyte), V(G) (gibibyte), V(T) (tebibyte), or V(P) (pebibyte).
V(M) (mebibyte), V(G) (gibibyte), V(T) (tebibyte), or V(P) (pebibyte)."
- Omitting the unit defaults to bytes. - Omitting the unit defaults to bytes.
- Before community.docker 3.6.0, no units were allowed, and neither was the special value V(unlimited). - Before community.docker 3.6.0, no units were allowed, and neither was the special value V(unlimited).
type: str type: str
@@ -142,14 +135,12 @@ options:
type: str type: str
use_config_proxy: use_config_proxy:
description: description:
- If set to V(true) and a proxy configuration is specified in the docker client configuration - If set to V(true) and a proxy configuration is specified in the docker client configuration (by default C($HOME/.docker/config.json)),
(by default C($HOME/.docker/config.json)), the corresponding environment variables will the corresponding environment variables will be set in the container being built.
be set in the container being built.
type: bool type: bool
target: target:
description: description:
- When building an image specifies an intermediate build stage by - When building an image specifies an intermediate build stage by name as a final stage for the resulting image.
name as a final stage for the resulting image.
type: str type: str
platform: platform:
description: description:
@@ -158,9 +149,8 @@ options:
version_added: 1.1.0 version_added: 1.1.0
shm_size: shm_size:
description: description:
- "Size of C(/dev/shm) in format C(<number>[<unit>]). Number is positive integer. - Size of C(/dev/shm) in format C(<number>[<unit>]). Number is positive integer. Unit can be V(B) (byte), V(K) (kibibyte,
Unit can be V(B) (byte), V(K) (kibibyte, 1024B), V(M) (mebibyte), V(G) (gibibyte), 1024B), V(M) (mebibyte), V(G) (gibibyte), V(T) (tebibyte), or V(P) (pebibyte).
V(T) (tebibyte), or V(P) (pebibyte)."
- Omitting the unit defaults to bytes. If you omit the size entirely, Docker daemon uses V(64M). - Omitting the unit defaults to bytes. If you omit the size entirely, Docker daemon uses V(64M).
type: str type: str
version_added: 3.6.0 version_added: 3.6.0
@@ -180,8 +170,8 @@ options:
type: path type: path
force_source: force_source:
description: description:
- Use with O(state=present) to build, load or pull an image (depending on the - Use with O(state=present) to build, load or pull an image (depending on the value of the O(source) option) when the
value of the O(source) option) when the image already exists. image already exists.
type: bool type: bool
default: false default: false
force_absent: force_absent:
@@ -196,23 +186,23 @@ options:
default: false default: false
name: name:
description: description:
- "Image name. Name format will be one of: C(name), C(repository/name), C(registry_server:port/name). - 'Image name. Name format will be one of: C(name), C(repository/name), C(registry_server:port/name). When pushing or
When pushing or pulling an image the name can optionally include the tag by appending C(:tag_name)." pulling an image the name can optionally include the tag by appending C(:tag_name).'
- Note that image IDs (hashes) are only supported for O(state=absent), for O(state=present) with O(source=load), - Note that image IDs (hashes) are only supported for O(state=absent), for O(state=present) with O(source=load), and
and for O(state=present) with O(source=local). for O(state=present) with O(source=local).
type: str type: str
required: true required: true
pull: pull:
description: description:
- "Specifies options used for pulling images." - Specifies options used for pulling images.
type: dict type: dict
version_added: 1.3.0 version_added: 1.3.0
suboptions: suboptions:
platform: platform:
description: description:
- When pulling an image, ask for this specific platform. - When pulling an image, ask for this specific platform.
- Note that this value is not used to determine whether the image needs to be pulled. This might change - Note that this value is not used to determine whether the image needs to be pulled. This might change in the future
in the future in a minor release, though. in a minor release, though.
type: str type: str
push: push:
description: description:
@@ -223,16 +213,16 @@ options:
description: description:
- Use with O(state=present) to tag the image. - Use with O(state=present) to tag the image.
- Expects format C(repository:tag). If no tag is provided, will use the value of the O(tag) parameter or V(latest). - Expects format C(repository:tag). If no tag is provided, will use the value of the O(tag) parameter or V(latest).
- If O(push=true), O(repository) must either include a registry, or will be assumed to belong to the default - If O(push=true), O(repository) must either include a registry, or will be assumed to belong to the default registry
registry (Docker Hub). (Docker Hub).
type: str type: str
state: state:
description: description:
- Make assertions about the state of an image. - Make assertions about the state of an image.
- When V(absent) an image will be removed. Use the force option to un-tag and remove all images - When V(absent) an image will be removed. Use the force option to un-tag and remove all images matching the provided
matching the provided name. name.
- When V(present) check if an image exists using the provided name and tag. If the image is not found or the - When V(present) check if an image exists using the provided name and tag. If the image is not found or the force option
force option is used, the image will either be pulled, built or loaded, depending on the O(source) option. is used, the image will either be pulled, built or loaded, depending on the O(source) option.
type: str type: str
default: present default: present
choices: choices:
@@ -240,8 +230,7 @@ options:
- present - present
tag: tag:
description: description:
- Used to select an image when pulling. Will be added to the image when pushing, tagging or building. Defaults to - Used to select an image when pulling. Will be added to the image when pushing, tagging or building. Defaults to V(latest).
V(latest).
- If O(name) parameter format is C(name:tag), then tag value from O(name) will take precedence. - If O(name) parameter format is C(name:tag), then tag value from O(name) will take precedence.
type: str type: str
default: latest default: latest
@@ -263,10 +252,9 @@ seealso:
- module: community.docker.docker_image_push - module: community.docker.docker_image_push
- module: community.docker.docker_image_remove - module: community.docker.docker_image_remove
- module: community.docker.docker_image_tag - module: community.docker.docker_image_tag
''' """
EXAMPLES = '''
EXAMPLES = r"""
- name: Pull an image - name: Pull an image
community.docker.docker_image: community.docker.docker_image:
name: pacur/centos-7 name: pacur/centos-7
@@ -350,9 +338,9 @@ EXAMPLES = '''
- nginx:latest - nginx:latest
- alpine:3.8 - alpine:3.8
source: build source: build
''' """
RETURN = ''' RETURN = r"""
image: image:
description: Image inspection results for the affected image. description: Image inspection results for the affected image.
returned: success returned: success
@@ -364,7 +352,7 @@ stdout:
type: str type: str
sample: "" sample: ""
version_added: 1.0.0 version_added: 1.0.0
''' """
import errno import errno
import json import json
+40 -49
View File
@@ -8,8 +8,7 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = r"""
---
module: docker_image_build module: docker_image_build
short_description: Build Docker images using Docker buildx short_description: Build Docker images using Docker buildx
@@ -18,10 +17,8 @@ version_added: 3.6.0
description: description:
- This module allows you to build Docker images using Docker's buildx plugin (BuildKit). - This module allows you to build Docker images using Docker's buildx plugin (BuildKit).
- Note that the module is B(not idempotent) in the sense of classical Ansible modules. - Note that the module is B(not idempotent) in the sense of classical Ansible modules. The only idempotence check is whether
The only idempotence check is whether the built image already exists. This check can the built image already exists. This check can be disabled with the O(rebuild) option.
be disabled with the O(rebuild) option.
extends_documentation_fragment: extends_documentation_fragment:
- community.docker.docker.cli_documentation - community.docker.docker.cli_documentation
- community.docker.attributes - community.docker.attributes
@@ -36,8 +33,8 @@ attributes:
options: options:
name: name:
description: description:
- "Image name. Name format will be one of: C(name), C(repository/name), C(registry_server:port/name). - 'Image name. Name format will be one of: C(name), C(repository/name), C(registry_server:port/name). When pushing or
When pushing or pulling an image the name can optionally include the tag by appending C(:tag_name)." pulling an image the name can optionally include the tag by appending C(:tag_name).'
- Note that image IDs (hashes) and names with digest cannot be used. - Note that image IDs (hashes) and names with digest cannot be used.
type: str type: str
required: true required: true
@@ -79,9 +76,8 @@ options:
etc_hosts: etc_hosts:
description: description:
- Extra hosts to add to C(/etc/hosts) in building containers, as a mapping of hostname to IP address. - Extra hosts to add to C(/etc/hosts) in building containers, as a mapping of hostname to IP address.
- Instead of an IP address, the special value V(host-gateway) can also be used, which - Instead of an IP address, the special value V(host-gateway) can also be used, which resolves to the host's gateway
resolves to the host's gateway IP and allows building containers to connect to services running IP and allows building containers to connect to services running on the host.
on the host.
type: dict type: dict
args: args:
description: description:
@@ -90,8 +86,7 @@ options:
type: dict type: dict
target: target:
description: description:
- When building an image specifies an intermediate build stage by - When building an image specifies an intermediate build stage by name as a final stage for the resulting image.
name as a final stage for the resulting image.
type: str type: str
platform: platform:
description: description:
@@ -101,9 +96,8 @@ options:
elements: str elements: str
shm_size: shm_size:
description: description:
- "Size of C(/dev/shm) in format C(<number>[<unit>]). Number is positive integer. - Size of C(/dev/shm) in format C(<number>[<unit>]). Number is positive integer. Unit can be V(B) (byte), V(K) (kibibyte,
Unit can be V(B) (byte), V(K) (kibibyte, 1024B), V(M) (mebibyte), V(G) (gibibyte), 1024B), V(M) (mebibyte), V(G) (gibibyte), V(T) (tebibyte), or V(P) (pebibyte).
V(T) (tebibyte), or V(P) (pebibyte)."
- Omitting the unit defaults to bytes. If you omit the size entirely, Docker daemon uses V(64M). - Omitting the unit defaults to bytes. If you omit the size entirely, Docker daemon uses V(64M).
type: str type: str
labels: labels:
@@ -145,8 +139,8 @@ options:
- Note that this requires the Buildkit plugin to have version 0.6.0 or newer. - Note that this requires the Buildkit plugin to have version 0.6.0 or newer.
value: value:
- Provides the secret from a given value O(secrets[].value). - Provides the secret from a given value O(secrets[].value).
- B(Note) that the secret will be passed as an environment variable to C(docker compose). - B(Note) that the secret will be passed as an environment variable to C(docker compose). Use another mean of
Use another mean of transport if you consider this not safe enough. transport if you consider this not safe enough.
- Note that this requires the Buildkit plugin to have version 0.6.0 or newer. - Note that this requires the Buildkit plugin to have version 0.6.0 or newer.
required: true required: true
src: src:
@@ -162,24 +156,23 @@ options:
value: value:
description: description:
- Value of the secret. - Value of the secret.
- B(Note) that the secret will be passed as an environment variable to C(docker compose). - B(Note) that the secret will be passed as an environment variable to C(docker compose). Use another mean of transport
Use another mean of transport if you consider this not safe enough. if you consider this not safe enough.
- Only supported and required for O(secrets[].type=value). - Only supported and required for O(secrets[].type=value).
type: str type: str
outputs: outputs:
description: description:
- Output destinations. - Output destinations.
- You can provide a list of exporters to export the built image in various places. - You can provide a list of exporters to export the built image in various places. Note that not all exporters might
Note that not all exporters might be supported by the build driver used. be supported by the build driver used.
- Note that depending on how this option is used, no image with name O(name) and tag O(tag) might - Note that depending on how this option is used, no image with name O(name) and tag O(tag) might be created, which
be created, which can cause the basic idempotency this module offers to not work. can cause the basic idempotency this module offers to not work.
- Providing an empty list to this option is equivalent to not specifying it at all. - Providing an empty list to this option is equivalent to not specifying it at all. The default behavior is a single
The default behavior is a single entry with O(outputs[].type=image). entry with O(outputs[].type=image).
- B(Note) that since community.docker 4.2.0, an entry for O(name)/O(tag) is added if O(outputs) - B(Note) that since community.docker 4.2.0, an entry for O(name)/O(tag) is added if O(outputs) has at least one entry
has at least one entry and no entry has type O(outputs[].type=image) and includes O(name)/O(tag) and no entry has type O(outputs[].type=image) and includes O(name)/O(tag) in O(outputs[].name). This is because the
in O(outputs[].name). This is because the module would otherwise pass C(--tag name:image) to module would otherwise pass C(--tag name:image) to the buildx plugin, which for some reason overwrites all images
the buildx plugin, which for some reason overwrites all images in O(outputs) by the C(name:image) in O(outputs) by the C(name:image) provided in O(name)/O(tag).
provided in O(name)/O(tag).
type: list type: list
elements: dict elements: dict
version_added: 3.10.0 version_added: 3.10.0
@@ -190,30 +183,28 @@ options:
type: str type: str
choices: choices:
local: local:
- This export type writes all result files to a directory on the client. - This export type writes all result files to a directory on the client. The new files will be owned by the current
The new files will be owned by the current user. user. On multi-platform builds, all results will be put in subdirectories by their platform.
On multi-platform builds, all results will be put in subdirectories by their platform.
- The destination has to be provided in O(outputs[].dest). - The destination has to be provided in O(outputs[].dest).
tar: tar:
- This export type export type writes all result files as a single tarball on the client. - This export type export type writes all result files as a single tarball on the client. On multi-platform builds,
On multi-platform builds, all results will be put in subdirectories by their platform. all results will be put in subdirectories by their platform.
- The destination has to be provided in O(outputs[].dest). - The destination has to be provided in O(outputs[].dest).
oci: oci:
- This export type writes the result image or manifest list as an - This export type writes the result image or manifest list as an L(OCI image layout,
L(OCI image layout, https://github.com/opencontainers/image-spec/blob/v1.0.1/image-layout.md) https://github.com/opencontainers/image-spec/blob/v1.0.1/image-layout.md)
tarball on the client. tarball on the client.
- The destination has to be provided in O(outputs[].dest). - The destination has to be provided in O(outputs[].dest).
docker: docker:
- This export type writes the single-platform result image as a Docker image specification tarball on the client. - This export type writes the single-platform result image as a Docker image specification tarball on the client.
Tarballs created by this exporter are also OCI compatible. Tarballs created by this exporter are also OCI compatible.
- The destination can be provided in O(outputs[].dest). - The destination can be provided in O(outputs[].dest). If not specified, the tar will be loaded automatically
If not specified, the tar will be loaded automatically to the local image store. to the local image store.
- The Docker context where to import the result can be provided in O(outputs[].context). - The Docker context where to import the result can be provided in O(outputs[].context).
image: image:
- This exporter writes the build result as an image or a manifest list. - This exporter writes the build result as an image or a manifest list. When using this driver, the image will
When using this driver, the image will appear in C(docker images). appear in C(docker images).
- The image name can be provided in O(outputs[].name). If it is not provided, - The image name can be provided in O(outputs[].name). If it is not provided, O(name) and O(tag) will be used.
O(name) and O(tag) will be used.
- Optionally, image can be automatically pushed to a registry by setting O(outputs[].push=true). - Optionally, image can be automatically pushed to a registry by setting O(outputs[].push=true).
required: true required: true
dest: dest:
@@ -250,9 +241,9 @@ author:
seealso: seealso:
- module: community.docker.docker_image_push - module: community.docker.docker_image_push
- module: community.docker.docker_image_tag - module: community.docker.docker_image_tag
''' """
EXAMPLES = ''' EXAMPLES = r"""
- name: Build Python 3.12 image - name: Build Python 3.12 image
community.docker.docker_image_build: community.docker.docker_image_build:
name: localhost/python/3.12:latest name: localhost/python/3.12:latest
@@ -267,9 +258,9 @@ EXAMPLES = '''
platform: platform:
- linux/amd64 - linux/amd64
- linux/arm64/v8 - linux/arm64/v8
''' """
RETURN = ''' RETURN = r"""
image: image:
description: Image inspection results for the affected image. description: Image inspection results for the affected image.
returned: success returned: success
@@ -282,7 +273,7 @@ command:
type: list type: list
elements: str elements: str
version_added: 4.2.0 version_added: 4.2.0
''' """
import base64 import base64
import os import os
+8 -10
View File
@@ -8,8 +8,7 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = r"""
---
module: docker_image_export module: docker_image_export
short_description: Export (archive) Docker images short_description: Export (archive) Docker images
@@ -19,7 +18,6 @@ version_added: 3.7.0
description: description:
- Creates an archive (tarball) from one or more Docker images. - Creates an archive (tarball) from one or more Docker images.
- This can be copied to another machine and loaded with M(community.docker.docker_image_load). - This can be copied to another machine and loaded with M(community.docker.docker_image_load).
extends_documentation_fragment: extends_documentation_fragment:
- community.docker.docker.api_documentation - community.docker.docker.api_documentation
- community.docker.attributes - community.docker.attributes
@@ -34,8 +32,8 @@ attributes:
options: options:
names: names:
description: description:
- "One or more image names. Name format will be one of: C(name), C(repository/name), C(registry_server:port/name). - 'One or more image names. Name format will be one of: C(name), C(repository/name), C(registry_server:port/name). When
When pushing or pulling an image the name can optionally include the tag by appending C(:tag_name)." pushing or pulling an image the name can optionally include the tag by appending C(:tag_name).'
- Note that image IDs (hashes) can also be used. - Note that image IDs (hashes) can also be used.
type: list type: list
elements: str elements: str
@@ -68,9 +66,9 @@ seealso:
- module: community.docker.docker_image - module: community.docker.docker_image
- module: community.docker.docker_image_info - module: community.docker.docker_image_info
- module: community.docker.docker_image_load - module: community.docker.docker_image_load
''' """
EXAMPLES = ''' EXAMPLES = r"""
- name: Export an image - name: Export an image
community.docker.docker_image_export: community.docker.docker_image_export:
name: pacur/centos-7 name: pacur/centos-7
@@ -82,16 +80,16 @@ EXAMPLES = '''
- hello-world:latest - hello-world:latest
- pacur/centos-7:latest - pacur/centos-7:latest
path: /tmp/various.tar path: /tmp/various.tar
''' """
RETURN = ''' RETURN = r"""
images: images:
description: Image inspection results for the affected images. description: Image inspection results for the affected images.
returned: success returned: success
type: list type: list
elements: dict elements: dict
sample: [] sample: []
''' """
import traceback import traceback
+27 -104
View File
@@ -8,23 +8,20 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = r"""
---
module: docker_image_info module: docker_image_info
short_description: Inspect docker images short_description: Inspect docker images
description: description:
- Provide one or more image names, and the module will inspect each, returning an array of inspection results. - Provide one or more image names, and the module will inspect each, returning an array of inspection results.
- If an image does not exist locally, it will not appear in the results. If you want to check whether an image exists - If an image does not exist locally, it will not appear in the results. If you want to check whether an image exists locally,
locally, you can call the module with the image name, then check whether the result list is empty (image does not you can call the module with the image name, then check whether the result list is empty (image does not exist) or has
exist) or has one element (the image exists locally). one element (the image exists locally).
- The module will not attempt to pull images from registries. Use M(community.docker.docker_image) with - The module will not attempt to pull images from registries. Use M(community.docker.docker_image) with O(community.docker.docker_image#module:source=pull)
O(community.docker.docker_image#module:source=pull) to ensure an image is pulled. to ensure an image is pulled.
notes: notes:
- This module was called C(docker_image_facts) before Ansible 2.8. The usage did not change. - This module was called C(docker_image_facts) before Ansible 2.8. The usage did not change.
extends_documentation_fragment: extends_documentation_fragment:
- community.docker.docker.api_documentation - community.docker.docker.api_documentation
- community.docker.attributes - community.docker.attributes
@@ -34,9 +31,8 @@ extends_documentation_fragment:
options: options:
name: name:
description: description:
- An image name or a list of image names. Name format will be C(name[:tag]) or C(repository/name[:tag]), - An image name or a list of image names. Name format will be C(name[:tag]) or C(repository/name[:tag]), where C(tag)
where C(tag) is optional. If a tag is not provided, V(latest) will be used. Instead of image names, also is optional. If a tag is not provided, V(latest) will be used. Instead of image names, also image IDs can be used.
image IDs can be used.
- If no name is provided, a list of all images will be returned. - If no name is provided, a list of all images will be returned.
type: list type: list
elements: str elements: str
@@ -46,10 +42,9 @@ requirements:
author: author:
- Chris Houseknecht (@chouseknecht) - Chris Houseknecht (@chouseknecht)
"""
''' EXAMPLES = r"""
EXAMPLES = '''
- name: Inspect a single image - name: Inspect a single image
community.docker.docker_image_info: community.docker.docker_image_info:
name: pacur/centos-7 name: pacur/centos-7
@@ -65,9 +60,9 @@ EXAMPLES = '''
ansible.builtin.assert: ansible.builtin.assert:
that: that:
- result.images | length == 2 - result.images | length == 2
''' """
RETURN = ''' RETURN = r"""
images: images:
description: description:
- Inspection results for the selected images. - Inspection results for the selected images.
@@ -75,93 +70,21 @@ images:
returned: always returned: always
type: list type: list
elements: dict elements: dict
sample: [ sample: [{"Architecture": "amd64", "Author": "", "Comment": "", "Config": {"AttachStderr": false, "AttachStdin": false,
{ "AttachStdout": false, "Cmd": ["/etc/docker/registry/config.yml"], "Domainname": "", "Entrypoint": ["/bin/registry"],
"Architecture": "amd64", "Env": ["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"], "ExposedPorts": {"5000/tcp": {}},
"Author": "", "Hostname": "e5c68db50333", "Image": "c72dce2618dc8f7b794d2b2c2b1e64e0205ead5befc294f8111da23bd6a2c799", "Labels": {},
"Comment": "", "OnBuild": [], "OpenStdin": false, "StdinOnce": false, "Tty": false, "User": "", "Volumes": {"/var/lib/registry": {}},
"Config": { "WorkingDir": ""}, "Container": "e83a452b8fb89d78a25a6739457050131ca5c863629a47639530d9ad2008d610", "ContainerConfig": {
"AttachStderr": false, "AttachStderr": false, "AttachStdin": false, "AttachStdout": false, "Cmd": ["/bin/sh", "-c", '#(nop) CMD ["/etc/docker/registry/config.yml"]'],
"AttachStdin": false, "Domainname": "", "Entrypoint": ["/bin/registry"], "Env": ["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],
"AttachStdout": false, "ExposedPorts": {"5000/tcp": {}}, "Hostname": "e5c68db50333", "Image": "c72dce2618dc8f7b794d2b2c2b1e64e0205ead5befc294f8111da23bd6a2c799",
"Cmd": [ "Labels": {}, "OnBuild": [], "OpenStdin": false, "StdinOnce": false, "Tty": false, "User": "", "Volumes": {"/var/lib/registry": {}},
"/etc/docker/registry/config.yml" "WorkingDir": ""}, "Created": "2016-03-08T21:08:15.399680378Z", "DockerVersion": "1.9.1", "GraphDriver": {"Data": null,
], "Name": "aufs"}, "Id": "53773d8552f07b730f3e19979e32499519807d67b344141d965463a950a66e08", "Name": "registry:2",
"Domainname": "", "Os": "linux", "Parent": "f0b1f729f784b755e7bf9c8c2e65d8a0a35a533769c2588f02895f6781ac0805", "RepoDigests": [], "RepoTags": [
"Entrypoint": [ "registry:2"], "Size": 0, "VirtualSize": 165808884}]
"/bin/registry" """
],
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"ExposedPorts": {
"5000/tcp": {}
},
"Hostname": "e5c68db50333",
"Image": "c72dce2618dc8f7b794d2b2c2b1e64e0205ead5befc294f8111da23bd6a2c799",
"Labels": {},
"OnBuild": [],
"OpenStdin": false,
"StdinOnce": false,
"Tty": false,
"User": "",
"Volumes": {
"/var/lib/registry": {}
},
"WorkingDir": ""
},
"Container": "e83a452b8fb89d78a25a6739457050131ca5c863629a47639530d9ad2008d610",
"ContainerConfig": {
"AttachStderr": false,
"AttachStdin": false,
"AttachStdout": false,
"Cmd": [
"/bin/sh",
"-c",
'#(nop) CMD ["/etc/docker/registry/config.yml"]'
],
"Domainname": "",
"Entrypoint": [
"/bin/registry"
],
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"ExposedPorts": {
"5000/tcp": {}
},
"Hostname": "e5c68db50333",
"Image": "c72dce2618dc8f7b794d2b2c2b1e64e0205ead5befc294f8111da23bd6a2c799",
"Labels": {},
"OnBuild": [],
"OpenStdin": false,
"StdinOnce": false,
"Tty": false,
"User": "",
"Volumes": {
"/var/lib/registry": {}
},
"WorkingDir": ""
},
"Created": "2016-03-08T21:08:15.399680378Z",
"DockerVersion": "1.9.1",
"GraphDriver": {
"Data": null,
"Name": "aufs"
},
"Id": "53773d8552f07b730f3e19979e32499519807d67b344141d965463a950a66e08",
"Name": "registry:2",
"Os": "linux",
"Parent": "f0b1f729f784b755e7bf9c8c2e65d8a0a35a533769c2588f02895f6781ac0805",
"RepoDigests": [],
"RepoTags": [
"registry:2"
],
"Size": 0,
"VirtualSize": 165808884
}
]
'''
import traceback import traceback
+7 -10
View File
@@ -9,8 +9,7 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = r"""
---
module: docker_image_load module: docker_image_load
short_description: Load docker image(s) from archives short_description: Load docker image(s) from archives
@@ -18,9 +17,7 @@ short_description: Load docker image(s) from archives
version_added: 1.3.0 version_added: 1.3.0
description: description:
- Load one or multiple Docker images from a C(.tar) archive, and return information on - Load one or multiple Docker images from a C(.tar) archive, and return information on the loaded image(s).
the loaded image(s).
extends_documentation_fragment: extends_documentation_fragment:
- community.docker.docker.api_documentation - community.docker.docker.api_documentation
- community.docker.attributes - community.docker.attributes
@@ -50,9 +47,9 @@ seealso:
- module: community.docker.docker_image_push - module: community.docker.docker_image_push
- module: community.docker.docker_image_remove - module: community.docker.docker_image_remove
- module: community.docker.docker_image_tag - module: community.docker.docker_image_tag
''' """
EXAMPLES = ''' EXAMPLES = r"""
- name: Load all image(s) from the given tar file - name: Load all image(s) from the given tar file
community.docker.docker_image_load: community.docker.docker_image_load:
path: /path/to/images.tar path: /path/to/images.tar
@@ -61,9 +58,9 @@ EXAMPLES = '''
- name: Print the loaded image names - name: Print the loaded image names
ansible.builtin.debug: ansible.builtin.debug:
msg: "Loaded the following images: {{ result.image_names | join(', ') }}" msg: "Loaded the following images: {{ result.image_names | join(', ') }}"
''' """
RETURN = ''' RETURN = r"""
image_names: image_names:
description: List of image names and IDs loaded from the archive. description: List of image names and IDs loaded from the archive.
returned: success returned: success
@@ -78,7 +75,7 @@ images:
type: list type: list
elements: dict elements: dict
sample: [] sample: []
''' """
import errno import errno
import traceback import traceback
+10 -12
View File
@@ -8,8 +8,7 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = r"""
---
module: docker_image_pull module: docker_image_pull
short_description: Pull Docker images from registries short_description: Pull Docker images from registries
@@ -18,7 +17,6 @@ version_added: 3.6.0
description: description:
- Pulls a Docker image from a registry. - Pulls a Docker image from a registry.
extends_documentation_fragment: extends_documentation_fragment:
- community.docker.docker.api_documentation - community.docker.docker.api_documentation
- community.docker.attributes - community.docker.attributes
@@ -36,8 +34,8 @@ attributes:
options: options:
name: name:
description: description:
- "Image name. Name format must be one of V(name), V(repository/name), or V(registry_server:port/name). - Image name. Name format must be one of V(name), V(repository/name), or V(registry_server:port/name).
- The name can optionally include the tag by appending V(:tag_name), or it can contain a digest by appending V(@hash:digest)." - The name can optionally include the tag by appending V(:tag_name), or it can contain a digest by appending V(@hash:digest).
type: str type: str
required: true required: true
tag: tag:
@@ -54,8 +52,8 @@ options:
description: description:
- Determines when to pull an image. - Determines when to pull an image.
- If V(always), will always pull the image. - If V(always), will always pull the image.
- If V(not_present), will only pull the image if no image of the name exists on the current Docker daemon, - If V(not_present), will only pull the image if no image of the name exists on the current Docker daemon, or if O(platform)
or if O(platform) does not match. does not match.
type: str type: str
choices: choices:
- always - always
@@ -72,23 +70,23 @@ seealso:
- module: community.docker.docker_image_pull - module: community.docker.docker_image_pull
- module: community.docker.docker_image_remove - module: community.docker.docker_image_remove
- module: community.docker.docker_image_tag - module: community.docker.docker_image_tag
''' """
EXAMPLES = ''' EXAMPLES = r"""
- name: Pull an image - name: Pull an image
community.docker.docker_image_pull: community.docker.docker_image_pull:
name: pacur/centos-7 name: pacur/centos-7
# Select platform for pulling. If not specified, will pull whatever docker prefers. # Select platform for pulling. If not specified, will pull whatever docker prefers.
platform: amd64 platform: amd64
''' """
RETURN = ''' RETURN = r"""
image: image:
description: Image inspection results for the affected image. description: Image inspection results for the affected image.
returned: success returned: success
type: dict type: dict
sample: {} sample: {}
''' """
import traceback import traceback
+8 -10
View File
@@ -8,8 +8,7 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = r"""
---
module: docker_image_push module: docker_image_push
short_description: Push Docker images to registries short_description: Push Docker images to registries
@@ -18,7 +17,6 @@ version_added: 3.6.0
description: description:
- Pushes a Docker image to a registry. - Pushes a Docker image to a registry.
extends_documentation_fragment: extends_documentation_fragment:
- community.docker.docker.api_documentation - community.docker.docker.api_documentation
- community.docker.attributes - community.docker.attributes
@@ -33,8 +31,8 @@ attributes:
options: options:
name: name:
description: description:
- "Image name. Name format must be one of V(name), V(repository/name), or V(registry_server:port/name). - Image name. Name format must be one of V(name), V(repository/name), or V(registry_server:port/name).
- The name can optionally include the tag by appending V(:tag_name), or it can contain a digest by appending V(@hash:digest)." - The name can optionally include the tag by appending V(:tag_name), or it can contain a digest by appending V(@hash:digest).
type: str type: str
required: true required: true
tag: tag:
@@ -54,22 +52,22 @@ seealso:
- module: community.docker.docker_image_pull - module: community.docker.docker_image_pull
- module: community.docker.docker_image_remove - module: community.docker.docker_image_remove
- module: community.docker.docker_image_tag - module: community.docker.docker_image_tag
''' """
EXAMPLES = ''' EXAMPLES = r"""
- name: Push an image - name: Push an image
community.docker.docker_image_push: community.docker.docker_image_push:
name: registry.example.com:5000/repo/image name: registry.example.com:5000/repo/image
tag: latest tag: latest
''' """
RETURN = ''' RETURN = r"""
image: image:
description: Image inspection results for the affected image. description: Image inspection results for the affected image.
returned: success returned: success
type: dict type: dict
sample: {} sample: {}
''' """
import traceback import traceback
+8 -11
View File
@@ -8,8 +8,7 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = r"""
---
module: docker_image_remove module: docker_image_remove
short_description: Remove Docker images short_description: Remove Docker images
@@ -18,7 +17,6 @@ version_added: 3.6.0
description: description:
- Remove Docker images from the Docker daemon. - Remove Docker images from the Docker daemon.
extends_documentation_fragment: extends_documentation_fragment:
- community.docker.docker.api_documentation - community.docker.docker.api_documentation
- community.docker.attributes - community.docker.attributes
@@ -33,8 +31,8 @@ attributes:
options: options:
name: name:
description: description:
- "Image name. Name format will be one of: C(name), C(repository/name), C(registry_server:port/name). - 'Image name. Name format will be one of: C(name), C(repository/name), C(registry_server:port/name). When pushing or
When pushing or pulling an image the name can optionally include the tag by appending C(:tag_name)." pulling an image the name can optionally include the tag by appending C(:tag_name).'
- Note that image IDs (hashes) can also be used. - Note that image IDs (hashes) can also be used.
type: str type: str
required: true required: true
@@ -65,16 +63,15 @@ seealso:
- module: community.docker.docker_image_load - module: community.docker.docker_image_load
- module: community.docker.docker_image_pull - module: community.docker.docker_image_pull
- module: community.docker.docker_image_tag - module: community.docker.docker_image_tag
''' """
EXAMPLES = '''
EXAMPLES = r"""
- name: Remove an image - name: Remove an image
community.docker.docker_image_remove: community.docker.docker_image_remove:
name: pacur/centos-7 name: pacur/centos-7
''' """
RETURN = ''' RETURN = r"""
image: image:
description: description:
- Image inspection results for the affected image before removal. - Image inspection results for the affected image before removal.
@@ -96,7 +93,7 @@ untagged:
type: list type: list
elements: str elements: str
sample: [] sample: []
''' """
import traceback import traceback
+12 -12
View File
@@ -8,8 +8,7 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = r"""
---
module: docker_image_tag module: docker_image_tag
short_description: Tag Docker images with new names and/or tags short_description: Tag Docker images with new names and/or tags
@@ -18,7 +17,6 @@ version_added: 3.6.0
description: description:
- This module allows to tag Docker images with new names and/or tags. - This module allows to tag Docker images with new names and/or tags.
extends_documentation_fragment: extends_documentation_fragment:
- community.docker.docker.api_documentation - community.docker.docker.api_documentation
- community.docker.attributes - community.docker.attributes
@@ -33,8 +31,8 @@ attributes:
options: options:
name: name:
description: description:
- "Image name. Name format will be one of: C(name), C(repository/name), C(registry_server:port/name). - 'Image name. Name format will be one of: C(name), C(repository/name), C(registry_server:port/name). When pushing or
When pushing or pulling an image the name can optionally include the tag by appending C(:tag_name)." pulling an image the name can optionally include the tag by appending C(:tag_name).'
- Note that image IDs (hashes) can also be used. - Note that image IDs (hashes) can also be used.
type: str type: str
required: true required: true
@@ -47,13 +45,15 @@ options:
repository: repository:
description: description:
- List of new image names to tag the image as. - List of new image names to tag the image as.
- Expects format C(repository:tag). If no tag is provided, will use the value of the O(tag) parameter if present, or V(latest). - Expects format C(repository:tag). If no tag is provided, will use the value of the O(tag) parameter if present, or
V(latest).
type: list type: list
elements: str elements: str
required: true required: true
existing_images: existing_images:
description: description:
- Defines the behavior if the image to be tagged already exists and is another image than the one identified by O(name) and O(tag). - Defines the behavior if the image to be tagged already exists and is another image than the one identified by O(name)
and O(tag).
- If set to V(keep), the tagged image is kept. - If set to V(keep), the tagged image is kept.
- If set to V(overwrite), the tagged image is overwritten by the specified one. - If set to V(overwrite), the tagged image is overwritten by the specified one.
type: str type: str
@@ -71,18 +71,18 @@ author:
seealso: seealso:
- module: community.docker.docker_image_push - module: community.docker.docker_image_push
- module: community.docker.docker_image_remove - module: community.docker.docker_image_remove
''' """
EXAMPLES = ''' EXAMPLES = r"""
- name: Tag Python 3.12 image with two new names - name: Tag Python 3.12 image with two new names
community.docker.docker_image_tag: community.docker.docker_image_tag:
name: python:3.12 name: python:3.12
repository: repository:
- python-3:3.12 - python-3:3.12
- local-registry:5000/python-3/3.12:latest - local-registry:5000/python-3/3.12:latest
''' """
RETURN = ''' RETURN = r"""
image: image:
description: Image inspection results for the affected image. description: Image inspection results for the affected image.
returned: success returned: success
@@ -96,7 +96,7 @@ tagged_images:
elements: str elements: str
sample: sample:
- python-3:3.12 - python-3:3.12
''' """
import traceback import traceback
+12 -18
View File
@@ -11,18 +11,16 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = r"""
---
module: docker_login module: docker_login
short_description: Log into a Docker registry. short_description: Log into a Docker registry
description: description:
- Provides functionality similar to the C(docker login) command. - Provides functionality similar to the C(docker login) command.
- Authenticate with a docker registry and add the credentials to your local Docker config file respectively the - Authenticate with a docker registry and add the credentials to your local Docker config file respectively the credentials
credentials store associated to the registry. Adding the credentials to the config files resp. the credential store associated to the registry. Adding the credentials to the config files resp. the credential store allows future
store allows future connections to the registry using tools such as Ansible's Docker modules, the Docker CLI connections to the registry using tools such as Ansible's Docker modules, the Docker CLI and Docker SDK for Python without
and Docker SDK for Python without needing to provide credentials. needing to provide credentials.
- Running in check mode will perform the authentication without updating the config file. - Running in check mode will perform the authentication without updating the config file.
extends_documentation_fragment: extends_documentation_fragment:
- community.docker.docker.api_documentation - community.docker.docker.api_documentation
- community.docker.attributes - community.docker.attributes
@@ -82,10 +80,9 @@ requirements:
author: author:
- Olaf Kilian (@olsaki) <olaf.kilian@symanex.com> - Olaf Kilian (@olsaki) <olaf.kilian@symanex.com>
- Chris Houseknecht (@chouseknecht) - Chris Houseknecht (@chouseknecht)
''' """
EXAMPLES = '''
EXAMPLES = r"""
- name: Log into DockerHub - name: Log into DockerHub
community.docker.docker_login: community.docker.docker_login:
username: docker username: docker
@@ -107,18 +104,15 @@ EXAMPLES = '''
- name: Log out of DockerHub - name: Log out of DockerHub
community.docker.docker_login: community.docker.docker_login:
state: absent state: absent
''' """
RETURN = ''' RETURN = r"""
login_results: login_results:
description: Results from the login. description: Results from the login.
returned: when O(state=present) returned: when O(state=present)
type: dict type: dict
sample: { sample: {"serveraddress": "localhost:5000", "username": "testuser"}
"serveraddress": "localhost:5000", """
"username": "testuser"
}
'''
import base64 import base64
import json import json
+30 -34
View File
@@ -8,13 +8,12 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = r"""
module: docker_network module: docker_network
short_description: Manage Docker networks short_description: Manage Docker networks
description: description:
- Create/remove Docker networks and connect containers to them. - Create/remove Docker networks and connect containers to them.
- Performs largely the same function as the C(docker network) CLI subcommand. - Performs largely the same function as the C(docker network) CLI subcommand.
extends_documentation_fragment: extends_documentation_fragment:
- community.docker.docker.api_documentation - community.docker.docker.api_documentation
- community.docker.attributes - community.docker.attributes
@@ -50,9 +49,9 @@ options:
connected: connected:
description: description:
- List of container names or container IDs to connect to a network. - List of container names or container IDs to connect to a network.
- Please note that the module only makes sure that these containers are connected to the network, - Please note that the module only makes sure that these containers are connected to the network, but does not care
but does not care about connection options. If you rely on specific IP addresses etc., use the about connection options. If you rely on specific IP addresses etc., use the M(community.docker.docker_container)
M(community.docker.docker_container) module to ensure your containers are correctly connected to this network. module to ensure your containers are correctly connected to this network.
type: list type: list
elements: str elements: str
default: [] default: []
@@ -73,10 +72,9 @@ options:
force: force:
description: description:
- With state V(present) will disconnect all containers for existing networks, delete the network and re-create the - With state V(present) will disconnect all containers for existing networks, delete the network and re-create the network.
network. - This option is required if you have changed the IPAM or driver options and want an existing network to be updated
- This option is required if you have changed the IPAM or driver options to use the new options.
and want an existing network to be updated to use the new options.
type: bool type: bool
default: false default: false
@@ -112,9 +110,9 @@ options:
ipam_config: ipam_config:
description: description:
- List of IPAM config blocks. Consult - List of IPAM config blocks. Consult L(Docker docs,https://docs.docker.com/compose/compose-file/compose-file-v2/#ipam)
L(Docker docs,https://docs.docker.com/compose/compose-file/compose-file-v2/#ipam) for valid options and values. for valid options and values. Note that O(ipam_config[].iprange) is spelled differently here (we use the notation
Note that O(ipam_config[].iprange) is spelled differently here (we use the notation from the Docker SDK for Python). from the Docker SDK for Python).
type: list type: list
elements: dict elements: dict
suboptions: suboptions:
@@ -137,14 +135,11 @@ options:
state: state:
description: description:
- V(absent) deletes the network. If a network has connected containers, these will be - V(absent) deletes the network. If a network has connected containers, these will be detached from the network.
detached from the network. - V(present) creates the network, if it does not already exist with the specified parameters, and connects the list
- V(present) creates the network, if it does not already exist with the of containers provided via the connected parameter. Containers not on the list will be disconnected. An empty list
specified parameters, and connects the list of containers provided via will leave no containers connected to the network. Use the O(appends) option to leave existing containers connected.
the connected parameter. Containers not on the list will be disconnected. Use the O(force) options to force re-creation of the network.
An empty list will leave no containers connected to the network. Use the
O(appends) option to leave existing containers connected. Use the O(force)
options to force re-creation of the network.
type: str type: str
default: present default: present
choices: choices:
@@ -173,18 +168,19 @@ options:
attachable: attachable:
description: description:
- If enabled, and the network is in the global scope, non-service containers on worker nodes will be able to connect to the network. - If enabled, and the network is in the global scope, non-service containers on worker nodes will be able to connect
to the network.
type: bool type: bool
notes: notes:
- When network options are changed, the module disconnects all containers from the network, deletes the network, and re-creates the network. - When network options are changed, the module disconnects all containers from the network, deletes the network, and re-creates
It does not try to reconnect containers, except the ones listed in (O(connected), and even for these, it does not consider specific the network. It does not try to reconnect containers, except the ones listed in (O(connected), and even for these, it
connection options like fixed IP addresses or MAC addresses. If you need more control over how the containers are connected to the does not consider specific connection options like fixed IP addresses or MAC addresses. If you need more control over
network, loop the M(community.docker.docker_container) module to loop over your containers to make sure they are connected properly. how the containers are connected to the network, loop the M(community.docker.docker_container) module to loop over your
- The module does not support Docker Swarm. This means that it will not try to disconnect or reconnect services. If services are connected to the containers to make sure they are connected properly.
network, deleting the network will fail. When network options are changed, the network has to be deleted and recreated, so this will - The module does not support Docker Swarm. This means that it will not try to disconnect or reconnect services. If services
fail as well. are connected to the network, deleting the network will fail. When network options are changed, the network has to be
deleted and recreated, so this will fail as well.
author: author:
- "Ben Keith (@keitwb)" - "Ben Keith (@keitwb)"
- "Chris Houseknecht (@chouseknecht)" - "Chris Houseknecht (@chouseknecht)"
@@ -192,9 +188,9 @@ author:
requirements: requirements:
- "Docker API >= 1.25" - "Docker API >= 1.25"
''' """
EXAMPLES = ''' EXAMPLES = r"""
- name: Create a network - name: Create a network
community.docker.docker_network: community.docker.docker_network:
name: network_one name: network_one
@@ -262,16 +258,16 @@ EXAMPLES = '''
community.docker.docker_network: community.docker.docker_network:
name: network_one name: network_one
state: absent state: absent
''' """
RETURN = ''' RETURN = r"""
network: network:
description: description:
- Network inspection results for the affected network. - Network inspection results for the affected network.
returned: success returned: success
type: dict type: dict
sample: {} sample: {}
''' """
import re import re
import traceback import traceback
+10 -36
View File
@@ -8,8 +8,7 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = r"""
---
module: docker_network_info module: docker_network_info
short_description: Retrieves facts about docker network short_description: Retrieves facts about docker network
@@ -18,7 +17,6 @@ description:
- Retrieves facts about a docker network. - Retrieves facts about a docker network.
- Essentially returns the output of C(docker network inspect <name>), similar to what M(community.docker.docker_network) - Essentially returns the output of C(docker network inspect <name>), similar to what M(community.docker.docker_network)
returns for a non-absent network. returns for a non-absent network.
extends_documentation_fragment: extends_documentation_fragment:
- community.docker.docker.api_documentation - community.docker.docker.api_documentation
- community.docker.attributes - community.docker.attributes
@@ -38,9 +36,9 @@ author:
requirements: requirements:
- "Docker API >= 1.25" - "Docker API >= 1.25"
''' """
EXAMPLES = ''' EXAMPLES = r"""
- name: Get infos on network - name: Get infos on network
community.docker.docker_network_info: community.docker.docker_network_info:
name: mydata name: mydata
@@ -54,9 +52,9 @@ EXAMPLES = '''
ansible.builtin.debug: ansible.builtin.debug:
var: result.network var: result.network
when: result.exists when: result.exists
''' """
RETURN = ''' RETURN = r"""
exists: exists:
description: description:
- Returns whether the network exists. - Returns whether the network exists.
@@ -69,35 +67,11 @@ network:
- Will be V(none) if network does not exist. - Will be V(none) if network does not exist.
returned: always returned: always
type: dict type: dict
sample: { sample: {"Attachable": false, "ConfigFrom": {"Network": ""}, "ConfigOnly": false, "Containers": {}, "Created": "2018-12-07T01:47:51.250835114-06:00",
"Attachable": false, "Driver": "bridge", "EnableIPv6": false, "IPAM": {"Config": [{"Gateway": "192.168.96.1", "Subnet": "192.168.96.0/20"}],
"ConfigFrom": { "Driver": "default", "Options": null}, "Id": "0856968545f22026c41c2c7c3d448319d3b4a6a03a40b148b3ac4031696d1c0a", "Ingress": false,
"Network": "" "Internal": false, "Labels": {}, "Name": "ansible-test-f2700bba", "Options": {}, "Scope": "local"}
}, """
"ConfigOnly": false,
"Containers": {},
"Created": "2018-12-07T01:47:51.250835114-06:00",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Config": [
{
"Gateway": "192.168.96.1",
"Subnet": "192.168.96.0/20"
}
],
"Driver": "default",
"Options": null
},
"Id": "0856968545f22026c41c2c7c3d448319d3b4a6a03a40b148b3ac4031696d1c0a",
"Ingress": false,
"Internal": false,
"Labels": {},
"Name": "ansible-test-f2700bba",
"Options": {},
"Scope": "local"
}
'''
import traceback import traceback
+23 -29
View File
@@ -8,14 +8,12 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = r"""
---
module: docker_node module: docker_node
short_description: Manage Docker Swarm node short_description: Manage Docker Swarm node
description: description:
- Manages the Docker nodes via Swarm Manager. - Manages the Docker nodes via Swarm Manager.
- This module allows to change the node's role, its availability, and to modify, add or remove node labels. - This module allows to change the node's role, its availability, and to modify, add or remove node labels.
extends_documentation_fragment: extends_documentation_fragment:
- community.docker.docker - community.docker.docker
- community.docker.docker.docker_py_1_documentation - community.docker.docker.docker_py_1_documentation
@@ -32,27 +30,25 @@ options:
hostname: hostname:
description: description:
- The hostname or ID of node as registered in Swarm. - The hostname or ID of node as registered in Swarm.
- If more than one node is registered using the same hostname the ID must be used, - If more than one node is registered using the same hostname the ID must be used, otherwise module will fail.
otherwise module will fail.
type: str type: str
required: true required: true
labels: labels:
description: description:
- User-defined key/value metadata that will be assigned as node attribute. - User-defined key/value metadata that will be assigned as node attribute.
- Label operations in this module apply to the docker swarm node specified by O(hostname). - Label operations in this module apply to the docker swarm node specified by O(hostname). Use M(community.docker.docker_swarm)
Use M(community.docker.docker_swarm) module to add/modify/remove swarm cluster labels. module to add/modify/remove swarm cluster labels.
- The actual state of labels assigned to the node when module completes its work depends on - The actual state of labels assigned to the node when module completes its work depends on O(labels_state) and O(labels_to_remove)
O(labels_state) and O(labels_to_remove) parameters values. See description below. parameters values. See description below.
type: dict type: dict
labels_state: labels_state:
description: description:
- It defines the operation on the labels assigned to node and labels specified in O(labels) option. - It defines the operation on the labels assigned to node and labels specified in O(labels) option.
- Set to V(merge) to combine labels provided in O(labels) with those already assigned to the node. - Set to V(merge) to combine labels provided in O(labels) with those already assigned to the node. If no labels are
If no labels are assigned then it will add listed labels. For labels that are already assigned assigned then it will add listed labels. For labels that are already assigned to the node, it will update their values.
to the node, it will update their values. The labels not specified in O(labels) will remain unchanged. The labels not specified in O(labels) will remain unchanged. If O(labels) is empty then no changes will be made.
If O(labels) is empty then no changes will be made. - Set to V(replace) to replace all assigned labels with provided ones. If O(labels) is empty then all labels assigned
- Set to V(replace) to replace all assigned labels with provided ones. If O(labels) is empty then to the node will be removed.
all labels assigned to the node will be removed.
type: str type: str
default: 'merge' default: 'merge'
choices: choices:
@@ -60,13 +56,13 @@ options:
- replace - replace
labels_to_remove: labels_to_remove:
description: description:
- List of labels that will be removed from the node configuration. The list has to contain only label - List of labels that will be removed from the node configuration. The list has to contain only label names, not their
names, not their values. values.
- If the label provided on the list is not assigned to the node, the entry is ignored. - If the label provided on the list is not assigned to the node, the entry is ignored.
- If the label is both on the O(labels_to_remove) and O(labels), then value provided in O(labels) remains - If the label is both on the O(labels_to_remove) and O(labels), then value provided in O(labels) remains assigned to
assigned to the node. the node.
- If O(labels_state=replace) and O(labels) is not provided or empty then all labels assigned to - If O(labels_state=replace) and O(labels) is not provided or empty then all labels assigned to node are removed and
node are removed and O(labels_to_remove) is ignored. O(labels_to_remove) is ignored.
type: list type: list
elements: str elements: str
availability: availability:
@@ -89,10 +85,9 @@ requirements:
author: author:
- Piotr Wojciechowski (@WojciechowskiPiotr) - Piotr Wojciechowski (@WojciechowskiPiotr)
- Thierry Bouvet (@tbouvet) - Thierry Bouvet (@tbouvet)
"""
''' EXAMPLES = r"""
EXAMPLES = '''
- name: Set node role - name: Set node role
community.docker.docker_node: community.docker.docker_node:
hostname: mynode hostname: mynode
@@ -127,15 +122,14 @@ EXAMPLES = '''
labels_to_remove: labels_to_remove:
- key1 - key1
- key2 - key2
''' """
RETURN = ''' RETURN = r"""
node: node:
description: Information about node after 'update' operation description: Information about node after 'update' operation.
returned: success returned: success
type: dict type: dict
"""
'''
import traceback import traceback
+8 -11
View File
@@ -8,8 +8,7 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = r"""
---
module: docker_node_info module: docker_node_info
short_description: Retrieves facts about docker swarm node from Swarm Manager short_description: Retrieves facts about docker swarm node from Swarm Manager
@@ -18,7 +17,6 @@ description:
- Retrieves facts about a docker node. - Retrieves facts about a docker node.
- Essentially returns the output of C(docker node inspect <name>). - Essentially returns the output of C(docker node inspect <name>).
- Must be executed on a host running as Swarm Manager, otherwise the module will fail. - Must be executed on a host running as Swarm Manager, otherwise the module will fail.
extends_documentation_fragment: extends_documentation_fragment:
- community.docker.docker - community.docker.docker
- community.docker.docker.docker_py_1_documentation - community.docker.docker.docker_py_1_documentation
@@ -50,9 +48,9 @@ author:
requirements: requirements:
- "L(Docker SDK for Python,https://docker-py.readthedocs.io/en/stable/) >= 2.4.0" - "L(Docker SDK for Python,https://docker-py.readthedocs.io/en/stable/) >= 2.4.0"
- "Docker API >= 1.25" - "Docker API >= 1.25"
''' """
EXAMPLES = ''' EXAMPLES = r"""
- name: Get info on all nodes - name: Get info on all nodes
community.docker.docker_node_info: community.docker.docker_node_info:
register: result register: result
@@ -73,20 +71,19 @@ EXAMPLES = '''
community.docker.docker_node_info: community.docker.docker_node_info:
self: true self: true
register: result register: result
''' """
RETURN = ''' RETURN = r"""
nodes: nodes:
description: description:
- Facts representing the current state of the nodes. Matches the C(docker node inspect) output. - Facts representing the current state of the nodes. Matches the C(docker node inspect) output.
- Can contain multiple entries if more than one node provided in O(name), or O(name) is not provided. - Can contain multiple entries if more than one node provided in O(name), or O(name) is not provided.
- If O(name) contains a list of nodes, the output will provide information on all nodes registered - If O(name) contains a list of nodes, the output will provide information on all nodes registered at the swarm, including
at the swarm, including nodes that left the swarm but have not been removed from the cluster on swarm nodes that left the swarm but have not been removed from the cluster on swarm managers and nodes that are unreachable.
managers and nodes that are unreachable.
returned: always returned: always
type: list type: list
elements: dict elements: dict
''' """
import traceback import traceback
+6 -7
View File
@@ -10,7 +10,7 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = r"""
module: docker_plugin module: docker_plugin
short_description: Manage Docker plugins short_description: Manage Docker plugins
version_added: 1.3.0 version_added: 1.3.0
@@ -19,7 +19,6 @@ description:
- Performs largely the same function as the C(docker plugin) CLI subcommand. - Performs largely the same function as the C(docker plugin) CLI subcommand.
notes: notes:
- The C(--grant-all-permissions) CLI flag is true by default in this module. - The C(--grant-all-permissions) CLI flag is true by default in this module.
extends_documentation_fragment: extends_documentation_fragment:
- community.docker.docker.api_documentation - community.docker.docker.api_documentation
- community.docker.attributes - community.docker.attributes
@@ -82,9 +81,9 @@ author:
requirements: requirements:
- "Docker API >= 1.25" - "Docker API >= 1.25"
''' """
EXAMPLES = ''' EXAMPLES = r"""
- name: Install a plugin - name: Install a plugin
community.docker.docker_plugin: community.docker.docker_plugin:
plugin_name: plugin_one plugin_name: plugin_one
@@ -111,9 +110,9 @@ EXAMPLES = '''
plugin_options: plugin_options:
IPALLOC_RANGE: "10.32.0.0/12" IPALLOC_RANGE: "10.32.0.0/12"
WEAVE_PASSWORD: "PASSWORD" WEAVE_PASSWORD: "PASSWORD"
''' """
RETURN = ''' RETURN = r"""
plugin: plugin:
description: description:
- Plugin inspection results for the affected plugin. - Plugin inspection results for the affected plugin.
@@ -125,7 +124,7 @@ actions:
- List of actions performed during task execution. - List of actions performed during task execution.
returned: when O(state) is not V(absent) returned: when O(state) is not V(absent)
type: list type: list
''' """
import traceback import traceback
+25 -28
View File
@@ -8,16 +8,14 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = r"""
---
module: docker_prune module: docker_prune
short_description: Allows to prune various docker objects short_description: Allows to prune various docker objects
description: description:
- Allows to run C(docker container prune), C(docker image prune), C(docker network prune) - Allows to run C(docker container prune), C(docker image prune), C(docker network prune) and C(docker volume prune) via
and C(docker volume prune) via the Docker API. the Docker API.
extends_documentation_fragment: extends_documentation_fragment:
- community.docker.docker.api_documentation - community.docker.docker.api_documentation
- community.docker.attributes - community.docker.attributes
@@ -38,9 +36,9 @@ options:
containers_filters: containers_filters:
description: description:
- A dictionary of filter values used for selecting containers to delete. - A dictionary of filter values used for selecting containers to delete.
- "For example, C(until: 24h)." - 'For example, C(until: 24h).'
- See L(the docker documentation,https://docs.docker.com/engine/reference/commandline/container_prune/#filtering) - See L(the docker documentation,https://docs.docker.com/engine/reference/commandline/container_prune/#filtering) for
for more information on possible filters. more information on possible filters.
type: dict type: dict
images: images:
description: description:
@@ -50,9 +48,9 @@ options:
images_filters: images_filters:
description: description:
- A dictionary of filter values used for selecting images to delete. - A dictionary of filter values used for selecting images to delete.
- "For example, C(dangling: true)." - 'For example, C(dangling: true).'
- See L(the docker documentation,https://docs.docker.com/engine/reference/commandline/image_prune/#filtering) - See L(the docker documentation,https://docs.docker.com/engine/reference/commandline/image_prune/#filtering) for more
for more information on possible filters. information on possible filters.
type: dict type: dict
networks: networks:
description: description:
@@ -62,8 +60,8 @@ options:
networks_filters: networks_filters:
description: description:
- A dictionary of filter values used for selecting networks to delete. - A dictionary of filter values used for selecting networks to delete.
- See L(the docker documentation,https://docs.docker.com/engine/reference/commandline/network_prune/#filtering) - See L(the docker documentation,https://docs.docker.com/engine/reference/commandline/network_prune/#filtering) for
for more information on possible filters. more information on possible filters.
type: dict type: dict
volumes: volumes:
description: description:
@@ -73,8 +71,8 @@ options:
volumes_filters: volumes_filters:
description: description:
- A dictionary of filter values used for selecting volumes to delete. - A dictionary of filter values used for selecting volumes to delete.
- See L(the docker documentation,https://docs.docker.com/engine/reference/commandline/volume_prune/#filtering) - See L(the docker documentation,https://docs.docker.com/engine/reference/commandline/volume_prune/#filtering) for more
for more information on possible filters. information on possible filters.
type: dict type: dict
builder_cache: builder_cache:
description: description:
@@ -90,17 +88,17 @@ options:
builder_cache_filters: builder_cache_filters:
description: description:
- A dictionary of filter values used for selecting images to delete. - A dictionary of filter values used for selecting images to delete.
- "For example, C(until: 10m)." - 'For example, C(until: 10m).'
- See L(the API documentation,https://docs.docker.com/engine/api/v1.44/#tag/Image/operation/BuildPrune) - See L(the API documentation,https://docs.docker.com/engine/api/v1.44/#tag/Image/operation/BuildPrune) for more information
for more information on possible filters. on possible filters.
type: dict type: dict
version_added: 3.10.0 version_added: 3.10.0
builder_cache_keep_storage: builder_cache_keep_storage:
description: description:
- Amount of disk space to keep for cache in format C(<number>[<unit>])." - Amount of disk space to keep for cache in format C(<number>[<unit>]).".
- "Number is a positive integer. Unit can be one of V(B) (byte), V(K) (kibibyte, 1024B), V(M) (mebibyte), V(G) (gibibyte), - Number is a positive integer. Unit can be one of V(B) (byte), V(K) (kibibyte, 1024B), V(M) (mebibyte), V(G) (gibibyte),
V(T) (tebibyte), or V(P) (pebibyte)." V(T) (tebibyte), or V(P) (pebibyte).
- "Omitting the unit defaults to bytes." - Omitting the unit defaults to bytes.
type: str type: str
version_added: 3.10.0 version_added: 3.10.0
@@ -109,12 +107,11 @@ author:
notes: notes:
- The module always returned C(changed=false) before community.docker 3.5.1. - The module always returned C(changed=false) before community.docker 3.5.1.
requirements: requirements:
- "Docker API >= 1.25" - "Docker API >= 1.25"
''' """
EXAMPLES = ''' EXAMPLES = r"""
- name: Prune containers older than 24h - name: Prune containers older than 24h
community.docker.docker_prune: community.docker.docker_prune:
containers: true containers: true
@@ -155,9 +152,9 @@ EXAMPLES = '''
networks: true networks: true
volumes: true volumes: true
builder_cache: true builder_cache: true
''' """
RETURN = ''' RETURN = r"""
# containers # containers
containers: containers:
description: description:
@@ -227,7 +224,7 @@ builder_cache_caches_deleted:
elements: str elements: str
sample: [] sample: []
version_added: 3.10.0 version_added: 3.10.0
''' """
import traceback import traceback
+15 -19
View File
@@ -8,19 +8,17 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = r"""
---
module: docker_secret module: docker_secret
short_description: Manage docker secrets. short_description: Manage docker secrets
description: description:
- Create and remove Docker secrets in a Swarm environment. Similar to C(docker secret create) and C(docker secret rm). - Create and remove Docker secrets in a Swarm environment. Similar to C(docker secret create) and C(docker secret rm).
- Adds to the metadata of new secrets C(ansible_key), an encrypted hash representation of the data, which is then used - Adds to the metadata of new secrets C(ansible_key), an encrypted hash representation of the data, which is then used in
in future runs to test if a secret has changed. If C(ansible_key) is not present, then a secret will not be updated future runs to test if a secret has changed. If C(ansible_key) is not present, then a secret will not be updated unless
unless the O(force) option is set. the O(force) option is set.
- Updates to secrets are performed by removing the secret and creating it again. - Updates to secrets are performed by removing the secret and creating it again.
extends_documentation_fragment: extends_documentation_fragment:
- community.docker.docker - community.docker.docker
- community.docker.docker.docker_py_2_documentation - community.docker.docker.docker_py_2_documentation
@@ -41,10 +39,8 @@ options:
type: str type: str
data_is_b64: data_is_b64:
description: description:
- If set to V(true), the data is assumed to be Base64 encoded and will be - If set to V(true), the data is assumed to be Base64 encoded and will be decoded before being used.
decoded before being used. - To use binary O(data), it is better to keep it Base64 encoded and let it be decoded by this option.
- To use binary O(data), it is better to keep it Base64 encoded and let it
be decoded by this option.
type: bool type: bool
default: false default: false
data_src: data_src:
@@ -55,8 +51,9 @@ options:
version_added: 1.10.0 version_added: 1.10.0
labels: labels:
description: description:
- "A map of key:value meta data, where both key and value are expected to be strings." - A map of key:value meta data, where both key and value are expected to be strings.
- If new meta data is provided, or existing meta data is modified, the secret will be updated by removing it and creating it again. - If new meta data is provided, or existing meta data is modified, the secret will be updated by removing it and creating
it again.
type: dict type: dict
force: force:
description: description:
@@ -99,10 +96,9 @@ requirements:
author: author:
- Chris Houseknecht (@chouseknecht) - Chris Houseknecht (@chouseknecht)
''' """
EXAMPLES = '''
EXAMPLES = r"""
- name: Create secret foo (from a file on the control machine) - name: Create secret foo (from a file on the control machine)
community.docker.docker_secret: community.docker.docker_secret:
name: foo name: foo
@@ -169,9 +165,9 @@ EXAMPLES = '''
community.docker.docker_secret: community.docker.docker_secret:
name: foo name: foo
state: absent state: absent
''' """
RETURN = ''' RETURN = r"""
secret_id: secret_id:
description: description:
- The ID assigned by Docker to the secret object. - The ID assigned by Docker to the secret object.
@@ -185,7 +181,7 @@ secret_name:
type: str type: str
sample: 'awesome_secret' sample: 'awesome_secret'
version_added: 2.2.0 version_added: 2.2.0
''' """
import base64 import base64
import hashlib import hashlib
+22 -29
View File
@@ -9,14 +9,12 @@ from __future__ import (absolute_import, division, print_function)
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = r"""
---
module: docker_stack module: docker_stack
author: "Dario Zanzico (@dariko)" author: "Dario Zanzico (@dariko)"
short_description: docker stack module short_description: docker stack module
description: description:
- Manage docker stacks using the C(docker stack) command - Manage docker stacks using the C(docker stack) command on the target node (see examples).
on the target node (see examples).
extends_documentation_fragment: extends_documentation_fragment:
- community.docker.docker.cli_documentation - community.docker.docker.cli_documentation
- community.docker.attributes - community.docker.attributes
@@ -31,7 +29,7 @@ attributes:
options: options:
name: name:
description: description:
- Stack name - Stack name.
type: str type: str
required: true required: true
state: state:
@@ -44,47 +42,42 @@ options:
- absent - absent
compose: compose:
description: description:
- List of compose definitions. Any element may be a string - List of compose definitions. Any element may be a string referring to the path of the compose file on the target host
referring to the path of the compose file on the target host
or the YAML contents of a compose file nested as dictionary. or the YAML contents of a compose file nested as dictionary.
type: list type: list
elements: raw elements: raw
default: [] default: []
prune: prune:
description: description:
- If true will add the C(--prune) option to the C(docker stack deploy) command. - If true will add the C(--prune) option to the C(docker stack deploy) command. This will have docker remove the services
This will have docker remove the services not present in the not present in the current stack definition.
current stack definition.
type: bool type: bool
default: false default: false
detach: detach:
description: description:
- If V(false), the C(--detach=false) option is added to the C(docker stack deploy) command, - If V(false), the C(--detach=false) option is added to the C(docker stack deploy) command, allowing Docker to wait
allowing Docker to wait for tasks to converge before exiting. for tasks to converge before exiting.
- If V(true) (default), Docker exits immediately instead of waiting for tasks to converge. - If V(true) (default), Docker exits immediately instead of waiting for tasks to converge.
type: bool type: bool
default: true default: true
version_added: 4.1.0 version_added: 4.1.0
with_registry_auth: with_registry_auth:
description: description:
- If true will add the C(--with-registry-auth) option to the C(docker stack deploy) command. - If true will add the C(--with-registry-auth) option to the C(docker stack deploy) command. This will have docker send
This will have docker send registry authentication details to Swarm agents. registry authentication details to Swarm agents.
type: bool type: bool
default: false default: false
resolve_image: resolve_image:
description: description:
- If set will add the C(--resolve-image) option to the C(docker stack deploy) command. - If set will add the C(--resolve-image) option to the C(docker stack deploy) command. This will have docker query the
This will have docker query the registry to resolve image digest and registry to resolve image digest and supported platforms. If not set, docker use "always" by default.
supported platforms. If not set, docker use "always" by default.
type: str type: str
choices: ["always", "changed", "never"] choices: ["always", "changed", "never"]
absent_retries: absent_retries:
description: description:
- If larger than V(0) and O(state=absent) the module will retry up to - If larger than V(0) and O(state=absent) the module will retry up to O(absent_retries) times to delete the stack until
O(absent_retries) times to delete the stack until all the all the resources have been effectively deleted. If the last try still reports the stack as not completely removed
resources have been effectively deleted. the module will fail.
If the last try still reports the stack as not completely
removed the module will fail.
type: int type: int
default: 0 default: 0
absent_retries_interval: absent_retries_interval:
@@ -117,12 +110,12 @@ requirements:
- Docker CLI tool C(docker) - Docker CLI tool C(docker)
- jsondiff - jsondiff
- pyyaml - pyyaml
''' """
RETURN = ''' RETURN = r"""
stack_spec_diff: stack_spec_diff:
description: | description: |-
dictionary containing the differences between the 'Spec' field Dictionary containing the differences between the 'Spec' field
of the stack services before and after applying the new stack of the stack services before and after applying the new stack
definition. definition.
sample: > sample: >
@@ -130,9 +123,9 @@ stack_spec_diff:
{'test_stack_test_service': {u'TaskTemplate': {u'ContainerSpec': {delete: [u'Env']}}}} {'test_stack_test_service': {u'TaskTemplate': {u'ContainerSpec': {delete: [u'Env']}}}}
returned: on change returned: on change
type: dict type: dict
''' """
EXAMPLES = ''' EXAMPLES = r"""
- name: Deploy stack from a compose file - name: Deploy stack from a compose file
community.docker.docker_stack: community.docker.docker_stack:
state: present state: present
@@ -157,7 +150,7 @@ EXAMPLES = '''
community.docker.docker_stack: community.docker.docker_stack:
name: mystack name: mystack
state: absent state: absent
''' """
import json import json
+10 -12
View File
@@ -9,14 +9,12 @@ from __future__ import (absolute_import, division, print_function)
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = r"""
---
module: docker_stack_info module: docker_stack_info
author: "Jose Angel Munoz (@imjoseangel)" author: "Jose Angel Munoz (@imjoseangel)"
short_description: Return information on all docker stacks short_description: Return information on all docker stacks
description: description:
- Retrieve information on docker stacks using the C(docker stack) command - Retrieve information on docker stacks using the C(docker stack) command on the target node (see examples).
on the target node (see examples).
requirements: requirements:
- Docker CLI tool C(docker) - Docker CLI tool C(docker)
extends_documentation_fragment: extends_documentation_fragment:
@@ -51,22 +49,22 @@ options:
seealso: seealso:
- module: community.docker.docker_stack_task_info - module: community.docker.docker_stack_task_info
description: >- description: >-
To retrieve detailed information about the services under a specific To retrieve detailed information about the services under a specific stack use the M(community.docker.docker_stack_task_info)
stack use the M(community.docker.docker_stack_task_info) module. module.
''' """
RETURN = ''' RETURN = r"""
results: results:
description: description:
- List of dictionaries containing the list of stacks on the target node - List of dictionaries containing the list of stacks on the target node.
sample: sample:
- {"name": "grafana", "namespace": "default", "orchestrator": "Kubernetes", "services": "2"} - {"name": "grafana", "namespace": "default", "orchestrator": "Kubernetes", "services": "2"}
returned: always returned: always
type: list type: list
elements: dict elements: dict
''' """
EXAMPLES = ''' EXAMPLES = r"""
- name: Shows stack info - name: Shows stack info
community.docker.docker_stack_info: community.docker.docker_stack_info:
register: result register: result
@@ -74,7 +72,7 @@ EXAMPLES = '''
- name: Show results - name: Show results
ansible.builtin.debug: ansible.builtin.debug:
var: result.results var: result.results
''' """
import json import json
import traceback import traceback
+10 -12
View File
@@ -9,14 +9,12 @@ from __future__ import (absolute_import, division, print_function)
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = r"""
---
module: docker_stack_task_info module: docker_stack_task_info
author: "Jose Angel Munoz (@imjoseangel)" author: "Jose Angel Munoz (@imjoseangel)"
short_description: Return information of the tasks on a docker stack short_description: Return information of the tasks on a docker stack
description: description:
- Retrieve information on docker stacks tasks using the C(docker stack) command - Retrieve information on docker stacks tasks using the C(docker stack) command on the target node (see examples).
on the target node (see examples).
extends_documentation_fragment: extends_documentation_fragment:
- community.docker.docker.cli_documentation - community.docker.docker.cli_documentation
- community.docker.attributes - community.docker.attributes
@@ -53,21 +51,21 @@ options:
version_added: 3.6.0 version_added: 3.6.0
requirements: requirements:
- Docker CLI tool C(docker) - Docker CLI tool C(docker)
''' """
RETURN = ''' RETURN = r"""
results: results:
description: description:
- List of dictionaries containing the list of tasks associated - List of dictionaries containing the list of tasks associated to a stack name.
to a stack name.
sample: sample:
- {"CurrentState":"Running","DesiredState":"Running","Error":"","ID":"7wqv6m02ugkw","Image":"busybox","Name":"test_stack.1","Node":"swarm","Ports":""} - {"CurrentState": "Running", "DesiredState": "Running", "Error": "", "ID": "7wqv6m02ugkw", "Image": "busybox", "Name": "test_stack.1",
"Node": "swarm", "Ports": ""}
returned: always returned: always
type: list type: list
elements: dict elements: dict
''' """
EXAMPLES = ''' EXAMPLES = r"""
- name: Shows stack info - name: Shows stack info
community.docker.docker_stack_task_info: community.docker.docker_stack_task_info:
name: test_stack name: test_stack
@@ -76,7 +74,7 @@ EXAMPLES = '''
- name: Show results - name: Show results
ansible.builtin.debug: ansible.builtin.debug:
var: result.results var: result.results
''' """
import json import json
import traceback import traceback
+32 -54
View File
@@ -7,14 +7,12 @@
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = r"""
---
module: docker_swarm module: docker_swarm
short_description: Manage Swarm cluster short_description: Manage Swarm cluster
description: description:
- Create a new Swarm cluster. - Create a new Swarm cluster.
- Add/Remove nodes or managers to an existing cluster. - Add/Remove nodes or managers to an existing cluster.
extends_documentation_fragment: extends_documentation_fragment:
- community.docker.docker - community.docker.docker
- community.docker.docker.docker_py_1_documentation - community.docker.docker.docker_py_1_documentation
@@ -31,41 +29,32 @@ options:
advertise_addr: advertise_addr:
description: description:
- Externally reachable address advertised to other nodes. - Externally reachable address advertised to other nodes.
- This can either be an address/port combination - This can either be an address/port combination in the form V(192.168.1.1:4567), or an interface followed by a port
in the form V(192.168.1.1:4567), or an interface followed by a number, like V(eth0:4567).
port number, like V(eth0:4567). - If the port number is omitted, the port number from the listen address is used.
- If the port number is omitted, - If O(advertise_addr) is not specified, it will be automatically detected when possible.
the port number from the listen address is used. - Only used when swarm is initialised or joined. Because of this it is not considered for idempotency checking.
- If O(advertise_addr) is not specified, it will be automatically
detected when possible.
- Only used when swarm is initialised or joined. Because of this it is not
considered for idempotency checking.
type: str type: str
default_addr_pool: default_addr_pool:
description: description:
- Default address pool in CIDR format. - Default address pool in CIDR format.
- Only used when swarm is initialised. Because of this it is not considered - Only used when swarm is initialised. Because of this it is not considered for idempotency checking.
for idempotency checking.
- Requires API version >= 1.39. - Requires API version >= 1.39.
type: list type: list
elements: str elements: str
subnet_size: subnet_size:
description: description:
- Default address pool subnet mask length. - Default address pool subnet mask length.
- Only used when swarm is initialised. Because of this it is not considered - Only used when swarm is initialised. Because of this it is not considered for idempotency checking.
for idempotency checking.
- Requires API version >= 1.39. - Requires API version >= 1.39.
type: int type: int
listen_addr: listen_addr:
description: description:
- Listen address used for inter-manager communication. - Listen address used for inter-manager communication.
- This can either be an address/port combination in the form - This can either be an address/port combination in the form V(192.168.1.1:4567), or an interface followed by a port
V(192.168.1.1:4567), or an interface followed by a port number, number, like V(eth0:4567).
like V(eth0:4567). - If the port number is omitted, the default swarm listening port is used.
- If the port number is omitted, the default swarm listening port - Only used when swarm is initialised or joined. Because of this it is not considered for idempotency checking.
is used.
- Only used when swarm is initialised or joined. Because of this it is not
considered for idempotency checking.
type: str type: str
default: 0.0.0.0:2377 default: 0.0.0.0:2377
force: force:
@@ -79,8 +68,8 @@ options:
- Set to V(present), to create/update a new cluster. - Set to V(present), to create/update a new cluster.
- Set to V(join), to join an existing cluster. - Set to V(join), to join an existing cluster.
- Set to V(absent), to leave an existing cluster. - Set to V(absent), to leave an existing cluster.
- Set to V(remove), to remove an absent node from the cluster. - Set to V(remove), to remove an absent node from the cluster. Note that removing requires Docker SDK for Python >=
Note that removing requires Docker SDK for Python >= 2.4.0. 2.4.0.
- M(community.docker.docker_node) can be used to demote a manager before removal. - M(community.docker.docker_node) can be used to demote a manager before removal.
type: str type: str
default: present default: present
@@ -98,8 +87,8 @@ options:
description: description:
- Swarm token used to join a swarm cluster. - Swarm token used to join a swarm cluster.
- Used with O(state=join). - Used with O(state=join).
- If this value is specified, the corresponding value in the return values will be censored by Ansible. - If this value is specified, the corresponding value in the return values will be censored by Ansible. This is a side-effect
This is a side-effect of this value not being logged. of this value not being logged.
type: str type: str
remote_addrs: remote_addrs:
description: description:
@@ -140,13 +129,11 @@ options:
description: description:
- The delay (in nanoseconds) for an agent to send a heartbeat to the dispatcher. - The delay (in nanoseconds) for an agent to send a heartbeat to the dispatcher.
- Docker default value is 5 seconds, which corresponds to a value of V(5000000000). - Docker default value is 5 seconds, which corresponds to a value of V(5000000000).
# DefaultHeartBeatPeriod in https://github.com/moby/moby/blob/master/vendor/github.com/moby/swarmkit/v2/manager/dispatcher/dispatcher.go#L32
type: int type: int
node_cert_expiry: node_cert_expiry:
description: description:
- Automatic expiry for nodes certificates, given in nanoseconds. - Automatic expiry for nodes certificates, given in nanoseconds.
- Docker default value is 90 days, which corresponds to a value of V(7776000000000000). - Docker default value is 90 days, which corresponds to a value of V(7776000000000000).
# DefaultNodeCertExpiration in https://github.com/moby/moby/blob/master/vendor/github.com/moby/swarmkit/v2/ca/certificates.go#L56
type: int type: int
name: name:
description: description:
@@ -155,8 +142,8 @@ options:
labels: labels:
description: description:
- User-defined key/value metadata. - User-defined key/value metadata.
- Label operations in this module apply to the docker swarm cluster. - Label operations in this module apply to the docker swarm cluster. Use M(community.docker.docker_node) module to add/modify/remove
Use M(community.docker.docker_node) module to add/modify/remove swarm node labels. swarm node labels.
- Requires API version >= 1.32. - Requires API version >= 1.32.
type: dict type: dict
signing_ca_cert: signing_ca_cert:
@@ -173,8 +160,7 @@ options:
type: str type: str
ca_force_rotate: ca_force_rotate:
description: description:
- An integer whose purpose is to force swarm to generate a new signing CA certificate and key, - An integer whose purpose is to force swarm to generate a new signing CA certificate and key, if none have been specified.
if none have been specified.
- Docker default value is V(0). - Docker default value is V(0).
- Requires API version >= 1.30. - Requires API version >= 1.30.
type: int type: int
@@ -195,10 +181,8 @@ options:
data_path_addr: data_path_addr:
description: description:
- Address or interface to use for data path traffic. - Address or interface to use for data path traffic.
- This can either be an address in the form V(192.168.1.1), or an interface, - This can either be an address in the form V(192.168.1.1), or an interface, like V(eth0).
like V(eth0). - Only used when swarm is initialised or joined. Because of this it is not considered for idempotency checking.
- Only used when swarm is initialised or joined. Because of this it is not
considered for idempotency checking.
- Requires API version >= 1.30. - Requires API version >= 1.30.
type: str type: str
version_added: 2.5.0 version_added: 2.5.0
@@ -206,8 +190,7 @@ options:
description: description:
- Port to use for data path traffic. - Port to use for data path traffic.
- This needs to be a port number like V(9789). - This needs to be a port number like V(9789).
- Only used when swarm is initialised. Because of this it is not - Only used when swarm is initialised. Because of this it is not considered for idempotency checking.
considered for idempotency checking.
- Requires API version >= 1.40. - Requires API version >= 1.40.
type: int type: int
version_added: 3.1.0 version_added: 3.1.0
@@ -218,10 +201,9 @@ requirements:
author: author:
- Thierry Bouvet (@tbouvet) - Thierry Bouvet (@tbouvet)
- Piotr Wojciechowski (@WojciechowskiPiotr) - Piotr Wojciechowski (@WojciechowskiPiotr)
''' """
EXAMPLES = '''
EXAMPLES = r"""
- name: Init a new swarm with default parameters - name: Init a new swarm with default parameters
community.docker.docker_swarm: community.docker.docker_swarm:
state: present state: present
@@ -262,9 +244,9 @@ EXAMPLES = '''
community.docker.docker_swarm: community.docker.docker_swarm:
state: present state: present
data_path_port: 9789 data_path_port: 9789
''' """
RETURN = ''' RETURN = r"""
swarm_facts: swarm_facts:
description: Information about swarm. description: Information about swarm.
returned: success returned: success
@@ -278,25 +260,22 @@ swarm_facts:
Worker: Worker:
description: description:
- Token to join the cluster as a new *worker* node. - Token to join the cluster as a new *worker* node.
- "B(Note:) if this value has been specified as O(join_token), the value here will not - B(Note:) if this value has been specified as O(join_token), the value here will not be the token, but C(VALUE_SPECIFIED_IN_NO_LOG_PARAMETER).
be the token, but C(VALUE_SPECIFIED_IN_NO_LOG_PARAMETER). If you pass O(join_token), If you pass O(join_token), make sure your playbook/role does not depend on this return value!
make sure your playbook/role does not depend on this return value!"
returned: success returned: success
type: str type: str
example: SWMTKN-1--xxxxx example: SWMTKN-1--xxxxx
Manager: Manager:
description: description:
- Token to join the cluster as a new *manager* node. - Token to join the cluster as a new *manager* node.
- "B(Note:) if this value has been specified as O(join_token), the value here will not - B(Note:) if this value has been specified as O(join_token), the value here will not be the token, but C(VALUE_SPECIFIED_IN_NO_LOG_PARAMETER).
be the token, but C(VALUE_SPECIFIED_IN_NO_LOG_PARAMETER). If you pass O(join_token), If you pass O(join_token), make sure your playbook/role does not depend on this return value!
make sure your playbook/role does not depend on this return value!"
returned: success returned: success
type: str type: str
example: SWMTKN-1--xxxxx example: SWMTKN-1--xxxxx
UnlockKey: UnlockKey:
description: The swarm unlock-key if O(autolock_managers=true). description: The swarm unlock-key if O(autolock_managers=true).
returned: on success if O(autolock_managers=true) returned: on success if O(autolock_managers=true) and swarm is initialised, or if O(autolock_managers) has changed.
and swarm is initialised, or if O(autolock_managers) has changed.
type: str type: str
example: SWMKEY-1-xxx example: SWMKEY-1-xxx
@@ -306,8 +285,7 @@ actions:
type: list type: list
elements: str elements: str
example: ['This cluster is already a swarm cluster'] example: ['This cluster is already a swarm cluster']
"""
'''
import json import json
import traceback import traceback
+32 -42
View File
@@ -8,21 +8,18 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = r"""
---
module: docker_swarm_info module: docker_swarm_info
short_description: Retrieves facts about Docker Swarm cluster. short_description: Retrieves facts about Docker Swarm cluster
description: description:
- Retrieves facts about a Docker Swarm. - Retrieves facts about a Docker Swarm.
- Returns lists of swarm objects names for the services - nodes, services, tasks. - Returns lists of swarm objects names for the services - nodes, services, tasks.
- The output differs depending on API version available on docker host. - The output differs depending on API version available on docker host.
- Must be run on Swarm Manager node; otherwise module fails with error message. - Must be run on Swarm Manager node; otherwise module fails with error message. It does return boolean flags in on both
It does return boolean flags in on both error and success which indicate whether error and success which indicate whether the docker daemon can be communicated with, whether it is in Swarm mode, and
the docker daemon can be communicated with, whether it is in Swarm mode, and
whether it is a Swarm Manager node. whether it is a Swarm Manager node.
author: author:
- Piotr Wojciechowski (@WojciechowskiPiotr) - Piotr Wojciechowski (@WojciechowskiPiotr)
@@ -42,9 +39,9 @@ options:
nodes_filters: nodes_filters:
description: description:
- A dictionary of filter values used for selecting nodes to list. - A dictionary of filter values used for selecting nodes to list.
- "For example, C(name: mynode)." - 'For example, C(name: mynode).'
- See L(the docker documentation,https://docs.docker.com/engine/reference/commandline/node_ls/#filtering) - See L(the docker documentation,https://docs.docker.com/engine/reference/commandline/node_ls/#filtering) for more information
for more information on possible filters. on possible filters.
type: dict type: dict
services: services:
description: description:
@@ -54,9 +51,9 @@ options:
services_filters: services_filters:
description: description:
- A dictionary of filter values used for selecting services to list. - A dictionary of filter values used for selecting services to list.
- "For example, C(name: myservice)." - 'For example, C(name: myservice).'
- See L(the docker documentation,https://docs.docker.com/engine/reference/commandline/service_ls/#filtering) - See L(the docker documentation,https://docs.docker.com/engine/reference/commandline/service_ls/#filtering) for more
for more information on possible filters. information on possible filters.
type: dict type: dict
tasks: tasks:
description: description:
@@ -66,9 +63,9 @@ options:
tasks_filters: tasks_filters:
description: description:
- A dictionary of filter values used for selecting tasks to list. - A dictionary of filter values used for selecting tasks to list.
- "For example, C(node: mynode-1)." - 'For example, C(node: mynode-1).'
- See L(the docker documentation,https://docs.docker.com/engine/reference/commandline/service_ps/#filtering) - See L(the docker documentation,https://docs.docker.com/engine/reference/commandline/service_ps/#filtering) for more
for more information on possible filters. information on possible filters.
type: dict type: dict
unlock_key: unlock_key:
description: description:
@@ -77,20 +74,20 @@ options:
default: false default: false
verbose_output: verbose_output:
description: description:
- When set to V(true) and O(nodes), O(services), or O(tasks) is set to V(true), then the module output will - When set to V(true) and O(nodes), O(services), or O(tasks) is set to V(true), then the module output will contain
contain verbose information about objects matching the full output of API method. verbose information about objects matching the full output of API method.
- For details see the documentation of your version of Docker API at U(https://docs.docker.com/engine/api/). - For details see the documentation of your version of Docker API at U(https://docs.docker.com/engine/api/).
- The verbose output in this module contains only subset of information returned by this info module - The verbose output in this module contains only subset of information returned by this info module for each type of
for each type of the objects. the objects.
type: bool type: bool
default: false default: false
requirements: requirements:
- "L(Docker SDK for Python,https://docker-py.readthedocs.io/en/stable/) >= 1.10.0" - "L(Docker SDK for Python,https://docker-py.readthedocs.io/en/stable/) >= 1.10.0"
- "Docker API >= 1.25" - "Docker API >= 1.25"
''' """
EXAMPLES = ''' EXAMPLES = r"""
- name: Get info on Docker Swarm - name: Get info on Docker Swarm
community.docker.docker_swarm_info: community.docker.docker_swarm_info:
ignore_errors: true ignore_errors: true
@@ -133,10 +130,9 @@ EXAMPLES = '''
- name: Print swarm unlock key - name: Print swarm unlock key
ansible.builtin.debug: ansible.builtin.debug:
var: result.swarm_unlock_key var: result.swarm_unlock_key
"""
''' RETURN = r"""
RETURN = '''
can_talk_to_docker: can_talk_to_docker:
description: description:
- Will be V(true) if the module can talk to the docker daemon. - Will be V(true) if the module can talk to the docker daemon.
@@ -144,22 +140,20 @@ can_talk_to_docker:
type: bool type: bool
docker_swarm_active: docker_swarm_active:
description: description:
- Will be V(true) if the module can talk to the docker daemon, - Will be V(true) if the module can talk to the docker daemon, and the docker daemon is in Swarm mode.
and the docker daemon is in Swarm mode.
returned: both on success and on error returned: both on success and on error
type: bool type: bool
docker_swarm_manager: docker_swarm_manager:
description: description:
- Will be V(true) if the module can talk to the docker daemon, - Will be V(true) if the module can talk to the docker daemon, the docker daemon is in Swarm mode, and the current node
the docker daemon is in Swarm mode, and the current node is is a manager node.
a manager node.
- Only if this one is V(true), the module will not fail. - Only if this one is V(true), the module will not fail.
returned: both on success and on error returned: both on success and on error
type: bool type: bool
swarm_facts: swarm_facts:
description: description:
- Facts representing the basic state of the docker Swarm cluster. - Facts representing the basic state of the docker Swarm cluster.
- Contains tokens to connect to the Swarm - Contains tokens to connect to the Swarm.
returned: always returned: always
type: dict type: dict
swarm_unlock_key: swarm_unlock_key:
@@ -169,30 +163,26 @@ swarm_unlock_key:
type: str type: str
nodes: nodes:
description: description:
- List of dict objects containing the basic information about each volume. - List of dict objects containing the basic information about each volume. Keys matches the C(docker node ls) output unless
Keys matches the C(docker node ls) output unless O(verbose_output=true). O(verbose_output=true). See description for O(verbose_output).
See description for O(verbose_output).
returned: When O(nodes=true) returned: When O(nodes=true)
type: list type: list
elements: dict elements: dict
services: services:
description: description:
- List of dict objects containing the basic information about each volume. - List of dict objects containing the basic information about each volume. Keys matches the C(docker service ls) output
Keys matches the C(docker service ls) output unless O(verbose_output=true). unless O(verbose_output=true). See description for O(verbose_output).
See description for O(verbose_output).
returned: When O(services=true) returned: When O(services=true)
type: list type: list
elements: dict elements: dict
tasks: tasks:
description: description:
- List of dict objects containing the basic information about each volume. - List of dict objects containing the basic information about each volume. Keys matches the C(docker service ps) output
Keys matches the C(docker service ps) output unless O(verbose_output=true). unless O(verbose_output=true). See description for O(verbose_output).
See description for O(verbose_output).
returned: When O(tasks=true) returned: When O(tasks=true)
type: list type: list
elements: dict elements: dict
"""
'''
import traceback import traceback
+68 -161
View File
@@ -7,8 +7,7 @@
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = r"""
---
module: docker_swarm_service module: docker_swarm_service
author: author:
- "Dario Zanzico (@dariko)" - "Dario Zanzico (@dariko)"
@@ -19,7 +18,6 @@ short_description: docker swarm service
description: description:
- Manages docker services via a swarm manager node. - Manages docker services via a swarm manager node.
- This modules does not support updating services in a stack. - This modules does not support updating services in a stack.
extends_documentation_fragment: extends_documentation_fragment:
- community.docker.docker - community.docker.docker
- community.docker.docker.docker_py_2_documentation - community.docker.docker.docker_py_2_documentation
@@ -118,16 +116,14 @@ options:
description: description:
- List or dictionary of the service environment variables. - List or dictionary of the service environment variables.
- If passed a list each items need to be in the format of C(KEY=VALUE). - If passed a list each items need to be in the format of C(KEY=VALUE).
- If passed a dictionary values which might be parsed as numbers, - If passed a dictionary values which might be parsed as numbers, booleans or other types by the YAML parser must be
booleans or other types by the YAML parser must be quoted (for example V("true")) quoted (for example V("true")) in order to avoid data loss.
in order to avoid data loss.
- Corresponds to the C(--env) option of C(docker service create). - Corresponds to the C(--env) option of C(docker service create).
type: raw type: raw
env_files: env_files:
description: description:
- List of paths to files, present on the target, containing environment variables C(FOO=BAR). - List of paths to files, present on the target, containing environment variables C(FOO=BAR).
- The order of the list is significant in determining the value assigned to a - The order of the list is significant in determining the value assigned to a variable that shows up more than once.
variable that shows up more than once.
- If variable also present in O(env), then O(env) value will override. - If variable also present in O(env), then O(env) value will override.
type: list type: list
elements: path elements: path
@@ -145,12 +141,12 @@ options:
elements: str elements: str
healthcheck: healthcheck:
description: description:
- Configure a check that is run to determine whether or not containers for this service are "healthy". - Configure a check that is run to determine whether or not containers for this service are "healthy". See the docs
See the docs for the L(HEALTHCHECK Dockerfile instruction,https://docs.docker.com/engine/reference/builder/#healthcheck) for the L(HEALTHCHECK Dockerfile instruction,https://docs.docker.com/engine/reference/builder/#healthcheck) for details
for details on how healthchecks work. on how healthchecks work.
- "O(healthcheck.interval), O(healthcheck.timeout), and O(healthcheck.start_period) are specified as durations. - 'O(healthcheck.interval), O(healthcheck.timeout), and O(healthcheck.start_period) are specified as durations. They
They accept duration as a string in a format that look like: V(5h34m56s), V(1m30s), and so on. accept duration as a string in a format that look like: V(5h34m56s), V(1m30s), and so on. The supported units are
The supported units are V(us), V(ms), V(s), V(m) and V(h)." V(us), V(ms), V(s), V(m) and V(h).'
type: dict type: dict
suboptions: suboptions:
test: test:
@@ -181,8 +177,8 @@ options:
type: str type: str
hosts: hosts:
description: description:
- Dict of host-to-IP mappings, where each host name is a key in the dictionary. - Dict of host-to-IP mappings, where each host name is a key in the dictionary. Each host name will be added to the
Each host name will be added to the container's /etc/hosts file. container's /etc/hosts file.
- Corresponds to the C(--host) option of C(docker service create). - Corresponds to the C(--host) option of C(docker service create).
type: dict type: dict
image: image:
@@ -212,9 +208,8 @@ options:
type: float type: float
memory: memory:
description: description:
- "Service memory limit in format C(<number>[<unit>]). Number is a positive integer. - Service memory limit in format C(<number>[<unit>]). Number is a positive integer. Unit can be V(B) (byte), V(K)
Unit can be V(B) (byte), V(K) (kibibyte, 1024B), V(M) (mebibyte), V(G) (gibibyte), (kibibyte, 1024B), V(M) (mebibyte), V(G) (gibibyte), V(T) (tebibyte), or V(P) (pebibyte).
V(T) (tebibyte), or V(P) (pebibyte)."
- V(0) equals no limit. - V(0) equals no limit.
- Omitting the unit defaults to bytes. - Omitting the unit defaults to bytes.
- Corresponds to the C(--limit-memory) option of C(docker service create). - Corresponds to the C(--limit-memory) option of C(docker service create).
@@ -222,7 +217,7 @@ options:
type: dict type: dict
logging: logging:
description: description:
- "Logging configuration for the service." - Logging configuration for the service.
suboptions: suboptions:
driver: driver:
description: description:
@@ -314,9 +309,8 @@ options:
type: dict type: dict
tmpfs_size: tmpfs_size:
description: description:
- "Size of the tmpfs mount in format C(<number>[<unit>]). Number is a positive integer. - Size of the tmpfs mount in format C(<number>[<unit>]). Number is a positive integer. Unit can be V(B) (byte),
Unit can be V(B) (byte), V(K) (kibibyte, 1024B), V(M) (mebibyte), V(G) (gibibyte), V(K) (kibibyte, 1024B), V(M) (mebibyte), V(G) (gibibyte), V(T) (tebibyte), or V(P) (pebibyte).
V(T) (tebibyte), or V(P) (pebibyte)."
- Can only be used when O(mounts[].type=tmpfs). - Can only be used when O(mounts[].type=tmpfs).
type: str type: str
tmpfs_mode: tmpfs_mode:
@@ -333,10 +327,9 @@ options:
networks: networks:
description: description:
- List of the service networks names or dictionaries. - List of the service networks names or dictionaries.
- When passed dictionaries valid sub-options are C(name), which is required, and - When passed dictionaries valid sub-options are C(name), which is required, and C(aliases) and C(options).
C(aliases) and C(options). - Prior to API version 1.29, updating and removing networks is not supported. If changes are made the service will then
- Prior to API version 1.29, updating and removing networks is not supported. be removed and recreated.
If changes are made the service will then be removed and recreated.
- Corresponds to the C(--network) option of C(docker service create). - Corresponds to the C(--network) option of C(docker service create).
type: list type: list
elements: raw elements: raw
@@ -361,7 +354,7 @@ options:
description: description:
- Maximum number of tasks per node. - Maximum number of tasks per node.
- Corresponds to the C(--replicas_max_per_node) option of C(docker service create). - Corresponds to the C(--replicas_max_per_node) option of C(docker service create).
- Requires API version >= 1.40 - Requires API version >= 1.40.
type: int type: int
version_added: 1.3.0 version_added: 1.3.0
type: dict type: dict
@@ -422,9 +415,8 @@ options:
type: float type: float
memory: memory:
description: description:
- "Service memory reservation in format C(<number>[<unit>]). Number is a positive integer. - Service memory reservation in format C(<number>[<unit>]). Number is a positive integer. Unit can be V(B) (byte),
Unit can be V(B) (byte), V(K) (kibibyte, 1024B), V(M) (mebibyte), V(G) (gibibyte), V(K) (kibibyte, 1024B), V(M) (mebibyte), V(G) (gibibyte), V(T) (tebibyte), or V(P) (pebibyte).
V(T) (tebibyte), or V(P) (pebibyte)."
- V(0) equals no reservation. - V(0) equals no reservation.
- Omitting the unit defaults to bytes. - Omitting the unit defaults to bytes.
- Corresponds to the C(--reserve-memory) option of C(docker service create). - Corresponds to the C(--reserve-memory) option of C(docker service create).
@@ -452,8 +444,8 @@ options:
delay: delay:
description: description:
- Delay between restarts. - Delay between restarts.
- "Accepts a a string in a format that look like: - 'Accepts a a string in a format that look like: V(5h34m56s), V(1m30s) etc. The supported units are V(us), V(ms),
V(5h34m56s), V(1m30s) etc. The supported units are V(us), V(ms), V(s), V(m) and V(h)." V(s), V(m) and V(h).'
- Corresponds to the C(--restart-delay) option of C(docker service create). - Corresponds to the C(--restart-delay) option of C(docker service create).
type: str type: str
max_attempts: max_attempts:
@@ -464,8 +456,8 @@ options:
window: window:
description: description:
- Restart policy evaluation window. - Restart policy evaluation window.
- "Accepts a string in a format that look like: - 'Accepts a string in a format that look like: V(5h34m56s), V(1m30s) etc. The supported units are V(us), V(ms),
V(5h34m56s), V(1m30s) etc. The supported units are V(us), V(ms), V(s), V(m) and V(h)." V(s), V(m) and V(h).'
- Corresponds to the C(--restart-window) option of C(docker service create). - Corresponds to the C(--restart-window) option of C(docker service create).
type: str type: str
type: dict type: dict
@@ -482,8 +474,8 @@ options:
delay: delay:
description: description:
- Delay between task rollbacks. - Delay between task rollbacks.
- "Accepts a string in a format that look like: - 'Accepts a string in a format that look like: V(5h34m56s), V(1m30s) etc. The supported units are V(us), V(ms),
V(5h34m56s), V(1m30s) etc. The supported units are V(us), V(ms), V(s), V(m) and V(h)." V(s), V(m) and V(h).'
- Corresponds to the C(--rollback-delay) option of C(docker service create). - Corresponds to the C(--rollback-delay) option of C(docker service create).
- Requires API version >= 1.28. - Requires API version >= 1.28.
type: str type: str
@@ -499,8 +491,8 @@ options:
monitor: monitor:
description: description:
- Duration after each task rollback to monitor for failure. - Duration after each task rollback to monitor for failure.
- "Accepts a string in a format that look like: - 'Accepts a string in a format that look like: V(5h34m56s), V(1m30s) etc. The supported units are V(us), V(ms),
V(5h34m56s), V(1m30s) etc. The supported units are V(us), V(ms), V(s), V(m) and V(h)." V(s), V(m) and V(h).'
- Corresponds to the C(--rollback-monitor) option of C(docker service create). - Corresponds to the C(--rollback-monitor) option of C(docker service create).
- Requires API version >= 1.28. - Requires API version >= 1.28.
type: str type: str
@@ -553,8 +545,8 @@ options:
state: state:
description: description:
- V(absent) - A service matching the specified name will be removed and have its tasks stopped. - V(absent) - A service matching the specified name will be removed and have its tasks stopped.
- V(present) - Asserts the existence of a service matching the name and provided configuration parameters. - V(present) - Asserts the existence of a service matching the name and provided configuration parameters. Unspecified
Unspecified configuration parameters will be set to docker defaults. configuration parameters will be set to docker defaults.
type: str type: str
default: present default: present
choices: choices:
@@ -563,8 +555,8 @@ options:
stop_grace_period: stop_grace_period:
description: description:
- Time to wait before force killing a container. - Time to wait before force killing a container.
- "Accepts a duration as a string in a format that look like: - 'Accepts a duration as a string in a format that look like: V(5h34m56s), V(1m30s) etc. The supported units are V(us),
V(5h34m56s), V(1m30s) etc. The supported units are V(us), V(ms), V(s), V(m) and V(h)." V(ms), V(s), V(m) and V(h).'
- Corresponds to the C(--stop-grace-period) option of C(docker service create). - Corresponds to the C(--stop-grace-period) option of C(docker service create).
type: str type: str
stop_signal: stop_signal:
@@ -589,8 +581,8 @@ options:
delay: delay:
description: description:
- Rolling update delay. - Rolling update delay.
- "Accepts a string in a format that look like: - 'Accepts a string in a format that look like: V(5h34m56s), V(1m30s) etc. The supported units are V(us), V(ms),
V(5h34m56s), V(1m30s) etc. The supported units are V(us), V(ms), V(s), V(m) and V(h)." V(s), V(m) and V(h).'
- Corresponds to the C(--update-delay) option of C(docker service create). - Corresponds to the C(--update-delay) option of C(docker service create).
type: str type: str
failure_action: failure_action:
@@ -606,8 +598,8 @@ options:
monitor: monitor:
description: description:
- Time to monitor updated tasks for failures. - Time to monitor updated tasks for failures.
- "Accepts a string in a format that look like: - 'Accepts a string in a format that look like: V(5h34m56s), V(1m30s) etc. The supported units are V(us), V(ms),
V(5h34m56s), V(1m30s) etc. The supported units are V(us), V(ms), V(s), V(m) and V(h)." V(s), V(m) and V(h).'
- Corresponds to the C(--update-monitor) option of C(docker service create). - Corresponds to the C(--update-monitor) option of C(docker service create).
type: str type: str
max_failure_ratio: max_failure_ratio:
@@ -653,122 +645,37 @@ requirements:
- "L(Docker SDK for Python,https://docker-py.readthedocs.io/en/stable/) >= 2.0.2" - "L(Docker SDK for Python,https://docker-py.readthedocs.io/en/stable/) >= 2.0.2"
- "Docker API >= 1.25" - "Docker API >= 1.25"
notes: notes:
- "Images will only resolve to the latest digest when using Docker API >= 1.30 and Docker SDK for Python >= 3.2.0. - Images will only resolve to the latest digest when using Docker API >= 1.30 and Docker SDK for Python >= 3.2.0. When using
When using older versions use O(force_update=true) to trigger the swarm to resolve a new image." older versions use O(force_update=true) to trigger the swarm to resolve a new image.
''' """
RETURN = ''' RETURN = r"""
swarm_service: swarm_service:
returned: always returned: always
type: dict type: dict
description: description:
- Dictionary of variables representing the current state of the service. - Dictionary of variables representing the current state of the service. Matches the module parameters format.
Matches the module parameters format.
- Note that facts are not part of registered vars but accessible directly. - Note that facts are not part of registered vars but accessible directly.
- Note that before Ansible 2.7.9, the return variable was documented as C(ansible_swarm_service), - Note that before Ansible 2.7.9, the return variable was documented as C(ansible_swarm_service), while the module actually
while the module actually returned a variable called C(ansible_docker_service). The variable returned a variable called C(ansible_docker_service). The variable was renamed to RV(swarm_service) in both code and
was renamed to RV(swarm_service) in both code and documentation for Ansible 2.7.9 and Ansible 2.8.0. documentation for Ansible 2.7.9 and Ansible 2.8.0. In Ansible 2.7.x, the old name C(ansible_docker_service) can still
In Ansible 2.7.x, the old name C(ansible_docker_service) can still be used. be used.
sample: '{ sample: '{ "args": [ "3600" ], "cap_add": null, "cap_drop": [ "ALL" ], "command": [ "sleep" ], "configs": null, "constraints":
"args": [ [ "node.role == manager", "engine.labels.operatingsystem == ubuntu 14.04" ], "container_labels": null, "sysctls": null,
"3600" "dns": null, "dns_options": null, "dns_search": null, "endpoint_mode": null, "env": [ "ENVVAR1=envvar1", "ENVVAR2=envvar2"
], ], "force_update": null, "groups": null, "healthcheck": { "interval": 90000000000, "retries": 3, "start_period": 30000000000,
"cap_add": null, "test": [ "CMD", "curl", "--fail", "http://nginx.host.com" ], "timeout": 10000000000 }, "healthcheck_disabled": false,
"cap_drop": [ "hostname": null, "hosts": null, "image": "alpine:latest@sha256:b3dbf31b77fd99d9c08f780ce6f5282aba076d70a513a8be859d8d3a4d0c92b8",
"ALL" "labels": { "com.example.department": "Finance", "com.example.description": "Accounting webapp" }, "limit_cpu": 0.5, "limit_memory":
], 52428800, "log_driver": "fluentd", "log_driver_options": { "fluentd-address": "127.0.0.1:24224", "fluentd-async-connect":
"command": [ "true", "tag": "myservice" }, "mode": "replicated", "mounts": [ { "readonly": false, "source": "/tmp/", "target": "/remote_tmp/",
"sleep" "type": "bind", "labels": null, "propagation": null, "no_copy": null, "driver_config": null, "tmpfs_size": null, "tmpfs_mode":
], null } ], "networks": null, "placement_preferences": [ { "spread": "node.labels.mylabel" } ], "publish": null, "read_only":
"configs": null, null, "replicas": 1, "replicas_max_per_node": 1, "reserve_cpu": 0.25, "reserve_memory": 20971520, "restart_policy": "on-failure",
"constraints": [ "restart_policy_attempts": 3, "restart_policy_delay": 5000000000, "restart_policy_window": 120000000000, "secrets": null,
"node.role == manager", "stop_grace_period": null, "stop_signal": null, "tty": null, "update_delay": 10000000000, "update_failure_action": null,
"engine.labels.operatingsystem == ubuntu 14.04" "update_max_failure_ratio": null, "update_monitor": null, "update_order": "stop-first", "update_parallelism": 2, "user":
], null, "working_dir": null }'
"container_labels": null,
"sysctls": null,
"dns": null,
"dns_options": null,
"dns_search": null,
"endpoint_mode": null,
"env": [
"ENVVAR1=envvar1",
"ENVVAR2=envvar2"
],
"force_update": null,
"groups": null,
"healthcheck": {
"interval": 90000000000,
"retries": 3,
"start_period": 30000000000,
"test": [
"CMD",
"curl",
"--fail",
"http://nginx.host.com"
],
"timeout": 10000000000
},
"healthcheck_disabled": false,
"hostname": null,
"hosts": null,
"image": "alpine:latest@sha256:b3dbf31b77fd99d9c08f780ce6f5282aba076d70a513a8be859d8d3a4d0c92b8",
"labels": {
"com.example.department": "Finance",
"com.example.description": "Accounting webapp"
},
"limit_cpu": 0.5,
"limit_memory": 52428800,
"log_driver": "fluentd",
"log_driver_options": {
"fluentd-address": "127.0.0.1:24224",
"fluentd-async-connect": "true",
"tag": "myservice"
},
"mode": "replicated",
"mounts": [
{
"readonly": false,
"source": "/tmp/",
"target": "/remote_tmp/",
"type": "bind",
"labels": null,
"propagation": null,
"no_copy": null,
"driver_config": null,
"tmpfs_size": null,
"tmpfs_mode": null
}
],
"networks": null,
"placement_preferences": [
{
"spread": "node.labels.mylabel"
}
],
"publish": null,
"read_only": null,
"replicas": 1,
"replicas_max_per_node": 1,
"reserve_cpu": 0.25,
"reserve_memory": 20971520,
"restart_policy": "on-failure",
"restart_policy_attempts": 3,
"restart_policy_delay": 5000000000,
"restart_policy_window": 120000000000,
"secrets": null,
"stop_grace_period": null,
"stop_signal": null,
"tty": null,
"update_delay": 10000000000,
"update_failure_action": null,
"update_max_failure_ratio": null,
"update_monitor": null,
"update_order": "stop-first",
"update_parallelism": 2,
"user": null,
"working_dir": null
}'
changes: changes:
returned: always returned: always
description: description:
@@ -779,12 +686,12 @@ changes:
rebuilt: rebuilt:
returned: always returned: always
description: description:
- True if the service has been recreated (removed and created) - True if the service has been recreated (removed and created).
type: bool type: bool
sample: true sample: true
''' """
EXAMPLES = ''' EXAMPLES = r"""
- name: Set command and arguments - name: Set command and arguments
community.docker.docker_swarm_service: community.docker.docker_swarm_service:
name: myservice name: myservice
@@ -936,7 +843,7 @@ EXAMPLES = '''
community.docker.docker_swarm_service: community.docker.docker_swarm_service:
name: myservice name: myservice
state: absent state: absent
''' """
import shlex import shlex
import time import time
+6 -8
View File
@@ -8,8 +8,7 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = r"""
---
module: docker_swarm_service_info module: docker_swarm_service_info
short_description: Retrieves information about docker services from a Swarm Manager short_description: Retrieves information about docker services from a Swarm Manager
@@ -18,7 +17,6 @@ description:
- Retrieves information about a docker service. - Retrieves information about a docker service.
- Essentially returns the output of C(docker service inspect <name>). - Essentially returns the output of C(docker service inspect <name>).
- Must be executed on a host running as Swarm Manager, otherwise the module will fail. - Must be executed on a host running as Swarm Manager, otherwise the module will fail.
extends_documentation_fragment: extends_documentation_fragment:
- community.docker.docker - community.docker.docker
- community.docker.docker.docker_py_1_documentation - community.docker.docker.docker_py_1_documentation
@@ -39,16 +37,16 @@ author:
requirements: requirements:
- "L(Docker SDK for Python,https://docker-py.readthedocs.io/en/stable/) >= 2.0.0" - "L(Docker SDK for Python,https://docker-py.readthedocs.io/en/stable/) >= 2.0.0"
- "Docker API >= 1.25" - "Docker API >= 1.25"
''' """
EXAMPLES = ''' EXAMPLES = r"""
- name: Get info from a service - name: Get info from a service
community.docker.docker_swarm_service_info: community.docker.docker_swarm_service_info:
name: myservice name: myservice
register: result register: result
''' """
RETURN = ''' RETURN = r"""
exists: exists:
description: description:
- Returns whether the service exists. - Returns whether the service exists.
@@ -61,7 +59,7 @@ service:
- Will be V(none) if service does not exist. - Will be V(none) if service does not exist.
returned: always returned: always
type: dict type: dict
''' """
import traceback import traceback
+14 -16
View File
@@ -9,13 +9,12 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = r"""
module: docker_volume module: docker_volume
short_description: Manage Docker volumes short_description: Manage Docker volumes
description: description:
- Create/remove Docker volumes. - Create/remove Docker volumes.
- Performs largely the same function as the C(docker volume) CLI subcommand. - Performs largely the same function as the C(docker volume) CLI subcommand.
extends_documentation_fragment: extends_documentation_fragment:
- community.docker.docker.api_documentation - community.docker.docker.api_documentation
- community.docker.attributes - community.docker.attributes
@@ -44,26 +43,25 @@ options:
driver_options: driver_options:
description: description:
- "Dictionary of volume settings. Consult docker docs for valid options and values: - 'Dictionary of volume settings. Consult the Docker documentation for valid options and values:
U(https://docs.docker.com/engine/reference/commandline/volume_create/#driver-specific-options)." U(https://docs.docker.com/engine/reference/commandline/volume_create/#driver-specific-options).'
type: dict type: dict
default: {} default: {}
labels: labels:
description: description:
- Dictionary of label key/values to set for the volume - Dictionary of label key/values to set for the volume.
type: dict type: dict
recreate: recreate:
description: description:
- Controls when a volume will be recreated when O(state=present). Please - Controls when a volume will be recreated when O(state=present). Please note that recreating an existing volume will
note that recreating an existing volume will cause B(any data in the existing volume cause B(any data in the existing volume to be lost!) The volume will be deleted and a new volume with the same name
to be lost!) The volume will be deleted and a new volume with the same name will be will be created.
created.
- The value V(always) forces the volume to be always recreated. - The value V(always) forces the volume to be always recreated.
- The value V(never) makes sure the volume will not be recreated. - The value V(never) makes sure the volume will not be recreated.
- The value V(options-changed) makes sure the volume will be recreated if the volume - The value V(options-changed) makes sure the volume will be recreated if the volume already exist and the driver, driver
already exist and the driver, driver options or labels differ. options or labels differ.
type: str type: str
default: never default: never
choices: choices:
@@ -86,9 +84,9 @@ author:
requirements: requirements:
- "Docker API >= 1.25" - "Docker API >= 1.25"
''' """
EXAMPLES = ''' EXAMPLES = r"""
- name: Create a volume - name: Create a volume
community.docker.docker_volume: community.docker.docker_volume:
name: volume_one name: volume_one
@@ -104,16 +102,16 @@ EXAMPLES = '''
driver_options: driver_options:
type: btrfs type: btrfs
device: /dev/sda2 device: /dev/sda2
''' """
RETURN = ''' RETURN = r"""
volume: volume:
description: description:
- Volume inspection results for the affected volume. - Volume inspection results for the affected volume.
returned: success returned: success
type: dict type: dict
sample: {} sample: {}
''' """
import traceback import traceback
+8 -16
View File
@@ -9,12 +9,11 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = r"""
module: docker_volume_info module: docker_volume_info
short_description: Retrieve facts about Docker volumes short_description: Retrieve facts about Docker volumes
description: description:
- Performs largely the same function as the C(docker volume inspect) CLI subcommand. - Performs largely the same function as the C(docker volume inspect) CLI subcommand.
extends_documentation_fragment: extends_documentation_fragment:
- community.docker.docker.api_documentation - community.docker.docker.api_documentation
- community.docker.attributes - community.docker.attributes
@@ -35,9 +34,9 @@ author:
requirements: requirements:
- "Docker API >= 1.25" - "Docker API >= 1.25"
''' """
EXAMPLES = ''' EXAMPLES = r"""
- name: Get infos on volume - name: Get infos on volume
community.docker.docker_volume_info: community.docker.docker_volume_info:
name: mydata name: mydata
@@ -51,9 +50,9 @@ EXAMPLES = '''
ansible.builtin.debug: ansible.builtin.debug:
var: result.volume var: result.volume
when: result.exists when: result.exists
''' """
RETURN = ''' RETURN = r"""
exists: exists:
description: description:
- Returns whether the volume exists. - Returns whether the volume exists.
@@ -66,16 +65,9 @@ volume:
- Will be V(none) if volume does not exist. - Will be V(none) if volume does not exist.
returned: success returned: success
type: dict type: dict
sample: '{ sample: '{ "CreatedAt": "2018-12-09T17:43:44+01:00", "Driver": "local", "Labels": null, "Mountpoint": "/var/lib/docker/volumes/ansible-test-bd3f6172/_data",
"CreatedAt": "2018-12-09T17:43:44+01:00", "Name": "ansible-test-bd3f6172", "Options": {}, "Scope": "local" }'
"Driver": "local", """
"Labels": null,
"Mountpoint": "/var/lib/docker/volumes/ansible-test-bd3f6172/_data",
"Name": "ansible-test-bd3f6172",
"Options": {},
"Scope": "local"
}'
'''
import traceback import traceback