mirror of
https://github.com/ansible-collections/hetzner.hcloud
synced 2024-11-10 06:34:13 +00:00
inventory - support jinjia templating within network
(#107)
Signed-off-by: Lukas Kämmerling <lukas.kaemmerling@hetzner-cloud.de>
This commit is contained in:
parent
f1526285d8
commit
51865c29ab
2 changed files with 5 additions and 2 deletions
2
changelogs/fragments/inventory-network-templating.yml
Normal file
2
changelogs/fragments/inventory-network-templating.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
minor_changes:
|
||||
- inventory - support jinjia templating within `network`
|
|
@ -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.")
|
||||
|
|
Loading…
Reference in a new issue