Skip to content

Commit e62bed0

Browse files
committed
Add private_key option to nb_lookup
1 parent 9416330 commit e62bed0

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

plugins/lookup/nb_lookup.py

Lines changed: 8 additions & 2 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, private_key or key_file must be provided.
3737
options:
3838
_terms:
3939
description:
@@ -69,9 +69,13 @@
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:
7781
description:
@@ -303,6 +307,7 @@ def run(self, terms, variables=None, **kwargs):
303307
or os.getenv("NETBOX_URL")
304308
)
305309
netbox_ssl_verify = kwargs.get("validate_certs", True)
310+
netbox_private_key = kwargs.get("private_key")
306311
netbox_private_key_file = kwargs.get("key_file")
307312
netbox_api_filter = kwargs.get("api_filter")
308313
netbox_raw_return = kwargs.get("raw_data")
@@ -318,6 +323,7 @@ def run(self, terms, variables=None, **kwargs):
318323
netbox = pynetbox.api(
319324
netbox_api_endpoint,
320325
token=netbox_api_token if netbox_api_token else None,
326+
private_key=netbox_private_key,
321327
private_key_file=netbox_private_key_file,
322328
)
323329
netbox.http_session = session

0 commit comments

Comments
 (0)