ansible-keepass/README.md

51 lines
1.6 KiB
Markdown
Raw Normal View History

2019-03-13 16:09:06 +01:00
# Ansible KeePass Lookup Plugin
This collection provides a plugin that allows to read data from KeePass file (modifying is not supported)
## How it works
The plugin opens a UNIX socket with decrypted KeePass file.
For performance reasons, decryption occurs only once at socket startup,
and the KeePass file remains decrypted as long as the socket is open.
The UNIX socket file is stored in a temporary folder according to OS.
2019-03-13 16:09:06 +01:00
## Installation
2022-08-09 00:50:25 +02:00
Requirements: `python 3`, `pykeepass==4.0.3`
2022-08-09 00:50:25 +02:00
pip install 'pykeepass==4.0.3' --user
2022-08-09 13:39:08 +02:00
ansible-galaxy collection install viczem.keepass
2019-03-13 16:09:06 +01:00
## Variables
2019-05-05 00:48:52 +02:00
- `keepass_dbx` - path to KeePass file
- `keepass_psw` - password
- `keepass_key` - *Optional*. Path to keyfile
- `keepass_ttl` - *Optional*. Socket TTL (will be closed automatically when not used).
Default 60 seconds.
2019-03-21 11:49:33 +01:00
2020-05-05 12:46:37 +02:00
## Usage
2019-03-21 11:49:33 +01:00
`ansible-doc -t lookup keepass` to get description of the plugin
2019-03-21 11:49:33 +01:00
> **WARNING**: For security reasons, do not store KeePass passwords in plain text.
Use `ansible-vault encrypt_string` to encrypt it and use it like below
2019-03-21 11:49:33 +01:00
# file: group_vars/all
keepass_dbx: "~/.keepass/database.kdbx"
keepass_psw: !vault |
$ANSIBLE_VAULT;1.1;AES256
...encrypted password...
2019-03-13 16:09:06 +01:00
### Example
2019-03-13 16:09:06 +01:00
ansible_user : "{{ lookup('viczem.keepass.keepass', 'path/to/entry', 'username') }}"
ansible_become_pass : "{{ lookup('viczem.keepass.keepass', 'path/to/entry', 'password') }}"
ansible_custom_field : "{{ lookup('viczem.keepass.keepass', 'path/to/entry', 'custom_properties', 'a_custom_property_name') }}"
2019-03-13 16:09:06 +01:00
More examples see in [/doc/examples](/doc/examples).