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
98e7eaf0
Commit
98e7eaf0
authored
Jun 30, 2013
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3316 from dsedivec/devel
expanduser on each component of plug-in paths
parents
e4e3c239
b32131c8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
7 deletions
+56
-7
lib/ansible/constants.py
+7
-7
lib/ansible/utils/plugins.py
+2
-0
test/TestUtils.py
+47
-0
No files found.
lib/ansible/constants.py
View file @
98e7eaf0
...
@@ -71,7 +71,7 @@ DEFAULTS='defaults'
...
@@ -71,7 +71,7 @@ DEFAULTS='defaults'
# configurable things
# configurable things
DEFAULT_HOST_LIST
=
shell_expand_path
(
get_config
(
p
,
DEFAULTS
,
'hostfile'
,
'ANSIBLE_HOSTS'
,
'/etc/ansible/hosts'
))
DEFAULT_HOST_LIST
=
shell_expand_path
(
get_config
(
p
,
DEFAULTS
,
'hostfile'
,
'ANSIBLE_HOSTS'
,
'/etc/ansible/hosts'
))
DEFAULT_MODULE_PATH
=
shell_expand_path
(
get_config
(
p
,
DEFAULTS
,
'library'
,
'ANSIBLE_LIBRARY'
,
DIST_MODULE_PATH
)
)
DEFAULT_MODULE_PATH
=
get_config
(
p
,
DEFAULTS
,
'library'
,
'ANSIBLE_LIBRARY'
,
DIST_MODULE_PATH
)
DEFAULT_REMOTE_TMP
=
shell_expand_path
(
get_config
(
p
,
DEFAULTS
,
'remote_tmp'
,
'ANSIBLE_REMOTE_TEMP'
,
'$HOME/.ansible/tmp'
))
DEFAULT_REMOTE_TMP
=
shell_expand_path
(
get_config
(
p
,
DEFAULTS
,
'remote_tmp'
,
'ANSIBLE_REMOTE_TEMP'
,
'$HOME/.ansible/tmp'
))
DEFAULT_MODULE_NAME
=
get_config
(
p
,
DEFAULTS
,
'module_name'
,
None
,
'command'
)
DEFAULT_MODULE_NAME
=
get_config
(
p
,
DEFAULTS
,
'module_name'
,
None
,
'command'
)
DEFAULT_PATTERN
=
get_config
(
p
,
DEFAULTS
,
'pattern'
,
None
,
'*'
)
DEFAULT_PATTERN
=
get_config
(
p
,
DEFAULTS
,
'pattern'
,
None
,
'*'
)
...
@@ -98,12 +98,12 @@ DEFAULT_LEGACY_PLAYBOOK_VARIABLES = get_config(p, DEFAULTS, 'legacy_playbook_var
...
@@ -98,12 +98,12 @@ DEFAULT_LEGACY_PLAYBOOK_VARIABLES = get_config(p, DEFAULTS, 'legacy_playbook_var
DEFAULT_JINJA2_EXTENSIONS
=
get_config
(
p
,
DEFAULTS
,
'jinja2_extensions'
,
'ANSIBLE_JINJA2_EXTENSIONS'
,
None
)
DEFAULT_JINJA2_EXTENSIONS
=
get_config
(
p
,
DEFAULTS
,
'jinja2_extensions'
,
'ANSIBLE_JINJA2_EXTENSIONS'
,
None
)
DEFAULT_EXECUTABLE
=
get_config
(
p
,
DEFAULTS
,
'executable'
,
'ANSIBLE_EXECUTABLE'
,
'/bin/sh'
)
DEFAULT_EXECUTABLE
=
get_config
(
p
,
DEFAULTS
,
'executable'
,
'ANSIBLE_EXECUTABLE'
,
'/bin/sh'
)
DEFAULT_ACTION_PLUGIN_PATH
=
shell_expand_path
(
get_config
(
p
,
DEFAULTS
,
'action_plugins'
,
'ANSIBLE_ACTION_PLUGINS'
,
'/usr/share/ansible_plugins/action_plugins'
)
)
DEFAULT_ACTION_PLUGIN_PATH
=
get_config
(
p
,
DEFAULTS
,
'action_plugins'
,
'ANSIBLE_ACTION_PLUGINS'
,
'/usr/share/ansible_plugins/action_plugins'
)
DEFAULT_CALLBACK_PLUGIN_PATH
=
shell_expand_path
(
get_config
(
p
,
DEFAULTS
,
'callback_plugins'
,
'ANSIBLE_CALLBACK_PLUGINS'
,
'/usr/share/ansible_plugins/callback_plugins'
)
)
DEFAULT_CALLBACK_PLUGIN_PATH
=
get_config
(
p
,
DEFAULTS
,
'callback_plugins'
,
'ANSIBLE_CALLBACK_PLUGINS'
,
'/usr/share/ansible_plugins/callback_plugins'
)
DEFAULT_CONNECTION_PLUGIN_PATH
=
shell_expand_path
(
get_config
(
p
,
DEFAULTS
,
'connection_plugins'
,
'ANSIBLE_CONNECTION_PLUGINS'
,
'/usr/share/ansible_plugins/connection_plugins'
)
)
DEFAULT_CONNECTION_PLUGIN_PATH
=
get_config
(
p
,
DEFAULTS
,
'connection_plugins'
,
'ANSIBLE_CONNECTION_PLUGINS'
,
'/usr/share/ansible_plugins/connection_plugins'
)
DEFAULT_LOOKUP_PLUGIN_PATH
=
shell_expand_path
(
get_config
(
p
,
DEFAULTS
,
'lookup_plugins'
,
'ANSIBLE_LOOKUP_PLUGINS'
,
'/usr/share/ansible_plugins/lookup_plugins'
)
)
DEFAULT_LOOKUP_PLUGIN_PATH
=
get_config
(
p
,
DEFAULTS
,
'lookup_plugins'
,
'ANSIBLE_LOOKUP_PLUGINS'
,
'/usr/share/ansible_plugins/lookup_plugins'
)
DEFAULT_VARS_PLUGIN_PATH
=
shell_expand_path
(
get_config
(
p
,
DEFAULTS
,
'vars_plugins'
,
'ANSIBLE_VARS_PLUGINS'
,
'/usr/share/ansible_plugins/vars_plugins'
)
)
DEFAULT_VARS_PLUGIN_PATH
=
get_config
(
p
,
DEFAULTS
,
'vars_plugins'
,
'ANSIBLE_VARS_PLUGINS'
,
'/usr/share/ansible_plugins/vars_plugins'
)
DEFAULT_FILTER_PLUGIN_PATH
=
shell_expand_path
(
get_config
(
p
,
DEFAULTS
,
'filter_plugins'
,
'ANSIBLE_FILTER_PLUGINS'
,
'/usr/share/ansible_plugins/filter_plugins'
)
)
DEFAULT_FILTER_PLUGIN_PATH
=
get_config
(
p
,
DEFAULTS
,
'filter_plugins'
,
'ANSIBLE_FILTER_PLUGINS'
,
'/usr/share/ansible_plugins/filter_plugins'
)
DEFAULT_LOG_PATH
=
shell_expand_path
(
get_config
(
p
,
DEFAULTS
,
'log_path'
,
'ANSIBLE_LOG_PATH'
,
''
))
DEFAULT_LOG_PATH
=
shell_expand_path
(
get_config
(
p
,
DEFAULTS
,
'log_path'
,
'ANSIBLE_LOG_PATH'
,
''
))
ANSIBLE_NOCOWS
=
get_config
(
p
,
DEFAULTS
,
'nocows'
,
'ANSIBLE_NOCOWS'
,
None
)
ANSIBLE_NOCOWS
=
get_config
(
p
,
DEFAULTS
,
'nocows'
,
'ANSIBLE_NOCOWS'
,
None
)
...
...
lib/ansible/utils/plugins.py
View file @
98e7eaf0
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
import
os
import
os
import
os.path
import
sys
import
sys
import
glob
import
glob
import
imp
import
imp
...
@@ -108,6 +109,7 @@ class PluginLoader(object):
...
@@ -108,6 +109,7 @@ class PluginLoader(object):
# look in any configured plugin paths, allow one level deep for subcategories
# look in any configured plugin paths, allow one level deep for subcategories
configured_paths
=
self
.
config
.
split
(
os
.
pathsep
)
configured_paths
=
self
.
config
.
split
(
os
.
pathsep
)
for
path
in
configured_paths
:
for
path
in
configured_paths
:
path
=
os
.
path
.
expanduser
(
path
)
contents
=
glob
.
glob
(
"
%
s/*"
%
path
)
contents
=
glob
.
glob
(
"
%
s/*"
%
path
)
for
c
in
contents
:
for
c
in
contents
:
if
os
.
path
.
isdir
(
c
):
if
os
.
path
.
isdir
(
c
):
...
...
test/TestUtils.py
View file @
98e7eaf0
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
import
unittest
import
unittest
import
os
import
os.path
import
tempfile
from
nose.plugins.skip
import
SkipTest
import
ansible.utils
import
ansible.utils
import
ansible.utils.template
as
template2
import
ansible.utils.template
as
template2
...
@@ -376,3 +381,45 @@ class TestUtils(unittest.TestCase):
...
@@ -376,3 +381,45 @@ class TestUtils(unittest.TestCase):
def
test_parse_kv_basic
(
self
):
def
test_parse_kv_basic
(
self
):
assert
(
ansible
.
utils
.
parse_kv
(
'a=simple b="with space" c="this=that"'
)
==
assert
(
ansible
.
utils
.
parse_kv
(
'a=simple b="with space" c="this=that"'
)
==
{
'a'
:
'simple'
,
'b'
:
'with space'
,
'c'
:
'this=that'
})
{
'a'
:
'simple'
,
'b'
:
'with space'
,
'c'
:
'this=that'
})
#####################################
### plugins
def
test_loaders_expanduser_each_dir
(
self
):
# Test that PluginLoader will call expanduser on each path
# when it splits its "config" argument.
home_dir
=
os
.
path
.
expanduser
(
"~"
)
if
home_dir
==
"~"
:
raise
SkipTest
(
"your platform doesn't expand ~ in paths"
)
elif
not
os
.
path
.
isdir
(
home_dir
):
raise
SkipTest
(
"~ expands to non-directory
%
r"
%
(
home_dir
,))
elif
not
os
.
path
.
isabs
(
home_dir
):
raise
SkipTest
(
"~ expands to non-absolute path
%
r"
%
(
home_dir
,))
# Unfortunately we have to create temporary directories in
# your home directory; the directories have to exist for
# PluginLoader to accept them.
abs_dirs
,
tilde_dirs
=
[],
[]
try
:
for
_
in
range
(
2
):
temp_dir
=
tempfile
.
mkdtemp
(
prefix
=
"ansible"
,
dir
=
home_dir
)
abs_dirs
.
append
(
temp_dir
)
# Convert mkdtemp's absolute path to one starting with "~".
tilde_dir
=
os
.
path
.
join
(
"~"
,
os
.
path
.
relpath
(
temp_dir
,
home_dir
))
tilde_dirs
.
append
(
tilde_dir
)
loader
=
ansible
.
utils
.
plugins
.
PluginLoader
(
""
,
""
,
os
.
pathsep
.
join
(
tilde_dirs
),
"something_under_basedir"
)
loader_paths
=
loader
.
print_paths
()
.
split
(
os
.
pathsep
)
for
abs_dir
in
abs_dirs
:
assert
abs_dir
in
loader_paths
,
\
"
%
r not in
%
r"
%
(
abs_dir
,
loader_paths
)
finally
:
for
a_dir
in
abs_dirs
:
try
:
os
.
rmdir
(
a_dir
)
except
os
.
error
:
pass
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