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? >
Your basic problem is that you are trying to manage the same physical resource (file /etc/snmpd/snmpd.conf) via two different Puppet resource declarations: a File and an Exec. Such an approach does not work with Puppet because Puppet checks each (puppet) resource individually to determine whether it needs to be applied. Additionally, Execs *always* run unless they have reason not to do, such as can be expressed via the 'refreshonly', 'creates', 'if', or 'unless' parameters. But those are not sufficient here, as I discuss next. In this case, when Puppet checks whether to apply File[/etc/snmpd/snmpd.conf], it always sees that the version present on the client does not match the one one the server. It therefore applies the version from server, then notifies the Exec. The Exec later modifies that same file (so that it again fails to match the version on the server). This will keep happening forever, because the File and Exec declarations effectively conflict with each other. The approach most in the Puppet paradigm would be to gather from the client, up front, all the information needed to determine the full contents of the target file, and then to apply the correct complete contents via a single File resource. To do that, replace your Exec with a custom fact that gathers the local filesystem information, and replace the flat 'source' of File['/etc/snmpd/snmpd.conf'] with 'content' drawn from a template that supplies the variable part of the file based on the fact value. John -- 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.