Skip to content

Commit

Permalink
timedatactrl
Browse files Browse the repository at this point in the history
  • Loading branch information
jordiprats committed Apr 25, 2017
1 parent 10eece5 commit f0b1045
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 8 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# CHANGELOG

## 0.1.3

* timedatectl support (CentOS 7)
22 changes: 16 additions & 6 deletions manifests/config.pp
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
class timezone::config inherits timezone {

file { '/etc/localtime':
source => "file:///usr/share/zoneinfo/${timezone::region}/${timezone::locality}",
links => 'follow',
replace => true,
mode => '0644',
if($timezone::params::timedatectl)
{
exec { 'set timezone':
command => "timedatectl set-timezone ${timezone::region}/${timezone::locality}",
unless => "timedatectl status | grep \"Time zone: ${timezone::region}/${timezone::locality}\"",
path => '/usr/sbin:/usr/bin:/sbin:/bin',
}
}
else
{
file { '/etc/localtime':
source => "file:///usr/share/zoneinfo/${timezone::region}/${timezone::locality}",
links => 'follow',
replace => true,
mode => '0644',
}
}

}
8 changes: 7 additions & 1 deletion manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@
{
case $::operatingsystemrelease
{
/^[5-7].*$/:
/^[5-6].*$/:
{
$timezonectl=false
}
/^7.*$/:
{
$timezonectl=true
}
default: { fail("Unsupported RHEL/CentOS version! - ${::operatingsystemrelease}") }
}
Expand All @@ -24,6 +29,7 @@
{
/^1[46].*$/:
{
$timezonectl=false
}
default: { fail("Unsupported Ubuntu version! - ${::operatingsystemrelease}") }
}
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eyp-timezone",
"version": "0.1.2",
"version": "0.1.3",
"author": "eyp",
"summary": "sets timezone",
"license": "Apache-2.0",
Expand Down

0 comments on commit f0b1045

Please sign in to comment.