From dff7c03996c40661228c0c2d29e3dadffacd9316 Mon Sep 17 00:00:00 2001
From: Andrea Dell'Amico <andrea.dellamico@isti.cnr.it>
Date: Thu, 30 Jul 2020 18:30:45 +0200
Subject: [PATCH] Change the LC_MESSAGES setting on EL.

---
 defaults/main.yml |  3 ++-
 tasks/locale.yml  | 22 +++++++++++++++-------
 2 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/defaults/main.yml b/defaults/main.yml
index 515e12a..6093c46 100644
--- a/defaults/main.yml
+++ b/defaults/main.yml
@@ -2,7 +2,8 @@
 # timezone
 timezone: 'Europe/Rome'
 default_locale_lang: "en_US.UTF-8"
-default_locale_messages: "C.UTF-8"
+default_deb_locale_messages: "C.UTF-8"
+default_el_locale_messages: "en_US.UTF-8"
 locales_list:
   - { name: '{{ default_locale_lang }}' }
   - { name: 'en_US.UTF-8' }
diff --git a/tasks/locale.yml b/tasks/locale.yml
index 44f0dbf..f1b5760 100644
--- a/tasks/locale.yml
+++ b/tasks/locale.yml
@@ -5,14 +5,11 @@
       locale_gen: name={{ item.name }} state={{ item.state | default('present') }}
       with_items: '{{ locales_list }}'
 
-  when: ansible_distribution_file_variety == "Debian"
-  tags: [ 'systemsetup', 'locale' ]
-
-- block:
     - name: Set the default locale on Trusty
       shell: update-locale LANG={{ default_locale_lang }}
+      when: ansible_distribution_release == "trusty"
 
-  when: ansible_distribution_release == "trusty"
+  when: ansible_distribution_file_variety == "Debian"
   tags: [ 'systemsetup', 'locale' ]
 
 - name: Set the locale on distributions that run systemd
@@ -25,7 +22,18 @@
       command: localectl set-locale "{{ item }}"
       with_items:
         - 'LANG={{ default_locale_lang }}'
-        - 'LC_MESSAGES={{ default_locale_messages }}'
-      when: localectl_executable.stat.exists | bool
+        - 'LC_MESSAGES={{ default_deb_locale_messages }}'
+      when:
+        - localectl_executable.stat.exists | bool
+        - ansible_distribution_file_variety == "Debian"
+
+    - name: Set the default locale
+      command: localectl set-locale "{{ item }}"
+      with_items:
+        - 'LANG={{ default_locale_lang }}'
+        - 'LC_MESSAGES={{ default_el_locale_messages }}'
+      when:
+        - localectl_executable.stat.exists | bool
+        - ansible_distribution_file_variety == "RedHat"
 
   tags: [ 'systemsetup', 'locale' ]