gehel
2010-Mar-02 11:22 UTC
[Puppet Users] Nagios based on David Schmitt''s Complete Config : variables are empty
Hello ! I''m trying to implement a Nagios solution based on David Schmitt''s Complete Config. But I the following error when running puppetd -t - v : notice: Starting catalog run err: //Node[monitoring]/nagios::target/Nagios::Host[]/File[/conf.d/ _host.cfg]/ensure: change from absent to present failed: Could not set present on ensure: No such file or directory - /conf.d/ _host.cfg.puppettmp at /etc/puppet/modules/nagios/manifests/init.pp:40 notice: Finished catalog run in 3.91 seconds As far as I understand, the problem comes from : define host($ip= $fqdn, $short_alias = $fqdn) { @@file { "${nagios_cfgdir}/conf.d/${name}_host.cfg": ensure => present, content => template( "nagios/host.erb" ), mode => 644, owner => root, group => root, tag => ''nagios'', } } When this definition is run, it seems that ${nagios_cfgdir} and $ {name} are undefined. I am probably missing something quite simple, but I cant put my finger on it ... Any help ? My Nagios class is as follow : class nagios { $nagios_cfgdir = ''/etc/nagios3'' include apache package { nagios3 : alias => ''nagios'', ensure => latest; [ ''nagios3-common'', ''nagios-plugins-basic'' ]: ensure => installed, before => Package[''nagios'']; } service { ''nagios3'': alias => ''nagios'', ensure => running, hasstatus => true, hasrestart => true, } file { "$nagios_cfgdir/htpasswd.users": content => "admin:QqtpoTN5OGzmA", mode => 0640, owner => root, group => www-data, } File <<| tag == ''nagios'' |>> define host($ip= $fqdn, $short_alias = $fqdn) { @@file { "${nagios_cfgdir}/conf.d/${name}_host.cfg": ensure => present, content => template( "nagios/host.erb" ), mode => 644, owner => root, group => root, tag => ''nagios'', } } class target { debug ( "$fqdn has $nagios_parent as parent" ) nagios::host { $fqdn: } } } And my nodes.pp : node ''monitoring'' inherits basenode { include apache include nagios $nagios_parent = "generic-host" include nagios::target } Thanks a lot ! Guillaume -- 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.
Joe McDonagh
2010-Mar-02 15:40 UTC
Re: [Puppet Users] Nagios based on David Schmitt''s Complete Config : variables are empty
gehel wrote:> Hello ! > > I''m trying to implement a Nagios solution based on David Schmitt''s > Complete Config. But I the following error when running puppetd -t - > v : > > notice: Starting catalog run > err: //Node[monitoring]/nagios::target/Nagios::Host[]/File[/conf.d/ > _host.cfg]/ensure: change from absent to present failed: Could not set > present on ensure: No such file or directory - /conf.d/ > _host.cfg.puppettmp at /etc/puppet/modules/nagios/manifests/init.pp:40 > notice: Finished catalog run in 3.91 seconds > > As far as I understand, the problem comes from : > > define host($ip= $fqdn, $short_alias = $fqdn) { > @@file { > "${nagios_cfgdir}/conf.d/${name}_host.cfg": > ensure => present, > content => template( "nagios/host.erb" ), > mode => 644, > owner => root, > group => root, > tag => ''nagios'', > } > } > > When this definition is run, it seems that ${nagios_cfgdir} and $ > {name} are undefined. I am probably missing something quite simple, > but I cant put my finger on it ... Any help ? > > > > My Nagios class is as follow : > > class nagios { > $nagios_cfgdir = ''/etc/nagios3'' > > include apache > > package { > nagios3 : > alias => ''nagios'', > ensure => latest; > [ ''nagios3-common'', ''nagios-plugins-basic'' ]: > ensure => installed, > before => Package[''nagios'']; > } > service { > ''nagios3'': > alias => ''nagios'', > ensure => running, > hasstatus => true, > hasrestart => true, > } > file { > "$nagios_cfgdir/htpasswd.users": > content => "admin:QqtpoTN5OGzmA", > mode => 0640, > owner => root, > group => www-data, > } > > File <<| tag == ''nagios'' |>> > > define host($ip= $fqdn, $short_alias = $fqdn) { > @@file { > "${nagios_cfgdir}/conf.d/${name}_host.cfg": > ensure => present, > content => template( "nagios/host.erb" ), > mode => 644, > owner => root, > group => root, > tag => ''nagios'', > } > } > > class target { > debug ( "$fqdn has $nagios_parent as parent" ) > nagios::host { $fqdn: } > } > } > > And my nodes.pp : > > node ''monitoring'' inherits basenode { > include apache > > include nagios > > $nagios_parent = "generic-host" > include nagios::target > } > > > > > Thanks a lot ! > > Guillaume > >Unfortunately, the variable is out of scope. I ran into this problem too and sadly ended up hard coding the value all over the place because it would have been difficult to set it in one proper spot, short of site.pp. Which I may end up doing, since I hate repeating myself. That project got put on the back burner but I will be re visiting fairly soon. -- Joe McDonagh AIM: YoosingYoonickz IRC: joe-mac on freenode L''ennui est contre-révolutionnaire -- 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.
David Schmitt
2010-Mar-08 16:23 UTC
Re: [Puppet Users] Nagios based on David Schmitt''s Complete Config : variables are empty
On 3/2/2010 4:40 PM, Joe McDonagh wrote:> gehel wrote: >> Hello ! >> >> I''m trying to implement a Nagios solution based on David Schmitt''s >> Complete Config. But I the following error when running puppetd -t - >> v : >> >> notice: Starting catalog run >> err: //Node[monitoring]/nagios::target/Nagios::Host[]/File[/conf.d/ >> _host.cfg]/ensure: change from absent to present failed: Could not set >> present on ensure: No such file or directory - /conf.d/ >> _host.cfg.puppettmp at /etc/puppet/modules/nagios/manifests/init.pp:40 >> notice: Finished catalog run in 3.91 seconds >> >> As far as I understand, the problem comes from : >> >> define host($ip= $fqdn, $short_alias = $fqdn) { >> @@file { >> "${nagios_cfgdir}/conf.d/${name}_host.cfg": >> ensure => present, >> content => template( "nagios/host.erb" ), >> mode => 644, >> owner => root, >> group => root, >> tag => ''nagios'', >> } >> } >> >> When this definition is run, it seems that ${nagios_cfgdir} and $ >> {name} are undefined. I am probably missing something quite simple, >> but I cant put my finger on it ... Any help ? >> >> >> >> My Nagios class is as follow : >> >> class nagios { >> $nagios_cfgdir = ''/etc/nagios3'' >> >> include apache >> >> package { >> nagios3 : >> alias => ''nagios'', >> ensure => latest; >> [ ''nagios3-common'', ''nagios-plugins-basic'' ]: >> ensure => installed, >> before => Package[''nagios'']; >> } >> service { >> ''nagios3'': >> alias => ''nagios'', >> ensure => running, >> hasstatus => true, >> hasrestart => true, >> } >> file { >> "$nagios_cfgdir/htpasswd.users": >> content => "admin:QqtpoTN5OGzmA", >> mode => 0640, >> owner => root, >> group => www-data, >> } >> >> File <<| tag == ''nagios'' |>> >> >> define host($ip= $fqdn, $short_alias = $fqdn) { >> @@file { >> "${nagios_cfgdir}/conf.d/${name}_host.cfg": >> ensure => present, >> content => template( "nagios/host.erb" ), >> mode => 644, >> owner => root, >> group => root, >> tag => ''nagios'', >> } >> } >> >> class target { >> debug ( "$fqdn has $nagios_parent as parent" ) >> nagios::host { $fqdn: } >> } >> } >> >> And my nodes.pp : >> >> node ''monitoring'' inherits basenode { >> include apache >> >> include nagios >> >> $nagios_parent = "generic-host" >> include nagios::target >> } >> >> >> >> >> Thanks a lot ! >> >> Guillaume >> > Unfortunately, the variable is out of scope. I ran into this problem too > and sadly ended up hard coding the value all over the place because it > would have been difficult to set it in one proper spot, short of > site.pp. Which I may end up doing, since I hate repeating myself. That > project got put on the back burner but I will be re visiting fairly soon.Exactly. $nagios_cfgdir is supposed to be a site-global configuration. You can either use ${nagios::nagios_cfgdir} to reference the variable within the class (but "include nagios" in the define, so the variable exists already) or put it into your site.pp and forget about it. Regards, David Schmitt -- dasz.at OG Tel: +43 (0)664 2602670 Web: http://dasz.at Klosterneuburg UID: ATU64260999 FB-Nr.: FN 309285 g FB-Gericht: LG Korneuburg -- 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.