A collection of task oriented solutions in Puppet

 

View all the puppet variables on this client

Challenge

You want to see all the variables that are set for this client when puppet runs

Solution

class all_facts_file {

  file { '/tmp/facts.yaml':
    content => inline_template(' scope.to_hash.reject { |k,v| !( k.is_a?(String) && v.is_a?(String) ) }.to_yaml '),
  }

}

Explanation

Sometimes you want to see all the variables available to a puppet client when it runs. One of the neatest approaches I've seen for this comes from Jordan Sissel. Using an inline template the above snippet dumps all the variables that look like a string (and so helpfully filters some internal puppet settings) to a file. The output is both human readable, which can help with debugging, and easily machine parsable. This ensures an up to date copy of the information is available for later processing on the client.

See also