-
Notifications
You must be signed in to change notification settings - Fork 1.7k
binary_file lookup: automatically unvault vaulted files (closes #10799) #10806
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
base: main
Are you sure you want to change the base?
Conversation
…collections#10799) this matches the behavior of the builtin file lookup
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ilia-kats thanks for your contribution.
result.append(base64.b64encode(f.read()).decode("utf-8")) | ||
except Exception as exc: | ||
raise AnsibleLookupError(f"Error while reading {path}: {exc}") | ||
result.append(base64.b64encode(self._loader._get_file_contents(path)[0]).decode("utf-8")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what I gathered on Matrix, it doesn't look like there's a public API for this. The only API there is decrypts the file to another file on disk, which is something we really want to avoid.
Also DataLoader._get_file_contents()
doesn't set the SourceWasEncrypted
tag (and the functionality to set it is definitely private), so I guess there's no way to properly achieve this right now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created ansible/ansible#85852 for this.
this matches the behavior of the builtin file lookup
SUMMARY
The
binary_file
plugin now automatically unvaults vaulted files, matching the behavior of the built-infile
plugin. I realize thatDataLoader._get_file_contents
is technically not public due to the underscore in front, but the alternative would be to either accessDataLoader._vault
, which is also not public, or usingDataLoader.get_real_file
, which creates an unnecessary temporary file.Fixes #10799.
ISSUE TYPE
COMPONENT NAME
binary_file
lookupADDITIONAL INFORMATION