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
dcb9b5a6
Commit
dcb9b5a6
authored
Jul 01, 2015
by
James Cammarata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make --module-path work and expand tilde's in paths
Fixes #9937 Fixes #9949
parent
fffb65d4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
4 deletions
+16
-4
lib/ansible/cli/__init__.py
+9
-4
lib/ansible/executor/playbook_executor.py
+7
-0
No files found.
lib/ansible/cli/__init__.py
View file @
dcb9b5a6
...
...
@@ -206,6 +206,10 @@ class CLI(object):
" are exclusive of each other"
)
@staticmethod
def
expand_tilde
(
option
,
opt
,
value
,
parser
):
setattr
(
parser
.
values
,
option
.
dest
,
os
.
path
.
expanduser
(
value
))
@staticmethod
def
base_parser
(
usage
=
""
,
output_opts
=
False
,
runas_opts
=
False
,
meta_opts
=
False
,
runtask_opts
=
False
,
vault_opts
=
False
,
async_opts
=
False
,
connect_opts
=
False
,
subset_opts
=
False
,
check_opts
=
False
,
diff_opts
=
False
,
epilog
=
None
,
fork_opts
=
False
):
''' create an options parser for most ansible scripts '''
...
...
@@ -221,11 +225,12 @@ class CLI(object):
if
runtask_opts
:
parser
.
add_option
(
'-i'
,
'--inventory-file'
,
dest
=
'inventory'
,
help
=
"specify inventory host file (default=
%
s)"
%
C
.
DEFAULT_HOST_LIST
,
default
=
C
.
DEFAULT_HOST_LIST
)
default
=
C
.
DEFAULT_HOST_LIST
,
action
=
"callback"
,
callback
=
CLI
.
expand_tilde
,
type
=
str
)
parser
.
add_option
(
'--list-hosts'
,
dest
=
'listhosts'
,
action
=
'store_true'
,
help
=
'outputs a list of matching hosts; does not execute anything else'
)
parser
.
add_option
(
'-M'
,
'--module-path'
,
dest
=
'module_path'
,
help
=
"specify path(s) to module library (default=
%
s)"
%
C
.
DEFAULT_MODULE_PATH
,
default
=
None
)
help
=
"specify path(s) to module library (default=
%
s)"
%
C
.
DEFAULT_MODULE_PATH
,
default
=
None
,
action
=
"callback"
,
callback
=
CLI
.
expand_tilde
,
type
=
str
)
parser
.
add_option
(
'-e'
,
'--extra-vars'
,
dest
=
"extra_vars"
,
action
=
"append"
,
help
=
"set additional variables as key=value or YAML/JSON"
,
default
=
[])
...
...
@@ -239,8 +244,8 @@ class CLI(object):
parser
.
add_option
(
'--ask-vault-pass'
,
default
=
False
,
dest
=
'ask_vault_pass'
,
action
=
'store_true'
,
help
=
'ask for vault password'
)
parser
.
add_option
(
'--vault-password-file'
,
default
=
C
.
DEFAULT_VAULT_PASSWORD_FILE
,
dest
=
'vault_password_file'
,
help
=
"vault password file"
)
dest
=
'vault_password_file'
,
help
=
"vault password file"
,
action
=
"callback"
,
callback
=
CLI
.
expand_tilde
,
type
=
str
)
if
subset_opts
:
parser
.
add_option
(
'-t'
,
'--tags'
,
dest
=
'tags'
,
default
=
'all'
,
...
...
lib/ansible/executor/playbook_executor.py
View file @
dcb9b5a6
...
...
@@ -25,6 +25,7 @@ from ansible import constants as C
from
ansible.errors
import
*
from
ansible.executor.task_queue_manager
import
TaskQueueManager
from
ansible.playbook
import
Playbook
from
ansible.plugins
import
module_loader
from
ansible.template
import
Templar
from
ansible.utils.color
import
colorize
,
hostcolor
...
...
@@ -46,6 +47,12 @@ class PlaybookExecutor:
self
.
_options
=
options
self
.
passwords
=
passwords
# make sure the module path (if specified) is parsed and
# added to the module_loader object
if
options
.
module_path
is
not
None
:
for
path
in
options
.
module_path
.
split
(
os
.
pathsep
):
module_loader
.
add_directory
(
path
)
if
options
.
listhosts
or
options
.
listtasks
or
options
.
listtags
or
options
.
syntax
:
self
.
_tqm
=
None
else
:
...
...
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