Added command module

pull/3/head
Michael DeHaan 13 years ago
parent f4fca1069a
commit a2a8deaeaa

@ -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

@ -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)
Loading…
Cancel
Save