Resouce names with variables.

6 views
Skip to first unread message

Douglas Garstang

unread,
Nov 7, 2009, 6:39:53 PM11/7/09
to Puppet Users
This seems like a bug to me. In the example below, puppet complains:

Nov 7 15:32:28 gumby puppetd[17245]: Configuration could not be
instantiated: Could not find dependency
File[/opt/jboss/jboss-current/conf/tfel-bindings.xml] for
Service[jboss-tfel2] at
/etc/puppet/modules/jboss/manifests/init.pp:31; using cached catalog

If I replace the File definition in the jboss class from
"/opt/jboss/jboss-$jboss_version/conf/tfel-bindings.xml" to
"/opt/jboss/jboss-$version/conf/tfel-bindings.xml", then puppet does
NOT complain about it. It appears that puppet is treating the two
resources differently, even though they both extrapolate to the same
thing, ie it treats them literally, without regard to what the value
of the variable is. Is this by design?

It's painful, because I wanted to set $jboss_version in the node, pass
it to the definition, and use $version inside the definition. I can't
do that. I have to use the $jboss_version variable.

Doug

define jboss::create_inst($version = "current", $naming_port, $cluster) {
service {
"jboss-$name":
require => [ Package["jboss-server"],
Package["jboss-server-$name"],

File["/opt/jboss/jboss-$version/conf/tfel-bindings.xml"] ],
ensure => running,
enable => true,
hasrestart => true,
hasstatus => true
}
}

class jboss::server {
"/opt/jboss/jboss-$jboss_version/conf/tfel-bindings.xml":
source => "puppet://$server/jboss/conf/tfel-bindings.xml",
require => Package["jboss-server"],
owner => root, group => root;
}

node 'gumby.fr.xxx.com' {
$jboss_version = "4.2.3.GA-1.tf"
jboss::create_inst {
tfel0:
cluster => "c0tfel0",
naming_port => "1099";
}
}

Peter Meier

unread,
Nov 7, 2009, 6:54:17 PM11/7/09
to puppet...@googlegroups.com
> It's painful, because I wanted to set $jboss_version in the node, pass
> it to the definition, and use $version inside the definition. I can't
> do that. I have to use the $jboss_version variable.


use ${jboss_version} instead of $jboss_version.

http://reductivelabs.com/trac/puppet/wiki/LanguageTutorial#quoting

cheers pete

Douglas Garstang

unread,
Nov 7, 2009, 7:07:49 PM11/7/09
to puppet...@googlegroups.com
Peter,

Same error...

Nov 7 16:06:57 gumby puppetd[17245]: Configuration could not be
instantiated: Could not find dependency
File[/opt/jboss/jboss-current/conf/tfel-bindings.xml] for
Service[jboss-tfel2] at
/etc/puppet/modules/jboss/manifests/init.pp:38; usi
ng cached catalog

after changing the require to...

File["/opt/jboss/jboss-${version}/conf/tfel-bindings.xml"] ],

Doug.
--
Regards,

Douglas Garstang
http://www.linkedin.com/in/garstang
Email: doug.g...@gmail.com
Cell: +1-805-340-5627

Douglas Garstang

unread,
Nov 7, 2009, 7:08:35 PM11/7/09
to puppet...@googlegroups.com
Oh, and I don't want to use $jboss_version. I want to use $version.
That was the whole point.

Avi Miller

unread,
Nov 7, 2009, 8:08:08 PM11/7/09
to puppet...@googlegroups.com
Douglas,

Douglas Garstang wrote:
> Could not find dependency
> File[/opt/jboss/jboss-current/conf/tfel-bindings.xml] for
> Service[jboss-tfel2] at
> /etc/puppet/modules/jboss/manifests/init.pp:38; using cached catalog

It is expanding ${version} to "current" as shown by the jboss-current
string in your File[]. Is this dependency defined?

cYa,
Avi

Douglas Garstang

unread,
Nov 7, 2009, 8:53:44 PM11/7/09
to puppet...@googlegroups.com
Avi,

Yes, it's defined in a class.

Doug.

Avi Miller

unread,
Nov 7, 2009, 8:59:48 PM11/7/09
to puppet...@googlegroups.com
Hi,

Douglas Garstang wrote:
> Yes, it's defined in a class.

Can you pastie the entire thing somewhere? It's difficult to tell if
there is perhaps a scoping issue unless we can see the entire manifest
involved.

cYa,
Avi

Reply all
Reply to author
Forward
0 new messages