[Puppet Users] Re: Variable not working in a define

imase
Thu, 10 Nov 2011 08:56:54 -0000

Oh man, I found the mistake.

It is in the template:

TOMCAT_VER="<%=
scope.lookupvar(''tcserver::params::instance_version'')
%>"

should be:

TOMCAT_VER="<%= scope.lookupvar(''version'')%>"

Because it is called out of tcserver::instance.

Kind regards


On 10 Nov., 09:24, imase <igor.ma...@googlemail.com>
wrote:
> Hello together,
>
> I have a define which was written by someone else and I am trying to
> extend it by the $version variable. My Module is called tcserver and
> it''s a type of an apache tomcat. The package of tcserver will be
> deployed by an rpm via the module. After the installation there are
> two version of Tomcat which I would like to use. So I would like, that
> Application 1 is using Tomcat 6 and the other one 7. Here is the
> config of an example application:
>
>         tcserver::instance { ''jira'':
>         httpport => ''8080'',
>         contextfile => ''jira_context.xml'',
>         serverfile => ''jira_server.xml'',
>         setenvfile => ''jira_setenv.sh'',
>         service_enable => false,
>         version => ''6.0.33.A.RELEASE'',
>         }
>
> The define tcserver::instance looks like this:
>
> define tcserver::instance(
>     $httpport="${tcserver::params::instance_httpport}",
>     $contextfile="${tcserver::params::instance_contextfile}",
>     $setenvfile="${tcserver::params::instance_setenvfile}",
>     $serverfile="${tcserver::params::instance_serverfile}",
>     $version="${tcserver::params::instance_version}",
>     $service_enable=true,
>     $service_ensure=''running''
>     ... (some more)
> )
>
> {
>
>     include jdk16
>     include tcserver
>     include tcserver::params
>
>     $instance_service_enable = "$service_enable"
>     $instance_service_ensure = "$service_ensure"
>     $instance_httpport = "$httpport"
>     $instance_serverfile = "$serverfile"
>     $instance_setenvfile = "$setenvfile"
>     $instance_version = "$version"
>     ... (some more)
>
>     file { "/etc/init.d/${instance_name}":
>         path    => "/etc/init.d/${instance_name}",
>         mode    => "755",
>         owner   => "root",
>         group   => "root",
>         ensure  => present,
>         require =>
Package["${tcserver::params::packagename}"],
>         content => template("tcserver/tcserver.erb"),
>     }
>
> }
>
> tcserver::params looks like this:
>
> ... (some more)
>     $instance_version = $tcserver_instance_version ? {
>         '''' => "6.0.32.B.RELEASE",
>         default => "${tcserver_instance_version}",
>     }
> ... (some more)
>
> After the whole declaration I write it in an template and try to
> replace it:
>
> TOMCAT_VER="<%=
scope.lookupvar(''tcserver::params::instance_version'')
> %>"
>
> After running puppet on the client I get the following in the
> templated file:
>
> TOMCAT_VER="6.0.32.B.RELEASE"
>
> Olthough this should be:
>
> TOMCAT_VER="6.0.33.A.RELEASE"
>
> What am I do wrong? Could you help me?
>
> Kind regards

--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to
puppet-users+unsubscribe@googlegroups.com.
For more options, visit this group at