package_version

Role Documentation

Welcome to the “package_version” role documentation.

Role Variables: redhat-8.yml

package_version_packages:
- name: podman
  version: 1.6.4-15.module+el8.2.0+7290+954fb593
  comparison: ==
  state: installed

Role Variables: centos.yml

package_version_packages: []

Molecule Scenarios

Molecule is being used to test the “package_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
  gather_facts: false

  tasks:
  - name: Check a simple existing package
    vars:
      package_version_packages:
      - name: bash
        version: 1.0
        comparison: '>='
        state: installed
    include_role:
      name: package_version

  - name: Ensure we fail if something is wrong
    vars:
      package_version_packages:
      - name: bash
        version: 1.0
        comparison: <
        state: available
    block:
    - name: Run check
      include_role:
        name: package_version
    rescue:
    - name: Clear host errors
      meta: clear_host_errors

    - name: Test output
      debug:
        msg: The validation works! End play

    - name: End play
      meta: end_play

  - name: Fail playbook if reached
    fail:
      msg: |
        The package_version validation didn't properly detect the failure!