Dear all, I''m getting this "Duplicate definition" error but can''t make sure what''s going wrong. I have this definition: voms in the vomscert.pp: # /etc/puppet/modules/d_services/manifests/vomscert.pp ---------------------------------------------------------------------------- class d_services::vomscert { define voms($dir, $lsc) { $voms_dir = ''/etc/grid-security/vomsdir'' exec { ''chk_vomsdir'': path => [ ''/bin'', ''/usr/bin'' ], command => "test -d ${voms_dir}/${dir}", } file { "${dir}": name => "${voms_dir}/${dir}/${lsc}", mode => ''0644'', owner => ''root'', group => ''root'', source => "puppet:///modules/d_services/vomsdir/${lsc}", require => Exec[ ''chk_vomsdir'' ]; } } } And then, in this is in the init.pp: # /etc/puppet/modules/d_services/manifests/init.pp: -------------------------------------------------------------------- class voms_cert { include d_services::vomscert d_services::vomscert::voms { ''camont.lsc'': dir => ''camont'', lsc => ''voms.gridpp.ac.uk.lsc''; ''atlas.lsc'': dir => ''gridpp'', lsc => ''voms.cern.ch.lsc''; } } On the agent, it fails, reporting: err: Could not retrieve catalog from remote server: Error 400 on SERVER: Duplicate definition: Exec[chk_vomsdir] is already defined in file /etc/puppet/modules/d_services/manifests/vomscert.pp at line 11; cannot redefine at /etc/puppet/modules/d_services/manifests/ vomscert.pp:11 Any idea what am I missing? Cheers, San -- 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.
Bernd Adamowicz
2012-Apr-12 13:55 UTC
AW: [Puppet Users] Error 400 on SERVER: Duplicate definition
Try to change * exec { ''chk_vomsdir'': to something like * exec { "chk_vomsdir_${dir}": and * require => Exec[ ''chk_vomsdir'' ]; to * require => Exec["chk_vomsdir_${dir}"]; This should make everything unique. Bernd> -----Ursprüngliche Nachricht----- > Von: puppet-users@googlegroups.com [mailto:puppet- > users@googlegroups.com] Im Auftrag von Sans > Gesendet: Donnerstag, 12. April 2012 15:50 > An: Puppet Users > Betreff: [Puppet Users] Error 400 on SERVER: Duplicate definition > > Dear all, > > I''m getting this "Duplicate definition" error but can''t make sure > what''s going wrong. I have this definition: voms in the vomscert.pp: > > > # /etc/puppet/modules/d_services/manifests/vomscert.pp > ----------------------------------------------------------------------- > ----- > class d_services::vomscert { > > define voms($dir, $lsc) { > > $voms_dir = ''/etc/grid-security/vomsdir'' > exec { ''chk_vomsdir'': > path => [ ''/bin'', ''/usr/bin'' ], > command => "test -d ${voms_dir}/${dir}", > } > > file { "${dir}": > name => "${voms_dir}/${dir}/${lsc}", > mode => ''0644'', owner => ''root'', group => ''root'', > source => "puppet:///modules/d_services/vomsdir/${lsc}", > require => Exec[ ''chk_vomsdir'' ]; > } > } > } > > > > And then, in this is in the init.pp: > > # /etc/puppet/modules/d_services/manifests/init.pp: > -------------------------------------------------------------------- > class voms_cert { > > include d_services::vomscert > > d_services::vomscert::voms { > ''camont.lsc'': > dir => ''camont'', > lsc => ''voms.gridpp.ac.uk.lsc''; > > ''atlas.lsc'': > dir => ''gridpp'', > lsc => ''voms.cern.ch.lsc''; > } > } > > > > On the agent, it fails, reporting: > > err: Could not retrieve catalog from remote server: Error 400 on > SERVER: Duplicate definition: Exec[chk_vomsdir] is already defined in > file /etc/puppet/modules/d_services/manifests/vomscert.pp at line 11; > cannot redefine at /etc/puppet/modules/d_services/manifests/ > vomscert.pp:11 > > Any idea what am I missing? > > Cheers, > San > > -- > 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.-- 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.
WOW!! that was real fast (I feel myself so silly now!!). Thanks a lot. But do you mind explaining why I was getting errors in the first place? If I do that ''static way'', like this: # /etc/puppet/modules/d_services/manifests/init.pp: --------------------------------------------------- class voms_cert { $voms_dir = ''/etc/grid-security/vomsdir'' exec { ''chk_vomsdir'': path => [ ''/bin'', ''/usr/bin'' ], command => "test -d ${voms_dir}", } file { ''camont'': name => "${voms_dir}/camont/voms.gridpp.ac.uk.lsc", mode => ''0644'', owner => ''root'', group => ''root'', source => "puppet:///modules/d_services/vomsdir/ voms.gridpp.ac.uk.lsc", require => Exec[ ''chk_vomsdir'' ]; ''atls'': name => "${voms_dir}/atlas/voms.cern.ch.lsc", mode => ''0644'', owner => ''root'', group => ''root'', source => "puppet:///modules/d_services/vomsdir/ voms.cern.ch.lsc", require => Exec[ ''chk_vomsdir'' ]; } } --------------------------------------------------- I don''t get any error at all. Cheers, San On Apr 12, 2:55 pm, Bernd Adamowicz <Bernd.Adamow...@esailors.de> wrote:> Try to change > > * exec { ''chk_vomsdir'': > > to something like > > * exec { "chk_vomsdir_${dir}": > > and > > * require => Exec[ ''chk_vomsdir'' ]; > > to > > * require => Exec["chk_vomsdir_${dir}"]; > > This should make everything unique. > > Bernd-- 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.
Bernd Adamowicz
2012-Apr-12 14:19 UTC
AW: [Puppet Users] Re: Error 400 on SERVER: Duplicate definition
No problem. You''re wellcome! And you''re not silly. It''s just a common pitfall. If you define a resource within a function, this resource will be re-defined with every function call. And since resources have to be unique, the second call to the function will lead to a duplicate definition. So that''s expected behavior. The only thing that could be improved is the error message which does not lead to the real problem. Maybe the Puppet guys could work on this in the future ;-) Cheers Bernd> -----Ursprüngliche Nachricht----- > Von: puppet-users@googlegroups.com [mailto:puppet- > users@googlegroups.com] Im Auftrag von Sans > Gesendet: Donnerstag, 12. April 2012 16:11 > An: Puppet Users > Betreff: [Puppet Users] Re: Error 400 on SERVER: Duplicate definition > > WOW!! that was real fast (I feel myself so silly now!!). Thanks a lot. > But do you mind explaining why I was getting errors in the first place? > If I do that ''static way'', like this: > > > # /etc/puppet/modules/d_services/manifests/init.pp: > --------------------------------------------------- > class voms_cert { > > $voms_dir = ''/etc/grid-security/vomsdir'' > exec { ''chk_vomsdir'': > path => [ ''/bin'', ''/usr/bin'' ], > command => "test -d ${voms_dir}", > } > > file { > ''camont'': > name => "${voms_dir}/camont/voms.gridpp.ac.uk.lsc", > mode => ''0644'', owner => ''root'', group => ''root'', > source => "puppet:///modules/d_services/vomsdir/ > voms.gridpp.ac.uk.lsc", > require => Exec[ ''chk_vomsdir'' ]; > > ''atls'': > name => "${voms_dir}/atlas/voms.cern.ch.lsc", > mode => ''0644'', owner => ''root'', group => ''root'', > source => "puppet:///modules/d_services/vomsdir/ > voms.cern.ch.lsc", > require => Exec[ ''chk_vomsdir'' ]; > } > } > --------------------------------------------------- > > I don''t get any error at all. > > Cheers, > San > > > On Apr 12, 2:55 pm, Bernd Adamowicz <Bernd.Adamow...@esailors.de> > wrote: > > Try to change > > > > * exec { ''chk_vomsdir'': > > > > to something like > > > > * exec { "chk_vomsdir_${dir}": > > > > and > > > > * require => Exec[ ''chk_vomsdir'' ]; > > > > to > > > > * require => Exec["chk_vomsdir_${dir}"]; > > > > This should make everything unique. > > > > Bernd > > -- > 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.-- 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.
Thanks Bernd! Make sense. Cheers!! On Apr 12, 3:19 pm, Bernd Adamowicz <Bernd.Adamow...@esailors.de> wrote:> No problem. You''re wellcome! And you''re not silly. It''s just a common pitfall. If you define a resource within a function, this resource will be re-defined with every function call. And since resources have to be unique, the second call to the function will lead to a duplicate definition. > > So that''s expected behavior. The only thing that could be improved is the error message which does not lead to the real problem. Maybe the Puppet guys could work on this in the future ;-) > > Cheers Bernd-- 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.