diff --git a/README.md.in b/README.md.in index aa25a059..7ed0d0f8 100644 --- a/README.md.in +++ b/README.md.in @@ -23,7 +23,6 @@ Requirements * Ansible core version 2.12.0 or higher * Python SDK version 4.5.0 or higher - * Python netaddr library on the ansible controller node Content of the collection ---------------- diff --git a/changelogs/fragments/691-drop-netaddr.yml b/changelogs/fragments/691-drop-netaddr.yml new file mode 100644 index 00000000..5383ca4c --- /dev/null +++ b/changelogs/fragments/691-drop-netaddr.yml @@ -0,0 +1,3 @@ +--- +bugfixes: + - HE - drop usage of ipaddr filters and remove dependency on python-netaddr (https://github.com/oVirt/ovirt-ansible-collection/pull/691) diff --git a/ovirt-ansible-collection.spec.in b/ovirt-ansible-collection.spec.in index 4c35a055..b4d1910b 100644 --- a/ovirt-ansible-collection.spec.in +++ b/ovirt-ansible-collection.spec.in @@ -26,7 +26,6 @@ Requires: qemu-img %if 0%{?rhel} >= 9 Requires: python3.11-ovirt-imageio-client Requires: python3.11-ovirt-engine-sdk4 >= 4.5.0 -Requires: python3.11-netaddr Requires: python3.11-jmespath Requires: python3.11-passlib %endif @@ -34,7 +33,6 @@ Requires: python3.11-passlib %if 0%{?rhel} < 9 Requires: python39-ovirt-imageio-client Requires: python39-ovirt-engine-sdk4 >= 4.5.0 -Requires: python39-netaddr Requires: python39-jmespath Requires: python39-passlib %endif diff --git a/roles/hosted_engine_setup/tasks/bootstrap_local_vm/01_prepare_routing_rules.yml b/roles/hosted_engine_setup/tasks/bootstrap_local_vm/01_prepare_routing_rules.yml index 5b724602..c0bd6c10 100644 --- a/roles/hosted_engine_setup/tasks/bootstrap_local_vm/01_prepare_routing_rules.yml +++ b/roles/hosted_engine_setup/tasks/bootstrap_local_vm/01_prepare_routing_rules.yml @@ -54,14 +54,14 @@ ansible.builtin.set_fact: virbr_cidr_ipv4: >- {{ (hostvars[inventory_hostname]['ansible_'+virbr_default]['ipv4']['address']+'/' - +hostvars[inventory_hostname]['ansible_'+virbr_default]['ipv4']['netmask']) |ipv4('host/prefix') }} + +hostvars[inventory_hostname]['ansible_'+virbr_default]['ipv4']['netmask']) }} when: not ipv6_deployment|bool - name: Fetch IPv6 CIDR for {{ virbr_default }} ansible.builtin.set_fact: virbr_cidr_ipv6: >- {{ (hostvars[inventory_hostname]['ansible_'+virbr_default]['ipv6'][0]['address']+'/'+ - hostvars[inventory_hostname]['ansible_'+virbr_default]['ipv6'][0]['prefix']) | - ipv6('host/prefix') if 'ipv6' in hostvars[inventory_hostname]['ansible_'+virbr_default] else None }} + hostvars[inventory_hostname]['ansible_'+virbr_default]['ipv6'][0]['prefix']) + if 'ipv6' in hostvars[inventory_hostname]['ansible_'+virbr_default] else None }} when: ipv6_deployment|bool - name: Add IPv4 outbound route rules ansible.builtin.command: ip rule add from {{ virbr_cidr_ipv4 }} priority 101 table main @@ -71,7 +71,7 @@ not ipv6_deployment|bool and route_rules_ipv4.stdout | from_json | selectattr('priority', 'equalto', 101) | - selectattr('src', 'equalto', virbr_cidr_ipv4 | ipaddr('address') ) | + selectattr('src', 'equalto', virbr_cidr_ipv4) | list | length == 0 changed_when: true - name: Add IPv4 inbound route rules @@ -83,7 +83,7 @@ not ipv6_deployment|bool and route_rules_ipv4.stdout | from_json | selectattr('priority', 'equalto', 100) | - selectattr('dst', 'equalto', virbr_cidr_ipv4 | ipaddr('address') ) | + selectattr('dst', 'equalto', virbr_cidr_ipv4) | list | length == 0 - name: Add IPv6 outbound route rules ansible.builtin.command: ip -6 rule add from {{ virbr_cidr_ipv6 }} priority 101 table main diff --git a/roles/hosted_engine_setup/tasks/fetch_host_ip.yml b/roles/hosted_engine_setup/tasks/fetch_host_ip.yml index 53907369..4a066ab7 100644 --- a/roles/hosted_engine_setup/tasks/fetch_host_ip.yml +++ b/roles/hosted_engine_setup/tasks/fetch_host_ip.yml @@ -16,10 +16,14 @@ - name: Choose IPv4, IPv6 or auto import_tasks: ipv_switch.yml - name: Get host address resolution - ansible.builtin.shell: getent {{ ip_key }} {{ he_host_address }} | grep STREAM + ansible.builtin.shell: getent {{ ip_key }} {{ he_host_address }} | grep STREAM | cut -d ' ' -f1 register: hostname_resolution_output changed_when: true ignore_errors: true + - name: Get host IP addresses + ansible.builtin.command: hostname -I + register: hostname_addresses_output + changed_when: true - name: Check address resolution ansible.builtin.fail: msg: > @@ -29,10 +33,8 @@ ansible.builtin.set_fact: he_host_ip: "{{ ( - hostname_resolution_output.stdout.split() | ipaddr | - difference(hostname_resolution_output.stdout.split() | - ipaddr('link-local') - ) + hostname_resolution_output.stdout.split() | + intersect(hostname_addresses_output.stdout.split()) )[0] }}" - name: Fail if host's ip is empty