diff --git a/roles/locales/tasks/main.yml b/roles/locales/tasks/main.yml index 28b0600d6..8d9d0bfe3 100644 --- a/roles/locales/tasks/main.yml +++ b/roles/locales/tasks/main.yml @@ -56,6 +56,12 @@ label: "{{ item.line }}" when: ansible_os_family == "Debian" + - name: Check that the /etc/locale.conf exists + stat: + path: /etc/locale.conf + register: locale_conf + when: ansible_os_family == "RedHat" + - name: Set locale "{{ locale }}" into /etc/locale.conf lineinfile: dest: "/etc/locale.conf" @@ -69,7 +75,7 @@ - {regexp: '^LC_ALL=', line: 'LC_ALL={{ locale }}'} loop_control: label: "{{ item.line }}" - when: ansible_os_family == "RedHat" + when: ansible_os_family == "RedHat" and locale_conf.stat.exists - name: Set locale "{{ locale }}" into /etc/environment lineinfile: