check_kernel_version¶
Role Documentation¶
Welcome to the “check_kernel_version” role documentation.
Role Defaults¶
This section highlights all of the defaults and variables set within the “check_kernel_version” role.
check_kernel_version_fact: '{{ ansible_facts.kernel }}'
check_kernel_version_expected: el8
Molecule Scenarios¶
Molecule is being used to test the “check_kernel_version” role. The following section highlights the drivers in service and provides an example playbook showing how the role is leveraged.
- Driver: podman:
Scenario: default¶
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: true
tasks:
- name: validate correct kernel version
include_role:
name: check_kernel_version
- name: detect wrong kernel version
block:
- name: run validation against wrong kernel version
include_role:
name: check_kernel_version
vars:
check_kernel_version_fact: 4.18.0-193.14.2.el7_2.x86_64
rescue:
- name: Clear host errors
meta: clear_host_errors
- name: Status message
debug:
msg: Detected kernel version mismatch!
- name: End play
meta: end_play
- name: Fail the test
fail:
msg: |
The kernel version mismatch should have been detected but it wasn't.