From 158048f51dc0ebc833edbb63aa6462ae93309823 Mon Sep 17 00:00:00 2001 From: Thomas von Dein Date: Tue, 26 Nov 2024 13:09:26 +0100 Subject: [PATCH] fixed ip variables, now using inventory vars --- Makefile | 4 ++++ debug.yaml | 1 - inventory/hosts.hcloud.yaml | 2 ++ roles/network/tasks/main.yaml | 9 +++++---- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 341221d..5349be8 100644 --- a/Makefile +++ b/Makefile @@ -16,6 +16,7 @@ DEPLOY_COMMAND = ansible-playbook deploy.yaml $(OPTIONS) CLEAN_COMMAND = ansible-playbook cleanup.yaml $(OPTIONS) HOSTS_COMMAND = ansible-playbook knownhosts.yaml $(OPTIONS) DEBUG_COMMAND = ansible-playbook debug.yaml $(OPTIONS) +SHOW_COMMAND = ansible-inventory -i inventory/hosts.hcloud.yaml --list ENV = HCLOUD_TOKEN="$(TOKEN)" SNAPSHOT="$(SNAPSHOT)" ANSIBLE_VERBOSITY=$(verbose) @@ -49,3 +50,6 @@ editvars: showvars: ansible-vault decrypt $(VARS) --output - + +showinventory: + $(ENV) $(SHOW_COMMAND) diff --git a/debug.yaml b/debug.yaml index cb7fdcf..7e220e9 100644 --- a/debug.yaml +++ b/debug.yaml @@ -6,4 +6,3 @@ user: root roles: - role: network - - role: pubnix diff --git a/inventory/hosts.hcloud.yaml b/inventory/hosts.hcloud.yaml index 47c5b5f..9d219e2 100644 --- a/inventory/hosts.hcloud.yaml +++ b/inventory/hosts.hcloud.yaml @@ -5,3 +5,5 @@ status: groups: dev: connect_with: "public_ipv6" +compose: + server_ipv6: ipv6 diff --git a/roles/network/tasks/main.yaml b/roles/network/tasks/main.yaml index fc9e3f1..77d5542 100644 --- a/roles/network/tasks/main.yaml +++ b/roles/network/tasks/main.yaml @@ -1,12 +1,13 @@ --- -- name: determine ipv6 address - shell: ifconfig {{ netif.primary }} inet6 | awk '{ if (/2a01/) { sub(/::.$/, "::2", $2); print $2 }}' +- name: determine ipv6 jail address + shell: echo {{ server_ipv6 }} | sed 's/::1/::2/' register: jailip - name: determine ipv6 net - shell: ifconfig {{ netif.primary }} inet6 | awk '{ if (/2a01/) { sub(/::.$/, "::", $2); print $2"/64" }}' + shell: echo '{{ ipv6_network }}/64' register: jailnet - name: determine primary ipv6 address - shell: ifconfig {{ netif.primary }} inet6 | awk '{ if (/2a01/) { print $2 }}' + shell: echo {{ server_ipv6 }} register: primaryip +