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
a811c884
Commit
a811c884
authored
Apr 03, 2015
by
Brian Coca
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
now listhosts shows the same info as v1
parent
41d9bfde
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
7 deletions
+17
-7
v2/ansible/executor/playbook_executor.py
+14
-2
v2/bin/ansible-playbook
+3
-5
No files found.
v2/ansible/executor/playbook_executor.py
View file @
a811c884
...
@@ -162,10 +162,11 @@ class PlaybookExecutor:
...
@@ -162,10 +162,11 @@ class PlaybookExecutor:
return
serialized_batches
return
serialized_batches
def
list
hosts
(
self
):
def
list
_hosts_per_play
(
self
):
playlist
=
[]
playlist
=
[]
try
:
try
:
i
=
1
for
playbook_path
in
self
.
_playbooks
:
for
playbook_path
in
self
.
_playbooks
:
pb
=
Playbook
.
load
(
playbook_path
,
variable_manager
=
self
.
_variable_manager
,
loader
=
self
.
_loader
)
pb
=
Playbook
.
load
(
playbook_path
,
variable_manager
=
self
.
_variable_manager
,
loader
=
self
.
_loader
)
for
play
in
pb
.
get_entries
():
for
play
in
pb
.
get_entries
():
...
@@ -175,10 +176,21 @@ class PlaybookExecutor:
...
@@ -175,10 +176,21 @@ class PlaybookExecutor:
new_play
=
play
.
copy
()
new_play
=
play
.
copy
()
new_play
.
post_validate
(
all_vars
,
fail_on_undefined
=
False
)
new_play
.
post_validate
(
all_vars
,
fail_on_undefined
=
False
)
playlist
.
append
(
set
(
self
.
_inventory
.
get_hosts
(
new_play
.
hosts
)))
pname
=
play
.
get_name
()
.
strip
()
if
pname
==
'PLAY: <no name specified>'
:
pname
=
'play #
%
d'
%
i
playlist
.
append
(
{
'name'
:
pname
,
'pattern'
:
play
.
hosts
,
'hosts'
:
set
(
self
.
_inventory
.
get_hosts
(
new_play
.
hosts
)),
}
)
i
=
i
+
1
except
AnsibleError
:
except
AnsibleError
:
raise
raise
except
Exception
,
e
:
except
Exception
,
e
:
#TODO: log exception
raise
AnsibleParserError
(
"Failed to process plays:
%
s"
%
str
(
e
))
raise
AnsibleParserError
(
"Failed to process plays:
%
s"
%
str
(
e
))
return
playlist
return
playlist
v2/bin/ansible-playbook
View file @
a811c884
...
@@ -135,12 +135,10 @@ def main(args):
...
@@ -135,12 +135,10 @@ def main(args):
pbex
=
PlaybookExecutor
(
playbooks
=
args
,
inventory
=
inventory
,
variable_manager
=
variable_manager
,
loader
=
loader
,
display
=
display
,
options
=
options
)
pbex
=
PlaybookExecutor
(
playbooks
=
args
,
inventory
=
inventory
,
variable_manager
=
variable_manager
,
loader
=
loader
,
display
=
display
,
options
=
options
)
if
options
.
listhosts
:
if
options
.
listhosts
:
i
=
1
for
p
in
pbex
.
list_hosts_per_play
():
for
play
in
pbex
.
listhosts
():
print
(
"
\n
%
s (
%
s): host count=
%
d"
%
(
p
[
'name'
],
p
[
'pattern'
],
len
(
p
[
'hosts'
])))
print
(
"
\n
play #
%
d"
%
i
)
for
host
in
p
[
'hosts'
]:
for
host
in
sorted
(
play
):
print
(
"
%
s"
%
host
)
print
(
"
%
s"
%
host
)
i
=
i
+
1
sys
.
exit
(
0
)
sys
.
exit
(
0
)
elif
options
.
listtasks
:
elif
options
.
listtasks
:
print
(
'TODO: implement'
)
print
(
'TODO: implement'
)
...
...
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