From ccfa51bf66043af48c9bc80a27b8ae81165b1809 Mon Sep 17 00:00:00 2001 From: n00b42 Date: Mon, 30 Jan 2023 12:08:09 +0100 Subject: [PATCH] feat: Pass extra vars to templating of api_token. (#156) Co-authored-by: Maximilian Senftleben --- plugins/inventory/hcloud.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugins/inventory/hcloud.py b/plugins/inventory/hcloud.py index 7f7063f..ab2d79f 100644 --- a/plugins/inventory/hcloud.py +++ b/plugins/inventory/hcloud.py @@ -86,6 +86,10 @@ EXAMPLES = r""" # Minimal example. `HCLOUD_TOKEN` is exposed in environment. plugin: hcloud +# Example with templated token, e.g. provided through extra vars. +plugin: hcloud +token: "{{ hetzner_apitoken }}" + # Example with locations, types, status and token plugin: hcloud token: foobar @@ -129,6 +133,7 @@ class InventoryModule(BaseInventoryPlugin, Constructable): def _configure_hcloud_client(self): self.token_env = self.get_option("token_env") + self.templar.available_variables = self._vars self.api_token = self.templar.template(self.get_option("token"), fail_on_undefined=False) or os.getenv(self.token_env) if self.api_token is None: raise AnsibleError(