From 5811796c0b193d25d30f2d6d3b56503c3aef7fe2 Mon Sep 17 00:00:00 2001 From: Martin Krizek Date: Thu, 26 Mar 2020 10:45:02 +0100 Subject: [PATCH] Ensure --version works with non-ascii project path Fixes #66617 --- changelogs/fragments/66617-version-unicode-fix.yml | 2 ++ lib/ansible/config/manager.py | 2 +- .../ansible.cfg" | 2 ++ test/integration/targets/unicode/runme.sh | 6 ++++++ 4 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/66617-version-unicode-fix.yml create mode 100644 "test/integration/targets/unicode/k\305\231\303\255\305\276ek-ansible-project/ansible.cfg" diff --git a/changelogs/fragments/66617-version-unicode-fix.yml b/changelogs/fragments/66617-version-unicode-fix.yml new file mode 100644 index 00000000000000..8e3fc51d3113a6 --- /dev/null +++ b/changelogs/fragments/66617-version-unicode-fix.yml @@ -0,0 +1,2 @@ +bugfixes: + - Ensure that ``--version`` works with non-ascii ansible project paths (https://github.com/ansible/ansible/issues/66617) diff --git a/lib/ansible/config/manager.py b/lib/ansible/config/manager.py index 7bff979d651570..18d2d11c955b9b 100644 --- a/lib/ansible/config/manager.py +++ b/lib/ansible/config/manager.py @@ -231,7 +231,7 @@ def find_ini_config_file(warnings=None): if os.path.exists(cwd_cfg): warn_cmd_public = True else: - potential_paths.append(cwd_cfg) + potential_paths.append(to_text(cwd_cfg, errors='surrogate_or_strict')) except OSError: # If we can't access cwd, we'll simply skip it as a possible config source pass diff --git "a/test/integration/targets/unicode/k\305\231\303\255\305\276ek-ansible-project/ansible.cfg" "b/test/integration/targets/unicode/k\305\231\303\255\305\276ek-ansible-project/ansible.cfg" new file mode 100644 index 00000000000000..6775889f1b00d7 --- /dev/null +++ "b/test/integration/targets/unicode/k\305\231\303\255\305\276ek-ansible-project/ansible.cfg" @@ -0,0 +1,2 @@ +[defaults] +library=~/.ansible/plugins/modules:/usr/share/ansible/plugins/modules:. diff --git a/test/integration/targets/unicode/runme.sh b/test/integration/targets/unicode/runme.sh index f95061dbce8db6..aa14783bc8f0b6 100755 --- a/test/integration/targets/unicode/runme.sh +++ b/test/integration/targets/unicode/runme.sh @@ -5,3 +5,9 @@ set -eux ansible-playbook unicode.yml -i inventory -v -e 'extra_var=café' "$@" # Test the start-at-task flag #9571 ANSIBLE_HOST_PATTERN_MISMATCH=warning ansible-playbook unicode.yml -i inventory -v --start-at-task '*¶' -e 'start_at_task=True' "$@" + +# Test --version works with non-ascii ansible project paths #66617 +# Unset these so values from the project dir are used +unset ANSIBLE_CONFIG +unset ANSIBLE_LIBRARY +pushd křížek-ansible-project && ansible --version; popd