Why does ansible change LANG to C?

We’ve tracked down a bug in our ansible-driven build to the LANG environment variable being explicitly set to “C”. I’m wondering why this is done i.e. why modify it at all? Why not just use the environment of the user/account executing the ansible script? It was confusing, because running the same commands manually from the ansible user account did not reproduce the fault.

I found this post:
https://groups.google.com/forum/#!topic/ansible-project/HD3yxPfsnzg

which says that it is done to avoid encoding issues; which is ironic, as it has caused us encoding issues…

We’ve set module_lang = en_NZ.UTF-8 in ansible.cfg for now.

It’s done because various modules rely on parsing Unix commands and these commands are difficult to parse in different languages.

The proposal has been made that if LANG is set in the environment, we possibly not set LANG, though we’ll need to consider implications.

It may be that only certain modules need to set the LANG to C, so it may warrant reading history and audit specifically what changes may have to occur.

The first modules that should use the default system LANG are command and shell. Having them as C can give a lot of problems, especially if you are inserting something into a database which is UTF8.

I’d agree especially for those.

Please make sure there’s a ticket filed if you can’t find one already. We’ll probably want to research a bit more which specifically should make modifications.

Issue 7060 created.