There is a config file e.g. /etc/network/interfaces. I want to manage only a certain section of that file using Puppet.
Example:
# At the beginning at least is some dynamic content that can be different
# from machine to machine and changed by an admin manually
auto eth0
iface eth0 inet static
address 192.168.108.5
netmask 255.255.255.0
# BEGIN PUPPET WLAN0
allow-hotplug wlan0
iface wlan0 inet static
address 192.168.109.5
netmask 255.255.255.0
# END PUPPET WLAN0
# Potentially more stuff that I do not want to touch through Puppet
# But could be static if it makes it more easy. E.g. simply force sections to end of file.
The stdlib file_line resource is very close to what I need. A regex and content to replace a match with. However, unfortunately, there is no way to make file_line match over multiple lines and replace with new content.
Alternative 1: create a bash script: ugly Exec resources and temp files.
Alternaitve 2: Use Augeas: seems overkill for a simple search & replace.
Is there another module than stdlib that allows me to do a regex match & replace over multiple lines?
Any other handcraft solutions better than juggling temp bash script and Exec resource?
#More stuf...
section static? – Joseph R. Aug 06 '14 at 21:17