puppet替换文件中的string

时间:2022-09-10 06:42:06

文件

<VirtualHost :80>

RewriteEngine On

RewriteCond %{HTTPS} off

RewriteRule (.
) https://%{SERVER_NAME}/$1 [R,L]



命题

substitute the * with the $fqdn facter variable on the first line

答案

include stdlib
$fqdn = $facts['fqdn']
file_line { 'virtual_host':
ensure => present,
path => '/path/to/httpd.conf',
line => "<VirtualHost ${fqdn}:80>",
match => '<VirtualHost \*:80>',
}