On Tuesday, October 30, 2012 1:38:32 PM UTC-5, Brandon Bell wrote:
>
> Hello, 
>
> Little background on what I am trying to do.  
>
> App1 and App2 are both distributed systems, running on both virtual and 
> physical machines.  Mount points for the virtual machines will be /data and 
> mount points for the physical machines will be /disk1/, /disk2/, ... 
> /diskN/.  
>
> In test, both App1 and App2 are running on the same machines so I can't 
> duplicate definitions.  I've read about Virtual Resources, however I cannot 
> figure out how to dynamically pass variables to the Virtual Resource.



In this context, virtual resources are an approach to handling the 
situation that multiple optional, independent classes or resources depend 
on the same resources.  The dependent classes and / or resources cannot 
declare those dependencies directly, lest they result in duplicate 
resources.  If those resources are declared virtually in some central 
place, however, then the dependent classes / resources can 'realize' or 
collect those they need to ensure that they are applied.  Note especially 
the "some central place" bit: you cannot make duplicate virtual 
declarations any more than you can make duplicate concrete ones.

It's not clear to me that that's what you really need for this situation.  
For example, if your two applications use all the same mount points (though 
it may vary from node to node which those actually are) or if the 
applications can safely be assumed to either both be present or both be 
absent, then you might be better off to just put the mounts in a separate 
class and leave them concrete.  Both applications' classes can then 
'include' or otherwise declare that class without any resource duplication.

 

>    I have the following: 
>
>
>
>     class data_mounts {
>
>             file { "$mountpoint":
>                     ensure  => directory,
>                     owner   => root,
>                     group   => root,
>                     mode    => 0644,
>             }
>
>             @mount { "$mountpoint":
>             name  => "${mountpoint}",
>             ensure  => mounted,
>             fstype  => "ext3",
>             options => "defaults,noatime",
>             require => [ File["$mountpoint"], ],
>     
>         }
>     } 
>
> How can I pass in different mountpoints?  I can generate a list of 
> mountpoints and pass them in to a `define` and it works, however I cannot 
> do this using virtual resources in order to work from multiple modules.
>


That class wants to be a defined type instead, with $mountpoint as a 
parameter.  The question is not about how you want to use it, but rather 
about its basic nature -- it has resource nature, not class nature.  Note 
also that resources of defined types can be declared virtually in exactly 
the same way as resources of built-in types.

Nevertheless, I think you're missing the usage pattern.  To use virtual 
resources to solve this sort of problem, you create a class that makes 
virtual declarations *all* of the resources you may need (within some 
problem space of your choosing), and then you 'include' that class and 
'realize' or collect the appropriate subset of those resources wherever you 
need them.  If you cannot enumerate in advance all the resources in the 
chosen space that any class might need, then you cannot apply that pattern.


John

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/puppet-users/-/IVspzDpOBU8J.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to