Skip to content

Instantly share code, notes, and snippets.

@stefanlasiewski
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stefanlasiewski/6d4db8075ffd07444709 to your computer and use it in GitHub Desktop.
Save stefanlasiewski/6d4db8075ffd07444709 to your computer and use it in GitHub Desktop.
Print Hiera arrays in Puppet

Following the example at http://docs.puppetlabs.com/hiera/1/complete_example.html

[root@puppet3 puppet]# puppet apply -e '$message = hiera_array(classes) notify { $message: }'
Notice: Compiled catalog for puppet3.example.org in environment production in 0.03 seconds
Notice: vmwaretoolsnn
Notice: /Stage[main]/Main/Notify[vmwaretools]/message: defined 'message' as 'vmwaretools'
Notice: epel
Notice: /Stage[main]/Main/Notify[epel]/message: defined 'message' as 'epel'
Notice: stefan-yum
Notice: /Stage[main]/Main/Notify[stefan-yum]/message: defined 'message' as 'stefan-yum'
Notice: motd
Notice: /Stage[main]/Main/Notify[motd]/message: defined 'message' as 'motd'
Notice: stefan-puppet
Notice: /Stage[main]/Main/Notify[stefan-puppet]/message: defined 'message' as 'stefan-puppet'
Notice: ntp
Notice: /Stage[main]/Main/Notify[ntp]/message: defined 'message' as 'ntp'
Notice: users
Notice: /Stage[main]/Main/Notify[users]/message: defined 'message' as 'users'
Notice: Finished catalog run in 0.04 seconds
[root@puppet3 puppet]# puppet apply -e "notice hiera_array(classes)"
Notice: Scope(Class[main]): vmwaretools stefan-yum ntp motd stefan-puppet epel users
Notice: Compiled catalog for puppet3.example.org in environment production in 0.02 seconds
Notice: Finished catalog run in 0.03 seconds
  • Printing arrays using Hiera on the commandline:
[root@puppet3 puppet]# hiera --array classes 
["ntp", "motd", "stefan-puppet", "epel", "users"]
[root@puppet3 puppet]# hiera --array classes ::virtual=vmware
["vmwaretools", "ntp", "motd", "stefan-puppet", "epel", "users"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment