Open EdificomSA opened 1 year ago
This feature may be added in the existing lookup plugin
working on an implementation. approach with minimum code change, yet extend flexibility by sending kwargs directly to pykeepass.
- "{{ lookup('keepass', 'path/to/entry', 'username') }}"
- "{{ lookup('keepass', 'path/to/entry', 'password') }}"
- "{{ lookup('keepass', 'path/to/entry', 'custom_properties', 'my_prop_name') }}"
- "{{ lookup('keepass', 'path/to/entry', 'attachments', 'my_file_name') }}"
# assumes title search if '/' is not found in 'path/to/entry'
# additional complex params can also be sent to pykeepass. (url, regex, etc)
- "{{ lookup('keepass', 'entry', 'username') }}" # default regex=false
- "{{ lookup('keepass', 'entry', 'password', regex=false) }}"
- "{{ lookup('keepass', 'entry', 'password', url='github.com', regex=true) }}" # match both entry, url
- "{{ lookup('keepass', 'entry', 'password', url='github.com', string={'custom_field1': 'custom value', 'custom_field2': 'custom value'}, regex=true, history=true) }}" # complex
@hgtok I have an idea how it implement
"{{ lookup('keepass', 'spam-[0-9]+$', 'password', regex=true) }}" # default is regexp match by path
"{{ lookup('keepass', 'spam-[0-9]+$', 'password', regex=url) }}" # regexp match by url attribute
"{{ lookup('keepass', 'spam-[0-9]+$', 'password', regex=username) }}" # regexp match by username attribute
... other attributes
"{{ lookup('keepass', 'spam-[0-9]+$', 'password') }}" # regexp is not used - search by path as default
looks good. when can it be released?
a possible limitation of your implementation: unable to support complex search like 'string' or multiple conditions.
have submitted my implementation for this issue under #53 for your considerations.
https://github.com/viczem/ansible-keepass/blob/c1ecea1fb5336d8972de22d270acd95b70dfc099/plugins/lookup/keepass.py#L290
Using
find_entries
as in https://github.com/libkeepass/pykeepass#finding-entries Maybe implementing another lookup plugin or maybe there is a way to add this feature in the existing lookup ?