check_network_gateway

Role Documentation

Welcome to the “check_network_gateway” role documentation.

Role Variables: main.yml

metadata:
  name: Check network_gateway on the provisioning network
  description: >
    If `gateway` in `undercloud.conf` is different from `local_ip`,
    verify that the gateway exists and is reachable.
  groups:
  - pre-introspection

Molecule Scenarios

Molecule is being used to test the “check_network_gateway” role. The following section highlights the drivers in service and provides an example playbook showing how the role is leveraged.

Scenario: default

Driver: podman
Molecule Platform(s)
- name: centos
  hostname: centos
  image: centos/centos:stream8
  registry:
    url: quay.io
  dockerfile: ../../../../.config/molecule/Dockerfile
  pkg_extras: python*setuptools python*-pyyaml iputils
  volumes:
  - /etc/ci/mirror_info.sh:/etc/ci/mirror_info.sh:ro
  privileged: true
  environment:
    http_proxy: "{{ lookup('env', 'http_proxy') }}"
    https_proxy: "{{ lookup('env', 'https_proxy') }}"
  ulimits:
  - host
Molecule Inventory
hosts:
  all:
    hosts:
      centos:
        ansible_python_interpreter: /usr/bin/python3
Example default playbook
- name: Converge
  hosts: all
  gather_facts: false
  tasks:
  - name: successful check with ctlplane-subnet
    include_role:
      name: check_network_gateway

  - name: override undercloud.conf
    copy:
      dest: '{{ ansible_env.HOME }}/undercloud.conf'
      content: |
        [DEFAULT]
        local_subnet = 192.168.254.0/24
        [192.168.254.0/24]
        gateway = 0.0.0.0

  - name: successful check with local_ip
    include_role:
      name: check_network_gateway

  - name: fail the validation
    block:
    - name: override undercloud.conf
      copy:
        dest: '{{ ansible_env.HOME }}/undercloud.conf'
        content: |
          [ctlplane-subnet]
          gateway = 192.168.254.254

    - name: run the validation
      include_role:
        name: check_network_gateway

    rescue:
    - name: Clear host error
      meta: clear_host_errors

    - name: Validation output
      debug:
        msg: The validation works! End the playbook run

    - name: End play
      meta: end_play

  - name: Fail the test
    fail:
      msg: |
        The check_network_gateway validation didn't properly detect faulty
        gateway!