diff --git a/plugins/module_utils/ansible_freeipa_module.py b/plugins/module_utils/ansible_freeipa_module.py index b5716277cc8e553596af411694115dd0d2ad8d26..45e956d08c6c5d89f5c2f08c93d4e94154cefb2c 100644 --- a/plugins/module_utils/ansible_freeipa_module.py +++ b/plugins/module_utils/ansible_freeipa_module.py @@ -962,6 +962,10 @@ else: def _run_ipa_commands(self): """Execute commands in self.ipa_commands.""" + if self.check_mode: + self.changed = len(self.ipa_commands) > 0 + return + result = None for name, command, args in self.ipa_commands: diff --git a/plugins/modules/ipadnszone.py b/plugins/modules/ipadnszone.py index c540c0111a9a30ded053c16da219e9d85f8315f7..39622f1712f8228567c4f40e235a8c9e409aab0f 100644 --- a/plugins/modules/ipadnszone.py +++ b/plugins/modules/ipadnszone.py @@ -537,6 +537,7 @@ def main(): argument_spec=get_argument_spec(), mutually_exclusive=[["name", "name_from_ip"]], required_one_of=[["name", "name_from_ip"]], + supports_check_mode=True, ).ipa_run() diff --git a/tests/dnszone/test_dnszone.yml b/tests/dnszone/test_dnszone.yml index d7860aae77b9c51b13732a1665463ab5558a5732..39f9cf38296c90d780feaa540232a870ae5668a6 100644 --- a/tests/dnszone/test_dnszone.yml +++ b/tests/dnszone/test_dnszone.yml @@ -11,6 +11,24 @@ include_tasks: env_setup.yml # Tests + - name: Check if zone is present, when in shouldn't be. + ipadnszone: + ipaadmin_password: SomeADMINpassword + name: testzone.local + state: present + check_mode: yes + register: result + failed_when: not result.changed or result.failed + + - name: Check if zone is present again, when in shouldn't be. + ipadnszone: + ipaadmin_password: SomeADMINpassword + name: testzone.local + state: present + check_mode: yes + register: result + failed_when: not result.changed or result.failed + - name: Ensure zone is present. ipadnszone: ipaadmin_password: SomeADMINpassword @@ -19,6 +37,15 @@ register: result failed_when: not result.changed or result.failed + - name: Check if zone is present, when in should be. + ipadnszone: + ipaadmin_password: SomeADMINpassword + name: testzone.local + state: present + check_mode: yes + register: result + failed_when: result.changed or result.failed + - name: Ensure zone is present, again. ipadnszone: ipaadmin_password: SomeADMINpassword