我正在尝试在木偶模板中的数组上包含一个 for 循环。我一直在关注http://docs.puppetlabs.com/guides/templating.html上的信息,但是在 puppet-client 上它没有说:
Could not retrieve catalog from remote server: wrong header line format
据我所知,这与 ERB 解析问题有关。
erb验证
#erb -P -x -T '-' /etc/puppet/modules/apache2/templates/site-config.erb | ruby -c
-:22: syntax error, unexpected '.'
; alias.each do |val|
^
欢迎任何线索。谢谢。
站点配置.erb:
# Virtual Host <%= name %>
NameVirtualHost <%= listen_config %>
<VirtualHost <%= listen_config %>>
## allgemeine Einstellungen wie für HTTP-<VirtualHost>
ServerAdmin <%= admin_mail %>
ServerName <%= server_name %>
DocumentRoot <%= document_root %>
CustomLog <%= custom_log %>
ErrorLog <%= error_log %>
# Let Apache httpd serve static web application content
<% alias.each do |val| -%>
Alias <%= val %>
<% end -%>
...
初始化.pp:
...
define site (
$ensure = 'present',
$listen_config = "*:80",
$admin_mail = "nobody@example.com",
$server_name = "example.local",
$document_root = "/var/www/",
$custom_log = "/var/log/apache2/$name.log combined",
$error_log = "/var/log/apache2/error_$name.log",
$alias = [],
$tomcat ="false",
$jk_logfile ="/var/log/apache2/jk_$name.log",
$jk_mount =["/$name worker1", "/$name/* worker1"],
$jk_unmount = [],
$tls = "false",
$tls_priorities = "",
$tls_certificate = "/etc/ssl/certs/apache2_$name.crt",
$tls_key ="/etc/ssl/certs/apache2_$name.key,
) {
case $ensure {
'present' : {
file { "/etc/apache2/sites-available/$name":
owner => root,
group => root,
mode => 644,
content => template("site-config.erb"),
}
exec { "/usr/sbin/a2ensite $name":
unless => "/bin/readlink -e ${apache2_sites}-enabled/$name",
notify => Exec["reload-apache2"],
}
}
'absent' : {
exec { "/usr/sbin/a2dissite $name":
onlyif => "/bin/readlink -e ${apache2_sites}-enabled/$name",
notify => Exec["reload-apache2"],
require => Package["apache2"],
}
}
default: { err ( "Unknown ensure value: '$ensure'" ) }
}
}
...