Thanks for the suggestion Patrick, it led me to the cause of the
problem :)

I wrote a very simple local test manifest to emulate the Exec problem
with 'puppet apply' and it still occurred. Out of pure habit, I often
execute 'ls -l' when I switch between terminals (so I know where I am)
and noticed that in /root on the server in question there was an empty
file called 'grep'... Removing this stray file and puppet now runs
fine :)

It seems that something to do with Ruby's FileTest module is
searching ./ before the specified Path in the exec resource, thus
finding a non executable 'grep' in CWD and complaining that it's not
executable. The touching of exec.rb was a red herring as I was
changing into the Ruby lib directory before hand :)

This doesn't appear to affect the actual execution of commands, so
don't be worried about the wrong commands being executed based on the
CWD of Puppet.

I've raised a bug for this: http://projects.puppetlabs.com/issues/5495

On Dec 9, 6:17 pm, Patrick <kc7...@gmail.com> wrote:
> On Dec 9, 2010, at 9:14 AM, luke.bigum wrote:
>
> > Interesting, I've noticed that puppet runs triggered from a daemonised
> > puppetd aren't affected by the problem (as Dashboard and /var/log/
> > messages says their is no errors), but when run from the command line
> > as puppetd --test it fails as usual for me:
>
> > err: /Stage[main]/Fh_freetds/Exec[change /etc/freetds.conf version]:
> > Could not evaluate: 'grep' is not executable
>
> > Can't spot any difference in the environments so far.
>
> Here's something to try, can you reproduce this problem using the local 
> "puppet" program that directly evaluates the manifest.  Not the client 
> "puppetd".  If so, that's a lot less code you've narrowed to down to.
>
> > On Dec 9, 4:42 pm, "luke.bigum" <luke.bi...@fasthosts.co.uk> wrote:
> >> Hi Rudy,
>
> >> I'm not sure if you fixed this yet, but I ran into the same problem
> >> using grep in an unless parameter of an exec resource.
>
> >> I went looking through the Ruby code, in /usr/lib/ruby/site_ruby/1.8/
> >> puppet/type/exec.rb on line 571. I changed these four lines:
>
> >>       unless FileTest.executable?(exe)
> >>         raise ArgumentError,
> >>           "'#{exe}' is not executable"
> >>       end
>
> >> To just a single line like the one above:
>
> >>       raise ArgumentError, "'#{exe}' is not executable" unless
> >> FileTest.executable?(exe)
>
> >> And then Puppet stopped complaining. I thought this doesn't make any
> >> sense at all, so I changed it back... Puppet still worked. I removed
> >> and reinstalled the RPM, Puppet is back to complaining about grep not
> >> being executable. I then just touched exec.rb and the problem is
> >> magically fixed again.
>
> >> I don't know very much about Ruby, so I'm just going to back away
> >> very, very slowly, arms raised in the air to ward off evil ;)
>
> >> But seriously, is there a Ruby guru who might know what's going on
> >> here? I can even reproduce the issue by uninstalling and reinstalling
> >> the puppet RPM - not sure how long it's going to stay broken though,
> >> we'll see.
>
> >> -Luke
>
> >> On Dec 2, 10:30 am, Rudy Gevaert <rudy.geva...@gmail.com> wrote:
>
> >>> Hi
>
> >>> I'm seeing a strange thing here.  I only have this on one machine!  3
> >>> others that are 'identical' don't have that issue...
>
> >>> err: /Stage[main]/Vim/Exec[update-alternatives --set editor /usr/bin/
> >>> vim.basic]: Could not evaluate: 'test' is not executable
>
> >>> class vim{
>
> >>>   $vim_package= "vim"
>
> >>>   package {
> >>>     $vim_package:
> >>>       ensure => installed,
> >>>       provider => $operatingsystem ? {
> >>>         "Solaris" => 'pkgutil',
> >>>         default => undef
> >>>       }
> >>>   }
>
> >>>   case $operatingsystem{
> >>>     "Debian": {
> >>>       exec { "update-alternatives --set editor /usr/bin/vim.basic":
> >>>         path => "/bin:/sbin:/usr/bin:/usr/sbin",
> >>>         unless => "test /etc/alternatives/editor -ef /usr/bin/
> >>> vim.basic"
> >>>       }
> >>>     }
> >>>   }
>
> >>> }
>
> >>> Manual output:
>
> >>> r...@cyrprd1:~# puppet agent --test
> >>> info: Retrieving plugin
> >>> info: Loading facts in ugentinfo
> >>> info: Loading facts in configured_ntp_servers
> >>> info: Loading facts in ugentinfo
> >>> info: Loading facts in configured_ntp_servers
> >>> info: Caching catalog for cyrprd1.ugent.be
> >>> info: Applying configuration version '1291285388'
> >>> notice: /Stage[main]/Debian_os/Exec[apt-get-update]/returns: executed
> >>> successfully
> >>> notice: /Stage[main]/Mailstore/Package[cyrus-ugent]/ensure: ensure
> >>> changed '0.1-33' to '0.1-34'
> >>> err: /Stage[main]/Vim/Exec[update-alternatives --set editor /usr/bin/
> >>> vim.basic]: Could not evaluate: 'test' is not executable
> >>> notice: Finished catalog run in 7.66 seconds
>
> >>> r...@cyrprd1:~# test /etc/alternatives/editor -ef /usr/bin/vim.basic
> >>> r...@cyrprd1:~# which test
> >>> /usr/bin/test
> >>> r...@cyrprd1:~# ls -l /usr/bin/test
> >>> -rwxr-xr-x 1 root root 30136 Apr 28  2010 /usr/bin/test
> >>> r...@cyrprd1:~#
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Puppet Users" group.
> > To post to this group, send email to puppet-us...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > puppet-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/puppet-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-us...@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to