Initial commit

This commit is contained in:
Sven Velt 2025-04-12 15:26:19 +02:00
commit 890d675a89
5 changed files with 87 additions and 0 deletions

36
README.md Normal file
View file

@ -0,0 +1,36 @@
# linux-locales
Configure Linux locales
## Requirements
- Linux system with glibc
## Role Variables
--------------
Variable | Context | Description
---|---|---
`locales_active` | (defaults) | list of locales to generate
`locales_inactive` | (defaults) | list of locales to deactivate
## Dependencies
- `glibc` on Linux, so no e.g. `musl libc` systems
## Example Playbook
- hosts: linux-locales
roles:
- role: keepalived-simple
when: ansible_distribution != "Alpine"
## License
GPL-2.0-or-later
## Author Information
- Sven Velt <sven-ansiblerole@velt.biz>
- https://git.velt.biz/velt.biz/

9
defaults/main.yml Normal file
View file

@ -0,0 +1,9 @@
---
locales_active:
- C.UTF-8 UTF-8
- de_DE ISO-8859-1
- de_DE.UTF-8 UTF-8
- de_DE@euro ISO-8859-15
- en_US.UTF-8 UTF-8
locales_inactive: []

6
locales.yml Normal file
View file

@ -0,0 +1,6 @@
---
- hosts: all
roles:
- role: linux-locales
when: ansible_distribution != "Alpine"

15
meta/main.yml Normal file
View file

@ -0,0 +1,15 @@
---
galaxy_info:
author: Sven Velt
description: Configure locales on Linux glibc system
company: velt.biz
issue_tracker_url: https://git.velt.biz/Ansible/role.linux-locales/issues
license: AGPL-3.0-or-later
min_ansible_version: '2.10'
platforms:
- all
galaxy_tags:
- operations
dependencies: []

21
tasks/main.yml Normal file
View file

@ -0,0 +1,21 @@
---
- name: Deactivate locales
ansible.builtin.lineinfile:
path: /etc/locale.gen
regexp: '^#*\s*{{ item }}'
line: '# {{ item }}'
loop: '{{ locales_inactive }}'
register: locales_inactivated
- name: Activate locales
ansible.builtin.lineinfile:
path: /etc/locale.gen
regexp: '^#*\s*{{ item }}'
line: '{{ item }}'
loop: '{{ locales_active }}'
register: locales_activated
- name: Regenerate locale-gen # noqa: no-changed-when
ansible.builtin.command:
cmd: /usr/sbin/locale-gen
when: locales_inactivated is changed or locales_activated is changed