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
35fdf663
Commit
35fdf663
authored
Apr 16, 2012
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow --user for playbooks, no need for port setting as can specify in inventory file now.
parent
8a027415
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
18 deletions
+23
-18
bin/ansible
+3
-4
bin/ansible-playbook
+15
-6
lib/ansible/playbook.py
+4
-2
lib/ansible/utils.py
+1
-6
No files found.
bin/ansible
View file @
35fdf663
...
...
@@ -47,7 +47,7 @@ class Cli(object):
def
parse
(
self
):
''' create an options parser for bin/ansible '''
parser
=
utils
.
base_parser
(
constants
=
C
,
port_opts
=
True
,
runas_opts
=
True
,
async_opts
=
True
,
parser
=
utils
.
base_parser
(
constants
=
C
,
runas_opts
=
True
,
async_opts
=
True
,
output_opts
=
True
,
connect_opts
=
True
,
usage
=
'
%
prog <host-pattern> [options]'
)
parser
.
add_option
(
'-a'
,
'--args'
,
dest
=
'module_args'
,
help
=
"module arguments"
,
default
=
C
.
DEFAULT_MODULE_ARGS
)
...
...
@@ -87,7 +87,7 @@ class Cli(object):
module_args
=
options
.
module_args
,
remote_user
=
options
.
remote_user
,
remote_pass
=
sshpass
,
host_list
=
options
.
inventory
,
timeout
=
options
.
timeout
,
remote_port
=
options
.
remote_port
,
forks
=
options
.
forks
,
forks
=
options
.
forks
,
background
=
options
.
seconds
,
pattern
=
pattern
,
callbacks
=
self
.
callbacks
,
sudo
=
options
.
sudo
,
sudo_pass
=
sudopass
,
verbose
=
True
,
...
...
@@ -104,8 +104,7 @@ class Cli(object):
module_args
=
"jid=
%
s"
%
jid
,
remote_user
=
old_runner
.
remote_user
,
remote_pass
=
old_runner
.
remote_pass
,
inventory
=
old_runner
.
inventory
,
timeout
=
old_runner
.
timeout
,
forks
=
old_runner
.
forks
,
remote_port
=
old_runner
.
remote_port
,
pattern
=
'*'
,
callbacks
=
self
.
silent_callbacks
,
verbose
=
True
,
pattern
=
'*'
,
callbacks
=
self
.
silent_callbacks
,
verbose
=
True
,
)
# ----------------------------------------------
...
...
bin/ansible-playbook
View file @
35fdf663
...
...
@@ -33,7 +33,7 @@ def main(args):
# create parser for CLI options
usage
=
"
%
prog playbook.yml"
parser
=
utils
.
base_parser
(
constants
=
C
,
usage
=
usage
,
connect_opts
=
True
)
parser
=
utils
.
base_parser
(
constants
=
C
,
usage
=
usage
,
connect_opts
=
True
,
runas_opts
=
True
)
parser
.
add_option
(
'-e'
,
'--extra-vars'
,
dest
=
'extra_vars'
,
help
=
'arguments to pass to the inventory script'
)
parser
.
add_option
(
'-O'
,
'--override-hosts'
,
dest
=
"override_hosts"
,
default
=
None
,
...
...
@@ -63,13 +63,22 @@ def main(args):
runner_cb
=
callbacks
.
PlaybookRunnerCallbacks
(
stats
)
pb
=
ansible
.
playbook
.
PlayBook
(
playbook
=
playbook
,
module_path
=
options
.
module_path
,
host_list
=
options
.
inventory
,
override_hosts
=
override_hosts
,
playbook
=
playbook
,
module_path
=
options
.
module_path
,
host_list
=
options
.
inventory
,
override_hosts
=
override_hosts
,
extra_vars
=
options
.
extra_vars
,
forks
=
options
.
forks
,
debug
=
options
.
debug
,
verbose
=
True
,
forks
=
options
.
forks
,
debug
=
options
.
debug
,
verbose
=
True
,
remote_user
=
options
.
remote_user
,
remote_pass
=
sshpass
,
callbacks
=
playbook_cb
,
runner_callbacks
=
runner_cb
,
stats
=
stats
,
timeout
=
options
.
timeout
,
transport
=
options
.
connection
,
callbacks
=
playbook_cb
,
runner_callbacks
=
runner_cb
,
stats
=
stats
,
timeout
=
options
.
timeout
,
transport
=
options
.
connection
,
sudo
=
options
.
sudo
,
sudo_pass
=
sudopass
)
try
:
...
...
lib/ansible/playbook.py
View file @
35fdf663
...
...
@@ -64,7 +64,8 @@ class PlayBook(object):
verbose
=
False
,
callbacks
=
None
,
runner_callbacks
=
None
,
stats
=
None
):
stats
=
None
,
sudo
=
False
):
if
playbook
is
None
or
callbacks
is
None
or
runner_callbacks
is
None
or
stats
is
None
:
raise
Exception
(
'missing required arguments'
)
...
...
@@ -83,6 +84,7 @@ class PlayBook(object):
self
.
override_hosts
=
override_hosts
self
.
extra_vars
=
extra_vars
self
.
stats
=
stats
self
.
sudo
=
sudo
self
.
sudo_pass
=
sudo_pass
self
.
basedir
=
os
.
path
.
dirname
(
playbook
)
...
...
@@ -529,7 +531,7 @@ class PlayBook(object):
handlers
=
pg
.
get
(
'handlers'
,
[])
user
=
pg
.
get
(
'user'
,
self
.
remote_user
)
port
=
pg
.
get
(
'port'
,
self
.
remote_port
)
sudo
=
pg
.
get
(
'sudo'
,
False
)
sudo
=
pg
.
get
(
'sudo'
,
self
.
sudo
)
transport
=
pg
.
get
(
'connection'
,
self
.
transport
)
self
.
callbacks
.
on_play_start
(
pattern
)
...
...
lib/ansible/utils.py
View file @
35fdf663
...
...
@@ -279,7 +279,7 @@ class SortedOptParser(optparse.OptionParser):
self
.
option_list
.
sort
(
key
=
methodcaller
(
'get_opt_string'
))
return
optparse
.
OptionParser
.
format_help
(
self
,
formatter
=
None
)
def
base_parser
(
constants
=
C
,
usage
=
""
,
output_opts
=
False
,
port_opts
=
False
,
runas_opts
=
False
,
async_opts
=
False
,
connect_opts
=
False
):
def
base_parser
(
constants
=
C
,
usage
=
""
,
output_opts
=
False
,
runas_opts
=
False
,
async_opts
=
False
,
connect_opts
=
False
):
''' create an options parser for any ansible script '''
parser
=
SortedOptParser
(
usage
)
...
...
@@ -301,11 +301,6 @@ def base_parser(constants=C, usage="", output_opts=False, port_opts=False, runas
dest
=
'timeout'
,
help
=
"override the SSH timeout in seconds (default=
%
s)"
%
constants
.
DEFAULT_TIMEOUT
)
if
port_opts
:
parser
.
add_option
(
'-p'
,
'--port'
,
default
=
constants
.
DEFAULT_REMOTE_PORT
,
type
=
'int'
,
dest
=
'remote_port'
,
help
=
"override the remote ssh port (default=
%
s)"
%
constants
.
DEFAULT_REMOTE_PORT
)
if
output_opts
:
parser
.
add_option
(
'-o'
,
'--one-line'
,
dest
=
'one_line'
,
action
=
'store_true'
,
help
=
'condense output'
)
...
...
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