community.general.locale_gen module – Creates or removes locales

Note

This module is part of the community.general collection (version 10.2.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

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

Notes

Note

  • If /etc/locale.gen exists, the module will assume to be using the glibc mechanism, else if /var/lib/locales/supported.d/ exists it will assume to be using the ubuntu_legacy mechanism, else it will raise an error.

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

  • When using ubuntu_legacy mechanism, it will manage locales by editing /var/lib/locales/supported.d/local and then running locale-gen.

  • Please note that the code path that uses ubuntu_legacy mechanism has not been tested for a while, because Ubuntu is already using the glibc mechanism. There is no support for that, given our inability to test it. Therefore, that mechanism is deprecated and will be removed in community.general 13.0.0.

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

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

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"

  • "ubuntu_legacy"

Sample: "glibc"

Authors

  • Augustus Kling (@AugustusKling)