Quantcast
Channel: Ask Puppet: Puppet DevOps Q&A Community - RSS feed
Viewing all articles
Browse latest Browse all 6104

Declare a resource only if not already declared?

$
0
0
I'm writing a module for which there are a number of resources that I want to declare, but only if those resources do not get declared elsewhere - in other words, I want a set of "default" resources that can be overridden. I finally came up with this solution, but I think it won't work due to parsing order dependencies: class foo::defaults { # we want a 'baz' and 'quux' resource, but only if the they haven't # already been defined somewhere else if not defined(foo::bar['baz']) { foo::bar { 'baz': ensure => present } } if not defined(foo::bar['quux']) { foo::bar { 'quux': ensure => present } } # etc... } ... somewhere else ... foo::bar { 'quux': ensure => absent } The issue (I think) is that I need to have class `foo::defaults` _evaluated_ after all possible declarations of `foo::bar` are complete. I'm pretty sure that resource ordering won't help, because that doesn't change evaluation order; similarly with trying to use stages. Does anyone have an alternate solution, or a way to make this solution work? Or can tell me that my evaluation of the ordering issue is wrong? Thanks in advance, - Johnson

Viewing all articles
Browse latest Browse all 6104

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>