From 2561351b918b9ae1e6c5cec90522a892206d2209 Mon Sep 17 00:00:00 2001 From: Kyr Shatskyy Date: Thu, 3 Apr 2025 19:11:17 +0200 Subject: [PATCH] roles/common: use timedatectl to set timezone for apt too Overwriting of /etc/timezone with new time zone and calling: dpkg-reconfigure --frontend noninteractive tzdata does not work. Just use timedatectl same as for all modern systems. Signed-off-by: Kyr Shatskyy --- roles/common/tasks/apt_systems.yml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/roles/common/tasks/apt_systems.yml b/roles/common/tasks/apt_systems.yml index 19449b9..824b133 100644 --- a/roles/common/tasks/apt_systems.yml +++ b/roles/common/tasks/apt_systems.yml @@ -6,6 +6,14 @@ tags: - timezone +- name: Set the timezone for apt systems + command: timedatectl set-timezone {{ timezone }} + when: + - current_tz.stdout|default("") != timezone + - ansible_distribution_major_version|int >= 20 + tags: + - timezone + - name: Set the timezone in /etc/timezone copy: content: "{{ timezone }}" @@ -14,14 +22,18 @@ group: root mode: 0644 # Default is used below to avoid breaking check mode - when: current_tz.stdout|default("") != timezone + when: + - current_tz.stdout|default("") != timezone + - ansible_distribution_major_version|int < 20 register: etc_timezone tags: - timezone - name: Inform the OS of the new timezone command: dpkg-reconfigure --frontend noninteractive tzdata - when: etc_timezone is changed + when: + - etc_timezone is changed + - ansible_distribution_major_version|int < 20 tags: - timezone -- 2.39.5