Does anyone have a technique for performing an exec the first time puppetd runs but then reverting to refreshonly => true state for subsequent runs? The basic idea is: file { "/etc/foo": notify => Exec["bar"] } exec { "bar": command => "Do stuff to /etc/foo", refreshonly => true } Should I use a fact that is unset based on a file''s presence or does someone have a more elegant way of doing this? Thanks, Trevor --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
check http://reductivelabs.com/trac/puppet/wiki/TypeReference#exec you could use creates, onlyif and unless. Ohad On Thu, Jul 31, 2008 at 5:39 AM, Trevor Vaughan <peiriannydd@gmail.com> wrote:> > Does anyone have a technique for performing an exec the first time > puppetd runs but then reverting to refreshonly => true state for > subsequent runs? > > The basic idea is: > > file { "/etc/foo": > notify => Exec["bar"] > } > > exec { "bar": > command => "Do stuff to /etc/foo", > refreshonly => true > } > > Should I use a fact that is unset based on a file''s presence or does > someone have a more elegant way of doing this? > > Thanks, > > Trevor > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Ohad, Thanks for the tip, but the combo''s just didn''t work out. I ended up using a custom fact based on the presence of a file. it works pretty well but feels a little bizarre. Trevor On Wed, Jul 30, 2008 at 8:47 PM, Ohad Levy <ohadlevy@gmail.com> wrote:> > check http://reductivelabs.com/trac/puppet/wiki/TypeReference#exec > > you could use creates, onlyif and unless. > > Ohad > > On Thu, Jul 31, 2008 at 5:39 AM, Trevor Vaughan <peiriannydd@gmail.com> wrote: >> >> Does anyone have a technique for performing an exec the first time >> puppetd runs but then reverting to refreshonly => true state for >> subsequent runs? >> >> The basic idea is: >> >> file { "/etc/foo": >> notify => Exec["bar"] >> } >> >> exec { "bar": >> command => "Do stuff to /etc/foo", >> refreshonly => true >> } >> >> Should I use a fact that is unset based on a file''s presence or does >> someone have a more elegant way of doing this? >> >> Thanks, >> >> Trevor >> >> > >> > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Whats the difference to the create option? On Thu, Jul 31, 2008 at 12:40 PM, Trevor Vaughan <peiriannydd@gmail.com> wrote:> > Ohad, > > Thanks for the tip, but the combo''s just didn''t work out. > > I ended up using a custom fact based on the presence of a file. it > works pretty well but feels a little bizarre. > > Trevor > > On Wed, Jul 30, 2008 at 8:47 PM, Ohad Levy <ohadlevy@gmail.com> wrote: >> >> check http://reductivelabs.com/trac/puppet/wiki/TypeReference#exec >> >> you could use creates, onlyif and unless. >> >> Ohad >> >> On Thu, Jul 31, 2008 at 5:39 AM, Trevor Vaughan <peiriannydd@gmail.com> wrote: >>> >>> Does anyone have a technique for performing an exec the first time >>> puppetd runs but then reverting to refreshonly => true state for >>> subsequent runs? >>> >>> The basic idea is: >>> >>> file { "/etc/foo": >>> notify => Exec["bar"] >>> } >>> >>> exec { "bar": >>> command => "Do stuff to /etc/foo", >>> refreshonly => true >>> } >>> >>> Should I use a fact that is unset based on a file''s presence or does >>> someone have a more elegant way of doing this? >>> >>> Thanks, >>> >>> Trevor >>> >>> > >>> >> >> > >> > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Basically, if you have multiple execs, you would have to tell them to all create different files and then clean those files up some way in the future if you wanted to force the execs to run again. The onlyif option would have done just about what I wanted to do, but with a custom fact, I could affect the state of various types of objects, not just exec. Also, I can quickly modify the custom fact on the server side to point at something different if I want to. For instance: Say, my fact is called "runnow": exec { "dostuff": command => ''echo "Doing stuff now"'', refreshonly => $runnow ? { "true" => "false", default => "true" } } So, this is pretty much the same as using onlyif, but a bit cleaner. But, with a custom fact, I can also do: file { "/tmp/test": content => $runnow ? { "true" => "This is a test file", default => template(test.erb) } } And then, if I decide that my trigger should be on an external source, instead of a file, (which would probably be better), I can just change the ''runnow'' fact instead of every exec in my manifest set. That''s my rationale anyway... Trevor Ohad Levy wrote:> Whats the difference to the create option? > > On Thu, Jul 31, 2008 at 12:40 PM, Trevor Vaughan <peiriannydd@gmail.com> wrote: > >> Ohad, >> >> Thanks for the tip, but the combo''s just didn''t work out. >> >> I ended up using a custom fact based on the presence of a file. it >> works pretty well but feels a little bizarre. >> >> Trevor >> >> On Wed, Jul 30, 2008 at 8:47 PM, Ohad Levy <ohadlevy@gmail.com> wrote: >> >>> check http://reductivelabs.com/trac/puppet/wiki/TypeReference#exec >>> >>> you could use creates, onlyif and unless. >>> >>> Ohad >>> >>> On Thu, Jul 31, 2008 at 5:39 AM, Trevor Vaughan <peiriannydd@gmail.com> wrote: >>> >>>> Does anyone have a technique for performing an exec the first time >>>> puppetd runs but then reverting to refreshonly => true state for >>>> subsequent runs? >>>> >>>> The basic idea is: >>>> >>>> file { "/etc/foo": >>>> notify => Exec["bar"] >>>> } >>>> >>>> exec { "bar": >>>> command => "Do stuff to /etc/foo", >>>> refreshonly => true >>>> } >>>> >>>> Should I use a fact that is unset based on a file''s presence or does >>>> someone have a more elegant way of doing this? >>>> >>>> Thanks, >>>> >>>> Trevor >>>> >>>> > > --~--~---------~--~----~------------~-------~--~----~ > 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 > -~----------~----~----~----~------~----~------~--~--- > >
Trevor Vaughan wrote:> Does anyone have a technique for performing an exec the first time > puppetd runs but then reverting to refreshonly => true state for > subsequent runs? > > The basic idea is: > > file { "/etc/foo": > notify => Exec["bar"] > } > > exec { "bar": > command => "Do stuff to /etc/foo", > refreshonly => true > } > > Should I use a fact that is unset based on a file''s presence or does > someone have a more elegant way of doing this? >I think what this does is, when File["/etc/foo"] changes state, it''ll execute Exec["bar"]. If File["/etc/foo"] does not change state however, Exec["bar"] will not execute because of the refreshonly => true setting. I''m not sure whether that is what you want though? Kind regards, Jeroen van Meeuwen -kanarip --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Evan, Thanks. Since one additional person thinks that it''s a nice solution, it''s what I''ll do :-). I will get it onto the wiki at some point. Trevor On Thu, Jul 31, 2008 at 9:14 AM, Evan Hisey <ehisey@gmail.com> wrote:> > On Thu, Jul 31, 2008 at 7:46 AM, Trevor Vaughan <peiriannydd@gmail.com> wrote: >> Basically, if you have multiple execs, you would have to tell them to all >> create different files and then clean those files up some way in the future >> if you wanted to force the execs to run again. >> >> The onlyif option would have done just about what I wanted to do, but with a >> custom fact, I could affect the state of various types of objects, not just >> exec. Also, I can quickly modify the custom fact on the server side to >> point at something different if I want to. >> >> For instance: >> >> Say, my fact is called "runnow": >> >> exec { "dostuff": >> command => ''echo "Doing stuff now"'', >> refreshonly => $runnow ? { >> "true" => "false", >> default => "true" >> } >> } >> >> So, this is pretty much the same as using onlyif, but a bit cleaner. But, >> with a custom fact, I can also do: >> >> file { "/tmp/test": >> content => $runnow ? { >> "true" => "This is a test file", >> default => template(test.erb) >> } >> } >> >> And then, if I decide that my trigger should be on an external source, >> instead of a file, (which would probably be better), I can just change the >> ''runnow'' fact instead of every exec in my manifest set. >> >> That''s my rationale anyway... > > Thats a really nice solution. You might consider putting that on the wiki. > > Evan > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---