Skip to content

Commit

Permalink
Update timezone to 0b3e3f06c7c3c4e4ab571666cceb7f4779e69856
Browse files Browse the repository at this point in the history
0b3e3f06c7c3c4e4ab571666cceb7f4779e69856 new release v3.2.0
ddc989773f4cc4c17d1e8d1fb6137ae611288061 Merge branch 'blake-freebsd-support'
1f9eb2611e278e9a5aec47561f6274442663e9eb Merge branch 'freebsd-support' of https://github.com/blake/puppet-timezone into blake-freebsd-support
29b74bf3a83571c699f0cf465034adf929bd85f4 Merge pull request #20 from apitalent/master
58c0696163440ab3dc01060bad684aa5b74e62a9 Merge pull request #18 from gerapeldoorn/master
5aae6a23c2339f1c7a325171f64f4b8efcc4c2a6 Merge pull request #17 from jlambert121/issue_14
10974344d1733e250fe0b11194f84b375e089418 Merge pull request #16 from jlambert121/rhel7
706cef09d854dd6f8a8fd01b97f8703efcb5a777 Merge pull request #1 from apitalent/lindsay-apitalent-patch-1
5e8053909c4308a15bab29390f08d111e024ce8b Update params.pp
36c0824219db044d71281eca0f58f1f6b248ca62 Add FreeBSD support
4e0154f1871b7ff63d24f5dd8be8a3cd27aee092 Update init.pp
f93889526ec8ba0dcb38304cfeb007f161eee7f1 Update clock.erb
0d30bd557054366276b73edb6c76742be3ec59da Added hwutc option
feeedb5f22cc09e617f73dd93070a54bcec99ca3 added docs
0d1393d47eaedfccba12655dd508c8f73bfefea8 Added parameter $hwutc to specify if the hardware clock is UTC
2e218cf468014519337671e75af3228a9d3f5ad4 add managed by puppet comment in templates
8e4152ced754cacc9619b11d8b32a650cf36293f RHEL7-based systems don't use /etc/sysconfig/clock
  • Loading branch information
xbezdick committed Apr 2, 2015
1 parent 0d41350 commit 96ce712
Show file tree
Hide file tree
Showing 11 changed files with 94 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Puppetfile
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ mod 'tempest',
:git => 'https://github.com/stackforge/puppet-tempest.git'

mod 'timezone',
:commit => 'e82cd1b32f395217056df492e5a7dac8dc5c683a',
:commit => '0b3e3f06c7c3c4e4ab571666cceb7f4779e69856',
:git => 'https://github.com/saz/puppet-timezone.git'

mod 'tripleo',
Expand Down
17 changes: 12 additions & 5 deletions timezone/manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
# Only set this, if your platform is not supported or you know, what you're doing.
# Default: auto-set, platform specific
#
# [*hwutc*]
# Is the hardware clock set to UTC? (true or false)
# Default: undefined
#
# Actions:
# Installs tzdata and configures timezone
#
Expand All @@ -45,6 +49,7 @@
class timezone (
$ensure = 'present',
$timezone = 'UTC',
$hwutc = '',
$autoupgrade = false
) inherits timezone::params {

Expand All @@ -71,8 +76,11 @@
}
}

