]> git.phdru.name Git - ansible.git/blobdiff - playbooks/roles/init-system/tasks/locales.yaml
Feat: Rename `*.yml` to `*.yaml`
[ansible.git] / playbooks / roles / init-system / tasks / locales.yaml
diff --git a/playbooks/roles/init-system/tasks/locales.yaml b/playbooks/roles/init-system/tasks/locales.yaml
new file mode 100644 (file)
index 0000000..8351b60
--- /dev/null
@@ -0,0 +1,25 @@
+- name: Check locales
+  shell: "grep -c '^ru_RU.KOI8-R' /etc/locale.gen || :"
+  register: has_locales
+  changed_when: has_locales.stdout == "0"
+
+- debug:
+    msg: "Locales have already been configured"
+  when: has_locales.stdout != "0"
+
+- block:
+    - 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',
+      ]
+    - name: Regenerate locales
+      become: true
+      command: /usr/sbin/locale-gen
+  when: has_locales.stdout == "0"