Skip to content
Snippets Groups Projects
Commit 7f4b91cf authored by Chris Croome's avatar Chris Croome
Browse files

Add TZ variable

parent 47b0b75b
No related branches found
Tags 1.2.0
No related merge requests found
Pipeline #24527 passed
......@@ -16,6 +16,10 @@ Set the `systemd` variable to `false` to prevent any tasks in this role being ru
When the `systemd_timesyncd_reboot` variable is set to `true` servers which have incorrect clocks will be rebooted by this role in order to correct their clocks, it defaults to `false`.
### systemd_tz
The time zone to be used (the hardware clock is set to UTC), for example `Europe/London`, it defaults to `Etc/UTC`.
### systemd_units
A list of systemd units to configure, for example:
......
---
systemd: true
systemd_timesyncd_reboot: false
systemd_tz: Etc/UTC
systemd_units:
- name: systemd-timesyncd
files:
......
......@@ -70,4 +70,8 @@ argument_specs:
type: bool
required: false
description: Reboot if the clock is not synced with time servers.
systemd_tz:
type: str
required: true
description: The timezone for the clock to be set to.
...
......@@ -42,12 +42,24 @@
- name: Set a variable for the timedatectl status dictionary
ansible.builtin.set_fact:
systemd_timedatectl_status: "{{ systemd_timedatectl_status_command.stdout | community.general.jc('timedatectl') }}"
systemd_timedatectl_tz: "{{ (systemd_timedatectl_status_command.stdout | community.general.jc('timedatectl') | community.general.json_query('time_zone') | ansible.builtin.split(' '))[0] }}"
- name: Debug the timedatectl status
ansible.builtin.debug:
var: systemd_timedatectl_status
verbosity: 2
- name: Debug the timedatectl tz
ansible.builtin.debug:
var: systemd_timedatectl_tz
verbosity: 2
- name: Set the timezone
community.general.timezone:
name: "{{ systemd_tz }}"
hwclock: UTC
when: systemd_timedatectl_tz != systemd_tz
- name: Set the time if not synchronized
block:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment