Questions about virtual resources and resource chaining

113 views
Skip to first unread message

Ramin K

unread,
Mar 7, 2012, 9:02:34 PM3/7/12
to puppet...@googlegroups.com
I managed to trigger this behavior when I realized the readline package in the ruby_devel class instead of specifying it. It appears that the resource chain in the rvm class does not include the realized resource. Is this the current expected behavior?  I'm running 2.7.11 on the client and server.

class vpackages
  @package { 'readline': }
}

class
ruby_devel
{ realize Package['readline'] }

class rvm {
  include ruby_devel
  include rvm::params, rvm::data, rvm::install
  Class['ruby_devel'] -> Class['rvm::install']
}

Ramin

jcbollinger

unread,
Mar 8, 2012, 10:48:52 AM3/8/12
to Puppet Users


On Mar 7, 8:02 pm, Ramin K <ramin.khat...@gmail.com> wrote:
> I managed to trigger this behavior when I realized the readline package in
> the ruby_devel class instead of specifying it. It appears that the resource
> chain in the rvm class does not include the realized resource. Is this the
> current expected behavior?


I think so. This appears to be a somewhat special case of confusing
parse order with application order. Class['ruby_devel'] does not
actually do anything during resource application -- realizing a
virtual package is strictly a server-side activity.
Package['readline'] belongs to Class['vpackages'], so if you want to
express your order dependency on a class instead of directly on
Package['readline'] then the class to target should be
Class['vpackages'].

If you want to hide that a bit, then I think you could add

Class['vpackages'] -> Class['ruby_devel']

in the same file as ruby_devel, right after the class's closing
brace. Probably. Then the chain in your "rvm" class should have the
expected result.


>  I'm running 2.7.11 on the client and server.
>
> class vpackages
>   @package { 'readline': }
>
> }
>
> class ruby_devel {
>   realize Package['readline']
>
> }
>
> class rvm {
>   include ruby_devel
>   include rvm::params, rvm::data, rvm::install
>   Class['ruby_devel'] -> Class['rvm::install']
>
> }


John

Ramin K

unread,
Mar 8, 2012, 12:11:10 PM3/8/12
to puppet...@googlegroups.com
On Thursday, March 8, 2012 7:48:52 AM UTC-8, jcbollinger wrote:


On Mar 7, 8:02 pm, Ramin K <ramin.khat...@gmail.com> wrote:
> I managed to trigger this behavior when I realized the readline package in
> the ruby_devel class instead of specifying it. It appears that the resource
> chain in the rvm class does not include the realized resource. Is this the
> current expected behavior?


I think so.  This appears to be a somewhat special case of confusing
parse order with application order.  Class['ruby_devel'] does not
actually do anything during resource application -- realizing a
virtual package is strictly a server-side activity.
Package['readline'] belongs to Class['vpackages'], so if you want to
express your order dependency on a class instead of directly on
Package['readline'] then the class to target should be
Class['vpackages'].


I was inclined to think it was my mistake, but wanted to make sure after looking at a few bugs around virtuals. Thanks for the explanation, that has helped me get it straight in my head. .

Ramin
Reply all
Reply to author
Forward
0 new messages