Re: [Puppet Users] Autorequire based on resource property???

11 views
Skip to first unread message

Gavin Williams

unread,
Feb 7, 2014, 10:39:44 AM2/7/14
to puppet...@googlegroups.com, puppe...@googlegroups.com
Felix

Thanks for the pointers there...

As discussed on #puppet-dev, I've managed to get it working with the following code: https://gist.github.com/fatmcgav/8864343

However it does raise the question of "Is this the most optimal method to handle this scenario?"

As it means iterating the entire catalog for each resource that wants to auto-require another resource. In a practical application, I could see 6+ resources of different types that might want to autorequire the domain resource.
Is there a more efficient method to pull out specific resource types from the catalogue? Or is the overhead from this operation likely to be soo small as not to worry?

Cross posting to Puppet-dev mailing list for comment aswell.

Cheers
Gavin

On Friday, 7 February 2014 12:50:58 UTC, Felix.Frank wrote:
Hi,

I suppose that should be possible, although the autorequire block will
be a lot more complex than those you're using right now (obviously,
since those are almost trivial - in a good way :-)

You can filter the list of all resources in the catalog for interesting
things to autorequire. This general pattern might get you going
(untested though)

autorequire(...) do
  self.catalog.resources.select { |res|
    # pseudo-code: resource is of desired type
    # and has desired properties/parameters
  }.collect { |res|
    res[:name]
  }
end

Not even sure if :name is the correct key, but I hope this brings the
idea across.

HTH,
Felix

On 02/07/2014 12:51 PM, Gavin Williams wrote:
> In other-words, if I want the /application/ resource type to
> auto-require the appropriate /domain/ resource type, the only
> information I have to relate is based on the '/portbase/' param[3][4].
>
> Is this technically possible? Or am I barking up the wrong tree???
Reply all
Reply to author
Forward
0 new messages