1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Setting LC_MESSAGES: prevent unparseable messages

This locale variable defines how tools should display their messages.
This is for example gonna change the yum message from "Nothing to do" to
"Rien a faire" in my case (french).

As the yum module parses that string in err, if the message is not
enforced in english this is gonna fail.

So this commits just enriches a bit more the code that's already written
for that enforcement.

This commit fixes issue #9635.
This commit is contained in:
Baptiste Mathus 2014-11-26 10:35:45 +01:00
parent 704f7d7b40
commit a1adff4ff0
2 changed files with 2 additions and 0 deletions

View file

@ -772,6 +772,7 @@ class AnsibleModule(object):
locale.setlocale(locale.LC_ALL, 'C') locale.setlocale(locale.LC_ALL, 'C')
os.environ['LANG'] = 'C' os.environ['LANG'] = 'C'
os.environ['LC_CTYPE'] = 'C' os.environ['LC_CTYPE'] = 'C'
os.environ['LC_MESSAGES'] = 'C'
except Exception, e: except Exception, e:
self.fail_json(msg="An unknown error was encountered while attempting to validate the locale: %s" % e) self.fail_json(msg="An unknown error was encountered while attempting to validate the locale: %s" % e)

View file

@ -29,6 +29,7 @@ class ShellModule(object):
env = dict( env = dict(
LANG = C.DEFAULT_MODULE_LANG, LANG = C.DEFAULT_MODULE_LANG,
LC_CTYPE = C.DEFAULT_MODULE_LANG, LC_CTYPE = C.DEFAULT_MODULE_LANG,
LC_MESSAGES = C.DEFAULT_MODULE_LANG,
) )
env.update(kwargs) env.update(kwargs)
return ' '.join(['%s=%s' % (k, pipes.quote(unicode(v))) for k,v in env.items()]) return ' '.join(['%s=%s' % (k, pipes.quote(unicode(v))) for k,v in env.items()])