From 49210c2101f99b90ebd3edc40b6a8a10b246a8ee Mon Sep 17 00:00:00 2001 From: Andrei Stepanov Date: May 07 2018 09:25:55 +0000 Subject: Remove copr rhts. Signed-off-by: Andrei Stepanov --- diff --git a/inventory/standard-inventory-qcow2 b/inventory/standard-inventory-qcow2 index 10cfd3b..06d4bde 100755 --- a/inventory/standard-inventory-qcow2 +++ b/inventory/standard-inventory-qcow2 @@ -127,7 +127,7 @@ def start_qemu(image, cloudinit, log, portrange=(2222, 5555)): "-net", "nic,model=virtio", "-net", "user,hostfwd=tcp:127.0.0.3:{0}-:22".format(port), "-device", "virtio-rng-pci", "-rtc", "base=utc", "-device", "isa-serial,chardev=pts2", "-chardev", "file,id=pts2,path=" + log, - "-display", "none"], stdout=open(log, 'a'), stderr=subprocess.STDOUT), port + "-display", "none", "-vnc", ":1"], stdout=open(log, 'a'), stderr=subprocess.STDOUT), port def inv_host(image): diff --git a/roles/standard-test-basic/defaults/main.yml b/roles/standard-test-basic/defaults/main.yml new file mode 100644 index 0000000..2abd1ec --- /dev/null +++ b/roles/standard-test-basic/defaults/main.yml @@ -0,0 +1,3 @@ +# This care about this lists will take str-common-init +role_pkgs_req: + - rsync diff --git a/roles/standard-test-basic/meta/main.yml b/roles/standard-test-basic/meta/main.yml index a113e4e..f6d273c 100644 --- a/roles/standard-test-basic/meta/main.yml +++ b/roles/standard-test-basic/meta/main.yml @@ -1,4 +1,4 @@ --- dependencies: - - role: str-common + - role: str-common-init diff --git a/roles/standard-test-basic/tasks/main.yml b/roles/standard-test-basic/tasks/main.yml index 354ac99..e5597da 100644 --- a/roles/standard-test-basic/tasks/main.yml +++ b/roles/standard-test-basic/tasks/main.yml @@ -47,13 +47,18 @@ with_items: - "{{ tests }}" - - include_role: - name: str-common - tasks_from: end.yml - # Can't go in block. See # https://github.com/ansible/ansible/issues/20736 - name: Check the results shell: grep "^FAIL" {{ remote_artifacts }}/test.log register: test_fails - failed_when: test_fails.stdout or test_fails.stderr + # Never fail at this step. Just store result of tests. + failed_when: False + + - name: Set role result + set_fact: + role_result_failed: "{{ (test_fails.stdout|d|length > 0) or (test_fails.stderr|d|length > 0) }}" + role_result_msg: "{{ test_fails.stdout|d('tests failed.') }}" + + - include_role: + name: str-common-final diff --git a/roles/standard-test-beakerlib/defaults/main.yml b/roles/standard-test-beakerlib/defaults/main.yml index 02a43f4..d51fb71 100644 --- a/roles/standard-test-beakerlib/defaults/main.yml +++ b/roles/standard-test-beakerlib/defaults/main.yml @@ -6,3 +6,12 @@ beakerlib_pkgs_req: centos_7: *rhel_7 fedora: - python2-lxml + +# This care about this lists will take str-common-init +role_pkgs_req: + - beakerlib + - rsync + - make + - libselinux-python + - "{{ beakerlib_pkgs_req[distro_name_ver] | default([]) }}" + - "{{ beakerlib_pkgs_req[distro_name] | default([]) }}" diff --git a/roles/standard-test-beakerlib/files/rhts-environment.sh b/roles/standard-test-beakerlib/files/rhts-environment.sh new file mode 100755 index 0000000..43a2bf2 --- /dev/null +++ b/roles/standard-test-beakerlib/files/rhts-environment.sh @@ -0,0 +1,49 @@ +#!/bin/bash +# Copyright (c) 2006 Red Hat, Inc. All rights reserved. This copyrighted material +# is made available to anyone wishing to use, modify, copy, or +# redistribute it subject to the terms and conditions of the GNU General +# Public License v.2. +# +# This program is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Authors: Bill Peck + +if [ -z "$OUTPUTFILE" ]; then + export OUTPUTFILE=`mktemp /mnt/testarea/tmp.XXXXXX` +fi + +if [ -z "$ARCH" ]; then + ARCH=$(uname -i) +fi + +if [ -z "$FAMILY" ]; then + FAMILY=$(cat /etc/redhat-release | sed -e 's/\(.*\)release\s\([0-9]*\).*/\1\2/; s/\s//g') +fi + +function report_result { + # Pass OUTPUTFILE to rstrnt-report-result in case the variable wasn't exported + # astepano@ : Not implemented for standard-test-roles + #OUTPUTFILE=$OUTPUTFILE rstrnt-report-result "$@" + : +} + +function runuser_ { + $(which runuser 2>/dev/null || which /sbin/runuser 2>/dev/null || echo /bin/su) "$@" +} + +function runas_ { + local user=$1 cmd=$2 + if [ -n "$user" ]; then + echo "As $user: " + HOME=$(eval "echo ~$user") LOGNAME=$user USER=$user runuser_ -m -c "$cmd" $user + else + echo "As $(whoami): " + $cmd + fi +} diff --git a/roles/standard-test-beakerlib/files/rhts-make.include b/roles/standard-test-beakerlib/files/rhts-make.include new file mode 100755 index 0000000..4da74cf --- /dev/null +++ b/roles/standard-test-beakerlib/files/rhts-make.include @@ -0,0 +1,32 @@ +#!/bin/bash +# Copyright (c) 2006 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +# Author: Greg Nichols +# Author: Bill Peck + +# +# rhts-make.include +# +# Stripped everything but the basics so rhts tests can run. +# + +# This file was copied to STR from restraint-rhts RPM. + +# Common Variables. +TEST_DIR=/mnt/tests$(TEST) +INSTALL_DIR=$(DEST)$(TEST_DIR) +METADATA=testinfo.desc + diff --git a/roles/standard-test-beakerlib/meta/main.yml b/roles/standard-test-beakerlib/meta/main.yml index a113e4e..4ce0693 100644 --- a/roles/standard-test-beakerlib/meta/main.yml +++ b/roles/standard-test-beakerlib/meta/main.yml @@ -1,4 +1,9 @@ --- +# Before this run: +# If roles/x/vars/main.yml exists, variables listed therein will be added to the play. +# If roles/x/defaults/main.yml exists, variables listed therein will be added to the play. +# https://docs.ansible.com/ansible/2.5/user_guide/playbooks_reuse_roles.html + dependencies: - - role: str-common + - role: str-common-init diff --git a/roles/standard-test-beakerlib/tasks/main.yml b/roles/standard-test-beakerlib/tasks/main.yml index 97b1bb2..8c6f122 100644 --- a/roles/standard-test-beakerlib/tasks/main.yml +++ b/roles/standard-test-beakerlib/tasks/main.yml @@ -1,81 +1,49 @@ --- -- delegate_to: "{{ test_runner_inventory_name }}" - block: - - name: Add restraint repo for restraint-rhts using DNF - block: - - package: name=dnf-plugins-core state=present - - shell: dnf copr enable -y bpeck/restraint - ignore_errors: True - when: "hostvars[test_runner_inventory_name]['is_dnf_os'] | bool" - - - name: Add restraint repo for restraint-rhts using YUM - block: - - package: name=yum-plugin-copr - - shell: yum copr -y enable bpeck/restraint - ignore_errors: True - when: "hostvars[test_runner_inventory_name]['is_yum_os'] | bool" - - - name: Install the beakerlib requirements - package: name={{item}} state=present - with_items: - - beakerlib - - restraint-rhts - - rsync - - debug: msg: > 1 req pkgs for: {{ distro_name }}: {{ beakerlib_pkgs_req[distro_name] | default([]) }} 2 req pkgs for: {{ distro_name_ver }}: {{ beakerlib_pkgs_req[distro_name_ver] | default([]) }} verbosity: 1 -- name: Install the beakerlib requirements to test environment - package: name={{item}} state=latest - with_flattened: - - - rsync - - findutils - - make - - libselinux-python - - "{{ beakerlib_pkgs_req[distro_name_ver] | default([]) }}" - - "{{ beakerlib_pkgs_req[distro_name] | default([]) }}" - when: not is_atomic +- name: Turn on usroverlay for Atomic Host + when: is_atomic + # This is dirty hack. It was made as temporary solution. + command: rpm-ostree usroverlay -- name: Put beakerlib binaries to test environment +- name: Put beakerlib binaries to test environment Atomic Host + when: is_atomic copy: src: "{{ item }}" dest: "{{ tenv_workdir }}" mode: 755 with_fileglob: - - "/usr/bin/beakerlib-*" - - "/usr/share/beakerlib/*" - - "/usr/bin/rhts-*" - - "/usr/share/rhts/*" - - "/usr/share/rhts/lib/*" - - "/usr/bin/rstrnt-*" - - "/usr/share/restraint/*" - "rpm.py" +- name: Copy rhts files to test environment /usr/share/rhts/lib + copy: + src: "{{ item }}" + dest: "/usr/share/rhts/lib/" + mode: 755 + force: no + with_fileglob: + - "rhts-make.include" + +- name: Copy rhts files to test environment /bin + copy: + src: "{{ item }}" + dest: "/usr/bin/" + mode: 755 + force: no + with_fileglob: + - "rhts-environment.sh" + - name: Copy tests to test environment synchronize: src: "{{ playbook_dir }}/" dest: "{{ tenv_workdir }}" ssh_args: "-o UserKnownHostsFile=/dev/null" -- name: Fix up beakerlib at tests environment - shell: > - find {{ tenv_workdir }} -type f - | - xargs sed -i - -e 's|/usr/share/beakerlib|{{ tenv_workdir }}|g' - -e 's|/usr/lib/beakerlib|{{ tenv_workdir }}|g' - -e 's|/usr/share/rhts/lib/rhts-|{{ tenv_workdir }}/rhts-|g' - -e 's|/usr/bin/rhts-|{{ tenv_workdir }}/rhts-|g' - -e 's|/usr/share/rhts/lib/rhts_|{{ tenv_workdir }}/rhts-|g' - -e 's|/usr/bin/rhts_|{{ tenv_workdir }}/rhts-|g' - -e 's|/usr/share/rhts-library/rhtslib.sh|{{ tenv_workdir }}/beakerlib.sh|g' - -e 's|/usr/bin/rstrnt-|{{ tenv_workdir }}/rstrnt-|g' - - - block: - name: Run beakerlib tests shell: | @@ -124,13 +92,18 @@ with_items: - "{{ tests }}" - - include_role: - name: str-common - tasks_from: end.yml - # Can't go in block. See # https://github.com/ansible/ansible/issues/20736 - name: Check the results shell: grep "^FAIL" {{ remote_artifacts }}/test.log register: test_fails - failed_when: test_fails.stdout or test_fails.stderr + # Never fail at this step. Just store result of tests. + failed_when: False + + - name: Set role result + set_fact: + role_result_failed: "{{ (test_fails.stdout|d|length > 0) or (test_fails.stderr|d|length > 0) }}" + role_result_msg: "{{ test_fails.stdout|d('Beaker tests failed.') }}" + + - include_role: + name: str-common-final diff --git a/roles/str-common-final/tasks/main.yml b/roles/str-common-final/tasks/main.yml new file mode 100644 index 0000000..53989d4 --- /dev/null +++ b/roles/str-common-final/tasks/main.yml @@ -0,0 +1,18 @@ +--- + +- name: Pull out the logs from test environment to test runner + synchronize: + dest: "{{ artifacts }}/" + src: "{{ remote_artifacts }}/" + mode: pull + ssh_args: "-o UserKnownHostsFile=/dev/null" + when: artifacts|default("") != "" + +- name: Report role result + vars: + msg: | + Tests failed: {{ role_result_failed|d('Undefined') }} + Tests msg: {{ role_result_msg|d('None') }} + debug: + msg: "{{ msg.split('\n') }}" + failed_when: "role_result_failed|bool" diff --git a/roles/str-common-init/defaults/main.yml b/roles/str-common-init/defaults/main.yml new file mode 100644 index 0000000..9981d95 --- /dev/null +++ b/roles/str-common-init/defaults/main.yml @@ -0,0 +1,12 @@ +--- + +tests: [] +required_packages: [] +tenv_workdir: /var/str/ +remote_artifacts: /tmp/artifacts/ +test_runner_inventory_name: test-runner +artifacts: "{{ lookup('env', 'TEST_ARTIFACTS')|default('./artifacts', true) }}" +# distro_name: rhel, centos, fedora +distro_name: "{{ansible_distribution|lower}}" +# distro_name_ver: rhel_7, centos_7, fedora_22 +distro_name_ver: "{{ansible_distribution|lower}}_{{ansible_distribution_major_version}}" diff --git a/roles/str-common-init/tasks/inspect.yml b/roles/str-common-init/tasks/inspect.yml new file mode 100644 index 0000000..74d7a86 --- /dev/null +++ b/roles/str-common-init/tasks/inspect.yml @@ -0,0 +1,35 @@ +- block: + - name: Check if system is Atomic Host + lineinfile: + name: /etc/os-release + regexp: .*Atomic Host.* + state: absent + check_mode: yes + changed_when: False + register: os_release_atomic + - name: Set fact 'is_atomic' + delegate_facts: True + set_fact: + is_atomic : "{{ os_release_atomic.found > 0 }}" + +- name: Set facts about system + delegate_facts: True + set_fact: + is_yum_os: >- + {{ ansible_pkg_mgr == 'yum' }} + is_dnf_os: >- + {{ ansible_pkg_mgr == 'dnf' }} + is_rhel8_based: >- + {{ + ( ['ansible_distribution'] | + intersect(['RedHat', 'CentOS']) | bool ) and + ansible_distribution_version|int == 8 + }} + +# Fix python ansible interpreter when running on RHEL8. Currently RHEL8 +# uses python2, but it does miss some python2 modules, such as python2-dnf. +# This can be removed once RHEL8 uses by default Python3 +- name: Hardcode Python interpreter for ansible modules on RHEL8 based OS + set_fact: + ansible_python_interpreter: /usr/bin/env python3 + when: is_rhel8_based diff --git a/roles/str-common-init/tasks/main.yml b/roles/str-common-init/tasks/main.yml new file mode 100644 index 0000000..f259710 --- /dev/null +++ b/roles/str-common-init/tasks/main.yml @@ -0,0 +1,26 @@ +- import_tasks: inspect.yml + +- debug: + msg: "System uses yum: {{ is_yum_os }}" + verbosity: 1 + +- debug: + msg: "System uses dnf: {{ is_dnf_os }}" + verbosity: 1 + +- debug: + msg: "System is Atomic Host: {{ is_atomic }}" + verbosity: 1 + +- import_tasks: trunner.yml +- import_tasks: pkgs.yml + +- name: Make artifacts directory + file: path={{ remote_artifacts }} state=directory owner=root mode=755 recurse=yes + +# Next task requires rsync on test environment +- name: Copy tests to test environment + synchronize: + src: "{{ playbook_dir }}/" + dest: "{{ tenv_workdir }}" + ssh_args: "-o UserKnownHostsFile=/dev/null" diff --git a/roles/str-common-init/tasks/pkgs-dnf.yml b/roles/str-common-init/tasks/pkgs-dnf.yml new file mode 100644 index 0000000..a030c16 --- /dev/null +++ b/roles/str-common-init/tasks/pkgs-dnf.yml @@ -0,0 +1,33 @@ +- name: Install test-specific package requirements + # Note, this method cannot install -debuginfo packages. + package: name={{item}} state=present + with_flattened: + - "{{ pkgs_ordinary_req|d|list|flatten }}" + - "{{ role_pkgs_req|d|list|flatten }}" + +- name: Install the common requirements on target + package: name={{item}} state=present + with_items: + - rsync # needed to copy tests to target + +- block: + - name: Install dnf-utils + # System can have installed yum-utils. Which conflicts wih dnf-utils. + # Therefore, remove yum-utils and install dnf-utils. + shell: dnf --assumeyes --allowerasing install dnf-utils + when: ansible_pkg_mgr == "dnf" + + - name: Install debuginfo packages + shell: | + debuginfo-install --assumeyes {{item}} + with_items: + - "{{ pkgs_debuginfo_req|d|list }}" + +- block: + - package: name=dnf-plugins-core state=present + - shell: dnf copr enable -y {{item}} + with_items: + - "{{copr_repos}}" + name: Enable copr repos using DNF + ignore_errors: True + when: copr_repos is defined diff --git a/roles/str-common-init/tasks/pkgs-rpm-ostree.yml b/roles/str-common-init/tasks/pkgs-rpm-ostree.yml new file mode 100644 index 0000000..3bbb099 --- /dev/null +++ b/roles/str-common-init/tasks/pkgs-rpm-ostree.yml @@ -0,0 +1,20 @@ +- block: + - name: Make a list of requested packages for Atomic Host + set_fact: + pkgs_atomic_req: "{{ pkgs_ordinary_req|d|flatten|join(' ') }} {{ role_pkgs_req|d|list|flatten|join(' ') }}" + - debug: + msg: "Requested packages for Atomic Host: {{ pkgs_atomic_req }}" + verbosity: 1 + - name: Check presence of test-specific package requirements + shell: rpm -q {{ pkgs_atomic_req }} + register: package_check + changed_when: False + failed_when: False + args: { warn: no } + - name: Install test-specific package requirements + shell: + rpm-ostree install {{ pkgs_atomic_req }} + && rpm-ostree ex livefs + when: package_check.rc != 0 + when: (pkgs_ordinary_req|d(false)) or + (role_pkgs_req|d(false)) diff --git a/roles/str-common-init/tasks/pkgs-yum.yml b/roles/str-common-init/tasks/pkgs-yum.yml new file mode 100644 index 0000000..f1c9060 --- /dev/null +++ b/roles/str-common-init/tasks/pkgs-yum.yml @@ -0,0 +1,31 @@ +- name: Install test-specific package requirements + # Note, this method cannot install -debuginfo packages. + package: name={{item}} state=present + with_flattened: + - "{{ pkgs_ordinary_req|d|list|flatten }}" + - "{{ role_pkgs_req|d|list|flatten }}" + +- name: Install the common requirements on target + package: name={{item}} state=present + with_items: + - rsync # needed to copy tests to target + +- block: + - name: Install yum-utils + package: name=yum-utils state=latest + when: ansible_pkg_mgr == "yum" + + - name: Care about debuginfo packages for YUM systems + shell: | + debuginfo-install --assumeyes {{item}} + with_items: + - "{{ pkgs_debuginfo_req|d|list }}" + +- block: + - package: name=yum-plugin-copr state=present + - shell: yum copr -y {{item}} + with_items: + - "{{copr_repos}}" + name: Enable copr repos using YUM + ignore_errors: True + when: copr_repos is defined diff --git a/roles/str-common-init/tasks/pkgs.yml b/roles/str-common-init/tasks/pkgs.yml new file mode 100644 index 0000000..ae9a0c9 --- /dev/null +++ b/roles/str-common-init/tasks/pkgs.yml @@ -0,0 +1,31 @@ +- name: Build packages lists to be present on test environment + # Separate debuginfo and ordinary packages. There is an issue on GitHub: + # https://github.com/ansible/ansible/issues/31579. The easiest way to install + # debuginfo for package is to use 'debuginfo-install'. This program is + # present on RHEL/CentOS/Fedora and it automatically enables debuginfo repos. + set_fact: + pkgs_ordinary_req: > + {{ + required_packages | + reject('match', '.*-debuginfo$') | + list + }} + pkgs_debuginfo_req: > + {{ + required_packages | + select('match', '.*-debuginfo$') | + list | + regex_replace('-debuginfo') + }} + pkg_mgr: > + {{ + 'rpm-ostree' if (is_atomic and + (ansible_pkg_mgr == 'unknown' or + ansible_pkg_mgr == 'atomic_container')) else ansible_pkg_mgr + }} + +- debug: + msg: "Package manager: {{ pkg_mgr }}" + verbosity: 1 + +- include_tasks: "pkgs-{{ pkg_mgr | trim}}.yml" diff --git a/roles/str-common-init/tasks/trunner.yml b/roles/str-common-init/tasks/trunner.yml new file mode 100644 index 0000000..f37909f --- /dev/null +++ b/roles/str-common-init/tasks/trunner.yml @@ -0,0 +1,68 @@ +- name: Add test-runner to ansible inventory + add_host: + name: "{{ test_runner_inventory_name }}" + ansible_connection: local + +- delegate_to: "{{ test_runner_inventory_name }}" + block: + - name: Gather facts + setup: + delegate_facts: True + + - name: Set facts about test-runner + delegate_facts: True + set_fact: + is_yum_os: >- + {{ hostvars[test_runner_inventory_name]['ansible_pkg_mgr'] == 'yum' }} + is_dnf_os: >- + {{ hostvars[test_runner_inventory_name]['ansible_pkg_mgr'] == 'dnf' }} + is_rhel8_based: >- + {{ + ( [hostvars[test_runner_inventory_name]['ansible_distribution']] | + intersect(['RedHat', 'CentOS']) | bool ) + and + ( hostvars[test_runner_inventory_name]['ansible_distribution_version'] | + int == 8 ) + }} + + # Fix python ansible interpreter when running on RHEL8. Currently RHEL8 + # uses python2, but it does miss some python2 modules, such as python2-dnf. + # This can be removed once RHEL8 uses by default Python 3. + - name: Hardcode Python interpreter for ansible modules on RHEL8 based OS for test-runner + delegate_facts: True + set_fact: + ansible_python_interpreter: /usr/bin/env python3 + when: "hostvars[test_runner_inventory_name]['is_rhel8_based'] | bool" + + - name: Fetch tests from remote repositories + git: + repo: "{{ item.repo }}" + dest: "{{ item.dest }}" + version: "{{ item.version | default('master') }}" + with_items: + "{{ repositories }}" + when: repositories is defined + +- debug: + msg: > + {{ test_runner_inventory_name }} is: + {{ hostvars[test_runner_inventory_name]['ansible_distribution'] }} + verbosity: 1 + +- debug: + msg: > + {{ test_runner_inventory_name }} uses yum: + {{ hostvars[test_runner_inventory_name]['is_yum_os'] }} + verbosity: 1 + +- debug: + msg: > + {{ test_runner_inventory_name }} uses dnf: + {{ hostvars[test_runner_inventory_name]['is_dnf_os'] }} + verbosity: 1 + +- debug: + msg: > + {{ test_runner_inventory_name }} is RHEL8 based OS: + {{ hostvars[test_runner_inventory_name]['is_rhel8_based'] }} + verbosity: 1 diff --git a/roles/str-common/defaults/main.yml b/roles/str-common/defaults/main.yml deleted file mode 100644 index 9981d95..0000000 --- a/roles/str-common/defaults/main.yml +++ /dev/null @@ -1,12 +0,0 @@ ---- - -tests: [] -required_packages: [] -tenv_workdir: /var/str/ -remote_artifacts: /tmp/artifacts/ -test_runner_inventory_name: test-runner -artifacts: "{{ lookup('env', 'TEST_ARTIFACTS')|default('./artifacts', true) }}" -# distro_name: rhel, centos, fedora -distro_name: "{{ansible_distribution|lower}}" -# distro_name_ver: rhel_7, centos_7, fedora_22 -distro_name_ver: "{{ansible_distribution|lower}}_{{ansible_distribution_major_version}}" diff --git a/roles/str-common/tasks/end.yml b/roles/str-common/tasks/end.yml deleted file mode 100644 index 0ea910a..0000000 --- a/roles/str-common/tasks/end.yml +++ /dev/null @@ -1,9 +0,0 @@ ---- - -- name: Pull out the logs from test environment to test runner - synchronize: - dest: "{{ artifacts }}/" - src: "{{ remote_artifacts }}/" - mode: pull - ssh_args: "-o UserKnownHostsFile=/dev/null" - when: artifacts|default("") != "" diff --git a/roles/str-common/tasks/inspect.yml b/roles/str-common/tasks/inspect.yml deleted file mode 100644 index 74d7a86..0000000 --- a/roles/str-common/tasks/inspect.yml +++ /dev/null @@ -1,35 +0,0 @@ -- block: - - name: Check if system is Atomic Host - lineinfile: - name: /etc/os-release - regexp: .*Atomic Host.* - state: absent - check_mode: yes - changed_when: False - register: os_release_atomic - - name: Set fact 'is_atomic' - delegate_facts: True - set_fact: - is_atomic : "{{ os_release_atomic.found > 0 }}" - -- name: Set facts about system - delegate_facts: True - set_fact: - is_yum_os: >- - {{ ansible_pkg_mgr == 'yum' }} - is_dnf_os: >- - {{ ansible_pkg_mgr == 'dnf' }} - is_rhel8_based: >- - {{ - ( ['ansible_distribution'] | - intersect(['RedHat', 'CentOS']) | bool ) and - ansible_distribution_version|int == 8 - }} - -# Fix python ansible interpreter when running on RHEL8. Currently RHEL8 -# uses python2, but it does miss some python2 modules, such as python2-dnf. -# This can be removed once RHEL8 uses by default Python3 -- name: Hardcode Python interpreter for ansible modules on RHEL8 based OS - set_fact: - ansible_python_interpreter: /usr/bin/env python3 - when: is_rhel8_based diff --git a/roles/str-common/tasks/main.yml b/roles/str-common/tasks/main.yml deleted file mode 100644 index f259710..0000000 --- a/roles/str-common/tasks/main.yml +++ /dev/null @@ -1,26 +0,0 @@ -- import_tasks: inspect.yml - -- debug: - msg: "System uses yum: {{ is_yum_os }}" - verbosity: 1 - -- debug: - msg: "System uses dnf: {{ is_dnf_os }}" - verbosity: 1 - -- debug: - msg: "System is Atomic Host: {{ is_atomic }}" - verbosity: 1 - -- import_tasks: trunner.yml -- import_tasks: pkgs.yml - -- name: Make artifacts directory - file: path={{ remote_artifacts }} state=directory owner=root mode=755 recurse=yes - -# Next task requires rsync on test environment -- name: Copy tests to test environment - synchronize: - src: "{{ playbook_dir }}/" - dest: "{{ tenv_workdir }}" - ssh_args: "-o UserKnownHostsFile=/dev/null" diff --git a/roles/str-common/tasks/pkgs-dnf.yml b/roles/str-common/tasks/pkgs-dnf.yml deleted file mode 100644 index bcf7c0b..0000000 --- a/roles/str-common/tasks/pkgs-dnf.yml +++ /dev/null @@ -1,32 +0,0 @@ -- name: Install test-specific package requirements - # Note, this method cannot install -debuginfo packages. - package: name={{item}} state=present - with_items: - - "{{ pkgs_ordinary_req|d|list }}" - -- name: Install the common requirements on target - package: name={{item}} state=present - with_items: - - rsync # needed to copy tests to target - -- block: - - name: Install dnf-utils - # System can have installed yum-utils. Which conflicts wih dnf-utils. - # Therefore, remove yum-utils and install dnf-utils. - shell: dnf --assumeyes --allowerasing install dnf-utils - when: ansible_pkg_mgr == "dnf" - - - name: Install debuginfo packages - shell: | - debuginfo-install --assumeyes {{item}} - with_items: - - "{{ pkgs_debuginfo_req|d|list }}" - -- block: - - package: name=dnf-plugins-core state=present - - shell: dnf copr enable -y {{item}} - with_items: - - "{{copr_repos}}" - name: Enable copr repos using DNF - ignore_errors: True - when: copr_repos is defined diff --git a/roles/str-common/tasks/pkgs-rpm-ostree.yml b/roles/str-common/tasks/pkgs-rpm-ostree.yml deleted file mode 100644 index 48ff116..0000000 --- a/roles/str-common/tasks/pkgs-rpm-ostree.yml +++ /dev/null @@ -1,14 +0,0 @@ -- block: - - name: Check presence of test-specific package requirements - shell: rpm -q {{ pkgs_ordinary_req|join(" ") }} - register: package_check - changed_when: False - failed_when: False - args: { warn: no } - - name: Install test-specific package requirements - shell: - rpm-ostree install {{ pkgs_ordinary_req|join(" ") }} - && rpm-ostree ex livefs - when: package_check.rc != 0 - when: - - pkgs_ordinary_req diff --git a/roles/str-common/tasks/pkgs-yum.yml b/roles/str-common/tasks/pkgs-yum.yml deleted file mode 100644 index b61f6c5..0000000 --- a/roles/str-common/tasks/pkgs-yum.yml +++ /dev/null @@ -1,30 +0,0 @@ -- name: Install test-specific package requirements - # Note, this method cannot install -debuginfo packages. - package: name={{item}} state=present - with_items: - - "{{ pkgs_ordinary_req|d|list }}" - -- name: Install the common requirements on target - package: name={{item}} state=present - with_items: - - rsync # needed to copy tests to target - -- block: - - name: Install yum-utils - package: name=yum-utils state=latest - when: ansible_pkg_mgr == "yum" - - - name: Care about debuginfo packages for YUM systems - shell: | - debuginfo-install --assumeyes {{item}} - with_items: - - "{{ pkgs_debuginfo_req|d|list }}" - -- block: - - package: name=yum-plugin-copr state=present - - shell: yum copr -y {{item}} - with_items: - - "{{copr_repos}}" - name: Enable copr repos using YUM - ignore_errors: True - when: copr_repos is defined diff --git a/roles/str-common/tasks/pkgs.yml b/roles/str-common/tasks/pkgs.yml deleted file mode 100644 index 6e75ae9..0000000 --- a/roles/str-common/tasks/pkgs.yml +++ /dev/null @@ -1,29 +0,0 @@ -- name: Build packages lists to be present on test environment - # Separate debuginfo and ordinary packages. There is an issue on GitHub: - # https://github.com/ansible/ansible/issues/31579. The easiest way to install - # debuginfo for package is to use 'debuginfo-install'. This program is - # present on RHEL/CentOS/Fedora and it automatically enables debuginfo repos. - set_fact: - pkgs_ordinary_req: > - {{ - required_packages | - reject('match', '.*-debuginfo$') | - list - }} - pkgs_debuginfo_req: > - {{ - required_packages | - select('match', '.*-debuginfo$') | - list | - regex_replace('-debuginfo') - }} - pkg_mgr: > - {{ - 'rpm-ostree' if ansible_pkg_mgr == 'unknown' and is_atomic else ansible_pkg_mgr - }} - -- debug: - msg: "Package manager: {{ pkg_mgr }}" - verbosity: 1 - -- include_tasks: "pkgs-{{ pkg_mgr | trim}}.yml" diff --git a/roles/str-common/tasks/trunner.yml b/roles/str-common/tasks/trunner.yml deleted file mode 100644 index 43432f5..0000000 --- a/roles/str-common/tasks/trunner.yml +++ /dev/null @@ -1,68 +0,0 @@ -- name: Add test-runner to ansible inventory - add_host: - name: "{{ test_runner_inventory_name }}" - ansible_connection: local - -- delegate_to: "{{ test_runner_inventory_name }}" - block: - - name: Gather facts - setup: - delegate_facts: True - - - name: Set facts about test-runner - delegate_facts: True - set_fact: - is_yum_os: >- - {{ hostvars[test_runner_inventory_name]['ansible_pkg_mgr'] == 'yum' }} - is_dnf_os: >- - {{ hostvars[test_runner_inventory_name]['ansible_pkg_mgr'] == 'dnf' }} - is_rhel8_based: >- - {{ - ( [hostvars[test_runner_inventory_name]['ansible_distribution']] | - intersect(['RedHat', 'CentOS']) | bool ) - and - ( hostvars[test_runner_inventory_name]['ansible_distribution_version'] | - int == 8 ) - }} - - # Fix python ansible interpreter when running on RHEL8. Currently RHEL8 - # uses python2, but it does miss some python2 modules, such as python2-dnf. - # This can be removed once RHEL8 uses by default Python 3. - - name: Hardcode Python interpreter for ansible modules on RHEL8 based OS - delegate_facts: True - set_fact: - ansible_python_interpreter: /usr/bin/env python3 - when: "hostvars[test_runner_inventory_name]['is_rhel8_based'] | bool" - - - name: Fetch tests from remote repositories - git: - repo: "{{ item.repo }}" - dest: "{{ item.dest }}" - version: "{{ item.version | default('master') }}" - with_items: - "{{ repositories }}" - when: repositories is defined - -- debug: - msg: > - {{ test_runner_inventory_name }} is: - {{ hostvars[test_runner_inventory_name]['ansible_distribution'] }} - verbosity: 1 - -- debug: - msg: > - {{ test_runner_inventory_name }} uses yum: - {{ hostvars[test_runner_inventory_name]['is_yum_os'] }} - verbosity: 1 - -- debug: - msg: > - {{ test_runner_inventory_name }} uses dnf: - {{ hostvars[test_runner_inventory_name]['is_dnf_os'] }} - verbosity: 1 - -- debug: - msg: > - {{ test_runner_inventory_name }} is RHEL8 based OS: - {{ hostvars[test_runner_inventory_name]['is_rhel8_based'] }} - verbosity: 1