[chef] Re: Re: using variables in recipes?


Chronological Thread 
  • From: Tomasz Chmielewski < >
  • To:
  • Subject: [chef] Re: Re: using variables in recipes?
  • Date: Mon, 28 Apr 2014 04:27:35 +0100
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=wpkg.org; h=to:subject :mime-version:content-type:content-transfer-encoding:date:from :in-reply-to:references:message-id; q=dns; s=default; b=yiLkq3PT XlCp2L8a+ejJ46bmEWxt+GMr0prRt+TCGFlNf/8d8OTsV4+AHzyDTlYKLmesy4WT xu73GgEU2PFSOGbnwD3aLg13oLcjF9mxPwNG2r1B76TwoxRW9lZLSfIbloiM3GUr xRWH7Nj74zoNOWW9RKyxubIplU7FeBW8Qos=

Unfortunately doesn't work as expected.

This is the output of $HOSTNAME on this server:

$ echo $HOSTNAME
server.example.com

In the recipe, "#{node['hostname']}" gives me just "server" (so, without ".example.com" I'm getting from $HOSTNAME variable).

"#{node['fqdn']}" gives me "localhost", and "#{node['domain']}" is empty.


Are there any other ways to get a variable to be used in a recipe (putting aside whether the fqdn should be localhost or not)?


--
Tomasz Chmielewski
http://wpkg.org


On 2014-04-28 04:04, Wolfe, Eric G wrote:
You can interpolate the ohai hostname attribute like so: "#{node['hostname']}"

Tomasz Chmielewski 
< >
 wrote:


How can I use the $HOSTNAME variable in a recipe?

I need something which would fit here:

remote_file "/tmp/$HOSTNAME.tar.xz" do
   source 
"https://user: :port/aaa/$HOSTNAME.tar.xz"
   owner "root"
   group "root"
   mode 00600
   not_if { ::File.exists?("/some/path/here") }
end


--
Tomasz Chmielewski
http://wpkg.org




Archive powered by MHonArc 2.6.16.

§