Ask Your Question

How can I ensure three modules are configured in the order I specify?

asked 2012-11-01 13:43:28 -0600

Dawn gravatar image

updated 2012-11-02 09:24:22 -0600

I have three modules, apt, java, and tomcat. I need Puppet to configure the apt module first so packages can be installed, java second so tomcat requirements are satisfied, and finally tomcat so I can deploy my application.

I've created a wrapper class named javastack to manage these dependencies in the order I want:

class javastack {
  class { apt:
    before => Class[java],
  class { java:
    before => Class[tomcat],
  class { tomcat: }

I have another class named contentmanager to manage my CMS application after tomcat has been configured:

class contentmanager {
  class { javastack: }
  class { opencms:
    require => Class[javastack]

However, the relationships I've specified ... (more)

edit retag flag offensive close merge delete


Is there a way for a contributor to add additional tags? Might I suggest "stdlib" and "relationship"?

jmccune gravatar imagejmccune ( 2012-11-01 15:42:33 -0600 )edit

I've added those tags.

Dawn gravatar imageDawn ( 2012-11-02 09:24:41 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2012-11-01 15:35:45 -0600

The anchor pattern is intended to address this type of problem. They method I use to determine if a problem might be resolved with the anchor pattern is to ask, "is there a class that declares other classes but has no resources itself?" The javastack class contains no resources itself, only classes, so the anchor pattern applies.

The root cause of the problem is that Puppet establishes relationships to the resources inside of a class, not to the class itself. When a class contains no resources, only classes, there is nothing to establish a relationship. As a result the apt ... (more)

edit flag offensive delete link more

Comments is the missing image in the above.

carthik gravatar imagecarthik ( 2013-06-24 15:33:48 -0600 )edit

answered 2012-12-18 17:12:55 -0600

jsosic gravatar image

updated 2012-12-18 17:17:44 -0600

If you don't want to use anchor from stdlib, you can just declare 'require' in your class manifests. So in your case that would look like this:

class apt {
  apt resources
class java {
  require apt
  java resources
class tomcat {
  require java
  tomcat resources

After that you could include only tomcat in your node manifest, and everything would work:

node 'blah' {
  include tomcat

'require' used as function and not as resource param does exactly the same thing as include, expect that it applies all resources from required class before ap plying the initial class.

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



Asked: 2012-11-01 13:43:28 -0600

Seen: 737 times

Last updated: Dec 18 '12