summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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',