php-ansible icon indicating copy to clipboard operation
php-ansible copied to clipboard

When using `json()` failing command has output on stdout and not stderr

Open bambamboole opened this issue 1 year ago • 13 comments

When the option json() is turned on, a not successful execution has its output in on stdout and not on stderr.

I am not sure whats the best way to get around the issue, that a failing execution does not output anything

Option 1: Check in runProcess if the ANSIBLE_STDOUT_CALLBACK is set to json and then return $process->getOutput() instead of $process->getErrorOutput().

Option 2: Make the process accesible from the outside and make the user responsible to get the right output

Option 3: just always return $process->getOutput() (don't know how it's without json enabled)

bambamboole avatar May 07 '23 15:05 bambamboole

@maschmann do you accept a PR for one of these cases?

bambamboole avatar May 13 '23 11:05 bambamboole