"Fossies" - the Fresh Open Source Software Archive

Member "ansible-6.1.0/ansible_collections/ovirt/ovirt/roles/hosted_engine_setup/tasks/pre_checks/002_validate_hostname_tasks.yml" (9 Jun 2022, 4732 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: Choose IPv4, IPv6 or auto
    3   import_tasks: ipv_switch.yml
    4 - name: Define he_host_address and he_host_ip
    5   import_tasks: fetch_host_ip.yml
    6   when: he_host_ip is none or he_host_address is none
    7 
    8 - name: Validate host hostname
    9   block:
   10     - name: Avoid localhost
   11       fail:
   12         msg: >
   13           localhost is not a valid address
   14       when: he_host_address in ['localhost', 'localhost.localdomain']
   15     - name: Ensure host address resolves locally
   16       fail:
   17         msg: >
   18           The address proposed for this host does not resolves locally
   19       when: he_host_ip not in ansible_all_ipv4_addresses | union(ansible_all_ipv6_addresses)
   20     - name: Ensure the resolved address resolves on the selected interface
   21       block:
   22         - name: Get target address from selected interface (IPv4)
   23           shell: >-
   24             ip addr show
   25             {{ he_mgmt_network
   26             if 'ansible_' + he_mgmt_network.replace('-','_') in hostvars[inventory_hostname]
   27             else he_bridge_if }} |
   28             grep 'inet ' |
   29             cut -d' ' -f6 |
   30             cut -d'/' -f1
   31           register: target_address_v4
   32           changed_when: true
   33         - debug: var=target_address_v4
   34         - name: Get target address from selected interface (IPv6)
   35           shell: >-
   36             ip addr show
   37             {{ he_mgmt_network
   38             if 'ansible_' + he_mgmt_network.replace('-','_') in hostvars[inventory_hostname]
   39             else he_bridge_if }} |
   40             grep 'inet6 ' |
   41             cut -d' ' -f6 |
   42             cut -d'/' -f1
   43           register: target_address_v6
   44           changed_when: true
   45         - debug: var=target_address_v6
   46         - name: Check the resolved address resolves on the selected interface
   47           fail:
   48             msg: >
   49               The resolved address doesn't resolve
   50               on the selected interface
   51           when: >-
   52             he_host_ip not in target_address_v4.stdout_lines and
   53             he_host_ip not in target_address_v6.stdout_lines
   54         - name: Check for alias
   55           shell: getent {{ ip_key }} {{ he_host_address }} | cut -d' ' -f1 | uniq
   56           register: hostname_res_count_output
   57           changed_when: true
   58           ignore_errors: true
   59         - debug: var=hostname_res_count_output
   60         - name: Filter resolved address list
   61           set_fact:
   62             hostname_res_count_output_filtered: >-
   63               {{ hostname_res_count_output.stdout_lines |
   64               difference(target_address_v6.stdout_lines) |
   65               difference(target_address_v4.stdout_lines) }}
   66         - name: Ensure the resolved address resolves only on the selected interface
   67           fail:
   68             msg: >
   69               hostname '{{ he_host_address }}' doesn't uniquely match the interface
   70               '{{ he_bridge_if }}' selected for the management bridge;
   71               it matches also interface with IP {{ hostname_res_count_output.stdout_lines |
   72               difference([he_host_ip,]) }}.
   73               Please make sure that the hostname got from
   74               the interface for the management network resolves
   75               only there.
   76           when: hostname_res_count_output_filtered|length > 0
   77       when: he_bridge_if is defined and he_bridge_if is not none and he_mgmt_network is defined
   78   when: he_host_address is defined and he_host_address is not none
   79 - name: Validate engine he_fqdn
   80   block:
   81     - name: Avoid localhost
   82       fail:
   83         msg: >
   84           localhost is not a valid he_fqdn for the engine VM
   85       when: he_fqdn in ['localhost', 'localhost.localdomain']
   86     - name: Get engine FQDN resolution
   87       shell: getent {{ ip_key }} {{ he_fqdn }} | grep STREAM
   88       environment: "{{ he_cmd_lang }}"
   89       register: fqdn_resolution_output
   90       changed_when: true
   91       ignore_errors: true
   92     - name: Check engine he_fqdn resolution
   93       fail:
   94         msg: >
   95           Unable to resolve address
   96       when: fqdn_resolution_output.rc != 0
   97     - name: Parse engine he_fqdn resolution
   98       set_fact:
   99         r_fqdn_address: "{{ fqdn_resolution_output.stdout.split()[0] }}"
  100     - name: Ensure engine he_fqdn doesn't resolve locally
  101       fail:
  102         msg: >
  103           The he_fqdn proposed for the engine VM resolves on this host
  104       when: r_fqdn_address in ansible_all_ipv4_addresses | union(ansible_all_ipv6_addresses)
  105     - name: Check http/https proxy
  106       fail:
  107         msg: >
  108           Your system is configured to use a proxy, please
  109           add an exception for {{ url }} with no_proxy directive.
  110       when: url is ovirt.ovirt.proxied
  111       loop_control:
  112         loop_var: url
  113       with_items:
  114         - "http://{{ he_fqdn }}/"
  115         - "https://{{ he_fqdn }}/"
  116   when: he_fqdn is defined and he_fqdn is not none