Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for an exception when for whatever reason the inventory script fails #1535

Merged
merged 1 commit into from
Nov 7, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/ansible/inventory/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,18 @@
from ansible.inventory.host import Host
from ansible.inventory.group import Group
from ansible import utils
from ansible import errors

class InventoryScript(object):
''' Host inventory parser for ansible using external inventory scripts. '''

def __init__(self, filename=C.DEFAULT_HOST_LIST):

cmd = [ filename, "--list" ]
sp = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
try:
sp = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
except OSError, e:
raise errors.AnsibleError("problem running %s (%s)" % (' '.join(cmd), e))
(stdout, stderr) = sp.communicate()
self.data = stdout
self.groups = self._parse()
Expand Down