image_serve

Role Documentation

Welcome to the “image_serve” role documentation.

Role Variables: main.yml

metadata:
  name: Image-serve availability
  description: Verify that image-serve service is ready
  groups:
  - pre-upgrade
  - pre-update
  - post-deployment
  - post-upgrade
  - post-update

Molecule Scenarios

Molecule is being used to test the “image_serve” 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
  etc_hosts:
    undercloud.ctlplane.mydomain.tld: 127.0.0.1
  dockerfile: ../../../../.config/molecule/Dockerfile
  override_command: true
  command: /sbin/init
  privileged: true
  pkg_extras: python*-setuptools
  volumes:
  - /etc/ci/mirror_info.sh:/etc/ci/mirror_info.sh:ro
  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: detect wrong port
    block:
    - name: run validation for wrong port
      include_role:
        name: image_serve
      vars:
        container_registry_port: 9999
    rescue:
    - name: Clear host errors
      meta: clear_host_errors

    - name: Status message
      debug:
        msg: Detected faulty port!

  - name: Run validation for wrong config file
    block:
    - name: Run validation for wrong config file
      include_role:
        name: image_serve
      vars:
        container_registry_httpd_config: /fake-image-serve.conf
    rescue:
    - name: Clear host errors
      meta: clear_host_errors

    - name: Status message
      debug:
        msg: Detected wrong config file!

  - name: Ensure we detect faulty tree
    block:
    - name: Stopping httpd
      systemd:
        name: httpd
        state: stopped

    - name: run validation for 404
      include_role:
        name: image_serve
    rescue:
    - name: Clear host errors
      meta: clear_host_errors

    - name: Status message
      debug:
        msg: Detected faulty image serve tree!

    - name: End play
      meta: end_play

  - name: Fail the test
    fail:
      msg: |
        The image_serve role should have detected httpd wasn't running or
        index.json is absent.