diff --git a/README.md b/README.md index f387f453b81..1a6f42fa7e2 100644 --- a/README.md +++ b/README.md @@ -121,18 +121,14 @@ up around the library scripts. Existing library modules ======================== - * ping - * facter - -Modules in Progress -=================== - - * command -- gives output, return code, and time - * many others -- users, groups, files + * 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 Future plans ============ + * modules for users, groups, and files, using puppet style ensure mechanics * inventory gathering (w/ accompanying ansible-inventory & RSS) * very simple option constructing/parsing for modules * Dead-simple declarative configuration management engine using diff --git a/library/command b/library/command new file mode 100755 index 00000000000..53a8d6ffff1 --- /dev/null +++ b/library/command @@ -0,0 +1,27 @@ +#!/usr/bin/python + +import json +import subprocess +import sys +import datetime + +args = sys.argv[1:] +startd = datetime.datetime.now() + +cmd = subprocess.Popen(args, shell=True, + stdout=subprocess.PIPE, stderr=subprocess.PIPE) + +out, err = cmd.communicate() +endd = datetime.datetime.now() +delta = endd - startd + +result = { + "stdout" : out, + "stderr" : err, + "rc" : cmd.returncode, + "start" : str(startd), + "end" : str(endd), + "delta" : str(delta), +} + +print json.dumps(result)