From 31c2075a4ca8898f4ac3c47f01e5f3a481267e05 Mon Sep 17 00:00:00 2001 From: Thomas Schneider <thomas@fsmpi.rwth-aachen.de> Date: Sat, 10 Jun 2023 16:40:52 +0200 Subject: [PATCH] localization: RHEL support --- localization/handlers/main.yml | 7 ++++++ localization/tasks/locale.yml | 29 ++++++++++++++++++++++-- localization/tasks/timesyncd.yml | 19 ++++++++++++++++ localization/tasks/timezone.yml | 2 ++ localization/templates/timesyncd.conf.j2 | 4 ++++ 5 files changed, 59 insertions(+), 2 deletions(-) diff --git a/localization/handlers/main.yml b/localization/handlers/main.yml index cc5308c..5a6a169 100644 --- a/localization/handlers/main.yml +++ b/localization/handlers/main.yml @@ -9,3 +9,10 @@ - name: update timezone command: dpkg-reconfigure --frontend noninteractive tzdata + when: is_debian + +- name: stop chronyd + systemd: + name: chronyd.service + state: stopped + ignore_errors: true diff --git a/localization/tasks/locale.yml b/localization/tasks/locale.yml index a6ae95b..b709c79 100644 --- a/localization/tasks/locale.yml +++ b/localization/tasks/locale.yml @@ -1,9 +1,20 @@ --- -- name: ensure locale support is installed +- name: ensure locale support is installed (Debian) apt: name: locales state: present + when: is_debian + tags: + - locale + +- name: ensure locale support is installed (RHEL) + dnf: + name: langpacks-{{ item }} + state: present + loop: >- + {{ localization_enabled_locales|map('split', '_')|map('first')|unique }} + when: is_rhel tags: - locale @@ -12,19 +23,33 @@ name: "{{ item }}.UTF-8" state: present with_items: "{{ localization_enabled_locales }}" + when: is_debian tags: - locale - name: ensure our default locale is default copy: src: "{{ localization_locale }}" - dest: /etc/default/locale + dest: >- + {%- if is_debian|default(true) -%} + /etc/default/locale + {%- elif is_rhel -%} + /etc/locale.conf + {%- endif -%} owner: root group: root mode: '0644' tags: - locale +- name: Install console keymaps + dnf: + name: kbd-legacy + state: present + when: is_rhel + tags: + - locale + - name: ensure our vconsole config is present copy: src: "{{ localization_vconsole }}" diff --git a/localization/tasks/timesyncd.yml b/localization/tasks/timesyncd.yml index 0dfa012..c4cadeb 100644 --- a/localization/tasks/timesyncd.yml +++ b/localization/tasks/timesyncd.yml @@ -6,6 +6,25 @@ name: ntp state: absent purge: true + when: is_debian + tags: + - timesyncd + +- name: Remove chrony + dnf: + name: chrony + state: absent + when: is_rhel + notify: + - stop chronyd + tags: + - timesyncd + +- name: Install timesyncd + dnf: + name: systemd-timesyncd + state: present + when: is_rhel tags: - timesyncd diff --git a/localization/tasks/timezone.yml b/localization/tasks/timezone.yml index 0955d88..a0af095 100644 --- a/localization/tasks/timezone.yml +++ b/localization/tasks/timezone.yml @@ -12,6 +12,7 @@ - "{{ localization_timezone.split('/') }}" notify: - update timezone + when: is_debian tags: - timezone @@ -28,6 +29,7 @@ mode: '0644' notify: - update timezone + when: is_debian tags: - timezone diff --git a/localization/templates/timesyncd.conf.j2 b/localization/templates/timesyncd.conf.j2 index 37fdf3a..2104875 100644 --- a/localization/templates/timesyncd.conf.j2 +++ b/localization/templates/timesyncd.conf.j2 @@ -13,4 +13,8 @@ [Time] NTP={{ ntpservers|join(' ') }} +{% if is_debian %} FallbackNTP=0.debian.pool.ntp.org 1.debian.pool.ntp.org 2.debian.pool.ntp.org 3.debian.pool.ntp.org +{% elif is_rhel %} +FallbackNTP=0.rhel.pool.ntp.org 1.rhel.pool.ntp.org 2.rhel.pool.ntp.org 3.rhel.pool.ntp.org +{% endif %} -- GitLab