需要使用puppet替换文件中的字符串
我需要帮助用Puppet替换apache Vhost文件中的一个单词。我的Vhost文件如下所示:需要使用puppet替换文件中的字符串,puppet,Puppet,我需要帮助用Puppet替换apache Vhost文件中的一个单词。我的Vhost文件如下所示: <VirtualHost *:80> RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.*) https://%{SERVER_NAME}/$1 [R,L] </VirtualHost> 重新启动发动机 重写条件%{HTTPS}关闭 重写规则(*)https://%{SERVER_NAME}/$1[R,L]
<VirtualHost *:80>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{SERVER_NAME}/$1 [R,L]
</VirtualHost>
重新启动发动机
重写条件%{HTTPS}关闭
重写规则(*)https://%{SERVER_NAME}/$1[R,L]
现在我想在第一行用$fqdn
facter变量替换*
。我不想使用Puppet Forge的apache模块。我从stdlib
模块中找到了file\u行
,但它不能用facter变量替换
我可以使用
exec
资源类型来运行sed
命令,用主机名替换*,但我希望避免这样做。还有其他方法吗?实际上,您可以在此处使用文件行
:
include stdlib
$fqdn = $facts['fqdn']
file_line { 'virtual_host':
ensure => present,
path => '/path/to/httpd.conf',
line => "<VirtualHost ${fqdn}:80>",
match => '<VirtualHost \*:80>',
}
包括stdlib
$fqdn=$facts['fqdn']
文件行{“虚拟主机”:
确保=>存在,
path=>'/path/to/httpd.conf',
行=>“”,
匹配=>'',
}
您实际上可以在此处使用文件行
:
include stdlib
$fqdn = $facts['fqdn']
file_line { 'virtual_host':
ensure => present,
path => '/path/to/httpd.conf',
line => "<VirtualHost ${fqdn}:80>",
match => '<VirtualHost \*:80>',
}
包括stdlib
$fqdn=$facts['fqdn']
文件行{“虚拟主机”:
确保=>存在,
path=>'/path/to/httpd.conf',
行=>“”,
匹配=>'',
}