summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorNathaniel Case <this.is@nathanielca.se>2017-11-14 15:51:14 -0500
committerGitHub <noreply@github.com>2017-11-14 15:51:14 -0500
commita1517234f661de58dd146f479e1ceac489e50b78 (patch)
tree53104fc275857a2a65be2ee642694b6d649a9425 /bin
parent3fedd88a9fd38bd734a1a594000e339c4d316fdd (diff)
downloadansible-a1517234f661de58dd146f479e1ceac489e50b78.tar.gz
Fix `authorize: yes` and `become_method: enable` (#32864)
* Update connection play_context when socket exists * Don't fail on connections other than network_cli * Fix enable prompt detection on ios & eos * Check against "Module not found" error code, defined in modules/jsonrpc.py
Diffstat (limited to 'bin')
-rwxr-xr-xbin/ansible-connection17
1 files changed, 15 insertions, 2 deletions
diff --git a/bin/ansible-connection b/bin/ansible-connection
index 7fbceedbd9..eed348f431 100755
--- a/bin/ansible-connection
+++ b/bin/ansible-connection
@@ -26,12 +26,11 @@ from ansible import constants as C
from ansible.module_utils._text import to_bytes, to_native, to_text
from ansible.module_utils.six import PY3
from ansible.module_utils.six.moves import cPickle
-from ansible.module_utils.connection import send_data, recv_data
+from ansible.module_utils.connection import Connection, ConnectionError, send_data, recv_data
from ansible.module_utils.service import fork_process
from ansible.playbook.play_context import PlayContext
from ansible.plugins.loader import connection_loader
from ansible.utils.path import unfrackpath, makedirs_safe
-from ansible.errors import AnsibleError
from ansible.utils.display import Display
from ansible.utils.jsonrpc import JsonRpcServer
@@ -293,6 +292,20 @@ def main():
else:
messages.append('found existing local domain socket, using it!')
+ conn = Connection(socket_path)
+ pc_data = to_text(init_data)
+ try:
+ messages.extend(conn.update_play_context(pc_data))
+ except Exception as exc:
+ # Only network_cli has update_play context, so missing this is
+ # not fatal e.g. netconf
+ if isinstance(exc, ConnectionError) and getattr(exc, 'code') == -32601:
+ pass
+ else:
+ result.update({
+ 'error': to_text(exc),
+ 'exception': traceback.format_exc()
+ })
result.update({
'messages': messages,