mirror of
https://github.com/ansible-collections/hetzner.hcloud
synced 2024-11-10 06:34:13 +00:00
feat: Pass extra vars to templating of api_token. (#156)
Co-authored-by: Maximilian Senftleben <maximilian.senftleben@frogblue-tec.com>
This commit is contained in:
parent
b5f205485a
commit
ccfa51bf66
1 changed files with 5 additions and 0 deletions
|
@ -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(
|
||||
|
|
Loading…
Reference in a new issue