Re: Can't Execute Scripts?

261 views
Skip to first unread message

jcbollinger

unread,
Apr 30, 2015, 9:58:45 AM4/30/15
to puppet...@googlegroups.com


On Wednesday, April 29, 2015 at 9:20:37 AM UTC-5, Jacob W. wrote:
Hi all,

I'm trying to run some scripts provided by Red Hat to test for select security vulnerabilities. They're as-is from Red Hat, excluding a minor modification so I get emailed when it finds a vulnerable system (noted in bold/highlighted). I can run the command from the script and it works fine, and I can run the script by hand and it works fine. However, when I try calling it from Puppet it fails with:

Notice: /Stage[main]/patches_security::test_ghost/Exec[/tmp/ghost-test.sh]/returns: Error: Could not execute posix command: Exec format error - /tmp/ghost-test.sh
Error: /Stage[main]/patches_security::test_ghost/Exec[/tmp/ghost-test.sh]: Failed to call refresh: /tmp/ghost-test.sh returned 1 instead of one of [0]
Error: /Stage[main]/patches_security::test_ghost/Exec[/tmp/ghost-test.sh]: /tmp/ghost-test.sh returned 1 instead of one of [0]



Those messages say that you're getting the 'posix' provider for your Exec resource, and they suggest that your script is not recognized as having a valid format (per execve(2) and the related exec-family functions).  But your script *does* appear to have a valid format, inasmuch as it starts with a shebang line that ought to be valid, and execve() handles that.

Usually when a program succeeds when run directly but fails when run from Puppet, the problem is related to environment (variables) or security context.  The agent does provide a very sparse environment to commands it Execs (and in particular, it looks like you may want to check that `HOSTNAME` is among them).  If you need additional environment variables then you provide them via Exec's 'environment' parameter.

The error message does not look like it indicates an environment issue, however.  Although you shouldn't need to do so, I'm going to suggest you try to invoke bash explicitly:

exec { '/bin/bash /tmp/ghost-test.sh':
# ...

OR

try using the 'shell' provider:

exec { '/tmp/ghost-test.sh':
  provider
=> 'shell',
 
# ...


Please let us know whether one or both of those solves your problem.


John

Reply all
Reply to author
Forward
Message has been deleted
Message has been deleted
0 new messages