1
0
Fork 0
mirror of https://github.com/ansible-collections/hetzner.hcloud.git synced 2026-02-04 08:01:49 +00:00

inventory - support jinjia templating within network

Signed-off-by: Lukas Kämmerling <lukas.kaemmerling@hetzner-cloud.de>
This commit is contained in:
Lukas Kämmerling 2021-08-25 10:06:54 +02:00
parent f1526285d8
commit d9d7bfc2d2
2 changed files with 5 additions and 2 deletions

View file

@ -0,0 +1,2 @@
minor_changes:
- inventory - support jinjia templating within `network`

View file

@ -142,10 +142,11 @@ class InventoryModule(BaseInventoryPlugin, Constructable):
def _filter_servers(self):
if self.get_option("network"):
network = self.templar.template(self.get_option("network"), fail_on_undefined=False) or self.get_option("network")
try:
self.network = self.client.networks.get_by_name(self.get_option("network"))
self.network = self.client.networks.get_by_name(network)
if self.network is None:
self.network = self.client.networks.get_by_id(self.get_option("network"))
self.network = self.client.networks.get_by_id(network)
except APIException:
raise AnsibleError(
"The given network is not found.")