Skip to content

Commit

Permalink
locale_gen: fix UbuntuMode (ansible-collections#5282)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Bartosz-lab authored and Dušan Markovič committed Nov 7, 2022
1 parent e611df1 commit ca78e39
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/5282-locale_gen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- "locale_gen - fix support for Ubuntu (https://github.com/ansible-collections/community.general/issues/5281)."
12 changes: 6 additions & 6 deletions plugins/modules/system/locale_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand Down

0 comments on commit ca78e39

Please sign in to comment.