Make logging consistent for network platforms (#23605)

This commit is contained in:
Ganesh Nalawade 2017-04-16 23:25:40 +05:30 committed by GitHub
parent 89fc098488
commit 89752cc34f
10 changed files with 31 additions and 8 deletions

View file

@ -60,6 +60,7 @@ class ActionModule(_ActionModule):
pc.private_key_file = provider['ssh_keyfile'] or self._play_context.private_key_file
pc.timeout = provider['timeout'] or self._play_context.timeout
display.vvv('using connection plugin %s' % pc.connection, pc.remote_addr)
connection = self._shared_loader_obj.connection_loader.get('persistent', pc, sys.stdin)
socket_path = self._get_socket_path(pc)
@ -68,8 +69,12 @@ class ActionModule(_ActionModule):
if not os.path.exists(socket_path):
# start the connection if it isn't started
rc, out, err = connection.exec_command('open_shell()')
if rc != 0:
return {'failed': True, 'msg': 'unable to connect to control socket'}
display.vvvv('open_shell() returned %s %s %s' % (rc, out, err))
if not rc == 0:
return {'failed': True,
'msg': 'unable to open shell. Please see: ' +
'https://docs.ansible.com/ansible/network_debug_troubleshooting.html#unable-to-open-shell',
'rc': rc}
else:
# make sure we are in the right cli context which should be
# enable mode and not config module