zester
GuidesModules

timezone

The timezone.* family of state modules.

ModuleSummary
timezone.systemEnsure the system timezone is set to a desired value.

All states also accept the full set of requisite parameters and Salt-parity state attributes — see Dependencies & Requisites.


timezone.system

Ensure the system timezone is set to a desired value.

Source: pkg/state/modules/timezone/timezone_system.go


timezone.system ensures the system timezone (name, defaulting to the state ID) is set. It uses timedatectl as the primary mechanism, falling back to writing /etc/timezone and invoking dpkg-reconfigure on systems without it (non-systemd). utc additionally sets the hardware clock to UTC.


Parameters

ParameterTypeRequiredDefaultDescription
namestringNoState IDdesired timezone (e.g. America/New_York, UTC); defaults to the state ID
utcboolNo(none)set the hardware clock to UTC (timedatectl set-local-rtc 0); a boolean that also accepts the integers 1 (true) and 0 (false)

Effects

Check

Reads the current timezone via timedatectl show --property=Timezone --value, falling back to /etc/timezone when timedatectl fails or is unavailable. Reports a change when the current value does not match name.

Apply

Reads and remembers the current timezone (for Revert), then runs timedatectl set-timezone <name>. If that fails, it writes <name> to /etc/timezone and runs dpkg-reconfigure -f noninteractive tzdata instead. When utc is set, it additionally runs timedatectl set-local-rtc 0. Reports the timezone and its previous value in its details.

Revert

Restores the timezone that was active immediately before this run's Apply, via timedatectl set-timezone <previous>. If Apply was never called on this instance the previous timezone is unknown, and Revert is an explicit no-op rather than a guess.


Examples

Set the timezone to UTC

The timezone defaults to the state ID.

UTC:
  timezone.system: []

Set a regional timezone and sync the hardware clock

utc: true additionally sets the hardware clock to UTC.

America/Chicago:
  timezone.system:
    - utc: true
    - require:
      - pkg.installed:tzdata

Use an explicit name parameter

name overrides the state ID as the desired timezone.

system-timezone:
  timezone.system:
    - name: Europe/Berlin

Set the timezone ad hoc

The bare positional argument is the timezone string.

zester '*' timezone.system America/New_York

On this page