diff --git a/plugins/modules/locale_gen.py b/plugins/modules/locale_gen.py index 7a2ab757b02..db33e4e9ce1 100644 --- a/plugins/modules/locale_gen.py +++ b/plugins/modules/locale_gen.py @@ -117,7 +117,7 @@ def __init_module__(self): apply_change=self.apply_change_debian, ), glibc=dict( - available=ETC_LOCALE_GEN, + available=SUPPORTED_LOCALES, apply_change=self.apply_change_glibc, ), ) @@ -151,7 +151,7 @@ def assert_available(self): checking either : * if the locale is present in /etc/locales.gen * or if the locale is present in /usr/share/i18n/SUPPORTED""" - regexp = r'^#?\s*(?P\S+[\._\S]+) (?P\S+)\s*$' + regexp = r'^\s*#?\s*(?P\S+[\._\S]+) (?P\S+)\s*$' locales_available = self.MECHANISMS[self.vars.mechanism]["available"] re_compiled = re.compile(regexp) diff --git a/tests/integration/targets/locale_gen/tasks/main.yml b/tests/integration/targets/locale_gen/tasks/main.yml index 2d9dfcee04d..1b99cb7644c 100644 --- a/tests/integration/targets/locale_gen/tasks/main.yml +++ b/tests/integration/targets/locale_gen/tasks/main.yml @@ -12,7 +12,25 @@ ansible.builtin.meta: end_play when: ansible_distribution not in ('Ubuntu', 'Debian') -- include_tasks: basic.yml +- name: Run tests auto-detecting mechanism + ansible.builtin.include_tasks: basic.yml + loop: "{{ locale_list_basic }}" + loop_control: + loop_var: locale_basic + +- name: Remove /etc/locale.gen + ansible.builtin.file: + path: /etc/locale.gen + state: absent + +- name: Ensure /var/lib/locales/supported.d exists + ansible.builtin.file: + path: /var/lib/locales/supported.d + state: directory + recurse: true + +- name: Force mechanism to be debian + ansible.builtin.include_tasks: basic.yml loop: "{{ locale_list_basic }}" loop_control: loop_var: locale_basic