O'Reilly logo

Mastering Puppet 5 by Jason Southgate, Ryan Russell-Yates

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

file_line – the scalpel

In this exercise, we'll be using a Puppet file resource to build a file, but only if it's not already present in the system. Then, we'll use file lines to insert values we want into the file, which are collected from exported resources across all systems.

The following sample uses puppetlabs-stdlib (for more information visit https://forge.puppet.com/puppetlabs/stdlib) from the Puppet Forge. stdlib contains a large number of functions to use in manifests, as well as the resource file_linefile_line allows a line to be individually managed inside of a file, and can also be used to provide regex matching when you want to use it as a find-and-replace to the unmanaged file. If targeting INI files, consider using puppetlabs-inifile ...

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