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 "