Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
a2a8deae
Commit
a2a8deae
authored
Feb 23, 2012
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added command module
parent
f4fca106
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
8 deletions
+31
-8
README.md
+4
-8
library/command
+27
-0
No files found.
README.md
View file @
a2a8deae
...
...
@@ -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
...
...
library/command
0 → 100755
View file @
a2a8deae
#!/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
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment