The language-puppet website.

Work with your manifests!

Version 0.10.3 Out - Hiera Support, and a Score of Incremental Updates

I did not announce the 0.10.2 version, which was mainly a bug fixing release and the first time I bothered to fix the dependencies of the language-puppet package. This version is full of new stuff however, you can get it on hackage or as binaries.

Hiera support, with facts manipulation utilities

This is the main attraction to this release. I did not use Hiera beforehand, so the development only started because of a GitHub issue. It turns out that this is really a great feature ! Most Hiera features should be supported (actually, I think all of them are, but I might have missed something). Facts manipulation is also easier now.

You can now have that kind of sessions :
$ ssh remote.node 'facter --yaml' > /tmp/facts.yaml # Retrieve facts from a remote host.
$ vi /tmp/facts.yaml # Edit the facts so as to test variations.
$ puppetresources -p ~/gits/puppet -o remote.node \
        --yaml ~/gits/puppet/hiera.yaml \  # Load the given yaml file.
        --facts-override /tmp/facts.yaml   # Override collected facts with
                                           # those from the remote host.

New stateWriter monad

I previously blogged about a replacement for the standard RWS monad, wrote a package, and moved to it. Code speed increased by 10% on a single run, but I expect subsequent runs to go twice as fast. I will need to benchmark this of course, but this is currently not a priority.

JSON output, for use with puppet apply

This is a funny feature. There is support for this in puppetresources, with the --json flag. Once this is generated, you can copy the file onto a machine and apply it with puppet apply --catalog. This also means that it is now trivial to write a replacement for the puppetmaster, a feature that was experimental before the full rewrite, but that might be fully supported (with debian packages) soon.

Full scope tracking for all resources

Now all resources are stored with the full ‘scope’ (think of it as some kind of stack trace, including the originating host for exported resources), which makes debugging much easier. A typical use case is resource duplication in a define, such as the following case situation :

define filewrapper($filename,$owner)
        file { $filename: ensure => present, owner => $owner; }

class class1 {
        filewrapper { 'fw1': filename => '/tmp/xxx', owner => 'class1' ; }
class class2 {
        filewrapper { 'fw2': filename => '/tmp/xxx', owner => 'class2' ; }

node 'a.b.c' {
        include class1,class2

The Puppet error messages is :

Error: Duplicate declaration: File[/tmp/xxx] is already declared in file \
/tmp/x/manifests/site.pp:3; cannot redeclare at /tmp/x/manifests/site.pp:3
on node a.b.c

The language-puppet error message is :

Collision error

This error message is way more informative :

  • The resources are fully displayed, including all attribute values, which might shed some light on the problem.
  • The originating host (a.b.c) is displayed. This is crucial for debugging exported resource collisions. The standard output also shows

Various stuff

There are also a few minor changes in this release :

  • Support for the $classes variable in templates : this one is just as limited as the official one, as its value is parse-order dependent.
  • Support for @instance variables in templates.
  • Support for scope['key'] syntax in templates.
  • The haddocks were updated for some modules.
  • New is_virtual fact, and stdlib functions (flatten, str2bool, validate_absolute_path).