I run into this problem often. I usually encounter it trying to make independent modules A and B, which both depend on some directory. Or even just around realizing users, I'd love to not worry about realizing the same user twice.
Anyhow, it's imperfect, but you can check if something is defined, and if it's not then define it. seph Jon Stanley <jonstan...@gmail.com> writes: > I'm attempting to use virtual resources to get around multiple > definition errors, but it doesn't seem to be working. I need to > create a directory structure like "/apps/siteA/instance_1/resin" and > "/apps/siteA/instance_2/resin". In reality it's a little more complex, > because there are multiple sites running on a given node. Anyhow, > here's how I've defined it: > > define resin::instance( > $site_alias, > $env_alias, > $instance, > $host_alias, > $resin_ver, > $java_ver > ) { > include resin::base > @file { "/apps/runtime/$site_alias": > owner => cnp, > group => cnp-admin, > mode => 0755, > require => File["/apps/runtime"], > ensure => directory; > "/apps/runtime/$site_alias/$env_alias": > owner => cnp, > group => cnp-admin, > mode => 0755, > require => File["/apps/runtime/$site_alias"], > ensure => directory; > > "/apps/runtime/$site_alias/$env_alias/resin/${host_alias}_${env_alias}_${instance}": > owner => cnp, > group => cnp-admin, > mode => 0755, > require => File["/apps/runtime/$site_alias/$env_alias"], > ensure => directory; > } > realize File["/apps/runtime/$site_alias"] > realize File["/apps/runtime/$site_alias/$env_alias"] > realize > File["/apps/runtime/$site_alias/$env_alias/resin/${host_alias}_${env_alias}_${instance}"] > > } > > I was thinking that using the virtual resource in the definition would > get around the errors, but it doesn't seem to have: > > err: Could not retrieve catalog: Puppet::Parser::AST::Resource failed > with error ArgumentError: Duplicate definition: File[/apps/runtime/gq] > is already defined in file > /var/lib/puppet/git/modules/resin/manifests/init.pp at line 40; cannot > redefine at /var/lib/puppet/git/modules/resin/manifests/init.pp:40 on > node s602250nj3el563.uspswy6.savvis.net > > What's another approach to doing this? The end goal is having one > simple call to define an instance, not mattering if the site is known > or unknown (so a bunch of classes to include wouldn't be scalable > here), or if it's on that machine or not - i.e. from one simple > resin::instance call, I should be able to have a functional instance. > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Users" group. 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 -~----------~----~----~----~------~----~------~--~---