I'd like to use multiple vhost templates from my apache module in my nodes manifest, and so far not having any luck.
I have one vhost template in my apache module that looks like this. This is my apache::vhost template:
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>
And when I define that template in my nodes.pp manifest it worked totally fine:
apache::vhost { 'dev.example.com':
port => 80,
docroot => '/var/www/jf-wp',
ssl => false,
priority => 002,
}
But when I try to use another vhost template with different settings in my nodes.pp manifest I get an error. This is the apache::vhost_admin template that I can't get to work in my nodes.pp manifest:
#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>
And when I try to define apache::vhost_admin in my nodes.pp file:
apache::vhost_admin { 'admin.example.com':
port => 80,
docroot => '/var/www/admin',
ssl => false,
priority => 004,
serveraliases => 'www.admin.example.com',
}
When I define the apache::vhost_admin template in the nodes.pp manifest is when I get the following error:
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
What am I doing wrong? How can I define multiple vhost definitions in puppet, each with different settings?
After the discussion with @bluethundr, it looks like the "apache::vhost_admin" define was missing.