-
Notifications
You must be signed in to change notification settings - Fork 23.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #14454 with_first_found fails with ansible 2 #15543
Conversation
8ffbc78
to
f7c75df
Compare
7f97379
to
fd7cd7a
Compare
Updated summary, I hope it makes some sense now. |
fd7cd7a
to
17af97c
Compare
- If `pathlist` is set during the first iteration of `terms`, it will be reset to an empty list during the following iterations. - Appending the file path to `total_search` results in an infinite loop while iterating `filelist`, since we're really appending to `filelist`. So we should copy `filelist` using `list()` here.
The roledir variable isn't defined when using `delegate_to` but it looks like role_path is available, so use this one instead.
17af97c
to
5c86c19
Compare
@twouters This PR was tested by travis-ci.org, which is no longer used. Please rebase your branch to trigger running of current tests. |
any chances to get this merged? |
Thanks for the submission. 9abeecb appears to have fixed the delegate_to bug you found. I think the
Feel free to stop by IRC or the mailing list if you have questions.
|
ISSUE TYPE
ANSIBLE VERSION
SUMMARY
Two issues popped up while using
with_first_found
in combination withdelegate_to
.The following works fine without
delegate_to
if filefindme
exists in<roledir>/templates/
but fails whendelegate_to
is used.The following always fails, regardless of
delegate_to
if filefindme
exists in<roledir>/templates/extra/
.delegate_to breakage
The variable
roledir
is unavailable when usingdelegate_to
and file lookups will thus only happen in basedir (the directory where the playbook lives).ansible/lib/ansible/plugins/lookup/first_found.py
Lines 186 to 197 in dee5dba
suggested fix: It looks like the variable
role_path
is always available, so we can use that instead ofroledir
. See commit 5c86c19paths
not considered while looking for filesProvided
paths
are always ignored and searches will only happen intemplates
,vars
andfiles
directories underroledir
.There seem to be a few issues that cause
total_search
to be incomplete (i.e. not including the provided paths):pathlist
is set during the first iteration ofterms
, it will be reset to an empty list during any following iterations. Same thing forfilelist
.total_search
results in an infinite loop while iteratingfilelist
, since we're really appending tofilelist
. So we should copyfilelist
usinglist()
here. (The infinite loop never hit us because eitherfilelist
orpathlist
has always been an empty list.)suggested fix: See commit cd8c0b1