i'm trying to pass Resources (single or in an array) to a resource, so I
can pass this to a notify or require. However I have some problems, when
no resource should be passed. Maybe somebody can help me? thanks
define gentoo::etcconfd (
$require = '',
$notify = ''
){
file { "/etc/conf.d/${name}":
owner => "root",
group => "0",
mode => 644,
source => [
"puppet://$server/dist/gentoo/etc_conf.d/${name}_${fqdn}",
"puppet://$server/dist/gentoo/etc_conf.d/${name}_default",
"puppet://$server/gentoo/etc_conf.d/${name}"
],
require => $require,
notify => $notify,
}
}
#works not:
gentoo::etcconfd { foobar: }
#works:
gentoo::etcconfd { apache2: require => "Package[apache]", notify =>
"Service[apache]"}
#Error I get:
err: Could not create /etc/conf.d/foobar: Parameter require failed:
interning empty string
I also tried setting it to undef, which didn't change anything.
Or should I use a trick to pass the resource?
thanks for your help and greets pete
>
> Hi
>
> i'm trying to pass Resources (single or in an array) to a resource,
> so I
> can pass this to a notify or require. However I have some problems,
> when
> no resource should be passed. Maybe somebody can help me? thanks
>
> define gentoo::etcconfd (
> $require = '',
> $notify = ''
> ){
You don't need to declare these (in fact, you should be seeing a
warning for them); all defined types automatically support all
metaparameters.
Otherwise, follow the advice of the other poster: default to false,
and test for the value before you go ahead and set it on the
resource. That won't work for metaparameters, because resources
automatically acquire all metaparameters from the definition they're in.
--
A bore is a man who deprives you of solitude without providing you
with company. -- Gian Vincenzo Gravina
---------------------------------------------------------------------
Luke Kanies | http://reductivelabs.com | http://madstop.com
> You don't need to declare these (in fact, you should be seeing a
> warning for them); all defined types automatically support all
> metaparameters.
ah cool. Didn't know that. I tried to add this to the Language Tutorial:
http://reductivelabs.com/trac/puppet/wiki/LanguageTutorial?action=diff&version=45
I hope that this might be ok?! Otherwise please change/correct it.
> Otherwise, follow the advice of the other poster: default to false,
> and test for the value before you go ahead and set it on the
> resource. That won't work for metaparameters, because resources
> automatically acquire all metaparameters from the definition they're in.
this works now: :)
define gentoo::etcconfd (){
file { "/etc/conf.d/${name}":
owner => "root",
group => "0",
mode => 644,
source => [
"puppet://$server/dist/gentoo/etc_conf.d/${name}_${fqdn}",
"puppet://$server/dist/gentoo/etc_conf.d/${name}_default",
"puppet://$server/gentoo/etc_conf.d/${name}"
],
}
if $require {
File["/etc/conf.d/${name}"]{
require => $require,
}
}
if $notify {
File["/etc/conf.d/${name}"]{
notify => $notify,
}
}
}
thanks a lot!
greets pete
Peter Meier wrote:
| Hi
|
|> You don't need to declare these (in fact, you should be seeing a
|> warning for them); all defined types automatically support all
|> metaparameters.
|
| ah cool. Didn't know that. I tried to add this to the Language Tutorial:
|
http://reductivelabs.com/trac/puppet/wiki/LanguageTutorial?action=diff&version=45
| I hope that this might be ok?! Otherwise please change/correct it.
|
Might want to include an example and a bit more information - the
Tutorial is designed as an introduction.
Regards
James Turnbull
- --
James Turnbull (ja...@lovedthanlost.net)
- --
Author of:
- - Pulling Strings with Puppet
(http://www.amazon.com/gp/product/1590599780/)
- - Pro Nagios 2.0
(http://www.amazon.com/gp/product/1590596099/)
- - Hardening Linux
(http://www.amazon.com/gp/product/1590594444/)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFH5m+G9hTGvAxC30ARApNkAKCbYIYKB4cWK/KY1dWYybhyyiGnVQCgubsH
rDuxxxQrhEF7dor8MzMZwU8=
=P39y
-----END PGP SIGNATURE-----
On Sat, 2008-03-22 at 15:35 -0500, Luke Kanies wrote:
> On Mar 22, 2008, at 2:03 PM, Peter Meier wrote:
>
> >
> > Hi
> >
> > i'm trying to pass Resources (single or in an array) to a resource,
> > so I
> > can pass this to a notify or require. However I have some problems,
> > when
> > no resource should be passed. Maybe somebody can help me? thanks
> >
> > define gentoo::etcconfd (
> > $require = '',
> > $notify = ''
> > ){
>
> You don't need to declare these (in fact, you should be seeing a
> warning for them); all defined types automatically support all
> metaparameters.
What is not clear to me, is if the resources in the define section
inherits the metaparameters or if we have to "propagate" them by hand?
In other words, should I do:
ex:
define my_definition() {
file {
...
}
exec {
...
}
}
or
define my_definition() {
file {
...
require => $require
}
exec {
...
require => $require
}
}
It was my understanding that they fully propagate, but I just want to be
sure it's really the case.
Thanks for clarifying,
--
Brice Figureau <brice-...@daysofwonder.com>
> What is not clear to me, is if the resources in the define section
> inherits the metaparameters or if we have to "propagate" them by hand?
>
> In other words, should I do:
> ex:
> define my_definition() {
> file {
> ...
> }
> exec {
> ...
> }
> }
>
> or
> define my_definition() {
> file {
> ...
> require => $require
> }
> exec {
> ...
> require => $require
> }
> }
>
> It was my understanding that they fully propagate, but I just want
> to be
> sure it's really the case.
This really is very easy to test:
define mptest {
notify { "this is a $name test": }
}
mptest { yay: loglevel => warning }
Prints:
warning: this is a yay test
Notice the loglevel.
--
This book fills a much-needed gap. -- Moses Hadas