Repository: ansible/ansible-modules-core

Issue:
source_control/subversion.py needs to reset LC_MESSAGES
##### Issue Type:

<!-- Please pick one and delete the rest: -->
- Bug Report
##### Plugin Name:

<!-- Name of the plugin/module/task -->

subversion
##### Ansible Version:

```
ansible-playbook 2.1.0 (devel 86080fbaa9) last updated 2016/03/15 19:12:05 (GMT +200)
  lib/ansible/modules/core: (detached HEAD a8841e6834) last updated 2016/03/15 19:40:46 (GMT +200)
  lib/ansible/modules/extras: (detached HEAD 45bba8ec64) last updated 2016/03/15 19:40:46 (GMT +200)
  config file = /var/tmp/subversion.bug/ansible.cfg
  configured module search path = Default w/o overrides
```
##### Ansible Configuration:

<!-- Please mention any settings you've changed/added/removed in ansible.cfg
(or using the ANSIBLE_* environment variables). -->

Default
##### Environment:

<!-- Please mention the OS you are running Ansible from, and the OS you are managing,
or say “N/A” for anything that isn't platform-specific. -->

Debian GNU Linux 8.3
##### Summary:

<!-- Please explain the problem briefly.  -->

Subversion module needs to reset LC_MESSAGES, not just LANG, since it screenscrapes the output of the svn(1) client. #2462 was the same issue for git.
##### Steps To Reproduce:

<!-- For bugs, please show exactly how to reproduce the problem.
For new features, show how the feature would be used.  -->

```
- hosts: all
  tasks:
    - shell: rm -fr {{ playbook_dir }}/repo {{ playbook_dir }}/working && svnadmin create {{ playbook_dir }}/repo
    - subversion: repo=file://{{ playbook_dir }}/repo dest={{ playbook_dir }}/working
EOF
```

<!-- You can also paste gist.github.com links for larger files.  -->
##### Expected Results:

<!-- What did you expect to happen when running the steps above?  -->

Success
##### Actual Results:

<!-- What actually happened? If possible run with high verbosity (-vvvv) -->

```
$ LANG=fr_FR.utf8 ansible-playbook -i localhost, svn_co.yml 

PLAY [all] *********************************************************************

TASK [setup] *******************************************************************
ok: [localhost]

TASK [command] *****************************************************************
changed: [localhost]
 [WARNING]: Consider using file module with state=absent rather than running rm


TASK [subversion] **************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "module_stderr": "", "module_stdout": "Traceback (most recent call last):\r\n  File \"/home/quinot/.ansible/tmp/ansible-tmp-1458067626.47-249928368830364/subversion\", line 2323, in <module>\r\n    main()\r\n  File \"/home/quinot/.ansible/tmp/ansible-tmp-1458067626.47-249928368830364/subversion\", line 259, in main\r\n    after = svn.get_revision()\r\n  File \"/home/quinot/.ansible/tmp/ansible-tmp-1458067626.47-249928368830364/subversion\", line 167, in get_revision\r\n    rev = re.search(r'^Revision:.*$', text, re.MULTILINE).group(0)\r\nAttributeError: 'NoneType' object has no attribute 'group'\r\n", "msg": "MODULE FAILURE", "parsed": false}

NO MORE HOSTS LEFT *************************************************************
    to retry, use: --limit @svn_co.retry

PLAY RECAP *********************************************************************
localhost                  : ok=2    changed=1    unreachable=0    failed=1
```



Discussion:

Resolving patch:
diff --git a/source_control/subversion.py b/source_control/subversion.py
--- a/source_control/subversion.py
+++ b/source_control/subversion.py
@@ -216,7 +216,10 @@ def main():
     export = module.params['export']
     switch = module.params['switch']
 
-    os.environ['LANG'] = 'C'
+    # We screenscrape a huge amount of svn commands so use C locale anytime we
+    # call run_command()
+    module.run_command_environ_update = dict(LANG='C', LC_ALL='C', LC_MESSAGES='C', LC_CTYPE='C')
+
     svn = Subversion(module, dest, repo, revision, username, password, svn_path)
 
     if export or not os.path.exists(dest):


Test patch: