From 16c7600e0ec90d403c24be745a11b7819fab378a Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Wed, 17 Jul 2019 02:58:18 +0300 Subject: [PATCH] Feat(debian/init-system): Check locales are configured Check that locales are already configured. If not - configure and regenerate. --- .../roles/debian/init-system/handlers/main.yml | 16 ++++++++++++++++ .../roles/debian/init-system/tasks/main.yml | 18 +++++++----------- 2 files changed, 23 insertions(+), 11 deletions(-) create mode 100644 playbooks/roles/debian/init-system/handlers/main.yml diff --git a/playbooks/roles/debian/init-system/handlers/main.yml b/playbooks/roles/debian/init-system/handlers/main.yml new file mode 100644 index 0000000..701e789 --- /dev/null +++ b/playbooks/roles/debian/init-system/handlers/main.yml @@ -0,0 +1,16 @@ +- name: Configure locales + become: true + lineinfile: + path: /etc/locale.gen + regexp: "^{{ item }}" + line: "{{ item }}" + loop: [ + 'en_US ISO-8859-1', + 'ru_RU.KOI8-R KOI8-R', + 'ru_RU.UTF-8 UTF-8', + ] + notify: Regenerate locales + +- name: Regenerate locales + become: true + command: /usr/sbin/locale-gen diff --git a/playbooks/roles/debian/init-system/tasks/main.yml b/playbooks/roles/debian/init-system/tasks/main.yml index 1c83ab3..0e1db28 100644 --- a/playbooks/roles/debian/init-system/tasks/main.yml +++ b/playbooks/roles/debian/init-system/tasks/main.yml @@ -30,14 +30,10 @@ id: 5C808C2B65558117 when: "inventory_hostname in ('localhost', 'iskra-aviel.phdru.name')" -- name: Configure locales - become: true - blockinfile: - path: /etc/locale.gen - block: | - en_US ISO-8859-1 - ru_RU.KOI8-R KOI8-R - ru_RU.UTF-8 UTF-8 -- name: Regenerate locales - become: true - command: /usr/sbin/locale-gen +- name: Check locales + command: grep -c '^ru_RU.KOI8-R' /etc/locale.gen + register: has_locales +- debug: + msg: "Creating and regenerating locales..." + notify: Configure locales + when: has_locales.stdout == "0" -- 2.39.5