"Fossies" - the Fresh Open Source Software Archive

Member "ansible-6.1.0/ansible_collections/ovirt/ovirt/roles/hosted_engine_setup/tasks/bootstrap_local_vm/01_prepare_routing_rules.yml" (9 Jun 2022, 4020 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. See also the last Fossies "Diffs" side-by-side code changes report for "01_prepare_routing_rules.yml": 5.9.0_vs_6.0.0.

    1 ---
    2 - name: Prepare routing rules
    3   block:
    4   - name: Check IPv6
    5     set_fact:
    6       ipv6_deployment: >-
    7         {{ true if he_host_ip not in target_address_v4.stdout_lines and
    8         he_host_ip in target_address_v6.stdout_lines
    9         else false }}
   10   - include_tasks: ../validate_ip_prefix.yml
   11   - include_tasks: ../alter_libvirt_default_net_configuration.yml
   12   # all of the next is a workaround for a network issue:
   13   # vdsm installation breaks the routing by defining separate
   14   # routing table for ovirtmgmt. But we need to enable communication
   15   # between virbr0 and ovirtmgmt
   16   - name: Start libvirt
   17     service:
   18       name: libvirtd
   19       state: started
   20       enabled: true
   21   - name: Activate default libvirt network
   22     command: virsh net-autostart default
   23     ignore_errors: true
   24     changed_when: false
   25   - name: Get routing rules, IPv4
   26     command: ip -j rule
   27     environment: "{{ he_cmd_lang }}"
   28     register: route_rules_ipv4
   29     changed_when: true
   30   - name: Get routing rules, IPv6
   31     command: ip -6 rule
   32     environment: "{{ he_cmd_lang }}"
   33     register: route_rules_ipv6
   34     changed_when: true
   35     when: ipv6_deployment|bool
   36   - name: Save bridge name
   37     set_fact:
   38       virbr_default: "{{ network_dict['bridge']['name'] }}"
   39   - name: Wait for the bridge to appear on the host
   40     command: ip link show {{ virbr_default }}
   41     environment: "{{ he_cmd_lang }}"
   42     changed_when: true
   43     register: ip_link_show_bridge
   44     until: ip_link_show_bridge.rc == 0
   45     retries: 30
   46     delay: 3
   47   - name: Accept IPv6 Router Advertisements for {{ virbr_default }}
   48     shell: echo 2 > /proc/sys/net/ipv6/conf/{{ virbr_default }}/accept_ra
   49     when: ipv6_deployment|bool
   50   - name: Refresh network facts
   51     setup:
   52     tags: ['skip_ansible_lint']
   53   - name: Fetch IPv4 CIDR for {{ virbr_default }}
   54     set_fact:
   55       virbr_cidr_ipv4: >-
   56         {{ (hostvars[inventory_hostname]['ansible_'+virbr_default]['ipv4']['address']+'/'
   57         +hostvars[inventory_hostname]['ansible_'+virbr_default]['ipv4']['netmask']) |ipv4('host/prefix') }}
   58     when: not ipv6_deployment|bool
   59   - name: Fetch IPv6 CIDR for {{ virbr_default }}
   60     set_fact:
   61       virbr_cidr_ipv6: >-
   62         {{ (hostvars[inventory_hostname]['ansible_'+virbr_default]['ipv6'][0]['address']+'/'+
   63         hostvars[inventory_hostname]['ansible_'+virbr_default]['ipv6'][0]['prefix']) |
   64         ipv6('host/prefix') if 'ipv6' in hostvars[inventory_hostname]['ansible_'+virbr_default] else None }}
   65     when: ipv6_deployment|bool
   66   - name: Add IPv4 outbound route rules
   67     command: ip rule add from {{ virbr_cidr_ipv4 }} priority 101 table main
   68     environment: "{{ he_cmd_lang }}"
   69     register: result
   70     when: >-
   71       not ipv6_deployment|bool and
   72       route_rules_ipv4.stdout | from_json |
   73       selectattr('priority', 'equalto', 101) |
   74       selectattr('src', 'equalto', virbr_cidr_ipv4 | ipaddr('address') ) |
   75       list | length == 0
   76     changed_when: true
   77   - name: Add IPv4 inbound route rules
   78     command: ip rule add from all to {{ virbr_cidr_ipv4 }} priority 100 table main
   79     environment: "{{ he_cmd_lang }}"
   80     register: result
   81     changed_when: true
   82     when: >-
   83       not ipv6_deployment|bool and
   84       route_rules_ipv4.stdout | from_json |
   85       selectattr('priority', 'equalto', 100) |
   86       selectattr('dst', 'equalto', virbr_cidr_ipv4 | ipaddr('address') ) |
   87       list | length == 0
   88   - name: Add IPv6 outbound route rules
   89     command: ip -6 rule add from {{ virbr_cidr_ipv6 }} priority 101 table main
   90     environment: "{{ he_cmd_lang }}"
   91     register: result
   92     when: ipv6_deployment|bool and "\"101:\tfrom \"+virbr_cidr_ipv6+\" lookup main\" not in route_rules_ipv6.stdout"
   93     changed_when: true
   94   - name: Add IPv6 inbound route rules
   95     command: ip -6 rule add from all to {{ virbr_cidr_ipv6 }} priority 100 table main
   96     environment: "{{ he_cmd_lang }}"
   97     register: result
   98     changed_when: true
   99     when: >-
  100       ipv6_deployment|bool and "\"100:\tfrom all to \"+virbr_cidr_ipv6+\" lookup main\" not in route_rules_ipv6.stdout"