我想在我的节点清单中使用我的apache模块中的多个vhost模板,到目前为止没有运气。
我的apache模块中有一个vhost模板,看起来像这样。这是我的apache :: vhost模板:
cat modules/apache/templates/vhost.conf.erb
<VirtualHost *:<%= port %>>
ServerName <%= name %>
<%if serveraliases.is_a? Array -%>
<% serveraliases.each do |name| -%>
<%= " ServerAlias #{name}\n" %><% end -%>
<% elsif serveraliases != '' -%>
<%= " ServerAlias #{serveraliases}" -%>
<% end -%>
php_value newrelic.appname <%= name %>
KeepAlive On
KeepAliveTimeout 5
MaxKeepAliveRequests 100
LogFormat "{ \
\"host\":\"<%= name %>.<%= domain %>\", \
\"path\":\"/var/log/httpd/jf_<%= name %>_access_log\", \
\"tags\":[\"Jokefire <%= name %>\"], \
\"message\": \"%h %l %u %t \\\"%r\\\" %>s %b\", \
\"timestamp\": \"%{%Y-%m-%dT%H:%M:%S%z}t\", \
\"clientip\": \"%a\", \
\"duration\": %D, \
\"status\": %>s, \
\"request\": \"%U%q\", \
\"urlpath\": \"%U\", \
\"urlquery\": \"%q\", \
\"method\": \"%m\", \
\"bytes\": %B, \
\"vhost\": \"%v\" \
}" <%= name %>_access_json
CustomLog /var/log/httpd/jf_<%= name %>_access_log <%= name %>_access_json
LogLevel debug
ErrorLog /var/log/httpd/jf_<%= name %>_error_log
DirectoryIndex index.html index.php
DocumentRoot <%= docroot %>
<Directory <%= docroot %>>
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
</Directory>
ServerSignature On
</VirtualHost>
当我在我的nodes.pp中定义该模板时,它完全正常工作:
apache::vhost { 'dev.example.com':
port => 80,
docroot => '/var/www/jf-wp',
ssl => false,
priority => 002,
}
但是当我尝试在我的nodes.pp清单中使用另一个具有不同设置的vhost模板时,我收到一个错误。这是我无法在我的nodes.pp清单中工作的apache :: vhost_admin模板:
#cat modules/apache/templates/vhost_admin.conf.erb
<VirtualHost *:<%= port %>>
ServerName <%= name %>
<%if serveraliases.is_a? Array -%>
<% serveraliases.each do |name| -%>
<%= " ServerAlias #{name}\n" %><% end -%>
<% elsif serveraliases != '' -%>
<%= " ServerAlias #{serveraliases}" -%>
<% end -%>
php_value newrelic.enabled false
KeepAlive On
KeepAliveTimeout 5
MaxKeepAliveRequests 100
LogFormat "{ \
\"host\":\"<%= name %>.<%= domain %>\", \
\"path\":\"/var/log/httpd/jf_<%= name %>_access_log\", \
\"tags\":[\"Jokefire <%= name %>\"], \
\"message\": \"%h %l %u %t \\\"%r\\\" %>s %b\", \
\"timestamp\": \"%{%Y-%m-%dT%H:%M:%S%z}t\", \
\"clientip\": \"%a\", \
\"duration\": %D, \
\"status\": %>s, \
\"request\": \"%U%q\", \
\"urlpath\": \"%U\", \
\"urlquery\": \"%q\", \
\"method\": \"%m\", \
\"bytes\": %B, \
\"vhost\": \"%v\" \
}" <%= name %>_access_json
CustomLog /var/log/httpd/jf_<%= name %>_access_log <%= name %>_access_json
LogLevel debug
ErrorLog /var/log/httpd/jf_<%= name %>_error_log
DirectoryIndex index.html index.php
DocumentRoot <%= docroot %>
<Directory <%= docroot %>>
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
</Directory>
ServerSignature On
</VirtualHost>
当我尝试在nodes.pp文件中定义apache :: vhost_admin时:
apache::vhost_admin { 'admin.example.com':
port => 80,
docroot => '/var/www/admin',
ssl => false,
priority => 004,
serveraliases => 'www.admin.example.com',
}
当我在nodes.pp清单中定义apache :: vhost_admin模板时,我收到以下错误:
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Puppet::Parser::AST::Resource failed with e
rror ArgumentError: Invalid resource type apache::vhost_admin at /etc/puppet/environments/production/manifests/nodes.p
p:139 on node web1.jokefire.com
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run
enter code here
我做错了什么?如何在puppet中定义多个vhost定义,每个定义具有不同的设置?
答案 0 :(得分:1)
与@bluethundr讨论后,看起来似乎缺少“apache :: vhost_admin”定义。