I need help replacing a word in an apache Vhost's file using Puppet. My Vhost file looks like:
<VirtualHost *:80>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{SERVER_NAME}/$1 [R,L]
</VirtualHost>
Now I want to substitute the * with the $fqdn facter variable on the first line. I don't want to use the apache module from Puppet Forge. I found file_line from the stdlib module but it is not able to substitute with a facter variable.
I could use the exec resource type which will run a sed command to replace * with the hostname, but I want to avoid doing that. Is there any other way to do this?
You can in fact use file_line here:
include stdlib
$fqdn = $facts['fqdn']
file_line { 'virtual_host':
ensure => present,
path => '/path/to/httpd.conf',
line => "<VirtualHost ${fqdn}:80>",
match => '<VirtualHost \*:80>',
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With