diff --git a/data/os/Archlinux.yaml b/data/os/Archlinux.yaml index c675df1..074cf91 100644 --- a/data/os/Archlinux.yaml +++ b/data/os/Archlinux.yaml @@ -1,6 +1,6 @@ --- timezone::package: tzdata timezone::zoneinfo_dir: /usr/share/zoneinfo timezone::localtime_file: /etc/localtime timezone::timezone_update: 'timedatectl set-timezone %s' -timezone::timezone_update_check_cmd: "timedatectl status | grep 'Timezone:\|Time zone:' | grep -q %s" +timezone::timezone_update_check_cmd: 'timedatectl status | grep "Timezone:\|Time zone:" | grep -q %s' diff --git a/data/os/RedHat/7.yaml b/data/os/RedHat/7.yaml index a9a0577..e4a45bf 100644 --- a/data/os/RedHat/7.yaml +++ b/data/os/RedHat/7.yaml @@ -1,6 +1,6 @@ --- timezone::timezone_update: 'timedatectl set-timezone %s' -timezone::timezone_update_check_cmd: "timedatectl status | grep 'Timezone:\|Time zone:' | grep -q %s" +timezone::timezone_update_check_cmd: 'timedatectl status | grep "Timezone:\|Time zone:" | grep -q %s' timezone::check_hwclock_enabled_cmd: 'grep LOCAL /etc/adjtime' timezone::check_hwclock_disabled_cmd: 'grep UTC /etc/adjtime' timezone::hwclock_cmd: 'timedatectl set-local-rtc %s' diff --git a/spec/support/redhat.rb b/spec/support/redhat.rb index a7f4836..92caf70 100644 --- a/spec/support/redhat.rb +++ b/spec/support/redhat.rb @@ -1,74 +1,74 @@ shared_examples 'RedHat' do describe 'when using default class parameters with osfamily => RedHat and major release => 6' do let(:params) { {} } let(:facts) do { :os => { :name => 'CentOS', :family => 'RedHat', :release => { :major => '6' } } } end it { is_expected.to create_class('timezone') } it do is_expected.to contain_package('tzdata').with(:ensure => 'present', :before => 'File[/etc/localtime]') end it { is_expected.to contain_file('/etc/sysconfig/clock').with_ensure('file') } it { is_expected.to contain_file('/etc/sysconfig/clock').with_content(%r{^ZONE="Etc/UTC"$}) } it { is_expected.not_to contain_exec('update_timezone') } it do is_expected.to contain_file('/etc/localtime').with(:ensure => 'file', :source => 'file:///usr/share/zoneinfo/Etc/UTC') end context 'when timezone => "Europe/Berlin"' do let(:params) { { :timezone => 'Europe/Berlin' } } it { is_expected.to contain_file('/etc/sysconfig/clock').with_content(%r{^ZONE="Europe/Berlin"$}) } it { is_expected.to contain_file('/etc/localtime').with_source('file:///usr/share/zoneinfo/Europe/Berlin') } end context 'when autoupgrade => true' do let(:params) { { :autoupgrade => true } } it { is_expected.to contain_package('tzdata').with_ensure('latest') } end context 'when ensure => absent' do let(:params) { { :ensure => 'absent' } } it { is_expected.to contain_package('tzdata').with_ensure('present') } it { is_expected.to contain_file('/etc/sysconfig/clock').with_ensure('absent') } it { is_expected.to contain_file('/etc/localtime').with_ensure('absent') } end include_examples 'validate parameters' end describe 'when using default class parameters with osfamily => RedHat and major release => 7' do let(:params) { {} } let(:facts) do { :os => { :name => 'CentOS', :family => 'RedHat', :release => { :major => '7' } } } end it { is_expected.to create_class('timezone') } it { is_expected.not_to contain_file('/etc/sysconfig/clock') } it { is_expected.to contain_file('/etc/localtime').with_ensure('file') } - it { is_expected.to contain_exec('update_timezone').with_command('timedatectl set-timezone Etc/UTC').with_unless("timedatectl status | grep 'Timezone:' | grep -q Etc/UTC") } + it { is_expected.to contain_exec('update_timezone').with_command('timedatectl set-timezone Etc/UTC').with_unless('timedatectl status | grep "Timezone:\|Time zone:" | grep -q Etc/UTC') } include_examples 'validate parameters' end end