community.general.timezone – Configure timezone setting¶
This plugin is part of the community.general collection.
To install it use:
ansible-galaxy collection install community.general.
To use it in a playbook, specify:
This module configures the timezone setting, both of the system clock and of the hardware clock. If you want to set up the NTP, use ansible.builtin.service module.
It is recommended to restart
crondafter changing the timezone, otherwise the jobs may run at the wrong time.
Several different tools are used depending on the OS/Distribution involved. For Linux it can use
hwclock. On SmartOS,
sm-set-timezone, for macOS,
systemsetup, for BSD,
/etc/localtimeis modified. On AIX,
As of Ansible 2.3 support was added for SmartOS and BSDs.
As of Ansible 2.4 support was added for macOS.
As of Ansible 2.9 support was added for AIX 6.1+
Windows and HPUX are not supported, please let us know if you find any other OS/distro in which this fails.
On SmartOS the
sm-set-timezoneutility (part of the smtools package) is required to set the zone timezone
On AIX only Olson/tz database timezones are useable (POSIX is not supported). - An OS reboot is also required on AIX for the new timezone setting to take effect.