Skip to content

Commit 874e04a

Browse files
bloomcakeclinta
authored andcommitted
Add custom headers to inventory request
1 parent 5fb2768 commit 874e04a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

plugins/inventory/nb_inventory.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,10 @@
264264
- By default, the inventory hostname is the netbox device name
265265
- If set, sets the inventory hostname from this field in custom_fields instead
266266
default: False
267+
headers:
268+
description: Dictionary of headers to be passed to the NetBox API.
269+
type: dict
270+
default: {}
267271
"""
268272

269273
EXAMPLES = """
@@ -281,6 +285,8 @@
281285
device_query_filters:
282286
- has_primary_ip: 'true'
283287
- tenant__n: internal
288+
headers:
289+
Cookie: "{{ auth_cookie }}"
284290
285291
# has_primary_ip is a useful way to filter out patch panels and other passive devices
286292
# Adding '__n' to a field searches for the negation of the value.
@@ -2142,6 +2148,7 @@ def parse(self, inventory, loader, path, cache=True):
21422148
"User-Agent": "ansible %s Python %s"
21432149
% (ansible_version, python_version.split(" ", maxsplit=1)[0]),
21442150
"Content-type": "application/json",
2151+
**self.get_option("headers"),
21452152
}
21462153
self.cert = self.get_option("cert")
21472154
self.key = self.get_option("key")

0 commit comments

Comments
 (0)