community.general.locale_gen module – Creates or removes locales

Note

This module is part of the community.general collection (version 13.1.0).

You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install community.general.

To use it in a playbook, specify: community.general.locale_gen.

Synopsis

  • Manages locales in Debian and Ubuntu systems.

Parameters

Parameter

Comments

name

list / elements=string / required

Name and encoding of the locales, such as en_GB.UTF-8.

Before community.general 9.3.0, this was a string. Using a string still works.

state

string

Whether the locales shall be present.

Choices:

  • "absent"

  • "present" ← (default)

Attributes

Attribute

Support

Description

check_mode

Support: full

Can run in check_mode and return changed status prediction without modifying target.

diff_mode

Support: none

Returns details on what has changed (or possibly needs changing in check_mode), when in diff mode.

Notes

Note

  • Currently the module is only supported for Debian, Ubuntu, and Arch Linux systems.

  • This module requires the package locales installed in Debian and Ubuntu systems.

  • If /etc/locale.gen exists, the module assumes to be using the glibc mechanism, else it raises an error. Support for /var/lib/locales/supported.d/ (the ubuntu_legacy mechanism) has been removed in community.general 13.0.0.

  • When using glibc mechanism, it manages locales by editing /etc/locale.gen and running locale-gen.

  • Please note that the module asserts the availability of the locale by checking the files /usr/share/i18n/SUPPORTED and /usr/local/share/i18n/SUPPORTED, but the /usr/local one is not supported by Archlinux.

Examples

- name: Ensure a locale exists
  community.general.locale_gen:
    name: de_CH.UTF-8
    state: present

- name: Ensure multiple locales exist
  community.general.locale_gen:
    name:
      - en_GB.UTF-8
      - nl_NL.UTF-8
    state: present

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key

Description

mechanism

string

added in community.general 10.2.0

Mechanism used to deploy the locales.

Returned: success

Can only return:

  • "glibc"

Sample: "glibc"

Authors

  • Augustus Kling (@AugustusKling)