Version 1.8.0 is out, and breaks the existing API. On the other hand, it is now very well integrated with PuppetDB ! The following new features are now available :
- Facts can be retrieved from PuppetDB.
- Exported resources can also be retrieved from PuppetDB.
- The resource query function from this module has been implemented.
This means you can now test all your higher order Puppet recipes. A typical use case is for the configuration of proxy servers. It gets really easy to declare something like this on a host:
1 2 3 4 5 |
|
Then you can get them in a hash with :
1 2 3 4 5 |
|
And use it in a template with :
1 2 3 |
|
This is the kind of things that drives people to Puppet. On the other hand, it quickly gets tricky to test. How are you supposed to check that your template will look the way you expect it to ?
Previously I used to just hardcode the result of the pdbresourcequery
function
during the testing phase, and use puppetresources
to look at the rendered
template. Now with PuppetDB integration you get the actual facts and exported
resources that Puppet will use when computing a catalog.
So how do you use it ? It requires having access to a clear text HTTP port that answers PuppetDB queries. Typically, you will want to use a SSH tunnel if you test on your workstation, just like that:
1
|
|
Once this is done, you have the following options, depending on how you use the language-puppet library :
- With
puppetresources
, start with the new-r
switch, like this :
1
|
|
- With the
puppetresources
in interactive mode, initialize the Daemon with theinitializedaemonWithPuppet
function, like this :
1
|
|
- With the
Daemon
API, modify thePrefs
records so as to add the correct URL:
1 2 |
|
If you wish to use the lower level APIs, you might want to check the new PuppetDB modules (unfortunately hackage doesn’t seem to generate documentation at the moment so I can’t link it). You might use the built-in PuppetDB query function, use your own or just mock their output.
There are probably bugs, and the URL to access to pdbresourcequery
is
currently hardcoded (won’t take long to makes it right), but this is a major
milestone for this project.