From fb1cf91ebd896c783a6863ae616f58d37fb07aa0 Mon Sep 17 00:00:00 2001 From: Bartosz-lab <73119351+Bartosz-lab@users.noreply.github.com> Date: Sun, 25 Sep 2022 16:31:32 +0200 Subject: [PATCH] locale_gen: fix UbuntuMode (#5282) * 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 --- 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 "