forklift icon indicating copy to clipboard operation
forklift copied to clipboard

Locale are not available

Open pratikbin opened this issue 4 years ago • 5 comments

Trying to install foreman with ansible

ansible-playbook --become --become-method=sudo -i hosts playbooks/foreman.yml -e foreman_repositories_version=3.0 --diff -vv

getting error The locale you've entered is not available on your system

TASK [foreman_installer : Ensure en_US.UTF-8 locale is available] *************************************************************************************************************************************************
task path: /home/pratik/workspace/pratikbalar/forklift/roles/foreman_installer/tasks/locales.yml:7
ok: [10.10.0.5] => changed=false 
  msg: OK
  name: en_US.UTF-8
 [started TASK: foreman_installer : Print the gateway for each host when defined on 10.10.0.5]

TASK [foreman_installer : Print the gateway for each host when defined] *******************************************************************************************************************************************
task path: /home/pratik/workspace/pratikbalar/forklift/roles/foreman_installer/tasks/locales.yml:11
ok: [10.10.0.5] => 
  msg:
  - en_US.utf8
  - C
 [started TASK: foreman_installer : Ensure ENV locales are available on 10.10.0.5]
redirecting (type: modules) ansible.builtin.locale_gen to community.general.locale_gen
[WARNING]: sftp transfer mechanism failed on [10.10.0.5]. Use ANSIBLE_DEBUG=1 to see detailed information

TASK [foreman_installer : Ensure ENV locales are available] *******************************************************************************************************************************************************
task path: /home/pratik/workspace/pratikbalar/forklift/roles/foreman_installer/tasks/locales.yml:15
failed: [10.10.0.5] (item=en_US.utf8) => changed=false 
  ansible_loop_var: item
  item: en_US.utf8
  msg: The locale you've entered is not available on your system.
redirecting (type: modules) ansible.builtin.locale_gen to community.general.locale_gen
failed: [10.10.0.5] (item=C) => changed=false 
  ansible_loop_var: item
  item: C
  msg: The locale you've entered is not available on your system.

added one job Print query before Ensure ENV locales are available to render and print the query thing https://github.com/theforeman/forklift/blob/eb7ae6abff14b39a14e0abed4e592afeeac22475/roles/foreman_installer/tasks/locales.yml#L11-L18

list of locales with diffrent commands

root@foreman:/home/administrator# localectl status
   System Locale: LANG=en_US.UTF-8
                  LANGUAGE=en_US
       VC Keymap: n/a
      X11 Layout: us
       X11 Model: pc105
root@foreman:/home/administrator# locale
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=en_US.UTF-8
root@foreman:/home/administrator# localectl list-locales
C.UTF-8
en_US.UTF-8

pratikbin avatar Aug 26 '21 13:08 pratikbin

What is the target OS? What I think is happening is that on the host OS the locale is resolved to C and the target OS doesn't understand C (but does C.UTF-8). That sounds like the target OS is EL8 or something else more modern.

ekohl avatar Aug 26 '21 13:08 ekohl

What is the target OS?

$ cat /etc/os-release 
NAME="Ubuntu"
VERSION="20.04.3 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.3 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal

pratikbin avatar Aug 27 '21 09:08 pratikbin

And your host OS? What's your environment on that?

ekohl avatar Aug 27 '21 09:08 ekohl

~~This is the host OS~~

~~wait, you mean, from where I'm running playbook?. ahh. checking...~~ it worked it's checking in localhost which is my machine from where I'm running ansible, I set/unset

export LC_COLLATE=
export LANG=

but why checking in localhost?

pratikbin avatar Aug 27 '21 09:08 pratikbin

The idea is that these local env vars are also exported to the remote host. This ensures the local locale is also available on the remote host. However, your local locale ends up being C and that's weird. Modern distributions are moving to C.UTF-8 only. I'd recommend setting the locale to something that does resolve.

ekohl avatar Aug 30 '21 16:08 ekohl