On Fri, Jul 12, 2013 at 7:45 AM, Christian Flamm <
[email protected]> wrote:

> Hi,
> I'm having trouble understanding the added value Virtual Resources
> provide. Let's say I'm having two different modules (that usually are
> assigned to different agents) that both contain a common resource (let's
> say a user). If I want to easily make it possible to assign both modules to
> the same agent - without suffering from the "duplicate resource
> declaration" error - I could make the resource definition virtual and
> realize it in different modules. See this simplified example.
>
> > cat $modulesdir/virtual/manifests/init.pp
> class virtual {
>   @user { 'admin': ensure => present }
> }
>
> > cat $modulesdir/mailserver/manifests/init.pp
> class mailserver {
>   realize(User['admin'])
>   # some more mailserver stuff...
> }
>
> > cat $modulesdir/webserver/manifests/init.pp
> class webserver {
>   realize(User['admin'])
>   # some more webserver stuff...
> }
>
> > cat $manifestsdir/nodes.pp
> node /<somenode>/ {
>   include virtual
>   include mailserver
>   include webserver
> }
>
>
> My question: How is that different, more convenient or more flexible than
> extracting that admin user into its own module? Like that:
>
> > cat $modulesdir/adminuser/manifests/init.pp
> class adminuser {
>   user { 'admin': ensure => present }
> }
>
> > cat $modulesdir/mailserver/manifests/init.pp
> class mailserver {
>   # some more mailserver stuff...
> }
>
> > cat $modulesdir/webserver/manifests/init.pp
> class webserver {
>   # some more webserver stuff...
> }
>
> > cat $manifestsdir/nodes.pp
> node /<somenode>/ {
>   include adminuser
>   include mailserver
>   include webserver
> }
>
>
> I guess I'm missing something here, or I'm using it wrong.
> Your help is highly appreciated,
>

In this simple case no, but think of a vinn diagram with overlapping groups
(such as user belonging to dbadmin/webadmin and two different teams of
dbadmin webadmin). You can easily realize virtual resource by tags, but not
so easy by splitting to class dbadmin/webadmin/db_and_webadmin ...

HTH,

Nan

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-users.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to