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


Chronological Thread 
  • From: WEINHAPL Andreas < >
  • To: " " < >
  • Subject: [chef] RE: Re: How to define a variable into an execution command
  • Date: Wed, 16 Mar 2011 15:23:37 +0100
  • Accept-language: en-US, fr-FR
  • Acceptlanguage: en-US, fr-FR

HI Ash,

 

Many thanks! Youre right, I forget that :D

 

Regards

andreas

 

From: Ash Berlin [mailto:
Sent: Mittwoch, 16. März 2011 15:08
To:
Subject: [chef] Re: How to define a variable into an execution command

 

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.

§