package { $timezone::params::package:
ensure => $package_ensure,
if $timezone::params::package {
package { $timezone::params::package:
ensure => $package_ensure,
before => File[$timezone::params::localtime_file],
}
}

if $timezone::params::timezone_file != false {
Expand All @@ -95,8 +103,7 @@
}

file { $timezone::params::localtime_file:
ensure => $localtime_ensure,
target => "${timezone::params::zoneinfo_dir}${timezone}",
require => Package[$timezone::params::package],
ensure => $localtime_ensure,
target => "${timezone::params::zoneinfo_dir}${timezone}",
}
}
17 changes: 15 additions & 2 deletions timezone/manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,18 @@
$timezone_file_template = 'timezone/timezone.erb'
$timezone_update = 'dpkg-reconfigure -f noninteractive tzdata'
}
'RedHat': {
'RedHat', 'Linux': {
$package = 'tzdata'
$zoneinfo_dir = '/usr/share/zoneinfo/'
$localtime_file = '/etc/localtime'
$timezone_file = '/etc/sysconfig/clock'
case $::operatingsystemmajrelease {
'7': {
$timezone_file = false
}
default: {
$timezone_file = '/etc/sysconfig/clock'
}
}
$timezone_file_template = 'timezone/clock.erb'
$timezone_update = false
}
Expand All @@ -42,6 +49,12 @@
$timezone_file = false
$timezone_update = 'zic -l '
}
'FreeBSD': {
$package = undef
$zoneinfo_dir = '/usr/share/zoneinfo/'
$localtime_file = '/etc/localtime'
$timezone_file = false
}
default: {
case $::operatingsystem {
default: {
Expand Down
2 changes: 1 addition & 1 deletion timezone/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
}
],
"name": "saz-timezone",
"version": "3.1.1",
"version": "3.2.0",
"source": "git://github.com/saz/puppet-timezone",
"author": "saz",
"license": "Apache License, Version 2.0",
Expand Down
2 changes: 1 addition & 1 deletion timezone/spec/classes/timezone_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'spec_helper'

describe 'timezone' do
['Debian','RedHat','Gentoo'].each do |osfamily|
['Debian','RedHat','Gentoo','FreeBSD'].each do |osfamily|
describe "on supported osfamily: #{osfamily}" do
include_examples osfamily
end
Expand Down
8 changes: 6 additions & 2 deletions timezone/spec/support/debian.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@
it { should create_class('timezone') }
it { should contain_class('timezone::params') }

it { should contain_package('tzdata').with_ensure('present') }
it do
should contain_package('tzdata').with({
:ensure => 'present',
:before => "File[/etc/localtime]",
})
end

it { should contain_file('/etc/timezone').with_ensure('file') }
it { should contain_file('/etc/timezone').with_content(/^UTC$/) }
Expand All @@ -17,7 +22,6 @@
should contain_file('/etc/localtime').with({
:ensure => 'link',
:target => '/usr/share/zoneinfo/UTC',
:require => "Package[tzdata]",
})
end

Expand Down
34 changes: 34 additions & 0 deletions timezone/spec/support/freebsd.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
shared_examples 'FreeBSD' do
let(:facts) {{ :osfamily => "FreeBSD" }}

describe "when using default class parameters" do
let(:params) {{ }}

it { should create_class('timezone') }
it { should contain_class('timezone::params') }

it do
should contain_file('/etc/localtime').with({
:ensure => 'link',
:target => '/usr/share/zoneinfo/UTC',
})
end

context 'when timezone => "Europe/Berlin"' do
let(:params) {{ :timezone => "Europe/Berlin" }}

it { should contain_file('/etc/localtime').with_target('/usr/share/zoneinfo/Europe/Berlin') }
end

context 'when autoupgrade => true' do
let(:params) {{ :autoupgrade => true }}
end

context 'when ensure => absent' do
let(:params) {{ :ensure => 'absent' }}
it { should contain_file('/etc/localtime').with_ensure('absent') }
end

include_examples 'validate parameters'
end
end
8 changes: 6 additions & 2 deletions timezone/spec/support/gentoo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@
it { should create_class('timezone') }
it { should contain_class('timezone::params') }

it { should contain_package('sys-libs/timezone-data').with_ensure('present') }
it do
should contain_package('sys-libs/timezone-data').with({
:ensure => 'present',
:before => 'File[/etc/localtime]',
})
end

it { should contain_file('/etc/timezone').with_ensure('file') }
it { should contain_file('/etc/timezone').with_content(/^UTC$/) }
Expand All @@ -16,7 +21,6 @@
should contain_file('/etc/localtime').with({
:ensure => 'link',
:target => '/usr/share/zoneinfo/UTC',
:require => "Package[sys-libs/timezone-data]",
})
end

Expand Down
16 changes: 13 additions & 3 deletions timezone/spec/support/redhat.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
shared_examples 'RedHat' do
let(:facts) {{ :osfamily => "RedHat" }}
let(:facts) {{ :osfamily => "RedHat", :operatingsystemmajrelease => '6' }}

describe "when using default class parameters" do
let(:params) {{ }}

it { should create_class('timezone') }
it { should contain_class('timezone::params') }

it { should contain_package('tzdata').with_ensure('present') }
it do
should contain_package('tzdata').with({
:ensure => 'present',
:before => 'File[/etc/localtime]',
})
end


it { should contain_file('/etc/sysconfig/clock').with_ensure('file') }
it { should contain_file('/etc/sysconfig/clock').with_content(/^ZONE="UTC"$/) }
Expand All @@ -17,7 +23,6 @@
should contain_file('/etc/localtime').with({
:ensure => 'link',
:target => '/usr/share/zoneinfo/UTC',
:require => "Package[tzdata]",
})
end

Expand All @@ -40,6 +45,11 @@
it { should contain_file('/etc/localtime').with_ensure('absent') }
end

context 'when RHEL 7' do
let(:facts) {{ :osfamily => "RedHat", :operatingsystemmajrelease => '7' }}
it { should_not contain_file('/etc/sysconfig/clock').with_ensure('file') }
end

include_examples 'validate parameters'
end
end
4 changes: 4 additions & 0 deletions timezone/templates/clock.erb
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
# Managed by puppet - do not modify
ZONE="<%= @timezone %>"
<% if [email protected]? -%>
UTC=<%= @hwutc %>
<% end -%>
1 change: 1 addition & 0 deletions timezone/templates/timezone.erb
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
# Managed by puppet - do not modify
<%= @timezone %>

0 comments on commit 96ce712

Please sign in to comment.