mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-28 03:00:23 -07:00
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
This commit is contained in:
parent
47173cc8b1
commit
1492414165
1 changed files with 25 additions and 6 deletions
|
@ -30,8 +30,9 @@ options:
|
||||||
peer_hostname:
|
peer_hostname:
|
||||||
description:
|
description:
|
||||||
- The hostname that you want to associate with the device. This value will
|
- 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
|
be used to easily distinguish this device in BIG-IP configuration.
|
||||||
specified, the value of C(peer_server) will be used as a default.
|
- 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:
|
peer_user:
|
||||||
description:
|
description:
|
||||||
- The API username of the remote peer device that you are trusting. Note
|
- 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))
|
result.update(dict(changed=changed))
|
||||||
return result
|
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):
|
def present(self):
|
||||||
if self.exists():
|
if self.exists():
|
||||||
return False
|
return False
|
||||||
|
@ -236,11 +253,11 @@ class ModuleManager(object):
|
||||||
def create(self):
|
def create(self):
|
||||||
self._set_changed_options()
|
self._set_changed_options()
|
||||||
if self.want.peer_user is None:
|
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:
|
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:
|
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:
|
if self.module.check_mode:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -255,6 +272,8 @@ class ModuleManager(object):
|
||||||
def remove(self):
|
def remove(self):
|
||||||
if self.module.check_mode:
|
if self.module.check_mode:
|
||||||
return True
|
return True
|
||||||
|
if self.want.peer_hostname is None:
|
||||||
|
self.want.update({'peer_hostname': self.want.peer_server})
|
||||||
self.remove_from_device()
|
self.remove_from_device()
|
||||||
if self.exists():
|
if self.exists():
|
||||||
raise F5ModuleError("Failed to remove the trusted peer.")
|
raise F5ModuleError("Failed to remove the trusted peer.")
|
||||||
|
@ -279,7 +298,7 @@ class ModuleManager(object):
|
||||||
)
|
)
|
||||||
|
|
||||||
def remove_from_device(self):
|
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
|
'run', deviceName=self.want.peer_hostname, name=self.want.peer_hostname
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue