Document attributes (#497)

* Add 'docker' action group attribute.

* Compatibility with older ansible-core releases.

* Fix typo.

* Docment standard attributes.

* Improve docs.

* Add shortcuts for common combinations.
This commit is contained in:
Felix Fontein 2022-11-06 21:15:09 +01:00 committed by GitHub
parent 7ea99edf07
commit 2261dff49f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 451 additions and 190 deletions

View File

@ -11,18 +11,18 @@ from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
DOCUMENTATION = '''
author:
author:
- Lorin Hochestein (!UNKNOWN)
- Leendert Brouwer (!UNKNOWN)
name: docker
short_description: Run tasks in docker containers
description:
name: docker
short_description: Run tasks in docker containers
description:
- Run commands or put/fetch files to an existing docker container.
- Uses the Docker CLI to execute commands in the container. If you prefer
to directly connect to the Docker daemon, use the
R(community.docker.docker_api,ansible_collections.community.docker.docker_api_connection)
connection plugin.
options:
options:
remote_addr:
description:
- The name of the container you want to access.

View File

@ -17,6 +17,9 @@ description:
directly with the Docker daemon instead of using the Docker CLI. Use the
R(community.docker.docker,ansible_collections.community.docker.docker_connection)
connection plugin if you want to use the Docker CLI.
extends_documentation_fragment:
- community.docker.docker.api_documentation
- community.docker.docker.var_names
options:
remote_user:
type: str
@ -63,10 +66,6 @@ options:
cli:
- name: timeout
type: integer
extends_documentation_fragment:
- community.docker.docker.api_documentation
- community.docker.docker.var_names
'''
import io

View File

@ -9,18 +9,18 @@ from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
DOCUMENTATION = '''
name: nsenter
short_description: execute on host running controller container
version_added: 1.9.0
description:
name: nsenter
short_description: execute on host running controller container
version_added: 1.9.0
description:
- This connection plugin allows Ansible, running in a privileged container, to execute tasks on the container
host instead of in the container itself.
- This is useful for running Ansible in a pull model, while still keeping the Ansible control node
containerized.
- It relies on having privileged access to run C(nsenter) in the host's PID namespace, allowing it to enter the
namespaces of the provided PID (default PID 1, or init/systemd).
author: Jeff Goldschrafe (@jgoldschrafe)
options:
author: Jeff Goldschrafe (@jgoldschrafe)
options:
nsenter_pid:
description:
- PID to attach with using nsenter.
@ -34,7 +34,7 @@ DOCUMENTATION = '''
ini:
- section: nsenter_connection
key: nsenter_pid
notes:
notes:
- The remote user is ignored; this plugin always runs as root.
- >-
This plugin requires the Ansible controller container to be launched in the following way:

View File

@ -0,0 +1,96 @@
# -*- coding: utf-8 -*-
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
class ModuleDocFragment(object):
# Standard documentation fragment
DOCUMENTATION = r'''
options: {}
attributes:
check_mode:
description: Can run in C(check_mode) and return changed status prediction without modifying target.
diff_mode:
description: Will return details on what has changed (or possibly needs changing in C(check_mode)), when in diff mode.
'''
# Should be used together with the standard fragment
INFO_MODULE = r'''
options: {}
attributes:
check_mode:
support: full
details:
- This action does not modify state.
diff_mode:
support: N/A
details:
- This action does not modify state.
'''
ACTIONGROUP_DOCKER = r'''
options: {}
attributes:
action_group:
description: Use C(group/docker) or C(group/community.docker.docker) in C(module_defaults) to set defaults for this module.
support: full
membership:
- community.docker.docker
- docker
'''
CONN = r'''
options: {}
attributes:
become:
description: Is usable alongside C(become) keywords.
connection:
description: Uses the target's configured connection information to execute code on it.
delegation:
description: Can be used in conjunction with C(delegate_to) and related keywords.
'''
FACTS = r'''
options: {}
attributes:
facts:
description: Action returns an C(ansible_facts) dictionary that will update existing host facts.
'''
# Should be used together with the standard fragment and the FACTS fragment
FACTS_MODULE = r'''
options: {}
attributes:
check_mode:
support: full
details:
- This action does not modify state.
diff_mode:
support: N/A
details:
- This action does not modify state.
facts:
support: full
'''
FILES = r'''
options: {}
attributes:
safe_file_operations:
description: Uses Ansible's strict file operation functions to ensure proper permissions and avoid data corruption.
'''
FLOW = r'''
options: {}
attributes:
action:
description: Indicates this has a corresponding action plugin so some parts of the options can be executed on the controller.
async:
description: Supports being used with the C(async) keyword.
'''

View File

@ -18,6 +18,10 @@ description:
- Return facts about whether the module runs in a Docker container.
author:
- Felix Fontein (@felixfontein)
extends_documentation_fragment:
- community.docker.attributes
- community.docker.attributes.facts
- community.docker.attributes.facts_module
'''
EXAMPLES = '''

View File

@ -14,7 +14,6 @@ module: docker_compose
short_description: Manage multi-container Docker applications with Docker Compose.
author: "Chris Houseknecht (@chouseknecht)"
description:
@ -24,6 +23,18 @@ description:
- Supports check mode.
- This module was called C(docker_service) before Ansible 2.8. The usage did not change.
extends_documentation_fragment:
- community.docker.docker
- community.docker.docker.docker_py_1_documentation
- community.docker.attributes
- community.docker.attributes.actiongroup_docker
attributes:
check_mode:
support: full
diff_mode:
support: none
options:
project_src:
description:
@ -172,11 +183,6 @@ options:
description:
- Currently ignored for this module, but might suddenly be supported later on.
extends_documentation_fragment:
- community.docker.docker
- community.docker.docker.docker_py_1_documentation
requirements:
- "L(Docker SDK for Python,https://docker-py.readthedocs.io/en/stable/) >= 1.8.0"
- "docker-compose >= 1.7.0, < 2.0.0"

View File

@ -14,13 +14,25 @@ module: docker_config
short_description: Manage docker configs.
description:
- Create and remove Docker configs in a Swarm environment. Similar to C(docker config create) and C(docker config rm).
- Adds to the metadata of new configs 'ansible_key', an encrypted hash representation of the data, which is then used
in future runs to test if a config has changed. If 'ansible_key' is not present, then a config will not be updated
unless the I(force) option is set.
- Updates to configs are performed by removing the config and creating it again.
extends_documentation_fragment:
- community.docker.docker
- community.docker.docker.docker_py_2_documentation
- community.docker.attributes
- community.docker.attributes.actiongroup_docker
attributes:
check_mode:
support: full
diff_mode:
support: none
options:
data:
description:
@ -88,11 +100,6 @@ options:
- golang
version_added: 2.5.0
extends_documentation_fragment:
- community.docker.docker
- community.docker.docker.docker_py_2_documentation
requirements:
- "L(Docker SDK for Python,https://docker-py.readthedocs.io/en/stable/) >= 2.6.0"
- "Docker API >= 1.30"

View File

@ -18,7 +18,6 @@ description:
- Manage the life cycle of Docker containers.
- Supports check mode. Run with C(--check) and C(--diff) to view config difference and list of actions to be taken.
notes:
- For most config changes, the container needs to be recreated. This means that the existing container has to be destroyed and
a new one created. This can cause unexpected data loss and downtime. You can use the I(comparisons) option to
@ -27,6 +26,20 @@ notes:
new container (except I(image)). Therefore, always specify B(all) options relevant to the container.
- When I(restart) is set to C(true), the module will only restart the container if no config changes are detected.
extends_documentation_fragment:
- community.docker.docker
- community.docker.docker.docker_py_1_documentation
- community.docker.attributes
- community.docker.attributes.actiongroup_docker
attributes:
check_mode:
support: partial
details:
- When trying to pull an image, the module assumes this is always changed in check mode.
diff_mode:
support: full
options:
auto_remove:
description:
@ -929,10 +942,6 @@ options:
description:
- Path to the working directory.
type: str
extends_documentation_fragment:
- community.docker.docker
- community.docker.docker.docker_py_1_documentation
author:
- "Cove Schneider (@cove)"

View File

@ -19,6 +19,17 @@ version_added: 1.5.0
description:
- Executes a command in a Docker container.
extends_documentation_fragment:
- community.docker.docker.api_documentation
- community.docker.attributes
- community.docker.attributes.actiongroup_docker
attributes:
check_mode:
support: none
diff_mode:
support: none
options:
container:
type: str
@ -82,8 +93,6 @@ options:
type: dict
version_added: 2.1.0
extends_documentation_fragment:
- community.docker.docker.api_documentation
notes:
- Does not support C(check_mode).
author:

View File

@ -19,6 +19,11 @@ description:
- Essentially returns the output of C(docker inspect <name>), similar to what M(community.docker.docker_container)
returns for a non-absent container.
extends_documentation_fragment:
- community.docker.docker.api_documentation
- community.docker.attributes
- community.docker.attributes.actiongroup_docker
- community.docker.attributes.info_module
options:
name:
@ -27,9 +32,6 @@ options:
- When identifying an existing container name may be a name or a long or short container ID.
type: str
required: true
extends_documentation_fragment:
- community.docker.docker.api_documentation
author:
- "Felix Fontein (@felixfontein)"

View File

@ -23,6 +23,20 @@ description:
- If the docker daemon cannot be contacted or does not meet the API version requirements,
the module will fail.
extends_documentation_fragment:
- community.docker.docker.api_documentation
- community.docker.attributes
- community.docker.attributes.actiongroup_docker
attributes:
check_mode:
support: full
details:
- This action does not modify state.
diff_mode:
support: N/A
details:
- This action does not modify state.
options:
containers:
@ -94,9 +108,6 @@ options:
for each type of the objects.
type: bool
default: false
extends_documentation_fragment:
- community.docker.docker.api_documentation
author:
- Piotr Wojciechowski (@WojciechowskiPiotr)

View File

@ -14,7 +14,6 @@ module: docker_image
short_description: Manage docker images
description:
- Build, load or pull an image, making the image available for creating containers. Also supports tagging
an image, pushing an image, and archiving an image to a C(.tar) file.
@ -22,6 +21,19 @@ description:
notes:
- Building images is done using Docker daemon's API. It is not possible to use BuildKit / buildx this way.
extends_documentation_fragment:
- community.docker.docker.api_documentation
- community.docker.attributes
- community.docker.attributes.actiongroup_docker
attributes:
check_mode:
support: partial
details:
- When trying to pull an image, the module assumes this is always changed in check mode.
diff_mode:
support: none
options:
source:
description:
@ -209,10 +221,6 @@ options:
type: str
default: latest
extends_documentation_fragment:
- community.docker.docker.api_documentation
requirements:
- "Docker API >= 1.25"

View File

@ -14,7 +14,6 @@ module: docker_image_info
short_description: Inspect docker images
description:
- Provide one or more image names, and the module will inspect each, returning an array of inspection results.
- If an image does not exist locally, it will not appear in the results. If you want to check whether an image exists
@ -26,6 +25,12 @@ description:
notes:
- This module was called C(docker_image_facts) before Ansible 2.8. The usage did not change.
extends_documentation_fragment:
- community.docker.docker.api_documentation
- community.docker.attributes
- community.docker.attributes.actiongroup_docker
- community.docker.attributes.info_module
options:
name:
description:
@ -36,10 +41,6 @@ options:
type: list
elements: str
extends_documentation_fragment:
- community.docker.docker.api_documentation
requirements:
- "Docker API >= 1.25"

View File

@ -21,6 +21,17 @@ description:
- Load one or multiple Docker images from a C(.tar) archive, and return information on
the loaded image(s).
extends_documentation_fragment:
- community.docker.docker.api_documentation
- community.docker.attributes
- community.docker.attributes.actiongroup_docker
attributes:
check_mode:
support: none
diff_mode:
support: none
options:
path:
description:
@ -28,9 +39,6 @@ options:
type: path
required: true
extends_documentation_fragment:
- community.docker.docker.api_documentation
notes:
- Does not support C(check_mode).

View File

@ -22,6 +22,18 @@ description:
store allows future connections to the registry using tools such as Ansible's Docker modules, the Docker CLI
and Docker SDK for Python without needing to provide credentials.
- Running in check mode will perform the authentication without updating the config file.
extends_documentation_fragment:
- community.docker.docker.api_documentation
- community.docker.attributes
- community.docker.attributes.actiongroup_docker
attributes:
check_mode:
support: full
diff_mode:
support: none
options:
registry_url:
description:
@ -65,9 +77,6 @@ options:
default: 'present'
choices: ['present', 'absent']
extends_documentation_fragment:
- community.docker.docker.api_documentation
requirements:
- "Docker API >= 1.25"
author:

View File

@ -14,6 +14,18 @@ short_description: Manage Docker networks
description:
- Create/remove Docker networks and connect containers to them.
- Performs largely the same function as the C(docker network) CLI subcommand.
extends_documentation_fragment:
- community.docker.docker.api_documentation
- community.docker.attributes
- community.docker.attributes.actiongroup_docker
attributes:
check_mode:
support: full
diff_mode:
support: full
options:
name:
description:
@ -149,10 +161,6 @@ options:
- 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
extends_documentation_fragment:
- community.docker.docker.api_documentation
notes:
- When network options are changed, the module disconnects all containers from the network, deletes the network, and re-creates the network.
It does not try to reconnect containers, except the ones listed in (I(connected), and even for these, it does not consider specific

View File

@ -19,6 +19,11 @@ description:
- Essentially returns the output of C(docker network inspect <name>), similar to what M(community.docker.docker_network)
returns for a non-absent network.
extends_documentation_fragment:
- community.docker.docker.api_documentation
- community.docker.attributes
- community.docker.attributes.actiongroup_docker
- community.docker.attributes.info_module
options:
name:
@ -27,9 +32,6 @@ options:
- When identifying an existing network name may be a name or a long or short network ID.
type: str
required: true
extends_documentation_fragment:
- community.docker.docker.api_documentation
author:
- "Dave Bendit (@DBendit)"

View File

@ -15,6 +15,19 @@ short_description: Manage Docker Swarm node
description:
- Manages the Docker nodes via Swarm Manager.
- This module allows to change the node's role, its availability, and to modify, add or remove node labels.
extends_documentation_fragment:
- community.docker.docker
- community.docker.docker.docker_py_1_documentation
- community.docker.attributes
- community.docker.attributes.actiongroup_docker
attributes:
check_mode:
support: full
diff_mode:
support: none
options:
hostname:
description:
@ -69,9 +82,6 @@ options:
- manager
- worker
type: str
extends_documentation_fragment:
- community.docker.docker
- community.docker.docker.docker_py_1_documentation
requirements:
- "L(Docker SDK for Python,https://docker-py.readthedocs.io/en/stable/) >= 2.4.0"

View File

@ -19,6 +19,12 @@ description:
- Essentially returns the output of C(docker node inspect <name>).
- Must be executed on a host running as Swarm Manager, otherwise the module will fail.
extends_documentation_fragment:
- community.docker.docker
- community.docker.docker.docker_py_1_documentation
- community.docker.attributes
- community.docker.attributes.actiongroup_docker
- community.docker.attributes.info_module
options:
name:
@ -37,10 +43,6 @@ options:
- If C(false) then query depends on I(name) presence and value.
type: bool
default: false
extends_documentation_fragment:
- community.docker.docker
- community.docker.docker.docker_py_1_documentation
author:
- Piotr Wojciechowski (@WojciechowskiPiotr)

View File

@ -17,6 +17,18 @@ version_added: 1.3.0
description:
- This module allows to install, delete, enable and disable Docker plugins.
- Performs largely the same function as the C(docker plugin) CLI subcommand.
extends_documentation_fragment:
- community.docker.docker.api_documentation
- community.docker.attributes
- community.docker.attributes.actiongroup_docker
attributes:
check_mode:
support: full
diff_mode:
support: full
options:
plugin_name:
description:
@ -62,9 +74,6 @@ options:
type: int
default: 0
extends_documentation_fragment:
- community.docker.docker.api_documentation
author:
- Sakar Mehra (@sakar97)
- Vladimir Porshkevich (@porshkevich)

View File

@ -18,6 +18,16 @@ description:
- Allows to run C(docker container prune), C(docker image prune), C(docker network prune)
and C(docker volume prune) via the Docker API.
extends_documentation_fragment:
- community.docker.docker.api_documentation
- community.docker.attributes
- community.docker.attributes.actiongroup_docker
attributes:
check_mode:
support: none
diff_mode:
support: none
options:
containers:
@ -72,10 +82,6 @@ options:
type: bool
default: false
extends_documentation_fragment:
- community.docker.docker.api_documentation
author:
- "Felix Fontein (@felixfontein)"

View File

@ -14,13 +14,25 @@ module: docker_secret
short_description: Manage docker secrets.
description:
- Create and remove Docker secrets in a Swarm environment. Similar to C(docker secret create) and C(docker secret rm).
- Adds to the metadata of new secrets C(ansible_key), an encrypted hash representation of the data, which is then used
in future runs to test if a secret has changed. If C(ansible_key) is not present, then a secret will not be updated
unless the I(force) option is set.
- Updates to secrets are performed by removing the secret and creating it again.
extends_documentation_fragment:
- community.docker.docker
- community.docker.docker.docker_py_2_documentation
- community.docker.attributes
- community.docker.attributes.actiongroup_docker
attributes:
check_mode:
support: full
diff_mode:
support: none
options:
data:
description:
@ -81,11 +93,6 @@ options:
- absent
- present
extends_documentation_fragment:
- community.docker.docker
- community.docker.docker.docker_py_2_documentation
requirements:
- "L(Docker SDK for Python,https://docker-py.readthedocs.io/en/stable/) >= 2.1.0"
- "Docker API >= 1.25"

View File

@ -17,6 +17,13 @@ short_description: docker stack module
description:
- Manage docker stacks using the C(docker stack) command
on the target node (see examples).
extends_documentation_fragment:
- community.docker.attributes
attributes:
check_mode:
support: none
diff_mode:
support: none
options:
name:
description:

View File

@ -17,6 +17,9 @@ short_description: Return information on a docker stack
description:
- Retrieve information on docker stacks using the C(docker stack) command
on the target node (see examples).
extends_documentation_fragment:
- community.docker.attributes
- community.docker.attributes.info_module
'''
RETURN = '''

View File

@ -17,6 +17,9 @@ short_description: Return information of the tasks on a docker stack
description:
- Retrieve information on docker stacks tasks using the C(docker stack) command
on the target node (see examples).
extends_documentation_fragment:
- community.docker.attributes
- community.docker.attributes.info_module
options:
name:
description:

View File

@ -14,6 +14,19 @@ short_description: Manage Swarm cluster
description:
- Create a new Swarm cluster.
- Add/Remove nodes or managers to an existing cluster.
extends_documentation_fragment:
- community.docker.docker
- community.docker.docker.docker_py_1_documentation
- community.docker.attributes
- community.docker.attributes.actiongroup_docker
attributes:
check_mode:
support: full
diff_mode:
support: full
options:
advertise_addr:
description:
@ -193,9 +206,6 @@ options:
considered for idempotency checking.
type: int
version_added: 3.1.0
extends_documentation_fragment:
- community.docker.docker
- community.docker.docker.docker_py_1_documentation
requirements:
- "L(Docker SDK for Python,https://docker-py.readthedocs.io/en/stable/) >= 1.10.0"

View File

@ -23,10 +23,16 @@ description:
the docker daemon can be communicated with, whether it is in Swarm mode, and
whether it is a Swarm Manager node.
author:
- Piotr Wojciechowski (@WojciechowskiPiotr)
extends_documentation_fragment:
- community.docker.docker
- community.docker.docker.docker_py_1_documentation
- community.docker.attributes
- community.docker.attributes.actiongroup_docker
- community.docker.attributes.info_module
options:
nodes:
description:
@ -78,10 +84,6 @@ options:
for each type of the objects.
type: bool
default: false
extends_documentation_fragment:
- community.docker.docker
- community.docker.docker.docker_py_1_documentation
requirements:
- "L(Docker SDK for Python,https://docker-py.readthedocs.io/en/stable/) >= 1.10.0"

View File

@ -19,6 +19,19 @@ short_description: docker swarm service
description:
- Manages docker services via a swarm manager node.
- This modules does not support updating services in a stack.
extends_documentation_fragment:
- community.docker.docker
- community.docker.docker.docker_py_2_documentation
- community.docker.attributes
- community.docker.attributes.actiongroup_docker
attributes:
check_mode:
support: full
diff_mode:
support: full
options:
args:
description:
@ -629,9 +642,6 @@ options:
type: list
elements: str
version_added: 2.2.0
extends_documentation_fragment:
- community.docker.docker
- community.docker.docker.docker_py_2_documentation
requirements:
- "L(Docker SDK for Python,https://docker-py.readthedocs.io/en/stable/) >= 2.0.2"

View File

@ -19,6 +19,12 @@ description:
- Essentially returns the output of C(docker service inspect <name>).
- Must be executed on a host running as Swarm Manager, otherwise the module will fail.
extends_documentation_fragment:
- community.docker.docker
- community.docker.docker.docker_py_1_documentation
- community.docker.attributes
- community.docker.attributes.actiongroup_docker
- community.docker.attributes.info_module
options:
name:
@ -26,10 +32,6 @@ options:
- The name of the service to inspect.
type: str
required: true
extends_documentation_fragment:
- community.docker.docker
- community.docker.docker.docker_py_1_documentation
author:
- Hannes Ljungberg (@hannseman)

View File

@ -15,6 +15,18 @@ short_description: Manage Docker volumes
description:
- Create/remove Docker volumes.
- Performs largely the same function as the C(docker volume) CLI subcommand.
extends_documentation_fragment:
- community.docker.docker.api_documentation
- community.docker.attributes
- community.docker.attributes.actiongroup_docker
attributes:
check_mode:
support: full
diff_mode:
support: full
options:
volume_name:
description:
@ -69,10 +81,6 @@ options:
- absent
- present
extends_documentation_fragment:
- community.docker.docker.api_documentation
author:
- Alex Grönholm (@agronholm)

View File

@ -14,6 +14,13 @@ module: docker_volume_info
short_description: Retrieve facts about Docker volumes
description:
- Performs largely the same function as the C(docker volume inspect) CLI subcommand.
extends_documentation_fragment:
- community.docker.docker.api_documentation
- community.docker.attributes
- community.docker.attributes.actiongroup_docker
- community.docker.attributes.info_module
options:
name:
description:
@ -23,10 +30,6 @@ options:
aliases:
- volume_name
extends_documentation_fragment:
- community.docker.docker.api_documentation
author:
- Felix Fontein (@felixfontein)