O'Reilly logo

Puppet 4.10 Beginner's Guide - Second Edition by John Arundel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Provisioning AWS resources from Hiera data

There's nothing wrong with managing AWS resources directly in code as we've done in the previous examples, but we can do just a little bit better.

In Chapter 6, Managing data with Hiera, we saw how to create Puppet resources directly from Hiera data. In that example (Building resources from Hiera hashes), we stored all the users for our infrastructure in a Hiera hash called users, and then used the each keyword to iterate over that hash, creating a user resource for each user. Here's the example code again (hiera_users2.pp):

lookup('users').each | String $username, Hash $attrs | {
  user { $username:
    * => $attrs,
  }
}

The magic * character (the attribute splat operator) tells Puppet to use the contents of the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required