Skip to content

Puppet versioncmp mnemonic

With the release of the Future Parser in Puppet 4 the type system got a complete overhaul. Comparing a string to an integer is no longer an accepted language contruct. This is a good thing because it prevents unforeseen errors. But your legacy code may contain comparisons between facts facts like $operatingsystemmajrelease and (numeric) version numbers. For Puppet 4 this code should use the versioncmp function instead.

Continue reading "Puppet versioncmp mnemonic"

Linux hostid and endianness

The hostid is often used to provide a host identification for a software license. I wanted to use Puppet to deploy a configuration file containing the hostid for a number of Linux hosts. Normally you would write a custom fact to call the hostid command on the host and use the returned value in your Puppet manifest. But I wanted to avoid forking another process, so here is my non-forking implementation.

Continue reading "Linux hostid and endianness"

Enter Puppet top scope symbols with Emacs Abbrev mode

Puppet manages variables in different scopes. Global variables and all facts are defined in top scope. To make this explicit, these variables and facts should be accessed using the top scope notation. So in a Puppet manifest the hostname fact should for example be written as $::hostname. Here is a piece of Emacs code that automatically adds the double-colon namespace separator to variable and fact names.

Continue reading "Enter Puppet top scope symbols with Emacs Abbrev mode"