diff options
author | Tim Rupp <caphrim007@gmail.com> | 2018-05-18 11:58:42 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-18 11:58:42 -0700 |
commit | 1492414165e18c7b5d73cb0540e2c01542544a77 (patch) | |
tree | ad8c5240e5fa16b57a994c52e1cbf4c137715db7 | |
parent | 47173cc8b1153e27fd00928a2d34b667a05e44cf (diff) | |
download | ansible-1492414165e18c7b5d73cb0540e2c01542544a77.tar.gz |
Fixes password missing in bigip_device_trust (#40414)
The documentation did not match the code. This patch fixes the code
to correctly fallback the peer password if necessary
-rw-r--r-- | lib/ansible/modules/network/f5/bigip_device_trust.py | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/lib/ansible/modules/network/f5/bigip_device_trust.py b/lib/ansible/modules/network/f5/bigip_device_trust.py index 2b6e24c85f..d87862e29e 100644 --- a/lib/ansible/modules/network/f5/bigip_device_trust.py +++ b/lib/ansible/modules/network/f5/bigip_device_trust.py @@ -30,8 +30,9 @@ options: peer_hostname: description: - The hostname that you want to associate with the device. This value will - be used to easily distinguish this device in BIG-IP configuration. If not - specified, the value of C(peer_server) will be used as a default. + be used to easily distinguish this device in BIG-IP configuration. + - When trusting a new device, if this parameter is not specified, the value + of C(peer_server) will be used as a default. peer_user: description: - The API username of the remote peer device that you are trusting. Note @@ -227,6 +228,22 @@ class ModuleManager(object): result.update(dict(changed=changed)) return result + def provided_password(self): + if self.want.password: + return self.password + if self.want.provider.get('password', None): + return self.provider.get('password') + if self.module.params.get('password', None): + return self.module.params.get('password') + + def provided_username(self): + if self.want.username: + return self.username + if self.want.provider.get('user', None): + return self.provider.get('user') + if self.module.params.get('user', None): + return self.module.params.get('user') + def present(self): if self.exists(): return False @@ -236,11 +253,11 @@ class ModuleManager(object): def create(self): self._set_changed_options() if self.want.peer_user is None: - self.want.update({'peer_user': self.want.user}) + self.want.update({'peer_user': self.provided_username()}) if self.want.peer_password is None: - self.want.update({'peer_password': self.want.password}) + self.want.update({'peer_password': self.provided_password()}) if self.want.peer_hostname is None: - self.want.update({'peer_hostname': self.want.server}) + self.want.update({'peer_hostname': self.want.peer_server}) if self.module.check_mode: return True @@ -255,6 +272,8 @@ class ModuleManager(object): def remove(self): if self.module.check_mode: return True + if self.want.peer_hostname is None: + self.want.update({'peer_hostname': self.want.peer_server}) self.remove_from_device() if self.exists(): raise F5ModuleError("Failed to remove the trusted peer.") @@ -279,7 +298,7 @@ class ModuleManager(object): ) def remove_from_device(self): - result = self.client.api.tm.cm.remove_from_trust.exec_cmd( + self.client.api.tm.cm.remove_from_trust.exec_cmd( 'run', deviceName=self.want.peer_hostname, name=self.want.peer_hostname ) |