Peter Meier
2008-Mar-22 19:03 UTC
[Puppet Users] pass Resources to a define or unsetting notify
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 = '''' ){ 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 --~--~---------~--~----~------------~-------~--~----~ 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 http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
Ashley Penney
2008-Mar-22 19:20 UTC
[Puppet Users] Re: pass Resources to a define or unsetting notify
I''m no expert, but why don''t you try wrapping the require => $require statments with an ''if $require'', just to make sure it only tries to set it if the variable exists. That way if you don''t pass a $require, it won''t exist and should work! On Sat, Mar 22, 2008 at 3:03 PM, Peter Meier <peter.meier@immerda.ch> 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 = '''' > ){ > 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 > > > >--~--~---------~--~----~------------~-------~--~----~ 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 http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
Luke Kanies
2008-Mar-22 20:35 UTC
[Puppet Users] Re: pass Resources to a define or unsetting notify
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. 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 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 http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
Peter Meier
2008-Mar-23 10:18 UTC
[Puppet Users] Re: pass Resources to a define or unsetting notify
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.> 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 --~--~---------~--~----~------------~-------~--~----~ 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 http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
James Turnbull
2008-Mar-23 14:56 UTC
[Puppet Users] Re: pass Resources to a define or unsetting notify
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 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 (james@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----- --~--~---------~--~----~------------~-------~--~----~ 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 http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
Brice Figureau
2008-Mar-28 13:26 UTC
[Puppet Users] Re: pass Resources to a define or unsetting notify
Hi, 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-puppet@daysofwonder.com> --~--~---------~--~----~------------~-------~--~----~ 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 http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
Luke Kanies
2008-Mar-28 14:45 UTC
[Puppet Users] Re: pass Resources to a define or unsetting notify
On Mar 28, 2008, at 8:26 AM, Brice Figureau wrote:> 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 --------------------------------------------------------------------- Luke Kanies | http://reductivelabs.com | http://madstop.com --~--~---------~--~----~------------~-------~--~----~ 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 http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
Possibly Parallel Threads
- PC EU feedback: exported resource syntax is too magical, hard to read
- Script work fine on sheel, but no on a cron job
- Ensure overriden service after exec has run
- Possible documentation error, around aliases?
- I am looking to try to mixing sounrce and content in a file instance