On Tuesday, December 5, 2017 at 1:39:38 PM UTC+1, Rob Nelson wrote:
>
> Facts are loaded, and distributed from the master, before the catalog 
> compilation step. See 
> https://docs.puppet.com/facter/3.3/custom_facts.html#external-facts. 
> Rather than distributing the json files as a File resource, you could add 
> an executable fact to a module and the fact could communicate with the CMDB 
> to gather the correct fact information.
>

I'm confused, because I created this on my client only:
/opt/puppetlabs/facter/facts.d/boo.json:
{ "boo": "boo222" }

And added this to me module:
   notify { "boo is ${boo}": }

And received:
Notice: boo is boo222

Doesn't that demonstrate that files in facts.d/boo.json are loaded read in 
on the agent side? There is no "boo" variable defined anywhere on the 
master side.


 

> However, I think what you really want is an External Node Classifier (
> https://puppet.com/docs/puppet/5.3/nodes_external.html). Similar to a 
> function, it runs on the master, but unlike functions it happens before 
> catalog compilation, so the hash of key/values it returns can be used 
> during catalog compilation. That seems like the perfect fit for your use 
> case, except ENCs need to return yaml, not json.
>
>

Thanks, I'll investigate that option.

 

>
>
> Rob Nelson
> [email protected] <javascript:>
>
> On Tue, Dec 5, 2017 at 5:13 AM, buoyant_puppy <[email protected] 
> <javascript:>> wrote:
>
>>
>>
>> On Friday, December 1, 2017 at 5:59:51 PM UTC+1, R.I. Pienaar wrote:
>>>
>>>
>>> All functions like foo() run on the master during compile.  It's a multi 
>>> phase process, the only way a node can influence the compile time is 
>>> using facts. 
>>>
>>> You could integrate your CMDB with puppet using a hiera data function 
>>> that could exist as a tier in your hierarchy 
>>>
>>
>> Thanks, that makes sense now. I'm looking into hiera, but I think I have 
>> another alternative as well. If I put my json files in the facter/facts.d 
>> directory (on the agent), it will be automatically loaded.
>> The only somewhat minor downside is that facter runs first, so the data 
>> it fetches will only be available in the next puppet run.
>>
>> I'm not sure if that's better or worse than the hiera option as I didn't 
>> get hiera working yet.
>>
>> -- 
>> 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] <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/puppet-users/1bbf939a-75a8-49a7-9b11-8e073b945335%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/puppet-users/1bbf939a-75a8-49a7-9b11-8e073b945335%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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/8a0ab143-a635-4e39-8805-0b1a8a16e120%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to