check_uc_hostname

Check-uc-hostname
=================

Add Ansible role to check DockerInsecureRegistryAddress matches the UC hostname.

Requirements
------------

This role will be executed pre Overcloud Update, and post Update


Role Variables
--------------

* `check_uc_hostname_debug`: <'false'> -- debugging mode.
* `check_uc_hostname_containers`: <'{{ansible_env.HOME}}/containers-prepare-parameter.yaml'> -- Sets the default path to the `containers-prepare-parameters.yaml` file on the Undercloud.
* `check_uc_hostname_undercloud`: <'{{ ansible_env.HOME }}/undercloud.conf'> -- Sets the default path to the `undercloud.conf` file on the Undercloud.

Dependencies
------------

No Dependencies

Example Playbook
----------------

    - hosts: servers
      roles:
      - { role: check_uc_hostname, check_uc_hostname_debug: true }

License
-------

Apache

Author Information
------------------

Red Hat TripleO DFG:Upgrades

Role Documentation

Welcome to the “check_uc_hostname” role documentation.

Role Defaults

This section highlights all of the defaults and variables set within the “check_uc_hostname” role.

# All variables intended for modification should place placed in this file.

# All variables within this role should have a prefix of "check_uc_hostname"
check_uc_hostname_debug: false
check_uc_hostname_containers: '{{ ansible_env.HOME }}/containers-prepare-parameter.yaml'
check_uc_hostname_undercloud: '{{ ansible_env.HOME }}/undercloud.conf'

Molecule Scenarios

Molecule is being used to test the “check_uc_hostname” 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: ubi8
  hostname: ubi8
  image: ubi8/ubi-init
  registry:
    url: registry.access.redhat.com
  dockerfile: ../../../../.config/molecule/Dockerfile
  pkg_extras: python*-setuptools python*-pyyaml
  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:
      ubi8:
        ansible_python_interpreter: /usr/bin/python3
Example default playbook
- name: Converge
  hosts: all
  tasks:
  - name: Test working
    block:
    - include_role:
        name: check_uc_hostname
      vars:
        check_uc_hostname_undercloud: /tmp/undercloud.conf
        check_uc_hostname_containers: /tmp/containers-prepare-parameter.yaml

  - name: Test failing
    block:
    - name: populate undercloud.conf
      copy:
        dest: /tmp/undercloud.conf
        content: |
          [DEFAULT]
          undercloud_public_host = 192.168.24.2

    - include_role:
        name: check_uc_hostname
      vars:
        check_uc_hostname_undercloud: /tmp/undercloud.conf
        check_uc_hostname_containers: /tmp/containers-prepare-parameter.yaml

    rescue:
    - name: Clear host errors
      meta: clear_host_errors

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

    - name: End play
      meta: end_play

  - name: Fail the test
    fail:
      msg: |
        The check-uc-hostname validation failed to check that the hostnames
        did not match.