From cedc012e3084981e382bea7f1d59214576f78bd3 Mon Sep 17 00:00:00 2001 From: Wojciech Wypior Date: Thu, 22 Aug 2019 17:27:58 +0100 Subject: [PATCH] adds diff functionality to the module (#61074) --- .../modules/network/f5/bigip_device_ntp.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/ansible/modules/network/f5/bigip_device_ntp.py b/lib/ansible/modules/network/f5/bigip_device_ntp.py index 7dfd84fbcf0..1414f5bc26a 100644 --- a/lib/ansible/modules/network/f5/bigip_device_ntp.py +++ b/lib/ansible/modules/network/f5/bigip_device_ntp.py @@ -268,8 +268,25 @@ class ModuleManager(object): reportable = ReportableChanges(params=self.changes.to_return()) changes = reportable.to_return() result.update(**changes) + + if self.module._diff and self.have: + result['diff'] = self.make_diff() + result.update(dict(changed=changed)) self._announce_deprecations(result) + + return result + + def _grab_attr(self, item): + result = dict() + updatables = Parameters.updatables + for k in updatables: + if getattr(item, k) is not None: + result[k] = getattr(item, k) + return result + + def make_diff(self): + result = dict(before=self._grab_attr(self.have), after=self._grab_attr(self.want)) return result def update(self):