The language-puppet website.

Work with your manifests!

Version 2.0.0 - the Lua Integration

Quick note on versionning. The official version number is 0.2.0, but I have been omitting the first zero on this blog. Anyway, this version includes two features, one of them built on the hslua library.

A huge bug was fixed: defaults finishing with a comma were interpreted as a function working on a hash! For example:

1
File { owner => 'root', }

Was seen as:

1
file({ 'owner' => 'root' })

Custom functions

Testing custom functions was almost impossible until now, as they required being compiled with the library to be used. It is now possible to include lua implementations of your functions alongside the ruby version.

It is a bit harder to write than the ruby versions as it can’t (for now) access anything from the “Puppet” side, such as facts, and you have to put up with the Lua syntax.

The other caveat is that it is stored right next to the ruby function right now, and Puppet tries to interpret it (and find syntax errors in it), so it isn’t very clean. I will move it for the next version, and will rewrite a few functions from Puppetlabs stdlib too.

From the implementation point of view, the difficult part was the fact that there were no instance for Data.Map. I wrote it and it is now part of the luautils package.

Custom types

As there was all the infrastructure to find files into subfolders, I also added a very weak custom type system. It will detect the file names in the usual places and will know these are valid Puppet types. It doesn’t perform any additional checks for now.

I might add a lua functionnality for fine grained verifications.

What’s next

The fabled dependency handling is not coming soon, but there is a few things that are already implemented and will be released next time:

  • Support for the defined function. Just like the real thing it is parse order dependant.

  • the create_resources function now accepts the third parameter (default (values).

  • The in operator now works with hashes. I am not sure why the Puppet stdlib implements has_key

Comments