puppet替换文件中的string

Posted on 2018-12-04 10:08  #大囚长#  阅读(115)  评论(0)    收藏  举报

文件
<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>',
}