From 6b3d0f4788f52b6f7cbed199a36c51cfda9ac17a Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Thu, 15 Jan 2015 11:52:22 -0500 Subject: [PATCH] now captures returncode errors on inventory scripts --- lib/ansible/inventory/script.py | 4 ++++ v2/ansible/inventory/script.py | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/lib/ansible/inventory/script.py b/lib/ansible/inventory/script.py index 6239be0140e..e0e8efb4a3d 100644 --- a/lib/ansible/inventory/script.py +++ b/lib/ansible/inventory/script.py @@ -43,6 +43,10 @@ class InventoryScript(object): except OSError, e: raise errors.AnsibleError("problem running %s (%s)" % (' '.join(cmd), e)) (stdout, stderr) = sp.communicate() + + if sp.returncode != 0: + raise errors.AnsibleError("Inventory script (%s) had an execution error: %s " % (filename,stderr)) + self.data = stdout # see comment about _meta below self.host_vars_from_top = None diff --git a/v2/ansible/inventory/script.py b/v2/ansible/inventory/script.py index 6239be0140e..e0e8efb4a3d 100644 --- a/v2/ansible/inventory/script.py +++ b/v2/ansible/inventory/script.py @@ -43,6 +43,10 @@ class InventoryScript(object): except OSError, e: raise errors.AnsibleError("problem running %s (%s)" % (' '.join(cmd), e)) (stdout, stderr) = sp.communicate() + + if sp.returncode != 0: + raise errors.AnsibleError("Inventory script (%s) had an execution error: %s " % (filename,stderr)) + self.data = stdout # see comment about _meta below self.host_vars_from_top = None