From f9fecf12e7c52157dd2e256a7b926db4fae610f4 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Sun, 25 Sep 2022 21:07:46 +0200 Subject: [PATCH] locale_gen: fix UbuntuMode (#5282) (#5310) * Fix UbuntuMode * Fix indentation * Create 5281-locale_gen.yaml * Update and rename 5281-locale_gen.yaml to 5282-locale_gen.yaml * apply suggested changes * apply suggested change (cherry picked from commit fb1cf91ebd896c783a6863ae616f58d37fb07aa0) Co-authored-by: Bartosz-lab <73119351+Bartosz-lab@users.noreply.github.com> --- changelogs/fragments/5282-locale_gen.yaml | 2 ++ plugins/modules/system/locale_gen.py | 12 ++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) create mode 100644 changelogs/fragments/5282-locale_gen.yaml diff --git a/changelogs/fragments/5282-locale_gen.yaml b/changelogs/fragments/5282-locale_gen.yaml new file mode 100644 index 0000000000..07cc13a72f --- /dev/null +++ b/changelogs/fragments/5282-locale_gen.yaml @@ -0,0 +1,2 @@ +bugfixes: + - "locale_gen - fix support for Ubuntu (https://github.com/ansible-collections/community.general/issues/5281)." diff --git a/plugins/modules/system/locale_gen.py b/plugins/modules/system/locale_gen.py index 814a82c72a..743570b7ab 100644 --- a/plugins/modules/system/locale_gen.py +++ b/plugins/modules/system/locale_gen.py @@ -197,15 +197,15 @@ def main(): name = module.params['name'] state = module.params['state'] - if not os.path.exists("/etc/locale.gen"): - if os.path.exists("/var/lib/locales/supported.d/"): - # Ubuntu created its own system to manage locales. - ubuntuMode = True + if not os.path.exists("/var/lib/locales/supported.d/"): + if os.path.exists("/etc/locale.gen"): + # We found the common way to manage locales. + ubuntuMode = False else: module.fail_json(msg="/etc/locale.gen and /var/lib/locales/supported.d/local are missing. Is the package \"locales\" installed?") else: - # We found the common way to manage locales. - ubuntuMode = False + # Ubuntu created its own system to manage locales. + ubuntuMode = True if not is_available(name, ubuntuMode): module.fail_json(msg="The locale you've entered is not available "