[chef] Re: Re: Re: Re: Re: Re: How to override node attribute with lazy value?


Chronological Thread 
  • From: Lamont Granquist < >
  • To:
  • Cc: Greg Barker < >
  • Subject: [chef] Re: Re: Re: Re: Re: Re: How to override node attribute with lazy value?
  • Date: Fri, 03 Oct 2014 17:13:06 -0700

On Fri Oct  3 16:39:36 2014, Lamont Granquist wrote:

How it should be written, i'll look at submitting a PR...


Sorry look like I fell victim to thinking that all problems were like my last problem.

The hostname is getting set at converge time, fairly late, by the hostname cookbook. Your node['fqdn'] will be the old hostname throughout the whole compile phase of the chef-client run. In your case since you control the code it'll be way easier to use the node['set_fqdn'] attribute that you're passing to the hostname cookbook to pass to the
chef-server cookbook:

node.override["chef-server"]["configuration"]["nginx"]["ssl_certificate"] = "/etc/pki/tls/certs/#{node['set_fqdn']}.pem"

If that doesn't work for you then you may have an issue trying to do that. The attributes are most likely getting passed into the template variable sometime in compiletime and your node['fqdn'] isn't getting updated until converge time. Either the hostname cookbook needs to be changed to do its work at compile-time or else the chef-server cookbook needs to be converted to be lazy.

A better approach would probably be for the hostname cookbook to expose a ruby library to call to get the desired hostname (basically sugar around either returning node['set_fqdn'] or else returning the output of "/usr/sbin/vmtoolsd --cmd 'info-get guestinfo.hostname'") and then you could get that value at compile time and set attributes with it just fine.





Archive powered by MHonArc 2.6.16.

§