Luc Suryo
2010-Sep-14 00:41 UTC
[Puppet Users] call define and keep getting Duplicate definition
Hello I been Google-ing and read docs for couple hours and can not see what I do wrong... can someone help? in my nodes i have include our-nagios::client the the our-nagios::client looks like this class our-nagiios::client { case $operatingsystem { "centos" : { $nagios_plugins_dir = "/usr/lib64/nagios/ plugins" } "redhat" : { $nagios_plugins_dir = "/usr/lib64/nagios/ plugins" } "debian" : { $nagios_plugins_dir = "/usr/lib/nagios/ plugins" } "ubuntu" : { $nagios_plugins_dir = "/usr/lib/nagios/ plugins" } } define my_nagios_plugins ( $name ) { file { "$name" : name => "$nagios_plugins_dir/$name", source => "puppet:///nagios/etc/nagios/bin/ $name", mode => 0555, owner => bin, group => bin, replace => true, ensure => file, after => File [ "$nagios_plugins_dir" ], } } file { "$nagios_plugins_dir" : name => "$nagios_plugins_dir", mode => 0755, owner => bin, group => bin, ensure => directory, } my_nagios_plugins { [ "check_disk.pl", "check_kestrel", "check_mongo", "check_fmongo_repl", "check_memcached.py", "check_mmm_agent", "check_mmm_mon", "check_mmm_mon_cluster", "check_outgoing_traffic", "check_ram" ]: } } What I want todo is able to add (and later remove) plugins with the correct permissions and ownerschip... and rather not to have to duplicate the ''file'' entry for each plugins but I keep getting this error: err: Could not retrieve catalog from remote server: Error 400 on SERVER: Duplicate definition: Our- nagios::Client::My_nagios_plugins[check_kestrel] is already defined in file /var/lib/puppet/our/modules/our-nagios/manifests/client.pp at line 51; cannot redefine at /var/lib/puppet/our/modules/our-nagios/ manifests/client.pp:51 on node puppet What do I do wrong? can some please help? thanks -- 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.
Nan Liu
2010-Sep-14 01:47 UTC
Re: [Puppet Users] call define and keep getting Duplicate definition
On Mon, Sep 13, 2010 at 5:41 PM, Luc Suryo <lsuryo@gmail.com> wrote:> I been Google-ing and read docs for couple hours and can not see what > I do wrong... can someone help? >Yes, except the code you copied and pasted doesn''t match the error message since it should of thrown a cannot find class error among several other issues, so I''m not sure how it even got to the error message in your email. class our-nagiios::client { class our-nagios::client define my_nagios_plugins ( $name ) {>You don''t need to pass $name as a variable, $name = the title/namevar of the resource, and $name is only in scope between { }. Puppet should throw an exception here as well. It should simply be: define my_nagios_plugins() {> file { "$name" : > name => "$nagios_plugins_dir/$name", >did you mean path => "${nagios_plugins_dir}/${name}" instead of name => ... ?> source => "puppet:///nagios/etc/nagios/bin/ > $name", > mode => 0555, owner => bin, group => bin, > replace => true, > ensure => file, > after => File [ "$nagios_plugins_dir" ], >Do you mean require => File["$nagios_plugins_dir"] ? File dependency is implicit, so puppet knows to require a parent directory before the file, so it''s not necessary. Thanks, Nan -- 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.
Luc Suryo
2010-Sep-14 02:13 UTC
Re: [Puppet Users] call define and keep getting Duplicate definition
Hello Nan, The reason of checking the directory is because sometime we have server with special installation and hence do not have the nagios-plugins packages installed.. but still it does not work.. Well let me cut and past the whole file: class fly-nagios::client inherits fly-nagios::base { include nagios::base case $operatingsystem { "centos" : { $nagios_plugins_dir "/usr/lib64/nagios/plugins" } "redhat" : { $nagios_plugins_dir "/usr/lib64/nagios/plugins" } "debian" : { $nagios_plugins_dir = "/usr/lib/nagios/plugins" } "ubuntu" : { $nagios_plugins_dir = "/usr/lib/nagios/plugins" } } file { "$nagios_plugins_dir" : name => "$nagios_plugins_dir", mode => 0755, owner => bin, group => bin, ensure => directory, } define nagiosPlugins () { file { "$name" : path => "$nagios_plugins_dir/$name", source => "puppet:///fly-nagios/etc/nagios/bin-fly/$name", mode => 0555, owner => bin, group => bin, replace => true, ensure => file, } } nagiosPlugins { [ "check_disk.pl", "check_fly_kestrel", "check_fly_mongo", "check_fly_mongo_repl", "check_memcached.py", "check_mmm_agent", "check_mmm_mon", "check_mmm_mon_cluster", "check_outgoing_traffic", "check_ram" ]: } } ==== error: err: Could not retrieve catalog from remote server: Error 400 on SERVER: Duplicate definition: Fly-nagios::Client::Nagiosplugins[check_fly_kestrel] is already defined in file /var/lib/puppet/fly/modules/fly-nagios/manifests/client.pp at line 40; cannot redefine at /var/lib/puppet/fly/modules/fly-nagios/manifests/client.pp:40 on node puppet thanks for any pointer/help On Mon, Sep 13, 2010 at 6:47 PM, Nan Liu <nan@puppetlabs.com> wrote:> On Mon, Sep 13, 2010 at 5:41 PM, Luc Suryo <lsuryo@gmail.com> wrote: > >> I been Google-ing and read docs for couple hours and can not see what >> I do wrong... can someone help? >> > > Yes, except the code you copied and pasted doesn''t match the error message > since it should of thrown a cannot find class error among several other > issues, so I''m not sure how it even got to the error message in your email. > > class our-nagiios::client { > > > class our-nagios::client > > define my_nagios_plugins ( $name ) { >> > > You don''t need to pass $name as a variable, $name = the title/namevar of > the resource, and $name is only in scope between { }. Puppet should throw > an exception here as well. It should simply be: > > define my_nagios_plugins() { > > >> file { "$name" : >> name => "$nagios_plugins_dir/$name", >> > > did you mean path => "${nagios_plugins_dir}/${name}" instead of name => ... > ? > > >> source => "puppet:///nagios/etc/nagios/bin/ >> $name", >> mode => 0555, owner => bin, group => bin, >> replace => true, >> ensure => file, >> after => File [ "$nagios_plugins_dir" ], >> > > Do you mean require => File["$nagios_plugins_dir"] ? File dependency is > implicit, so puppet knows to require a parent directory before the file, so > it''s not necessary. > > Thanks, > > Nan > > -- > 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. >-- -ls -- 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.
Nan Liu
2010-Sep-14 03:38 UTC
Re: [Puppet Users] call define and keep getting Duplicate definition
On Mon, Sep 13, 2010 at 7:13 PM, Luc Suryo <lsuryo@gmail.com> wrote:> The reason of checking the directory is because sometime we have server > with special installation > and hence do not have the nagios-plugins packages installed.. but still it > does not work.. >The directory resource is perfectly fine. I was just commenting on the implicit resource dependency for files.> Well let me cut and past the whole file: > > class fly-nagios::client inherits fly-nagios::base { > > include nagios::baseI ran a quick module test include fly-nagios::client with a stub fly-nagios::base and a nagios::base and it''s passing the test without any issues: notice: //fly-nagios::client/File[/usr/lib64/nagios/plugins]/ensure: is absent, should be directory (noop) ... notice: //fly-nagios::client/Fly-nagios::Client::Nagiosplugins[check_outgoing_traffic]/File[check_outgoing_traffic]/ensure: is absent, should be file (noop) err: Could not retrieve catalog from remote server: Error 400 on SERVER:> Duplicate definition: Fly-nagios::Client::Nagiosplugins[check_fly_kestrel] > is already defined in file > /var/lib/puppet/fly/modules/fly-nagios/manifests/client.pp at line 40; > cannot redefine at > /var/lib/puppet/fly/modules/fly-nagios/manifests/client.pp:40 on node puppet >I checked where the error is raised in source code. I know this isn''t an issue with the code in the email, but the only way I was able to duplicate the error so it shows the same puppet manifest file and same line number is to include check_disk.pl twice in the resource array (error is last line of the array): nagiosPlugins { [ "check_disk.pl", ... "check_disk.pl", ... Duplicate definition: Fly-nagios::Client::Nagiosplugins[check_disk.pl] is already defined in file /etc/puppet/modules/fly-nagios/manifests/client.pp at line 38; cannot redefine at /etc/puppet/modules/fly-nagios/manifests/client.pp:38 on node puppet.training.lan If that''s not the source of the problem, I''m out of ideas at the moment. Thanks, Nan -- 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.
Luc Suryo
2010-Sep-14 04:58 UTC
Re: [Puppet Users] call define and keep getting Duplicate definition
well I *think* this is the problem? the init.pp file class fly-nagios::base { include nrpe::base case $hostname { "web01": { $var_NRPE_HOST_IP_ADDRESS $ipaddress_eth0 } "db02","web02": { $var_NRPE_HOST_IP_ADDRESS $ipaddress_eth2 } "white": { $var_NRPE_HOST_IP_ADDRESS $ipaddress_eth0 } default: { $var_NRPE_HOST_IP_ADDRESS $ipaddress_eth1 } } $var_NRPE_NAGIOS_SERVERS_IP_ADDRESS = "192.168.0.18,192.168.0.19" file { "nrpe.cfg" : path => "/etc/nagios/nrpe.cfg", content => template("fly-nagios/etc/nagios/nrpe.cfg"), mode => 444, owner => bin, group => bin, ensure => file, notify => Service[ "nrpe" ], require => $operatingsystem ? { "centos" => Package[ "nagios-nrpe" ], "redhat" => Package[ "nagios-nrpe" ], "debian" => Package[ "nagios-nrpe-server" ], "ubuntu" => Package[ "nagios-nrpe-server" ], }, } } import "client.pp" import "server.pp" === the client.pp is what I sent before... It this a loop in what I do ??? maybe the base class should use inherits instead of include ?? thanks! On Mon, Sep 13, 2010 at 8:38 PM, Nan Liu <nan@puppetlabs.com> wrote:> On Mon, Sep 13, 2010 at 7:13 PM, Luc Suryo <lsuryo@gmail.com> wrote: > >> The reason of checking the directory is because sometime we have server >> with special installation >> and hence do not have the nagios-plugins packages installed.. but still it >> does not work.. >> > > The directory resource is perfectly fine. I was just commenting on the > implicit resource dependency for files. > > >> Well let me cut and past the whole file: >> >> class fly-nagios::client inherits fly-nagios::base { >> >> include nagios::base > > > I ran a quick module test include fly-nagios::client with a stub > fly-nagios::base and a nagios::base and it''s passing the test without any > issues: > > notice: //fly-nagios::client/File[/usr/lib64/nagios/plugins]/ensure: is > absent, should be directory (noop) > ... > notice: > //fly-nagios::client/Fly-nagios::Client::Nagiosplugins[check_outgoing_traffic]/File[check_outgoing_traffic]/ensure: > is absent, should be file (noop) > > err: Could not retrieve catalog from remote server: Error 400 on SERVER: >> Duplicate definition: Fly-nagios::Client::Nagiosplugins[check_fly_kestrel] >> is already defined in file >> /var/lib/puppet/fly/modules/fly-nagios/manifests/client.pp at line 40; >> cannot redefine at >> /var/lib/puppet/fly/modules/fly-nagios/manifests/client.pp:40 on node puppet >> > > I checked where the error is raised in source code. I know this isn''t an > issue with the code in the email, but the only way I was able to duplicate > the error so it shows the same puppet manifest file and same line number is > to include check_disk.pl twice in the resource array (error is last line > of the array): > > nagiosPlugins { [ > "check_disk.pl", > ... > "check_disk.pl", > ... > > Duplicate definition: Fly-nagios::Client::Nagiosplugins[check_disk.pl] is > already defined in file /etc/puppet/modules/fly-nagios/manifests/client.pp > at line 38; cannot redefine at > /etc/puppet/modules/fly-nagios/manifests/client.pp:38 on node > puppet.training.lan > > If that''s not the source of the problem, I''m out of ideas at the moment. > > Thanks, > > Nan > > -- > 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. >-- -ls -- 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.
Luc Suryo
2010-Sep-14 15:44 UTC
Re: [Puppet Users] call define and keep getting Duplicate definition
well .... I upgraded to 2.6.1 and it works.. changed nothing!! But thanks for the help and your time Nan!! -- -ls -- 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.