I am working on rspec tests for a module for Puppet 5 that refers to nodes' 
$::trusted_facts hash, and, separately, relies on nodes' $::networking 
fact.  In particular it uses the values of $::networking['fqdn'] and 
$::networking['hostname'].  I would like to test scenarios where the 
attributes of $::networking are unrelated to the node name, or even are 
absent altogether, but I can't figure out how to do it.

Through a combination of documentation and trial and error, I think I have 
determined that in order for rspec-puppet to provide the $::trusted_facts 
hash to the catalog builder, I need to configure its trusted_node_data 
parameter to true, and to define a node name in my tests via let(:node) { 
'node-name' }.

After doing so, however, I found that the catalog builder was receiving 
different values for the hostname and fqdn than those I specify via a 
let(:facts) call.  After much head scratching, hypothesizing, and net 
searching, I think I finally established that by default, rspec-puppet uses 
the node name to set values for these properties, overriding anything to 
the contrary in the facts I provide.

But wait!  Rspec-puppet also has a configuration parameter, 
derive_node_facts_from_nodename, that seems custom-made for disabling the 
troublesome behavior.  That's great, except that setting that parameter to 
false seems to disable the $::trusted_facts hash as well.

Is there some combination of rspec configuration settings and test code 
that can give me the test scenarios I want?  That is, $::trusted_facts 
presented to the catalog builder and containing at least the certname key, 
with $::networking['fqdn'] and $::networking['hostname'] taking independent 
values (or being undefined), as I specify separately?


John

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/0f40d103-e796-4a1a-aa25-e56622071c8e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to