From d7fac82f97c153af08dbea2b2ae9718b19abeb8a Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Wed, 20 Jan 2016 12:09:32 -0800 Subject: [PATCH] Fix for yum's use of rpm with non English locales Depends upon https://github.com/ansible/ansible/pull/14025 Fixes https://github.com/ansible/ansible/issues/13996 Fixes https://github.com/ansible/ansible/issues/13975 --- packaging/os/yum.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packaging/os/yum.py b/packaging/os/yum.py index 80f5e359a08..87b4c88a48b 100644 --- a/packaging/os/yum.py +++ b/packaging/os/yum.py @@ -256,7 +256,10 @@ def is_installed(module, repoq, pkgspec, conf_file, qf=def_qf, en_repos=None, di rpmbin = module.get_bin_path('rpm', required=True) cmd = [rpmbin, '-q', '--qf', qf, pkgspec] - rc, out, err = module.run_command(cmd) + # rpm localizes messages and we're screen scraping so make sure we use + # the C locale + lang_env = dict(LANG='C', LC_ALL='C', LC_MESSAGES='C') + rc, out, err = module.run_command(cmd, environ_update=lang_env) if rc != 0 and 'is not installed' not in out: module.fail_json(msg='Error from rpm: %s: %s' % (cmd, err)) if 'is not installed' in out: @@ -265,7 +268,7 @@ def is_installed(module, repoq, pkgspec, conf_file, qf=def_qf, en_repos=None, di pkgs = [p for p in out.replace('(none)', '0').split('\n') if p.strip()] if not pkgs and not is_pkg: cmd = [rpmbin, '-q', '--qf', qf, '--whatprovides', pkgspec] - rc2, out2, err2 = module.run_command(cmd) + rc2, out2, err2 = module.run_command(cmd, environ_update=lang_env) else: rc2, out2, err2 = (0, '', '')