Class containment: wrong order

asked 2016-11-11 02:14:54 -0500

Hi,

Regarding to the blog post "class containment in puppet" am I using the following (simplified) setup:

hieradata/common.yaml

classes:
- 'role::base'

site.pp

hiera_include('classes')

site/role/manifests/base.pp

class role::base {
  include profile::base
}

site/profile/manifests/base.pp

class profile::base {
  contain profile::base::network
  contain profile::base::ssh
  Class['profile::base::network'] -> Class['profile::base::ssh']
}

site/profile/manifests/base/network.pp

class profile::base::network {
    err ("network is contained")
 }

site/profile/manifests/base/ssh.pp

class profile::base::ssh {
    err ("ssh is contained")
 }

now I'm doing a puppet apply (puppet 4.8.0)

FACTER_virtual_type=vagrant  puppet apply --hiera_config=hiera.yaml --modulepath=modules:site site.pp

and the output is:

.... 
Error: Scope(Class[Profile::Base::Network]): network is contained
Error: Scope(Class[Profile::Base::Ssh]): ssh is contained
.....

That's expected. Now I'm changing the contain order in the base.pp to:

#switch contain ssh and network in code, but class ordering is the same
contain profile::base::ssh
contain profile::base::network
Class['profile::base::network'] -> Class['profile::base::ssh']

and my puppet apply shows.

Error: Scope(Class[Profile::Base::Ssh]): ssh is contained
Error: Scope(Class[Profile::Base::Network]): network is contained

I would expect that network is still applied first. Or did I understand something wrong?

cheers, Kevin

edit retag flag offensive close merge delete

Comments

Hmm, I can't duplicate your experience on puppet 3.7.4 (it works as expected). I had thought it was err('msg') vs a resource (notify{"msg":}. Can you give a resource a try instead of a function?

DarylW gravatar imageDarylW ( 2016-11-11 08:35:07 -0500 )edit

_Resources_ are ordered by the ordering arrow. Resources are then applied in order. The error/warning/fail messages are not ordered. They are not resources. As catalog compilation proceeds, manifest evaluation can happen in any order. Catalog compilation's just a matter of _in_ or _out_.

Kai Burghardt gravatar imageKai Burghardt ( 2016-11-16 18:02:42 -0500 )edit