]> git.phdru.name Git - ansible.git/commitdiff
Feat(debian/init-system): Check locales are configured
authorOleg Broytman <phd@phdru.name>
Tue, 16 Jul 2019 23:58:18 +0000 (02:58 +0300)
committerOleg Broytman <phd@phdru.name>
Wed, 17 Jul 2019 00:18:34 +0000 (03:18 +0300)
Check that locales are already configured.
If not - configure and regenerate.

playbooks/roles/debian/init-system/handlers/main.yml [new file with mode: 0644]
playbooks/roles/debian/init-system/tasks/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 (file)
index 0000000..701e789
--- /dev/null
@@ -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
index 1c83ab39cd73914c7da0249bea5372d8e9deeba9..0e1db285b0a1791b3c37918e4d0b780b50d608cc 100644 (file)
     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"