From dd920b3295d5f1426f75a02fcb8549bea89e5bd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Skyler=20M=C3=A4ntysaari?= Date: Mon, 17 Jul 2023 21:18:22 +0300 Subject: [PATCH] Ansible: IPv6 net validation :rocket: --- bootstrap/tasks/validation/net.yaml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/bootstrap/tasks/validation/net.yaml b/bootstrap/tasks/validation/net.yaml index bad577d2982..880f0f8cbbf 100644 --- a/bootstrap/tasks/validation/net.yaml +++ b/bootstrap/tasks/validation/net.yaml @@ -15,13 +15,15 @@ - name: Verify cluster CIDR ansible.builtin.assert: - that: ["{{ bootstrap_cluster_cidr is ansible.utils.ipv4 }}"] + that: + - "{{ bootstrap_cluster_cidr | regex_search('^(?:[0-9]{1,3}\\.){3}[0-9]{1,3}\\/[0-9]{1,2}$') is match('^.*$') or bootstrap_cluster_cidr | regex_search('^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}\\/[0-9]{1,3}$') is match('^.*$') }}" success_msg: "Cluster CIDR {{ bootstrap_cluster_cidr }} is valid." fail_msg: "Cluster CIDR {{ bootstrap_cluster_cidr }} is invalid." - name: Verify service CIDR ansible.builtin.assert: - that: ["{{ bootstrap_service_cidr is ansible.utils.ipv4 }}"] + that: + - "{{ bootstrap_service_cidr | regex_search('^(?:[0-9]{1,3}\\.){3}[0-9]{1,3}\\/[0-9]{1,2}$') is match('^.*$') or bootstrap_service_cidr | regex_search('^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}\\/[0-9]{1,3}$') is match('^.*$') }}" success_msg: "Service CIDR {{ bootstrap_service_cidr }} is valid." fail_msg: "Service CIDR {{ bootstrap_service_cidr }} is invalid." @@ -92,3 +94,11 @@ loop: "{{ bootstrap_nodes.master + bootstrap_nodes.worker | default([]) }}" loop_control: label: "{{ item.address }}" + +- Name: Verify that nodes have an IPv6 address + ansible.builtin.assert: + that: ["{{ ansible_default_ipv6.address is ansible.utils.ipv6 }}"] + success_msg: "Node address {{ ansible_default_ipv6.address }} is valid IPv6." + fail_msg: "Node IPv6 address is not valid or it's missing from node." + quiet: true + when: ipv6_enabled