Understanding Exported Resources in Puppet

puppet

In order to understand exported resources in Puppet the following documentation was read. After reading the documentation the understanding was that exported resources consist of declaring and collecting.

Attempt

Based on the documentation and understanding of exported resources in Puppet the following code was created:

class test {
  @@file { "/tmp/$hostname": }

  File <<| |>>
}

Expected

The expectation was that a file /tmp/vm-one would be created

Current

No file has been created

[vagrant@vm-one modules]$ sudo puppet agent -t
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Info: Caching catalog for vm-one.domain
Info: Applying configuration version '1421499164'
Notice: Finished catalog run in 0.10 seconds

Best Answer

For exported resources to function properly you need to set up PuppetDB. They won't work without PuppetDB. Also, you often need two Puppet runs for resources to get applied.

What happens behind the scenes is:

  • puppet agent requests catalog from master

  • master compiles catalog (fetching exported resources from PuppetDB, and storing newly found exported resources back to PuppetDB)

  • master delivers catalog to agent

Of course having exported resources within the manifest for a single node isn't really useful. The idea behind them is that individual nodes can report some of their resources which are later collected by another node on which you want them to be applied.

Here's an example: if want to insert Nagios checks into each and every one of your services, you don't want to apply and collect those checks on the nodes where services reside on, but you want to collect them all on a Nagios node.

Hope this helps.

Related Topic