Ask Your Question
4

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

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

Dawn gravatar image

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

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

Comments

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 -0500 )edit
1

I've added those tags.

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

2 Answers

Sort by ยป oldest newest most voted
8

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

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

http://projects.puppetlabs.com/attachments/1688/Anchor_no_relationships.png is the missing image in the above.

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

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

jsosic gravatar image

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

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

6 followers

Stats

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

Seen: 668 times

Last updated: Dec 18 '12