From 1863fe512c22730a509315c33c4b71a2d7a67b6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20T=C3=B6lle?= Date: Wed, 1 Feb 2023 12:56:21 +0100 Subject: [PATCH] feat(inventory): add variable for ipv6 address (#188) This variable matches the `ansible_host` variable that we set when `connect_with: public_ipv6`, and allows the user to dynamically choose the connection method in `compose`. --- changelogs/fragments/inventory-ipv6-adress-variable.yml | 2 ++ plugins/inventory/hcloud.py | 1 + 2 files changed, 3 insertions(+) create mode 100644 changelogs/fragments/inventory-ipv6-adress-variable.yml diff --git a/changelogs/fragments/inventory-ipv6-adress-variable.yml b/changelogs/fragments/inventory-ipv6-adress-variable.yml new file mode 100644 index 0000000..baa7e30 --- /dev/null +++ b/changelogs/fragments/inventory-ipv6-adress-variable.yml @@ -0,0 +1,2 @@ +minor_changes: + - inventory plugin - Add public IPv6 address to server variables. diff --git a/plugins/inventory/hcloud.py b/plugins/inventory/hcloud.py index 303dd0a..f032eb8 100644 --- a/plugins/inventory/hcloud.py +++ b/plugins/inventory/hcloud.py @@ -225,6 +225,7 @@ class InventoryModule(BaseInventoryPlugin, Constructable): if server.public_net.ipv6: self.inventory.set_variable(server.name, "ipv6_network", to_native(server.public_net.ipv6.network)) self.inventory.set_variable(server.name, "ipv6_network_mask", to_native(server.public_net.ipv6.network_mask)) + self.inventory.set_variable(server.name, "ipv6", to_native(self._first_ipv6_address(server.public_net.ipv6.ip))) self.inventory.set_variable( server.name,