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

-- 
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/CACxdKhEwL22T05824xbGfTagdW2bJOwUeK_yW7jvgr20VSCJpg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to