From 86663c8060a5086bd99fa220281143c66cfff02a Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Fri, 27 Apr 2018 14:06:56 -0400 Subject: [PATCH] fixy typo (#39430) (cherry picked from commit 01e7f44e0df4b11ddd8d6a5e32e249da4324901b) --- changelogs/fragments/fix_spurious_stderr.yml | 2 ++ lib/ansible/plugins/inventory/script.py | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/fix_spurious_stderr.yml 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))