Role - 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.

check_uc_hostname_containers: '{{ ansible_env.HOME }}/containers-prepare-parameter.yaml'
check_uc_hostname_debug: false
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
Example default configuration
driver:
  name: podman
log: true
platforms:
- dockerfile: Dockerfile
  environment:
    http_proxy: '{{ lookup(''env'', ''http_proxy'') }}'
    https_proxy: '{{ lookup(''env'', ''https_proxy'') }}'
  hostname: ubi8
  image: ubi8/ubi-init
  name: ubi8
  pkg_extras: python*-setuptools python*-pyyaml
  privileged: true
  registry:
    url: registry.access.redhat.com
  ulimits:
  - host
  volumes:
  - /etc/ci/mirror_info.sh:/etc/ci/mirror_info.sh:ro
  - /etc/pki/rpm-gpg:/etc/pki/rpm-gpg
  - /opt/yum.repos.d:/etc/yum.repos.d:rw
provisioner:
  env:
    ANSIBLE_LIBRARY: ${ANSIBLE_LIBRARY:-/usr/share/ansible/plugins/modules}
    ANSIBLE_STDOUT_CALLBACK: yaml
  inventory:
    hosts:
      all:
        hosts:
          ubi8:
            ansible_python_interpreter: /usr/bin/python3
  log: true
  name: ansible
scenario:
  test_sequence:
  - destroy
  - create
  - prepare
  - converge
  - verify
  - destroy
verifier:
  name: testinfra
Molecule Inventory
hosts:
  all:
    hosts:
      ubi8:
        ansible_python_interpreter: /usr/bin/python3
Example default playbook
- hosts: all
  name: Converge
  tasks:
  - block:
    - include_role:
        name: check_uc_hostname
      vars:
        check_uc_hostname_containers: /tmp/containers-prepare-parameter.yaml
        check_uc_hostname_undercloud: /tmp/undercloud.conf
    name: Test working
  - block:
    - copy:
        content: '[DEFAULT]

          undercloud_public_host = 192.168.24.2

          '
        dest: /tmp/undercloud.conf
      name: populate undercloud.conf
    - include_role:
        name: check_uc_hostname
      vars:
        check_uc_hostname_containers: /tmp/containers-prepare-parameter.yaml
        check_uc_hostname_undercloud: /tmp/undercloud.conf
    name: Test failing
    rescue:
    - meta: clear_host_errors
      name: Clear host errors
    - debug:
        msg: The validation works! End the playbook run
    - meta: end_play
      name: End play
  - fail:
      msg: 'The check-uc-hostname validation failed to check that the hostnames

        did not match.

        '
    name: Fail the test