Skip to content

Commit 8200f13

Browse files
Inventroy: Remove token being required for nb_inventory (#181)
1 parent 255a4fb commit 8200f13

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

plugins/inventory/nb_inventory.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,10 @@
4242
default: False
4343
type: boolean
4444
token:
45-
required: True
46-
description: NetBox token.
45+
required: False
46+
description:
47+
- NetBox API token to be able to read against NetBox.
48+
- This may not be required depending on the NetBox setup.
4749
env:
4850
# in order of precedence
4951
- name: NETBOX_TOKEN
@@ -59,7 +61,7 @@
5961
- If True, it adds the device or virtual machine services information in host vars.
6062
default: True
6163
type: boolean
62-
version_added: "2.0"
64+
version_added: "0.2.0"
6365
group_by:
6466
description: Keys used to create groups.
6567
type: list
@@ -896,11 +898,12 @@ def parse(self, inventory, loader, path, cache=True):
896898
self.interfaces = self.get_option("interfaces")
897899
self.services = self.get_option("services")
898900
self.headers = {
899-
"Authorization": "Token %s" % token,
900901
"User-Agent": "ansible %s Python %s"
901902
% (ansible_version, python_version.split(" ")[0]),
902903
"Content-type": "application/json",
903904
}
905+
if token:
906+
self.headers.update({"Authorization": "Token %s" % token})
904907

905908
# Filter and group_by options
906909
self.group_by = self.get_option("group_by")

0 commit comments

Comments
 (0)