From 15ceacf95b20376d95470a0caa77d8ffcca78fe6 Mon Sep 17 00:00:00 2001 From: Petr Šplíchal Date: Nov 03 2017 11:17:31 +0000 Subject: Support for installing required packages on Atomic It seems the need for installing extra packages to satisfy test dependencies is quite common. Despite using rpm-ostree is probably not a completely clear solution I believe we should make this option available for cases when it's really needed. This commit adds support to the beakerlib role and adjusts docs accordingly. --- diff --git a/roles/standard-test-beakerlib/README.md b/roles/standard-test-beakerlib/README.md index 3c9ff94..33dc0f4 100644 --- a/roles/standard-test-beakerlib/README.md +++ b/roles/standard-test-beakerlib/README.md @@ -12,5 +12,8 @@ roles/standard-test-beakerlib/vars/main.yml: where the logs are stored. Note: if this variable is left undefined, it will default to /tmp/artifacts * required_packages: A list of prerequisite packages required by - beakerlib tests. Note: will be disregarded on Atomic Host, etc. - where additional packages can't be installed + beakerlib tests. Please note that for Atomic Host, additional + packages will be installed using the rpm-ostree command which + is affecting the test subject (it's similar as rebuilding an + rpm package to be tested) so this should be used with caution + and only when necessary. diff --git a/roles/standard-test-beakerlib/tasks/main.yml b/roles/standard-test-beakerlib/tasks/main.yml index f6c6df1..340f92c 100644 --- a/roles/standard-test-beakerlib/tasks/main.yml +++ b/roles/standard-test-beakerlib/tasks/main.yml @@ -46,6 +46,23 @@ # Only manually install packages on non atomic hosts when: ansible_pkg_mgr != 'unknown' +- block: + - name: Check packages required by the test (atomic) + shell: rpm -q {{ required_packages|join(" ") }} + register: package_check + changed_when: no + failed_when: no + args: { warn: no } + + - name: Install packages required by the test (atomic) + shell: + rpm-ostree install {{ required_packages|join(" ") }} + && rpm-ostree ex livefs + when: package_check.rc != 0 + + tags: atomic + when: required_packages.0 is defined + - name: Define remote_artifacts if it is not already defined set_fact: remote_artifacts: /tmp/artifacts