# Ansible 2.0.0.2 forwarding LANG and LC\_ALL and modules failing

**URL:** <https://forum.ansible.com/t/ansible-2-0-0-2-forwarding-lang-and-lc-all-and-modules-failing/20277>\
**Category:** Ansible Developer\
**Created:** [January 19, 2016, 4:07pm UTC](https://forum.ansible.com/t/ansible-2-0-0-2-forwarding-lang-and-lc-all-and-modules-failing/20277 "2016-01-19T16:07:13Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alejandro\_Guirao\_Rod](https://avatars.discourse-cdn.com/v4/letter/a/53a042/32.png) [@Alejandro\_Guirao\_Rod](https://forum.ansible.com/u/Alejandro_Guirao_Rod)\
**Post date:** [January 19, 2016, 4:07pm UTC](https://forum.ansible.com/t/ansible-2-0-0-2-forwarding-lang-and-lc-all-and-modules-failing/20277/1 "2016-01-19T16:07:13Z")

</div>

Hi,

I have experienced that Ansible 2.0.0.2 forwards the LANG and LC\_ALL variables from the controller machine to the hosts.

I hadn’t experienced this behaviour with versions 1.9.X, and this results in modules depending on literals (e.g: [yum](https://github.com/ansible/ansible-modules-core/blob/devel/packaging/os/yum.py), searching for “Nothing to do” ).

I have experienced that setting the variable ANSIBLE\_MODULE\_LANG to “C”, “en-us.UTF-8” or even “C” solves the problem, but if the default value of the parameter is “C” (as the [documentatio](http://docs.ansible.com/ansible/intro_configuration.html#module-lang)n says so) it should work without setting the value.

I have found this [issue](https://github.com/ansible/ansible/pull/10714) and it’s been closed and redirected to this list. The fact is that with Ansible 2.X this will happen to many people now.

I would like to start a discussion to determine if this behaviour is the right one or should be changed. Personally I think it is misbehaving as it is not enforcing the default value.

Thanks!

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [January 19, 2016, 4:14pm UTC](https://forum.ansible.com/t/ansible-2-0-0-2-forwarding-lang-and-lc-all-and-modules-failing/20277/2 "2016-01-19T16:14:29Z")

</div>

Env vars get set from the default in ansible.cfg or the var you  
mention, we changed from a default of 'C' to "en-us.UTF-8" a while  
back to deal with unicode filesystems, any other value you are seeing  
should be because someone explicitly changed this.

---

<div class="post-metadata">

**Author:** ![Alejandro\_Guirao\_Rod](https://avatars.discourse-cdn.com/v4/letter/a/53a042/32.png) [@Alejandro\_Guirao\_Rod](https://forum.ansible.com/u/Alejandro_Guirao_Rod)\
**Post date:** [January 19, 2016, 4:20pm UTC](https://forum.ansible.com/t/ansible-2-0-0-2-forwarding-lang-and-lc-all-and-modules-failing/20277/3 "2016-01-19T16:20:46Z")

</div>

Hi Brian,

In Ansible 2.0.0.2, if I don’t define ANSIBLE\_MODULE\_LANG or module\_lang in the defaults section of ansible.cfg, then the LANG variables are, by default, forwarded from the locale variables of the controller machine.

I can reproduce that.

Regards,

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [January 19, 2016, 4:21pm UTC](https://forum.ansible.com/t/ansible-2-0-0-2-forwarding-lang-and-lc-all-and-modules-failing/20277/4 "2016-01-19T16:21:35Z")

</div>

looking at teh code:

lib/ansible/plugins/shell/sh.py: LANG = C.DEFAULT\_MODULE\_LANG,  
lib/ansible/plugins/shell/sh.py: LC\_ALL = C.DEFAULT\_MODULE\_LANG,  
lib/ansible/plugins/shell/sh.py: LC\_MESSAGES = C.DEFAULT\_MODULE\_LANG,

i don't see this changed from 1.9

---

<div class="post-metadata">

**Author:** ![Alejandro\_Guirao\_Rod](https://avatars.discourse-cdn.com/v4/letter/a/53a042/32.png) [@Alejandro\_Guirao\_Rod](https://forum.ansible.com/u/Alejandro_Guirao_Rod)\
**Post date:** [January 20, 2016, 8:11am UTC](https://forum.ansible.com/t/ansible-2-0-0-2-forwarding-lang-and-lc-all-and-modules-failing/20277/5 "2016-01-20T08:11:24Z")

</div>

Hi Brian,

So, if I don’t set any value for the variable, the LANG and LC used for communication should be “C”, isn’t it? It that assumption is correct, the current behaviour (forwarding the local value of the controller) could be a bug.

Regards,

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [January 20, 2016, 1:28pm UTC](https://forum.ansible.com/t/ansible-2-0-0-2-forwarding-lang-and-lc-all-and-modules-failing/20277/6 "2016-01-20T13:28:43Z")

</div>

No, en\_us.UTF-8, that is the default as the previous default of C had  
issues with unicode paths.

---

<div class="post-metadata">

**Author:** ![Alejandro\_Guirao\_Rod](https://avatars.discourse-cdn.com/v4/letter/a/53a042/32.png) [@Alejandro\_Guirao\_Rod](https://forum.ansible.com/u/Alejandro_Guirao_Rod)\
**Post date:** [January 20, 2016, 2:14pm UTC](https://forum.ansible.com/t/ansible-2-0-0-2-forwarding-lang-and-lc-all-and-modules-failing/20277/7 "2016-01-20T14:14:33Z")

</div>

Ok, it’s the same.

The issue is that the variables in the ansible SSH session are the ones forwarded, not en\_us.UTF-8. Should that be correct?

Regards,

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [January 20, 2016, 2:15pm UTC](https://forum.ansible.com/t/ansible-2-0-0-2-forwarding-lang-and-lc-all-and-modules-failing/20277/8 "2016-01-20T14:15:36Z")

</div>

should not be, unless you are forcing it in your ssh config, still we  
set these in the command line and should override the forwarded ones.

---

<div class="post-metadata">

**Author:** ![Harald\_Laabs](https://avatars.discourse-cdn.com/v4/letter/h/9de0a6/32.png) [@Harald\_Laabs](https://forum.ansible.com/u/Harald_Laabs)\
**Post date:** [January 20, 2016, 6:52pm UTC](https://forum.ansible.com/t/ansible-2-0-0-2-forwarding-lang-and-lc-all-and-modules-failing/20277/9 "2016-01-20T18:52:58Z")

</div>

Running ansible with '-m shell -a "echo \$LANG"'  
results in  
IP\_CENSORED | SUCCESS | rc=0 \>\>  
de\_DE.UTF-8

ansible 2.1.0 (devel e3a6accc1d)  
last updated 2016/01/20 08:57:23 (GMT +200)

Running the same on 1.9.4 I get en\_US.UTF-8.  
In both cases variables from ssh SendEnv config will also be transfered. In 1.9.4 LANG is still overwritten.  
module\_lang in defaults section of ansible.cfg replaces the environment values as expected. (Both 1.9.4 and 2.x)

From -vvv:

'LANG=de\_DE.UTF-8 LC\_ALL=de\_DE.UTF-8 LC\_MESSAGES=de\_DE.UTF-8 /usr/bin/python'

vs.

/bin/sh -c 'LANG=en\_US.UTF-8 LC\_CTYPE=en\_US.UTF-8 /usr/bin/python'

So beside different env there is a "/bin/sh -c" in 1.9.4. That change feels right but can anyone point out side effects we should look for...?

Best regards,  
Harald

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [January 20, 2016, 7:48pm UTC](https://forum.ansible.com/t/ansible-2-0-0-2-forwarding-lang-and-lc-all-and-modules-failing/20277/10 "2016-01-20T19:48:50Z")

</div>

I just added /bin/sh -c back to 2.0 as there were other breakages.  
What is the user's default shell? I suspect this was only hitting only  
'non bash/sh' shells.

---

<div class="post-metadata">

**Author:** ![Harald\_Laabs](https://avatars.discourse-cdn.com/v4/letter/h/9de0a6/32.png) [@Harald\_Laabs](https://forum.ansible.com/u/Harald_Laabs)\
**Post date:** [January 20, 2016, 7:55pm UTC](https://forum.ansible.com/t/ansible-2-0-0-2-forwarding-lang-and-lc-all-and-modules-failing/20277/11 "2016-01-20T19:55:45Z")

</div>

Client and server have bash as default shell.
