Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9696700
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Subscribers
None
View Options
diff --git a/data/os/Debian.yaml b/data/os/Debian.yaml
index 3b11eaa..e48e2cc 100644
--- a/data/os/Debian.yaml
+++ b/data/os/Debian.yaml
@@ -1,8 +1,9 @@
---
timezone::package: tzdata
timezone::zoneinfo_dir: /usr/share/zoneinfo
timezone::localtime_file: /etc/localtime
timezone::timezone_file: /etc/timezone
timezone::timezone_file_template: timezone/timezone.erb
timezone::timezone_file_supports_comment: false
timezone::timezone_update: dpkg-reconfigure -f noninteractive tzdata
+timezone::use_debconf: true
diff --git a/manifests/init.pp b/manifests/init.pp
index 7a54284..04a04ac 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -1,150 +1,151 @@
# This module manages timezone settings
#
# @param timezone
# The name of the timezone.
#
# @param ensure
# Ensure if present or absent.
#
# @param autoupgrade
# Upgrade package automatically, if there is a newer version.
#
# @param package
# Name of the package.
# Only set this, if your platform is not supported or you know, what you're doing.
#
# @param config_file
# Main configuration file.
# Only set this, if your platform is not supported or you know, what you're doing.
#
# @param zoneinfo_dir
# Source directory of zoneinfo files.
# Only set this, if your platform is not supported or you know, what you're doing.
# Default: auto-set, platform specific
#
# @param hwutc
# Is the hardware clock set to UTC? (true or false)
#
# @param notify_services
# List of services to notify
#
# @example
# class { 'timezone':
# timezone => 'Europe/Berlin',
# }
#
class timezone (
String $timezone = 'Etc/UTC',
Enum['present','absent'] $ensure = 'present',
Optional[Boolean] $hwutc = undef,
Boolean $autoupgrade = false,
Optional[Array[String]] $notify_services = undef,
Optional[String] $package = undef,
String $zoneinfo_dir = '/usr/share/zoneinfo/',
String $localtime_file = '/etc/localtime',
Optional[String] $timezone_file = undef,
Optional[String] $timezone_file_template = 'timezone/clock.erb',
Optional[Boolean] $timezone_file_supports_comment = undef,
Optional[String] $timezone_update = undef
) {
case $ensure {
/(present)/: {
if $autoupgrade == true {
$package_ensure = 'latest'
} else {
$package_ensure = 'present'
}
$localtime_ensure = 'file'
$timezone_ensure = 'file'
}
/(absent)/: {
# Leave package installed, as it is a system dependency
$package_ensure = 'present'
$localtime_ensure = 'absent'
$timezone_ensure = 'absent'
}
default: {
fail('ensure parameter must be present or absent')
}
}
if $package {
- if $package_ensure == 'present' and $facts['os']['family'] == 'Debian' {
+ $use_debconf = lookup('timezone::use_debconf', Boolean, 'first', false)
+ if $package_ensure == 'present' and $use_debconf {
$_tz = split($timezone, '/')
$area = $_tz[0]
$zone = $_tz[1]
debconf {
'tzdata/Areas':
package => 'tzdata',
item => 'tzdata/Areas',
type => 'select',
value => $area;
"tzdata/Zones/${area}":
package => 'tzdata',
item => "tzdata/Zones/${area}",
type => 'select',
value => $zone;
}
-> Package[$package]
}
package { $package:
ensure => $package_ensure,
before => File[$localtime_file],
}
}
if $timezone_file {
file { $timezone_file:
ensure => $timezone_ensure,
content => template($timezone_file_template),
notify => $notify_services,
}
if $ensure == 'present' and $timezone_update {
exec { 'update_timezone':
command => sprintf($timezone_update, $timezone),
subscribe => File[$timezone_file],
refreshonly => true,
path => '/usr/bin:/usr/sbin:/bin:/sbin',
}
}
} else {
if $ensure == 'present' and $timezone_update {
$unless_cmd = lookup('timezone::timezone_update_check_cmd', String, 'first')
exec { 'update_timezone':
command => sprintf($timezone_update, $timezone),
unless => sprintf($unless_cmd, $timezone),
path => '/usr/bin:/usr/sbin:/bin:/sbin',
}
}
}
if $ensure == 'present' and $hwutc != undef {
$hwclock_cmd = lookup('timezone::hwclock_cmd', Optional[String], 'first', undef)
$hwclock_check_enabled_cmd = lookup('timezone::check_hwclock_enabled_cmd', Optional[String], 'first', undef)
$hwclock_check_disabled_cmd = lookup('timezone::check_hwclock_disabled_cmd', Optional[String], 'first', undef)
if $hwclock_cmd != '' and $hwclock_cmd != undef {
if ! $hwutc {
$hwclock_unless = $hwclock_check_enabled_cmd
} else {
$hwclock_unless = $hwclock_check_disabled_cmd
}
exec { 'set_hwclock':
command => sprintf($hwclock_cmd, (! $hwutc)),
unless => $hwclock_unless,
path => '/usr/bin:/usr/sbin:/bin:/sbin',
}
}
}
file { $localtime_file:
ensure => $localtime_ensure,
source => "file://${zoneinfo_dir}/${timezone}",
links => follow,
notify => $notify_services,
}
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Mon, Aug 18, 9:05 PM (4 h, 41 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3312359
Attached To
rSPTZ Manage timezone settings via Puppet
Event Timeline
Log In to Comment