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


Chronological Thread 
  • From: Lamont Granquist < >
  • To:
  • Cc: Tomasz Chmielewski < >
  • Subject: [chef] Re: Re: Re: using variables in recipes?
  • Date: Sun, 27 Apr 2014 23:42:22 -0700

On Sun Apr 27 20:39:39 2014, Tomasz Chmielewski wrote:
Turned out #{node['machinename']} was what I was looking for - thanks
for the tip!


^^^^ that is the correct answer for ohai 7

node['hostname'] == always the short hostname (`hostname -s` on linux)
node['fqdn'] == DNS resolved FQDN (`hostname -f` on linux)
node['machinename'] == return host hostname (whatever `hostname` returns)

it grew organically so it doesn't necessary make the best sense.

the default node_name was also changed (in chef 11.10-ish?) so that if you don't specify an explicit node_name is uses the node['fqdn'] and then node['machinename'] so that reading the default node_name should never fail with nil any more.

node['machinename'] won't be backwards compatible if you care about that, but it's probably preferable to node['fqdn'] going forwards.

node['machinename'] || node['fqdn'] should be a backwards-compatible idiom that prefers the new behavior.




Archive powered by MHonArc 2.6.16.

§