Skip to content

Commit fb9b06c

Browse files
authored
Merge pull request #532 from devon-mar/nb-lookup-private-key
Add `private_key` option to `nb_lookup`.
2 parents 9416330 + 647fe92 commit fb9b06c

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

plugins/lookup/nb_lookup.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
description:
3434
- Queries Netbox via its API to return virtually any information
3535
capable of being held in Netbox.
36-
- If wanting to obtain the plaintext attribute of a secret, key_file must be provided.
36+
- If wanting to obtain the plaintext attribute of a secret, I(private_key) or I(key_file) must be provided.
3737
options:
3838
_terms:
3939
description:
@@ -49,7 +49,7 @@
4949
required: True
5050
api_filter:
5151
description:
52-
- The api_filter to use.
52+
- The api_filter to use. Filters should be key value pairs separated by a space.
5353
required: False
5454
plugin:
5555
description:
@@ -69,11 +69,16 @@
6969
- Whether or not to validate SSL of the NetBox instance
7070
required: False
7171
default: True
72+
private_key:
73+
description:
74+
- The private key as a string. Mutually exclusive with I(key_file).
75+
required: False
7276
key_file:
7377
description:
74-
- The location of the private key tied to user account.
78+
- The location of the private key tied to user account. Mutually exclusive with I(private_key).
7579
required: False
7680
raw_data:
81+
type: bool
7782
description:
7883
- Whether to return raw API data with the lookup/query or whether to return a key/value dict
7984
required: False
@@ -303,6 +308,7 @@ def run(self, terms, variables=None, **kwargs):
303308
or os.getenv("NETBOX_URL")
304309
)
305310
netbox_ssl_verify = kwargs.get("validate_certs", True)
311+
netbox_private_key = kwargs.get("private_key")
306312
netbox_private_key_file = kwargs.get("key_file")
307313
netbox_api_filter = kwargs.get("api_filter")
308314
netbox_raw_return = kwargs.get("raw_data")
@@ -318,6 +324,7 @@ def run(self, terms, variables=None, **kwargs):
318324
netbox = pynetbox.api(
319325
netbox_api_endpoint,
320326
token=netbox_api_token if netbox_api_token else None,
327+
private_key=netbox_private_key,
321328
private_key_file=netbox_private_key_file,
322329
)
323330
netbox.http_session = session

0 commit comments

Comments
 (0)