Could not evaluate: 'test' is not executable

805 views
Skip to first unread message

Rudy Gevaert

unread,
Dec 2, 2010, 5:30:41 AM12/2/10
to Puppet Users
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:

root@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



root@cyrprd1:~# test /etc/alternatives/editor -ef /usr/bin/vim.basic
root@cyrprd1:~# which test
/usr/bin/test
root@cyrprd1:~# ls -l /usr/bin/test
-rwxr-xr-x 1 root root 30136 Apr 28 2010 /usr/bin/test
root@cyrprd1:~#


luke.bigum

unread,
Dec 9, 2010, 11:42:22 AM12/9/10
to Puppet Users
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

luke.bigum

unread,
Dec 9, 2010, 12:14:01 PM12/9/10
to Puppet Users
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.

Patrick

unread,
Dec 9, 2010, 1:17:48 PM12/9/10
to puppet...@googlegroups.com

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.

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

luke.bigum

unread,
Dec 10, 2010, 5:34:15 AM12/10/10
to Puppet Users
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

Patrick

unread,
Dec 10, 2010, 6:19:02 AM12/10/10
to puppet...@googlegroups.com

On Dec 10, 2010, at 2:34 AM, luke.bigum wrote:

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

Except it might be. Puppet might have been trying to execute the file and then failing because the permissions were 644 instead of 755.

luke.bigum

unread,
Dec 10, 2010, 6:40:56 AM12/10/10
to Puppet Users
> > 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.
>
> Except it might be.  Puppet might have been trying to execute the file and then failing because the permissions were 644 instead of 755.

I thought of that and put a script in ./grep to touch another file to
see if it would be executed instead of the grep that is in the Exec
resource's path. It wasn't so I assume it's something to do with the
Ruby FileTest module 'executable?' method that's not being done right,
the actual command execution obeys the Exec's path as expected. At
least that's what I observed for the bug report.

Patrick

unread,
Dec 10, 2010, 3:40:48 PM12/10/10
to puppet...@googlegroups.com

Ah. Nevermind then.

Rudy Gevaert

unread,
Dec 20, 2010, 11:25:07 AM12/20/10
to puppet...@googlegroups.com


On Friday, December 10, 2010 11:34:15 AM UTC+1, luke.bigum wrote:

file called 'grep'... Removing this stray file and puppet now runs
fine :)


Hi Luke.  Yes you are right!  I had a file called test in /root !


 thanks!
Reply all
Reply to author
Forward
0 new messages