This collection provides modules that allows to read data from KeePass file.
The secret_reader, group_reader and secret_writer helps on managing the secrets of a keepass database with the ability to integrate it in automated tasks.
Requirements: python 3
, pykeepass==4.0.6
pip install 'pykeepass==4.0.6' --user
ansible-galaxy collection install hasnimehdi91.keepass
- Module :
hasnimehdi91.keepass.secret_reader
db_path
: Path to KeePass filedb_password
: Password of KeePass filesecret_path
: Path to secret in of KeePass file
- Module :
hasnimehdi91.keepass.secret_reader
db_path
: Path to KeePass filedb_password
: Password of KeePass filesecret_path
: Path to secret in of KeePass file
- Module :
hasnimehdi91.keepass.secret_writer
db_path
: Path to KeePass filedb_password
: Password of KeePass filesecret_path
: Path to secret in of KeePass filesecret_value
: Dictionary containing the secret data. If not provided a empty secret will be created.secret_value.username
: Secret usernamesecret_value.password:
: Secret passwordsecret_value.url:
: Secret passwordsecret_value.custom_properties:
: Secret customer properties (key, value)force
: If set to true the secret will be overridden, Default is false
- name: Read secret
hosts: all
become: no
connection: local
tasks:
- hasnimehdi91.keepass.secret_reader:
db_path: "secrets.kdbx"
db_password: "password"
secret_path: "foo/bar/secret"
register: test
- debug:
msg: "{{ test.secret }}"
ansible-playbook playbook.yml
- name: Read group secrets
hosts: all
become: no
connection: local
tasks:
- hasnimehdi91.keepass.group_reader:
db_path: "secrets.kdbx"
db_password: "password"
group_path: "foo/bar"
register: test
- debug:
msg: "{{ test.group }}"
ansible-playbook playbook.yml
# Write secret to database
#
# Define secret
- set_fact:
secret:
username: "John"
password: "Doe"
custom_properties:
gender: "Male"
# Write secret
- name: Write secret
hasnimehdi91.keepass.secret_writer:
db_path: "keys.kdbx"
db_password: "password"
secret_path: "/foo/bar"
secret_value: "{{ secret }}
force: false
register: created_secret
- debug: var=created_secret
ansible-playbook playbook.yml