Lookup function examples

Let's just quickly run through the main use cases for the lookup( ) function, also showing the equivalent usages of the old hiera( ) function:

  • The following usage is a completely regular lookup:

lookup('ntp::user') # equivalent to hiera('ntp::user')
  • The following usage is a regular lookup, while providing a default:

lookup('ntp::user','root') # equivalent to hiera('ntp::user','root')
  • The following usage is an array lookup:

lookup('my_ntp_servers', Array, 'unique') # equivalent to hiera_array('ntp_servers')
  • The following is a deep-merge lookup:

lookup('users', Hash, 'deep') # equivalent to hiera_hash('users') with deep
  • The following is a classification lookup:

lookup('classes', Array[String], 'unique').include ...

Get Mastering Puppet 5 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.