ansible: use _ansible_shell_executable in ScriptRunner.

Now we match Ansible error output and exit status. Ansible:

    $ ansible localhost -e end=2 -m custom_binary_single_null
    localhost | FAILED! => {
        "changed": false,
        "module_stderr": "Shared connection to localhost closed.\r\n",
        "module_stdout": "/bin/sh: /Users/dmw/.ansible/tmp/ansible-tmp-1522661797.42-158833651208060/custom_binary_single_null: cannot execute binary file\r\n",
        "msg": "MODULE FAILURE",
        "rc": 126
    }

Mitogen now:

    localhost | FAILED! => {
        "changed": false,
        "module_stderr": "/bin/sh: /var/folders/gw/f6w3dgy16fsg5y4kdthbqycw0000gn/T/ansible_mitogenAYF8LM-binary: cannot execute binary file\n",
        "module_stdout": "",
        "msg": "MODULE FAILURE",
        "rc": 126
    }

Previously:

    localhost | FAILED! => {
        "changed": false,
        "module_stderr": "<type 'exceptions.OSError'>: [Errno 8] Exec format error",
        "module_stdout": "",
        "msg": "MODULE FAILURE",
        "rc": 1
    }
This commit is contained in:
David Wilson 2018-04-02 10:37:23 +01:00
parent e2542c1683
commit a731be32a2
1 changed files with 11 additions and 2 deletions

View File

@ -214,7 +214,11 @@ class ProgramRunner(Runner):
)
def _get_program_args(self):
return [self.program_fp.name]
return [
self.args['_ansible_shell_executable'],
'-c',
self.program_fp.name
]
def revert(self):
"""
@ -229,6 +233,7 @@ class ProgramRunner(Runner):
args=self._get_program_args(),
)
except Exception, e:
LOG.exception('While running %s', self._get_program_args())
return {
'rc': 1,
'stdout': '',
@ -267,7 +272,11 @@ class ArgsFileRunner(Runner):
return json.dumps(self.args)
def _get_program_args(self):
return [self.program_fp.name, self.args_fp.name]
return [
self.args['_ansible_shell_executable'],
'-c',
"%s %s" % (self.program_fp.name, self.args_fp.name),
]
def revert(self):
"""