I like nerding-out, specifically around Ansible and Terraform automated test and infrastucture.
Always willing to help, love to learn and work with people.
Configure locale on your system.
Home Page: https://robertdebock.nl/
License: Apache License 2.0
The role sets the remote machine to the same locale as the machine running ansible, instead of using var defined values. This seems weird, as the role performs no checks regarding the local locales, only the asertions are delegated to localhost, but that shouldn't impact values within vars. Is it possible there is some sort of variable collision (ansible magic var <> locale_lang)?
See this issue for my playbook.
I'll just paste the additional (verbose) output not shown in the above mentioned issue. Note that I am provisioning 2 hosts with this role, I just censored the actual domains of those servers, thats why you can see two ok: [my.remote.host] ...
statements each. Also this was the second run of the play using the role, thats why there appear no changed
statements.
TASK [robertdebock.locale : test if locale_lang is set correctly] *************************************************************************************************************************************************
task path: /home/user/.ansible/roles/robertdebock.locale/tasks/assert.yml:3
ok: [my.remote.host -> localhost] => {
"changed": false,
"msg": "All assertions passed"
}
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
TASK [robertdebock.locale : test if locale_language is set correctly] *********************************************************************************************************************************************
task path: /home/user/.ansible/roles/robertdebock.locale/tasks/assert.yml:10
ok: [my.remote.host -> localhost] => {
"changed": false,
"msg": "All assertions passed"
}
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
TASK [robertdebock.locale : test if locale_lc_address is set correctly] *******************************************************************************************************************************************
task path: /home/user/.ansible/roles/robertdebock.locale/tasks/assert.yml:17
ok: [my.remote.host -> localhost] => {
"changed": false,
"msg": "All assertions passed"
}
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
TASK [robertdebock.locale : test if locale_lc_all is set correctly] ***********************************************************************************************************************************************
task path: /home/user/.ansible/roles/robertdebock.locale/tasks/assert.yml:24
ok: [my.remote.host -> localhost] => {
"changed": false,
"msg": "All assertions passed"
}
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
TASK [robertdebock.locale : test if locale_lc_collate is set correctly] *******************************************************************************************************************************************
task path: /home/user/.ansible/roles/robertdebock.locale/tasks/assert.yml:31
ok: [my.remote.host -> localhost] => {
"changed": false,
"msg": "All assertions passed"
}
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
TASK [robertdebock.locale : test if locale_lc_ctype is set correctly] *********************************************************************************************************************************************
task path: /home/user/.ansible/roles/robertdebock.locale/tasks/assert.yml:38
ok: [my.remote.host -> localhost] => {
"changed": false,
"msg": "All assertions passed"
}
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
TASK [robertdebock.locale : test if locale_lc_identification is set correctly] ************************************************************************************************************************************
task path: /home/user/.ansible/roles/robertdebock.locale/tasks/assert.yml:45
ok: [my.remote.host -> localhost] => {
"changed": false,
"msg": "All assertions passed"
}
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
TASK [robertdebock.locale : test if locale_lc_measurement is set correctly] ***************************************************************************************************************************************
task path: /home/user/.ansible/roles/robertdebock.locale/tasks/assert.yml:52
ok: [my.remote.host -> localhost] => {
"changed": false,
"msg": "All assertions passed"
}
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
TASK [robertdebock.locale : test if locale_lc_messages is set correctly] ******************************************************************************************************************************************
task path: /home/user/.ansible/roles/robertdebock.locale/tasks/assert.yml:59
ok: [my.remote.host -> localhost] => {
"changed": false,
"msg": "All assertions passed"
}
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
TASK [robertdebock.locale : test if locale_lc_monetary is set correctly] ******************************************************************************************************************************************
task path: /home/user/.ansible/roles/robertdebock.locale/tasks/assert.yml:66
ok: [my.remote.host -> localhost] => {
"changed": false,
"msg": "All assertions passed"
}
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
TASK [robertdebock.locale : test if locale_lc_name is set correctly] **********************************************************************************************************************************************
task path: /home/user/.ansible/roles/robertdebock.locale/tasks/assert.yml:73
ok: [my.remote.host -> localhost] => {
"changed": false,
"msg": "All assertions passed"
}
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
TASK [robertdebock.locale : test if locale_lc_numeric is set correctly] *******************************************************************************************************************************************
task path: /home/user/.ansible/roles/robertdebock.locale/tasks/assert.yml:80
ok: [my.remote.host -> localhost] => {
"changed": false,
"msg": "All assertions passed"
}
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
TASK [robertdebock.locale : test if locale_lc_paper is set correctly] *********************************************************************************************************************************************
task path: /home/user/.ansible/roles/robertdebock.locale/tasks/assert.yml:87
ok: [my.remote.host -> localhost] => {
"changed": false,
"msg": "All assertions passed"
}
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
TASK [robertdebock.locale : test if locale_lc_response is set correctly] ******************************************************************************************************************************************
task path: /home/user/.ansible/roles/robertdebock.locale/tasks/assert.yml:94
ok: [my.remote.host -> localhost] => {
"changed": false,
"msg": "All assertions passed"
}
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
TASK [robertdebock.locale : test if locale_lc_telephone is set correctly] *****************************************************************************************************************************************
task path: /home/user/.ansible/roles/robertdebock.locale/tasks/assert.yml:101
ok: [my.remote.host -> localhost] => {
"changed": false,
"msg": "All assertions passed"
}
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
TASK [robertdebock.locale : test if locale_lc_time is set correctly] **********************************************************************************************************************************************
task path: /home/user/.ansible/roles/robertdebock.locale/tasks/assert.yml:108
ok: [my.remote.host -> localhost] => {
"changed": false,
"msg": "All assertions passed"
}
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
TASK [robertdebock.locale : test if locale_timezone is set correctly] *********************************************************************************************************************************************
task path: /home/user/.ansible/roles/robertdebock.locale/tasks/assert.yml:115
ok: [my.remote.host -> localhost] => {
"changed": false,
"msg": "All assertions passed"
}
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
TASK [robertdebock.locale : install requirements] *****************************************************************************************************************************************************************
task path: /home/user/.ansible/roles/robertdebock.locale/tasks/main.yml:9
ok: [my.remote.host] => {
"cache_update_time": 1631618169,
"cache_updated": false,
"changed": false,
"invocation": {
"module_args": {
"allow_unauthenticated": false,
"autoclean": false,
"autoremove": false,
"cache_valid_time": 0,
"deb": null,
"default_release": null,
"dpkg_options": "force-confdef,force-confold",
"fail_on_autoremove": false,
"force": false,
"force_apt_get": false,
"install_recommends": null,
"name": [
"locales-all",
"tzdata"
],
"only_upgrade": false,
"package": [
"locales-all",
"tzdata"
],
"policy_rc_d": null,
"purge": false,
"state": "present",
"update_cache": null,
"update_cache_retries": 5,
"update_cache_retry_max_delay": 12,
"upgrade": null
}
}
}
ok: [my.remote.host] => {
"cache_update_time": 1631618170,
"cache_updated": false,
"changed": false,
"invocation": {
"module_args": {
"allow_unauthenticated": false,
"autoclean": false,
"autoremove": false,
"cache_valid_time": 0,
"deb": null,
"default_release": null,
"dpkg_options": "force-confdef,force-confold",
"fail_on_autoremove": false,
"force": false,
"force_apt_get": false,
"install_recommends": null,
"name": [
"locales-all",
"tzdata"
],
"only_upgrade": false,
"package": [
"locales-all",
"tzdata"
],
"policy_rc_d": null,
"purge": false,
"state": "present",
"update_cache": null,
"update_cache_retries": 5,
"update_cache_retry_max_delay": 12,
"upgrade": null
}
}
}
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
TASK [robertdebock.locale : configure locale.conf] ****************************************************************************************************************************************************************
task path: /home/user/.ansible/roles/robertdebock.locale/tasks/main.yml:14
ok: [my.remote.host] => {
"changed": false,
"checksum": "c42aaf3c520136c2e7a944c2b8f66b538b4298f9",
"dest": "/etc/default/locale",
"diff": {
"after": {
"path": "/etc/default/locale"
},
"before": {
"path": "/etc/default/locale"
}
},
"gid": 0,
"group": "root",
"invocation": {
"module_args": {
"_diff_peek": null,
"_original_basename": "locale.conf.j2",
"access_time": null,
"access_time_format": "%Y%m%d%H%M.%S",
"attributes": null,
"dest": "/etc/default/locale",
"follow": true,
"force": false,
"group": null,
"mode": "0644",
"modification_time": null,
"modification_time_format": "%Y%m%d%H%M.%S",
"owner": null,
"path": "/etc/default/locale",
"recurse": false,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"src": null,
"state": "file",
"unsafe_writes": false
}
},
"mode": "0644",
"owner": "root",
"path": "/etc/default/locale",
"size": 42,
"state": "file",
"uid": 0
}
ok: [my.remote.host] => {
"changed": false,
"checksum": "c42aaf3c520136c2e7a944c2b8f66b538b4298f9",
"dest": "/etc/default/locale",
"diff": {
"after": {
"path": "/etc/default/locale"
},
"before": {
"path": "/etc/default/locale"
}
},
"gid": 0,
"group": "root",
"invocation": {
"module_args": {
"_diff_peek": null,
"_original_basename": "locale.conf.j2",
"access_time": null,
"access_time_format": "%Y%m%d%H%M.%S",
"attributes": null,
"dest": "/etc/default/locale",
"follow": true,
"force": false,
"group": null,
"mode": "0644",
"modification_time": null,
"modification_time_format": "%Y%m%d%H%M.%S",
"owner": null,
"path": "/etc/default/locale",
"recurse": false,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"src": null,
"state": "file",
"unsafe_writes": false
}
},
"mode": "0644",
"owner": "root",
"path": "/etc/default/locale",
"size": 42,
"state": "file",
"uid": 0
}
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
TASK [robertdebock.locale : set timezone] *************************************************************************************************************************************************************************
task path: /home/user/.ansible/roles/robertdebock.locale/tasks/main.yml:22
ok: [my.remote.host] => {
"changed": false,
"diff": {
"after": {
"name": "Europe/Vienna"
},
"before": {
"name": "Europe/Vienna"
}
},
"invocation": {
"module_args": {
"hwclock": null,
"name": "Europe/Vienna"
}
}
}
ok: [my.remote.host] => {
"changed": false,
"diff": {
"after": {
"name": "Europe/Vienna"
},
"before": {
"name": "Europe/Vienna"
}
},
"invocation": {
"module_args": {
"hwclock": null,
"name": "Europe/Vienna"
}
}
}
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
META: role_complete for my.remote.host
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
META: role_complete for my.remote.host
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
This is what the server says after the role ran:
~$ locale
LANG=de_AT.UTF-8
LANGUAGE=
LC_CTYPE="de_AT.UTF-8"
LC_NUMERIC="de_AT.UTF-8"
LC_TIME="de_AT.UTF-8"
LC_COLLATE="de_AT.UTF-8"
LC_MONETARY="de_AT.UTF-8"
LC_MESSAGES="de_AT.UTF-8"
LC_PAPER="de_AT.UTF-8"
LC_NAME="de_AT.UTF-8"
LC_ADDRESS="de_AT.UTF-8"
LC_TELEPHONE="de_AT.UTF-8"
LC_MEASUREMENT="de_AT.UTF-8"
LC_IDENTIFICATION="de_AT.UTF-8"
LC_ALL=
Before it was all set to C.UTF-8
which appears to be the default value within a proxmox ubuntu 20.04 container.
See this issue for my environment.
To begin with, I'm unsure if this is a bug or just happens because I'm doing it wrong.
When trying to provision a remote Ubuntu LXC on a Proxmox Host, the role immediately fails with the error fatal: [my.remote.host -> localhost]: FAILED! => {"msg": "'dict object' has no attribute 'password'"}
I just paste the part of the playbook relating to locale(s), which is within our "common" role, as setting the locale is one of the things that needs to be done on all of our hosts.
...
# Locale role
- name: Change locale using external role
include_role:
name: robertdebock.locale
...
Our config done via group_vars/all.yml:
...
# Default locale configuration
locale_lang: en_GB.UTF-8
locale_timezone: Europe/Vienna
...
Our requirements.yml which is fed into ansible before every run:
roles:
- name: robertdebock.bootstrap
version: 5.2.3
- name: robertdebock.locale
version: 3.1.0
...
collections:
...
The first "TASK" in the output is the line calling the role, as described above.
...
TASK [Change locale using external role] **************************************************************************************************************************************************************************
TASK [robertdebock.locale : test if locale_lang is set correctly] *************************************************************************************************************************************************
fatal: [my.remote.host -> localhost]: FAILED! => {"msg": "'dict object' has no attribute 'password'"}
...
NAME="Ubuntu" VERSION="20.04.3 LTS (Focal Fossa)"
ansible [core 2.11.3]
NAME="Ubuntu" VERSION="18.04.5 LTS (Bionic Beaver)"
actually just a LXC on a Proxmox 6.4-13 Host (Debian 10)The role set the chosen locale(s) in /etc/default/locale
surrounding them with double quotes.
cat /etc/default/locale
#
# Ansible managed
#
LANG="en_US.UTF-8"
On Debian distributions the handler then executes the command update-locale LANG=en_US.UTF-8
that cause double quotes to be removed.
Maybe we could use localectl
also on Debian 11, as it is shipped by systemd
package.
- hosts: all
gather_facts: no
become: no
vars:
# https://github.com/robertdebock/ansible-role-locale/blob/master/defaults/main.yml
locale_timezone: Europe/Rome
tasks:
- ansible.builtin.setup:
filter:
- ansible_os_family
- ansible_distribution
- ansible.builtin.import_role:
name: robertdebock.locale
Every execution after the first show this diff
--- before: /etc/default/locale
+++ after: /Users/_redacted_/.ansible/tmp/ansible-local-8260libc5m2z/tmpbk5uok4j/locale.conf.j2
@@ -1,4 +1,5 @@
#
# Ansible managed
#
-LANG=en_US.UTF-8
+
+LANG="en_US.UTF-8"
On Ubuntu, the config file is different.
Centos: /etc/locale.conf
- name: configure locale.conf centos
template:
src: locale.conf.j2
dest: /etc/locale.conf
notify:
- localectl set-locale
Ubuntu: /etc/default/locale
https://www.thomas-krenn.com/en/wiki/Configure_Locales_in_Ubuntu
- name: configure locale.conf ubuntu
template:
src: locale.conf.j2
dest: /etc/default/locale
notify:
- localectl set-locale
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.