Skip to content

Commit

Permalink
Merge pull request #6 from jordiprats/master
Browse files Browse the repository at this point in the history
suport timedatectl
  • Loading branch information
jordiprats authored Apr 28, 2017
2 parents 6695c42 + c9c1a5b commit 56f4d52
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 30 deletions.
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,8 @@ matrix:
dist: trusty
bundler_args:
script: sudo service docker restart ; sleep 10 && bundle exec rspec spec/acceptance/*_spec.rb
- rvm: default
env: BEAKER_set="ubuntu16-docker"
dist: trusty
bundler_args:
script: sudo service docker restart ; sleep 10 && bundle exec rspec spec/acceptance/*_spec.rb
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)
26 changes: 16 additions & 10 deletions manifests/config.pp
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
# == Class: timezone
#
# === timezone::config documentation
#
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 - timedatectl':
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',
}
}

}
10 changes: 3 additions & 7 deletions manifests/init.pp
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
# == Class: timezone
#
# === timezone documentation
#
class timezone(
$manage_package = true,
$package_ensure = 'installed',
$region = 'Europe',
$locality = 'Andorra',
) inherits timezone::params {

class { '::timezone::install': } ->
class { '::timezone::config': } ->
Class['::timezone']
class { '::timezone::install': }
-> class { '::timezone::config': }
-> Class['::timezone']

}
4 changes: 0 additions & 4 deletions manifests/install.pp
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# == Class: timezone
#
# === timezone::install documentation
#
class timezone::install inherits timezone {

if($timezone::manage_package)
Expand Down
10 changes: 8 additions & 2 deletions 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].*$/:
{
$timedatectl=false
}
/^7.*$/:
{
$timedatectl=true
}
default: { fail("Unsupported RHEL/CentOS version! - ${::operatingsystemrelease}") }
}
Expand All @@ -22,8 +27,9 @@
{
case $::operatingsystemrelease
{
/^14.*$/:
/^1[46].*$/:
{
$timedatectl=false
}
default: { fail("Unsupported Ubuntu version! - ${::operatingsystemrelease}") }
}
Expand Down
8 changes: 2 additions & 6 deletions 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 Expand Up @@ -34,14 +34,10 @@
},
{
"operatingsystem": "Ubuntu",
"operatingsystemrelease": [ "14.04" ]
"operatingsystemrelease": [ "14.04", "16.04" ]
}
],
"requirements": [
{
"name": "pe",
"version_requirement": ">= 3.0.0"
},
{
"name": "puppet",
"version_requirement": ">= 3.0.0"
Expand Down
2 changes: 1 addition & 1 deletion spec/acceptance/nodesets/centos5-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ HOSTS:
strict_variables:
platform: el-5-x86_64
hypervisor : docker
image: tianon/centos:5.10
image: jordiprats/centos5:5.11
docker_preserve_image: true
docker_cmd: '["/sbin/init"]'
docker_image_commands:
Expand Down
15 changes: 15 additions & 0 deletions spec/acceptance/nodesets/ubuntu16-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
HOSTS:
ubuntu-1604-x64:
default_apply_opts:
order: random
strict_variables:
platform: ubuntu-16.04-amd64
hypervisor : docker
image: ubuntu:16.04
docker_cmd: '["/sbin/init"]'
docker_preserve_image: true
docker_image_commands:
- 'apt-get install net-tools gcc make tar wget -y'
CONFIG:
type: foss
log_level: debug

0 comments on commit 56f4d52

Please sign in to comment.