W3cubDocs

/Ansible 2.9

timezone – Configure timezone setting

Synopsis

  • 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 service module.
  • It is recommended to restart crond after 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 timedatectl or edit /etc/sysconfig/clock or /etc/timezone and hwclock. On SmartOS, sm-set-timezone, for macOS, systemsetup, for BSD, /etc/localtime is modified. On AIX, chtz is used.
  • 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.

Parameters

Parameter Choices/Defaults Comments
hwclock
string
    Choices:
  • local
  • UTC
Whether the hardware clock is in UTC or in local timezone.
Default is to keep current setting.
Note that this option is recommended not to change and may fail to configure, especially on virtual environments such as AWS.
At least one of name and hwclock are required.
Only used on Linux.

aliases: rtc
name
string
Name of the timezone for the system clock.
Default is to keep current setting.
At least one of name and hwclock are required.

Notes

Note

  • On SmartOS the sm-set-timezone utility (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.

Examples

- name: Set timezone to Asia/Tokyo
  timezone:
    name: Asia/Tokyo

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key Returned Description
diff
complex
success
The differences about the given arguments.

after
dictionary
The values after change

before
dictionary
The values before change



Status

Authors

  • Shinichi TAMURA (@tmshn)
  • Jasper Lievisse Adriaanse (@jasperla)
  • Indrajit Raychaudhuri (@indrajitr)

Hint

If you notice any issues in this documentation, you can edit this document to improve it.

© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.9/modules/timezone_module.html