nekmo / ansible-keepass Goto Github PK
View Code? Open in Web Editor NEWUse become (sudo) in Ansible without giving any password and safely
Use become (sudo) in Ansible without giving any password and safely
First, thank you very much for this nice plugin.
I was about to replace your implementation of the password cache with lru_cache
of functools
for readability.
However, I recognized that get_password
gets called for every task in a Play.
Some good old printf debugging (print(self.identity, host_name)
to get_password
) gave me:
TASK [Gathering Facts] *************************************************
<ansible.plugins.vars.ansible_keepass.KeepassXC object at 0x7f8d3f0ff150> myhost
ok: [myhost]
TASK [foo] *************************************************************
<ansible.plugins.vars.ansible_keepass.KeepassXC object at 0x7f8d3f0ff150> myhost
ok: [myhost]
TASK [bar] *************************************************************
<ansible.plugins.vars.ansible_keepass.KeepassXC object at 0x7f8d3f0ff150> myhost
ok: [myhost]
TASK [baz] *************************************************************
<ansible.plugins.vars.ansible_keepass.KeepassXC object at 0x7f8d3f0ff150> myhost
ok: [myhost]
So I was asking myself โ what is the password cache actually good for? When can it actually be reused?
Cheers :)
Is there anything (apart from checking become
) why monkey patching TaskExecutor
is a superior solution to just writing a VarsModule
?
IMHO the present approach torpedoes the idea of "vars plugins" (and the Law of Demeter).
In order to gain readability and comprehensibility (which is surely is subjective) for investigating #4, a refactored version of your wonderful plugin resulted. In this refactored version, you can find an example implementation as a "vars plugin".
The refactored version also contains the changes I pull-requested (plus: it moves all functions out the scope of the module, fixes to be more compliant with PEP 8, etc.).
When I tried to make the plugin work I never found an entry, so I debugged the code and saw that under KeepassXC you are not looking for ssh://[host]
but for ssh:[host]
. This might be a typo but changing the following worked for me
def get_password(self, host_name):
try:
logins = self.connection.get_logins(
self.identity,
url='ssh://{}'.format(host_name)
On a side note, entering the URL values with just ssh:[host]
is marked red in KeepassXC, indicating that the URL is not correct
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.