On Tuesday, September 30, 2014 10:55:32 AM UTC-5, Chris Lee wrote: > > Hi all, > > We are busy migrating out puppet 2.7 code to puppet 3 and have run into a > problem where we are getting dependency cycles when using tidy. > This mostly happens with stages (and yes, I completely understand why we > should avoid them). > > As an example we have a defined class that we use to create our cron jobs, > and then a tidy to clean up anything that isn't defined. > > class crond::cleanup { > tidy { > "/etc/cron.d": > age => 0, recurse => true, > matches => "*.puppet.cron" > } > } > > define crond::job($jobs,$comment,$mail="root") { > include crond::cleanup > file { > "/etc/cron.d/${name}.puppet.cron": > owner=>root,group=>root, > content=>template("crond/job.erb") > } > } > > > and we get a dependency as follows: > > (File[/etc/cron.d/puppetcheck.puppet.cron] => Tidy[/etc/cron.d] => > Class[Crond::Cleanup] => Stage[main] => Stage[apps] => Stage[apps] => > Stage[post] => Class[Puppet::Service] => Crond::Job[puppetcheck] => > File[/etc/cron.d/puppetcheck.puppet.cron]) > > Does anyone know of a workaround? > >
Yes. Stop using run stages. That's somewhat tongue-in-cheek, but it is certainly the case that your use of run stages is a significant factor in this problem, and that use of run stages is prone to this kind of problem in general. That doesn't necessarily mean you shouldn't use run stages at all, but I usually discourage it. There is nothing you can express via stages that you cannot also express (albeit more verbosely) via ordinary resource relationships, and although stages are not inherently bad, but they are trickier to use and more dangerous than their documentation might lead you to believe. If you feel compelled to use stages, then I recommend that you at least tread lightly: as much as possible should go in Stage[main], and there should be no more than three stages altogether (up to one preceding main and up to one following it). As for the specifics of your case, not all of the relationships in that cycle are coming from the code you presented, and the reasons for some of them are unclear to me. In addition to the run stage assignments, it is unclear - whether Class[Puppet::Service] actually needs the specified relationship with Crond::Job[puppetcheck]; - where the relationship File[/etc/cron.d/puppetcheck.puppet.cron] -> Tidy[/etc/cron.d] is coming from; it could in principle be an autorequire, but no such autorequire is documented in the type reference, and neither the code for the File type nor the code for the Tidy type appears to have such an autorequire - why Crond::Job[puppetcheck] needs to be applied in Stage[post], or after Class[Puppet::Service] specifically If any of those is wrong or unneeded, then getting rid of it will probably help. I cannot explain why this issue did not appear under Puppet 2.7. Is it possible that a change applied as part of your migration process is contributing? John -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/9db57030-8527-447a-a0a7-434d425c27ea%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.