I've got a defined resource type to append a line to a file if it doesn't exist, as per below:
define appendLineToFile($file, $line, $user) {
exec { "echo \"\\n$line\" >> \"$file\"":
path => '/bin',
unless => "grep -Fx \"$line\" \"$file\"",
user => $user,
}
}
It works great most of the time, but not in situations like below, where you have double quotes that have to be escaped twice (which is terribly confusing to read):
appendLineToFile { 'Add http_proxy & https_proxy to sudoers':
file => '/etc/sudoers',
line => "Defaults env_keep += \\\"http_proxy https_proxy\\\"",
user => root,
}
Is there a way to change the defined resource type that it doesn't require escaping as such? e.g.
line => "Defaults env_keep += \"http_proxy https_proxy\"",