diff --git a/plugins/modules/ipaconfig.py b/plugins/modules/ipaconfig.py index 41a6d0a877a177bd30ecc312534c51dbe66dbe1f..9b4a9625988682cab2f54f6c86d43caf990cab35 100644 --- a/plugins/modules/ipaconfig.py +++ b/plugins/modules/ipaconfig.py @@ -428,7 +428,8 @@ def main(): if params \ and not compare_args_ipa(ansible_module, params, res_show): changed = True - api_command_no_name(ansible_module, "config_mod", params) + if not ansible_module.check_mode: + api_command_no_name(ansible_module, "config_mod", params) else: rawresult = api_command_no_name(ansible_module, "config_show", {}) diff --git a/plugins/modules/ipadelegation.py b/plugins/modules/ipadelegation.py index 098bd5de4ef08b7349f53897d5bae983ef42c1e0..a5f5469940e32f0f50a4ccf433c923757b02f3bf 100644 --- a/plugins/modules/ipadelegation.py +++ b/plugins/modules/ipadelegation.py @@ -310,6 +310,10 @@ def main(): else: ansible_module.fail_json(msg="Unkown state '%s'" % state) + # Check mode exit + if ansible_module.check_mode: + ansible_module.exit_json(changed=len(commands) > 0, **exit_args) + # Execute commands for name, command, args in commands: diff --git a/plugins/modules/ipadnsconfig.py b/plugins/modules/ipadnsconfig.py index b89344dac548ef2dc7dbf621eeabc719974ec3be..a0f2bc56c0454664b165296cd23e19cba3ba67c9 100644 --- a/plugins/modules/ipadnsconfig.py +++ b/plugins/modules/ipadnsconfig.py @@ -233,7 +233,8 @@ def main(): # Execute command only if configuration changes. if not compare_args_ipa(ansible_module, args, res_find): try: - api_command_no_name(ansible_module, 'dnsconfig_mod', args) + if not ansible_module.check_mode: + api_command_no_name(ansible_module, 'dnsconfig_mod', args) # If command did not fail, something changed. changed = True diff --git a/plugins/modules/ipadnsforwardzone.py b/plugins/modules/ipadnsforwardzone.py index 69ee040fffef39cc3f694056cd8225406d5ff564..ffebc3d23ed81325c8ff37172b07413f15e7bc10 100644 --- a/plugins/modules/ipadnsforwardzone.py +++ b/plugins/modules/ipadnsforwardzone.py @@ -380,6 +380,12 @@ def main(): [name, 'dnsforwardzone_remove_permission', {}] ) + # Check mode exit + if ansible_module.check_mode: + ansible_module.exit_json(changed=len(commands) > 0, + **exit_args) + + # Execute commands for name, command, args in commands: api_command(ansible_module, command, name, args) changed = True diff --git a/plugins/modules/ipadnsrecord.py b/plugins/modules/ipadnsrecord.py index 4de8a949b920456a6d00310b802c0074c7e2eb3a..6c20c5da5f28729ed12d01ee4b25532b3fb9e1bb 100644 --- a/plugins/modules/ipadnsrecord.py +++ b/plugins/modules/ipadnsrecord.py @@ -1496,6 +1496,10 @@ def main(): if cmds: commands.extend(cmds) + # Check mode exit + if ansible_module.check_mode: + ansible_module.exit_json(changed=len(commands) > 0, **exit_args) + # Execute commands for name, command, args in commands: try: diff --git a/plugins/modules/ipagroup.py b/plugins/modules/ipagroup.py index b88f651bc6794159e8834c04bcc9fde93047ab26..e7072f08adb20b71e6a4fa0655cf3aa86fb3188d 100644 --- a/plugins/modules/ipagroup.py +++ b/plugins/modules/ipagroup.py @@ -616,6 +616,10 @@ def main(): else: ansible_module.fail_json(msg="Unkown state '%s'" % state) + # Check mode exit + if ansible_module.check_mode: + ansible_module.exit_json(changed=len(commands) > 0, **exit_args) + # Execute commands for name, command, args in commands: diff --git a/plugins/modules/ipahbacrule.py b/plugins/modules/ipahbacrule.py index 12725c7025f178c0f404bfb4459b57690b327dac..4be826932e7a04a8186b1f65c3301821b5dc7307 100644 --- a/plugins/modules/ipahbacrule.py +++ b/plugins/modules/ipahbacrule.py @@ -500,6 +500,10 @@ def main(): else: ansible_module.fail_json(msg="Unkown state '%s'" % state) + # Check mode exit + if ansible_module.check_mode: + ansible_module.exit_json(changed=len(commands) > 0, **exit_args) + # Execute commands errors = [] diff --git a/plugins/modules/ipahbacsvc.py b/plugins/modules/ipahbacsvc.py index 969a62efa7f9b06691266f48838e03312468a76c..1ead6d53d66b1cef19f69d137a5c334fb228c8fa 100644 --- a/plugins/modules/ipahbacsvc.py +++ b/plugins/modules/ipahbacsvc.py @@ -195,6 +195,10 @@ def main(): else: ansible_module.fail_json(msg="Unkown state '%s'" % state) + # Check mode exit + if ansible_module.check_mode: + ansible_module.exit_json(changed=len(commands) > 0, **exit_args) + # Execute commands for name, command, args in commands: diff --git a/plugins/modules/ipahbacsvcgroup.py b/plugins/modules/ipahbacsvcgroup.py index d55dc138ab362eae07171806137d26a21b187511..6676bca71b8b551b953e77e5c7702beb37131b5b 100644 --- a/plugins/modules/ipahbacsvcgroup.py +++ b/plugins/modules/ipahbacsvcgroup.py @@ -300,6 +300,10 @@ def main(): else: ansible_module.fail_json(msg="Unkown state '%s'" % state) + # Check mode exit + if ansible_module.check_mode: + ansible_module.exit_json(changed=len(commands) > 0, **exit_args) + # Execute commands errors = [] for name, command, args in commands: diff --git a/plugins/modules/ipahost.py b/plugins/modules/ipahost.py index ccec5d796a72895f46631a587e7372000c137695..6fc3176647a8b110ca6da25751c76e6c8a923e37 100644 --- a/plugins/modules/ipahost.py +++ b/plugins/modules/ipahost.py @@ -1347,6 +1347,10 @@ def main(): del host_set + # Check mode exit + if ansible_module.check_mode: + ansible_module.exit_json(changed=len(commands) > 0, **exit_args) + # Execute commands errors = [] diff --git a/plugins/modules/ipahostgroup.py b/plugins/modules/ipahostgroup.py index 79b92b143ba6ef1c04696f2df0884b2b5b6aa1dc..8c594353c275ed48b2c11dc8e2b54a53472115cb 100644 --- a/plugins/modules/ipahostgroup.py +++ b/plugins/modules/ipahostgroup.py @@ -463,6 +463,10 @@ def main(): else: ansible_module.fail_json(msg="Unkown state '%s'" % state) + # Check mode exit + if ansible_module.check_mode: + ansible_module.exit_json(changed=len(commands) > 0, **exit_args) + # Execute commands for name, command, args in commands: try: diff --git a/plugins/modules/ipalocation.py b/plugins/modules/ipalocation.py index a7439df465a69e12e722125277a1172d85b50eda..140662967520bae371f2de7f189e24868dcd230c 100644 --- a/plugins/modules/ipalocation.py +++ b/plugins/modules/ipalocation.py @@ -190,6 +190,10 @@ def main(): else: ansible_module.fail_json(msg="Unkown state '%s'" % state) + # Check mode exit + if ansible_module.check_mode: + ansible_module.exit_json(changed=len(commands) > 0, **exit_args) + # Execute commands for name, command, args in commands: diff --git a/plugins/modules/ipapermission.py b/plugins/modules/ipapermission.py index f613cba38e2d7a699ca5d69142ed2be971f25998..39e79d513d15a747ff4272dce6ed17ffbe040812 100644 --- a/plugins/modules/ipapermission.py +++ b/plugins/modules/ipapermission.py @@ -466,6 +466,10 @@ def main(): else: ansible_module.fail_json(msg="Unknown state '%s'" % state) + # Check mode exit + if ansible_module.check_mode: + ansible_module.exit_json(changed=len(commands) > 0, **exit_args) + # Execute commands for name, command, args in commands: diff --git a/plugins/modules/ipaprivilege.py b/plugins/modules/ipaprivilege.py index 355e2ca59b30f7f33697270e621ed979bba6b3fd..18074f585d41ba077d717a6b7c905d850d6ae066 100644 --- a/plugins/modules/ipaprivilege.py +++ b/plugins/modules/ipaprivilege.py @@ -312,6 +312,10 @@ def main(): else: ansible_module.fail_json(msg="Unkown state '%s'" % state) + # Check mode exit + if ansible_module.check_mode: + ansible_module.exit_json(changed=len(commands) > 0, **exit_args) + # Execute commands for name, command, args in commands: diff --git a/plugins/modules/ipapwpolicy.py b/plugins/modules/ipapwpolicy.py index 0d68fb1c7fde44cf841723deeac265b95c3ebd82..77fa023d90d327e80432606a278d8d3552883905 100644 --- a/plugins/modules/ipapwpolicy.py +++ b/plugins/modules/ipapwpolicy.py @@ -284,6 +284,10 @@ def main(): else: ansible_module.fail_json(msg="Unkown state '%s'" % state) + # Check mode exit + if ansible_module.check_mode: + ansible_module.exit_json(changed=len(commands) > 0, **exit_args) + # Execute commands for name, command, args in commands: diff --git a/plugins/modules/iparole.py b/plugins/modules/iparole.py index 1fbf6718e4309076e48e3c011ddadcc18966f816..a833149afc5a5f11d77cea67737a0571f0c383de 100644 --- a/plugins/modules/iparole.py +++ b/plugins/modules/iparole.py @@ -355,6 +355,11 @@ def process_commands(module, commands): errors = [] exit_args = {} changed = False + + # Check mode exit + if module.check_mode: + return len(commands) > 0, exit_args + for name, command, args in commands: try: result = api_command(module, command, name, args) diff --git a/plugins/modules/ipaselfservice.py b/plugins/modules/ipaselfservice.py index 9a900bd39fe619d728051efd095e4561b6ddff9b..801a8f54fd26fbc8808fb96cfd5f2d5fb6a071ab 100644 --- a/plugins/modules/ipaselfservice.py +++ b/plugins/modules/ipaselfservice.py @@ -293,6 +293,10 @@ def main(): else: ansible_module.fail_json(msg="Unkown state '%s'" % state) + # Check mode exit + if ansible_module.check_mode: + ansible_module.exit_json(changed=len(commands) > 0, **exit_args) + # Execute commands for name, command, args in commands: diff --git a/plugins/modules/ipaservice.py b/plugins/modules/ipaservice.py index af293513bd86e9bd79ee6b50c632afcc44f78002..a72a48e6d17bea4a351b7acd07fdfcf460e88c54 100644 --- a/plugins/modules/ipaservice.py +++ b/plugins/modules/ipaservice.py @@ -824,6 +824,10 @@ def main(): else: ansible_module.fail_json(msg="Unkown state '%s'" % state) + # Check mode exit + if ansible_module.check_mode: + ansible_module.exit_json(changed=len(commands) > 0, **exit_args) + # Execute commands errors = [] for name, command, args in commands: diff --git a/plugins/modules/ipasudocmd.py b/plugins/modules/ipasudocmd.py index 749479335e32869c00371fb9ee0e8a8a4487de24..ca484ba97798fc67d684774d22fce535b741b84b 100644 --- a/plugins/modules/ipasudocmd.py +++ b/plugins/modules/ipasudocmd.py @@ -182,6 +182,10 @@ def main(): else: ansible_module.fail_json(msg="Unkown state '%s'" % state) + # Check mode exit + if ansible_module.check_mode: + ansible_module.exit_json(changed=len(commands) > 0, **exit_args) + # Execute commands for name, command, args in commands: try: diff --git a/plugins/modules/ipasudocmdgroup.py b/plugins/modules/ipasudocmdgroup.py index f1204fdb2ed08f1a491021a5bc3ac5a41f6ac836..c4d8830e63595f078df70318f794c349fb0e53b5 100644 --- a/plugins/modules/ipasudocmdgroup.py +++ b/plugins/modules/ipasudocmdgroup.py @@ -298,6 +298,10 @@ def main(): else: ansible_module.fail_json(msg="Unkown state '%s'" % state) + # Check mode exit + if ansible_module.check_mode: + ansible_module.exit_json(changed=len(commands) > 0, **exit_args) + # Execute commands for name, command, args in commands: try: diff --git a/plugins/modules/ipasudorule.py b/plugins/modules/ipasudorule.py index 354b9e483678f3fa48bcf66903cef1fa39c28aa3..171ec9abc77cbdd869402fc977224ce21a2882ab 100644 --- a/plugins/modules/ipasudorule.py +++ b/plugins/modules/ipasudorule.py @@ -686,6 +686,10 @@ def main(): else: ansible_module.fail_json(msg="Unkown state '%s'" % state) + # Check mode exit + if ansible_module.check_mode: + ansible_module.exit_json(changed=len(commands) > 0, **exit_args) + # Execute commands errors = [] diff --git a/plugins/modules/ipatopologysegment.py b/plugins/modules/ipatopologysegment.py index 5b63e8b1673022305c8d542bc1df04511a2e07db..4d522bdafb0b784ab0e831a5c0e3ab9b08c1225c 100644 --- a/plugins/modules/ipatopologysegment.py +++ b/plugins/modules/ipatopologysegment.py @@ -326,6 +326,10 @@ def main(): else: ansible_module.fail_json(msg="Unkown state '%s'" % state) + # Check mode exit + if ansible_module.check_mode: + ansible_module.exit_json(changed=len(commands) > 0, **exit_args) + # Execute command for command, args, _suffix in commands: diff --git a/plugins/modules/ipatrust.py b/plugins/modules/ipatrust.py index 4dc144fd8f43f91c623cc80e21a7f101d5463c99..c48dcb410569d41e5c46ab32da1b77b66b993a2a 100644 --- a/plugins/modules/ipatrust.py +++ b/plugins/modules/ipatrust.py @@ -244,7 +244,8 @@ def main(): if state == "absent": if res_find is not None: - del_trust(ansible_module, realm) + if not ansible_module.check_mode: + del_trust(ansible_module, realm) changed = True elif res_find is None: if admin is None and trust_secret is None: @@ -256,7 +257,8 @@ def main(): trust_secret, base_id, range_size, range_type, two_way, external) - add_trust(ansible_module, realm, args) + if not ansible_module.check_mode: + add_trust(ansible_module, realm, args) changed = True except Exception as e: diff --git a/plugins/modules/ipauser.py b/plugins/modules/ipauser.py index c5f0afdb54bef6a4c8975ba4c7284f59a6625cc1..52463abb6f02abe366d8416c1a52545c7f89dab1 100644 --- a/plugins/modules/ipauser.py +++ b/plugins/modules/ipauser.py @@ -1377,6 +1377,10 @@ def main(): del user_set + # Check mode exit + if ansible_module.check_mode: + ansible_module.exit_json(changed=len(commands) > 0, **exit_args) + # Execute commands errors = [] diff --git a/plugins/modules/ipavault.py b/plugins/modules/ipavault.py index f1d6825680c03e50d3e1d5bc4d975d475fb89048..9d2e1be533b30bb2377c655dd3503b4a63b6ef79 100644 --- a/plugins/modules/ipavault.py +++ b/plugins/modules/ipavault.py @@ -910,6 +910,10 @@ def main(): else: ansible_module.fail_json(msg="Unknown state '%s'" % state) + # Check mode exit + if ansible_module.check_mode: + ansible_module.exit_json(changed=len(commands) > 0, **exit_args) + # Execute commands errors = [] diff --git a/utils/templates/ipamodule+member.py.in b/utils/templates/ipamodule+member.py.in index 781973511cc8c89adf6c572440603ac81c308c09..bd63739897c59c63df7ba4e46042b884274e2395 100644 --- a/utils/templates/ipamodule+member.py.in +++ b/utils/templates/ipamodule+member.py.in @@ -286,6 +286,10 @@ def main(): else: ansible_module.fail_json(msg="Unkown state '%s'" % state) + # Check mode exit + if ansible_module.check_mode: + ansible_module.exit_json(changed=len(commands) > 0, **exit_args) + # Execute commands for name, command, args in commands: diff --git a/utils/templates/ipamodule.py.in b/utils/templates/ipamodule.py.in index 24243a2f41c7020b4e8c0a8484854ee6bdd086d2..233c5985ca93198c60828f1a9d34e18c8885b47b 100644 --- a/utils/templates/ipamodule.py.in +++ b/utils/templates/ipamodule.py.in @@ -207,6 +207,10 @@ def main(): else: ansible_module.fail_json(msg="Unkown state '%s'" % state) + # Check mode exit + if ansible_module.check_mode: + ansible_module.exit_json(changed=len(commands) > 0, **exit_args) + # Execute commands for name, command, args in commands: