On Thu, Nov 03, 2011 at 10:39:29PM -0700, Robert Atkins wrote:
> On Nov 2, 7:33 pm, Christopher Wood <[email protected]>
> wrote:
> > It's worth mentioning that find -exec this way forks a separate copy of 
> > find for each file. You'll notice how much slower this is on a really large 
> > set of files (possibly larger than yours). If you have a recursion-capable 
> > chown it's quicker to use chown -R.
> 
> Noted, this is what I'm using now:
> 
> exec { "enforce ${jetty_install_dir} permissions":
>       command => "/bin/chown jetty:users ${jetty_install_dir}",
>       onlyif  => "/usr/bin/test $(/usr/bin/find ${jetty_install_dir} ! -
> user jetty -o ! -group users | wc -l) -gt 0",
>       subscribe => [File["/opt/jetty/bin/jetty.sh"], File["/opt/jetty/
> resources/log4j.xml"]],
>       refreshonly => true,
> }
> 
> I can see it execute ("notice: /Stage[main]//Exec[enforce /opt/
> jetty-6.1.26 permissions]: Triggered 'refresh' from 1 events") but the
> new files are still left with the wrong ownership. When I run the
> "onlyif" command manually and echo $? I get 0, which says it should
> run the chown. Can anyone see what I'm missing?
> 
> Cheers, Robert.
> 

I don't see the need to specify refreshonly => true because you already
have a propert onlyif statement. Refreshonly means that the command is
ONLY run when the exec resource receives a refresh event. A refresh event
is triggered when the subscribed resource has changed or a changed
resource has set the notify metaparamter.

So in your case the refreshonly renders your onlyif useless; the chown
command is only run, when /opt/jetty/bin/jetty.sh or
/opt/jetty/resources/log4j.xml changes.

-Stefan

Attachment: pgpw7TQgzyTfF.pgp
Description: PGP signature

Reply via email to