Hello Pros and users of Puppet. I have two problems with the following modul setup: My first problem that i tried every combination of require,notify,subscribe for the mail sending exec but it runs every single time when i run the module no matter if the files changed or not. Second problem that puppet reports that snmpd was refreshed by two resource and restarted but actually it doesnt happen. remote: info: /etc/default/snmpd: Scheduling refresh of Service[snmpd] remote: notice: /Stage[main]/Monitoring/Service[snmpd]/ensure: ensure changed ''stopped'' to ''running'' remote: notice: /Stage[main]/Monitoring/Service[snmpd]: Triggered ''refresh'' from 2 events Any help would be much appreciated regarding how to restart snmpd on Ubuntu LTS 10.04 repository install and how to make exec to run only if the created file changes. file{ ''/etc/default/snmpd'': ensure => present, source => "puppet:///modules/${module_name}/snmpd", notify => Service[''snmpd''], require => [ Package[''snmp''], Package[''snmpd''] ]; ''/etc/snmp/snmpd.conf'': ensure => present, source => "puppet:///modules/${module_name}/snmpd.conf", notify => Service[''snmpd''], require => [ Package[''snmp''], Package[''snmpd''] ]; ''/etc/nagios/nrpe.cfg'': ensure => present, source => "puppet:///modules/${module_name}/nrpe.cfg", notify => Service[''nagios-nrpe-server''], require => Package[''nagios-nrpe-server'']; ''/etc/nagios/nrpe.d/nrpe-disk.cfg'': ensure => present, source => "puppet:///modules/${module_name}/nrpe-disk.cfg", notify => Service[''nagios-nrpe-server''], require => Package[''nagios-nrpe-server'']; "/root/${hostname}.cfg": ensure => present, content => template("${module_name}/nagioshost.erb"), notify => Exec["/usr/bin/mail -s ${hostname}-nagios-host-config -a /root/${hostname}.cfg seewebmaster@smydomain.com"], } exec{ "/usr/bin/mail -s ${hostname}-nagios-host-config -a /root/${hostname}.cfg seewebmaster@mydomain.com": require => File["/root/${hostname}.cfg"]; } service{''snmpd'': ensure => running, subscribe => [ File[''/etc/default/snmpd''], File[''/etc/snmp/snmpd.conf''] ]; ''nagios-nrpe-server'': ensure => running, subscribe => [ File[''/etc/nagios/nrpe.cfg''], File[''/etc/nagios/nrpe.d/nrpe-disk.cfg''] ], } Thank you Peter -- 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.
If anybody interested the simple solution was to add refreshonly => true to the exec. the snmp restart instead of a proper service resource type has been replaced with an Exec ''/usr/sbin/service snmpd restart'': subscribe => [ File[''/etc/default/ snmpd''], File[''/etc/snmp/snmpd.conf''] ], refreshonly => true; On Apr 25, 11:04 am, Peter Horvath <peter.horvat...@googlemail.com> wrote:> Hello Pros and users of Puppet. > > I have two problems with the following modul setup: > My first problem that i tried every combination of > require,notify,subscribe for the mail sending exec but it runs every > single time when i run the module no matter if the files changed or > not. > > Second problem that puppet reports that snmpd was refreshed by two > resource and restarted but actually it doesnt happen. > remote: info: /etc/default/snmpd: Scheduling refresh of Service[snmpd] > remote: notice: /Stage[main]/Monitoring/Service[snmpd]/ensure: ensure > changed ''stopped'' to ''running'' > remote: notice: /Stage[main]/Monitoring/Service[snmpd]: Triggered > ''refresh'' from 2 events > > Any help would be much appreciated regarding how to restart snmpd on > Ubuntu LTS 10.04 repository install and how to make exec to run only > if the created file changes. > > file{ ''/etc/default/snmpd'': > ensure => present, > source => > "puppet:///modules/${module_name}/snmpd", > notify => Service[''snmpd''], > require => [ Package[''snmp''], > Package[''snmpd''] ]; > > ''/etc/snmp/snmpd.conf'': > ensure => present, > source => > "puppet:///modules/${module_name}/snmpd.conf", > notify => Service[''snmpd''], > require => [ Package[''snmp''], > Package[''snmpd''] ]; > > ''/etc/nagios/nrpe.cfg'': > ensure => present, > source => > "puppet:///modules/${module_name}/nrpe.cfg", > notify => Service[''nagios-nrpe-server''], > require => Package[''nagios-nrpe-server'']; > > ''/etc/nagios/nrpe.d/nrpe-disk.cfg'': > ensure => present, > source => > "puppet:///modules/${module_name}/nrpe-disk.cfg", > notify => Service[''nagios-nrpe-server''], > require => Package[''nagios-nrpe-server'']; > > "/root/${hostname}.cfg": > ensure => present, > content => > template("${module_name}/nagioshost.erb"), > notify => Exec["/usr/bin/mail -s > ${hostname}-nagios-host-config -a /root/${hostname}.cfg > seewebmas...@smydomain.com"], > } > > exec{ "/usr/bin/mail -s ${hostname}-nagios-host-config -a > /root/${hostname}.cfg seewebmas...@mydomain.com": > require => File["/root/${hostname}.cfg"]; > } > > service{''snmpd'': > ensure => running, > subscribe => [ > File[''/etc/default/snmpd''], File[''/etc/snmp/snmpd.conf''] ]; > > ''nagios-nrpe-server'': > ensure => running, > subscribe => [ > File[''/etc/nagios/nrpe.cfg''], File[''/etc/nagios/nrpe.d/nrpe-disk.cfg''] > ], > } > > Thank you > Peter-- 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.
On Apr 25, 6:57 am, Peter Horvath <peter.horvat...@gmail.com> wrote:> If anybody interested the simple solution was to add refreshonly => > true to the exec. > the snmp restart instead of a proper service resource type has been > replaced with an Exec > ''/usr/sbin/service snmpd restart'': > subscribe => [ File[''/etc/default/ > snmpd''], File[''/etc/snmp/snmpd.conf''] ], > refreshonly => true;So, is there a reason to prefer that to service { ''snmpd'': ensure => running, enable => true, hasstatus => true, hasrestart => false, restart => ''/usr/sbin/service snmpd restart'', subscribe => [ File[''/etc/default/snmpd''], File[''/etc/snmp/ snmpd.conf''] ], } ? John -- 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.
Peter Horvath
2012-Apr-25 14:15 UTC
Re: [Puppet Users] Re: Exec and snmpd restart question
I didnt know this way of declaration :) thank you works like a charm On 25 April 2012 15:07, jcbollinger <John.Bollinger@stjude.org> wrote:> > > On Apr 25, 6:57 am, Peter Horvath <peter.horvat...@gmail.com> wrote: >> If anybody interested the simple solution was to add refreshonly => >> true to the exec. >> the snmp restart instead of a proper service resource type has been >> replaced with an Exec >> ''/usr/sbin/service snmpd restart'': >> subscribe => [ File[''/etc/default/ >> snmpd''], File[''/etc/snmp/snmpd.conf''] ], >> refreshonly => true; > > > So, is there a reason to prefer that to > > service { ''snmpd'': > ensure => running, > enable => true, > hasstatus => true, > hasrestart => false, > restart => ''/usr/sbin/service snmpd restart'', > subscribe => [ File[''/etc/default/snmpd''], File[''/etc/snmp/ > snmpd.conf''] ], > } > > ? > > > John > > -- > 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.