Fix issues with ironware modules (#33068)
- authorize was not working as expected - use end command to get to exec context instead of exit - error due to mishandling of global variable _DEVICE_CONFIGpull/4420/head
parent
d372cea2f8
commit
47eaf662a7
|
@ -96,6 +96,7 @@ def run_commands(module, commands, check_rc=True):
|
||||||
|
|
||||||
|
|
||||||
def get_config(module, source='running', flags=None):
|
def get_config(module, source='running', flags=None):
|
||||||
|
global _DEVICE_CONFIG
|
||||||
if source is 'running' and flags is None and _DEVICE_CONFIG is not None:
|
if source is 'running' and flags is None and _DEVICE_CONFIG is not None:
|
||||||
return _DEVICE_CONFIG
|
return _DEVICE_CONFIG
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -228,7 +228,7 @@ def run(module, result):
|
||||||
if result['changed'] or module.params['save_when'] == 'always':
|
if result['changed'] or module.params['save_when'] == 'always':
|
||||||
result['changed'] = True
|
result['changed'] = True
|
||||||
if not module.check_mode:
|
if not module.check_mode:
|
||||||
cmd = {'command': 'write memory', 'output': 'text'}
|
cmd = {'command': 'write memory'}
|
||||||
run_commands(module, [cmd])
|
run_commands(module, [cmd])
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,8 @@ class ActionModule(_ActionModule):
|
||||||
pc.private_key_file = provider['ssh_keyfile'] or self._play_context.private_key_file
|
pc.private_key_file = provider['ssh_keyfile'] or self._play_context.private_key_file
|
||||||
pc.timeout = int(provider['timeout'] or C.PERSISTENT_COMMAND_TIMEOUT)
|
pc.timeout = int(provider['timeout'] or C.PERSISTENT_COMMAND_TIMEOUT)
|
||||||
pc.become = provider['authorize'] or False
|
pc.become = provider['authorize'] or False
|
||||||
|
if pc.become:
|
||||||
|
pc.become_method = 'enable'
|
||||||
pc.become_pass = provider['auth_pass']
|
pc.become_pass = provider['auth_pass']
|
||||||
|
|
||||||
display.vvv('using connection plugin %s' % pc.connection, pc.remote_addr)
|
display.vvv('using connection plugin %s' % pc.connection, pc.remote_addr)
|
||||||
|
@ -78,8 +80,8 @@ class ActionModule(_ActionModule):
|
||||||
conn = Connection(socket_path)
|
conn = Connection(socket_path)
|
||||||
out = conn.get_prompt()
|
out = conn.get_prompt()
|
||||||
if to_text(out, errors='surrogate_then_replace').strip().endswith(')#'):
|
if to_text(out, errors='surrogate_then_replace').strip().endswith(')#'):
|
||||||
display.vvvv('wrong context, sending exit to device', self._play_context.remote_addr)
|
display.vvvv('wrong context, sending end to device', self._play_context.remote_addr)
|
||||||
conn.send_command('exit')
|
conn.send_command('end')
|
||||||
|
|
||||||
task_vars['ansible_socket'] = socket_path
|
task_vars['ansible_socket'] = socket_path
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue