From fe5e6d74af093228fd7ae342963a17f92b6d07fb Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Thu, 19 Apr 2018 09:45:30 -0400 Subject: [PATCH] better handle appending \n on stderr fixes #39007 --- lib/ansible/plugins/inventory/script.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/ansible/plugins/inventory/script.py b/lib/ansible/plugins/inventory/script.py index 35008fa2e8..342974dac2 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))