Timezone Recipe

Problem: inconsistent timezone information

Custom installations and grow servers tend to have inconsistent ideas about time zone information. Having different time zones creates problems when cooperating or correlating events from logfiles.

Solution

NOTE: This has been tested in Debian. Do other distro’s tzdata as the package?

class timezone {
    package { "tzdata":
        ensure => installed
    }
}

class timezone::central inherits timezone {
    file { "/etc/localtime":
        require => Package["tzdata"],
        source => "file:///usr/share/zoneinfo/US/Central",
    }
}

class timezone::eastern inherits timezone {
    file { "/etc/localtime":
        require => Package["tzdata"],
        source => "file:///usr/share/zoneinfo/US/Eastern"
    }
}

class timezone::pacific inherits timezone {
    file { "/etc/localtime":
        require => Package["tzdata"],
        source => "file:///usr/share/zoneinfo/US/Pacific"
    }
}

class timezone::mountain inherits timezone {
    file { "/etc/localtime":
        require => Package["tzdata"],
        source =>
             "file:///usr/share/zoneinfo/US/Mountain"
    }
}

Solution (old)

I had problems with this solution — apologies to original poster if it was my issue—drmikecrowe

Use puppet to maintain consistent timezone information on your servers.

class timezone-base {
    package { "tzdata":
        ensure => installed
    }

    file { "/etc/localtime":
        source => "file:///usr/share/zoneinfo/US/Central",
        require => Package["tzdata"]
    }
}

class timezone-central inherits timezone-base {

}

class timezone-eastern inherits timezone-base {
    File["/etc/localtime"] {
        source => "file:///usr/share/zoneinfo/US/Central"
    }
}

node twincities {
     include timezone-central
}

node newyork {
     include timezone-eastern
}

Discussion