Ask Your Question
2

About Puppet Class Dependencies

asked 2013-08-19 14:54:35 -0500

louis gravatar image

Having the following modules/classes...

module A

class A{
  include A::install, include A::configure
  Class['A::install'] -> Class['A::configure'] 
}

class A::install{
  ..some resources here
}

class A::configure{
 ... some resources here
}

module B

class B {
  require A
}

Based on the documentation. B should enforce the dependency on the A class before executing ANYTHING on B right? or doing the the same thing with another syntax...

module B

    class B{
     include A

     ...whole bunch of resources

     Class['A']->Class['B']
}

Since i want to get rid of the following code like resources:

file{
 ...
 require => Class['A']
 }

It seems that ... (more)

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2013-08-19 20:09:57 -0500

"Classes do not get contained by the class or defined type that declares them."
Source: http://docs.puppetlabs.com/puppet/2.7/reference/lang_containment.html

This is a known design problem in Puppet. Simple resources (eg. file or package) do get included in the correct order because they are contained. However, the same idea of containment doesn't apply to classes because you can include them in more than one place.

Luckily, there is a workaround called the Anchor Pattern. By modifying a contained resource so that is has an explicit require relationship with the classes you want to include ... (more)

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2013-08-19 14:54:35 -0500

Seen: 9,859 times

Last updated: Aug 19 '13