Creating resources with Hiera data
When we started working with Puppet, we created resources directly in the manifest using literal attribute values. In this chapter, we've seen how to use Hiera data to fill in the title and attributes of resources in the manifest. We can now take this idea one step further and create resources directly from Hiera queries. The advantage of this method is that we can create any number of resources of any type, based purely on data.
Building resources from Hiera arrays
In Chapter 5, Variables, expressions, and facts, we learned how to use Puppet's each
function to iterate over an array or hash, creating resources as we go. Let's apply this technique to some Hiera data. In our first example, we'll create some user resources from a Hiera array.
On your Puppet-managed node, run the following command:
cd /etc/puppetlabs/code/environments/production sudo cp /vagrant/examples/hiera_users.yaml data/common.yaml
Next, run the following command:
sudo puppet apply /vagrant...