John,

Thank you for your help; it pointed me in the right direction. My problem 
ended up being something quirky to our environment. Someone setup a script 
so when we pushed files a header would be added that said "Managed by 
Puppet" and such so no one would modify that file from the end system 
itself. The problem was it was injecting at the very top, above the 
shebang. Easy enough of a fix once I looked at the deployed script and 
pieced it together, but unfortunately I wasted time with tunnel vision 
convinced it was Puppet or the script itself.
Thanks again!

On Thursday, April 30, 2015 at 9:58:45 AM UTC-4, jcbollinger wrote:
>
>
>
> 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 
> <https://docs.puppetlabs.com/references/3.4.stable/type.html#exec-attribute-environment>
> .
>
> 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
>
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/d3fcd758-12e0-485e-b7ae-fa6c8ffa5613%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to