[chef] Re: How to define a variable into an execution command


Chronological Thread 
  • From: Ash Berlin < >
  • To:
  • Subject: [chef] Re: How to define a variable into an execution command
  • Date: Wed, 16 Mar 2011 14:07:56 +0000

On 16 Mar 2011, at 14:01, WEINHAPL Andreas wrote:
Hi,
 
I have a problem with my executing command string in chef, because it doesn’t see my declaration as a variable instead he will use the “name” of the variable.  I tried it with attributes aso but the result will be the same L
 
This is my recipe:
 
Recipe:default.rb:
# Update and restart ntp-deamon
# NTP is the variable for Server1(first) and the Server(second)
 
execute "Set time to NTP Time now" do
   command '/usr/sbin/ntpdate <%= node[:ntp][:first] %>'  => should be “command ‘/usr/sbin/ntpdate 217.0.0.1’ “
  action :run
end
 
That is what chef will see if I execute it:
handle_command_failures': /usr/sbin/ntpdate <%= node[:ntp][:first] %> returned 2, expected 0
 
Have anybody a similar problem and could resolve it?!
 
Best regards and thanks for the help
Andreas


<%= %> is ERB syntax and doesn't apply in recipe files. Instead you want to use ruby interpolation syntax:

command "ntpdate #{ node[:ntp][:first] }"

HTH,
-ash



Archive powered by MHonArc 2.6.16.

§