From ffdae9e20d920b0c9577b67484a42f9818190afd Mon Sep 17 00:00:00 2001 From: Thomas Bellman <bellman@nsc.liu.se> Date: Mon, 12 Dec 2016 17:44:10 +0100 Subject: [PATCH] Use '@var' syntax consistently in ERB templates. This is the preferred style in ERB templates, as it makes it clearer where the variables come from, and avoids shadowing by the templating internals (e.g. 'memory' and 'file' are shadowed). Also, in newer versions of Puppet, it is the way you *must* do it. --- manifests/init.pp | 2 +- templates/dsm.opt.erb | 6 +++--- templates/dsm.sys.erb | 14 +++++++------- templates/include_exclude.erb | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 7073712..61f4abd 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -363,7 +363,7 @@ class tsmclient::install $pw_save_file = $tsmclient::siteconfig::password_save_location if $pw_save_file { $pw_vsave_file = inline_template( - '<%= File.basename(pw_save_file) + ".%Y%m%d-%H%M%S" -%>') + '<%= File.basename(@pw_save_file) + ".%Y%m%d-%H%M%S" -%>') store_versioned_data($tsm_password, $pw_save_file, $pw_vsave_file) } diff --git a/templates/dsm.opt.erb b/templates/dsm.opt.erb index 38f0b0e..afbcf78 100644 --- a/templates/dsm.opt.erb +++ b/templates/dsm.opt.erb @@ -7,14 +7,14 @@ mandatory = { } options = { } -tsm_optoptions.each do |opt| +@tsm_optoptions.each do |opt| name,value = opt.strip.split(nil, 2) name = name.strip.downcase value = (value or "").strip if (mandatory.has_key?(name) or name =~ /^(include|exclude)([.].*)?$/ or name == "servername" or name == "nodename") raise(Puppet::ParseError, - ("Tsm_client[#{tsm_servername}]: " + + ("Tsm_client[#{@tsm_servername}]: " + "Illegal TSM optoption ``#{opt}''")) end options[name] = value @@ -22,7 +22,7 @@ end options.merge!(mandatory) -%> -SERVERNAME <%= tsm_servername.upcase %> +SERVERNAME <%= @tsm_servername.upcase %> <% options.keys.sort.each do |optname| -%> <%= sprintf("%-24s %s", optname.to_s, options[optname]).strip %> <% end %> diff --git a/templates/dsm.sys.erb b/templates/dsm.sys.erb index ec61a59..1298366 100644 --- a/templates/dsm.sys.erb +++ b/templates/dsm.sys.erb @@ -6,20 +6,20 @@ mandatory = { # The tsm_client define expects these to be set this way 'commmethod' => "tcpip", - 'tcpserveraddress' => tsm_serveraddress, - 'passworddir' => "#{tsmpassworddir}/", - 'inclexcl' => "#{tsmdir}/bin/include_exclude.#{tsm_servername}", + 'tcpserveraddress' => @tsm_serveraddress, + 'passworddir' => "#{@tsmpassworddir}/", + 'inclexcl' => "#{@tsmdir}/bin/include_exclude.#{@tsm_servername}", } options = { } -tsm_sysoptions.each do |opt| +@tsm_sysoptions.each do |opt| name,value = opt.strip.split(nil, 2) name = name.strip.downcase value = (value or "").strip if (mandatory.has_key?(name) or name =~ /^(include|exclude)([.].*)?$/ or name == "servername" or name == "nodename") raise(Puppet::ParseError, - ("Tsm_client[#{tsm_servername}]: " + + ("Tsm_client[#{@tsm_servername}]: " + "Illegal TSM sysoption ``#{opt}''")) end options[name] = value @@ -27,8 +27,8 @@ end options.merge!(mandatory) -%> -SERVERNAME <%= tsm_servername.upcase %> - NODENAME <%= tsm_nodename %> +SERVERNAME <%= @tsm_servername.upcase %> + NODENAME <%= @tsm_nodename %> <% options.keys.sort.each do |optname| -%> <%= sprintf("%-24s %s", optname.to_s, options[optname]).strip %> <% end %> diff --git a/templates/include_exclude.erb b/templates/include_exclude.erb index 2ec36da..f5b5377 100644 --- a/templates/include_exclude.erb +++ b/templates/include_exclude.erb @@ -3,11 +3,11 @@ # Licensed under the GNU LGPL v3+; see the README file for more information. -tsm_inclexcl.each do |directive| +@tsm_inclexcl.each do |directive| type,path = directive.split(nil, 2) if path == nil raise(Puppet::ParseError, - "Tsm_client[#{tsm_servername}]: Bad inclexcl line #{directive}") + "Tsm_client[#{@tsm_servername}]: Bad inclexcl line #{directive}") end type.strip! path.strip! -- GitLab