An array is passed to aegir::platform_directory causing it to invoke
the define aegir::platform_directory multiple times. In the define I
set namevar of the exec to "unpack-drupal-${name}" in order to to
avoid the error "Duplicate definition: Exec[unpack-drupal]".
class aegir::platform::dev inherits aegir::platform {
$environments = [ "dev", "qa" ]
if $environments {
aegir::platform_directory { $environments:
platform_dir => $platform_dir,
}
}
}
define aegir::platform_directory (
ensure = "directory",
source = "puppet:///aegir/empty"
) {
file {"${name}":
ensure => $ensure,
recurse => true,
force => $ensure ? {
"absent" => true,
default => false
},
source => $source,
owner => $aegir_unix_user,
group => $aegir_unix_group,
#TODO: selinux
mode => 775,
}
/*
* setting namevar "unpack-drupal-${name}" to avoid "Duplicate
definition:
* Exec[unpack-drupal]" resulting from passing an array to this
define.
*
* tar.gz files seem to be automatically cleaned up--no need to
remove them.
*/
exec { "unpack-drupal-${name}":
command => "/bin/tar zxf *.gz && /bin/rm *.gz",
cwd => $name,
onlyif => "test -e *.gz",
require => File[$name],
}
}
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.
Ohad Levy
2010-Mar-11 04:19 UTC
Re: [Puppet Users] Is setting a dynamic namevar bad practice?
hmm.. one option would be to use a virtual @exec, and realize it instead. Ohad On Thu, Mar 11, 2010 at 7:45 AM, briwood <briwood@berkeley.edu> wrote:> An array is passed to aegir::platform_directory causing it to invoke > the define aegir::platform_directory multiple times. In the define I > set namevar of the exec to "unpack-drupal-${name}" in order to to > avoid the error "Duplicate definition: Exec[unpack-drupal]". > > > class aegir::platform::dev inherits aegir::platform { > > $environments = [ "dev", "qa" ] > if $environments { > aegir::platform_directory { $environments: > platform_dir => $platform_dir, > } > } > > } > > > define aegir::platform_directory ( > ensure = "directory", > source = "puppet:///aegir/empty" > ) { > > file {"${name}": > ensure => $ensure, > recurse => true, > force => $ensure ? { > "absent" => true, > default => false > }, > source => $source, > owner => $aegir_unix_user, > group => $aegir_unix_group, > #TODO: selinux > mode => 775, > } > > /* > * setting namevar "unpack-drupal-${name}" to avoid "Duplicate > definition: > * Exec[unpack-drupal]" resulting from passing an array to this > define. > * > * tar.gz files seem to be automatically cleaned up--no need to > remove them. > */ > exec { "unpack-drupal-${name}": > command => "/bin/tar zxf *.gz && /bin/rm *.gz", > cwd => $name, > onlyif => "test -e *.gz", > require => File[$name], > } > > } > > -- > 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+unsubscribe@googlegroups.com<puppet-users%2Bunsubscribe@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en. > >-- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Brice Figureau
2010-Mar-11 16:54 UTC
Re: [Puppet Users] Is setting a dynamic namevar bad practice?
On Wed, 2010-03-10 at 15:45 -0800, briwood wrote:> An array is passed to aegir::platform_directory causing it to invoke > the define aegir::platform_directory multiple times. In the define I > set namevar of the exec to "unpack-drupal-${name}" in order to to > avoid the error "Duplicate definition: Exec[unpack-drupal]".I don''t consider this as bad practice. I''m often using this pattern. The only caveat is if you need to before/require/notify/subscribe such resources. -- Brice Figureau Follow the latest Puppet Community evolutions on www.planetpuppet.org! -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.