Trevor Vaughan
2007-Feb-06 19:07 UTC
Unless in exec doesn''t seem to be honored on notify.
This was a fun one to track down... I was trying to use the append_if_no_such_line script from the wiki and it was working fine EXCEPT when I threw a notify at it. The notify appears to completely ignore both unless and onlyif within the exec for some reason. If I put the same test in the actual command line, it works fine. Example: unless => "/bin/grep -Fqe ''$line'' ''$file''" works normally, but not on notify name => "/bin/grep -Fqe ''$line'' ''$file''; if [ $? -eq 1 ]; then <do stuff>; fi works in the normal case and on notify. Thanks, Trevor _______________________________________________ Puppet-users mailing list Puppet-users@madstop.com https://mail.madstop.com/mailman/listinfo/puppet-users
Luke Kanies
2007-Feb-06 20:40 UTC
Re: Unless in exec doesn''t seem to be honored on notify.
On Feb 6, 2007, at 1:07 PM, Trevor Vaughan wrote:> This was a fun one to track down... > > I was trying to use the append_if_no_such_line script from the wiki > and it was working fine EXCEPT when I threw a notify at it. > > The notify appears to completely ignore both unless and onlyif > within the exec for some reason. > > If I put the same test in the actual command line, it works fine. > > Example: > > unless => "/bin/grep -Fqe ''$line'' ''$file''" works normally, but not > on notify > > name => "/bin/grep -Fqe ''$line'' ''$file''; if [ $? -eq 1 ]; then <do > stuff>; fi works in the normal case and on notify.Just to be sure I understand: You''re using an exec with refreshonly => true, and you are expecting the checks (like ''unless'') to affect whether the exec refreshes? The checks only affect whether the exec runs as part of a normal transaction, not whether it refreshes in response to an event. I hadn''t even though of having the checks apply there. Would other people expect this same behaviour? Any other input? -- A classic is something that everybody wants to have read and nobody wants to read. -- Mark Twain --------------------------------------------------------------------- Luke Kanies | http://reductivelabs.com | http://madstop.com
Trevor Vaughan
2007-Feb-06 20:55 UTC
Re: Unless in exec doesn''t seem to be honored on notify.
Ah, I understand. I''ll just have to remember that when running execs. Thanks, Trevor On 2/6/07, Luke Kanies <luke@madstop.com> wrote:> > On Feb 6, 2007, at 1:07 PM, Trevor Vaughan wrote: > > > This was a fun one to track down... > > > > I was trying to use the append_if_no_such_line script from the wiki > > and it was working fine EXCEPT when I threw a notify at it. > > > > The notify appears to completely ignore both unless and onlyif > > within the exec for some reason. > > > > If I put the same test in the actual command line, it works fine. > > > > Example: > > > > unless => "/bin/grep -Fqe ''$line'' ''$file''" works normally, but not > > on notify > > > > name => "/bin/grep -Fqe ''$line'' ''$file''; if [ $? -eq 1 ]; then <do > > stuff>; fi works in the normal case and on notify. > > Just to be sure I understand: You''re using an exec with refreshonly > => true, and you are expecting the checks (like ''unless'') to affect > whether the exec refreshes? > > The checks only affect whether the exec runs as part of a normal > transaction, not whether it refreshes in response to an event. I > hadn''t even though of having the checks apply there. > > Would other people expect this same behaviour? Any other input? > > -- > A classic is something that everybody wants to have read and nobody > wants to read. -- Mark Twain > --------------------------------------------------------------------- > Luke Kanies | http://reductivelabs.com | http://madstop.com > > > _______________________________________________ > Puppet-users mailing list > Puppet-users@madstop.com > https://mail.madstop.com/mailman/listinfo/puppet-users >_______________________________________________ Puppet-users mailing list Puppet-users@madstop.com https://mail.madstop.com/mailman/listinfo/puppet-users
Robert Mombro
2007-Feb-06 22:25 UTC
Re: Unless in exec doesn''t seem to be honored on notify.
Mr. Kanies, I also expected the unless and onlyif to be standard in all cases. I was using the Exec with a subscribe to change permissions, but only if the permissions were not already correct. I just modified my scripts to check everything in the Exec command and not use the onlyif or unless commands. Thank you, -- Rob -- ----- Original Message ---- From: Luke Kanies <luke@madstop.com> To: Puppet User Discussion <puppet-users@madstop.com> Sent: Tuesday, February 6, 2007 3:40:55 PM Subject: Re: [Puppet-users] Unless in exec doesn''t seem to be honored on notify. On Feb 6, 2007, at 1:07 PM, Trevor Vaughan wrote:> This was a fun one to track down... > > I was trying to use the append_if_no_such_line script from the wiki > and it was working fine EXCEPT when I threw a notify at it. > > The notify appears to completely ignore both unless and onlyif > within the exec for some reason. > > If I put the same test in the actual command line, it works fine. > > Example: > > unless => "/bin/grep -Fqe ''$line'' ''$file''" works normally, but not > on notify > > name => "/bin/grep -Fqe ''$line'' ''$file''; if [ $? -eq 1 ]; then <do > stuff>; fi works in the normal case and on notify.Just to be sure I understand: You''re using an exec with refreshonly => true, and you are expecting the checks (like ''unless'') to affect whether the exec refreshes? The checks only affect whether the exec runs as part of a normal transaction, not whether it refreshes in response to an event. I hadn''t even though of having the checks apply there. Would other people expect this same behaviour? Any other input? -- A classic is something that everybody wants to have read and nobody wants to read. -- Mark Twain --------------------------------------------------------------------- Luke Kanies | http://reductivelabs.com | http://madstop.com _______________________________________________ Puppet-users mailing list Puppet-users@madstop.com https://mail.madstop.com/mailman/listinfo/puppet-users ____________________________________________________________________________________ Looking for earth-friendly autos? Browse Top Cars by "Green Rating" at Yahoo! Autos'' Green Center. http://autos.yahoo.com/green_center/ _______________________________________________ Puppet-users mailing list Puppet-users@madstop.com https://mail.madstop.com/mailman/listinfo/puppet-users
Luke Kanies
2007-Feb-06 22:28 UTC
Re: Unless in exec doesn''t seem to be honored on notify.
On Feb 6, 2007, at 4:25 PM, Robert Mombro wrote:> Mr. Kanies, > > I also expected the unless and onlyif to be standard in all cases. > I was using the Exec with a subscribe to change permissions, but > only if the permissions were not already correct. > > I just modified my scripts to check everything in the Exec command > and not use the onlyif or unless commands.What kind of permissions? Files? If so, why not just use a file resource? What''s the point of the subscribe? What is the exec subscribed to? This seems like a pretty normal case for idempotent usage of the exec, with no refreshonly. -- Don''t throw away the old bucket until you know whether the new one holds water. -- Swedish Proverb --------------------------------------------------------------------- Luke Kanies | http://reductivelabs.com | http://madstop.com
Robert Mombro
2007-Feb-06 22:42 UTC
Re: Unless in exec doesn''t seem to be honored on notify.
Mr. Kanies, An example is as follows: define ensure_owner ( $refreshonly = false) { exec { "ensure_owner": command => "find / -nouser -exec chown root {} \;", path => "/bin:/usr/bin", logoutput => "true", refreshonly => $refreshonly } } file { "/etc/passwd": checksum => "md5" } ensure_owner { "ensureowner": subscribe => File [ "/etc/passwd" ], refreshonly => true } This makes sure that I do not have unowned files floating around my system when a user gets deleted. I considered making this a cron job, but it seemed more efficient to do it only when necessary. Also, I have utilized this construct in several other places with like effect. For example, setting the default gateway in /etc/sysconfig/network using file edits so that I don''t have to change the rest of the file content. Thank you, -- Rob -- ----- Original Message ---- From: Luke Kanies <luke@madstop.com> To: Puppet User Discussion <puppet-users@madstop.com> Sent: Tuesday, February 6, 2007 5:28:00 PM Subject: Re: [Puppet-users] Unless in exec doesn''t seem to be honored on notify. On Feb 6, 2007, at 4:25 PM, Robert Mombro wrote:> Mr. Kanies, > > I also expected the unless and onlyif to be standard in all cases. > I was using the Exec with a subscribe to change permissions, but > only if the permissions were not already correct. > > I just modified my scripts to check everything in the Exec command > and not use the onlyif or unless commands.What kind of permissions? Files? If so, why not just use a file resource? What''s the point of the subscribe? What is the exec subscribed to? This seems like a pretty normal case for idempotent usage of the exec, with no refreshonly. -- Don''t throw away the old bucket until you know whether the new one holds water. -- Swedish Proverb --------------------------------------------------------------------- Luke Kanies | http://reductivelabs.com | http://madstop.com _______________________________________________ Puppet-users mailing list Puppet-users@madstop.com https://mail.madstop.com/mailman/listinfo/puppet-users ____________________________________________________________________________________ Need Mail bonding? Go to the Yahoo! Mail Q&A for great tips from Yahoo! Answers users. http://answers.yahoo.com/dir/?link=list&sid=396546091 _______________________________________________ Puppet-users mailing list Puppet-users@madstop.com https://mail.madstop.com/mailman/listinfo/puppet-users
Luke Kanies
2007-Feb-06 22:48 UTC
Re: Unless in exec doesn''t seem to be honored on notify.
On Feb 6, 2007, at 4:42 PM, Robert Mombro wrote:> Mr. Kanies, > > An example is as follows: > > define ensure_owner ( $refreshonly = false) { > exec { "ensure_owner": > command => "find / -nouser -exec chown root {} \;", > path => "/bin:/usr/bin", > logoutput => "true", > refreshonly => $refreshonly > } > } > > file { "/etc/passwd": checksum => "md5" } > > ensure_owner { "ensureowner": subscribe => File [ "/etc/passwd" ], > refreshonly => true } > > This makes sure that I do not have unowned files floating around my > system when a user gets deleted. I considered making this a cron > job, but it seemed more efficient to do it only when necessary. > Also, I have utilized this construct in several other places with > like effect. For example, setting the default gateway in /etc/ > sysconfig/network using file edits so that I don''t have to change > the rest of the file content.Ah, I see. It was your talk of changing permissions that confused me, but this is much more efficient than using Puppet''s file type. So is this doing what you want, then, or is there still something missing? -- Man is the only animal that can remain on friendly terms with the victims he intends to eat until he eats them. -- Samuel Butler (1835-1902) --------------------------------------------------------------------- Luke Kanies | http://reductivelabs.com | http://madstop.com
Robert Mombro
2007-Feb-06 23:01 UTC
Re: Unless in exec doesn''t seem to be honored on notify.
Mr. Kanies, This particular example is doing what I want it to. However, if I try to do this with the file modification Execs as presented by Mr. Vaughan, I cannot use the unless functionality. Additional example from the wiki http://reductivelabs.com/trac/puppet/wiki/SimpleTextRecipes: define append_if_no_such_line($file, $line, $refreshonly = ''false'') { exec { "/bin/echo ''$line'' >> ''$file''": unless => "/bin/grep -Fxqe ''$line'' ''$file''", path => "/bin", refreshonly => $refreshonly, } } file { "/etc/modules": ensure => present, } append_if_no_such_line { dummy_module: file => "/etc/modules", line => "dummy", subscribe => File["/etc/modules"], refreshonly => true, } This just does not work and seems that it should. However, if I change the define to the following: define append_if_no_such_line($file, $line, $refreshonly = ''false'') { exec { "/bin/grep -Fxqe ''$line'' ''$file''; if [ ! $? ]; then /bin/echo ''$line'' >> ''$file''; fi": path => "/bin", refreshonly => $refreshonly, } } Then it works properly, but does not follow what I believe to be the obvious tenants of Exec. It would seem that the presence of unless should function the same in all cases. Thank you, -- Rob -- ----- Original Message ---- From: Luke Kanies <luke@madstop.com> To: Puppet User Discussion <puppet-users@madstop.com> Sent: Tuesday, February 6, 2007 5:48:17 PM Subject: Re: [Puppet-users] Unless in exec doesn''t seem to be honored on notify. On Feb 6, 2007, at 4:42 PM, Robert Mombro wrote:> Mr. Kanies, > > An example is as follows: > > define ensure_owner ( $refreshonly = false) { > exec { "ensure_owner": > command => "find / -nouser -exec chown root {} \;", > path => "/bin:/usr/bin", > logoutput => "true", > refreshonly => $refreshonly > } > } > > file { "/etc/passwd": checksum => "md5" } > > ensure_owner { "ensureowner": subscribe => File [ "/etc/passwd" ], > refreshonly => true } > > This makes sure that I do not have unowned files floating around my > system when a user gets deleted. I considered making this a cron > job, but it seemed more efficient to do it only when necessary. > Also, I have utilized this construct in several other places with > like effect. For example, setting the default gateway in /etc/ > sysconfig/network using file edits so that I don''t have to change > the rest of the file content.Ah, I see. It was your talk of changing permissions that confused me, but this is much more efficient than using Puppet''s file type. So is this doing what you want, then, or is there still something missing? -- Man is the only animal that can remain on friendly terms with the victims he intends to eat until he eats them. -- Samuel Butler (1835-1902) --------------------------------------------------------------------- Luke Kanies | http://reductivelabs.com | http://madstop.com _______________________________________________ Puppet-users mailing list Puppet-users@madstop.com https://mail.madstop.com/mailman/listinfo/puppet-users ____________________________________________________________________________________ Want to start your own business? Learn how on Yahoo! Small Business. http://smallbusiness.yahoo.com/r-index _______________________________________________ Puppet-users mailing list Puppet-users@madstop.com https://mail.madstop.com/mailman/listinfo/puppet-users
David Schmitt
2007-Feb-07 13:16 UTC
Re: Unless in exec doesn''t seem to be honored on notify.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Tuesday 06 February 2007 21:40, Luke Kanies wrote:> Just to be sure I understand: You''re using an exec with refreshonly > => true, and you are expecting the checks (like ''unless'') to affect > whether the exec refreshes? > > The checks only affect whether the exec runs as part of a normal > transaction, not whether it refreshes in response to an event. I > hadn''t even though of having the checks apply there. > > Would other people expect this same behaviour? Any other input?I never thought about it until now, but, yes, I would expect the checks to apply. Then again, I believe I never read a concise explanation of the difference between dependencies with or without event passing. Ah, on https://reductivelabs.com/projects/puppet/reference/typedocs.html#meta-parameters it says: | Changes in the subscribed to objects result in the dependent objects being | refreshed (e.g., a service will get restarted). I still couldn''t find anything more on what "refreshed" means except what is given in examples. I see now, that "the exec is re-executed" could be a valid interpretation of "refresh" for Exec. But it is also clear to me that for append_if_no_such_line, the correct interpretation for "refresh" should be more along the line of "really, really ensure that the line is in the file, if it doesn''t exist", not? Regards, David - -- - - hallo... wie gehts heute? - - *hust* gut *rotz* *keuch* - - gott sei dank kommunizieren wir über ein septisches medium ;) -- Matthias Leeb, Uni f. angewandte Kunst, 2005-02-15 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFFydET/Pp1N6Uzh0URAqYzAJ49YUb2LisS+5P/E85ApHgsAZa3hwCfYhFt wFsdl6Y2B6s4yoz13y5Yupc=FXcI -----END PGP SIGNATURE-----
Trevor Vaughan
2007-Feb-07 13:33 UTC
Re: Unless in exec doesn''t seem to be honored on notify.
Wow, I''m glad I didn''t have to post any of that. Rob posted excellent examples of the problem that I''m having and David summed it up well. Thanks, Trevor On 2/7/07, David Schmitt <david@schmitt.edv-bus.at> wrote:> > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > On Tuesday 06 February 2007 21:40, Luke Kanies wrote: > > Just to be sure I understand: You''re using an exec with refreshonly > > => true, and you are expecting the checks (like ''unless'') to affect > > whether the exec refreshes? > > > > The checks only affect whether the exec runs as part of a normal > > transaction, not whether it refreshes in response to an event. I > > hadn''t even though of having the checks apply there. > > > > Would other people expect this same behaviour? Any other input? > > I never thought about it until now, but, yes, I would expect the checks to > apply. Then again, I believe I never read a concise explanation of the > difference between dependencies with or without event passing. > > Ah, on > > https://reductivelabs.com/projects/puppet/reference/typedocs.html#meta-parameters > it says: > > | Changes in the subscribed to objects result in the dependent objects > being > | refreshed (e.g., a service will get restarted). > > I still couldn''t find anything more on what "refreshed" means except what > is > given in examples. > > I see now, that "the exec is re-executed" could be a valid interpretation > of "refresh" for Exec. But it is also clear to me that for > append_if_no_such_line, the correct interpretation for "refresh" should be > more along the line of "really, really ensure that the line is in the > file, > if it doesn''t exist", not? > > > Regards, David > - -- > - - hallo... wie gehts heute? > - - *hust* gut *rotz* *keuch* > - - gott sei dank kommunizieren wir über ein septisches medium ;) > -- Matthias Leeb, Uni f. angewandte Kunst, 2005-02-15 > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.6 (GNU/Linux) > > iD8DBQFFydET/Pp1N6Uzh0URAqYzAJ49YUb2LisS+5P/E85ApHgsAZa3hwCfYhFt > wFsdl6Y2B6s4yoz13y5Yupc> =FXcI > -----END PGP SIGNATURE----- > _______________________________________________ > Puppet-users mailing list > Puppet-users@madstop.com > https://mail.madstop.com/mailman/listinfo/puppet-users >_______________________________________________ Puppet-users mailing list Puppet-users@madstop.com https://mail.madstop.com/mailman/listinfo/puppet-users
Luke Kanies
2007-Feb-07 17:40 UTC
Re: Unless in exec doesn''t seem to be honored on notify.
On Feb 7, 2007, at 7:16 AM, David Schmitt wrote:> > I never thought about it until now, but, yes, I would expect the > checks to > apply. Then again, I believe I never read a concise explanation of the > difference between dependencies with or without event passing.Okay, I just changed exec so that this is the case.> Ah, on > https://reductivelabs.com/projects/puppet/reference/ > typedocs.html#meta-parameters > it says: > > | Changes in the subscribed to objects result in the dependent > objects being > | refreshed (e.g., a service will get restarted). > > I still couldn''t find anything more on what "refreshed" means > except what is > given in examples.The definition of ''refresh'' changes by resource. Most don''t even support it, but for services it means restart, for exec it means run the command again, and for mounts it means remount the fs.> I see now, that "the exec is re-executed" could be a valid > interpretation > of "refresh" for Exec. But it is also clear to me that for > append_if_no_such_line, the correct interpretation for "refresh" > should be > more along the line of "really, really ensure that the line is in > the file, > if it doesn''t exist", not?I would hope not; that looks like using refresh to check that the normal execution actually worked, which I think would be a bad idea. -- I am not a vegetarian because I love animals; I am a vegetarian because I hate plants. -- A. Whitney Brown --------------------------------------------------------------------- Luke Kanies | http://reductivelabs.com | http://madstop.com
Luke Kanies
2007-Feb-07 18:54 UTC
Re: Unless in exec doesn''t seem to be honored on notify.
On Feb 6, 2007, at 5:01 PM, Robert Mombro wrote:> Mr. Kanies, > > This particular example is doing what I want it to. However, if I > try to do this with the file modification Execs as presented by Mr. > Vaughan, I cannot use the unless functionality. > > Additional example from the wiki http://reductivelabs.com/trac/ > puppet/wiki/SimpleTextRecipes: > define append_if_no_such_line($file, $line, $refreshonly = ''false'') { > exec { "/bin/echo ''$line'' >> ''$file''": > unless => "/bin/grep -Fxqe ''$line'' ''$file''", > path => "/bin", > refreshonly => $refreshonly, > } > } > > file { "/etc/modules": ensure => present, } > > append_if_no_such_line { dummy_module: > file => "/etc/modules", > line => "dummy", > subscribe => File["/etc/modules"], > refreshonly => true, > } > This just does not work and seems that it should.I don''t really understand what the point of the relationship is here. Are you doing a performance optimization, so that you only check whether the line is there if the modules file has changed? If not, what''s the point?> However, if I change the define to the following: > define append_if_no_such_line($file, $line, $refreshonly = ''false'') { > exec { "/bin/grep -Fxqe ''$line'' ''$file''; if [ ! $? ]; then /bin/ > echo ''$line'' >> ''$file''; fi": > path => "/bin", > refreshonly => $refreshonly, > } > }Then it works properly, but does not follow what I believe to be > the obvious tenants of Exec. It would seem that the presence of > unless should function the same in all cases.Well, it works (in svn) now, so you''ll get the behaviour you want in the next release. -- I object to doing things that computers can do. --Olin Shivers --------------------------------------------------------------------- Luke Kanies | http://reductivelabs.com | http://madstop.com
David Schmitt
2007-Feb-08 11:18 UTC
Re: Unless in exec doesn''t seem to be honored on notify.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Wednesday 07 February 2007 18:40, Luke Kanies wrote:> On Feb 7, 2007, at 7:16 AM, David Schmitt wrote: > > I still couldn''t find anything more on what "refreshed" means > > except what is > > given in examples. > > The definition of ''refresh'' changes by resource. Most don''t even > support it, but for services it means restart, for exec it means run > the command again, and for mounts it means remount the fs.Nice to know. Perhaps that could be noted in the type reference? It is a important information after all ;) Regards, David - -- - - hallo... wie gehts heute? - - *hust* gut *rotz* *keuch* - - gott sei dank kommunizieren wir über ein septisches medium ;) -- Matthias Leeb, Uni f. angewandte Kunst, 2005-02-15 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFFywbu/Pp1N6Uzh0URAmu9AKCBA4poLupzsssR8n/f0VPjoBbZ5QCfZ0CO 7QHvTRDLMmJc7SmDabV/CQA=4xpI -----END PGP SIGNATURE-----
Luke Kanies
2007-Feb-08 16:29 UTC
Re: Unless in exec doesn''t seem to be honored on notify.
On Feb 8, 2007, at 5:18 AM, David Schmitt wrote:>> >> The definition of ''refresh'' changes by resource. Most don''t even >> support it, but for services it means restart, for exec it means run >> the command again, and for mounts it means remount the fs. > > Nice to know. Perhaps that could be noted in the type reference? It > is a > important information after all ;)I''m sure it should be. This would be a great way for someone to spend a bit of time and start helping out: Find the types that support ''refresh'' and document what it does. Send me a patch and I''ll get it integrated essentially immediately. -- I went to a restaurant that serves "breakfast at anytime". So I ordered French Toast during the Renaissance. -- Stephen Wright --------------------------------------------------------------------- Luke Kanies | http://reductivelabs.com | http://madstop.com
David Schmitt
2007-Feb-11 23:44 UTC
Re: Unless in exec doesn''t seem to be honored on notify.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Thursday 08 February 2007 17:29, Luke Kanies wrote:> On Feb 8, 2007, at 5:18 AM, David Schmitt wrote: > >> The definition of ''refresh'' changes by resource. Most don''t even > >> support it, but for services it means restart, for exec it means run > >> the command again, and for mounts it means remount the fs. > > > > Nice to know. Perhaps that could be noted in the type reference? It > > is a > > important information after all ;) > > I''m sure it should be. This would be a great way for someone to > spend a bit of time and start helping out: Find the types that > support ''refresh'' and document what it does. Send me a patch and > I''ll get it integrated essentially immediately.I should have expected that kind of answer from you :) I''ve filed a bug with the patch: #494 Regards, David - -- - - hallo... wie gehts heute? - - *hust* gut *rotz* *keuch* - - gott sei dank kommunizieren wir über ein septisches medium ;) -- Matthias Leeb, Uni f. angewandte Kunst, 2005-02-15 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFFz6pc/Pp1N6Uzh0URAnCTAJ93x7w8Tr0yZRrL1q0z05zL4YWnBwCbBIoj mK6cnxBT23o+Rqels96gow0=kwQm -----END PGP SIGNATURE-----