From 890d675a89a47366545fb1436869c5f196e18f0d Mon Sep 17 00:00:00 2001 From: Sven Velt Date: Sat, 12 Apr 2025 15:26:19 +0200 Subject: [PATCH] Initial commit --- README.md | 36 ++++++++++++++++++++++++++++++++++++ defaults/main.yml | 9 +++++++++ locales.yml | 6 ++++++ meta/main.yml | 15 +++++++++++++++ tasks/main.yml | 21 +++++++++++++++++++++ 5 files changed, 87 insertions(+) create mode 100644 README.md create mode 100644 defaults/main.yml create mode 100644 locales.yml create mode 100644 meta/main.yml create mode 100644 tasks/main.yml diff --git a/README.md b/README.md new file mode 100644 index 0000000..b21efbd --- /dev/null +++ b/README.md @@ -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 +- https://git.velt.biz/velt.biz/ + diff --git a/defaults/main.yml b/defaults/main.yml new file mode 100644 index 0000000..b8f5e78 --- /dev/null +++ b/defaults/main.yml @@ -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: [] diff --git a/locales.yml b/locales.yml new file mode 100644 index 0000000..1be9198 --- /dev/null +++ b/locales.yml @@ -0,0 +1,6 @@ +--- +- hosts: all + + roles: + - role: linux-locales + when: ansible_distribution != "Alpine" diff --git a/meta/main.yml b/meta/main.yml new file mode 100644 index 0000000..0d624b1 --- /dev/null +++ b/meta/main.yml @@ -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: [] diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..6b1692d --- /dev/null +++ b/tasks/main.yml @@ -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