Merge pull request #2981 from ansible/apt-locale-fix
use new method of setting locale and other environment variables
This commit is contained in:
commit
009389bbb2
1 changed files with 10 additions and 15 deletions
|
@ -181,9 +181,14 @@ import itertools
|
||||||
|
|
||||||
# APT related constants
|
# APT related constants
|
||||||
APT_ENV_VARS = dict(
|
APT_ENV_VARS = dict(
|
||||||
DEBIAN_FRONTEND = 'noninteractive',
|
DEBIAN_FRONTEND = 'noninteractive',
|
||||||
DEBIAN_PRIORITY = 'critical',
|
DEBIAN_PRIORITY = 'critical',
|
||||||
LANG = 'C'
|
# We screenscrape apt-get and aptitude output for information so we need
|
||||||
|
# to make sure we use the C locale when running commands
|
||||||
|
LANG = 'C',
|
||||||
|
LC_ALL = 'C',
|
||||||
|
LC_MESSAGES = 'C',
|
||||||
|
LC_CTYPE = 'C',
|
||||||
)
|
)
|
||||||
|
|
||||||
DPKG_OPTIONS = 'force-confdef,force-confold'
|
DPKG_OPTIONS = 'force-confdef,force-confold'
|
||||||
|
@ -388,9 +393,6 @@ def install(m, pkgspec, cache, upgrade=False, default_release=None,
|
||||||
else:
|
else:
|
||||||
autoremove = ''
|
autoremove = ''
|
||||||
|
|
||||||
for (k,v) in APT_ENV_VARS.iteritems():
|
|
||||||
os.environ[k] = v
|
|
||||||
|
|
||||||
if build_dep:
|
if build_dep:
|
||||||
cmd = "%s -y %s %s %s build-dep %s" % (APT_GET_CMD, dpkg_options, force_yes, check_arg, packages)
|
cmd = "%s -y %s %s %s build-dep %s" % (APT_GET_CMD, dpkg_options, force_yes, check_arg, packages)
|
||||||
else:
|
else:
|
||||||
|
@ -455,9 +457,6 @@ def install_deb(m, debs, cache, force, install_recommends, dpkg_options):
|
||||||
if force:
|
if force:
|
||||||
options += " --force-all"
|
options += " --force-all"
|
||||||
|
|
||||||
for (k,v) in APT_ENV_VARS.iteritems():
|
|
||||||
os.environ[k] = v
|
|
||||||
|
|
||||||
cmd = "dpkg %s -i %s" % (options, " ".join(pkgs_to_install))
|
cmd = "dpkg %s -i %s" % (options, " ".join(pkgs_to_install))
|
||||||
rc, out, err = m.run_command(cmd)
|
rc, out, err = m.run_command(cmd)
|
||||||
if "stdout" in retvals:
|
if "stdout" in retvals:
|
||||||
|
@ -495,9 +494,6 @@ def remove(m, pkgspec, cache, purge=False,
|
||||||
else:
|
else:
|
||||||
purge = ''
|
purge = ''
|
||||||
|
|
||||||
for (k,v) in APT_ENV_VARS.iteritems():
|
|
||||||
os.environ[k] = v
|
|
||||||
|
|
||||||
if autoremove:
|
if autoremove:
|
||||||
autoremove = '--auto-remove'
|
autoremove = '--auto-remove'
|
||||||
else:
|
else:
|
||||||
|
@ -546,9 +542,6 @@ def upgrade(m, mode="yes", force=False, default_release=None,
|
||||||
|
|
||||||
apt_cmd_path = m.get_bin_path(apt_cmd, required=True)
|
apt_cmd_path = m.get_bin_path(apt_cmd, required=True)
|
||||||
|
|
||||||
for (k,v) in APT_ENV_VARS.iteritems():
|
|
||||||
os.environ[k] = v
|
|
||||||
|
|
||||||
cmd = '%s -y %s %s %s %s' % (apt_cmd_path, dpkg_options,
|
cmd = '%s -y %s %s %s %s' % (apt_cmd_path, dpkg_options,
|
||||||
force_yes, check_arg, upgrade_command)
|
force_yes, check_arg, upgrade_command)
|
||||||
|
|
||||||
|
@ -583,6 +576,8 @@ def main():
|
||||||
supports_check_mode = True
|
supports_check_mode = True
|
||||||
)
|
)
|
||||||
|
|
||||||
|
module.run_command_environ_update = APT_ENV_VARS
|
||||||
|
|
||||||
if not HAS_PYTHON_APT:
|
if not HAS_PYTHON_APT:
|
||||||
try:
|
try:
|
||||||
module.run_command('apt-get update && apt-get install python-apt -y -q --force-yes', use_unsafe_shell=True, check_rc=True)
|
module.run_command('apt-get update && apt-get install python-apt -y -q --force-yes', use_unsafe_shell=True, check_rc=True)
|
||||||
|
|
Loading…
Reference in a new issue