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
80852f86
Commit
80852f86
authored
May 26, 2012
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Leverage cowsay if installed.
parent
a604463f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
7 deletions
+21
-7
bin/ansible-playbook
+1
-1
lib/ansible/callbacks.py
+18
-4
lib/ansible/utils.py
+2
-2
No files found.
bin/ansible-playbook
View file @
80852f86
...
@@ -84,7 +84,7 @@ def main(args):
...
@@ -84,7 +84,7 @@ def main(args):
pb
.
run
()
pb
.
run
()
hosts
=
sorted
(
pb
.
stats
.
processed
.
keys
())
hosts
=
sorted
(
pb
.
stats
.
processed
.
keys
())
print
"
\n\n
PLAY RECAP **********************
\n\n
"
print
callbacks
.
banner
(
"PLAY RECAP"
)
for
h
in
hosts
:
for
h
in
hosts
:
t
=
pb
.
stats
.
summarize
(
h
)
t
=
pb
.
stats
.
summarize
(
h
)
print
"
%-30
s : ok=
%4
s changed=
%4
s unreachable=
%4
s failed=
%4
s "
%
(
h
,
print
"
%-30
s : ok=
%4
s changed=
%4
s unreachable=
%4
s failed=
%4
s "
%
(
h
,
...
...
lib/ansible/callbacks.py
View file @
80852f86
...
@@ -20,6 +20,8 @@
...
@@ -20,6 +20,8 @@
import
utils
import
utils
import
sys
import
sys
import
getpass
import
getpass
import
os
import
subprocess
#######################################################
#######################################################
...
@@ -74,6 +76,18 @@ class AggregateStats(object):
...
@@ -74,6 +76,18 @@ class AggregateStats(object):
########################################################################
########################################################################
def
banner
(
msg
):
res
=
""
if
os
.
path
.
exists
(
"/usr/bin/cowsay"
):
cmd
=
subprocess
.
Popen
(
"/usr/bin/cowsay -W 60
\"
%
s
\"
"
%
msg
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
,
shell
=
True
)
(
out
,
err
)
=
cmd
.
communicate
()
res
=
"
%
s
\n
"
%
out
else
:
res
=
"
%
s *********************
\n
"
%
msg
return
res
class
DefaultRunnerCallbacks
(
object
):
class
DefaultRunnerCallbacks
(
object
):
''' no-op callbacks for API usage of Runner() if no callbacks are specified '''
''' no-op callbacks for API usage of Runner() if no callbacks are specified '''
...
@@ -226,7 +240,7 @@ class PlaybookCallbacks(object):
...
@@ -226,7 +240,7 @@ class PlaybookCallbacks(object):
pass
pass
def
on_task_start
(
self
,
name
,
is_conditional
):
def
on_task_start
(
self
,
name
,
is_conditional
):
print
utils
.
task_start_msg
(
name
,
is_conditional
)
print
banner
(
utils
.
task_start_msg
(
name
,
is_conditional
)
)
def
on_vars_prompt
(
self
,
varname
,
private
=
True
):
def
on_vars_prompt
(
self
,
varname
,
private
=
True
):
msg
=
'input for
%
s: '
%
varname
msg
=
'input for
%
s: '
%
varname
...
@@ -235,10 +249,10 @@ class PlaybookCallbacks(object):
...
@@ -235,10 +249,10 @@ class PlaybookCallbacks(object):
return
raw_input
(
msg
)
return
raw_input
(
msg
)
def
on_setup_primary
(
self
):
def
on_setup_primary
(
self
):
print
"SETUP PHASE ****************************
\n
"
print
banner
(
"SETUP PHASE"
)
def
on_setup_secondary
(
self
):
def
on_setup_secondary
(
self
):
print
"
\n
VARIABLE IMPORT PHASE ******************
\n
"
print
banner
(
"VARIABLE IMPORT PHASE"
)
def
on_import_for_host
(
self
,
host
,
imported_file
):
def
on_import_for_host
(
self
,
host
,
imported_file
):
print
"
%
s: importing
%
s"
%
(
host
,
imported_file
)
print
"
%
s: importing
%
s"
%
(
host
,
imported_file
)
...
@@ -247,4 +261,4 @@ class PlaybookCallbacks(object):
...
@@ -247,4 +261,4 @@ class PlaybookCallbacks(object):
print
"
%
s: not importing file:
%
s"
%
(
host
,
missing_file
)
print
"
%
s: not importing file:
%
s"
%
(
host
,
missing_file
)
def
on_play_start
(
self
,
pattern
):
def
on_play_start
(
self
,
pattern
):
print
"PLAY [
%
s] ****************************
\n
"
%
pattern
print
banner
(
"PLAY [
%
s]"
%
pattern
)
lib/ansible/utils.py
View file @
80852f86
...
@@ -65,9 +65,9 @@ def smjson(result):
...
@@ -65,9 +65,9 @@ def smjson(result):
def
task_start_msg
(
name
,
conditional
):
def
task_start_msg
(
name
,
conditional
):
if
conditional
:
if
conditional
:
return
"
\n
NOTIFIED: [
%
s] **********
\n
"
%
name
return
"
NOTIFIED: [
%
s]
"
%
name
else
:
else
:
return
"
\n
TASK: [
%
s] *********
\n
"
%
name
return
"
TASK: [
%
s]
"
%
name
def
regular_generic_msg
(
hostname
,
result
,
oneline
,
caption
):
def
regular_generic_msg
(
hostname
,
result
,
oneline
,
caption
):
''' output on the result of a module run that is not command '''
''' output on the result of a module run that is not command '''
...
...
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