From ad4d00e1dbcff86deb975faede6625777c411121 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Wed, 1 Sep 2021 12:38:57 -0400 Subject: [PATCH] Clarify get_bin_path error message (#75544) (#75564) (cherry picked from commit 3ca50a2200cba04b6fa82e27e485784cee011277) --- changelogs/fragments/clarify_missing_exe.yml | 2 ++ lib/ansible/module_utils/common/process.py | 2 +- test/units/module_utils/common/process/test_get_bin_path.py | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/clarify_missing_exe.yml diff --git a/changelogs/fragments/clarify_missing_exe.yml b/changelogs/fragments/clarify_missing_exe.yml new file mode 100644 index 00000000000..a087f561b71 --- /dev/null +++ b/changelogs/fragments/clarify_missing_exe.yml @@ -0,0 +1,2 @@ +bugfixes: + - get_bin_path, clarify with quotes what the missing required executable is. diff --git a/lib/ansible/module_utils/common/process.py b/lib/ansible/module_utils/common/process.py index 91e818a023f..f128cd98006 100644 --- a/lib/ansible/module_utils/common/process.py +++ b/lib/ansible/module_utils/common/process.py @@ -39,6 +39,6 @@ def get_bin_path(arg, opt_dirs=None, required=None): bin_path = path break if bin_path is None: - raise ValueError('Failed to find required executable %s in paths: %s' % (arg, os.pathsep.join(paths))) + raise ValueError('Failed to find required executable "%s" in paths: %s' % (arg, os.pathsep.join(paths))) return bin_path diff --git a/test/units/module_utils/common/process/test_get_bin_path.py b/test/units/module_utils/common/process/test_get_bin_path.py index a337e78d5e5..7c0bd0a8db5 100644 --- a/test/units/module_utils/common/process/test_get_bin_path.py +++ b/test/units/module_utils/common/process/test_get_bin_path.py @@ -35,5 +35,5 @@ def test_get_path_path_raise_valueerror(mocker): mocker.patch('os.path.isdir', return_value=False) mocker.patch('ansible.module_utils.common.process.is_executable', return_value=True) - with pytest.raises(ValueError, match='Failed to find required executable notacommand'): + with pytest.raises(ValueError, match='Failed to find required executable "notacommand"'): get_bin_path('notacommand')