mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 14:22:46 +00:00
Merge branch 'setup-no-dash-facts' of https://github.com/tima/ansible into devel
Conflicts: library/setup
This commit is contained in:
@@ -684,7 +684,7 @@ def run_setup(module):
|
|||||||
facts = ansible_facts()
|
facts = ansible_facts()
|
||||||
|
|
||||||
for (k, v) in facts.items():
|
for (k, v) in facts.items():
|
||||||
setup_options["ansible_%s" % k] = v
|
setup_options["ansible_%s" % k.replace('-', '_')] = v
|
||||||
|
|
||||||
# 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
|
||||||
@@ -707,19 +707,19 @@ def run_setup(module):
|
|||||||
# 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 os.path.exists("/usr/bin/ohai"):
|
||||||
cmd = subprocess.Popen("/usr/bin/ohai", shell=True,
|
cmd = subprocess.Popen("/usr/bin/ohai", shell=True,
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
out, err = cmd.communicate()
|
out, err = cmd.communicate()
|
||||||
ohai = True
|
ohai = True
|
||||||
try:
|
try:
|
||||||
ohai_ds = json.loads(out)
|
ohai_ds = json.loads(out)
|
||||||
except:
|
except:
|
||||||
ohai = False
|
ohai = False
|
||||||
if ohai:
|
if ohai:
|
||||||
for (k,v) in ohai_ds.items():
|
for (k,v) in ohai_ds.items():
|
||||||
if type(v) == str or type(v) == unicode:
|
if type(v) == str or type(v) == unicode:
|
||||||
k2 = "ohai_%s" % k
|
k2 = "ohai_%s" % k.replace('-', '_')
|
||||||
setup_options[k2] = v
|
setup_options[k2] = v
|
||||||
|
|
||||||
setup_result = {}
|
setup_result = {}
|
||||||
setup_result['ansible_facts'] = setup_options
|
setup_result['ansible_facts'] = setup_options
|
||||||
|
|||||||
Reference in New Issue
Block a user