mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fix authorize in net agnostic modules (#33549)
* This should fix authorize for net_* modules * transport: none means network_cli in eos For now anyway
This commit is contained in:
parent
961c3fcca7
commit
fdc547601c
2 changed files with 4 additions and 3 deletions
|
@ -130,9 +130,7 @@ def map_config_to_obj(module):
|
||||||
output = run_commands(module, ['show banner %s' % module.params['banner']])
|
output = run_commands(module, ['show banner %s' % module.params['banner']])
|
||||||
obj = {'banner': module.params['banner'], 'state': 'absent'}
|
obj = {'banner': module.params['banner'], 'state': 'absent'}
|
||||||
if output:
|
if output:
|
||||||
if module.params['transport'] == 'cli':
|
if module.params['transport'] == 'eapi':
|
||||||
obj['text'] = output[0]
|
|
||||||
else:
|
|
||||||
# On EAPI we need to extract the banner text from dict key
|
# On EAPI we need to extract the banner text from dict key
|
||||||
# 'loginBanner'
|
# 'loginBanner'
|
||||||
if module.params['banner'] == 'login':
|
if module.params['banner'] == 'login':
|
||||||
|
@ -141,6 +139,8 @@ def map_config_to_obj(module):
|
||||||
banner_response_key = 'motd'
|
banner_response_key = 'motd'
|
||||||
if isinstance(output[0], dict) and banner_response_key in output[0].keys():
|
if isinstance(output[0], dict) and banner_response_key in output[0].keys():
|
||||||
obj['text'] = output[0]
|
obj['text'] = output[0]
|
||||||
|
else:
|
||||||
|
obj['text'] = output[0]
|
||||||
obj['state'] = 'present'
|
obj['state'] = 'present'
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
|
|
|
@ -70,6 +70,7 @@ class ActionModule(ActionBase):
|
||||||
if 'authorize' in self.provider.keys():
|
if 'authorize' in self.provider.keys():
|
||||||
play_context.become = self.provider['authorize'] or False
|
play_context.become = self.provider['authorize'] or False
|
||||||
play_context.become_pass = self.provider['auth_pass']
|
play_context.become_pass = self.provider['auth_pass']
|
||||||
|
play_context.become_method = 'enable'
|
||||||
|
|
||||||
if self._play_context.connection == 'local':
|
if self._play_context.connection == 'local':
|
||||||
socket_path = self._start_connection(play_context)
|
socket_path = self._start_connection(play_context)
|
||||||
|
|
Loading…
Reference in a new issue