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.
file_line – the scalpel
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_line. file_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 ...
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.