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

Multiple entries with one file open #1

Closed
Rulqu opened this issue May 2, 2019 · 2 comments
Closed

Multiple entries with one file open #1

Rulqu opened this issue May 2, 2019 · 2 comments

Comments

@Rulqu
Copy link

Rulqu commented May 2, 2019

Would it be possible to get multiple entries without opening the keepass file multiple times? Currently it is time consuming when many entries get fetched during one playbook.

@viczem viczem added the enhancement New feature or request label May 2, 2019
@viczem viczem assigned viczem and unassigned viczem May 2, 2019
@Rulqu
Copy link
Author

Rulqu commented May 3, 2019

I tried with something like

                                                                                                 
        for t in terms[0]:
            entry_path = t.get('path').strip('/')                                                                    
            entry_attr = t.get('variable') 
            # entry getting code here

And using something like

keepass_dict:
  - username:
    path: 'path/to/entry'
    variable: 'username'
  - password:
    path: 'path/to/entry'
    variable: 'password'
  - become:
    path: 'path/to/entry' 
    variable: password

ansible_user: "{{ lookup('keepass',keepass_dict)}}"

This lacks the yml side of handling the returning array or dict, whichever is gonna be returned.
This seems to work but it would change the original purpose of the file too much so it would perhaps need to be and option somehow. My knowledge of python is lacking to do it the right way.

@viczem
Copy link
Owner

viczem commented May 4, 2019

There are two ways to use this plugin - without and with a UNIX socket (see README).

  1. If you use the plugin without a UNIX socket, you will not be able to keep Keepass file decrypted, because for each playbook task Ansible runs this plugin as a new instance.
    Now PyKeePass object stored in a global variable for decrease time consumption (one file open for one task) compared to the previous version. But it not resolve the issue.

  2. If you will use UNIX sockets, you can keep Keepass file decrypted while the socket is open. I considered this variant as a bad idea for security reasons and programmed to close the database after each request. I agree that this is a bad option for performance. I rewrote this part of the code and reduced the default socket TTL to 1 minute. Now, while the socket is open, the Keepass file is always in decrypted state.

@viczem viczem closed this as completed May 6, 2019
@viczem viczem removed the enhancement New feature or request label May 6, 2019
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

No branches or pull requests

2 participants