Re: Error: Failed to parse template . Detail: Could not find value for 'serveraliases' at

430 views
Skip to first unread message
Message has been deleted

Craig White

unread,
Jan 9, 2015, 10:58:17 AM1/9/15
to puppet...@googlegroups.com
Testing for errors is part of the erb game. Comment all of that out and put in just <%= serveraliases -%> just to see what is written to the file.

In your case above, it seems you have accounted for whether serveraliases is an array or empty but not a simple string which is probably what it is.

On Friday, January 9, 2015 at 8:41:20 AM UTC-7, Spriya wrote:
Hi,

I am having this issue:


Error: Failed to parse template otrs/vhost-otrs.conf.erb:
  Filepath: /opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/templatewrapper.rb
  Line: 81
  Detail: Could not find value for 'serveraliases' at /etc/puppetlabs/puppet/modules/otrs/templates/vhost-otrs.conf.erb:7
 at /etc/puppetlabs/puppet/modules/otrs/manifests/apache.pp:10 on node dot-pap-spr-t03.ddc.dot.state.ma.us


Here is my code manifests code:

class otrs::apache {

  include apache

  apache::vhost { $otrs::sitename:
    priority        => '01',
    docroot         => '/var/www',
    port            => '80',
    serveraliases   => [ $::fqdn ],
}
}

Here is my template:
 cat vhost-otrs.conf.erb
# OTRS Config
# MaxRequestsPerChild (so no apache child will be to big!)
MaxRequestsPerChild 4000

<VirtualHost *:<%= scope.lookupvar("otrs::apache::port") %>>
  ServerName <%= @name %>
<%if serveraliases.is_a? Array -%>
<% serveraliases.each do |name| -%><%= "  ServerAlias #{name}\n" %><% end -%>
<% elsif serveraliases != '' -%>
<%= "  ServerAlias #{serveraliases}" -%>
<% end -%>


Do any one knows  answer? I could not find the answer for this?

Martin Alfke

unread,
Jan 9, 2015, 11:09:14 AM1/9/15
to puppet...@googlegroups.com
Seems to be an issue with unscoped variable inside the template.
https://docs.puppetlabs.com/guides/templating.html#referencing-variables

Please switch to scoped variables in your template:

# OTRS Config
# MaxRequestsPerChild (so no apache child will be to big!)
MaxRequestsPerChild 4000

<VirtualHost *:<%= scope.lookupvar("otrs::apache::port") %>>
ServerName <%= @name %>
<%if @serveraliases.is_a? Array -%>
<% @serveraliases.each do |name| -%><%= " ServerAlias #{name}\n" %><% end -%>
<% elsif @serveraliases != '' -%>
<%= " ServerAlias #{@serveraliases}" -%>
<% end -%>

hth,

Martin
> --
> You received this message because you are subscribed to the Google Groups "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/3d6e89bc-f8e9-4708-89d2-6f3408f14299%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Spriya

unread,
Jan 9, 2015, 11:18:27 AM1/9/15
to puppet...@googlegroups.com
Hi Martin,

I switched that to scoped variables. After  that i am getting another issue.

Here is .erb file:

# OTRS Config
# MaxRequestsPerChild (so no apache child will be to big!)
MaxRequestsPerChild 4000

<VirtualHost *:<%= scope.lookupvar("otrs::apache::port") %>>
  ServerName <%= @name %>
<%if scope.lookupvar("otrs::apache::serveraliases").is_a? Array -%>
<% serveraliases.each do |name| -%><%= "  ServerAlias #{name}\n" %><% end -%>
<% elsif scope.lookupvar("otrs::apache::serveraliases") != '' -%>
<%= "  ServerAlias #{scope.lookupvar("otrs::apache::serveraliases")}" -%>
<% end -%>

  ServerAdmin <%= scope.lookupvar("otrs::serveradmin") %>


Now the issue is:

class otrs::apache {

  include apache

  apache::vhost { $otrs::sitename:
    priority        => '01',
    docroot         => '/var/www',
    port            => '80',
    serveraliases   => [ $::fqdn ],
    content        => template('otrs/vhost-otrs.conf.erb'),
  }

Error: Invalid parameter content at /etc/puppetlabs/puppet/modules/otrs/manifests/apache.pp:11 

Martin Alfke

unread,
Jan 10, 2015, 5:53:05 AM1/10/15
to puppet...@googlegroups.com
Hi,

>
> class otrs::apache {
>
> include apache
>
> apache::vhost { $otrs::sitename:
> priority => '01',
> docroot => '/var/www',
> port => '80',
> serveraliases => [ $::fqdn ],
> content => template('otrs/vhost-otrs.conf.erb'),
> }
>
> Error: Invalid parameter content at /etc/puppetlabs/puppet/modules/otrs/manifests/apache.pp:11
>

Are you using puppetlabs-apache module or have you written the apache::ghost define by yourself?
Check that the define knows about the parameter content.

Puppetlabs-apache ghost define does not have the content attribute.
They switched to concat module and small template snippets.
https://github.com/puppetlabs/puppetlabs-apache/blob/master/manifests/vhost.pp

- Martin

Reply all
Reply to author
Forward
0 new messages