summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMatt Martz <matt@sivel.net>2021-09-29 11:54:56 -0500
committerGitHub <noreply@github.com>2021-09-29 11:54:56 -0500
commit555d1fb64d89d706c2e749c5551c089d6873acd5 (patch)
tree4672381aae631f796773cadd81aa9266de120d98 /lib
parentd4f96531d9bec481cf24fee36b517f6a8a86f2f3 (diff)
downloadansible-555d1fb64d89d706c2e749c5551c089d6873acd5.tar.gz
[stable-2.9] Don't show params when there is an issue with `set_option(s)` (#75805). (#75810)
(cherry picked from commit 79e9dae29212a88aa60122ca6bd608947399017f) Co-authored-by: Matt Martz <matt@sivel.net>
Diffstat (limited to 'lib')
-rwxr-xr-xlib/ansible/cli/scripts/ansible_connection_cli_stub.py12
-rw-r--r--lib/ansible/module_utils/connection.py5
2 files changed, 15 insertions, 2 deletions
diff --git a/lib/ansible/cli/scripts/ansible_connection_cli_stub.py b/lib/ansible/cli/scripts/ansible_connection_cli_stub.py
index b5347fd9f3..bbe4182e06 100755
--- a/lib/ansible/cli/scripts/ansible_connection_cli_stub.py
+++ b/lib/ansible/cli/scripts/ansible_connection_cli_stub.py
@@ -100,7 +100,11 @@ class ConnectionProcess(object):
self.play_context.private_key_file = os.path.join(self.original_path, self.play_context.private_key_file)
self.connection = connection_loader.get(self.play_context.connection, self.play_context, '/dev/null',
task_uuid=self._task_uuid, ansible_playbook_pid=self._ansible_playbook_pid)
- self.connection.set_options(var_options=variables)
+ try:
+ self.connection.set_options(var_options=variables)
+ except ConnectionError as exc:
+ messages.append(('debug', to_text(exc)))
+ raise ConnectionError('Unable to decode JSON from response set_options. See the debug log for more information.')
self.connection._socket_path = self.socket_path
self.srv.register(self.connection)
@@ -302,7 +306,11 @@ def main():
else:
messages.append(('vvvv', 'found existing local domain socket, using it!'))
conn = Connection(socket_path)
- conn.set_options(var_options=variables)
+ try:
+ conn.set_options(var_options=variables)
+ except ConnectionError as exc:
+ messages.append(('debug', to_text(exc)))
+ raise ConnectionError('Unable to decode JSON from response set_options. See the debug log for more information.')
pc_data = to_text(init_data)
try:
conn.update_play_context(pc_data)
diff --git a/lib/ansible/module_utils/connection.py b/lib/ansible/module_utils/connection.py
index d1ea86f843..716e9f284b 100644
--- a/lib/ansible/module_utils/connection.py
+++ b/lib/ansible/module_utils/connection.py
@@ -155,6 +155,11 @@ class Connection(object):
try:
response = json.loads(out)
except ValueError:
+ # set_option(s) has sensitive info, and the details are unlikely to matter anyway
+ if name.startswith("set_option"):
+ raise ConnectionError(
+ "Unable to decode JSON from response to {0}. Received '{1}'.".format(name, out)
+ )
params = list(args) + ['{0}={1}'.format(k, v) for k, v in iteritems(kwargs)]
params = ', '.join(params)
raise ConnectionError(