diff options
author | Nathaniel Case <this.is@nathanielca.se> | 2017-11-14 21:51:14 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-14 21:51:14 +0100 |
commit | a1517234f661de58dd146f479e1ceac489e50b78 (patch) | |
tree | 53104fc275857a2a65be2ee642694b6d649a9425 /bin | |
parent | Avoid AttributeError: internal_network on os_floating_ip (#32887) (diff) | |
download | ansible-a1517234f661de58dd146f479e1ceac489e50b78.tar.xz ansible-a1517234f661de58dd146f479e1ceac489e50b78.zip |
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-x | bin/ansible-connection | 17 |
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, |