From 744855c595468e28204bf2e6e308cc08de7e15b5 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Mon, 30 Dec 2024 18:00:09 +0100 Subject: [PATCH 1/2] Add 'idempotent' attribute. --- plugins/doc_fragments/attributes.py | 14 ++++++++++++++ plugins/modules/boot.py | 2 ++ plugins/modules/failover_ip.py | 2 ++ plugins/modules/failover_ip_info.py | 1 + plugins/modules/firewall.py | 2 ++ plugins/modules/firewall_info.py | 1 + plugins/modules/reset.py | 4 ++++ plugins/modules/reverse_dns.py | 2 ++ plugins/modules/server.py | 2 ++ plugins/modules/server_info.py | 1 + plugins/modules/ssh_key.py | 2 ++ plugins/modules/ssh_key_info.py | 1 + plugins/modules/v_switch.py | 2 ++ 13 files changed, 36 insertions(+) diff --git a/plugins/doc_fragments/attributes.py b/plugins/doc_fragments/attributes.py index 3b084d8..47da577 100644 --- a/plugins/doc_fragments/attributes.py +++ b/plugins/doc_fragments/attributes.py @@ -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 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 diff --git a/plugins/modules/boot.py b/plugins/modules/boot.py index dcc54a5..779ce8b 100644 --- a/plugins/modules/boot.py +++ b/plugins/modules/boot.py @@ -34,6 +34,8 @@ support: full diff_mode: support: none + idempotent: + support: full options: server_number: diff --git a/plugins/modules/failover_ip.py b/plugins/modules/failover_ip.py index e422423..996c7ce 100644 --- a/plugins/modules/failover_ip.py +++ b/plugins/modules/failover_ip.py @@ -34,6 +34,8 @@ support: full diff_mode: support: full + idempotent: + support: full options: failover_ip: diff --git a/plugins/modules/failover_ip_info.py b/plugins/modules/failover_ip_info.py index 817e51d..2620b49 100644 --- a/plugins/modules/failover_ip_info.py +++ b/plugins/modules/failover_ip_info.py @@ -26,6 +26,7 @@ - community.hrobot.robot - community.hrobot.attributes - community.hrobot.attributes.actiongroup_robot + - community.hrobot.attributes.idempotent_not_modify_state - community.hrobot.attributes.info_module attributes: diff --git a/plugins/modules/firewall.py b/plugins/modules/firewall.py index 0bc637b..cc66e1f 100644 --- a/plugins/modules/firewall.py +++ b/plugins/modules/firewall.py @@ -38,6 +38,8 @@ support: full diff_mode: support: full + idempotent: + support: full options: server_ip: diff --git a/plugins/modules/firewall_info.py b/plugins/modules/firewall_info.py index eddb50a..463a17e 100644 --- a/plugins/modules/firewall_info.py +++ b/plugins/modules/firewall_info.py @@ -26,6 +26,7 @@ - community.hrobot.robot - community.hrobot.attributes - community.hrobot.attributes.actiongroup_robot + - community.hrobot.attributes.idempotent_not_modify_state - community.hrobot.attributes.info_module attributes: diff --git a/plugins/modules/reset.py b/plugins/modules/reset.py index 9c2439a..05f01ed 100644 --- a/plugins/modules/reset.py +++ b/plugins/modules/reset.py @@ -29,6 +29,10 @@ support: full diff_mode: support: none + idempotent: + support: none + details: + - This module performs an action on every invocation. options: server_number: diff --git a/plugins/modules/reverse_dns.py b/plugins/modules/reverse_dns.py index 14cc695..bfecdb2 100644 --- a/plugins/modules/reverse_dns.py +++ b/plugins/modules/reverse_dns.py @@ -32,6 +32,8 @@ support: full diff_mode: support: none + idempotent: + support: full options: ip: diff --git a/plugins/modules/server.py b/plugins/modules/server.py index 3eb6f77..6ada7d9 100644 --- a/plugins/modules/server.py +++ b/plugins/modules/server.py @@ -30,6 +30,8 @@ support: full diff_mode: support: none + idempotent: + support: full options: server_number: diff --git a/plugins/modules/server_info.py b/plugins/modules/server_info.py index ce2fcba..a1a49ce 100644 --- a/plugins/modules/server_info.py +++ b/plugins/modules/server_info.py @@ -21,6 +21,7 @@ - community.hrobot.robot - community.hrobot.attributes - community.hrobot.attributes.actiongroup_robot + - community.hrobot.attributes.idempotent_not_modify_state - community.hrobot.attributes.info_module attributes: diff --git a/plugins/modules/ssh_key.py b/plugins/modules/ssh_key.py index 1767a90..e2e8bd8 100644 --- a/plugins/modules/ssh_key.py +++ b/plugins/modules/ssh_key.py @@ -32,6 +32,8 @@ support: full diff_mode: support: none + idempotent: + support: full options: state: diff --git a/plugins/modules/ssh_key_info.py b/plugins/modules/ssh_key_info.py index 2baf20b..a7972ef 100644 --- a/plugins/modules/ssh_key_info.py +++ b/plugins/modules/ssh_key_info.py @@ -24,6 +24,7 @@ - community.hrobot.robot - community.hrobot.attributes - community.hrobot.attributes.actiongroup_robot + - community.hrobot.attributes.idempotent_not_modify_state - community.hrobot.attributes.info_module attributes: action_group: diff --git a/plugins/modules/v_switch.py b/plugins/modules/v_switch.py index eb68e09..6e87531 100644 --- a/plugins/modules/v_switch.py +++ b/plugins/modules/v_switch.py @@ -32,6 +32,8 @@ support: full diff_mode: support: none + idempotent: + support: full options: vlan: From 1867ddbe293578e5474a851eb4a5e09a37de2d8c Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Mon, 30 Dec 2024 20:06:54 +0100 Subject: [PATCH 2/2] Mention check mode in attribute description. Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> --- plugins/doc_fragments/attributes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/doc_fragments/attributes.py b/plugins/doc_fragments/attributes.py index 47da577..44b76d1 100644 --- a/plugins/doc_fragments/attributes.py +++ b/plugins/doc_fragments/attributes.py @@ -20,7 +20,7 @@ class ModuleDocFragment(object): 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 with the same arguments, the second invocation indicates no change. + - 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. """