File lines replacement for multiple lines from an array?
I'd like to do something that's a combination of file_line with match=>, and template expansion from an array variable.
Specifically, I'd like the config to be able to supply an array of nameserver IP addresses, and have that override the nameserver lines in /etc/resolv.conf. For example, if $nameservers = ['10.0.0.1', '10.0.0.2'], then it would replace any existing nameserver lines in resolv.conf with the two lines: nameserver 10.0.0.1 nameserver 10.0.0.2
However, anything else in the resolv.conf file, such as the domain search list, and comments, should be left as is.
So, if this array has any values: - remove any existing nameserver lines from resolv.conf - add one nameserver line for each value in the array - leave all other lines in resolv.conf unchanged
If I use a template, I don't know how to preserve existing lines other than nameserver. If I use file_line, I don't know how to expand an array into a bunch of lines.