From 32b8861681bc2e6af086eef2a6d27da5ef89d991 Mon Sep 17 00:00:00 2001 From: Paul Borg Date: Thu, 1 Sep 2016 01:18:26 +1000 Subject: [PATCH 1/2] Fix method access to node attributes --- recipes/default.rb | 16 ++++++++-------- recipes/linux-generic.rb | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/recipes/default.rb b/recipes/default.rb index db68d51..2a9916c 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -15,7 +15,7 @@ 'default' => 'tzdata' ) -case node.platform_family +case node['platform_family'] when 'rhel' include_recipe value_for_platform( 'amazon' => { 'default' => 'timezone-ii::amazon' }, @@ -23,29 +23,29 @@ ) when 'debian', 'fedora', 'pld' - include_recipe "timezone-ii::#{node.platform_family}" + include_recipe "timezone-ii::#{node['platform_family']}" else - if node.os == "linux" + if node['os'] == "linux" # Load the generic Linux recipe if there's no better known way to change the # timezone. Log a warning (unless this is known to be the best way on a # particular platform). - message = "Linux platform '#{node.platform}' is unknown to this recipe; " + + message = "Linux platform '#{node['platform']}' is unknown to this recipe; " + "using generic Linux method" log message do level :warn - not_if { %w( centos gentoo rhel ).include? node.platform_family } + not_if { %w( centos gentoo rhel ).include? node['platform_family'] } end include_recipe 'timezone-ii::linux-generic' else message = "Don't know how to configure timezone for " + - "'#{node.platform_family}'!" + "'#{node['platform_family']}'!" log message do level :error end - end # if/else node.os + end # if/else node['os'] -end # case node.platform_family +end # case node['platform_family'] diff --git a/recipes/linux-generic.rb b/recipes/linux-generic.rb index ae0a506..ffc54f2 100644 --- a/recipes/linux-generic.rb +++ b/recipes/linux-generic.rb @@ -10,8 +10,8 @@ # Generic timezone-changing method for Linux that should work for any distro # without a platform-specific method. -timezone_data_file = File.join(node.timezone.tzdata_dir, node.tz) -localtime_path = node.timezone.localtime_path +timezone_data_file = File.join(node['timezone']['tzdata_dir'], node['tz']) +localtime_path = node['timezone']['localtime_path'] ruby_block "confirm timezone" do block { @@ -21,7 +21,7 @@ } end -if node.timezone.use_symlink +if node['timezone']['use_symlink'] link localtime_path do to timezone_data_file owner 'root' @@ -41,4 +41,4 @@ " or set attribute ['timezone']['use_symlink']=true" } end -end # if/else node.timezone.use_symlink +end # if/else node['timezone']['use_symlink'] From 21c9f341e900d8121f02512cebde2f824d39c25c Mon Sep 17 00:00:00 2001 From: Paul Borg Date: Thu, 1 Sep 2016 02:05:46 +1000 Subject: [PATCH 2/2] Use node attribute for tz without symbolizing in rhel7. --- recipes/rhel7.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/rhel7.rb b/recipes/rhel7.rb index 769b29e..b1ca4ff 100644 --- a/recipes/rhel7.rb +++ b/recipes/rhel7.rb @@ -8,4 +8,4 @@ # # This sets the timezone on EL 7 distributions (e.g. RedHat and CentOS) -execute "timedatectl --no-ask-password set-timezone #{node[:tz]}" +execute "timedatectl --no-ask-password set-timezone #{node['tz']}"