Skip to content

Commit

Permalink
Ansible: IPv6 net validation 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
samip5 committed Jul 17, 2023
1 parent 2cb5732 commit dd920b3
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions bootstrap/tasks/validation/net.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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."

Expand Down Expand Up @@ -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

0 comments on commit dd920b3

Please sign in to comment.