From aeb9d2145e86cdfc60419eb72c74380e2a8a976c Mon Sep 17 00:00:00 2001 From: shnee Date: Mon, 2 May 2022 14:20:17 -0400 Subject: [PATCH] molecule tests working for ubuntu and centos 8. - Currently the ubuntu images is a generic image that's actually 19.04. This image will be updated. --- molecule/default/molecule.yml | 6 +++++- molecule/default/verify.yml | 33 ++++++++++++++++++++++++--------- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index b5d8023..cdb3534 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -4,9 +4,13 @@ dependency: driver: name: docker platforms: - - name: instance + - name: centos-8-stream image: quay.io/centos/centos:stream8 pre_build_image: true + - name: ubuntu + # TODO This is only a temporary measure until we get a better image. + image: tanquetav/ubuntu-ansible:latest + pre_build_image: true provisioner: name: ansible verifier: diff --git a/molecule/default/verify.yml b/molecule/default/verify.yml index f527253..4b9afcf 100644 --- a/molecule/default/verify.yml +++ b/molecule/default/verify.yml @@ -3,15 +3,30 @@ - name: Verify hosts: all - gather_facts: false + vars: + + # exp_vals is dict where each top-level field corresponds to the name of the + # of the platforms defined in molecule.yml. The key-value pairs under the + # top-level will be used to test against the values in os_release. + exp_vals: + ubuntu: + ID: ubuntu + ID_LIKE: debian + VERSION_ID: '19.04' + centos-8-stream: + ID: centos + ID_LIKE: rhel fedora + VERSION_ID: '8' + roles: - shnee.os_release + tasks: - - name: Example assertion - debug: - var: os_release - - name: Verify that os-release match our expected values. - assert: - that: - - os_release.ID == 'centos' - - os_release.ID_LIKE == 'rhel fedora' + + - name: Is the OS in exp_vals? + assert: + that: exp_vals[ansible_hostname] is defined + - name: Verify that os-release matches our expected values. + assert: + that: os_release[item.key] == item.value + loop: "{{ exp_vals[ansible_hostname] | dict2items }}"