diff --git a/localization/defaults/main.yml b/localization/defaults/main.yml index de8cd0ff394401d31f6a07768253bb2a0a346f25..128eec56d0865f018f34170b6ef1e23889bffd50 100644 --- a/localization/defaults/main.yml +++ b/localization/defaults/main.yml @@ -8,3 +8,5 @@ localization_locale: locales/en localization_vconsole: vconsole.conf localization_prefer_timesyncd: False + +localization_timezone: Europe/Berlin diff --git a/localization/tasks/main.yml b/localization/tasks/main.yml index 6d54dbc1393834b546cb7a25ce6b644ddcdbfb0d..41a1cc7abec9eacc2da9120adf0f24811ed40939 100644 --- a/localization/tasks/main.yml +++ b/localization/tasks/main.yml @@ -3,22 +3,13 @@ - include: locale.yml - meta: flush_handlers -- name: ensure correct timezone setting - debconf: - name: tzdata - question: "{{ item.0 }}" - value: "{{ item.1 }}" - vtype: select - with_together: - - "{{ ['tzdata/Zones/Europe', 'tzdata/Areas'] }}" - - "{{ ['Berlin', 'Europe'] }}" - notify: - - update timezone - tags: - - timezone +- include: timezone.yml +- meta: flush_handlers - include: ntpd.yml when: not localization_prefer_timesyncd + - include: timesyncd.yml when: localization_prefer_timesyncd + - meta: flush_handlers diff --git a/localization/tasks/timezone.yml b/localization/tasks/timezone.yml new file mode 100644 index 0000000000000000000000000000000000000000..08cd45544e7d6c30801fc48d0a092080ab5fa9c6 --- /dev/null +++ b/localization/tasks/timezone.yml @@ -0,0 +1,42 @@ +--- + +- name: ensure correct timezone setting + debconf: + name: tzdata + question: "{{ item.0 }}" + value: "{{ item.1 }}" + vtype: select + with_together: + - "{{ ['tzdata/Areas', 'tzdata/Zones/'~localization_timezone.split('/')[0]] }}" + - "{{ localization_timezone.split('/') }}" + notify: + - update timezone + tags: + - timezone + +## see: https://github.com/debops/ansible-ntp/blob/master/tasks/timezone.yml +# tzdata ignores debconf answers when configured non-interactively +# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=704089 + +- name: ensure correct timezone setting in /etc/timezone + copy: + content: "{{ localization_timezone }}\n" + dest: /etc/timezone + owner: root + group: root + mode: 0644 + notify: + - update timezone + tags: + - timezone + +- name: ensure correct timezone link by /etc/localtime + file: + path: /etc/localtime + src: "/usr/share/zoneinfo/{{ localization_timezone }}" + state: link + notify: + - update timezone + tags: + - timezone +