From adc0d2cd8367064a7a61759908de2c52933cac81 Mon Sep 17 00:00:00 2001 From: Wojciech Wypior Date: Thu, 11 Apr 2019 21:51:16 +0200 Subject: [PATCH] fixes an edge case where order of devices parameters breaks idempotency (#55181) code correction for aggregates in bigip_gtm_pool_member and bigip_pool to be in line with established patterns --- .../modules/network/f5/bigip_gtm_pool_member.py | 5 ++--- lib/ansible/modules/network/f5/bigip_gtm_server.py | 12 ++++++++++++ lib/ansible/modules/network/f5/bigip_pool.py | 6 +++--- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/lib/ansible/modules/network/f5/bigip_gtm_pool_member.py b/lib/ansible/modules/network/f5/bigip_gtm_pool_member.py index 159d516fb83..2246fad19eb 100644 --- a/lib/ansible/modules/network/f5/bigip_gtm_pool_member.py +++ b/lib/ansible/modules/network/f5/bigip_gtm_pool_member.py @@ -606,9 +606,8 @@ class ModuleManager(object): self.want = None self.have = None self.changes = None - self.replace_all_with = False + self.replace_all_with = None self.purge_links = list() - self.on_device = None def _set_changed_options(self): changed = {} @@ -711,7 +710,7 @@ class ModuleManager(object): if diff: to_purge = [item['selfLink'] for item in on_device if self._transform_api_names(item) in diff] - self.purge_links = to_purge + self.purge_links.extend(to_purge) def execute(self, params=None): self.want = ModuleParameters(params=params) diff --git a/lib/ansible/modules/network/f5/bigip_gtm_server.py b/lib/ansible/modules/network/f5/bigip_gtm_server.py index 5715d62f30d..6b6199870f2 100644 --- a/lib/ansible/modules/network/f5/bigip_gtm_server.py +++ b/lib/ansible/modules/network/f5/bigip_gtm_server.py @@ -1157,10 +1157,22 @@ class Difference(object): ) want = [OrderedDict(sorted(d.items())) for d in devices] have = [OrderedDict(sorted(d.items())) for d in have_devices] + if len(have_devices) > 0: + if self._false_positive(devices, have_devices): + return False if want != have: return True return False + def _false_positive(self, devices, have_devices): + match = 0 + for w in devices: + for h in have_devices: + if w.items() == h.items(): + match = match + 1 + if match == len(devices): + return True + def _server_type_changed(self): if self.want.server_type is None: self.want.update({'server_type': self.have.server_type}) diff --git a/lib/ansible/modules/network/f5/bigip_pool.py b/lib/ansible/modules/network/f5/bigip_pool.py index 55033198f3a..5197e9c940e 100644 --- a/lib/ansible/modules/network/f5/bigip_pool.py +++ b/lib/ansible/modules/network/f5/bigip_pool.py @@ -814,8 +814,8 @@ class ModuleManager(object): self.want = None self.have = None self.changes = None - self.replace_all_with = False - self.purge_links = None + self.replace_all_with = None + self.purge_links = list() def exec_module(self): wants = None @@ -874,7 +874,7 @@ class ModuleManager(object): if diff: to_purge = [item['selfLink'] for item in on_device if item['name'] in diff] - self.purge_links = to_purge + self.purge_links.extend(to_purge) def execute(self, params=None): self.want = ModuleParameters(params=params)