Compare commits
12 Commits
Author | SHA1 | Date |
---|---|---|
![]() |
b633a57fc3 | |
![]() |
acb07e8335 | |
![]() |
c1ecea1fb5 | |
![]() |
6be989a0d3 | |
![]() |
ab6d3a8228 | |
![]() |
61a8f39081 | |
![]() |
1988cb62a6 | |
![]() |
dd97f8a830 | |
![]() |
8259d85305 | |
![]() |
02fc763fd5 | |
![]() |
47ebe2e6dd | |
![]() |
808391953c |
|
@ -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.
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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),
|
||||
|
|
Loading…
Reference in New Issue