7

I have the following definitions:

class nginx::install{
  ...
}

class nginx::service{
  ...
}

class nginx::config{
  ...
}

class nginx{
  include nginx::install, nginx::service, nginx::config
}

class jenkins::nginx{
  include nginx

  file{'/etc/nginx/sites-enabled/jenkins':
    source => ...,
    require => Class['nginx'],
  }
}

But when I run this, Puppet tells me that I have a cycle:

err: Could not apply complete catalog: Found 1 dependency cycle:
(Class[Jenkins::Nginx] => File[/etc/nginx/sites-available/jenkins] => Class[Jenkins::Nginx])
Try the '--graph' option and opening the resulting '.dot' file in OmniGraffle or GraphViz

The plain reference to nginx in jenkins::nginx references itself. How do I tell Puppet that I depend on the top-level nginx class instead?

I tried to change my dependency to Class['::nginx'] (as if I was in Ruby), and Puppet now tells me it can't find the dependency.

  • Related: http://serverfault.com/questions/421023/why-does-my-namespace-and-class-name-conflict – quanta Aug 31 '12 at 15:38

2 Answers2

7

Did a ton of testing as your question was interesting...

Found this post after a while: http://www.mail-archive.com/puppet-users@googlegroups.com/msg08224.html

I agree with the poster that this is a bug, or at least not well designed, but if you include the class with absolute scope (::nginx), you can then set a require to it, like so:

class jenkins::nginx{
  include ::nginx

  file{'/etc/nginx/sites-enabled/jenkins':
    source => ...,
    require => Class['::nginx'],
  }
}
Kyle Smith
  • 9,683
  • 1
  • 31
  • 32
0

Include with prefix?

include main:nginx

Korjavin Ivan
  • 2,250
  • 2
  • 26
  • 41