From f17c4ca4b2b95dd250ca4916dc9415a85f4e1800 Mon Sep 17 00:00:00 2001 From: Michael DeHaan Date: Fri, 24 Feb 2012 02:04:50 -0500 Subject: [PATCH] Added an 'ohai' module. Some weird JSON hackage to get it to work. --- README.md | 1 + library/ohai | 12 ++++++++++++ 2 files changed, 13 insertions(+) create mode 100644 library/ohai diff --git a/README.md b/README.md index a54d0c8170f..e683493662a 100644 --- a/README.md +++ b/README.md @@ -146,6 +146,7 @@ Modules include: * command -- runs commands, giving output, return codes, and run time info * ping - just returns if the system is up or not * facter - retrieves facts about the host OS + * ohai - similar to facter, but returns structured data * copy - add files to remote systems Playbooks diff --git a/library/ohai b/library/ohai new file mode 100644 index 00000000000..968c0472367 --- /dev/null +++ b/library/ohai @@ -0,0 +1,12 @@ +#!/usr/bin/python + +# requires 'ohai' to be installed + +import json +import subprocess + +cmd = subprocess.Popen("/usr/bin/ohai", stdout=subprocess.PIPE, stderr=subprocess.PIPE) +out, err = cmd.communicate() + +# try to cleanup the JSON, for some reason facter --json doesn't need this hack +print json.dumps(json.loads(out))