I am not positive exactly what you are trying to accomplish, but I believe 
you can do this in a couple of ways.

First, if puppet manages snmpd.conf and /etc/fstab simply set "refreshonly 
=> true" on the exec and set those two file resources to notify the exec.

If puppet does not manage those files, or only partially managed them, it 
will be more complicated but it is still doable.

In this case, you would need to make use of 'unless' or 'onlyif' to 
determine if the command needs to be ran.

See http://docs.puppetlabs.com/references/3.2.latest/type.html#exec for 
more details.

If the command to use as a test is complicated, I would suggest writing a 
shell script and pushing the file out with a file resource and then 
executing the script in the unless or only if.

On Thursday, May 30, 2013 12:32:05 PM UTC-5, Stan wrote:
>
> Hello
>
> Here is my manifest for snmpd, my problem now is that my manifest will run 
> every time because my snmpd.conf file changes after the "exec"!! I want 
> that my manifest run when the snmpd.conf (only snmpd.conf source and not 
> with exec) file change or when my /etc/fstab file on the client changeand 
> it restart the snmpd service.
>
>
> I do not know if I'm very clear, but it is not easy to explain it in 
> English.
>
> Did you have an idea?
>
> class snmpd::redhat {
>     package { "net-snmp":
>             ensure => present,
>     }
>
> file { "/etc/snmp/snmpd.conf":
>             ensure => present,
>             owner  => 'root',
>             group  => 'root',
>             mode => 644,
>             source => "puppet:///modules/snmpd/snmpd.conf",
>             require=> Package["net-snmp"],
>             notify  => Exec["disk-snmp"]
>         #    notify  => Service["snmpd"]
>     }
>
>
> file { "/etc/fstab":
>             ensure => present
>     }
>
>
> exec { "disk-snmp":
>         command   => "grep -e \"ext[2-4]\" /etc/fstab|awk '{print 
> \"disk\",'$\2'}' >> /etc/snmp/snmpd.conf",
> #       subscribe => File["/etc/snmp/snmpd.conf"],
>         subscribe => File["/etc/fstab"],
>         path => ["/usr/bin", "/bin", "/usr/sbin"],
>         notify  => Service["snmpd"]
>     }
>
>
> service { "snmpd":
>              ensure     => running,
>              hasstatus  => true,
>              hasrestart => true,
>              enable     => true,
>              require    => File['/etc/snmp/snmpd.conf']
>         }
> }
>
>
> my source : snmpd.conf :
>
> com2sec nagios          192.168.1.1   communaute
> view tout included .1
> group collecte v1 cacti
> access collecte "" any noauth exact tout none none
> syslocation Unknown (edit /etc/snmp/snmpd.conf)
> syscontact Root <root@localhost> (configure /etc/snmp/snmp.local.conf)
> pass .1.3.6.1.4.1.4413.4.1 /usr/bin/ucd5820stat
>
>
>
> Is it possible in my snmpd.conf source a solution as :
>
> com2sec nagios          192.168.1.1   communaute
> view tout included .1
> group collecte v1 cacti
> access collecte "" any noauth exact tout none none
> syslocation Unknown (edit /etc/snmp/snmpd.conf)
> syscontact Root <root@localhost> (configure /etc/snmp/snmp.local.conf)
> pass .1.3.6.1.4.1.4413.4.1 /usr/bin/ucd5820stat
> *Exec **["disk-snmp"]*
>

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To post to this group, send email to puppet-users@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to