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
8e039a63
Commit
8e039a63
authored
Aug 15, 2012
by
Seth Vidal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add --list-hosts option to ansible-playbook to dump out the hosts
being run against for each playbook
parent
ffabded2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
14 deletions
+32
-14
bin/ansible-playbook
+32
-14
No files found.
bin/ansible-playbook
View file @
8e039a63
...
...
@@ -57,6 +57,8 @@ def main(args):
help
=
"set additional key=value variables from the CLI"
)
parser
.
add_option
(
'-t'
,
'--tags'
,
dest
=
'tags'
,
default
=
'all'
,
help
=
"only run plays and tasks tagged with these values"
)
parser
.
add_option
(
'--list-hosts'
,
dest
=
'listhosts'
,
action
=
'store_true'
,
help
=
"dump out a list of hosts, each play will run against, does not run playbook!"
)
options
,
args
=
parser
.
parse_args
(
args
)
...
...
@@ -66,14 +68,15 @@ def main(args):
sshpass
=
None
sudopass
=
None
if
options
.
ask_pass
:
sshpass
=
getpass
.
getpass
(
prompt
=
"SSH password: "
)
if
options
.
ask_sudo_pass
:
sudopass
=
getpass
.
getpass
(
prompt
=
"sudo password: "
)
options
.
sudo
=
True
if
options
.
sudo_user
:
options
.
sudo
=
True
options
.
sudo_user
=
options
.
sudo_user
or
C
.
DEFAULT_SUDO_USER
if
not
options
.
listhosts
:
if
options
.
ask_pass
:
sshpass
=
getpass
.
getpass
(
prompt
=
"SSH password: "
)
if
options
.
ask_sudo_pass
:
sudopass
=
getpass
.
getpass
(
prompt
=
"sudo password: "
)
options
.
sudo
=
True
if
options
.
sudo_user
:
options
.
sudo
=
True
options
.
sudo_user
=
options
.
sudo_user
or
C
.
DEFAULT_SUDO_USER
extra_vars
=
utils
.
parse_kv
(
options
.
extra_vars
)
only_tags
=
options
.
tags
.
split
(
","
)
...
...
@@ -104,6 +107,21 @@ def main(args):
only_tags
=
only_tags
,
subset
=
options
.
subset
,
)
if
options
.
listhosts
:
playnum
=
0
for
play
in
pb
.
playbook
:
playnum
+=
1
if
'hosts'
in
play
:
label
=
'unnamed'
if
'name'
in
play
:
label
=
play
[
'name'
]
print
'hosts in play
%
s:
%
s'
%
(
playnum
,
label
)
for
host
in
pb
.
inventory
.
list_hosts
(
play
[
'hosts'
]):
print
'
%
s'
%
host
print
'
\n
'
return
0
try
:
pb
.
run
()
...
...
@@ -111,12 +129,12 @@ def main(args):
print
callbacks
.
banner
(
"PLAY RECAP"
)
for
h
in
hosts
:
t
=
pb
.
stats
.
summarize
(
h
)
print
"
%-30
s :
%
s
%
s
%
s
%
s "
%
(
hostcolor
(
h
,
t
),
colorize
(
'ok'
,
t
[
'ok'
],
'green'
),
colorize
(
'changed'
,
t
[
'changed'
],
'yellow'
),
colorize
(
'unreachable'
,
t
[
'unreachable'
],
'red'
),
colorize
(
'failed'
,
t
[
'failures'
],
'red'
))
print
"
%-30
s :
%
s
%
s
%
s
%
s "
%
(
hostcolor
(
h
,
t
),
colorize
(
'ok'
,
t
[
'ok'
],
'green'
),
colorize
(
'changed'
,
t
[
'changed'
],
'yellow'
),
colorize
(
'unreachable'
,
t
[
'unreachable'
],
'red'
),
colorize
(
'failed'
,
t
[
'failures'
],
'red'
))
print
"
\n
"
...
...
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