diff --git a/changelogs/fragments/display_verbosity.yml b/changelogs/fragments/display_verbosity.yml new file mode 100644 index 00000000000..a5bdf3fb35c --- /dev/null +++ b/changelogs/fragments/display_verbosity.yml @@ -0,0 +1,2 @@ +bugfixes: + - display itself should be single source of 'verbosity' level to the engine. diff --git a/lib/ansible/executor/task_executor.py b/lib/ansible/executor/task_executor.py index d027dfaeefb..06e78b6a151 100644 --- a/lib/ansible/executor/task_executor.py +++ b/lib/ansible/executor/task_executor.py @@ -1212,7 +1212,7 @@ def start_connection(play_context, variables, task_uuid): display.vvvv(message, host=play_context.remote_addr) if 'error' in result: - if play_context.verbosity > 2: + if display.verbosity > 2: if result.get('exception'): msg = "The full traceback is:\n" + result['exception'] display.display(msg, color=C.COLOR_ERROR) diff --git a/lib/ansible/plugins/action/__init__.py b/lib/ansible/plugins/action/__init__.py index 87d85c4fb51..88ce93390b8 100644 --- a/lib/ansible/plugins/action/__init__.py +++ b/lib/ansible/plugins/action/__init__.py @@ -453,7 +453,7 @@ class ActionBase(ABC): output = 'Authentication failure.' elif result['rc'] == 255 and self._connection.transport in ('ssh',): - if self._play_context.verbosity > 3: + if display.verbosity > 3: output = u'SSH encountered an unknown error. The output was:\n%s%s' % (result['stdout'], result['stderr']) else: output = (u'SSH encountered an unknown error during the connection. ' @@ -468,7 +468,7 @@ class ActionBase(ABC): 'Failed command was: %s, exited with result %d' % (cmd, result['rc'])) if 'stdout' in result and result['stdout'] != u'': output = output + u", stdout output: %s" % result['stdout'] - if self._play_context.verbosity > 3 and 'stderr' in result and result['stderr'] != u'': + if display.verbosity > 3 and 'stderr' in result and result['stderr'] != u'': output += u", stderr output: %s" % result['stderr'] raise AnsibleConnectionFailure(output) else: diff --git a/lib/ansible/plugins/connection/psrp.py b/lib/ansible/plugins/connection/psrp.py index 1a386d1889d..daa3c8488af 100644 --- a/lib/ansible/plugins/connection/psrp.py +++ b/lib/ansible/plugins/connection/psrp.py @@ -876,7 +876,7 @@ if ($bytes_read -gt 0) { % (command_name, str(error), position, error.message, error.fq_error) stacktrace = error.script_stacktrace - if self._play_context.verbosity >= 3 and stacktrace is not None: + if display.verbosity >= 3 and stacktrace is not None: error_msg += "\r\nStackTrace:\r\n%s" % stacktrace stderr_list.append(error_msg) diff --git a/lib/ansible/plugins/connection/ssh.py b/lib/ansible/plugins/connection/ssh.py index 328f753ca68..3c73fd742cd 100644 --- a/lib/ansible/plugins/connection/ssh.py +++ b/lib/ansible/plugins/connection/ssh.py @@ -698,7 +698,7 @@ class Connection(ConnectionBase): self._add_args(b_command, b_args, u'disable batch mode for sshpass') b_command += [b'-b', b'-'] - if self._play_context.verbosity > 3: + if display.verbosity > 3: b_command.append(b'-vvv') # Next, we add ssh_args diff --git a/test/units/plugins/action/test_action.py b/test/units/plugins/action/test_action.py index a36e2285347..0a50bdd4651 100644 --- a/test/units/plugins/action/test_action.py +++ b/test/units/plugins/action/test_action.py @@ -308,7 +308,6 @@ class TestActionBase(unittest.TestCase): # ssh error action_base._low_level_execute_command.return_value = dict(rc=255, stdout='', stderr='') self.assertRaises(AnsibleError, action_base._make_tmp_path, 'root') - play_context.verbosity = 5 self.assertRaises(AnsibleError, action_base._make_tmp_path, 'root') # general error