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
ad97c618
Commit
ad97c618
authored
Jun 04, 2014
by
James Cammarata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for relative paths in the file lookup plugin for roles
Fixes #7628
parent
b3bbca03
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
6 deletions
+20
-6
lib/ansible/runner/lookup_plugins/file.py
+20
-6
No files found.
lib/ansible/runner/lookup_plugins/file.py
View file @
ad97c618
...
@@ -35,11 +35,25 @@ class LookupModule(object):
...
@@ -35,11 +35,25 @@ class LookupModule(object):
terms
=
[
terms
]
terms
=
[
terms
]
for
term
in
terms
:
for
term
in
terms
:
path
=
utils
.
path_dwim
(
self
.
basedir
,
term
)
basedir_path
=
utils
.
path_dwim
(
self
.
basedir
,
term
)
if
not
os
.
path
.
exists
(
path
):
relative_path
=
None
raise
errors
.
AnsibleError
(
"
%
s does not exist"
%
path
)
playbook_path
=
None
ret
.
append
(
codecs
.
open
(
path
,
encoding
=
"utf8"
)
.
read
()
.
rstrip
())
# Special handling of the file lookup, used primarily when the
# lookup is done from a role. If the file isn't found in the
# basedir of the current file, use dwim_relative to look in the
# role/files/ directory, and finally the playbook directory
# itself (which will be relative to the current working dir)
if
'_original_file'
in
inject
:
relative_path
=
utils
.
path_dwim_relative
(
inject
[
'_original_file'
],
'files'
,
term
,
self
.
basedir
,
check
=
False
)
if
'playbook_dir'
in
inject
:
playbook_path
=
os
.
path
.
join
(
inject
[
'playbook_dir'
],
term
)
for
path
in
(
basedir_path
,
relative_path
,
playbook_path
):
if
path
and
os
.
path
.
exists
(
path
):
ret
.
append
(
codecs
.
open
(
path
,
encoding
=
"utf8"
)
.
read
()
.
rstrip
())
break
else
:
raise
errors
.
AnsibleError
(
"could not locate file in lookup:
%
s"
%
term
)
return
ret
return
ret
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