Graham Stratton
2009-Apr-22 07:26 UTC
[Puppet Users] Subscribe should override creates for exec resources?
Hi all, I''m clearly missing something here. I thought that if I had a subscribe attribute on an exec resource, then that resource would run regardless on any creates/unless, but that is not what I''m seeing. I created a minimal test, shown below. As you can see: - The file ''trigger'' was changed, and Puppet noticed. - The exec was ''refreshed'' due to the dependency, but it didn''t actually run. - Without the ''creates'' file, the exec runs correctly. Is this expected behaviour? From the docs it looks like a ''refresh'' of an exec should run the exec again, unless the ''refresh'' attribute is specified. (I tried that too, and it made no difference). Thanks, Graham graham@mini:~/puppettest$ cat notification.pp file { "/Users/graham/puppettest/trigger": content => ''c'', } exec { "echo potato > output": subscribe => File[''/Users/graham/puppettest/trigger''], creates => ''/Users/graham/puppettest/creates'', path => ''/bin/'', } graham@mini:~/puppettest$ puppet notification.pp notice: //File[/Users/graham/puppettest/trigger]: Filebucketed to with sum 0cc175b9c0f1b6a831c399e269772661 notice: //File[/Users/graham/puppettest/trigger]/content: content changed ''{md5}0cc175b9c0f1b6a831c399e269772661'' to ''{md5}4a8a08f09d37b73795649038408b5f33'' notice: //Exec[echo potato > output]: Triggering ''refresh'' from 1 dependencies graham@mini:~/puppettest$ ls creates notification trigger graham@mini:~/puppettest$ rm creates graham@mini:~/puppettest$ puppet notification.pp notice: //Exec[echo potato > output]/returns: executed successfully graham@mini:~/puppettest$ ls notification output trigger --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Graham Stratton
2009-Apr-22 07:50 UTC
[Puppet Users] Re: Subscribe should override creates for exec resources?
On 22/04/2009, at 5:26 PM, Graham Stratton wrote:>> I''m clearly missing something here. I thought that if I had a > subscribe attribute on an exec resource, then that resource would run > regardless on any creates/unless, but that is not what I''m seeing. > > I created a minimal test, shown below. As you can see: > > - The file ''trigger'' was changed, and Puppet noticed. > - The exec was ''refreshed'' due to the dependency, but it didn''t > actually run. > - Without the ''creates'' file, the exec runs correctly.After a discussion on IRC this makes more sense. Since subscribe/ notify are metaparameters they control when resources are run, but the exec parameter ''creates'' will still override that. That''s rather unfortunate for my use-case, though. I want an exec to run until a file has been created or whenever a config file is updated. But that''s not quite perfect, so maybe this will force me to fix things more! Regards, Graham --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Robin Sheat
2009-Apr-22 10:45 UTC
[Puppet Users] Re: Subscribe should override creates for exec resources?
On Wednesday 22 April 2009 19:50:11 Graham Stratton wrote:> That''s rather unfortunate for my use-case, though. I want an exec to > run until a file has been created or whenever a config file is > updated. But that''s not quite perfect, so maybe this will force me to > fix things more!I had the same problem with ''unless'' recently. I fixed in by making a duplicate in my define. Due to the unless, the top one will happen if the unless returns false, the bottom one will happen on a notify. The requiring of the ''force redeploy'' ensures that if it''s going to happen, it''ll happen first and so the ''unless'' will fail and the action will only ever occur once. exec { "Deploy glassfish app $name": command => "$asadmin deploy -- interactive=false --contextroot $name --name $name --force=true $file", unless => "$asadmin list-components -- interactive=false --terse=true --type web | grep ''^$name ''", # In case we get a notify, this should stop # both execs from happening. require => [Exec["Forced redeploy glassfish app $name"]], logoutput => on_failure, } # This exec is the same as the previous one, except # it should _only_ occur if we get sent a notification # (which probably indicates the source file has changed) exec { "Forced redeploy glassfish app $name": command => "$asadmin deploy -- interactive=false --contextroot $name --name $name --force=true $file", logoutput => on_failure, refreshonly => true, } if $notify { Exec ["Deploy glassfish app $name"] { notify +> $notify, } Exec ["Forced redeploy glassfish app $name"] { notify +> $notify, } } if $require { Exec["Forced redeploy glassfish app $name"] { require +> $require, } } -- Robin <robin@kallisti.net.nz> JabberID: <eythian@jabber.kallisti.net.nz> http://www.kallisti.net.nz/blog ||| http://identi.ca/eythian PGP Key 0xA99CEB6D = 5957 6D23 8B16 EFAB FEF8 7175 14D3 6485 A99C EB6D
Graham Stratton
2009-Apr-23 00:48 UTC
[Puppet Users] Re: Subscribe should override creates for exec resources?
On 22/04/2009, at 5:50 PM, Graham Stratton wrote:> On 22/04/2009, at 5:26 PM, Graham Stratton wrote: > >> I''m clearly missing something here. I thought that if I had a >> subscribe attribute on an exec resource, then that resource would run >> regardless on any creates/unless, but that is not what I''m seeing. >> >> I created a minimal test, shown below. As you can see: >> >> - The file ''trigger'' was changed, and Puppet noticed. >> - The exec was ''refreshed'' due to the dependency, but it didn''t >> actually run. >> - Without the ''creates'' file, the exec runs correctly. > > After a discussion on IRC this makes more sense. Since subscribe/ > notify are metaparameters they control when resources are run, but the > exec parameter ''creates'' will still override that. > > That''s rather unfortunate for my use-case, though. I want an exec to > run until a file has been created or whenever a config file is > updated. But that''s not quite perfect, so maybe this will force me to > fix things more!Replying to myself once more, my final solution was to use the bash - nt (newer than) comparator. I replaced the subscribe and the creates with: onlyif => "[ $path/buildout.cfg -nt $path/.installed.cfg ]" and now it runs if the .installed.cfg doesn''t exist or the config file is newer. It''s not perfectly clean, but I can''t see where it''s likely to go wrong. Regards, Graham --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---