From 867873cd4167abfbdf3a70650671e92fa6139024 Mon Sep 17 00:00:00 2001 From: Jordi Prats Date: Tue, 18 Jul 2017 12:04:30 +0200 Subject: [PATCH 1/3] timezonename per UTC --- CHANGELOG.md | 4 ++++ manifests/config.pp | 21 ++++++++++++++++++--- manifests/init.pp | 11 ++++++----- metadata.json | 6 +++--- 4 files changed, 31 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7431e5e..0db7260 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## 0.1.4 + +* added support to be able to set timezone by name (for example, UTC) + ## 0.1.3 * timedatectl support (CentOS 7) diff --git a/manifests/config.pp b/manifests/config.pp index dd6c947..d23e4cc 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -1,17 +1,32 @@ class timezone::config inherits timezone { + if($timezone::timezonenam!=undef) + { + $tzctl_command = "timedatectl set-timezone ${timezone::timezonename}" + $tzctl_unless = "timedatectl status | grep \"Time zone: ${timezone::timezonename}\"" + + $file_ln_tz = "file:///usr/share/zoneinfo/${timezone::timezonename}" + } + else + { + $tzctl_command = "timedatectl set-timezone ${timezone::region}/${timezone::locality}" + $tzctl_unless = "timedatectl status | grep \"Time zone: ${timezone::region}/${timezone::locality}\"" + + $file_ln_tz = "file:///usr/share/zoneinfo/${timezone::region}/${timezone::locality}" + } + if($timezone::params::timedatectl) { exec { 'set timezone - timedatectl': - command => "timedatectl set-timezone ${timezone::region}/${timezone::locality}", - unless => "timedatectl status | grep \"Time zone: ${timezone::region}/${timezone::locality}\"", + command => $tzctl_command, + unless => $tzctl_unless, path => '/usr/sbin:/usr/bin:/sbin:/bin', } } else { file { '/etc/localtime': - source => "file:///usr/share/zoneinfo/${timezone::region}/${timezone::locality}", + source => $file_ln_tz, links => 'follow', replace => true, mode => '0644', diff --git a/manifests/init.pp b/manifests/init.pp index 120c98e..876057f 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,9 +1,10 @@ class timezone( - $manage_package = true, - $package_ensure = 'installed', - $region = 'Europe', - $locality = 'Andorra', - ) inherits timezone::params { + $manage_package = true, + $package_ensure = 'installed', + $region = 'Europe', + $locality = 'Andorra', + $timezonename = undef, + ) inherits timezone::params { class { '::timezone::install': } -> class { '::timezone::config': } diff --git a/metadata.json b/metadata.json index 0b893b9..bbfa8e9 100644 --- a/metadata.json +++ b/metadata.json @@ -1,14 +1,14 @@ { "name": "eyp-timezone", - "version": "0.1.3", + "version": "0.1.4", "author": "eyp", "summary": "sets timezone", "license": "Apache-2.0", "source": "https://github.com/NTTCom-MS/eyp-timezone", - "project_page": null, + "project_page": "https://github.com/NTTCom-MS/eyp-timezone", "issues_url": "https://github.com/NTTCom-MS/eyp-timezone/issues", "dependencies": [ - {"name":"puppetlabs/stdlib","version_requirement":">= 1.0.0"}, + {"name":"puppetlabs/stdlib","version_requirement":">= 1.0.0 < 9.9.9"}, {"name":"eyp/eyplib","version_requirement":">= 0.1.0 < 0.2.0"} ], "operatingsystem_support": [ From 63a0c0f508f4e363e1518a9d3b1d589c06372f97 Mon Sep 17 00:00:00 2001 From: Jordi Prats Date: Tue, 18 Jul 2017 12:06:54 +0200 Subject: [PATCH 2/3] typo --- manifests/config.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/config.pp b/manifests/config.pp index d23e4cc..1dfde60 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -1,6 +1,6 @@ class timezone::config inherits timezone { - if($timezone::timezonenam!=undef) + if($timezone::timezonename!=undef) { $tzctl_command = "timedatectl set-timezone ${timezone::timezonename}" $tzctl_unless = "timedatectl status | grep \"Time zone: ${timezone::timezonename}\"" From 44593419cf40d370ea7149a360bae799a12ccf2f Mon Sep 17 00:00:00 2001 From: Jordi Prats Date: Tue, 18 Jul 2017 12:12:36 +0200 Subject: [PATCH 3/3] docs --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 65a62b6..8f38782 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,14 @@ class { 'timezone': } ``` +Set UTC: + +``` +class { 'timezone': + timezonename => 'UTC', +} +``` + ## Usage It just sets localtime to the appropriate timezone, it doesn't do much fancy stuff. @@ -52,6 +60,7 @@ It just sets localtime to the appropriate timezone, it doesn't do much fancy stu ### timezone * **region**: region to be used (default: **Europe**) * **locality**: locality to be used (default: **Andorra**) +* **timezonename**: timezone to set, if it is defined, overrides **region** and **locality** * **manage_package**: manage package, usually it's called tzdata (default: **true**) * **package_ensure**: package's ensure (default: **installed**)