/etc/localtime on its own doesn't cause the hardware clock to be reset
(at least immediately). So, do that.
Signed-off-by: Zack Cerza <zack@redhat.com>
tags:
- timezone
-- name: Set the timezone (RHEL/CentOS 6)
+- name: Set /etc/localtime (RHEL/CentOS 6)
file:
src: /usr/share/zoneinfo/{{ timezone }}
dest: /etc/localtime
tags:
- timezone
+- name: Set the hardware clock (RHEL/CentOS 6)
+ command: hwclock --systohc
+ when: ansible_distribution_major_version == "6" and current_tz.stdout|default("") != timezone
+ tags:
+ - timezone
+
- name: Set the timezone (RHEL/CentOS 7)
command: timedatectl set-timezone {{ timezone }}
# Default is used below to avoid breaking check mode