diff --git a/plugins/module_utils/ansible_freeipa_module.py b/plugins/module_utils/ansible_freeipa_module.py index 4799e5a44abfb0e2a61c1fe5df2851a8b3b3d4b4..30302b4ffd85676ae32ad7193331e8d6fb5f9e51 100644 --- a/plugins/module_utils/ansible_freeipa_module.py +++ b/plugins/module_utils/ansible_freeipa_module.py @@ -619,7 +619,7 @@ class FreeIPABaseModule(AnsibleModule): if exc_val: self.fail_json(msg=str(exc_val)) - self.exit_json(changed=self.changed, user=self.exit_args) + self.exit_json(changed=self.changed, **self.exit_args) def get_command_errors(self, command, result): """Look for erros into command results.""" @@ -658,14 +658,22 @@ class FreeIPABaseModule(AnsibleModule): except Exception as excpt: self.fail_json(msg="%s: %s: %s" % (command, name, str(excpt))) else: - if "completed" in result: - if result["completed"] > 0: - self.changed = True - else: - self.changed = True - + self.process_command_result(name, command, args, result) self.get_command_errors(command, result) + def process_command_result(self, name, command, args, result): + """ + Process an API command result. + + This method can be overriden in subclasses, and change self.exit_values + to return data in the result for the controller. + """ + if "completed" in result: + if result["completed"] > 0: + self.changed = True + else: + self.changed = True + def require_ipa_attrs_change(self, command_args, ipa_attrs): """ Compare given args with current object attributes. diff --git a/plugins/modules/ipadnszone.py b/plugins/modules/ipadnszone.py index 901bfefd51e7901cd851b312fe5e838033b9f7c4..6a90fa2b2c80a2ca713efbb5503d209bc447867c 100644 --- a/plugins/modules/ipadnszone.py +++ b/plugins/modules/ipadnszone.py @@ -472,6 +472,14 @@ class DNSZoneModule(FreeIPABaseModule): } self.add_ipa_command("dnszone_mod", zone_name, args) + def process_command_result(self, name, command, args, result): + super(DNSZoneModule, self).process_command_result( + name, command, args, result + ) + if command == "dnszone_add" and self.ipa_params.name_from_ip: + dnszone_exit_args = self.exit_args.setdefault('dnszone', {}) + dnszone_exit_args['name'] = name + def get_argument_spec(): forwarder_spec = dict(