Merge branch 'facter-fix' of git://github.com/flyapen/ansible into devel

This commit is contained in:
Michael DeHaan 2013-05-29 10:00:20 -04:00
commit da348cf079

View file

@ -1713,11 +1713,17 @@ def run_setup(module):
for (k, v) in facts.items(): for (k, v) in facts.items():
setup_options["ansible_%s" % k.replace('-', '_')] = v setup_options["ansible_%s" % k.replace('-', '_')] = v
# Look for the path to the facter and ohai binary and set
# the variable to that path.
facter_path = module.get_bin_path('facter')
ohai_path = module.get_bin_path('ohai')
# if facter is installed, and we can use --json because # if facter is installed, and we can use --json because
# ruby-json is ALSO installed, include facter data in the JSON # ruby-json is ALSO installed, include facter data in the JSON
if os.path.exists("/usr/bin/facter"): if facter_path is not None:
rc, out, err = module.run_command("/usr/bin/facter --json") rc, out, err = module.run_command(facter_path + " --json")
facter = True facter = True
try: try:
facter_ds = json.loads(out) facter_ds = json.loads(out)
@ -1731,8 +1737,8 @@ def run_setup(module):
# because it contains a lot of nested stuff we can't use for # because it contains a lot of nested stuff we can't use for
# templating w/o making a nicer key for it (TODO) # templating w/o making a nicer key for it (TODO)
if os.path.exists("/usr/bin/ohai"): if ohai_path is not None:
rc, out, err = module.run_command("/usr/bin/ohai") rc, out, err = module.run_command(ohai_path)
ohai = True ohai = True
try: try:
ohai_ds = json.loads(out) ohai_ds = json.loads(out)