docker modules: add missing option types (#52422)

* Add missing option types for docker modules.

* Reorder argument_spec.

* First part of option reordering/reformatting.

* Second part of option reordering/reformatting.

* Forgot two required: false.

* Normalize booleans.

* Added missing period.
This commit is contained in:
Felix Fontein 2019-02-18 21:40:52 +01:00 committed by ansibot
parent 0e9ff44df1
commit 8388c89a29
18 changed files with 647 additions and 561 deletions

View file

@ -78,9 +78,9 @@ MIN_DOCKER_VERSION = "1.8.0"
DEFAULT_TIMEOUT_SECONDS = 60 DEFAULT_TIMEOUT_SECONDS = 60
DOCKER_COMMON_ARGS = dict( DOCKER_COMMON_ARGS = dict(
docker_host=dict(type='str', aliases=['docker_url'], default=DEFAULT_DOCKER_HOST, fallback=(env_fallback, ['DOCKER_HOST'])), docker_host=dict(type='str', default=DEFAULT_DOCKER_HOST, fallback=(env_fallback, ['DOCKER_HOST']), aliases=['docker_url']),
tls_hostname=dict(type='str', default=DEFAULT_TLS_HOSTNAME, fallback=(env_fallback, ['DOCKER_TLS_HOSTNAME'])), tls_hostname=dict(type='str', default=DEFAULT_TLS_HOSTNAME, fallback=(env_fallback, ['DOCKER_TLS_HOSTNAME'])),
api_version=dict(type='str', aliases=['docker_api_version'], default='auto', fallback=(env_fallback, ['DOCKER_API_VERSION'])), api_version=dict(type='str', default='auto', fallback=(env_fallback, ['DOCKER_API_VERSION']), aliases=['docker_api_version']),
timeout=dict(type='int', default=DEFAULT_TIMEOUT_SECONDS, fallback=(env_fallback, ['DOCKER_TIMEOUT'])), timeout=dict(type='int', default=DEFAULT_TIMEOUT_SECONDS, fallback=(env_fallback, ['DOCKER_TIMEOUT'])),
cacert_path=dict(type='path', aliases=['tls_ca_cert']), cacert_path=dict(type='path', aliases=['tls_ca_cert']),
cert_path=dict(type='path', aliases=['tls_client_cert']), cert_path=dict(type='path', aliases=['tls_client_cert']),

View file

@ -36,55 +36,62 @@ options:
- Path to a directory containing a docker-compose.yml or docker-compose.yaml file. - Path to a directory containing a docker-compose.yml or docker-compose.yaml file.
- Mutually exclusive with C(definition). - Mutually exclusive with C(definition).
- Required when no C(definition) is provided. - Required when no C(definition) is provided.
type: path
project_name: project_name:
description: description:
- Provide a project name. If not provided, the project name is taken from the basename of C(project_src). - Provide a project name. If not provided, the project name is taken from the basename of C(project_src).
- Required when C(definition) is provided. - Required when C(definition) is provided.
type: str
files: files:
description: description:
- List of file names relative to C(project_src). Overrides docker-compose.yml or docker-compose.yaml. - List of file names relative to C(project_src). Overrides docker-compose.yml or docker-compose.yaml.
- Files are loaded and merged in the order given. - Files are loaded and merged in the order given.
type: list
state: state:
description: description:
- Desired state of the project. - Desired state of the project.
- Specifying I(present) is the same as running I(docker-compose up). - Specifying I(present) is the same as running I(docker-compose up).
- Specifying I(absent) is the same as running I(docker-compose down). - Specifying I(absent) is the same as running I(docker-compose down).
type: str
default: present
choices: choices:
- absent - absent
- present - present
default: present
services: services:
description: description:
- When C(state) is I(present) run I(docker-compose up) on a subset of services. - When C(state) is I(present) run I(docker-compose up) on a subset of services.
type: list
scale: scale:
description: description:
- When C(state) is I(present) scale services. Provide a dictionary of key/value pairs where the key - When C(state) is I(present) scale services. Provide a dictionary of key/value pairs where the key
is the name of the service and the value is an integer count for the number of containers. is the name of the service and the value is an integer count for the number of containers.
type: dict
dependencies: dependencies:
description: description:
- When C(state) is I(present) specify whether or not to include linked services. - When C(state) is I(present) specify whether or not to include linked services.
type: bool type: bool
default: 'yes' default: yes
definition: definition:
description: description:
- Provide docker-compose yaml describing one or more services, networks and volumes. - Provide docker-compose yaml describing one or more services, networks and volumes.
- Mutually exclusive with C(project_src) and C(files). - Mutually exclusive with C(project_src) and C(files).
type: dict
hostname_check: hostname_check:
description: description:
- Whether or not to check the Docker daemon's hostname against the name provided in the client certificate. - Whether or not to check the Docker daemon's hostname against the name provided in the client certificate.
type: bool type: bool
default: 'no' default: no
recreate: recreate:
description: description:
- By default containers will be recreated when their configuration differs from the service definition. - By default containers will be recreated when their configuration differs from the service definition.
- Setting to I(never) ignores configuration differences and leaves existing containers unchanged. - Setting to I(never) ignores configuration differences and leaves existing containers unchanged.
- Setting to I(always) forces recreation of all existing containers. - Setting to I(always) forces recreation of all existing containers.
required: false type: str
default: smart
choices: choices:
- always - always
- never - never
- smart - smart
default: smart
build: build:
description: description:
- Use with state I(present) to always build images prior to starting the application. - Use with state I(present) to always build images prior to starting the application.
@ -93,24 +100,25 @@ options:
- Use the C(nocache) option to ignore the image cache when performing the build. - Use the C(nocache) option to ignore the image cache when performing the build.
- If an existing image is replaced, services using the image will be recreated unless C(recreate) is I(never). - If an existing image is replaced, services using the image will be recreated unless C(recreate) is I(never).
type: bool type: bool
default: 'no' default: no
pull: pull:
description: description:
- Use with state I(present) to always pull images prior to starting the application. - Use with state I(present) to always pull images prior to starting the application.
- Same as running docker-compose pull. - Same as running docker-compose pull.
- When a new image is pulled, services using the image will be recreated unless C(recreate) is I(never). - When a new image is pulled, services using the image will be recreated unless C(recreate) is I(never).
type: bool type: bool
default: 'no' default: no
version_added: "2.2" version_added: "2.2"
nocache: nocache:
description: description:
- Use with the build option to ignore the cache during the image build process. - Use with the build option to ignore the cache during the image build process.
type: bool type: bool
default: 'no' default: no
version_added: "2.2" version_added: "2.2"
remove_images: remove_images:
description: description:
- Use with state I(absent) to remove the all images or only local images. - Use with state I(absent) to remove the all images or only local images.
type: str
choices: choices:
- 'all' - 'all'
- 'local' - 'local'
@ -118,25 +126,26 @@ options:
description: description:
- Use with state I(absent) to remove data volumes. - Use with state I(absent) to remove data volumes.
type: bool type: bool
default: 'no' default: no
stopped: stopped:
description: description:
- Use with state I(present) to leave the containers in an exited or non-running state. - Use with state I(present) to leave the containers in an exited or non-running state.
type: bool type: bool
default: 'no' default: no
restarted: restarted:
description: description:
- Use with state I(present) to restart all containers. - Use with state I(present) to restart all containers.
type: bool type: bool
default: 'no' default: no
remove_orphans: remove_orphans:
description: description:
- Remove containers for services not defined in the compose file. - Remove containers for services not defined in the compose file.
type: bool type: bool
default: false default: no
timeout: timeout:
description: description:
- timeout in seconds for container shutdown when attached or when containers are already running. - timeout in seconds for container shutdown when attached or when containers are already running.
type: int
default: 10 default: 10
extends_documentation_fragment: extends_documentation_fragment:
@ -1033,10 +1042,10 @@ def main():
project_src=dict(type='path'), project_src=dict(type='path'),
project_name=dict(type='str',), project_name=dict(type='str',),
files=dict(type='list', elements='path'), files=dict(type='list', elements='path'),
state=dict(type='str', choices=['absent', 'present'], default='present'), state=dict(type='str', default='present', choices=['absent', 'present']),
definition=dict(type='dict'), definition=dict(type='dict'),
hostname_check=dict(type='bool', default=False), hostname_check=dict(type='bool', default=False),
recreate=dict(type='str', choices=['always', 'never', 'smart'], default='smart'), recreate=dict(type='str', default='smart', choices=['always', 'never', 'smart']),
build=dict(type='bool', default=False), build=dict(type='bool', default=False),
remove_images=dict(type='str', choices=['all', 'local']), remove_images=dict(type='str', choices=['all', 'local']),
remove_volumes=dict(type='bool', default=False), remove_volumes=dict(type='bool', default=False),

View file

@ -30,7 +30,6 @@ options:
data: data:
description: description:
- The value of the config. Required when state is C(present). - The value of the config. Required when state is C(present).
required: false
type: str type: str
data_is_b64: data_is_b64:
description: description:
@ -38,29 +37,28 @@ options:
decoded before being used. decoded before being used.
- To use binary C(data), it is better to keep it Base64 encoded and let it - To use binary C(data), it is better to keep it Base64 encoded and let it
be decoded by this option. be decoded by this option.
default: false
type: bool type: bool
default: no
labels: labels:
description: description:
- "A map of key:value meta data, where both the I(key) and I(value) are expected to be a string." - "A map of key:value meta data, where both the I(key) and I(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.
required: false
type: dict type: dict
force: force:
description: description:
- Use with state C(present) to always remove and recreate an existing config. - Use with state C(present) to always remove and recreate an existing config.
- If I(true), an existing config will be replaced, even if it has not been changed. - If I(true), an existing config will be replaced, even if it has not been changed.
default: false
type: bool type: bool
default: no
name: name:
description: description:
- The name of the config. - The name of the config.
required: true
type: str type: str
required: yes
state: state:
description: description:
- Set to C(present), if the config should exist, and C(absent), if it should not. - Set to C(present), if the config should exist, and C(absent), if it should not.
required: false type: str
default: present default: present
choices: choices:
- absent - absent
@ -264,7 +262,7 @@ class ConfigManager(DockerBaseClass):
def main(): def main():
argument_spec = dict( argument_spec = dict(
name=dict(type='str', required=True), name=dict(type='str', required=True),
state=dict(type='str', choices=['absent', 'present'], default='present'), state=dict(type='str', default='present', choices=['absent', 'present']),
data=dict(type='str'), data=dict(type='str'),
data_is_b64=dict(type='bool', default=False), data_is_b64=dict(type='bool', default=False),
labels=dict(type='dict'), labels=dict(type='dict'),

View file

@ -29,31 +29,34 @@ options:
description: description:
- enable auto-removal of the container on daemon side when the container's process exits - enable auto-removal of the container on daemon side when the container's process exits
type: bool type: bool
default: 'no' default: no
version_added: "2.4" version_added: "2.4"
blkio_weight: blkio_weight:
description: description:
- Block IO (relative weight), between 10 and 1000. - Block IO (relative weight), between 10 and 1000.
type: int
capabilities: capabilities:
description: description:
- List of capabilities to add to the container. - List of capabilities to add to the container.
type: list
cap_drop: cap_drop:
description: description:
- List of capabilities to drop from the container. - List of capabilities to drop from the container.
type: list
version_added: "2.7" version_added: "2.7"
cleanup: cleanup:
description: description:
- Use with I(detach=false) to remove the container after successful execution. - Use with I(detach=false) to remove the container after successful execution.
type: bool type: bool
default: 'no' default: no
version_added: "2.2" version_added: "2.2"
command: command:
description: description:
- Command to execute when the container starts. - Command to execute when the container starts.
A command may be either a string or a list. A command may be either a string or a list.
Prior to version 2.4, strings were split on commas. - Prior to version 2.4, strings were split on commas.
type: raw
comparisons: comparisons:
type: dict
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 should be recreated / updated module options to decide whether the container should be recreated / updated
@ -72,50 +75,57 @@ options:
- The wildcard option C(*) can be used to set one of the default values C(strict) - The wildcard option C(*) can be used to set one of the default values C(strict)
or C(ignore) to I(all) comparisons. or C(ignore) to I(all) comparisons.
- See the examples for details. - See the examples for details.
type: dict
version_added: "2.8" version_added: "2.8"
cpu_period: cpu_period:
description: description:
- Limit CPU CFS (Completely Fair Scheduler) period - Limit CPU CFS (Completely Fair Scheduler) period
type: int
cpu_quota: cpu_quota:
description: description:
- Limit CPU CFS (Completely Fair Scheduler) quota - Limit CPU CFS (Completely Fair Scheduler) quota
type: int
cpuset_cpus: cpuset_cpus:
description: description:
- CPUs in which to allow execution C(1,3) or C(1-3). - CPUs in which to allow execution C(1,3) or C(1-3).
type: str
cpuset_mems: cpuset_mems:
description: description:
- Memory nodes (MEMs) in which to allow execution C(0-3) or C(0,1) - Memory nodes (MEMs) in which to allow execution C(0-3) or C(0,1)
type: str
cpu_shares: cpu_shares:
description: description:
- CPU shares (relative weight). - CPU shares (relative weight).
type: int
detach: detach:
description: description:
- Enable detached mode to leave the container running in background. - Enable detached mode to leave the container running in background.
If disabled, the task will reflect the status of the container run (failed if the command failed). If disabled, the task will reflect the status of the container run (failed if the command failed).
type: bool type: bool
default: true default: yes
devices: devices:
description: description:
- "List of host device bindings to add to the container. Each binding is a mapping expressed - "List of host device bindings to add to the container. Each binding is a mapping expressed
in the format: <path_on_host>:<path_in_container>:<cgroup_permissions>" in the format: <path_on_host>:<path_in_container>:<cgroup_permissions>"
type: list
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
suboptions: suboptions:
path: path:
type: str
required: true
description: description:
- Device path in the container. - Device path in the container.
rate:
type: str type: str
required: true required: yes
rate:
description: description:
- "Device read limit. Format: <number>[<unit>]" - "Device read limit. Format: <number>[<unit>]"
- "Number is a positive integer. Unit can be one of C(B) (byte), C(K) (kibibyte, 1024B), C(M) (mebibyte), C(G) (gibibyte), - "Number is a positive integer. Unit can be one of C(B) (byte), C(K) (kibibyte, 1024B), C(M) (mebibyte), C(G) (gibibyte),
C(T) (tebibyte), or C(P) (pebibyte)" C(T) (tebibyte), or C(P) (pebibyte)"
- "Omitting the unit defaults to bytes." - "Omitting the unit defaults to bytes."
type: str
required: yes
version_added: "2.8" version_added: "2.8"
device_write_bps: device_write_bps:
description: description:
@ -123,18 +133,18 @@ options:
type: list type: list
suboptions: suboptions:
path: path:
type: str
required: true
description: description:
- Device path in the container. - Device path in the container.
rate:
type: str type: str
required: true required: yes
rate:
description: description:
- "Device read limit. Format: <number>[<unit>]" - "Device read limit. Format: <number>[<unit>]"
- "Number is a positive integer. Unit can be one of C(B) (byte), C(K) (kibibyte, 1024B), C(M) (mebibyte), C(G) (gibibyte), - "Number is a positive integer. Unit can be one of C(B) (byte), C(K) (kibibyte, 1024B), C(M) (mebibyte), C(G) (gibibyte),
C(T) (tebibyte), or C(P) (pebibyte)" C(T) (tebibyte), or C(P) (pebibyte)"
- "Omitting the unit defaults to bytes." - "Omitting the unit defaults to bytes."
type: str
required: yes
version_added: "2.8" version_added: "2.8"
device_read_iops: device_read_iops:
description: description:
@ -142,16 +152,16 @@ options:
type: list type: list
suboptions: suboptions:
path: path:
type: str
required: true
description: description:
- Device path in the container. - Device path in the container.
type: str
required: yes
rate: rate:
type: int
required: true
description: description:
- "Device read limit." - "Device read limit."
- "Must be a positive integer." - "Must be a positive integer."
type: int
required: yes
version_added: "2.8" version_added: "2.8"
device_write_iops: device_write_iops:
description: description:
@ -159,29 +169,33 @@ options:
type: list type: list
suboptions: suboptions:
path: path:
type: str
required: true
description: description:
- Device path in the container. - Device path in the container.
type: str
required: yes
rate: rate:
type: int
required: true
description: description:
- "Device read limit." - "Device read limit."
- "Must be a positive integer." - "Must be a positive integer."
type: int
required: yes
version_added: "2.8" version_added: "2.8"
dns_opts: dns_opts:
description: description:
- list of DNS options - list of DNS options
type: list
dns_servers: dns_servers:
description: description:
- List of custom DNS servers. - List of custom DNS servers.
type: list
dns_search_domains: dns_search_domains:
description: description:
- List of custom DNS search domains. - List of custom DNS search domains.
type: list
domainname: domainname:
description: description:
- Container domainname. - Container domainname.
type: str
version_added: "2.5" version_added: "2.5"
env: env:
description: description:
@ -189,23 +203,27 @@ options:
- Values which might be parsed as numbers, booleans or other types by the YAML parser must be quoted (e.g. C("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 (e.g. C("true")) in order to avoid data loss.
type: dict type: dict
env_file: env_file:
version_added: "2.2"
description: description:
- Path to a file, present on the target, containing environment variables I(FOO=BAR). - Path to a file, present on the target, containing environment variables I(FOO=BAR).
- If variable also present in C(env), then C(env) value will override. - If variable also present in C(env), then C(env) value will override.
type: path
version_added: "2.2"
entrypoint: entrypoint:
description: description:
- Command that overwrites the default ENTRYPOINT of the image. - Command that overwrites the default ENTRYPOINT of the image.
type: list
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 container's /etc/hosts file. Each host name will be added to the container's /etc/hosts file.
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 at runtime. listens on the specified network ports at runtime.
If the port is already exposed using EXPOSE in a Dockerfile, it does not If the port is already exposed using EXPOSE in a Dockerfile, it does not
need to be exposed again. need to be exposed again.
type: list
aliases: aliases:
- exposed - exposed
- expose - expose
@ -213,26 +231,27 @@ options:
description: description:
- Use the kill command when stopping a running container. - Use the kill command when stopping a running container.
type: bool type: bool
default: 'no' default: no
aliases: aliases:
- forcekill - forcekill
groups: groups:
description: description:
- List of additional group names and/or IDs that the container process will run as. - List of additional group names and/or IDs that the container process will run as.
type: list
healthcheck: healthcheck:
version_added: "2.8"
type: dict
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.'
- 'I(interval), I(timeout) and I(start_period) are specified as durations. They accept duration as a string in a format - 'I(interval), I(timeout) and I(start_period) are specified as durations. They accept duration as a string in a format
that look like: C(5h34m56s), C(1m30s) etc. The supported units are C(us), C(ms), C(s), C(m) and C(h)' that look like: C(5h34m56s), C(1m30s) etc. The supported units are C(us), C(ms), C(s), C(m) and C(h)'
type: dict
suboptions: suboptions:
test: test:
description: description:
- Command to run to check health. - Command to run to check health.
- Must be either a string or a list. If it is a list, the first item must be one of C(NONE), C(CMD) or C(CMD-SHELL). - Must be either a string or a list. If it is a list, the first item must be one of C(NONE), C(CMD) or C(CMD-SHELL).
type: raw
interval: interval:
description: description:
- 'Time between running the check. (default: 30s)' - 'Time between running the check. (default: 30s)'
@ -249,9 +268,11 @@ options:
description: description:
- 'Start period for the container to initialize before starting health-retries countdown. (default: 0s)' - 'Start period for the container to initialize before starting health-retries countdown. (default: 0s)'
type: str type: str
version_added: "2.8"
hostname: hostname:
description: description:
- Container hostname. - Container hostname.
type: str
ignore_image: ignore_image:
description: description:
- When C(state) is I(present) or I(started) the module compares the configuration of an existing - When C(state) is I(present) or I(started) the module compares the configuration of an existing
@ -260,7 +281,7 @@ options:
recreated. Stop this behavior by setting C(ignore_image) to I(True). recreated. Stop this behavior by setting C(ignore_image) to I(True).
- I(Warning:) This option is ignored if C(image) or C(*) is used for the C(comparisons) option. - I(Warning:) This option is ignored if C(image) or C(*) is used for the C(comparisons) option.
type: bool type: bool
default: 'no' default: no
version_added: "2.2" version_added: "2.2"
image: image:
description: description:
@ -268,63 +289,72 @@ options:
will be pulled from the registry. If no tag is included, C(latest) will be used. will be pulled from the registry. If no tag is included, C(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 C(pull) option is ignored for this case. The C(pull) option is ignored for this case.
type: str
init: init:
description: description:
- Run an init inside the container that forwards signals and reaps processes. - Run an init inside the container that forwards signals and reaps processes.
This option requires Docker API 1.25+. This option requires Docker API 1.25+.
type: bool type: bool
default: 'no' default: no
version_added: "2.6" version_added: "2.6"
interactive: interactive:
description: description:
- Keep stdin open after a container is launched, even if not attached. - Keep stdin open after a container is launched, even if not attached.
type: bool type: bool
default: 'no' default: no
ipc_mode: ipc_mode:
description: description:
- Set the IPC mode for the container. Can be one of 'container:<name|id>' to reuse another - Set the IPC mode for the container. Can be one of 'container:<name|id>' to reuse another
container's IPC namespace or 'host' to use the host's IPC namespace within the container. container's IPC namespace or 'host' to use the host's IPC namespace within the container.
type: str
keep_volumes: keep_volumes:
description: description:
- Retain volumes associated with a removed container. - Retain volumes associated with a removed container.
type: bool type: bool
default: 'yes' default: yes
kill_signal: kill_signal:
description: description:
- Override default signal used to kill a running container. - Override default signal used to kill a running container.
type: str
kernel_memory: kernel_memory:
description: description:
- "Kernel memory limit (format: C(<number>[<unit>])). Number is a positive integer. - "Kernel memory limit (format: C(<number>[<unit>])). Number is a positive integer.
Unit can be C(B) (byte), C(K) (kibibyte, 1024B), C(M) (mebibyte), C(G) (gibibyte), Unit can be C(B) (byte), C(K) (kibibyte, 1024B), C(M) (mebibyte), C(G) (gibibyte),
C(T) (tebibyte), or C(P) (pebibyte). Minimum is C(4M)." C(T) (tebibyte), or C(P) (pebibyte). Minimum is C(4M)."
- Omitting the unit defaults to bytes. - Omitting the unit defaults to bytes.
type: str
labels: labels:
description: description:
- Dictionary of key value pairs. - Dictionary of key value pairs.
type: dict
links: links:
description: description:
- List of name aliases for linked containers in the format C(container_name:alias). - List of name aliases for linked containers in the format C(container_name:alias).
- Setting this will force container to be restarted. - Setting this will force container to be restarted.
type: list
log_driver: log_driver:
description: description:
- Specify the logging driver. Docker uses I(json-file) by default. - Specify the logging driver. Docker uses I(json-file) by default.
- See L(here,https://docs.docker.com/config/containers/logging/configure/) for possible choices. - See L(here,https://docs.docker.com/config/containers/logging/configure/) for possible choices.
required: false type: str
log_options: log_options:
description: description:
- Dictionary of options specific to the chosen log_driver. See https://docs.docker.com/engine/admin/logging/overview/ - Dictionary of options specific to the chosen log_driver. See https://docs.docker.com/engine/admin/logging/overview/
for details. for details.
type: dict
aliases: aliases:
- log_opt - log_opt
mac_address: mac_address:
description: description:
- Container MAC address (e.g. 92:d0:c6:0a:29:33) - Container MAC address (e.g. 92:d0:c6:0a:29:33)
type: str
memory: memory:
description: description:
- "Memory limit (format: C(<number>[<unit>])). Number is a positive integer. - "Memory limit (format: C(<number>[<unit>])). Number is a positive integer.
Unit can be C(B) (byte), C(K) (kibibyte, 1024B), C(M) (mebibyte), C(G) (gibibyte), Unit can be C(B) (byte), C(K) (kibibyte, 1024B), C(M) (mebibyte), C(G) (gibibyte),
C(T) (tebibyte), or C(P) (pebibyte)." C(T) (tebibyte), or C(P) (pebibyte)."
- Omitting the unit defaults to bytes. - Omitting the unit defaults to bytes.
type: str
default: '0' default: '0'
memory_reservation: memory_reservation:
description: description:
@ -332,27 +362,33 @@ options:
Unit can be C(B) (byte), C(K) (kibibyte, 1024B), C(M) (mebibyte), C(G) (gibibyte), Unit can be C(B) (byte), C(K) (kibibyte, 1024B), C(M) (mebibyte), C(G) (gibibyte),
C(T) (tebibyte), or C(P) (pebibyte)." C(T) (tebibyte), or C(P) (pebibyte)."
- Omitting the unit defaults to bytes. - Omitting the unit defaults to bytes.
type: str
memory_swap: memory_swap:
description: description:
- "Total memory limit (memory + swap, format: C(<number>[<unit>])). - "Total memory limit (memory + swap, format: C(<number>[<unit>])).
Number is a positive integer. Unit can be C(B) (byte), C(K) (kibibyte, 1024B), Number is a positive integer. Unit can be C(B) (byte), C(K) (kibibyte, 1024B),
C(M) (mebibyte), C(G) (gibibyte), C(T) (tebibyte), or C(P) (pebibyte)." C(M) (mebibyte), C(G) (gibibyte), C(T) (tebibyte), or C(P) (pebibyte)."
- Omitting the unit defaults to bytes. - Omitting the unit defaults to bytes.
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 from the host machine if it is (re-)created. - If not set, the value will be remain the same if container exists and will be inherited from the host machine if it is (re-)created.
type: int
name: name:
description: description:
- Assign a name to a new container or match an existing container. - Assign a name to a new container or match an existing container.
- When identifying an existing container name may be a name or a long or short container ID. - When identifying an existing container name may be a name or a long or short container ID.
required: true type: str
required: yes
network_mode: network_mode:
description: description:
- Connect the container to a network. Choices are "bridge", "host", "none" or "container:<name|id>" - Connect the container to a network. Choices are "bridge", "host", "none" or "container:<name|id>"
type: str
userns_mode: userns_mode:
description: description:
- Set the user namespace mode for the container. Currently, the only valid value is C(host). - Set the user namespace mode for the container. Currently, the only valid value is C(host).
type: str
version_added: "2.5" version_added: "2.5"
networks: networks:
description: description:
@ -362,31 +398,31 @@ options:
- Note that as opposed to C(docker run ...), M(docker_container) does not remove the default - Note that as opposed to C(docker run ...), M(docker_container) does not remove the default
network if C(networks) is specified. You need to explicity use C(purge_networks) to enforce network if C(networks) is specified. You need to explicity use C(purge_networks) to enforce
the removal of the default network (and all other networks not explicitly mentioned in C(networks)). the removal of the default network (and all other networks not explicitly mentioned in C(networks)).
version_added: "2.2"
type: list type: list
suboptions: suboptions:
name: name:
type: str
required: true
description: description:
- The network's name. - The network's name.
ipv4_address:
type: str type: str
required: yes
ipv4_address:
description: description:
- The container's IPv4 address in this network. - The container's IPv4 address in this network.
ipv6_address:
type: str type: str
ipv6_address:
description: description:
- The container's IPv6 address in this network. - The container's IPv6 address in this network.
type: str
links: links:
type: list
description: description:
- A list of containers to link to. - A list of containers to link to.
aliases:
type: list type: list
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
version_added: "2.2"
oom_killer: oom_killer:
description: description:
- Whether or not to disable OOM Killer for the container. - Whether or not to disable OOM Killer for the container.
@ -394,22 +430,24 @@ options:
oom_score_adj: oom_score_adj:
description: description:
- An integer value containing the score given to the container in order to tune OOM killer preferences. - An integer value containing the score given to the container in order to tune OOM killer preferences.
type: int
version_added: "2.2" version_added: "2.2"
output_logs: output_logs:
description: description:
- If set to true, output of the container command will be printed (only effective when log_driver is set to json-file or journald. - If set to true, output of the container command will be printed (only effective when log_driver is set to json-file or journald.
type: bool type: bool
default: 'no' default: no
version_added: "2.7" version_added: "2.7"
paused: paused:
description: description:
- Use with the started state to pause running processes inside the container. - Use with the started state to pause running processes inside the container.
type: bool type: bool
default: 'no' default: no
pid_mode: pid_mode:
description: description:
- Set the PID namespace mode for the container. - Set the PID namespace mode for the container.
- Note that docker-py < 2.0 only supports 'host'. Newer versions allow all values supported by the docker daemon. - Note that docker-py < 2.0 only supports 'host'. Newer versions allow all values supported by the docker daemon.
type: str
pids_limit: pids_limit:
description: description:
- Set PIDs limit for the container. It accepts an integer value. - Set PIDs limit for the container. It accepts an integer value.
@ -420,7 +458,7 @@ options:
description: description:
- Give extended privileges to the container. - Give extended privileges to the container.
type: bool type: bool
default: 'no' default: no
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.
@ -440,6 +478,7 @@ options:
will be bound to the host IP pointed to by com.docker.network.bridge.host_binding_ipv4. will be bound to the host IP pointed to by com.docker.network.bridge.host_binding_ipv4.
Note that the first bridge network with a com.docker.network.bridge.host_binding_ipv4 Note that the first bridge network with a com.docker.network.bridge.host_binding_ipv4
value encountered in the list of C(networks) is the one that will be used. value encountered in the list of C(networks) is the one that will be used.
type: list
aliases: aliases:
- ports - ports
pull: pull:
@ -449,32 +488,33 @@ options:
- I(Note) that images are only pulled when specified by name. If the image is specified - I(Note) that images are only pulled when specified by name. If the image is specified
as a image ID (hash), it cannot be pulled. as a image ID (hash), it cannot be pulled.
type: bool type: bool
default: 'no' default: no
purge_networks: purge_networks:
description: description:
- Remove the container from ALL networks not included in C(networks) parameter. - Remove the container from ALL networks not included in C(networks) parameter.
- Any default networks such as I(bridge), if not found in C(networks), will be removed as well. - Any default networks such as I(bridge), if not found in C(networks), will be removed as well.
type: bool type: bool
default: 'no' default: no
version_added: "2.2" version_added: "2.2"
read_only: read_only:
description: description:
- Mount the container's root file system as read-only. - Mount the container's root file system as read-only.
type: bool type: bool
default: 'no' default: no
recreate: recreate:
description: description:
- Use with present and started states to force the re-creation of an existing container. - Use with present and started states to force the re-creation of an existing container.
type: bool type: bool
default: 'no' default: no
restart: restart:
description: description:
- Use with started state to force a matching container to be stopped and restarted. - Use with started state to force a matching container to be stopped and restarted.
type: bool type: bool
default: 'no' default: no
restart_policy: restart_policy:
description: description:
- Container restart policy. Place quotes around I(no) option. - Container restart policy. Place quotes around I(no) option.
type: str
choices: choices:
- 'no' - 'no'
- 'on-failure' - 'on-failure'
@ -483,9 +523,11 @@ options:
restart_retries: restart_retries:
description: description:
- Use with restart policy to control maximum number of restart attempts. - Use with restart policy to control maximum number of restart attempts.
type: int
runtime: runtime:
description: description:
- Runtime to use for the container. - Runtime to use for the container.
type: str
version_added: "2.8" version_added: "2.8"
shm_size: shm_size:
description: description:
@ -493,9 +535,11 @@ options:
Unit can be C(B) (byte), C(K) (kibibyte, 1024B), C(M) (mebibyte), C(G) (gibibyte), Unit can be C(B) (byte), C(K) (kibibyte, 1024B), C(M) (mebibyte), C(G) (gibibyte),
C(T) (tebibyte), or C(P) (pebibyte)." C(T) (tebibyte), or C(P) (pebibyte)."
- Omitting the unit defaults to bytes. If you omit the size entirely, the system uses C(64M). - Omitting the unit defaults to bytes. If you omit the size entirely, the system uses C(64M).
type: str
security_opts: security_opts:
description: description:
- List of security options in the form of C("label:user:User") - List of security options in the form of C("label:user:User")
type: list
state: state:
description: description:
- 'I(absent) - A container matching the specified name will be stopped and removed. Use force_kill to kill the container - 'I(absent) - A container matching the specified name will be stopped and removed. Use force_kill to kill the container
@ -517,6 +561,7 @@ options:
with a removed container.' with a removed container.'
- 'I(stopped) - Asserts that the container is first I(present), and then if the container is running moves it to a stopped - 'I(stopped) - Asserts that the container is first I(present), and then if the container is running moves it to a stopped
state. Use force_kill to kill a container rather than stopping it.' state. Use force_kill to kill a container rather than stopping it.'
type: str
default: started default: started
choices: choices:
- absent - absent
@ -526,6 +571,7 @@ options:
stop_signal: stop_signal:
description: description:
- Override default signal used to stop the container. - Override default signal used to stop the container.
type: str
stop_timeout: stop_timeout:
description: description:
- Number of seconds to wait for the container to stop before sending SIGKILL. - Number of seconds to wait for the container to stop before sending SIGKILL.
@ -536,34 +582,40 @@ options:
the behavior depends on the version of docker. New versions of docker will the behavior depends on the version of docker. New versions of docker will
always use the container's configured C(StopTimeout) value if it has been always use the container's configured C(StopTimeout) value if it has been
configured. configured.
type: int
trust_image_content: trust_image_content:
description: description:
- If C(yes), skip image verification. - If C(yes), skip image verification.
type: bool type: bool
default: 'no' default: no
tmpfs: tmpfs:
description: description:
- Mount a tmpfs directory - Mount a tmpfs directory
type: list
version_added: 2.4 version_added: 2.4
tty: tty:
description: description:
- Allocate a pseudo-TTY. - Allocate a pseudo-TTY.
type: bool type: bool
default: 'no' default: no
ulimits: ulimits:
description: description:
- "List of ulimit options. A ulimit is specified as C(nofile:262144:262144)" - "List of ulimit options. A ulimit is specified as C(nofile:262144:262144)"
type: list
sysctls: sysctls:
description: description:
- Dictionary of key,value pairs. - Dictionary of key,value pairs.
type: dict
version_added: 2.4 version_added: 2.4
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 [ user | user:group | uid | uid:gid | user:gid | uid:group ]" - "Can be [ user | user:group | uid | uid:gid | user:gid | uid:group ]"
type: str
uts: uts:
description: description:
- Set the UTS namespace mode for the container. - Set the UTS namespace mode for the container.
type: str
volumes: volumes:
description: description:
- List of volumes to mount within the container. - List of volumes to mount within the container.
@ -575,15 +627,19 @@ options:
private label for the volume. private label for the volume.
- "Note that Ansible 2.7 and earlier only supported one mode, which had to be one of C(ro), C(rw), - "Note that Ansible 2.7 and earlier only supported one mode, which had to be one of C(ro), C(rw),
C(z), and C(Z)." C(z), and C(Z)."
type: list
volume_driver: volume_driver:
description: description:
- The container volume driver. - The container volume driver.
type: str
volumes_from: volumes_from:
description: description:
- List of container names or Ids to get volumes from. - List of container names or Ids to get volumes from.
type: list
working_dir: working_dir:
description: description:
- Path to the working directory. - Path to the working directory.
type: str
version_added: "2.4" version_added: "2.4"
extends_documentation_fragment: extends_documentation_fragment:
- docker - docker
@ -2794,7 +2850,7 @@ def main():
env=dict(type='dict'), env=dict(type='dict'),
env_file=dict(type='path'), env_file=dict(type='path'),
etc_hosts=dict(type='dict'), etc_hosts=dict(type='dict'),
exposed_ports=dict(type='list', aliases=['exposed', 'expose'], elements='str'), exposed_ports=dict(type='list', elements='str', aliases=['exposed', 'expose']),
force_kill=dict(type='bool', default=False, aliases=['forcekill']), force_kill=dict(type='bool', default=False, aliases=['forcekill']),
groups=dict(type='list', elements='str'), groups=dict(type='list', elements='str'),
healthcheck=dict(type='dict', options=dict( healthcheck=dict(type='dict', options=dict(
@ -2825,7 +2881,7 @@ def main():
name=dict(type='str', required=True), name=dict(type='str', required=True),
network_mode=dict(type='str'), network_mode=dict(type='str'),
networks=dict(type='list', elements='dict', options=dict( networks=dict(type='list', elements='dict', options=dict(
name=dict(required=True, type='str'), name=dict(type='str', required=True),
ipv4_address=dict(type='str'), ipv4_address=dict(type='str'),
ipv6_address=dict(type='str'), ipv6_address=dict(type='str'),
aliases=dict(type='list', elements='str'), aliases=dict(type='list', elements='str'),
@ -2838,18 +2894,18 @@ def main():
pid_mode=dict(type='str'), pid_mode=dict(type='str'),
pids_limit=dict(type='int'), pids_limit=dict(type='int'),
privileged=dict(type='bool', default=False), privileged=dict(type='bool', default=False),
published_ports=dict(type='list', aliases=['ports'], elements='str'), published_ports=dict(type='list', elements='str', aliases=['ports']),
pull=dict(type='bool', default=False), pull=dict(type='bool', default=False),
purge_networks=dict(type='bool', default=False), purge_networks=dict(type='bool', default=False),
read_only=dict(type='bool', default=False), read_only=dict(type='bool', default=False),
recreate=dict(type='bool', default=False), recreate=dict(type='bool', default=False),
restart=dict(type='bool', default=False), restart=dict(type='bool', default=False),
restart_policy=dict(type='str', choices=['no', 'on-failure', 'always', 'unless-stopped']), restart_policy=dict(type='str', choices=['no', 'on-failure', 'always', 'unless-stopped']),
restart_retries=dict(type='int', default=None), restart_retries=dict(type='int'),
runtime=dict(type='str', default=None), runtime=dict(type='str'),
security_opts=dict(type='list', elements='str'), security_opts=dict(type='list', elements='str'),
shm_size=dict(type='str'), shm_size=dict(type='str'),
state=dict(type='str', choices=['absent', 'present', 'started', 'stopped'], default='started'), state=dict(type='str', default='started', choices=['absent', 'present', 'started', 'stopped']),
stop_signal=dict(type='str'), stop_signal=dict(type='str'),
stop_timeout=dict(type='int'), stop_timeout=dict(type='int'),
sysctls=dict(type='dict'), sysctls=dict(type='dict'),

View file

@ -30,7 +30,8 @@ options:
description: description:
- The name of the container to inspect. - The name of the container to inspect.
- When identifying an existing container name may be a name or a long or short container ID. - When identifying an existing container name may be a name or a long or short container ID.
required: true type: str
required: yes
extends_documentation_fragment: extends_documentation_fragment:
- docker - docker
- docker.docker_py_1_documentation - docker.docker_py_1_documentation

View file

@ -28,88 +28,83 @@ options:
archive_path: archive_path:
description: description:
- Use with state C(present) to archive an image to a .tar file. - Use with state C(present) to archive an image to a .tar file.
required: false type: path
version_added: "2.1" version_added: "2.1"
cache_from: cache_from:
description: description:
- List of image names to consider as cache source. - List of image names to consider as cache source.
required: false
type: list type: list
version_added: "2.8" version_added: "2.8"
load_path: load_path:
description: description:
- Use with state C(present) to load an image from a .tar file. - Use with state C(present) to load an image from a .tar file.
required: false type: path
version_added: "2.2" version_added: "2.2"
dockerfile: dockerfile:
description: description:
- Use with state C(present) to provide an alternate name for the Dockerfile to use when building an image. - Use with state C(present) to provide an alternate name for the Dockerfile to use when building an image.
required: false type: str
version_added: "2.0" version_added: "2.0"
force: force:
description: description:
- Use with state I(absent) to un-tag and remove all images matching the specified name. Use with state - Use with state I(absent) to un-tag and remove all images matching the specified name. Use with state
C(present) to build, load or pull an image when the image already exists. C(present) to build, load or pull an image when the image already exists.
default: false
required: false
version_added: "2.1"
type: bool type: bool
default: no
version_added: "2.1"
http_timeout: http_timeout:
description: description:
- Timeout for HTTP requests during the image build operation. Provide a positive integer value for the number of - Timeout for HTTP requests during the image build operation. Provide a positive integer value for the number of
seconds. seconds.
required: false type: int
version_added: "2.1" version_added: "2.1"
name: name:
description: description:
- "Image name. Name format will be one of: name, repository/name, registry_server:port/name. - "Image name. Name format will be one of: name, repository/name, registry_server:port/name.
When pushing or pulling an image the name can optionally include the tag by appending ':tag_name'." When pushing or pulling an image the name can optionally include the tag by appending ':tag_name'."
- Note that image IDs (hashes) are not supported. - Note that image IDs (hashes) are not supported.
required: true type: str
required: yes
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 for building an image. Dockerfile for building an image.
type: path
aliases: aliases:
- build_path - build_path
required: false
pull: pull:
description: description:
- When building an image downloads any updates to the FROM image in Dockerfile. - When building an image downloads any updates to the FROM image in Dockerfile.
default: true
required: false
version_added: "2.1"
type: bool type: bool
default: yes
version_added: "2.1"
push: push:
description: description:
- Push the image to the registry. Specify the registry as part of the I(name) or I(repository) parameter. - Push the image to the registry. Specify the registry as part of the I(name) or I(repository) parameter.
default: false
required: false
version_added: "2.2"
type: bool type: bool
default: no
version_added: "2.2"
rm: rm:
description: description:
- Remove intermediate containers after build. - Remove intermediate containers after build.
default: true
required: false
version_added: "2.1"
type: bool type: bool
default: yes
version_added: "2.1"
network: network:
description: description:
- The network to use for C(RUN) build instructions. - The network to use for C(RUN) build instructions.
required: false type: str
version_added: "2.8" version_added: "2.8"
nocache: nocache:
description: description:
- Do not use cache when building an image. - Do not use cache when building an image.
default: false
required: false
type: bool type: bool
default: no
repository: repository:
description: description:
- Full path to a repository. Use with state C(present) to tag the image into the repository. Expects - Full path to a repository. Use with state C(present) to tag the image into the repository. Expects
format I(repository:tag). If no tag is provided, will use the value of the C(tag) parameter or I(latest). format I(repository:tag). If no tag is provided, will use the value of the C(tag) parameter or I(latest).
required: false type: str
version_added: "2.1" version_added: "2.1"
state: state:
description: description:
@ -123,7 +118,7 @@ options:
repository, provide a repository path. If the name contains a repository path, it will be pushed. repository, provide a repository path. If the name contains a repository path, it will be pushed.
- "NOTE: C(build) is DEPRECATED and will be removed in release 2.11. Specifying C(build) will behave the - "NOTE: C(build) is DEPRECATED and will be removed in release 2.11. Specifying C(build) will behave the
same as C(present)." same as C(present)."
required: false type: str
default: present default: present
choices: choices:
- absent - absent
@ -134,33 +129,37 @@ options:
- 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
I(latest). I(latest).
- If C(name) parameter format is I(name:tag), then tag value from C(name) will take precedence. - If C(name) parameter format is I(name:tag), then tag value from C(name) will take precedence.
type: str
default: latest default: latest
required: false
buildargs: buildargs:
description: description:
- Provide a dictionary of C(key:value) build arguments that map to Dockerfile ARG directive. - Provide a dictionary of C(key:value) build arguments that map to Dockerfile ARG directive.
- Docker expects the value to be a string. For convenience any non-string values will be converted to strings. - Docker expects the value to be a string. For convenience any non-string values will be converted to strings.
- Requires Docker API >= 1.21. - Requires Docker API >= 1.21.
required: false type: dict
version_added: "2.2" version_added: "2.2"
container_limits: container_limits:
description: description:
- A dictionary of limits applied to each container created by the build process. - A dictionary of limits applied to each container created by the build process.
required: false type: dict
version_added: "2.1"
suboptions: suboptions:
memory: memory:
description: description:
- Set memory limit for build. - Set memory limit for build.
type: int
memswap: memswap:
description: description:
- Total memory (memory + swap), -1 to disable swap. - Total memory (memory + swap), -1 to disable swap.
type: int
cpushares: cpushares:
description: description:
- CPU shares (relative weight). - CPU shares (relative weight).
type: int
cpusetcpus: cpusetcpus:
description: description:
- CPUs in which to allow execution, e.g., "0-3", "0,1". - CPUs in which to allow execution, e.g., "0-3", "0,1".
type: str
version_added: "2.1"
use_tls: use_tls:
description: description:
- "DEPRECATED. Whether to use tls to connect to the docker server. Set to - "DEPRECATED. Whether to use tls to connect to the docker server. Set to
@ -169,11 +168,11 @@ options:
- "NOTE: If you specify this option, it will set the value of the I(tls) or - "NOTE: If you specify this option, it will set the value of the I(tls) or
I(tls_verify) parameters if not set to I(no)." I(tls_verify) parameters if not set to I(no)."
- Will be removed in Ansible 2.11. - Will be removed in Ansible 2.11.
type: str
choices: choices:
- 'no' - 'no'
- 'encrypt' - 'encrypt'
- 'verify' - 'verify'
required: false
version_added: "2.0" version_added: "2.0"
extends_documentation_fragment: extends_documentation_fragment:
@ -628,10 +627,10 @@ def main():
push=dict(type='bool', default=False), push=dict(type='bool', default=False),
repository=dict(type='str'), repository=dict(type='str'),
rm=dict(type='bool', default=True), rm=dict(type='bool', default=True),
state=dict(type='str', choices=['absent', 'present', 'build'], default='present'), state=dict(type='str', default='present', choices=['absent', 'present', 'build']),
tag=dict(type='str', default='latest'), tag=dict(type='str', default='latest'),
use_tls=dict(type='str', choices=['no', 'encrypt', 'verify'], removed_in_version='2.11'), use_tls=dict(type='str', choices=['no', 'encrypt', 'verify'], removed_in_version='2.11'),
buildargs=dict(type='dict', default=None), buildargs=dict(type='dict'),
) )
option_minimal_versions = dict( option_minimal_versions = dict(

View file

@ -29,7 +29,8 @@ options:
- 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) is optional. If a tag is not provided, C(latest) will be used. Instead of image names, also where C(tag) is optional. If a tag is not provided, C(latest) will be used. Instead of image names, also
image IDs can be used. image IDs can be used.
required: true type: list
required: yes
extends_documentation_fragment: extends_documentation_fragment:
- docker - docker

View file

@ -31,6 +31,7 @@ options:
required: False required: False
description: description:
- The registry URL. - The registry URL.
type: str
default: "https://index.docker.io/v1/" default: "https://index.docker.io/v1/"
aliases: aliases:
- registry - registry
@ -38,25 +39,29 @@ options:
username: username:
description: description:
- The username for the registry account - The username for the registry account
required: True type: str
required: yes
password: password:
description: description:
- The plaintext password for the registry account - The plaintext password for the registry account
required: True type: str
required: yes
email: email:
required: False required: False
description: description:
- "The email address for the registry account." - "The email address for the registry account."
type: str
reauthorize: reauthorize:
description: description:
- Refresh existing authentication found in the configuration file. - Refresh existing authentication found in the configuration file.
type: bool type: bool
default: 'no' default: no
aliases: aliases:
- reauth - reauth
config_path: config_path:
description: description:
- Custom path to the Docker CLI configuration file. - Custom path to the Docker CLI configuration file.
type: path
default: ~/.docker/config.json default: ~/.docker/config.json
aliases: aliases:
- self.config_path - self.config_path
@ -68,8 +73,9 @@ options:
- To logout you only need the registry server, which defaults to DockerHub. - To logout you only need the registry server, which defaults to DockerHub.
- Before 2.1 you could ONLY log in. - Before 2.1 you could ONLY log in.
- docker does not support 'logout' with a custom config file. - docker does not support 'logout' with a custom config file.
choices: ['present', 'absent'] type: str
default: 'present' default: 'present'
choices: ['present', 'absent']
extends_documentation_fragment: extends_documentation_fragment:
- docker - docker
@ -287,9 +293,9 @@ class LoginManager(DockerBaseClass):
def main(): def main():
argument_spec = dict( argument_spec = dict(
registry_url=dict(type='str', required=False, default=DEFAULT_DOCKER_REGISTRY, aliases=['registry', 'url']), registry_url=dict(type='str', default=DEFAULT_DOCKER_REGISTRY, aliases=['registry', 'url']),
username=dict(type='str', required=False), username=dict(type='str'),
password=dict(type='str', required=False, no_log=True), password=dict(type='str', no_log=True),
email=dict(type='str'), email=dict(type='str'),
reauthorize=dict(type='bool', default=False, aliases=['reauth']), reauthorize=dict(type='bool', default=False, aliases=['reauth']),
state=dict(type='str', default='present', choices=['present', 'absent']), state=dict(type='str', default='present', choices=['present', 'absent']),

View file

@ -23,24 +23,28 @@ options:
name: name:
description: description:
- Name of the network to operate on. - Name of the network to operate on.
required: true type: str
required: yes
aliases: aliases:
- network_name - network_name
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.
type: list
aliases: aliases:
- containers - containers
driver: driver:
description: description:
- Specify the type of network. Docker provides bridge and overlay drivers, but 3rd party drivers can also be used. - Specify the type of network. Docker provides bridge and overlay drivers, but 3rd party drivers can also be used.
type: str
default: bridge default: bridge
driver_options: driver_options:
description: description:
- Dictionary of network settings. Consult docker docs for valid options and values. - Dictionary of network settings. Consult docker docs for valid options and values.
type: dict
force: force:
description: description:
@ -51,28 +55,27 @@ options:
driver options and want an existing network to be updated to use the driver options and want an existing network to be updated to use the
new options. new options.
type: bool type: bool
default: 'no' default: no
appends: appends:
description: description:
- By default the connected list is canonical, meaning containers not on the list are removed from the network. - By default the connected list is canonical, meaning containers not on the list are removed from the network.
Use C(appends) to leave existing containers connected. Use C(appends) to leave existing containers connected.
type: bool type: bool
default: 'no' default: no
aliases: aliases:
- incremental - incremental
enable_ipv6: enable_ipv6:
version_added: 2.8
description: description:
- Enable IPv6 networking. - Enable IPv6 networking.
type: bool type: bool
default: null version_added: 2.8
required: false
ipam_driver: ipam_driver:
description: description:
- Specify an IPAM driver. - Specify an IPAM driver.
type: str
ipam_options: ipam_options:
description: description:
@ -80,16 +83,14 @@ options:
- Deprecated in 2.8, will be removed in 2.12. Use parameter C(ipam_config) instead. In Docker 1.10.0, IPAM - Deprecated in 2.8, will be removed in 2.12. Use parameter C(ipam_config) instead. In Docker 1.10.0, IPAM
options were introduced (see L(here,https://github.com/moby/moby/pull/17316)). This module parameter addresses options were introduced (see L(here,https://github.com/moby/moby/pull/17316)). This module parameter addresses
the IPAM config not the newly introduced IPAM options. the IPAM config not the newly introduced IPAM options.
type: dict
ipam_config: ipam_config:
version_added: 2.8
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) for valid options and values. L(Docker docs,https://docs.docker.com/compose/compose-file/compose-file-v2/#ipam) for valid options and values.
Note that I(iprange) is spelled differently here (we use the notation from the Docker Python SDK). Note that I(iprange) is spelled differently here (we use the notation from the Docker Python SDK).
type: list type: list
default: null
required: false
suboptions: suboptions:
subnet: subnet:
description: description:
@ -107,6 +108,7 @@ options:
description: description:
- Auxiliary IP addresses used by Network driver, as a mapping from hostname to IP. - Auxiliary IP addresses used by Network driver, as a mapping from hostname to IP.
type: dict type: dict
version_added: 2.8
state: state:
description: description:
@ -119,46 +121,39 @@ options:
An empty list will leave no containers connected to the network. Use the An empty list will leave no containers connected to the network. Use the
C(appends) option to leave existing containers connected. Use the C(force) C(appends) option to leave existing containers connected. Use the C(force)
options to force re-creation of the network. options to force re-creation of the network.
type: str
default: present default: present
choices: choices:
- absent - absent
- present - present
internal: internal:
version_added: 2.8
description: description:
- Restrict external access to the network. - Restrict external access to the network.
type: bool type: bool
default: null version_added: 2.8
required: false
labels: labels:
version_added: 2.8
description: description:
- Dictionary of labels. - Dictionary of labels.
type: dict type: dict
default: null version_added: 2.8
required: false
scope: scope:
version_added: 2.8
description: description:
- Specify the network's scope. - Specify the network's scope.
type: str type: str
default: null
required: false
choices: choices:
- local - local
- global - global
- swarm - swarm
version_added: 2.8
attachable: attachable:
version_added: 2.8
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
default: null version_added: 2.8
required: false
extends_documentation_fragment: extends_documentation_fragment:
- docker - docker
@ -590,19 +585,19 @@ class DockerNetworkManager(object):
def main(): def main():
argument_spec = dict( argument_spec = dict(
network_name=dict(type='str', required=True, aliases=['name']), network_name=dict(type='str', required=True, aliases=['name']),
connected=dict(type='list', default=[], aliases=['containers'], elements='str'), connected=dict(type='list', default=[], elements='str', aliases=['containers']),
state=dict(type='str', default='present', choices=['present', 'absent']), state=dict(type='str', default='present', choices=['present', 'absent']),
driver=dict(type='str', default='bridge'), driver=dict(type='str', default='bridge'),
driver_options=dict(type='dict', default={}), driver_options=dict(type='dict', default={}),
force=dict(type='bool', default=False), force=dict(type='bool', default=False),
appends=dict(type='bool', default=False, aliases=['incremental']), appends=dict(type='bool', default=False, aliases=['incremental']),
ipam_driver=dict(type='str'), ipam_driver=dict(type='str'),
ipam_options=dict(type='dict', default={}, removed_in_version='2.12', options=dict( ipam_options=dict(type='dict', default={}, options=dict(
subnet=dict(type='str'), subnet=dict(type='str'),
iprange=dict(type='str'), iprange=dict(type='str'),
gateway=dict(type='str'), gateway=dict(type='str'),
aux_addresses=dict(type='dict'), aux_addresses=dict(type='dict'),
)), ), removed_in_version='2.12'),
ipam_config=dict(type='list', elements='dict', options=dict( ipam_config=dict(type='list', elements='dict', options=dict(
subnet=dict(type='str'), subnet=dict(type='str'),
iprange=dict(type='str'), iprange=dict(type='str'),

View file

@ -30,7 +30,8 @@ options:
description: description:
- The name of the network to inspect. - The name of the network to inspect.
- When identifying an existing network name may be a name or a long or short network ID. - When identifying an existing network name may be a name or a long or short network ID.
required: true type: str
required: yes
extends_documentation_fragment: extends_documentation_fragment:
- docker - docker
- docker.docker_py_1_documentation - docker.docker_py_1_documentation

View file

@ -25,14 +25,13 @@ options:
- 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.
required: true
type: str type: str
required: yes
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.
- 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
I(labels_state) and I(labels_to_remove) parameters values. See description below. I(labels_state) and I(labels_to_remove) parameters values. See description below.
required: false
type: dict type: dict
labels_state: labels_state:
description: description:
@ -43,12 +42,11 @@ options:
If I(labels) is empty then no changes will be made. If I(labels) is empty then no changes will be made.
- Set to C(replace) to replace all assigned labels with provided ones. If I(labels) is empty then - Set to C(replace) to replace all assigned labels with provided ones. If I(labels) is empty then
all labels assigned to the node will be removed. all labels assigned to the node will be removed.
type: str
default: 'merge'
choices: choices:
- merge - merge
- replace - replace
default: 'merge'
required: false
type: str
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
@ -58,7 +56,6 @@ options:
assigned to the node. assigned to the node.
- If I(labels_state) is C(replace) and I(labels) is not provided or empty then all labels assigned to - If I(labels_state) is C(replace) and I(labels) is not provided or empty then all labels assigned to
node are removed and I(labels_to_remove) is ignored. node are removed and I(labels_to_remove) is ignored.
required: false
type: list type: list
availability: availability:
description: Node availability to assign. If not provided then node availability remains unchanged. description: Node availability to assign. If not provided then node availability remains unchanged.
@ -66,14 +63,12 @@ options:
- active - active
- pause - pause
- drain - drain
required: false
type: str type: str
role: role:
description: Node role to assign. If not provided then node role remains unchanged. description: Node role to assign. If not provided then node role remains unchanged.
choices: choices:
- manager - manager
- worker - worker
required: false
type: str type: str
extends_documentation_fragment: extends_documentation_fragment:
- docker - docker
@ -262,7 +257,7 @@ def main():
argument_spec = dict( argument_spec = dict(
hostname=dict(type='str', required=True), hostname=dict(type='str', required=True),
labels=dict(type='dict'), labels=dict(type='dict'),
labels_state=dict(type='str', choices=['merge', 'replace'], default='merge'), labels_state=dict(type='str', default='merge', choices=['merge', 'replace']),
labels_to_remove=dict(type='list', elements='str'), labels_to_remove=dict(type='list', elements='str'),
availability=dict(type='str', choices=['active', 'pause', 'drain']), availability=dict(type='str', choices=['active', 'pause', 'drain']),
role=dict(type='str', choices=['worker', 'manager']), role=dict(type='str', choices=['worker', 'manager']),

View file

@ -32,16 +32,14 @@ options:
- If empty then return information of all nodes in Swarm cluster. - If empty then return information of all nodes in Swarm cluster.
- When identifying the node use either the hostname of the node (as registered in Swarm) or node ID. - When identifying the node use either the hostname of the node (as registered in Swarm) or node ID.
- If I(self) is C(true) then this parameter is ignored. - If I(self) is C(true) then this parameter is ignored.
required: false
type: list type: list
self: self:
description: description:
- If C(true), queries the node (i.e. the docker daemon) the module communicates with. - If C(true), queries the node (i.e. the docker daemon) the module communicates with.
- If C(true) then I(name) is ignored. - If C(true) then I(name) is ignored.
- If C(false) then query depends on I(name) presence and value. - If C(false) then query depends on I(name) presence and value.
required: false
type: bool type: bool
default: false default: no
extends_documentation_fragment: extends_documentation_fragment:
- docker - docker
- docker.docker_py_1_documentation - docker.docker_py_1_documentation
@ -126,7 +124,7 @@ def get_node_facts(client):
def main(): def main():
argument_spec = dict( argument_spec = dict(
name=dict(type='list', elements='str'), name=dict(type='list', elements='str'),
self=dict(type='bool', default='False'), self=dict(type='bool', default=False),
) )
client = AnsibleDockerSwarmClient( client = AnsibleDockerSwarmClient(

View file

@ -30,7 +30,6 @@ options:
data: data:
description: description:
- The value of the secret. Required when state is C(present). - The value of the secret. Required when state is C(present).
required: false
type: str type: str
data_is_b64: data_is_b64:
description: description:
@ -38,30 +37,29 @@ options:
decoded before being used. decoded before being used.
- To use binary C(data), it is better to keep it Base64 encoded and let it - To use binary C(data), it is better to keep it Base64 encoded and let it
be decoded by this option. be decoded by this option.
default: false
type: bool type: bool
default: no
version_added: "2.8" version_added: "2.8"
labels: labels:
description: description:
- "A map of key:value meta data, where both the I(key) and I(value) are expected to be a string." - "A map of key:value meta data, where both the I(key) and I(value) are expected to be a string."
- 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.
required: false
type: dict type: dict
force: force:
description: description:
- Use with state C(present) to always remove and recreate an existing secret. - Use with state C(present) to always remove and recreate an existing secret.
- If I(true), an existing secret will be replaced, even if it has not changed. - If I(true), an existing secret will be replaced, even if it has not changed.
default: false
type: bool type: bool
default: no
name: name:
description: description:
- The name of the secret. - The name of the secret.
required: true
type: str type: str
required: yes
state: state:
description: description:
- Set to C(present), if the secret should exist, and C(absent), if it should not. - Set to C(present), if the secret should exist, and C(absent), if it should not.
required: false type: str
default: present default: present
choices: choices:
- absent - absent
@ -264,7 +262,7 @@ class SecretManager(DockerBaseClass):
def main(): def main():
argument_spec = dict( argument_spec = dict(
name=dict(type='str', required=True), name=dict(type='str', required=True),
state=dict(type='str', choices=['absent', 'present'], default='present'), state=dict(type='str', default='present', choices=['absent', 'present']),
data=dict(type='str', no_log=True), data=dict(type='str', no_log=True),
data_is_b64=dict(type='bool', default=False), data_is_b64=dict(type='bool', default=False),
labels=dict(type='dict'), labels=dict(type='dict'),

View file

@ -19,58 +19,63 @@ author: "Dario Zanzico (@dariko)"
short_description: docker stack module short_description: docker stack module
description: description:
- Manage docker stacks using the 'docker stack' command - Manage docker stacks using the 'docker stack' command
on the target node on the target node (see examples).
(see examples)
version_added: "2.8" version_added: "2.8"
options: options:
name: name:
required: true
description: description:
- Stack name - Stack name
type: str
required: yes
state: state:
description: description:
- Service state. - Service state.
type: str
default: "present" default: "present"
choices: choices:
- present - present
- absent - absent
compose: compose:
default: []
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
default: []
prune: prune:
default: false
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 not present in the This will have docker remove the services not present in the
current stack definition. current stack definition.
type: bool type: bool
default: no
with_registry_auth: with_registry_auth:
default: false
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 registry authentication details to Swarm agents. This will have docker send registry authentication details to Swarm agents.
type: bool type: bool
default: no
resolve_image: resolve_image:
choices: ["always", "changed", "never"]
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 registry to resolve image digest and This will have docker query the 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
choices: ["always", "changed", "never"]
absent_retries: absent_retries:
default: 0
description: description:
- If C(>0) and C(state==absent) the module will retry up to - If C(>0) and C(state==absent) the module will retry up to
C(absent_retries) times to delete the stack until all the C(absent_retries) times to delete the stack until all the
resources have been effectively deleted. resources have been effectively deleted.
If the last try still reports the stack as not completely If the last try still reports the stack as not completely
removed the module will fail. removed the module will fail.
type: int
default: 0
absent_retries_interval: absent_retries_interval:
default: 1
description: description:
- Interval in seconds between C(absent_retries) - Interval in seconds between C(absent_retries)
type: int
default: 1
requirements: requirements:
- jsondiff - jsondiff
@ -204,12 +209,12 @@ def docker_stack_rm(module, stack_name, retries, interval):
def main(): def main():
module = AnsibleModule( module = AnsibleModule(
argument_spec={ argument_spec={
'name': dict(required=True, type='str'), 'name': dict(type='str', required=True),
'compose': dict(required=False, type='list', default=[]), 'compose': dict(type='list', default=[]),
'prune': dict(default=False, type='bool'), 'prune': dict(type='bool', default=False),
'with_registry_auth': dict(default=False, type='bool'), 'with_registry_auth': dict(type='bool', default=False),
'resolve_image': dict(type='str', choices=['always', 'changed', 'never']), 'resolve_image': dict(type='str', choices=['always', 'changed', 'never']),
'state': dict(default='present', choices=['present', 'absent']), 'state': dict(tpye='str', default='present', choices=['present', 'absent']),
'absent_retries': dict(type='int', default=0), 'absent_retries': dict(type='int', default=0),
'absent_retries_interval': dict(type='int', default=1) 'absent_retries_interval': dict(type='int', default=1)
}, },

View file

@ -29,6 +29,7 @@ options:
the port number from the listen address is used. the port number from the listen address is used.
- If C(advertise_addr) is not specified, it will be automatically - If C(advertise_addr) is not specified, it will be automatically
detected when possible. detected when possible.
type: str
listen_addr: listen_addr:
description: description:
- Listen address used for inter-manager communication. - Listen address used for inter-manager communication.
@ -37,13 +38,14 @@ options:
like C(eth0:4567). like C(eth0:4567).
- If the port number is omitted, the default swarm listening port - If the port number is omitted, the default swarm listening port
is used. is used.
type: str
default: 0.0.0.0:2377 default: 0.0.0.0:2377
force: force:
description: description:
- Use with state C(present) to force creating a new Swarm, even if already part of one. - Use with state C(present) to force creating a new Swarm, even if already part of one.
- Use with state C(absent) to Leave the swarm even if this node is a manager. - Use with state C(absent) to Leave the swarm even if this node is a manager.
type: bool type: bool
default: 'no' default: no
state: state:
description: description:
- Set to C(present), to create/update a new cluster. - Set to C(present), to create/update a new cluster.
@ -51,7 +53,8 @@ options:
- Set to C(absent), to leave an existing cluster. - Set to C(absent), to leave an existing cluster.
- Set to C(remove), to remove an absent node from the cluster. - Set to C(remove), to remove an absent node from the cluster.
- Set to C(inspect) to display swarm informations. - Set to C(inspect) to display swarm informations.
required: true type: str
required: yes
default: present default: present
choices: choices:
- present - present
@ -63,62 +66,78 @@ options:
description: description:
- Swarm id of the node to remove. - Swarm id of the node to remove.
- Used with I(state=remove). - Used with I(state=remove).
type: str
join_token: join_token:
description: description:
- Swarm token used to join a swarm cluster. - Swarm token used to join a swarm cluster.
- Used with I(state=join). - Used with I(state=join).
type: str
remote_addrs: remote_addrs:
description: description:
- Remote address of a manager to connect to. - Remote address of a manager to connect to.
- Used with I(state=join). - Used with I(state=join).
type: list
task_history_retention_limit: task_history_retention_limit:
description: description:
- Maximum number of tasks history stored. - Maximum number of tasks history stored.
- Docker default value is C(5). - Docker default value is C(5).
type: int
snapshot_interval: snapshot_interval:
description: description:
- Number of logs entries between snapshot. - Number of logs entries between snapshot.
- Docker default value is C(10000). - Docker default value is C(10000).
type: int
keep_old_snapshots: keep_old_snapshots:
description: description:
- Number of snapshots to keep beyond the current snapshot. - Number of snapshots to keep beyond the current snapshot.
- Docker default value is C(0). - Docker default value is C(0).
type: int
log_entries_for_slow_followers: log_entries_for_slow_followers:
description: description:
- Number of log entries to keep around to sync up slow followers after a snapshot is created. - Number of log entries to keep around to sync up slow followers after a snapshot is created.
type: int
heartbeat_tick: heartbeat_tick:
description: description:
- Amount of ticks (in seconds) between each heartbeat. - Amount of ticks (in seconds) between each heartbeat.
- Docker default value is C(1s). - Docker default value is C(1s).
type: int
election_tick: election_tick:
description: description:
- Amount of ticks (in seconds) needed without a leader to trigger a new election. - Amount of ticks (in seconds) needed without a leader to trigger a new election.
- Docker default value is C(10s). - Docker default value is C(10s).
type: int
dispatcher_heartbeat_period: dispatcher_heartbeat_period:
description: description:
- The delay for an agent to send a heartbeat to the dispatcher. - The delay for an agent to send a heartbeat to the dispatcher.
- Docker default value is C(5s). - Docker default value is C(5s).
type: int
node_cert_expiry: node_cert_expiry:
description: description:
- Automatic expiry for nodes certificates. - Automatic expiry for nodes certificates.
- Docker default value is C(3months). - Docker default value is C(3months).
type: int
name: name:
description: description:
- The name of the swarm. - The name of the swarm.
type: str
labels: labels:
description: description:
- User-defined key/value metadata. - User-defined key/value metadata.
type: dict
signing_ca_cert: signing_ca_cert:
description: description:
- The desired signing CA certificate for all swarm node TLS leaf certificates, in PEM format. - The desired signing CA certificate for all swarm node TLS leaf certificates, in PEM format.
type: path
signing_ca_key: signing_ca_key:
description: description:
- The desired signing CA key for all swarm node TLS leaf certificates, in PEM format. - The desired signing CA key for all swarm node TLS leaf certificates, in PEM format.
type: path
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 C(0). - Docker default value is C(0).
type: int
autolock_managers: autolock_managers:
description: description:
- If set, generate a key and use it to lock data stored on the managers. - If set, generate a key and use it to lock data stored on the managers.
@ -127,11 +146,11 @@ options:
rotate_worker_token: rotate_worker_token:
description: Rotate the worker join token. description: Rotate the worker join token.
type: bool type: bool
default: 'no' default: no
rotate_manager_token: rotate_manager_token:
description: Rotate the manager join token. description: Rotate the manager join token.
type: bool type: bool
default: 'no' default: no
extends_documentation_fragment: extends_documentation_fragment:
- docker - docker
- docker.docker_py_2_documentation - docker.docker_py_2_documentation
@ -471,7 +490,7 @@ class SwarmManager(DockerBaseClass):
def main(): def main():
argument_spec = dict( argument_spec = dict(
advertise_addr=dict(type='str'), advertise_addr=dict(type='str'),
state=dict(type='str', choices=['present', 'join', 'absent', 'remove', 'inspect'], default='present'), state=dict(type='str', default='present', choices=['present', 'join', 'absent', 'remove', 'inspect']),
force=dict(type='bool', default=False), force=dict(type='bool', default=False),
listen_addr=dict(type='str', default='0.0.0.0:2377'), listen_addr=dict(type='str', default='0.0.0.0:2377'),
remote_addrs=dict(type='list', elements='str'), remote_addrs=dict(type='list', elements='str'),
@ -486,8 +505,8 @@ def main():
node_cert_expiry=dict(type='int'), node_cert_expiry=dict(type='int'),
name=dict(type='str'), name=dict(type='str'),
labels=dict(type='dict'), labels=dict(type='dict'),
signing_ca_cert=dict(type='str'), signing_ca_cert=dict(type='path'),
signing_ca_key=dict(type='str'), signing_ca_key=dict(type='path'),
ca_force_rotate=dict(type='int'), ca_force_rotate=dict(type='int'),
autolock_managers=dict(type='bool'), autolock_managers=dict(type='bool'),
node_id=dict(type='str'), node_id=dict(type='str'),

View file

@ -14,34 +14,34 @@ DOCUMENTATION = '''
module: docker_swarm_service module: docker_swarm_service
author: "Dario Zanzico (@dariko), Jason Witkowski (@jwitko)" author: "Dario Zanzico (@dariko), Jason Witkowski (@jwitko)"
short_description: docker swarm service short_description: docker swarm service
description: | description:
Manage docker services. Allows live altering of already defined services - Manage docker services. Allows live altering of already defined services.
version_added: "2.7" version_added: "2.7"
options: options:
name: name:
required: true
type: str
description: description:
- Service name. - Service name.
- Corresponds to the C(--name) option of C(docker service create). - Corresponds to the C(--name) option of C(docker service create).
image:
required: true
type: str type: str
required: yes
image:
description: description:
- Service image path and tag. - Service image path and tag.
- Corresponds to the C(IMAGE) parameter of C(docker service create). - Corresponds to the C(IMAGE) parameter of C(docker service create).
type: str
required: yes
resolve_image: resolve_image:
type: bool
default: true
description: description:
- If the current image digest should be resolved from registry and updated if changed. - If the current image digest should be resolved from registry and updated if changed.
type: bool
default: yes
version_added: 2.8 version_added: 2.8
state: state:
required: true
type: str
default: present
description: description:
- Service state. - Service state.
type: str
required: yes
default: present
choices: choices:
- present - present
- absent - absent
@ -49,26 +49,27 @@ options:
description: description:
- List arguments to be passed to the container. - List arguments to be passed to the container.
- Corresponds to the C(ARG) parameter of C(docker service create). - Corresponds to the C(ARG) parameter of C(docker service create).
type: list
command: command:
description: description:
- Command to execute when the container starts. - Command to execute when the container starts.
- A command may be either a string or a list or a list of strings. - A command may be either a string or a list or a list of strings.
- Corresponds to the C(COMMAND) parameter of C(docker service create). - Corresponds to the C(COMMAND) parameter of C(docker service create).
type: raw
version_added: 2.8 version_added: 2.8
constraints: constraints:
type: list
description: description:
- List of the service constraints. - List of the service constraints.
- Corresponds to the C(--constraint) option of C(docker service create). - Corresponds to the C(--constraint) option of C(docker service create).
placement_preferences:
type: list type: list
placement_preferences:
description: description:
- List of the placement preferences as key value pairs. - List of the placement preferences as key value pairs.
- Corresponds to the C(--placement-pref) option of C(docker service create). - Corresponds to the C(--placement-pref) option of C(docker service create).
- Requires API version >= 1.27. - Requires API version >= 1.27.
type: list
version_added: 2.8 version_added: 2.8
healthcheck: healthcheck:
type: dict
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)
@ -76,93 +77,94 @@ options:
- "I(interval), I(timeout) and I(start_period) are specified as durations. They accept duration as a string in a format - "I(interval), I(timeout) and I(start_period) are specified as durations. They accept duration as a string in a format
that look like: C(5h34m56s), C(1m30s) etc. The supported units are C(us), C(ms), C(s), C(m) and C(h)." that look like: C(5h34m56s), C(1m30s) etc. The supported units are C(us), C(ms), C(s), C(m) and C(h)."
- Requires API version >= 1.25. - Requires API version >= 1.25.
type: dict
suboptions: suboptions:
test: test:
description: description:
- Command to run to check health. - Command to run to check health.
- Must be either a string or a list. If it is a list, the first item must be one of C(NONE), C(CMD) or C(CMD-SHELL). - Must be either a string or a list. If it is a list, the first item must be one of C(NONE), C(CMD) or C(CMD-SHELL).
type: raw
interval: interval:
type: str
description: description:
- Time between running the check. - Time between running the check.
timeout:
type: str type: str
timeout:
description: description:
- Maximum time to allow one check to run. - Maximum time to allow one check to run.
type: str
retries: retries:
type: int
description: description:
- Consecutive failures needed to report unhealthy. It accept integer value. - Consecutive failures needed to report unhealthy. It accept integer value.
type: int
start_period: start_period:
type: str
description: description:
- Start period for the container to initialize before starting health-retries countdown. - Start period for the container to initialize before starting health-retries countdown.
type: str
version_added: "2.8" version_added: "2.8"
hostname: hostname:
type: str
description: description:
- Container hostname. - Container hostname.
- Corresponds to the C(--hostname) option of C(docker service create). - Corresponds to the C(--hostname) option of C(docker service create).
- Requires API version >= 1.25. - Requires API version >= 1.25.
type: str
tty: tty:
type: bool
description: description:
- Allocate a pseudo-TTY. - Allocate a pseudo-TTY.
- Corresponds to the C(--tty) option of C(docker service create). - Corresponds to the C(--tty) option of C(docker service create).
- Requires API version >= 1.25. - Requires API version >= 1.25.
type: bool
dns: dns:
type: list
description: description:
- List of custom DNS servers. - List of custom DNS servers.
- Corresponds to the C(--dns) option of C(docker service create). - Corresponds to the C(--dns) option of C(docker service create).
- Requires API version >= 1.25. - Requires API version >= 1.25.
dns_search:
type: list type: list
dns_search:
description: description:
- List of custom DNS search domains. - List of custom DNS search domains.
- Corresponds to the C(--dns-search) option of C(docker service create). - Corresponds to the C(--dns-search) option of C(docker service create).
- Requires API version >= 1.25. - Requires API version >= 1.25.
dns_options:
type: list type: list
dns_options:
description: description:
- List of custom DNS options. - List of custom DNS options.
- Corresponds to the C(--dns-option) option of C(docker service create). - Corresponds to the C(--dns-option) option of C(docker service create).
- Requires API version >= 1.25. - Requires API version >= 1.25.
type: list
force_update: force_update:
type: bool
default: false
description: description:
- Force update even if no changes require it. - Force update even if no changes require it.
- Corresponds to the C(--force) option of C(docker service update). - Corresponds to the C(--force) option of C(docker service update).
- Requires API version >= 1.25. - Requires API version >= 1.25.
type: bool
default: no
groups: groups:
type: list
description: description:
- List of additional group names and/or IDs that the container process will run as. - List of additional group names and/or IDs that the container process will run as.
- Corresponds to the C(--group) option of C(docker service update). - Corresponds to the C(--group) option of C(docker service update).
- Requires API version >= 1.25. - Requires API version >= 1.25.
type: list
version_added: "2.8" version_added: "2.8"
labels: labels:
type: dict
description: description:
- Dictionary of key value pairs. - Dictionary of key value pairs.
- Corresponds to the C(--label) option of C(docker service create). - Corresponds to the C(--label) option of C(docker service create).
container_labels:
type: dict type: dict
container_labels:
description: description:
- Dictionary of key value pairs. - Dictionary of key value pairs.
- Corresponds to the C(--container-label) option of C(docker service create). - Corresponds to the C(--container-label) option of C(docker service create).
type: dict
endpoint_mode: endpoint_mode:
type: str
description: description:
- Service endpoint mode. - Service endpoint mode.
- Corresponds to the C(--endpoint-mode) option of C(docker service create). - Corresponds to the C(--endpoint-mode) option of C(docker service create).
- Requires API version >= 1.25. - Requires API version >= 1.25.
type: str
choices: choices:
- vip - vip
- dnsrr - dnsrr
env: env:
type: raw
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).
@ -170,36 +172,36 @@ options:
booleans or other types by the YAML parser must be quoted (e.g. C("true")) booleans or other types by the YAML parser must be quoted (e.g. C("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
env_files: env_files:
type: list
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 I(env), then I(env) value will override. - If variable also present in I(env), then I(env) value will override.
type: list
version_added: "2.8" version_added: "2.8"
log_driver: log_driver:
type: str
description: description:
- Configure the logging driver for a service. - Configure the logging driver for a service.
- Corresponds to the C(--log-driver) option of C(docker service create). - Corresponds to the C(--log-driver) option of C(docker service create).
type: str
log_driver_options: log_driver_options:
type: dict
description: description:
- Options for service logging driver. - Options for service logging driver.
- Corresponds to the C(--log-opt) option of C(docker service create). - Corresponds to the C(--log-opt) option of C(docker service create).
type: dict
limit_cpu: limit_cpu:
type: float
description: description:
- Service CPU limit. C(0) equals no limit. - Service CPU limit. C(0) equals no limit.
- Corresponds to the C(--limit-cpu) option of C(docker service create). - Corresponds to the C(--limit-cpu) option of C(docker service create).
reserve_cpu:
type: float type: float
reserve_cpu:
description: description:
- Service CPU reservation. C(0) equals no reservation. - Service CPU reservation. C(0) equals no reservation.
- Corresponds to the C(--reserve-cpu) option of C(docker service create). - Corresponds to the C(--reserve-cpu) option of C(docker service create).
type: float
limit_memory: limit_memory:
type: str
description: description:
- "Service memory limit (format: C(<number>[<unit>])). Number is a positive integer. - "Service memory limit (format: C(<number>[<unit>])). Number is a positive integer.
Unit can be C(B) (byte), C(K) (kibibyte, 1024B), C(M) (mebibyte), C(G) (gibibyte), Unit can be C(B) (byte), C(K) (kibibyte, 1024B), C(M) (mebibyte), C(G) (gibibyte),
@ -207,8 +209,8 @@ options:
- C(0) equals no limit. - C(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).
reserve_memory:
type: str type: str
reserve_memory:
description: description:
- "Service memory reservation (format: C(<number>[<unit>])). Number is a positive integer. - "Service memory reservation (format: C(<number>[<unit>])). Number is a positive integer.
Unit can be C(B) (byte), C(K) (kibibyte, 1024B), C(M) (mebibyte), C(G) (gibibyte), Unit can be C(B) (byte), C(K) (kibibyte, 1024B), C(M) (mebibyte), C(G) (gibibyte),
@ -216,241 +218,242 @@ options:
- C(0) equals no reservation. - C(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).
mode:
type: str type: str
default: replicated mode:
description: description:
- Service replication mode. - Service replication mode.
- Corresponds to the C(--mode) option of C(docker service create). - Corresponds to the C(--mode) option of C(docker service create).
type: str
default: replicated
mounts: mounts:
type: list
description: description:
- List of dictionaries describing the service mounts. - List of dictionaries describing the service mounts.
- Corresponds to the C(--mount) option of C(docker service create). - Corresponds to the C(--mount) option of C(docker service create).
type: list
suboptions: suboptions:
source: source:
type: str
required: true
description: description:
- Mount source (e.g. a volume name or a host path). - Mount source (e.g. a volume name or a host path).
target:
type: str type: str
required: true required: yes
target:
description: description:
- Container path. - Container path.
type: str
required: yes
type: type:
description:
- The mount type.
type: str type: str
default: bind default: bind
choices: choices:
- bind - bind
- volume - volume
- tmpfs - tmpfs
description:
- The mount type.
readonly: readonly:
type: bool
default: false
description: description:
- Whether the mount should be read-only. - Whether the mount should be read-only.
type: bool
default: no
secrets: secrets:
type: list
description: description:
- List of dictionaries describing the service secrets. - List of dictionaries describing the service secrets.
- Corresponds to the C(--secret) option of C(docker service create). - Corresponds to the C(--secret) option of C(docker service create).
- Requires API version >= 1.25. - Requires API version >= 1.25.
type: list
suboptions: suboptions:
secret_id: secret_id:
type: str
required: true
description: description:
- Secret's ID. - Secret's ID.
secret_name:
type: str type: str
required: true required: yes
secret_name:
description: description:
- Secret's name as defined at its creation. - Secret's name as defined at its creation.
filename:
type: str type: str
required: yes
filename:
description: description:
- Name of the file containing the secret. Defaults to the I(secret_name) if not specified. - Name of the file containing the secret. Defaults to the I(secret_name) if not specified.
type: str
uid: uid:
type: int
default: 0
description: description:
- UID of the secret file's owner. - UID of the secret file's owner.
gid:
type: int type: int
default: 0 default: 0
gid:
description: description:
- GID of the secret file's group. - GID of the secret file's group.
mode:
type: int type: int
default: 0o444 default: 0
mode:
description: description:
- File access mode inside the container. - File access mode inside the container.
type: int
default: 0o444
configs: configs:
type: list
description: description:
- List of dictionaries describing the service configs. - List of dictionaries describing the service configs.
- Corresponds to the C(--config) option of C(docker service create). - Corresponds to the C(--config) option of C(docker service create).
- Requires API version >= 1.30. - Requires API version >= 1.30.
type: list
suboptions: suboptions:
config_id: config_id:
type: str
required: true
description: description:
- Config's ID. - Config's ID.
config_name:
type: str type: str
required: true required: yes
config_name:
description: description:
- Config's name as defined at its creation. - Config's name as defined at its creation.
filename:
type: str type: str
required: true required: yes
filename:
description: description:
- Name of the file containing the config. Defaults to the I(config_name) if not specified. - Name of the file containing the config. Defaults to the I(config_name) if not specified.
type: str
required: yes
uid: uid:
type: int
default: 0
description: description:
- UID of the config file's owner. - UID of the config file's owner.
gid:
type: int type: int
default: 0 default: 0
gid:
description: description:
- GID of the config file's group. - GID of the config file's group.
type: int
default: 0
mode: mode:
type: str
default: "0o444"
description: description:
- File access mode inside the container. - File access mode inside the container.
type: str
default: "0o444"
networks: networks:
type: list
description: description:
- List of the service networks names. - List of the service networks names.
- Corresponds to the C(--network) option of C(docker service create). - Corresponds to the C(--network) option of C(docker service create).
type: list
stop_signal: stop_signal:
type: str
description: description:
- Override default signal used to stop the container. - Override default signal used to stop the container.
- Corresponds to the C(--stop-signal) option of C(docker service create). - Corresponds to the C(--stop-signal) option of C(docker service create).
type: str
version_added: "2.8" version_added: "2.8"
publish: publish:
type: list
description: description:
- List of dictionaries describing the service published ports. - List of dictionaries describing the service published ports.
- Corresponds to the C(--publish) option of C(docker service create). - Corresponds to the C(--publish) option of C(docker service create).
- Requires API version >= 1.25. - Requires API version >= 1.25.
type: list
suboptions: suboptions:
published_port: published_port:
type: int
required: true
description: description:
- The port to make externally available. - The port to make externally available.
target_port:
type: int type: int
required: true required: yes
target_port:
description: description:
- The port inside the container to expose. - The port inside the container to expose.
type: int
required: yes
protocol: protocol:
type: str
default: tcp
description: description:
- What protocol to use. - What protocol to use.
type: str
default: tcp
choices: choices:
- tcp - tcp
- udp - udp
mode: mode:
type: str
description: description:
- What publish mode to use. - What publish mode to use.
- Requires API version >= 1.32. - Requires API version >= 1.32.
type: str
choices: choices:
- ingress - ingress
- host - host
replicas: replicas:
type: int
default: -1
description: description:
- Number of containers instantiated in the service. Valid only if I(mode) is C(replicated). - Number of containers instantiated in the service. Valid only if I(mode) is C(replicated).
- If set to C(-1), and service is not present, service replicas will be set to C(1). - If set to C(-1), and service is not present, service replicas will be set to C(1).
- If set to C(-1), and service is present, service replicas will be unchanged. - If set to C(-1), and service is present, service replicas will be unchanged.
- Corresponds to the C(--replicas) option of C(docker service create). - Corresponds to the C(--replicas) option of C(docker service create).
type: int
default: -1
restart_policy: restart_policy:
type: str
description: description:
- Restart condition of the service. - Restart condition of the service.
- Corresponds to the C(--restart-condition) option of C(docker service create). - Corresponds to the C(--restart-condition) option of C(docker service create).
type: str
choices: choices:
- none - none
- on-failure - on-failure
- any - any
restart_policy_attempts: restart_policy_attempts:
type: int
description: description:
- Maximum number of service restarts. - Maximum number of service restarts.
- Corresponds to the C(--restart-condition) option of C(docker service create). - Corresponds to the C(--restart-condition) option of C(docker service create).
restart_policy_delay:
type: int type: int
restart_policy_delay:
description: description:
- Delay between restarts. - Delay between restarts.
- Corresponds to the C(--restart-delay) option of C(docker service create). - Corresponds to the C(--restart-delay) option of C(docker service create).
restart_policy_window:
type: int type: int
restart_policy_window:
description: description:
- Restart policy evaluation window. - Restart policy evaluation window.
- Corresponds to the C(--restart-window) option of C(docker service create). - Corresponds to the C(--restart-window) option of C(docker service create).
update_delay:
type: int type: int
update_delay:
description: description:
- Rolling update delay in nanoseconds. - Rolling update delay in nanoseconds.
- Corresponds to the C(--update-delay) option of C(docker service create). - Corresponds to the C(--update-delay) option of C(docker service create).
- Before Ansible 2.8, the default value for this option was C(10). - Before Ansible 2.8, the default value for this option was C(10).
update_parallelism:
type: int type: int
update_parallelism:
description: description:
- Rolling update parallelism. - Rolling update parallelism.
- Corresponds to the C(--update-parallelism) option of C(docker service create). - Corresponds to the C(--update-parallelism) option of C(docker service create).
- Before Ansible 2.8, the default value for this option was C(1). - Before Ansible 2.8, the default value for this option was C(1).
type: int
update_failure_action: update_failure_action:
type: str
description: description:
- Action to take in case of container failure. - Action to take in case of container failure.
- Corresponds to the C(--update-failure-action) option of C(docker service create). - Corresponds to the C(--update-failure-action) option of C(docker service create).
type: str
choices: choices:
- continue - continue
- pause - pause
update_monitor: update_monitor:
type: int
description: description:
- Time to monitor updated tasks for failures, in nanoseconds. - Time to monitor updated tasks for failures, in nanoseconds.
- Corresponds to the C(--update-monitor) option of C(docker service create). - Corresponds to the C(--update-monitor) option of C(docker service create).
- Requires API version >= 1.25. - Requires API version >= 1.25.
type: int
update_max_failure_ratio: update_max_failure_ratio:
type: float
description: description:
- Fraction of tasks that may fail during an update before the failure action is invoked. - Fraction of tasks that may fail during an update before the failure action is invoked.
- Corresponds to the C(--update-max-failure-ratio) option of C(docker service create). - Corresponds to the C(--update-max-failure-ratio) option of C(docker service create).
- Requires API version >= 1.25. - Requires API version >= 1.25.
type: float
update_order: update_order:
type: str
description: description:
- Specifies the order of operations when rolling out an updated task. - Specifies the order of operations when rolling out an updated task.
- Corresponds to the C(--update-order) option of C(docker service create). - Corresponds to the C(--update-order) option of C(docker service create).
- Requires API version >= 1.29. - Requires API version >= 1.29.
user:
type: str type: str
user:
description: description:
- Sets the username or UID used for the specified command. - Sets the username or UID used for the specified command.
- Before Ansible 2.8, the default value for this option was C(root). - Before Ansible 2.8, the default value for this option was C(root).
- The default has been removed so that the user defined in the image is used if no user is specified here. - The default has been removed so that the user defined in the image is used if no user is specified here.
- Corresponds to the C(--user) option of C(docker service create). - Corresponds to the C(--user) option of C(docker service create).
working_dir:
type: str type: str
working_dir:
description: description:
- Path to the working directory. - Path to the working directory.
- Corresponds to the C(--workdir) option of C(docker service create). - Corresponds to the C(--workdir) option of C(docker service create).
type: str
version_added: "2.8" version_added: "2.8"
extends_documentation_fragment: extends_documentation_fragment:
- docker - docker
@ -1638,48 +1641,48 @@ def _detect_healthcheck_start_period(client):
def main(): def main():
argument_spec = dict( argument_spec = dict(
name=dict(required=True), name=dict(type='str', required=True),
image=dict(type='str'), image=dict(type='str'),
state=dict(default='present', choices=['present', 'absent']), state=dict(type='str', default='present', choices=['present', 'absent']),
mounts=dict(type='list', elements='dict', options=dict( mounts=dict(type='list', elements='dict', options=dict(
source=dict(type='str', required=True), source=dict(type='str', required=True),
target=dict(type='str', required=True), target=dict(type='str', required=True),
type=dict( type=dict(
default='bind',
type='str', type='str',
default='bind',
choices=['bind', 'volume', 'tmpfs'] choices=['bind', 'volume', 'tmpfs']
), ),
readonly=dict(default=False, type='bool'), readonly=dict(type='bool', default=False),
)), )),
configs=dict(type='list', elements='dict', options=dict( configs=dict(type='list', elements='dict', options=dict(
config_id=dict(type='str', required=True), config_id=dict(type='str', required=True),
config_name=dict(type='str', required=True), config_name=dict(type='str', required=True),
filename=dict(type='str'), filename=dict(type='str'),
uid=dict(default=0, type='int'), uid=dict(type='int', default=0),
gid=dict(default=0, type='int'), gid=dict(type='int', default=0),
mode=dict(default=0o444, type='int'), mode=dict(type='int', default=0o444),
)), )),
secrets=dict(type='list', elements='dict', options=dict( secrets=dict(type='list', elements='dict', options=dict(
secret_id=dict(type='str', required=True), secret_id=dict(type='str', required=True),
secret_name=dict(type='str', required=True), secret_name=dict(type='str', required=True),
filename=dict(type='str'), filename=dict(type='str'),
uid=dict(default=0, type='int'), uid=dict(type='int', default=0),
gid=dict(default=0, type='int'), gid=dict(type='int', default=0),
mode=dict(default=0o444, type='int'), mode=dict(type='int', default=0o444),
)), )),
networks=dict(type='list'), networks=dict(type='list', elements='str'),
command=dict(type='raw'), command=dict(type='raw'),
args=dict(type='list'), args=dict(type='list', elements='str'),
env=dict(type='raw'), env=dict(type='raw'),
env_files=dict(type='list', elements='path'), env_files=dict(type='list', elements='path'),
force_update=dict(default=False, type='bool'), force_update=dict(type='bool', default=False),
groups=dict(type='list', elements='str'), groups=dict(type='list', elements='str'),
log_driver=dict(type='str'), log_driver=dict(type='str'),
log_driver_options=dict(type='dict'), log_driver_options=dict(type='dict'),
publish=dict(type='list', elements='dict', options=dict( publish=dict(type='list', elements='dict', options=dict(
published_port=dict(type='int', required=True), published_port=dict(type='int', required=True),
target_port=dict(type='int', required=True), target_port=dict(type='int', required=True),
protocol=dict(default='tcp', type='str', choices=('tcp', 'udp')), protocol=dict(type='str', default='tcp', choices=('tcp', 'udp')),
mode=dict(type='str', choices=('ingress', 'host')), mode=dict(type='str', choices=('ingress', 'host')),
)), )),
constraints=dict(type='list'), constraints=dict(type='list'),
@ -1698,22 +1701,22 @@ def main():
hostname=dict(type='str'), hostname=dict(type='str'),
labels=dict(type='dict'), labels=dict(type='dict'),
container_labels=dict(type='dict'), container_labels=dict(type='dict'),
mode=dict(default='replicated', type='str'), mode=dict(type='str', default='replicated'),
replicas=dict(default=-1, type='int'), replicas=dict(type='int', default=-1),
endpoint_mode=dict(choices=['vip', 'dnsrr']), endpoint_mode=dict(type='str', choices=['vip', 'dnsrr']),
stop_signal=dict(type='str'), stop_signal=dict(type='str'),
limit_cpu=dict(type='float'), limit_cpu=dict(type='float'),
limit_memory=dict(type='str'), limit_memory=dict(type='str'),
reserve_cpu=dict(type='float'), reserve_cpu=dict(type='float'),
reserve_memory=dict(type='str'), reserve_memory=dict(type='str'),
resolve_image=dict(default=True, type='bool'), resolve_image=dict(type='bool', default=True),
restart_policy=dict(choices=['none', 'on-failure', 'any']), restart_policy=dict(type='str', choices=['none', 'on-failure', 'any']),
restart_policy_delay=dict(type='int'), restart_policy_delay=dict(type='int'),
restart_policy_attempts=dict(type='int'), restart_policy_attempts=dict(type='int'),
restart_policy_window=dict(type='int'), restart_policy_window=dict(type='int'),
update_delay=dict(type='int'), update_delay=dict(type='int'),
update_parallelism=dict(type='int'), update_parallelism=dict(type='int'),
update_failure_action=dict(choices=['continue', 'pause']), update_failure_action=dict(type='str', choices=['continue', 'pause']),
update_monitor=dict(type='int'), update_monitor=dict(type='int'),
update_max_failure_ratio=dict(type='float'), update_max_failure_ratio=dict(type='float'),
update_order=dict(type='str'), update_order=dict(type='str'),

View file

@ -24,16 +24,16 @@ options:
volume_name: volume_name:
description: description:
- Name of the volume to operate on. - Name of the volume to operate on.
required: true
type: str type: str
required: yes
aliases: aliases:
- name - name
driver: driver:
description: description:
- Specify the type of volume. Docker provides the C(local) driver, but 3rd party drivers can also be used. - Specify the type of volume. Docker provides the C(local) driver, but 3rd party drivers can also be used.
default: local
type: str type: str
default: local
driver_options: driver_options:
description: description:
@ -67,16 +67,18 @@ options:
- The value C(never) makes sure the volume will not be recreated. - The value C(never) makes sure the volume will not be recreated.
- The value C(options-changed) makes sure the volume will be recreated if the volume - The value C(options-changed) makes sure the volume will be recreated if the volume
already exist and the driver, driver options or labels differ. already exist and the driver, driver options or labels differ.
type: str
default: never
choices: choices:
- always - always
- never - never
- options-changed - options-changed
default: never
state: state:
description: description:
- C(absent) deletes the volume. - C(absent) deletes the volume.
- C(present) creates the volume, if it does not already exist. - C(present) creates the volume, if it does not already exist.
type: str
default: present default: present
choices: choices:
- absent - absent

View file

@ -23,8 +23,8 @@ options:
name: name:
description: description:
- Name of the volume to inspect. - Name of the volume to inspect.
required: true
type: str type: str
required: yes
aliases: aliases:
- volume_name - volume_name