Compare commits

...

12 Commits
v0.7.3 ... main

Author SHA1 Message Date
Victor Zemtsov b633a57fc3
Merge pull request #51 from MichaelEllnebrand/deprecated-configuration-setting
Deprecated Configuration Setting
2024-04-25 09:42:56 +03:00
Michael Ellnebrand acb07e8335
Deprecated Configuration Setting
The configuration setting COLLECTIONS_PATHS was deprecated in Ansible 2.19, see: https://docs.ansible.com/ansible/latest/reference_appendices/config.html#collections-paths
2024-04-21 19:57:33 +02:00
Victor Zemtsov c1ecea1fb5 Fix version 2023-06-11 23:22:15 +03:00
Victor Zemtsov 6be989a0d3 Fix DEPRECATION WARNING 2023-06-11 23:21:43 +03:00
Victor Zemtsov ab6d3a8228 Fix example 2023-06-11 23:14:43 +03:00
Victor Zemtsov 61a8f39081 Merge branch 'advanova-main' 2023-06-11 23:13:29 +03:00
Markus Heberling 1988cb62a6 Dereference field references 2023-06-01 08:23:12 +02:00
Victor Zemtsov dd97f8a830 Fix version to 0.7.4 2023-02-10 02:19:03 +03:00
Victor Zemtsov 8259d85305 Merge branch 'jpmens-attachment_new' 2023-02-10 01:04:44 +03:00
Victor Zemtsov 02fc763fd5 Merge branch 'attachment_new' of github.com:jpmens/ansible-keepass into jpmens-attachment_new 2023-02-10 01:02:58 +03:00
Victor Zemtsov 47ebe2e6dd Fix #46 custom_properties - long chain are truncated 2023-02-10 00:55:32 +03:00
Jan-Piet Mens 808391953c support kdbx key file for attachment extraction
the lookup plugin supports using a key file, but the module didn't.
  This small patch adds support for specifying a key file for
  accessing the kdbx file.
2023-01-25 20:53:46 +01:00
5 changed files with 21 additions and 8 deletions

View File

@ -4,7 +4,7 @@
```
[defaults]
COLLECTIONS_PATHS = ./collections
COLLECTIONS_PATH = ./collections
```
2. Create requirements.yml in cloned directory:
@ -26,4 +26,4 @@ rm -rf ./collections && ansible-galaxy install -r requirements.yml
Note: Any change on your clone imply to reinstall the collection.
Tip: You can place a ansible.cfg with `COLLECTIONS_PATHS = ../../collections` in the examples dictory if you want to run the example on local collection in your cloned directory.
Tip: You can place a ansible.cfg with `COLLECTIONS_PATH = ../../collections` in the examples dictory if you want to run the example on local collection in your cloned directory.

View File

@ -34,7 +34,8 @@
- debug:
msg: "fetch entry: '/slash\\/group/slash\\/title'; username: '{{ slash_login }}'; url: '{{ slash_url }}'"
- debug: "{{ lookup('viczem.keepass.keepass', 'close') }}"
- debug:
msg: "close {{ lookup('viczem.keepass.keepass', 'close') }}"
- name: "Export file: {{ keepass_attachment_1_name }}"
viczem.keepass.attachment:

View File

@ -8,7 +8,7 @@ namespace: viczem
name: keepass
# The version of the collection. Must be compatible with semantic versioning
version: 0.7.3
version: 0.7.5
# The path to the Markdown (.md) readme file. This path is relative to the root of the collection
readme: README.md

View File

@ -22,7 +22,7 @@ from pykeepass.exceptions import CredentialsError
DOCUMENTATION = """
lookup: keepass
author: Victor Zemtsov <viczem.dev@gmail.com>
version_added: '0.7.3'
version_added: '0.7.5'
short_description: Fetching data from KeePass file
description:
- This lookup returns a value of a property of a KeePass entry
@ -147,6 +147,7 @@ class LookupModule(LookupBase):
if len(terms) == 1 and terms[0] in ("quit", "exit", "close"):
self._send(socket_path, terms[0], [])
return []
else:
# Fetching data from the keepass socket
return self._send(socket_path, "fetch", terms)
@ -164,7 +165,14 @@ class LookupModule(LookupBase):
display.vvv("KeePass: %s %s" % (cmd, terms))
sock.send(_rq(cmd, *terms))
resp = sock.recv(1024).decode().splitlines()
data = b''
while True:
_ = sock.recv(1024)
data += _
if len(_) < 1024:
break
resp = data.decode().splitlines()
resp_len = len(resp)
if resp_len == 0:
raise AnsibleError("KeePass: '%s' result is empty" % cmd)
@ -362,7 +370,7 @@ def _keepass_socket(kdbx, kdbx_key, sock_path, ttl=60, kdbx_password=None):
)
)
break
conn.send(_resp("fetch", 0, getattr(entry, prop)))
conn.send(_resp("fetch", 0, entry.deref(prop)))
except CredentialsError:
print("%s failed to decrypt" % kdbx)
sys.exit(1)

View File

@ -110,7 +110,10 @@ def check_file_attrs(module, result, diff):
def export_attachment(module, result):
try:
# load database
kp = PyKeePass(module.params["database"], password=module.params["password"])
kp = PyKeePass(
module.params["database"],
password=module.params["password"],
keyfile=module.params["keyfile"])
entrypath = module.params["entrypath"]
dest = module.params["dest"]
@ -170,6 +173,7 @@ def main():
module_args = dict(
database=dict(type="str", required=True),
password=dict(type="str", no_log=True, required=True),
keyfile=dict(type="str", no_log=True, required=False),
entrypath=dict(type="str", required=True),
attachment=dict(type="str", required=True),
dest=dict(type="path", required=True),