From 0055360315f61c26abee9bce2e4616d0fb7dbcee Mon Sep 17 00:00:00 2001 From: Tim Rupp Date: Tue, 25 Oct 2016 04:50:42 -0700 Subject: [PATCH] Make irules module idempotent (#3175) The irules module was failing to strip whitespace that is, for some reason, automatically inserted by BIG-IP. This patch adds necessary strips --- .../modules/extras/network/f5/bigip_irule.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/lib/ansible/modules/extras/network/f5/bigip_irule.py b/lib/ansible/modules/extras/network/f5/bigip_irule.py index 4a7ff4d951f..f2be61dfd89 100644 --- a/lib/ansible/modules/extras/network/f5/bigip_irule.py +++ b/lib/ansible/modules/extras/network/f5/bigip_irule.py @@ -202,7 +202,7 @@ class BigIpiRule(object): ) if hasattr(r, 'apiAnonymous'): - p['content'] = str(r.apiAnonymous) + p['content'] = str(r.apiAnonymous.strip()) p['name'] = name return p @@ -246,14 +246,10 @@ class BigIpiRule(object): ) def present(self): - changed = False - if self.exists(): - changed = self.update() + return self.update() else: - changed = self.create() - - return changed + return self.create() def update(self): params = dict() @@ -267,6 +263,7 @@ class BigIpiRule(object): module = self.params['module'] if content is not None: + content = content.strip() if 'content' in current: if content != current['content']: params['apiAnonymous'] = content @@ -318,7 +315,7 @@ class BigIpiRule(object): return True if content is not None: - params['apiAnonymous'] = content + params['apiAnonymous'] = content.strip() params['name'] = name params['partition'] = partition