check_rhsm_version

Role Documentation

Welcome to the “check_rhsm_version” role documentation.

Role Defaults

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

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

# All variables within this role should have a prefix of "check_rhsm_version"
check_rhsm_version_debug: false

# subscription manager command used to retrieve the
# rhsm release. Parametrized mostly for testing
check_rhsm_version_command: subscription-manager release --show

# Version expected by the validation, if the configured RHSM version
# does not match the validation will fail.
check_rhsm_version_expected: '8.2'

Molecule Scenarios

Molecule is being used to test the “check_rhsm_version” 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
  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
  roles:
  - role: check_rhsm_version
    vars:
      check_rhsm_version_command: "echo 'Release: 8.2'"
      check_rhsm_version_expected: '8.2'

Scenario: rhsm_mismatch

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
  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 rhsm_mismatch playbook
- name: Converge
  hosts: all
  tasks:
  - name: detect wrong rhsm version
    block:
    - name: run validation with wrong rhsm version
      include_role:
        name: check_rhsm_version
      vars:
        check_rhsm_version_command: "echo 'Release: 8.4'"
        check_rhsm_version_expected: '8.2'
    rescue:
    - name: Clear host errors
      meta: clear_host_errors

    - name: Status message
      debug:
        msg: Detected RHSM version mismatch!

    - name: End play
      meta: end_play

  - name: Fail the test
    fail:
      msg: |
        The rhsm version mismatch should have detected but it wasn't..