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_CONFIG
This commit is contained in:
paulquack 2017-11-21 16:11:06 +11:00 committed by Ganesh Nalawade
parent d372cea2f8
commit 47eaf662a7
3 changed files with 6 additions and 3 deletions

View file

@ -96,6 +96,7 @@ def run_commands(module, commands, check_rc=True):
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:
return _DEVICE_CONFIG
else:

View file

@ -228,7 +228,7 @@ def run(module, result):
if result['changed'] or module.params['save_when'] == 'always':
result['changed'] = True
if not module.check_mode:
cmd = {'command': 'write memory', 'output': 'text'}
cmd = {'command': 'write memory'}
run_commands(module, [cmd])

View file

@ -60,6 +60,8 @@ class ActionModule(_ActionModule):
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.become = provider['authorize'] or False
if pc.become:
pc.become_method = 'enable'
pc.become_pass = provider['auth_pass']
display.vvv('using connection plugin %s' % pc.connection, pc.remote_addr)
@ -78,8 +80,8 @@ class ActionModule(_ActionModule):
conn = Connection(socket_path)
out = conn.get_prompt()
if to_text(out, errors='surrogate_then_replace').strip().endswith(')#'):
display.vvvv('wrong context, sending exit to device', self._play_context.remote_addr)
conn.send_command('exit')
display.vvvv('wrong context, sending end to device', self._play_context.remote_addr)
conn.send_command('end')
task_vars['ansible_socket'] = socket_path