summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSloane Hertel <19572925+s-hertel@users.noreply.github.com>2022-12-08 14:06:08 -0500
committerGitHub <noreply@github.com>2022-12-09 05:06:08 +1000
commit11e43e9d6e9809ca8fdf56f814b89da3dc0d5659 (patch)
tree4ad302ec55f03cd4caeac290334bedeb8f240a70
parent527abba86010629e21f8227c4234c393e4ee8122 (diff)
downloadansible-11e43e9d6e9809ca8fdf56f814b89da3dc0d5659.tar.gz
Set locale for python apt (#79546)
* set locale to get_best_parsable_locale for the python-apt API * add a test case * add changelog * remove test that tests nothing
-rw-r--r--changelogs/fragments/79546-apt-fix-setting-locale.yml2
-rw-r--r--lib/ansible/modules/apt.py2
2 files changed, 4 insertions, 0 deletions
diff --git a/changelogs/fragments/79546-apt-fix-setting-locale.yml b/changelogs/fragments/79546-apt-fix-setting-locale.yml
new file mode 100644
index 0000000000..7ddd86714c
--- /dev/null
+++ b/changelogs/fragments/79546-apt-fix-setting-locale.yml
@@ -0,0 +1,2 @@
+bugfixes:
+ - apt - set locale to fix updating the cache (https://github.com/ansible/ansible/issues/79523).
diff --git a/lib/ansible/modules/apt.py b/lib/ansible/modules/apt.py
index ba0aed050d..b98a47a6f5 100644
--- a/lib/ansible/modules/apt.py
+++ b/lib/ansible/modules/apt.py
@@ -354,6 +354,7 @@ warnings.filterwarnings('ignore', "apt API not stable yet", FutureWarning)
import datetime
import fnmatch
import itertools
+import locale as locale_module
import os
import random
import re
@@ -1218,6 +1219,7 @@ def main():
# to make sure we use the best parsable locale when running commands
# also set apt specific vars for desired behaviour
locale = get_best_parsable_locale(module)
+ locale_module.setlocale(locale_module.LC_ALL, locale)
# APT related constants
APT_ENV_VARS = dict(
DEBIAN_FRONTEND='noninteractive',