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
e25bb2f8
Commit
e25bb2f8
authored
Feb 24, 2012
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upgrade output for playbook runs
parent
ee2fa721
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
13 deletions
+22
-13
lib/ansible/playbook.py
+22
-13
No files found.
lib/ansible/playbook.py
View file @
e25bb2f8
...
@@ -68,6 +68,10 @@ class PlayBook(object):
...
@@ -68,6 +68,10 @@ class PlayBook(object):
for
pattern
in
self
.
playbook
:
for
pattern
in
self
.
playbook
:
self
.
_run_pattern
(
pattern
)
self
.
_run_pattern
(
pattern
)
# TODO: return a summary of success & failure counts per node
# TODO: in bin/ancible, ensure return codes are appropriate
return
"complete"
return
"complete"
def
_get_task_runner
(
self
,
def
_get_task_runner
(
self
,
...
@@ -76,8 +80,6 @@ class PlayBook(object):
...
@@ -76,8 +80,6 @@ class PlayBook(object):
module_name
=
None
,
module_name
=
None
,
module_args
=
None
):
module_args
=
None
):
print
"GET TASK RUNNER FOR HL=
%
s"
%
host_list
'''
'''
return a runner suitable for running this task, using
return a runner suitable for running this task, using
preferences from the constructor
preferences from the constructor
...
@@ -98,7 +100,7 @@ class PlayBook(object):
...
@@ -98,7 +100,7 @@ class PlayBook(object):
timeout
=
self
.
timeout
timeout
=
self
.
timeout
)
)
def
_run_task
(
self
,
pattern
,
task
,
host_list
=
None
):
def
_run_task
(
self
,
pattern
,
task
,
host_list
=
None
,
conditional
=
False
):
'''
'''
run a single task in the playbook and
run a single task in the playbook and
recursively run any subtasks.
recursively run any subtasks.
...
@@ -107,10 +109,14 @@ class PlayBook(object):
...
@@ -107,10 +109,14 @@ class PlayBook(object):
if
host_list
is
None
:
if
host_list
is
None
:
host_list
=
self
.
host_list
host_list
=
self
.
host_list
print
"TASK=
%
s"
%
task
instructions
=
task
[
'do'
]
instructions
=
task
[
'do'
]
(
comment
,
module_name
,
module_args
)
=
instructions
(
comment
,
module_name
,
module_args
)
=
instructions
print
"running task: (
%
s) on hosts matching (
%
s)"
%
(
comment
,
pattern
)
namestr
=
"
%
s/
%
s"
%
(
pattern
,
comment
)
if
conditional
:
namestr
=
"subset/
%
s"
%
namestr
print
"TASK [
%
s]"
%
namestr
runner
=
self
.
_get_task_runner
(
runner
=
self
.
_get_task_runner
(
pattern
=
pattern
,
pattern
=
pattern
,
host_list
=
host_list
,
host_list
=
host_list
,
...
@@ -118,9 +124,9 @@ class PlayBook(object):
...
@@ -118,9 +124,9 @@ class PlayBook(object):
module_args
=
module_args
module_args
=
module_args
)
)
results
=
runner
.
run
()
results
=
runner
.
run
()
print
"RESULTS=
%
s"
%
results
dark
=
results
.
get
(
"dark"
,
[])
dark
=
results
.
get
(
"dark"
,
[])
contacted
=
results
.
get
(
"contacted"
,
[])
contacted
=
results
.
get
(
"contacted"
,
[])
# TODO: filter based on values that indicate
# TODO: filter based on values that indicate
...
@@ -132,14 +138,20 @@ class PlayBook(object):
...
@@ -132,14 +138,20 @@ class PlayBook(object):
ok_hosts
=
contacted
.
keys
()
ok_hosts
=
contacted
.
keys
()
for
host
,
msg
in
dark
.
items
():
for
host
,
msg
in
dark
.
items
():
print
"contacting
%
s failed --
%
s"
%
(
host
,
msg
)
print
"DARK: [
%
s] =>
%
s"
%
(
host
,
msg
)
for
host
,
results
in
contacted
.
items
():
if
module_name
==
"command"
:
if
results
.
get
(
"rc"
,
0
)
!=
0
:
print
"FAIL: [
%
s/
%
s] =>
%
s"
%
(
host
,
comment
,
results
)
elif
results
.
get
(
"failed"
,
0
)
==
1
:
print
"FAIL: [
%
s/
%
s]"
%
(
host
,
comment
,
results
)
subtasks
=
task
.
get
(
'onchange'
,
[])
subtasks
=
task
.
get
(
'onchange'
,
[])
if
len
(
subtasks
)
>
0
:
if
len
(
subtasks
)
>
0
:
print
"the following hosts have registered change events"
print
ok_hosts
for
subtask
in
subtasks
:
for
subtask
in
subtasks
:
self
.
_run_task
(
pattern
,
subtask
,
ok_hosts
)
self
.
_run_task
(
pattern
,
subtask
,
ok_hosts
,
conditional
=
True
)
# TODO: if a host fails in task 1, add it to an excludes
# TODO: if a host fails in task 1, add it to an excludes
# list such that no other tasks in the list ever execute
# list such that no other tasks in the list ever execute
...
@@ -154,10 +166,7 @@ class PlayBook(object):
...
@@ -154,10 +166,7 @@ class PlayBook(object):
pattern
=
pg
[
'pattern'
]
pattern
=
pg
[
'pattern'
]
tasks
=
pg
[
'tasks'
]
tasks
=
pg
[
'tasks'
]
print
"PATTERN=
%
s"
%
pattern
print
"TASKS=
%
s"
%
tasks
for
task
in
tasks
:
for
task
in
tasks
:
print
"*** RUNNING A TASK (
%
s)***"
%
task
self
.
_run_task
(
pattern
,
task
)
self
.
_run_task
(
pattern
,
task
)
...
...
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