add config_locale role -> bump version to 0.1.1

This commit is contained in:
2023-10-07 12:38:18 +02:00
parent cd180c7285
commit c309b1da69
4 changed files with 47 additions and 5 deletions

View File

@@ -10,11 +10,15 @@ if you have any questions or suggestions feel free to get in touch with me.
## roles ## roles
* **test** * **test** a simple role to test ansible or just this collection
a simple role to test ansible or just this collection
it will run a debug task printing 'hello world' it will run a debug task printing 'hello world'
* **docker** * **config_locale** role to configure system locale and language settings
a docker install role that can install docker-ce engine in two ways: you should set `system_locale` and `system_language` if you want to deviate from the default:
```
system_locale: 'de_DE.UTF-8'
system_language: 'en_US.UTF-8'
```
* **docker** a docker install role that can install docker-ce engine in two ways:
1. from the official docker repository (recommended by docker) 1. from the official docker repository (recommended by docker)
2. from your distribution 2. from your distribution
you can switch to the distribution method by setting `docker_use_dist_repo` to `true` (defaults to `false`). you can switch to the distribution method by setting `docker_use_dist_repo` to `true` (defaults to `false`).

View File

@@ -8,7 +8,7 @@ namespace: dede
name: common name: common
# The version of the collection. Must be compatible with semantic versioning # The version of the collection. Must be compatible with semantic versioning
version: 0.1.0 version: 0.1.1
# The path to the Markdown (.md) readme file. This path is relative to the root of the collection # The path to the Markdown (.md) readme file. This path is relative to the root of the collection
readme: README.md readme: README.md

View File

@@ -0,0 +1,3 @@
---
system_locale: 'de_DE.UTF-8'
system_language: 'en_US.UTF-8'

View File

@@ -0,0 +1,35 @@
---
# got this from here:
# https://serverfault.com/questions/959026/how-do-i-generate-and-set-the-locale-using-ansible/981742#981742
- name: ensure locale files for '{{ system_locale }}' are available
become: true
community.general.locale_gen:
name: "{{ system_locale }}"
state: present
- name: ensure locale files for '{{ system_language }}' are available
become: true
community.general.locale_gen:
name: "{{ system_language }}"
state: present
- name: get current locale and language configuration
ansible.builtin.command: localectl status
register: locale_status
changed_when: false
- name: set facts locale_lang and locale_language
ansible.builtin.set_fact:
locale_lang: "{{ locale_status.stdout | regex_search('LANG=([^\n]+)', '\\1') | first }}"
locale_language: "{{ locale_status.stdout | regex_search('LANGUAGE=([^\n]+)', '\\1') | default([locale_lang], true) | first }}"
- name: set locale to '{{ system_locale }}'
become: true
ansible.builtin.command: localectl set-locale LANG={{ system_locale }}
changed_when: locale_lang != system_locale
- name: set language to '{{ system_language }}'
become: true
ansible.builtin.command: localectl set-locale LANGUAGE={{ system_language }}
changed_when: locale_language != system_language