Puppet – Variables, If-statements, and Environment variables








Complete list of environment variables (aka “FACTS”): https://docs.puppetlabs.com/facter/latest/core_facts.html

“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:


# facter

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.