Skip to content

Commit

Permalink
improve extra vips validations
Browse files Browse the repository at this point in the history
  • Loading branch information
manurodriguez committed Aug 17, 2023
1 parent c3d84fd commit 8e78f19
Showing 1 changed file with 29 additions and 9 deletions.
38 changes: 29 additions & 9 deletions roles/validate_inventory/tasks/ai.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,42 @@
- openshift_full_version is version('4.12', '>=')
fail_msg: "openshift_full_version must be >= 4.12. to support dualstack VIPs"

- name: Assert extra api VIP is within the extra machine networks
assert:
that:
- hostvars['assisted_installer']['extra_api_vip'] | ansible.utils.ipaddr(item.cidr) | ansible.utils.ipaddr('bool')
fail_msg: "{{ extra_api_vip }} is not within the extra machine networks!"
- name: Check if extra api VIP is within the extra machine networks
ansible.builtin.debug:
msg: "{{ hostvars['assisted_installer']['extra_api_vip'] | ansible.utils.ipaddr(item.cidr) }}"
when:
- vip_dhcp_allocation == false
- extra_machine_networks is defined
register: extra_api_vip_tests
loop: "{{ hostvars['assisted_installer']['extra_machine_networks'] }}"

- name: Assert extra ingress VIP is within the extra machine networks
assert:
- name: Fail if extra api VIP is NOT within any of the extra machine networks
vars:
vip_field_filter: "results[*].msg"
extra_api_ipv6_list: "{{ extra_api_vip_tests | json_query(vip_field_filter) }}"
ansible.builtin.assert:
that:
- hostvars['assisted_installer']['extra_ingress_vip'] | ansible.utils.ipaddr(item.cidr) | ansible.utils.ipaddr('bool')
fail_msg: "{{ extra_ingress_vip }} is not within the extra machine networks!"
- extra_api_vip in extra_api_ipv6_list
fail_msg: "{{ extra_api_vip }} is not within any of the extra machine networks!"
when:
- extra_api_vip_tests is defined

- name: Check if extra ingress VIP is within the extra machine networks
ansible.builtin.debug:
msg: "{{ hostvars['assisted_installer']['extra_ingress_vip'] | ansible.utils.ipaddr(item.cidr) }}"
when:
- vip_dhcp_allocation == false
- extra_machine_networks is defined
register: extra_ingress_vip_tests
loop: "{{ hostvars['assisted_installer']['extra_machine_networks'] }}"

- name: Fail if extra ingress VIP is NOT within any of the extra machine networks
vars:
vip_field_filter: "results[*].msg"
extra_ingress_ipv6_list: "{{ extra_ingress_vip_tests | json_query(vip_field_filter) }}"
ansible.builtin.assert:
that:
- extra_ingress_vip in extra_ingress_ipv6_list
fail_msg: "{{ extra_ingress_vip }} is not within any of the extra machine networks!"
when:
- extra_ingress_vip_tests is defined

0 comments on commit 8e78f19

Please sign in to comment.