Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'idempotent' attribute #1022

Merged
merged 2 commits into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions plugins/doc_fragments/attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,20 @@ class ModuleDocFragment(object):
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.
idempotent:
description:
- When run twice in a row outside check mode, with the same arguments, the second invocation indicates no change.
- This assumes that the system controlled/queried by the module has not changed in a relevant way.
"""

# Should be used together with the standard fragment
IDEMPOTENT_NOT_MODIFY_STATE = r"""
options: {}
attributes:
idempotent:
support: full
details:
- This action does not modify state.
"""

# Should be used together with the standard fragment
Expand Down
1 change: 1 addition & 0 deletions plugins/modules/current_container_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
- community.docker.attributes
- community.docker.attributes.facts
- community.docker.attributes.facts_module
- community.docker.attributes.idempotent_not_modify_state
"""

EXAMPLES = r"""
Expand Down
4 changes: 4 additions & 0 deletions plugins/modules/docker_compose_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
- In check mode, pulling the image does not result in a changed result.
diff_mode:
support: none
idempotent:
support: partial
details:
- If O(state=restarted) or O(recreate=always) the module is not idempotent.

options:
state:
Expand Down
4 changes: 4 additions & 0 deletions plugins/modules/docker_compose_v2_exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
support: none
diff_mode:
support: none
idempotent:
support: N/A
details:
- Whether the executed command is idempotent depends on the command.

options:
service:
Expand Down
2 changes: 2 additions & 0 deletions plugins/modules/docker_compose_v2_pull.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
pulling would update the image or not.
diff_mode:
support: none
idempotent:
support: full

options:
policy:
Expand Down
4 changes: 4 additions & 0 deletions plugins/modules/docker_compose_v2_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
support: none
diff_mode:
support: none
idempotent:
support: N/A
details:
- Whether the executed command is idempotent depends on the command.

options:
service:
Expand Down
8 changes: 6 additions & 2 deletions plugins/modules/docker_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

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
- Adds to the metadata of new configs C(ansible_key), an encrypted hash representation of the data, which is then used in
future runs to test if a config has changed. If C(ansible_key) is not present, then a config will not be updated unless
the O(force) option is set.
- Updates to configs are performed by removing the config and creating it again.
extends_documentation_fragment:
Expand All @@ -30,6 +30,10 @@
support: full
diff_mode:
support: none
idempotent:
support: partial
details:
- If O(force=true) the module is not idempotent.

options:
data:
Expand Down
4 changes: 4 additions & 0 deletions plugins/modules/docker_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
- This behavior can be configured with O(pull_check_mode_behavior).
diff_mode:
support: full
idempotent:
support: partial
details:
- If O(recreate=true) or O(restart=true) the module is not idempotent.

options:
auto_remove:
Expand Down
4 changes: 4 additions & 0 deletions plugins/modules/docker_container_copy_into.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
- Additional data will need to be transferred to compute diffs.
- The module uses R(the MAX_FILE_SIZE_FOR_DIFF ansible-core configuration,MAX_FILE_SIZE_FOR_DIFF) to determine for how
large files diffs should be computed.
idempotent:
support: partial
details:
- If O(force=true) the module is not idempotent.

options:
container:
Expand Down
4 changes: 4 additions & 0 deletions plugins/modules/docker_container_exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
support: none
diff_mode:
support: none
idempotent:
support: N/A
details:
- Whether the executed command is idempotent depends on the command.

options:
container:
Expand Down
1 change: 1 addition & 0 deletions plugins/modules/docker_container_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
- community.docker.attributes
- community.docker.attributes.actiongroup_docker
- community.docker.attributes.info_module
- community.docker.attributes.idempotent_not_modify_state

options:
name:
Expand Down
1 change: 1 addition & 0 deletions plugins/modules/docker_host_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
- community.docker.docker.api_documentation
- community.docker.attributes
- community.docker.attributes.actiongroup_docker
- community.docker.attributes.idempotent_not_modify_state

attributes:
check_mode:
Expand Down
8 changes: 8 additions & 0 deletions plugins/modules/docker_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
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.
- We recommend to use the individual modules M(community.docker.docker_image_build), M(community.docker.docker_image_export),
M(community.docker.docker_image_load), M(community.docker.docker_image_pull), M(community.docker.docker_image_push),
M(community.docker.docker_image_remove), and M(community.docker.docker_image_tag) instead of this module.
notes:
- Building images is done using Docker daemon's API. It is not possible to use BuildKit / buildx this way. Use M(community.docker.docker_image_build)
to build images with BuildKit.
Expand All @@ -31,6 +34,11 @@
- When trying to pull an image, the module assumes this is always changed in check mode.
diff_mode:
support: none
idempotent:
support: partial
details:
- Whether the module is idempotent depends on the exact parameters, in particular of O(force_source) and O(force_tag).
# TODO: improve idempotent details!

options:
source:
Expand Down
4 changes: 4 additions & 0 deletions plugins/modules/docker_image_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
support: full
diff_mode:
support: none
idempotent:
support: partial
details:
- If O(rebuild=always) the module is not idempotent.

options:
name:
Expand Down
2 changes: 2 additions & 0 deletions plugins/modules/docker_image_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
support: full
diff_mode:
support: none
idempotent:
support: full

options:
names:
Expand Down
1 change: 1 addition & 0 deletions plugins/modules/docker_image_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
- community.docker.attributes
- community.docker.attributes.actiongroup_docker
- community.docker.attributes.info_module
- community.docker.attributes.idempotent_not_modify_state

options:
name:
Expand Down
2 changes: 2 additions & 0 deletions plugins/modules/docker_image_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
support: none
diff_mode:
support: none
idempotent:
support: none

options:
path:
Expand Down
2 changes: 2 additions & 0 deletions plugins/modules/docker_image_pull.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
- When check mode is combined with diff mode, the pulled image's ID is always shown as V(unknown) in the diff.
diff_mode:
support: full
idempotent:
support: full

options:
name:
Expand Down
2 changes: 2 additions & 0 deletions plugins/modules/docker_image_push.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
support: none
diff_mode:
support: none
idempotent:
support: full

options:
name:
Expand Down
2 changes: 2 additions & 0 deletions plugins/modules/docker_image_remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
support: full
diff_mode:
support: full
idempotent:
support: full

options:
name:
Expand Down
2 changes: 2 additions & 0 deletions plugins/modules/docker_image_tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
support: full
diff_mode:
support: full
idempotent:
support: full

options:
name:
Expand Down
5 changes: 3 additions & 2 deletions plugins/modules/docker_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
support: full
diff_mode:
support: none
idempotent:
support: full

options:
registry_url:
Expand Down Expand Up @@ -280,8 +282,7 @@ def _login(self, reauth):
authcfg = self.client._auth_configs.resolve_authconfig(self.registry_url)
# If we found an existing auth config for this registry and username
# combination, we can return it immediately unless reauth is requested.
if authcfg and authcfg.get('username', None) == self.username \
and not reauth:
if authcfg and authcfg.get('username') == self.username and not reauth:
return authcfg

req_data = {
Expand Down
4 changes: 4 additions & 0 deletions plugins/modules/docker_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
support: full
diff_mode:
support: full
idempotent:
support: partial
details:
- If O(force=true) the module is not idempotent.

options:
name:
Expand Down
1 change: 1 addition & 0 deletions plugins/modules/docker_network_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
- community.docker.attributes
- community.docker.attributes.actiongroup_docker
- community.docker.attributes.info_module
- community.docker.attributes.idempotent_not_modify_state

options:
name:
Expand Down
2 changes: 2 additions & 0 deletions plugins/modules/docker_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
support: full
diff_mode:
support: none
idempotent:
support: full

options:
hostname:
Expand Down
1 change: 1 addition & 0 deletions plugins/modules/docker_node_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
- community.docker.attributes
- community.docker.attributes.actiongroup_docker
- community.docker.attributes.info_module
- community.docker.attributes.idempotent_not_modify_state

options:
name:
Expand Down
2 changes: 2 additions & 0 deletions plugins/modules/docker_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
support: full
diff_mode:
support: full
idempotent:
support: full

options:
plugin_name:
Expand Down
2 changes: 2 additions & 0 deletions plugins/modules/docker_prune.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
support: none
diff_mode:
support: none
idempotent:
support: full

options:
containers:
Expand Down
4 changes: 4 additions & 0 deletions plugins/modules/docker_secret.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
support: full
diff_mode:
support: none
idempotent:
support: partial
details:
- If O(force=true) the module is not idempotent.

options:
data:
Expand Down
2 changes: 2 additions & 0 deletions plugins/modules/docker_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
support: none
action_group:
version_added: 3.6.0
idempotent:
support: full
options:
name:
description:
Expand Down
1 change: 1 addition & 0 deletions plugins/modules/docker_stack_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
- community.docker.attributes
- community.docker.attributes.actiongroup_docker
- community.docker.attributes.info_module
- community.docker.attributes.idempotent_not_modify_state
attributes:
action_group:
version_added: 3.6.0
Expand Down
1 change: 1 addition & 0 deletions plugins/modules/docker_stack_task_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
- community.docker.attributes
- community.docker.attributes.actiongroup_docker
- community.docker.attributes.info_module
- community.docker.attributes.idempotent_not_modify_state
attributes:
action_group:
version_added: 3.6.0
Expand Down
2 changes: 2 additions & 0 deletions plugins/modules/docker_swarm.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
support: full
diff_mode:
support: full
idempotent:
support: full

options:
advertise_addr:
Expand Down
1 change: 1 addition & 0 deletions plugins/modules/docker_swarm_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
- community.docker.attributes
- community.docker.attributes.actiongroup_docker
- community.docker.attributes.info_module
- community.docker.attributes.idempotent_not_modify_state

options:
nodes:
Expand Down
2 changes: 2 additions & 0 deletions plugins/modules/docker_swarm_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
support: full
diff_mode:
support: full
idempotent:
support: full

options:
args:
Expand Down
1 change: 1 addition & 0 deletions plugins/modules/docker_swarm_service_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
- community.docker.attributes
- community.docker.attributes.actiongroup_docker
- community.docker.attributes.info_module
- community.docker.attributes.idempotent_not_modify_state

options:
name:
Expand Down
4 changes: 4 additions & 0 deletions plugins/modules/docker_volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
support: full
diff_mode:
support: full
idempotent:
support: partial
details:
- If O(recreate=always) the module is not idempotent.

options:
volume_name:
Expand Down
1 change: 1 addition & 0 deletions plugins/modules/docker_volume_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
- community.docker.attributes
- community.docker.attributes.actiongroup_docker
- community.docker.attributes.info_module
- community.docker.attributes.idempotent_not_modify_state

options:
name:
Expand Down
Loading