Resource Scope

27 views
Skip to first unread message

Douglas Garstang

unread,
Oct 8, 2012, 1:26:35 PM10/8/12
to Puppet Users
I can't work this out and I'm getting frustrated. :(

Puppet is complaining:

err: Failed to apply catalog: Could not find dependency
Lvm::Volume_group[bcvg] for Lvm::Application_volume[cache] at
/truth/sauce/env/prod/modules/object_store/manifests/server.pp:47

Yet, if I comment out that line so that puppet runs ok, and then look
at the state.yml file on the client, I see:

"Lvm::Volume_group[bcvg]":
!ruby/sym checked: 2012-10-08 17:05:45.117364 +00:00

Now, according to the puppet docs at
http://docs.puppetlabs.com/puppet/2.7/reference/lang_scope.html,
resource titles are all global.

So.... what gives? By definition, this should not be occurring.

Doug.

jcbollinger

unread,
Oct 8, 2012, 4:28:37 PM10/8/12
to puppet...@googlegroups.com

Resource titles are global once the associated resource declaration is parsed.  It is up to you to ensure that declarations are parsed in an order that works.  That's not a big deal within one class, but it is potentially an issue when classes reference each others' declarations.

Far and away the best means I know to reliably get a suitable parse order is for each class and definition to 'include' any other classes whose resources or variables it references.  That is incompatible with parametrized-style declarations of those same classes anywhere else in your manifests, however, which is the biggest reason that I have no use for parametrized classes.  In Puppet 3 you can of course rely entirely on the new hiera binding for class parameters, and thereby use only 'include'-style class declarations, but if you are committed to doing that then why parametrize your classes in the first place?

If you are stuck with parametrized classes then your only alternative is to be very careful and deliberate about where and in what order you declare each class.  Minimizing or centralizing interclass and especially intermodule dependencies will make that easier.


John

Reply all
Reply to author
Forward
0 new messages