summaryrefslogtreecommitdiffstats
path: root/playbooks/init/validate_hostnames.yml
blob: b49f7dd08111b8b9c6aa4fc598381634a5a50c29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
---
- name: Validate node hostnames
  hosts: oo_nodes_to_config
  any_errors_fatal: true
  tasks:
  - name: Query DNS for IP address of {{ openshift.common.hostname }}
    shell:
      getent ahostsv4 {{ openshift.common.hostname }} | head -n 1 | awk '{ print $1 }'
    register: lookupip
    changed_when: false
    failed_when: false

  - name: Validate openshift_hostname when defined
    fail:
      msg: >
        The hostname {{ openshift.common.hostname }} for {{ ansible_nodename }}
        doesn't resolve to an IP address owned by this host. Please set
        openshift_hostname variable to a hostname that when resolved on the host
        in question resolves to an IP address matching an interface on this host.
        This will ensure proper functionality of OpenShift networking features.
        Inventory setting: openshift_hostname={{ openshift_hostname }}
        This check can be overridden by setting openshift_hostname_check=false in
        the inventory.
        See https://docs.openshift.org/latest/install_config/install/advanced_install.html#configuring-host-variables
    when:
    - lookupip.stdout != '127.0.0.1'
    - lookupip.stdout not in ansible_all_ipv4_addresses
    - openshift_hostname_check | default(true) | bool

  - name: Validate openshift_ip exists on node when defined
    fail:
      msg: >
        The IP address {{ openshift_ip }} does not exist on {{ ansible_nodename }}.
        Please set the openshift_ip variable to an IP address of this node.
        This will ensure proper functionality of OpenShift networking features.
        Inventory setting: openshift_ip={{ openshift_ip }}
        This check can be overridden by setting openshift_ip_check=false in
        the inventory.
        See https://docs.openshift.org/latest/install_config/install/advanced_install.html#configuring-host-variables
    when:
    - openshift_ip is defined
    - openshift_ip not in ansible_all_ipv4_addresses
    - openshift_ip_check | default(true) | bool