Skip to content

Commit

Permalink
Add 'idempotent' attribute (#217)
Browse files Browse the repository at this point in the history
* Add 'idempotent' attribute.

* Add attributes to install role.

* Mention check mode in attribute description.

Co-authored-by: Alexei Znamensky <[email protected]>

---------

Co-authored-by: Alexei Znamensky <[email protected]>
  • Loading branch information
felixfontein and russoz authored Dec 30, 2024
1 parent 9f2e345 commit d7d823b
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 0 deletions.
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
4 changes: 4 additions & 0 deletions plugins/modules/load_vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@
- This action does not modify state.
facts:
support: full
idempotent:
support: N/A
details:
- The action has no C(changed) state.
seealso:
- module: ansible.builtin.set_fact
- module: ansible.builtin.include_vars
Expand Down
2 changes: 2 additions & 0 deletions plugins/modules/sops_encrypt.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@
support: none
safe_file_operations:
support: full
idempotent:
support: full
seealso:
- plugin: community.sops.sops
plugin_type: lookup
Expand Down
31 changes: 31 additions & 0 deletions roles/install/meta/argument_specs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,34 @@ argument_specs:
- Should mainly be used in GitHub Actions.
type: str
version_added: 1.6.0
attributes:
check_mode:
description: Can run in C(check_mode) and return changed status prediction without modifying target.
support: none
details:
- The role currently does not work in check mode.
# TODO: add 'check_mode: false' to tasks that prepare something
diff_mode:
description: Will return details on what has changed (or possibly needs changing in C(check_mode)), when in diff mode.
support: partial
details:
- The role supports diff mode if the M(ansible.builtin.package) action for the system supports it.
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.
support: partial
details:
- The role is idempotent if the M(ansible.builtin.package) action for the system is idempotent.
- This is usually the case, but if packages need to be installed from GitHub (that is, through an URL), idempotence might not hold.
platform:
description: Target OS/families that can be operated against.
support: full
platforms:
- Alpine (new enough)
- Arch Linux
- CentOS 7, Stream 8, or newer
- Debian 10 (Buster) or newer
- Fedora (new enough)
- RHEL 7 or newer
- Ubuntu 16.04 or newer LTS versions

0 comments on commit d7d823b

Please sign in to comment.