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_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 O’Reilly online learning.
O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.