Re: [Puppet Users] exec resource not refreshed when subscribed resource changes

2013-03-21 Thread Keith Burdis
The subscribe isn't needed if notify is used which is in point 1.  There
are multiple ways to solve the problem - I prefer pushing these events
using notify rather than pulling via subscribe :-)


On 21 March 2013 10:37, Felix Frank felix.fr...@alumni.tu-berlin.de wrote:

 Hi,

 On 03/14/2013 09:25 AM, Keith Burdis wrote:
  2) Adding refreshonly = true to the exec.
 
  3) Remove the creates and subscribe  from the exec.
 

 The subscribe is actually fine, but yes - the 'creates' needs to go in
 order to allow repeated execution.

 Note that this can be considered unclean manifest design, because
 a) notifications can get lost during agent crashes (if you're unlucky) and
 b) if the exec fails, puppet will likely not notify again next time,
 which is a painful and not at all unlikely failure scenario.

 Ideally, you could construct a dynamic creates or unless clause, that
 will enable puppet to always infer wether the exec need running or not.

 --
 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.




-- 
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.




Re: [Puppet Users] exec resource not refreshed when subscribed resource changes

2013-03-14 Thread Keith Burdis
Perhaps try:

1) Adding a notify = Exec['unpack_archive'] to the file resource.

2) Adding refreshonly = true to the exec.

3) Remove the creates and subscribe  from the exec.

That way the exec will only be called when the file changes.

- Keith
On 14 Mar 2013 07:56, dirk.heinri...@altum.de wrote:

 Hello,

 I've created a little class which should unpack a 7z archive on Windows.
 The class has a parameter for passing in the archive version, so that I can
 trigger an update when a new version of the archive is available. A
 simplyfied version looks like this (requires 7z):

 class my_archive ($version = undef) {
 file { 'version':
 path = 'C:/the_version',
 content = $version,
 ensure = present,
 mode = 0666,
 }

 # Extracting archive creates C:/some/dir
 exec { 'unpack_archive':
 command = cmd /c rmdir /S /Q C:\some/dir  7z x -oC:/some
 C:/path/to/archive-${version}.7z,
 creates = 'C:/some/dir/a_file',
 require = File['version'],
 path = $::path,
 subscribe = File['version'],
 }
 }

 I trigger this from site.pp like so:

   class { 'my_archive':
 version = '1.2.3'
   }

 The initial unpacking of (an older version of) the archive works fine, but
 when I change the version, I see that this change is recognized by the
 agent and a refresh is triggered, but the command isn't executed:

 Info: /Stage[main]/My_archive/File[version]: Filebucketed C:/the_version
 to puppet with sum 185910a1e94c599dc6541266286675bc
 Notice: /Stage[main]/My_archive/File[version]/content: content changed
 '{md5}185910a1e94c599dc6541266286675bc' to
 '{md5}d0cdd9a6594750ea1063643fcda90d3b'
 Debug: /Stage[main]/My_archive/File[version]: The container
 Class[My_archive] will propagate my refresh event
 Info: /Stage[main]/My_archive/File[version]: Scheduling refresh of
 Exec[unpack_archive]
 Debug: /Schedule[weekly]: Skipping device resources because running on a
 host
 Debug: Prefetching windows resources for package
 Notice: /Stage[main]/My_archive/Exec[unpack_archive]: Triggered 'refresh'
 from 1 events
 Debug: /Stage[main]/My_archive/Exec[unpack_archive]: The container
 Class[My_archive] will propagate my refresh event
 Debug: Class[My_archive]: The container Stage[main] will propagate my
 refresh event
 Debug: /Schedule[puppet]: Skipping device resources because running on a
 host
 Debug: Finishing transaction 144533424
 Debug: Storing state
 Debug: Stored state in 0.06 seconds
 Notice: Finished catalog run in 0.75 seconds

 I tried to omit creates = ..., but this only makes the agent run the
 resource every time. I also tried adding refreshonly = true, but this
 doesn't help. I even tried adding refresh = ... with the exact same
 command without any change in behaviour.

 Any hints what could be wrong?

 Puppet Agent version on Windows is 3.1.0.

 Thanks...

 Dirk

 --
 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.




-- 
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.