# Ansible vs. localectl

**URL:** <https://forums.rockylinux.org/t/ansible-vs-localectl/13564>\
**Category:** Rocky Linux Help & Support\
**Created:** [April 12, 2024, 7:01am UTC](https://forums.rockylinux.org/t/ansible-vs-localectl/13564 "2024-04-12T07:01:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![microlinux](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.rockylinux.org/microlinux/32/1244_2.png) [@microlinux](https://forums.rockylinux.org/u/microlinux)\
**Post date:** [April 12, 2024, 7:01am UTC](https://forums.rockylinux.org/t/ansible-vs-localectl/13564/1 "2024-04-12T07:01:31Z")

</div>

Hi,

I’m currently writing an Ansible playbook for Rocky Linux 8 and 9.

At some point I have to define my locale using something like this:

```auto
localectl set-locale LANG=fr_FR.UTF-8

```

Curiously enough, there’s no Ansible module to handle `localectl`.

Now I could simply use the command module with `changed_when: false`. But I wonder: when defining the locale using `localectl`, what exactly is altered under the hood? I was hoping to use `creates: something` to make this idempotent.

Any suggestions ?

---

<div class="post-metadata">

**Author:** ![label](https://avatars.discourse-cdn.com/v4/letter/l/c5a1d2/32.png) [@label](https://forums.rockylinux.org/u/label)\
**Post date:** [April 12, 2024, 8:44am UTC](https://forums.rockylinux.org/t/ansible-vs-localectl/13564/2 "2024-04-12T08:44:58Z")

</div>

```auto
man localectl

       localectl may be used to query and change the system locale and keyboard layout settings. It communicates with systemd-localed(8) to modify files
       such as /etc/locale.conf and /etc/vconsole.conf.

```

The man page lists /etc/locale.conf and /etc/vconsole.conf as files that it potentially changes.

---

<div class="post-metadata">

**Author:** ![jlehtone](https://avatars.discourse-cdn.com/v4/letter/j/e9a140/32.png) [@jlehtone](https://forums.rockylinux.org/u/jlehtone)\
**Post date:** [April 12, 2024, 11:25am UTC](https://forums.rockylinux.org/t/ansible-vs-localectl/13564/3 "2024-04-12T11:25:59Z")

</div>

There is also:

```auto
$ cat /etc/X11/xorg.conf.d/00-keyboard.conf 
# Written by systemd-localed(8), read by systemd-localed and Xorg. It's
# probably wise not to edit this file manually. Use localectl(1) to
# instruct systemd-localed to update it.
...

```

I don’t know whether that is only for X11 or also for Wayland.

* * *

`systemctl status systemd-localed` lists four man-pages, but none of them seems exhaustive on where data is stashed.  
[Chapter&nbsp;4.&nbsp;Changing basic environment settings Red Hat Enterprise Linux 9 | Red Hat Customer Portal](https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/9/html/configuring_basic_system_settings/assembly_changing-basic-environment-settings_configuring-basic-system-settings#doc-wrapper) does mention /etc/locale.conf and /etc/vconsole.conf.

* * *

A reply in [How do I generate and set the locale using ansible? - Server Fault](https://serverfault.com/questions/959026/how-do-i-generate-and-set-the-locale-using-ansible) does what I would probably have tried first:

1. Parse output of `localectl status`
2. Call `localectl set-*` on bits that are not on the output

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/rockylinux/original/1X/91b7219eec10e30013422e4df76c1d898711a5d5.svg) [@system](https://forums.rockylinux.org/u/system)\
**Post date:** [June 11, 2024, 11:26am UTC](https://forums.rockylinux.org/t/ansible-vs-localectl/13564/4 "2024-06-11T11:26:39Z")

</div>

Closed on June 11, 2024, 11:26am UTC

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
