new module locale_gen fails with "Is the package “locales” installed?"

Hi all

Can anyone see what I’m doing wrong? I’m trying to generate and set the system’s locale with the following tasks against ubuntu server 14.04.

tasks

  • name: install the locales package

apt: pkg=locales state=present

  • name: ensure the locale exists
    locale_gen: name={{ locale }} state=present

  • name: set the locale
    command: /usr/sbin/update-locale LANG={{ locale }} --reset

output

msg: /etc/locale.gen and /var/lib/locales/supported.d/local are missing. Is the package “locales” installed?

However I have confirmed that the locales package is indeed installed.

Also if I don’t use the locale_gen: module everything works fine.

tasks

  • name: install the locales package

apt: pkg=locales state=present

  • name: ensure the locale exists
    command: /usr/sbin/locale-gen {{ locale }}

  • name: set the locale
    command: /usr/sbin/update-locale LANG={{ locale }} --reset

output

changed: [vps03.fqdn.com] => {“changed”: true, “cmd”: [“/usr/sbin/locale-gen”, “en_GB.UTF-8”], “delta”: “0:00:02.105356”, “end”: “2014-04-25 01:03:10.600058”, “item”: “”, “rc”: 0, “start”: “2014-04-25 01:03:08.494702”, “stderr”: “”, “stdout”: “Generating locales…\n en_GB.UTF-8… done\nGeneration complete.”}

Thanks for the help

“However I have confirmed that the locales package is indeed installed.”

Is it installed on the remote node? That’s where it’s needed.

Hi Michael

Thanks - sorry for not replying. I forgot to set up notifications correctly.

the locales package is installed on the remote node via the task

  • name: install the locales package

apt: pkg=locales state=present

and I confirmed that it was present

root@vps01:~# apt-get install locales
Reading package lists… Done
Building dependency tree
Reading state information… Done
locales is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

using /usr/sbin/locale-gen directly works fine so I guess I’ll stick with that for now

I get the error message on ubuntu server 12.04 and 14.04

if I haven’t made any obvious mistakes perhaps I should mention this on github

Thanks

The error message may have made some assumptions about the name of the package in a particular distro.

If you’d like to file a ticket in github we can take a look.

github.com/ansible/ansible – thanks!