Ask Your Question
0

resource ordering issue

asked 2014-11-07 05:04:41 -0500

jaksky gravatar image

updated 2014-11-07 05:14:01 -0500

Hello,

I am having a problem with ordering or class containment. I have following code:

 class { 'elasticsearch::repo': before => Class['elasticsearch::install'] }

      class { 'elasticsearch::install': before => Class['elasticsearch::configure'] }

      class { 'elasticsearch::configure': }

The problem here is that package resource which is inside a install is running before repository installations from repo class. Acording to this documentation https://docs.puppetlabs.com/puppet/latest/reference/lang_containment.html that shouldn't be the case. classes install and repo contains standard resource or realization of virtual resource in case of repo. Is that a problem? How the containment works with virtual resources and its realization?

Am I missing something here?

I am using puppet 3.7.1 thx

edit retag flag offensive close merge delete

Comments

Do any of these classes contain subclasses? Have you ensured that everything is either contained or anchored in place?

cbarbour gravatar imagecbarbour ( 2014-11-07 12:28:31 -0500 )edit

Doesn't contain any classes just resources, so containment should be by default. Or how do I anchor resources within class?

jaksky gravatar imagejaksky ( 2014-11-07 16:55:29 -0500 )edit

In this case, the repos in elasticsearch::repo should be applied before the packages in elasticsearch::install, with no other changes, so you're okay there. Have you checked the dependency graph? https://docs.puppetlabs.com/guides/faq.html#how-do-i-use-puppets-graphing-support

cbarbour gravatar imagecbarbour ( 2014-11-07 18:17:12 -0500 )edit

Yea, that was my expectation as well but that doesn't match expected to true behaviour. repo class contains just realize(Yumrepo['internalYum']). Seems that containment doesn't apply when virtual resources are in place. Resource definition is in parent class - inheritance.

jaksky gravatar imagejaksky ( 2014-11-10 02:29:02 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2014-11-10 18:09:26 -0500

cbarbour gravatar image

The original poster comments:

repo class contains just realize(Yumrepo['internalYum']). Seems that containment doesn't apply when virtual resources are in place. Resource definition is in parent class - inheritance.

I think you solved your own problem. Containment works on the service definition. With virtual resources, that happens where the resource is declared, not where it's realized. The workaround would be to declare an explicit relationship between the other classes and internalYum, perhaps using a collector.

See this long thread regarding how Virtual Resources are implemented under the hood.

Generally, I prefer to use run stages to setup package repositories. It's one of the few cases where stages are recommended.

edit flag offensive delete link more

Comments

That what I exactly did just didn't understand the whole story.

jaksky gravatar imagejaksky ( 2014-11-11 02:30:31 -0500 )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

1 follower

Stats

Asked: 2014-11-07 05:04:41 -0500

Seen: 105 times

Last updated: Nov 10 '14