Compare commits
12 Commits
Author | SHA1 | Date |
---|---|---|
Victor Zemtsov | b633a57fc3 | |
Michael Ellnebrand | acb07e8335 | |
Victor Zemtsov | c1ecea1fb5 | |
Victor Zemtsov | 6be989a0d3 | |
Victor Zemtsov | ab6d3a8228 | |
Victor Zemtsov | 61a8f39081 | |
Markus Heberling | 1988cb62a6 | |
Victor Zemtsov | dd97f8a830 | |
Victor Zemtsov | 8259d85305 | |
Victor Zemtsov | 02fc763fd5 | |
Victor Zemtsov | 47ebe2e6dd | |
Jan-Piet Mens | 808391953c |
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
```
|
```
|
||||||
[defaults]
|
[defaults]
|
||||||
COLLECTIONS_PATHS = ./collections
|
COLLECTIONS_PATH = ./collections
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Create requirements.yml in cloned directory:
|
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.
|
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:
|
- debug:
|
||||||
msg: "fetch entry: '/slash\\/group/slash\\/title'; username: '{{ slash_login }}'; url: '{{ slash_url }}'"
|
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 }}"
|
- name: "Export file: {{ keepass_attachment_1_name }}"
|
||||||
viczem.keepass.attachment:
|
viczem.keepass.attachment:
|
||||||
|
|
|
@ -8,7 +8,7 @@ namespace: viczem
|
||||||
name: keepass
|
name: keepass
|
||||||
|
|
||||||
# The version of the collection. Must be compatible with semantic versioning
|
# 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
|
# The path to the Markdown (.md) readme file. This path is relative to the root of the collection
|
||||||
readme: README.md
|
readme: README.md
|
||||||
|
|
|
@ -22,7 +22,7 @@ from pykeepass.exceptions import CredentialsError
|
||||||
DOCUMENTATION = """
|
DOCUMENTATION = """
|
||||||
lookup: keepass
|
lookup: keepass
|
||||||
author: Victor Zemtsov <viczem.dev@gmail.com>
|
author: Victor Zemtsov <viczem.dev@gmail.com>
|
||||||
version_added: '0.7.3'
|
version_added: '0.7.5'
|
||||||
short_description: Fetching data from KeePass file
|
short_description: Fetching data from KeePass file
|
||||||
description:
|
description:
|
||||||
- This lookup returns a value of a property of a KeePass entry
|
- 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"):
|
if len(terms) == 1 and terms[0] in ("quit", "exit", "close"):
|
||||||
self._send(socket_path, terms[0], [])
|
self._send(socket_path, terms[0], [])
|
||||||
|
return []
|
||||||
else:
|
else:
|
||||||
# Fetching data from the keepass socket
|
# Fetching data from the keepass socket
|
||||||
return self._send(socket_path, "fetch", terms)
|
return self._send(socket_path, "fetch", terms)
|
||||||
|
@ -164,7 +165,14 @@ class LookupModule(LookupBase):
|
||||||
display.vvv("KeePass: %s %s" % (cmd, terms))
|
display.vvv("KeePass: %s %s" % (cmd, terms))
|
||||||
sock.send(_rq(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)
|
resp_len = len(resp)
|
||||||
if resp_len == 0:
|
if resp_len == 0:
|
||||||
raise AnsibleError("KeePass: '%s' result is empty" % cmd)
|
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
|
break
|
||||||
conn.send(_resp("fetch", 0, getattr(entry, prop)))
|
conn.send(_resp("fetch", 0, entry.deref(prop)))
|
||||||
except CredentialsError:
|
except CredentialsError:
|
||||||
print("%s failed to decrypt" % kdbx)
|
print("%s failed to decrypt" % kdbx)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
|
@ -110,7 +110,10 @@ def check_file_attrs(module, result, diff):
|
||||||
def export_attachment(module, result):
|
def export_attachment(module, result):
|
||||||
try:
|
try:
|
||||||
# load database
|
# 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"]
|
entrypath = module.params["entrypath"]
|
||||||
dest = module.params["dest"]
|
dest = module.params["dest"]
|
||||||
|
@ -170,6 +173,7 @@ def main():
|
||||||
module_args = dict(
|
module_args = dict(
|
||||||
database=dict(type="str", required=True),
|
database=dict(type="str", required=True),
|
||||||
password=dict(type="str", no_log=True, 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),
|
entrypath=dict(type="str", required=True),
|
||||||
attachment=dict(type="str", required=True),
|
attachment=dict(type="str", required=True),
|
||||||
dest=dict(type="path", required=True),
|
dest=dict(type="path", required=True),
|
||||||
|
|
Loading…
Reference in New Issue