From 4635c75ef7e76342fac076cfa5f730ea48706bb9 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Thu, 24 Mar 2022 18:16:33 -0400 Subject: [PATCH] log results for get_best_parsable_locale (#77319) * log locale outcomes from function * also included variant forms of same prefs --- changelogs/fragments/log_locale_selection_results.yml | 2 ++ lib/ansible/module_utils/common/locale.py | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/log_locale_selection_results.yml diff --git a/changelogs/fragments/log_locale_selection_results.yml b/changelogs/fragments/log_locale_selection_results.yml new file mode 100644 index 00000000000..5da012d4ee4 --- /dev/null +++ b/changelogs/fragments/log_locale_selection_results.yml @@ -0,0 +1,2 @@ +minor_changes: + - get_parsable_locale now logs result when in debug mode. diff --git a/lib/ansible/module_utils/common/locale.py b/lib/ansible/module_utils/common/locale.py index ced9ee6f133..e8b201b23ea 100644 --- a/lib/ansible/module_utils/common/locale.py +++ b/lib/ansible/module_utils/common/locale.py @@ -32,7 +32,7 @@ def get_best_parsable_locale(module, preferences=None, raise_on_locale=False): if preferences is None: # new POSIX standard or English cause those are messages core team expects # yes, the last 2 are the same but some systems are weird - preferences = ['C.utf8', 'en_US.utf8', 'C', 'POSIX'] + preferences = ['C.utf8', 'C.UTF-8', 'en_US.utf8', 'en_US.UTF-8', 'C', 'POSIX'] rc, out, err = module.run_command([locale, '-a']) @@ -50,8 +50,12 @@ def get_best_parsable_locale(module, preferences=None, raise_on_locale=False): found = pref break - except RuntimeWarning: + except RuntimeWarning as e: if raise_on_locale: raise + else: + module.debug('Failed to get locale information: %s' % to_native(e)) + + module.debug('Matched prefered locale to: %s' % found) return found