diff --git a/changelogs/fragments/fix_spurious_stderr.yml b/changelogs/fragments/fix_spurious_stderr.yml new file mode 100644 index 00000000000..9318f4b8911 --- /dev/null +++ b/changelogs/fragments/fix_spurious_stderr.yml @@ -0,0 +1,2 @@ +bugfixes: + - dont emit empty error due to \n https://github.com/ansible/ansible/pull/39019 diff --git a/lib/ansible/plugins/inventory/script.py b/lib/ansible/plugins/inventory/script.py index b62da1ff82a..9e85bba0554 100644 --- a/lib/ansible/plugins/inventory/script.py +++ b/lib/ansible/plugins/inventory/script.py @@ -104,7 +104,10 @@ class InventoryModule(BaseInventoryPlugin, Cacheable): (stdout, stderr) = sp.communicate() path = to_native(path) - err = to_native(stderr or "") + "\n" + err = to_native(stderr or "") + + if err and not err.endswith('\n'): + err += '\n' if sp.returncode != 0: raise AnsibleError("Inventory script (%s) had an execution error: %s " % (path, err))