Ask Your Question
0

How do I guarantee execution order in puppet?

asked 2015-12-08 16:35:11 -0500

catpants gravatar image

updated 2015-12-08 16:35:37 -0500

I thought I understood how to guarantee execution order, but apparently not.

Currently doing:

class profiles::ldap_server_apt {
  class { 'apt':
  }

  apt::source { 'my_repo':
    location => 'my.repo.com',
  }

  package { 'my_ldap_package':
    require => [Class['apt::update'], Apt::Source['my_repo'] ]
  }
  include profiles::ldap_server
} 

class profiles::ldap_server {
  require profiles::ldap_server_apt

  class { 'openldap::server':
  }                           
}

Yet my_ldap_package still gets installed last. Um, what? How much more explicit can I get about the order I want things to execute? My only guess is that the apt module has some kind of "install packages last no matter what the user says they want" code block but I have no idea.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-12-08 18:02:31 -0500

lavaman gravatar image

updated 2015-12-08 18:07:43 -0500

A class declaration has no effect on ordering. I assume what you are trying to do is make sure that the package gets installed before the openldap::server class runs. Simply declaring the class won't do that. (Also, you should never declare classes unless you are passing them parameters. Just include or require them).

There is nothing in your code that would ensure that the resources in profiles::ldapserverapt get applied before openldap::server. Try the following:

class profiles::ldap_server {
  include profiles::ldap_server_apt
  include openldap::server

  Class['profiles::ldap_server_apt'] -> Class['openldap::server']
}

To elaborate, ordering of resources in puppet is based on the tags the resources have. Each resource gets tagged with the name of the class containing it. Since, in your example, there are no resources in the profiles::ldapserver class, requiring profiles::ldapserverapt does not actually order anything. The last line of my class above effectively says "Ensure all resources tagged with profiles::ldapserver_apt are applied before any resources tagged with openldap::server."

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

2 followers

Stats

Asked: 2015-12-08 16:35:11 -0500

Seen: 663 times

Last updated: Dec 08 '15