Hi, I''m using Puppet 0.24.8 and facter 1.5.4 on RHEL4 update 7. The version of Ruby is vendor supplied (ruby-1.8.1-7.el4_7.2). I know that this is below the recommended version but replacing the supplied binary from Red Hat is probably not an option at this time. In one of my classes I have the following type instance: exec { "sendmail_m4compile": command => "make -C /etc/mail; service sendmail restart", require => File["sendmail.mc"], onlyif => "m4 /etc/mail/sendmail.mc | diff --ignore-matching-lines=\"^##### built\" - /etc/mail/sendmail.cf; [[ $? -eq 0 ]] && exit 1" } According to the docs, the command in onlyif SHOULD return 0 if the file is different from what is expected. As I understand it this should cause the command to run. Unfortunately it does not seem to matter what I do to the onlyif command; I cannot get the command to run when the file differs from what is expected. I''ve tried many variations on onlyif but nothing seems to trigger the command. This is the output (I have removed some non-related lines) from puppetd when I run it as # puppetd --test --debug info: Caching catalog at /var/puppet/state/localconfig.yaml notice: Starting catalog run debug: /:main/Node[...]/general::mail/sendmail/Exec[sendmail_m4compile]/require: requires File[sendmail.mc] debug: /:main/Node[...]/general::mail/sendmail/Service[sendmail]/require: requires Package[sendmail] debug: /:main/Node[...]/general::mail/sendmail/File[sendmail.mc]/require: requires Package[sendmail] debug: /:main/Node[...]/general::mail/sendmail/File[sendmail.mc]/content: Executing ''diff /etc/mail/sendmail.mc /tmp/puppet-diffing16654.0'' 1c1 < test 1 --- > test 2 debug: /:main/Node[...]/general::mail/sendmail/File[sendmail.mc]: Changing content debug: /:main/Node[...]/general::mail/sendmail/File[sendmail.mc]: 1 change(s) debug: /:main/Node[...]/general::mail/sendmail/Exec[sendmail_m4compile]: Executing check ''m4 /etc/mail/sendmail.mc | diff --ignore-matching-lines="^##### built" - /etc/mail/sendmail.cf; [[ $? -eq 0 ]] && exit 1'' debug: Executing ''m4 /etc/mail/sendmail.mc | diff --ignore-matching-lines="^##### built" - /etc/mail/sendmail.cf; [[ $? -eq 0 ]] && exit 1'' /usr/lib/site_ruby/1.8/puppet/util.rb:286: warning: fork terminates thread at /usr/lib/ruby/1.8/timeout.rb:41 Any suggestions as to what I''m doing wrong or perhaps what can be done to fix this bug or work around it would be great. Thanks in advance, Matt --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Chad Huneycutt
2009-May-26 12:24 UTC
[Puppet Users] Re: exec onlyif not cooperating on RHEL4
I think the problem is that you are ''exit''ing. It looks like you are doing that to invert the return code? Try using ''unless'' instead of ''onlyif'', and you can drop everything after the diff. On 5/26/09, Matt Adams <matt.adams@cypressinteractive.com> wrote:> > Hi, > > I''m using Puppet 0.24.8 and facter 1.5.4 on RHEL4 update 7. > > The version of Ruby is vendor supplied (ruby-1.8.1-7.el4_7.2). I know > that this is below the recommended version but replacing the supplied > binary from Red Hat is probably not an option at this time. > > In one of my classes I have the following type instance: > > exec { > "sendmail_m4compile": > command => "make -C /etc/mail; service sendmail restart", > require => File["sendmail.mc"], > onlyif => "m4 /etc/mail/sendmail.mc | diff > --ignore-matching-lines=\"^##### built\" - /etc/mail/sendmail.cf; [[ $? > -eq 0 ]] && exit 1" > } > > According to the docs, the command in onlyif SHOULD return 0 if the file > is different from what is expected. As I understand it this should > cause the command to run. > > Unfortunately it does not seem to matter what I do to the onlyif > command; I cannot get the command to run when the file differs from what > is expected. I''ve tried many variations on onlyif but nothing seems to > trigger the command. > > This is the output (I have removed some non-related lines) from puppetd > when I run it as > > # puppetd --test --debug > > info: Caching catalog at /var/puppet/state/localconfig.yaml > notice: Starting catalog run > debug: > /:main/Node[...]/general::mail/sendmail/Exec[sendmail_m4compile]/require: > requires File[sendmail.mc] > debug: > /:main/Node[...]/general::mail/sendmail/Service[sendmail]/require: > requires Package[sendmail] > debug: > /:main/Node[...]/general::mail/sendmail/File[sendmail.mc]/require: > requires Package[sendmail] > debug: > /:main/Node[...]/general::mail/sendmail/File[sendmail.mc]/content: > Executing ''diff /etc/mail/sendmail.mc /tmp/puppet-diffing16654.0'' > 1c1 > < test 1 > --- > > test 2 > debug: /:main/Node[...]/general::mail/sendmail/File[sendmail.mc]: > Changing content > debug: /:main/Node[...]/general::mail/sendmail/File[sendmail.mc]: 1 > change(s) > debug: /:main/Node[...]/general::mail/sendmail/Exec[sendmail_m4compile]: > Executing check ''m4 /etc/mail/sendmail.mc | diff > --ignore-matching-lines="^##### built" - /etc/mail/sendmail.cf; [[ $? > -eq 0 ]] && exit 1'' > debug: Executing ''m4 /etc/mail/sendmail.mc | diff > --ignore-matching-lines="^##### built" - /etc/mail/sendmail.cf; [[ $? > -eq 0 ]] && exit 1'' > /usr/lib/site_ruby/1.8/puppet/util.rb:286: warning: fork terminates > thread at /usr/lib/ruby/1.8/timeout.rb:41 > > Any suggestions as to what I''m doing wrong or perhaps what can be done > to fix this bug or work around it would be great. > > > Thanks in advance, > > Matt > > > >-- Sent from my mobile device Chad M. Huneycutt --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Chad Huneycutt wrote:> I think the problem is that you are ''exit''ing. It looks like you are > doing that to invert the return code? Try using ''unless'' instead of > ''onlyif'', and you can drop everything after the diff.Perfect. Thanks, Chad. I should have read a little further down the type reference page. Matt --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---