Puppet Class: timezone

Defined in:
manifests/init.pp

Summary

This module manages the system's default timezone setting.

Overview

Examples:

Declaring the class

include timezone

Parameters:

  • timezone (String) (defaults to: 'UTC')

    The systems default timezone, e.g. ‘UTC’ or ‘Europe/Berlin’. See ‘/usr/share/zoneinfo` for available values.

  • hwclock_utc (Optional[Boolean]) (defaults to: undef)

    Optional boolean value indicating if the system’s hardware clock is UTC (true) or localtime (false). This value is only used on EL 6. If set to ‘undef` the `UTC` setting will not be present in `/etc/sysconfig/clock`.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'manifests/init.pp', line 15

class timezone (
  String            $timezone    = 'UTC',
  Optional[Boolean] $hwclock_utc = undef,
) {

  $tzdata = "/usr/share/zoneinfo/${timezone}"

  file { '/etc/localtime':
    ensure => link,
    target => $tzdata,
  }

  case $facts['os']['family'] {
    'RedHat': {


      if $facts['os']['release']['major'] == '6' {
        file { '/etc/sysconfig/clock':
          owner   => 'root',
          group   => 'root',
          mode    => '0644',
          content => template('timezone/clock.erb'),
        }
      }
    }
    'Debian': {

      file { '/etc/timezone':
        owner   => 'root',
        group   => 'root',
        mode    => '0644',
        content => "${timezone}\n",
      }
    }
    default: {
      fail("Detected os.family <${facts['os']['family']}> is not supported.")
    }
  }
}