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
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
0 deletions
+18
-0
bin/ansible-playbook
+18
-0
No files found.
bin/ansible-playbook
View file @
8e039a63
...
@@ -57,6 +57,8 @@ def main(args):
...
@@ -57,6 +57,8 @@ def main(args):
help
=
"set additional key=value variables from the CLI"
)
help
=
"set additional key=value variables from the CLI"
)
parser
.
add_option
(
'-t'
,
'--tags'
,
dest
=
'tags'
,
default
=
'all'
,
parser
.
add_option
(
'-t'
,
'--tags'
,
dest
=
'tags'
,
default
=
'all'
,
help
=
"only run plays and tasks tagged with these values"
)
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
)
options
,
args
=
parser
.
parse_args
(
args
)
...
@@ -66,6 +68,7 @@ def main(args):
...
@@ -66,6 +68,7 @@ def main(args):
sshpass
=
None
sshpass
=
None
sudopass
=
None
sudopass
=
None
if
not
options
.
listhosts
:
if
options
.
ask_pass
:
if
options
.
ask_pass
:
sshpass
=
getpass
.
getpass
(
prompt
=
"SSH password: "
)
sshpass
=
getpass
.
getpass
(
prompt
=
"SSH password: "
)
if
options
.
ask_sudo_pass
:
if
options
.
ask_sudo_pass
:
...
@@ -104,6 +107,21 @@ def main(args):
...
@@ -104,6 +107,21 @@ def main(args):
only_tags
=
only_tags
,
only_tags
=
only_tags
,
subset
=
options
.
subset
,
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
:
try
:
pb
.
run
()
pb
.
run
()
...
...
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