1

as many people, I have a class dependency problem with puppet. Either one class gets executed too early or I end up in a dependency cycle.

Following setup:

node foo:
  require base
  include somethingelse

class base:
  require sources // <- class defines package sources needed for everything

class somethingelse
  apt::builddep { 'foo': } // <- requires some package sources

To my understanding, node foo gets executed but has a requirement to base, so puppet proceeds executing that first. base's first line requires sources so puppet will execute that first. builddep comes last.

However it does the exact opposite. Sources are getting executed at any time without any logic (like a ressource without dependencies). Many times after builddep which results in a puppet error since the source it needs is not there yet.

When I defined the node dependencies like so:

include "base"
include "somethingelse"

Class['base'] -> Class['somethingelse']

Or add Class['sources'] as dependency to builddep, I am getting a dependency cycle similar to this:

(Anchor[apt::source::puppetlabs] => Apt::Source[puppetlabs] => Class[Sources] => Class[Base] => Cron[execute-puppet] => Class[Base] => Class[somethingelse] => Apt::Builddep[foo] => Exec[apt-builddep-foo] => Exec[apt_update] => Class[Apt::Update] => Anchor[apt::source::puppetlabs])

What am I doing wrong? Can someone point me into the correct direction? The important thing is, that everything in base (including sources) is getting executed before class somethingelse (and therefore builddep)

EDIT

Narrowing it down. The problem is, that builddep doesn't require sources to be there. Without any requirements, builddep gets executed before sources are being added, but requires a apt-get update. When adding a requirement to my sources class, I fall into a dependency cycle once again.

Currently trying this one: Apt::Source <| |> -> Apt::Builddep <| |> which results in

(Anchor[apt::source::puppetlabs] => Apt::Source[puppetlabs] => Apt::Builddep[foo] => Exec[apt-builddep-foo] => Exec[apt_update] => Class[Apt::Update] => Anchor[apt::source::puppetlabs])
  • Can you provide the configuration that's throwing this error? There's some strange requirement relationships that it's talking about there, Class[Base] => Cron[execute-puppet] => Class[Base] seems particularly wacky. It seems like you've hardcoded a dependency into the internals of the puppetlabs apt module? – Shane Madden Jul 5 '14 at 18:09
  • @ShaneMadden I am using puppet masterless. execute-puppet is cron resource which makes sure the puppet pull gets executed all 10 minutes. Base resource: pastebin.com/gLvQQ9b6. Node: pastebin.com/Zw5EytJK. Somethingelse: pastebin.com/SAV3jz8k. I trimmed it down to the important parts – dvcrn Jul 5 '14 at 23:45
  • And sources class here - pastebin.com/TCn87sDM – dvcrn Jul 5 '14 at 23:46
2

I concluded this to be a bug in apt. builddep notifies apt-get update instead of requiring it, which doesn't make much sense in my opinion. You want apt-get update to be executed before installing build dependencies.

I patched apt to require apt-get update, which solves my dependency cycle. Submitted a pull request to apt to see what the devs say.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.