Ansible ubuntu locale & keyboard-configuration

Nesbit7
Fri, 15 Sep 2023 09:07:07 +0000
Get Help

[I can’t believe my questions haven’t been asked here previously, am I using search properly?]

OK, so my current challenge is to configure my Ubuntu 22 boxes for GB keyboard & locale [en_GB.UTF-8].

This is my code:-

   - name: Update and upgrade apt packages
     become: true
     apt:
       update_cache: yes
       upgrade: 'yes'
     when: ansible_distribution == 'Ubuntu'

   - name: Apply localectl settings to Ubuntu
     community.general.locale_gen:
       name: en_GB.UTF8
       state: present
     when: ansible_distribution == 'Ubuntu'

   - name: set as default locale
     command: localectl set-locale LANG=en_GB.UTF-8 LC_ALL=en_GB.UTF-8
     when: ansible_distribution == 'Ubuntu'

These are the errors encountered:-

fatal: [hostname]: FAILED! => {“changed”: false, “msg”: “The locale you’ve entered is not available on your system.”}

and

fatal: [hostname]: FAILED! => {“changed”: true, “cmd”: [“localectl”, “set-locale”, “LANG=en_GB.UTF-8”, “LC_ALL=en_GB.UTF-8”], “delta”: “0:00:00.125000”, “end”: “2023-09-15 09:58:17.548654”, “msg”: “non-zero return code”, “rc”: 1, “start”: “2023-09-15 09:58:17.423654”, “stderr”: “Failed to issue method call: Locale assignment LC_ALL=en_GB.UTF-8 not valid, refusing.”, “stderr_lines”: [“Failed to issue method call: Locale assignment LC_ALL=en_GB.UTF-8 not valid, refusing.”], “stdout”: “”, “stdout_lines”: }

[My script works for RedHat by following the following guidance:-

serverfault.com

How do I generate and set the locale using ansible?

ansible

asked by mniess on 09:50PM - 19 Mar 19 UTC

though that only applies to RHEL and clones.]

15 posts - 5 participants

Read full topic