From 9439b03d6469a1bbbfa5415d92babaf2c4806d88 Mon Sep 17 00:00:00 2001 From: Thomas Witzenrath Date: Mon, 27 Jun 2022 16:16:00 +0200 Subject: [PATCH] Allow netbox api access token to be templated Allow jinja-templating of the api access token. This makes it possible to use a lookup() to retrieve the token, i.e. from a password-manager. Idea is stolen from the hcloud inventory. --- plugins/inventory/nb_inventory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/inventory/nb_inventory.py b/plugins/inventory/nb_inventory.py index 1e7081782..b573f0f1a 100644 --- a/plugins/inventory/nb_inventory.py +++ b/plugins/inventory/nb_inventory.py @@ -1853,7 +1853,7 @@ def parse(self, inventory, loader, path, cache=True): self.use_cache = cache # NetBox access - token = self.get_option("token") + token = self.templar.template(self.get_option("token"), fail_on_undefined=False) # Handle extra "/" from api_endpoint configuration and trim if necessary, see PR#49943 self.api_endpoint = self.get_option("api_endpoint").strip("/") self.timeout = self.get_option("timeout")