[chef] Odd node.default behavior


Chronological Thread 
  • From: "John Warren" < >
  • To: < >
  • Subject: [chef] Odd node.default behavior
  • Date: Tue, 12 Aug 2014 15:32:50 -0400
  • Importance: Normal

In a test recipe I’m trying to determine whether a node attribute was explicitly set and I’m seeing some odd behavior.  Here is the code:
 
log "Resolved value before: #{node['mysql']['server_root_password']}"
log "Default value: #{node.default['mysql']['server_root_password']}"
log "Normal value: #{node.normal['mysql']['server_root_password']}"
log "Resolved value after: #{node['mysql']['server_root_password']}"
 
Here is the relevant log output:
 
[2014-08-12T19:19:15+00:00] INFO: Resolved value before: ilikerandompasswords
[2014-08-12T19:19:15+00:00] INFO: Default value: ilikerandompasswords
[2014-08-12T19:19:15+00:00] INFO: Normal value: {}
[2014-08-12T19:19:15+00:00] INFO: Resolved value after: {}
 
Note that the attribute value was not explicitly set and the “default” value is “ilikerandompasswords”.
 
It looks like the “default” node value for the attribute is overridden after reading the “normal” node value for the purposes of logging.
 
Note that I get the same behavior if I simply assign the “normal” value to a variable (and don’t log it), i.e.:
 
val = node.normal['mysql']['server_root_password']
 
Is this behavior expected?
 
Thanks,
 
John



Archive powered by MHonArc 2.6.16.

§