Ask Your Question

Order of puppt module execution, Stages

asked 2016-05-10 08:10:01 -0600

bortek gravatar image

What problem/issue/behavior are you having trouble with? What do you expect to see?

I have a bunch of puppet modules that are executed during new server installation. Some modules fail because they are dependant on the things that are being fixed by other modules.

For example sssd/Ldap module should be executed before other modules that do some manipulation that requires users .

So my quesrtion is how do I tell which modules should be executed in which order. And I mean seperate puppet modules.

I know there are so called Run Stages but it is not clear how to use it with multiple existingpuppet modules.

Please help!

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2016-05-12 07:46:48 -0600

FranzCC gravatar image

updated 2016-05-19 03:06:14 -0600

i had the very same problem and since i had one dependency in one module is used:
require [class]
and then the normal ordering arrows ~> or -> for the following statements.
Require always executes the code before the next term.

Hope that helps

Rgds. Franz

Edit: E.g: I have two modules
One does the interface ordering using udev, the other installs the kernel

require udev_cpe::validate

file { '/var/cache/apt/archives/aufs-image-3.18.19.aufs-cpe_3.18.19.aufs-cpe-10.00.Custom_amd64.deb':
  ensure => present,
  mode => "0644",
  source => 'puppet://',
} ~>
package { 'aufs-image-3.18.19.aufs-cpe':
  ensure => installed,
  provider => dpkg,
  name => 'aufs-image-3.18.19.aufs-cpe',
  source => '/var/cache/apt/archives/aufs-image-3.18.19.aufs-cpe_3.18.19.aufs-cpe-10.00.Custom_amd64.deb',
  require => FILE['/var/cache/apt/archives/aufs-image-3.18.19.aufs-cpe_3.18.19.aufs-cpe-10.00.Custom_amd64.deb'],
} ~>
reboot { 'after aufs-image-3.18.19.aufs-cpe':
  subscribe => Package['aufs-image-3.18.19.aufs-cpe'],

The first line with "require" will be executed at first.
udev_cpe::validate is a class in another, INSTALLED module ! (Of course it has to be classified for the group the node is in !!!)
The rest will be executed one by one and at the end the cpe reboots after a successful installation of the kernel image !

edit flag offensive delete link more


I dont really understand how you mean. Can yo give an example?

bortek gravatar imagebortek ( 2016-05-12 08:19:29 -0600 )edit

E.g: (i need my udev class before i install a kernel package)
require udev::validate
package { 'linux-image':
etc. Require was the key !

FranzCC gravatar imageFranzCC ( 2016-05-12 08:24:04 -0600 )edit

It should be clear now. Updated my anwser !

FranzCC gravatar imageFranzCC ( 2016-05-13 00:43:25 -0600 )edit

Okej this seems to work. :) I have added "require classname" in the begining of my class after the opening square bracket "{" on a new line and yes it did what it supposed to do. Thanks for your help!

bortek gravatar imagebortek ( 2016-05-16 06:56:36 -0600 )edit

answered 2016-05-11 11:29:18 -0600

ideally shouldnt have intermodule dependencies - but we dont live in an ideal world!

if module a depends on modules x,y,z etc then in module a's init.pp just add an include x etc.. this is probably the simplest way of doing this.

edit flag offensive delete link more


an include doesn't ensure that the other classes resources have all resolved before your class is done. using 'contain' instead of 'include' ( Also, use resource ordering to sort your classes.

DarylW gravatar imageDarylW ( 2016-05-11 22:01:06 -0600 )edit

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: 2016-05-10 08:10:01 -0600

Seen: 618 times

Last updated: May 19 '16