diff --git a/changelogs/fragments/inventory-network-templating.yml b/changelogs/fragments/inventory-network-templating.yml new file mode 100644 index 0000000..084ad8e --- /dev/null +++ b/changelogs/fragments/inventory-network-templating.yml @@ -0,0 +1,2 @@ +minor_changes: + - inventory - support jinjia templating within `network` diff --git a/plugins/inventory/hcloud.py b/plugins/inventory/hcloud.py index a683245..be35e2d 100644 --- a/plugins/inventory/hcloud.py +++ b/plugins/inventory/hcloud.py @@ -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.")