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
a6ba149c
Commit
a6ba149c
authored
Jul 23, 2015
by
Brian Coca
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implemented simplified output for adhoc adn command modules as in v1
parent
65ae9780
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
5 deletions
+36
-5
lib/ansible/constants.py
+1
-0
lib/ansible/plugins/callback/minimal.py
+20
-3
lib/ansible/plugins/callback/oneline.py
+15
-2
No files found.
lib/ansible/constants.py
View file @
a6ba149c
...
...
@@ -229,6 +229,7 @@ DEFAULT_PASSWORD_CHARS = ascii_letters + digits + ".,:-_"
# non-configurable things
MODULE_REQUIRE_ARGS
=
[
'command'
,
'shell'
,
'raw'
,
'script'
]
MODULE_NO_JSON
=
[
'command'
,
'shell'
,
'raw'
]
DEFAULT_BECOME_PASS
=
None
DEFAULT_SUDO_PASS
=
None
DEFAULT_REMOTE_PASS
=
None
...
...
lib/ansible/plugins/callback/minimal.py
View file @
a6ba149c
...
...
@@ -20,6 +20,7 @@ from __future__ import (absolute_import, division, print_function)
__metaclass__
=
type
from
ansible.plugins.callback
import
CallbackBase
from
ansible
import
constants
as
C
class
CallbackModule
(
CallbackBase
):
...
...
@@ -33,6 +34,16 @@ class CallbackModule(CallbackBase):
CALLBACK_TYPE
=
'stdout'
CALLBACK_NAME
=
'minimal'
def
_command_generic_msg
(
self
,
host
,
result
,
caption
):
''' output the result of a command run '''
buf
=
"
%
s |
%
s | rc=
%
s >>
\n
"
%
(
host
,
caption
,
result
.
get
(
'rc'
,
0
))
buf
+=
result
.
get
(
'stdout'
,
''
)
buf
+=
result
.
get
(
'stdout'
,
''
)
buf
+=
result
.
get
(
'msg'
,
''
)
return
buf
+
"
\n
"
def
v2_runner_on_failed
(
self
,
result
,
ignore_errors
=
False
):
if
'exception'
in
result
.
_result
:
if
self
.
_display
.
verbosity
<
3
:
...
...
@@ -47,11 +58,17 @@ class CallbackModule(CallbackBase):
# finally, remove the exception from the result so it's not shown every time
del
result
.
_result
[
'exception'
]
self
.
_display
.
display
(
"
%
s | FAILED! =>
%
s"
%
(
result
.
_host
.
get_name
(),
self
.
_dump_results
(
result
.
_result
)),
color
=
'red'
)
if
result
.
_task
.
action
in
C
.
MODULE_NO_JSON
:
self
.
_display
.
display
(
self
.
_command_generic_msg
(
result
.
_host
.
get_name
(),
result
.
_result
,
"FAILED"
),
color
=
'red'
)
else
:
self
.
_display
.
display
(
"
%
s | FAILED! =>
%
s"
%
(
result
.
_host
.
get_name
(),
self
.
_dump_results
(
result
.
_result
)),
color
=
'red'
)
def
v2_runner_on_ok
(
self
,
result
):
self
.
_display
.
display
(
"
%
s | SUCCESS =>
%
s"
%
(
result
.
_host
.
get_name
(),
self
.
_dump_results
(
result
.
_result
)),
color
=
'green'
)
self
.
_handle_warnings
(
result
.
_result
)
if
result
.
_task
.
action
in
C
.
MODULE_NO_JSON
:
self
.
_display
.
display
(
self
.
_command_generic_msg
(
result
.
_host
.
get_name
(),
result
.
_result
,
"SUCCESS"
),
color
=
'green'
)
else
:
self
.
_display
.
display
(
"
%
s | SUCCESS =>
%
s"
%
(
result
.
_host
.
get_name
(),
self
.
_dump_results
(
result
.
_result
)),
color
=
'green'
)
self
.
_handle_warnings
(
result
.
_result
)
def
v2_runner_on_skipped
(
self
,
result
):
self
.
_display
.
display
(
"
%
s | SKIPPED"
%
(
result
.
_host
.
get_name
()),
color
=
'cyan'
)
...
...
lib/ansible/plugins/callback/oneline.py
View file @
a6ba149c
...
...
@@ -20,6 +20,7 @@ from __future__ import (absolute_import, division, print_function)
__metaclass__
=
type
from
ansible.plugins.callback
import
CallbackBase
from
ansible
import
constants
as
C
class
CallbackModule
(
CallbackBase
):
...
...
@@ -33,6 +34,12 @@ class CallbackModule(CallbackBase):
CALLBACK_TYPE
=
'stdout'
CALLBACK_NAME
=
'oneline'
def
_command_generic_msg
(
self
,
hostname
,
result
,
caption
):
if
'stderr'
in
result
and
result
[
'stderr'
]:
return
"
%
s |
%
s | rc=
%
s | (stdout)
%
s (stderr)
%
s"
%
(
hostname
,
caption
,
result
.
get
(
'rc'
,
0
),
result
.
get
(
'stdout'
,
''
),
result
.
get
(
'stderr'
,
''
))
else
:
return
"
%
s |
%
s | rc=
%
s | (stdout)
%
s"
%
(
hostname
,
caption
,
result
.
get
(
'rc'
,
0
),
result
.
get
(
'stdout'
,
''
))
def
v2_runner_on_failed
(
self
,
result
,
ignore_errors
=
False
):
if
'exception'
in
result
.
_result
:
if
self
.
_display
.
verbosity
<
3
:
...
...
@@ -42,7 +49,10 @@ class CallbackModule(CallbackBase):
else
:
msg
=
"An exception occurred during task execution. The full traceback is:
\n
"
+
result
.
_result
[
'exception'
]
.
replace
(
'
\n
'
,
''
)
self
.
_display
.
display
(
msg
,
color
=
'red'
)
if
result
.
_task
.
action
in
C
.
MODULE_NO_JSON
:
self
.
_display
.
display
(
self
.
_command_generic_msg
(
result
.
_host
.
get_name
(),
result
.
_result
,
'FAILED'
),
color
=
'red'
)
else
:
self
.
_display
.
display
(
msg
,
color
=
'red'
)
# finally, remove the exception from the result so it's not shown every time
del
result
.
_result
[
'exception'
]
...
...
@@ -50,7 +60,10 @@ class CallbackModule(CallbackBase):
self
.
_display
.
display
(
"
%
s | FAILED! =>
%
s"
%
(
result
.
_host
.
get_name
(),
self
.
_dump_results
(
result
.
_result
,
indent
=
0
)
.
replace
(
'
\n
'
,
''
)),
color
=
'red'
)
def
v2_runner_on_ok
(
self
,
result
):
self
.
_display
.
display
(
"
%
s | SUCCESS =>
%
s"
%
(
result
.
_host
.
get_name
(),
self
.
_dump_results
(
result
.
_result
,
indent
=
0
)
.
replace
(
'
\n
'
,
''
)),
color
=
'green'
)
if
result
.
_task
.
action
in
C
.
MODULE_NO_JSON
:
self
.
_display
.
display
(
self
.
_command_generic_msg
(
result
.
_host
.
get_name
(),
result
.
_result
,
'SUCCESS'
),
color
=
'green'
)
else
:
self
.
_display
.
display
(
"
%
s | SUCCESS =>
%
s"
%
(
result
.
_host
.
get_name
(),
self
.
_dump_results
(
result
.
_result
,
indent
=
0
)
.
replace
(
'
\n
'
,
''
)),
color
=
'green'
)
def
v2_runner_on_unreachable
(
self
,
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