Skip to content
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

Feature Request: Cache #11

Open
markusressel opened this issue Oct 30, 2020 · 2 comments · May be fixed by #18
Open

Feature Request: Cache #11

markusressel opened this issue Oct 30, 2020 · 2 comments · May be fixed by #18

Comments

@markusressel
Copy link

When running an ansible project on a comparably slow netbook I noticed that ansible takes a really long time for each step. When evaluating the htop output I noticed that bitwarden is called each and every time a task uses the become: true option, since I have configured the project to fetch the sudo password from bitwarden.

It would be nice if this module would cache the values of password lookups, to speed up querying of the same item when it is accessed more than once.

rkokkelk added a commit to rkokkelk/ansible-modules-bitwarden that referenced this issue Aug 20, 2021
The `LookupModule` is initialised during every lookup. This results in a
new Bitwarden object for every lookup removing the benefit of the cache.

However, importing the bitwarden Lookup module is only done at specific
stages during a playbook and not run for every lookup itself. So
changing the cache to a global variable makes it persistent for as long
as possible and thus making the cache actually benefical for improving
the executing time.

Fixes c0sco#11
@rkokkelk
Copy link

@markusressel I've created a PR to resolve this issue as much as possible. However, due to the way Ansible is implemented it is not possible to implement a cache which exists for the entire Playbook. Ansible simply does not implement that type of control within a single lookup plugin. The existence of a lookup plugin code is never the entirety of the Ansible playbook.

However this PR ensures that a cache exists for as long as possible within Ansible, thus greatly improving lookup times within similar tasks and lookups. Especially when using this lookup plugin for become passwords this greatly increases execution times.

@markusressel
Copy link
Author

markusressel commented Aug 21, 2021

Thx for the effort, I also did some testing (months ago) and had the same conclusion 😢
Good thing there is at least some performance gain possible with this.

I thought about writing and reading decrypted passwords to a file (in some form of tmpfs that sits in memory), but that could cause some major security concerns in itself and we are probably not be able to cleanup this file afterwards. Reading this file would probably still be faster than querying bitwarden though 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants