To anyone following this, I recently stumbled across this https://tickets.puppetlabs.com/browse/PUP-1963 ... Have you ever tried searching for anything to do with the "resources resource"? It's not very search friendly ;-)
TL;DR, It took a couple of years but this problem was addressed with Puppet 4.3 My original question can be ignored, I've changed the code in master on crayfishx/purge back to something a bit less crazytown as this seems to work as expected with dependencies in 4.3+, we'll just document that relationships aren't supported in Puppet < 4.3, the alternatives are too hacky given the fact there is already a fix in 4. With that in mind, and as an FYI for any users of the crayfishx/purge module, the latest code (which includes the the ability to define *how* to purge stuff, eg: to unmount mounts rather than delete them), will be tidied up and go out soon as 1.2, not 2.0. Thanks, from me and Jeff Goldblum. Craig On Tue, Aug 23, 2016 at 10:00 PM, Craig Dunn <cr...@craigdunn.org> wrote: > > Hi all > > I'm after a bit of advice on talking to some Puppet internals... > background; I have a module called crayfishx/purge which so far has proved > pretty stable and useful. It works on the same principle as the resources > resource in Puppet, in so far that it spits out resources from the generate > method of its type (it also has some way cooler features than resources). > Here's how we currently do it... > > https://github.com/crayfishx/puppet-purge/blob/1.1.0/lib/ > puppet/type/purge.rb#L117-L121 > > That works, but I'm working on a bit of a refactor, the main issue I'm > trying to overcome is https://github.com/crayfishx/puppet-purge/issues/5 > > > I'm not too worried about the first example, but the second one is proving > tricky to solve in a nice way. The problem here is that any resources spat > out from the generate are floating outside of the dependency graph > therefore there is no way to pin dependencies on them. In that example I > want the exec to trigger once all the resources have actually been purged. > > So, following that train of thought I'm trying actually yo get the > resources in their desired state during the execution of the generate > method so, when the purge resource goes into a change state, we can be sure > that all the resources have already been purged, and therefore we can > notify stuff to do afterwards. > > I've played around with some ways today (some of them almost worked, some > of them bat shit crazy), but talking directly to the should=, sync and > flush methods of types just doesn't seem very generic and i kept hitting > problems. > > My final stab at getting this to work was just to create a new catalog > object and apply it in this method.... here is what I've currently got > thats sitting in the master branch.... > > https://github.com/crayfishx/puppet-purge/blob/master/lib/ > puppet/type/purge.rb#L184-L212 > > > That code actually works, and from a functional point of view it does what > I want, so I guess my main questions are; > > * Is this is a _really_ bad idea and if so why? > * Is there a better way? > > The main issue here is that rather than throwing things randomly in the > catalog to be actioned some time in the future, I want to be sure that the > desired state has been maintained when the purge resource has been > evaluated. That is happening now and I'm getting the desired results..... > > > > .... but I don't want to be this guy..... > > > Suggestions really welcome, > > Thanks > Craig > > > -- > Enviatics | Automation and Configuration Management > Puppet Labs Service Delivery Partner & Certified Consultant > http://www.enviatics.com | @Enviatics | cr...@enviatics.com > > -- Enviatics | Automation and Configuration Management Puppet Labs Service Delivery Partner & Certified Consultant http://www.enviatics.com | @Enviatics | cr...@enviatics.com -- You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-dev+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-dev/CACxdKhFs_yu3%2BPbWjSyZUxm%3DSs%2Bvz2Jb_0cB7CcB4BzNsfrcog%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.