August 13, 2014

Puppet – Variables, If-statements, and Environment variables


You can find all my latest posts on medium.



Complete list of environment variables (aka “FACTS”):

“facter” is a standalone package. This means that it isn’t a puppet subcommand but is actually a command in it’s own right.

If you you:


[bash]# facter[/bash]

then it will output a list of all environment variable (similar to linux’s “env” command).



In the selectors example it showed:


$apache = $operatingsystem ? {
      centos                => 'httpd',
      redhat                => 'httpd',
      /(?i)(ubuntu|debian)/ => 'apache2',
      default               => undef,

Here we are trying to determine what value that “$apache” can take. This depends on the value of the $operatingsystem (which is a builtin variable, aka fact).


The third line shows “/…../”. This is actually a regex. The   “?i” is acutally a regex switch that enables case-sensitivity, a bit like the “-i” switch for bash’s grep command.