puppet替換檔案中的string

大囚長發表於2018-12-04

檔案
<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>',
}

相關文章