From 36b3fc3acf21a428480782144d20eebe6c79c05e Mon Sep 17 00:00:00 2001 From: Blair Zajac Date: Sun, 17 Mar 2013 11:50:15 -0700 Subject: [PATCH] Fix for inventory scripts with no path prefix that are in CWD. Without this, using '-i ec2.py' will not work if '.' is not in PATH. --- lib/ansible/inventory/script.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/ansible/inventory/script.py b/lib/ansible/inventory/script.py index 628e8029349..16929524263 100644 --- a/lib/ansible/inventory/script.py +++ b/lib/ansible/inventory/script.py @@ -17,6 +17,7 @@ ############################################# +import os import subprocess import ansible.constants as C from ansible.inventory.host import Host @@ -29,7 +30,10 @@ class InventoryScript(object): def __init__(self, filename=C.DEFAULT_HOST_LIST): - self.filename = filename + # Support inventory scripts that are not prefixed with some + # path information but happen to be in the current working + # directory when '.' is not in PATH. + self.filename = os.path.abspath(filename) cmd = [ self.filename, "--list" ] try: sp = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)