"Fossies" - the Fresh Open Source Software Archive

Member "ansible-6.1.0/ansible_collections/ovirt/ovirt/roles/hosted_engine_setup/tasks/pre_checks/001_validate_network_interfaces.yml" (9 Jun 2022, 3927 Bytes) of package /linux/misc/ansible-6.1.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Ansible YAML source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 ---
    2 - name: Network interfaces
    3   block:
    4   - name: Detecting interface on existing management bridge
    5     set_fact:
    6       bridge_interface="{{ hostvars[inventory_hostname]['ansible_' + bridge_name ]['interfaces']|first }}"
    7     when: "'ansible_' + bridge_name in hostvars[inventory_hostname]"
    8     with_items:
    9       - 'ovirtmgmt'
   10       - 'rhevm'
   11     loop_control:
   12       loop_var: bridge_name
   13   - name: Set variable for supported bond modes
   14     set_fact:
   15       acceptable_bond_modes: ['active-backup', 'balance-xor', 'broadcast', '802.3ad']
   16   - name: Get all active network interfaces
   17     set_fact:
   18       otopi_net_host="{{ hostvars[inventory_hostname]['ansible_' + iface_item]['device'] }}"
   19       type="{{ hostvars[inventory_hostname]['ansible_' + iface_item]['type'] }}"
   20       bond_valid_name="{{ iface_item | regex_search('(^bond[0-9]+)') }}"
   21     when: (
   22         (
   23           iface_item != 'lo'
   24         ) and (
   25           bridge_interface is not defined
   26         ) and (
   27           'active' in hostvars[inventory_hostname]['ansible_' + iface_item] and
   28           hostvars[inventory_hostname]['ansible_' + iface_item]['active']
   29         ) and (
   30           hostvars[inventory_hostname]['ansible_' + iface_item]['type'] != 'bridge'
   31         ) and (
   32           hostvars[inventory_hostname]['ansible_' + iface_item]['ipv4'] is defined or
   33           hostvars[inventory_hostname]['ansible_' + iface_item]['ipv6'] is defined
   34         ) and (
   35           (
   36             hostvars[inventory_hostname]['ansible_' + iface_item]['type'] != 'bonding'
   37           ) or (
   38             (
   39               hostvars[inventory_hostname]['ansible_' + iface_item]['type'] == 'bonding'
   40             ) and (
   41               hostvars[inventory_hostname]['ansible_' + iface_item]['slaves'][0] is defined
   42             ) and (
   43               hostvars[inventory_hostname]['ansible_' + iface_item]['mode'] in acceptable_bond_modes
   44             )
   45           )
   46         )
   47       )
   48     with_items:
   49       - "{{ ansible_interfaces | map('replace', '-','_') | list }}"
   50     loop_control:
   51       loop_var: iface_item
   52     register: valid_network_interfaces
   53   - name: Filter bonds with bad naming
   54     set_fact:
   55       net_iface="{{ bond_item }}"
   56     when: >-
   57       not 'skipped' in bond_item and ((bond_item['ansible_facts']['type']  == 'ether') or
   58       ( (bond_item['ansible_facts']['type'] == 'bonding') and bond_item['ansible_facts']['bond_valid_name'] ))
   59     with_items:
   60       - "{{ valid_network_interfaces['results'] }}"
   61     loop_control:
   62       loop_var: bond_item
   63     register: bb_filtered_list
   64   - name: Generate output list
   65     set_fact:
   66       host_net: >-
   67         {{ [bridge_interface] if bridge_interface is defined else bb_filtered_list.results |
   68         reject('skipped') | map(attribute='bond_item.ansible_facts.otopi_net_host') | list }}
   69   - import_tasks: ../filter_team_devices.yml
   70   - import_tasks: ../filter_unsupported_vlan_devices.yml
   71   - name: Generate list of all unsupported network devices
   72     set_fact:
   73       invalid_net_if: "{{ invalid_vlan_if + team_if }}"
   74   - name: Filter unsupported interface types
   75     set_fact:
   76       otopi_host_net: "{{ host_net | difference(invalid_net_if) }}"
   77     register: otopi_host_net
   78   - name: Failed if only unsupported devices are available
   79     fail:
   80       msg: >-
   81         Only unsupported devices {{ invalid_net_if | join(', ') }} are present.
   82         Teaming and bond modes: Round Robin, TLB, ALB are unsupported.
   83         Supported VLAN naming convention is: VLAN_PARENT.VLAN_ID
   84         The following bond modes are supported: {{ acceptable_bond_modes }}
   85     when: (otopi_host_net.ansible_facts.otopi_host_net | length == 0)
   86   - name: Validate selected bridge interface if management bridge does not exist
   87     fail:
   88       msg: The selected network interface is not valid
   89     when:
   90       he_bridge_if not in otopi_host_net.ansible_facts.otopi_host_net and bridge_interface is not defined and
   91       not he_just_collect_network_interfaces
   92 ...