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
cbfabcd0
Commit
cbfabcd0
authored
Mar 02, 2012
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add -i, -k, and -M to ansible-playbook CLI to match options in /usr/bin/ansible
parent
e4304a0a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
8 deletions
+20
-8
bin/ansible-playbook
+16
-4
lib/ansible/playbook.py
+1
-2
lib/ansible/runner.py
+3
-2
No files found.
bin/ansible-playbook
View file @
cbfabcd0
...
...
@@ -21,6 +21,7 @@
import
sys
import
ansible.playbook
import
ansible.constants
as
C
import
getpass
from
optparse
import
OptionParser
#######################################################
...
...
@@ -33,21 +34,32 @@ def main(args):
parser
.
usage
=
"ans-playbook playbook.yml ..."
parser
.
add_option
(
'-f'
,
'--forks'
,
dest
=
'forks'
,
default
=
C
.
DEFAULT_FORKS
,
type
=
'int'
,
help
=
'set the number of forks to start up'
)
parser
.
add_option
(
"-m"
,
"--module-path"
,
dest
=
"module_path"
,
parser
.
add_option
(
"-i"
,
"--inventory-file"
,
dest
=
"inventory"
,
help
=
"inventory host file"
,
default
=
C
.
DEFAULT_HOST_LIST
)
parser
.
add_option
(
"-k"
,
"--ask-pass"
,
default
=
False
,
action
=
"store_true"
,
help
=
"ask for SSH password"
)
parser
.
add_option
(
"-M"
,
"--module-path"
,
dest
=
"module_path"
,
help
=
"path to module library"
,
default
=
C
.
DEFAULT_MODULE_PATH
)
options
,
args
=
parser
.
parse_args
(
args
)
if
len
(
args
)
==
0
:
print
>>
sys
.
stderr
,
"playbook path is a required argument"
return
1
print
>>
sys
.
stderr
,
"playbook path is a required argument"
return
1
sshpass
=
None
if
options
.
ask_pass
:
sshpass
=
getpass
.
getpass
(
prompt
=
"SSH password: "
)
# run all playbooks specified on the command line
for
playbook
in
args
:
pb
=
ansible
.
playbook
.
PlayBook
(
playbook
=
playbook
,
host_list
=
options
.
inventory
,
module_path
=
options
.
module_path
,
forks
=
options
.
forks
,
verbose
=
True
verbose
=
True
,
remote_pass
=
sshpass
,
)
pb
.
run
()
...
...
lib/ansible/playbook.py
View file @
cbfabcd0
...
...
@@ -242,8 +242,7 @@ class PlayBook(object):
handlers
=
pg
[
'handlers'
]
user
=
pg
.
get
(
'user'
,
C
.
DEFAULT_REMOTE_USER
)
host_file
=
pg
.
get
(
'inventory'
,
'/etc/ansible/hosts'
)
self
.
host_list
,
groups
=
ansible
.
runner
.
Runner
.
parse_hosts
(
host_file
)
self
.
host_list
,
groups
=
ansible
.
runner
.
Runner
.
parse_hosts
(
self
.
host_list
)
if
self
.
verbose
:
print
"PLAY [
%
s] ****************************
\n
"
%
pattern
...
...
lib/ansible/runner.py
View file @
cbfabcd0
...
...
@@ -272,10 +272,11 @@ class Runner(object):
# module, call the appropriate executor function
ok
,
conn
=
self
.
_connect
(
host
)
if
not
ok
:
return
[
host
,
False
,
conn
]
tmp
=
self
.
_get_tmp_path
(
conn
)
result
=
None
if
not
ok
:
result
=
[
host
,
False
,
conn
]
if
self
.
module_name
not
in
[
'copy'
,
'template'
]:
result
=
self
.
_execute_normal_module
(
conn
,
host
,
tmp
)
elif
self
.
module_name
==
'copy'
:
...
...
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