From 319c29c2a2f0d3a299093e9f00240ca8a119a791 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Sun, 22 May 2022 17:20:30 +0200 Subject: [PATCH] Add RHEL 9.0, FreeBSD 13.1, Ubuntu 22.04 and Fedora 36 to CI, fix bug in filesystem module (#4700) * Add RHEL 9.0 and FreeBSD 13.1 to CI. * RHEL 9 has no pyOpenSSL apparently. * Adjust URL for EPEL. * Fix cargo install on FreeBSD 13.1. * Add Ubuntu 22.04 and Fedora 36 to CI. * Fix logic. * filesystem: do not die output line does not contain ':' * Skip django_manage tests on RHEL 9 as well. * homectl tests don't work with RHEL 9.0. * Improve error handling, improve fatresize output handling. * Skip Fedora 36. * Skip filesystem vfat tests on Ubuntu 22.04. There, resizing fails with a bug: Bug: Assertion (disk != NULL) at ../../libparted/disk.c:1620 in function ped_disk_get_partition_by_sector() failed. * 'trusty' is 14.04. Adding 22.04 to skip list. * Skip jail tests for FreeBSD 13.1. * Add config for postgres on Ubuntu 22.04. * Make CentOS 6 happy. * Adjust postgres version. * Try installing EPEL a bit differently. * Skip ufw and iso_extract tests on RHEL 9. * Skip odbc tests on RHEL 9. * Skip RHEL 9.0 for snap tests. * Add changelog fragment for filesystem code changes. --- .azure-pipelines/azure-pipelines.yml | 16 ++++++++-------- changelogs/fragments/4700-code-changes.yml | 3 +++ plugins/modules/system/filesystem.py | 19 +++++++++++-------- .../integration/targets/cargo/tasks/setup.yml | 12 +++++++++++- .../integration/targets/django_manage/aliases | 1 + .../targets/filesystem/tasks/main.yml | 3 +++ tests/integration/targets/homectl/aliases | 3 ++- .../targets/homectl/tasks/main.yml | 1 + tests/integration/targets/iso_extract/aliases | 2 ++ .../targets/iso_extract/meta/main.yml | 1 - .../targets/iso_extract/tasks/main.yml | 7 +++++++ .../integration/targets/monit/tasks/main.yml | 3 +++ tests/integration/targets/mqtt/tasks/main.yml | 2 +- tests/integration/targets/odbc/aliases | 1 + .../targets/pkgng/tasks/freebsd.yml | 5 ++++- .../targets/setup_epel/tasks/main.yml | 12 +++++++++++- .../targets/setup_openssl/vars/RedHat-9.yml | 4 ++++ .../vars/Ubuntu-22-py3.yml | 8 ++++++++ tests/integration/targets/setup_snap/aliases | 1 + .../targets/setup_snap/meta/main.yml | 1 - .../targets/setup_snap/tasks/D-RedHat-9.0.yml | 1 + .../targets/setup_snap/tasks/main.yml | 7 +++++++ tests/integration/targets/ufw/aliases | 7 +++---- tests/integration/targets/ufw/tasks/main.yml | 4 +++- 24 files changed, 96 insertions(+), 28 deletions(-) create mode 100644 changelogs/fragments/4700-code-changes.yml create mode 100644 tests/integration/targets/setup_openssl/vars/RedHat-9.yml create mode 100644 tests/integration/targets/setup_postgresql_db/vars/Ubuntu-22-py3.yml create mode 100644 tests/integration/targets/setup_snap/aliases create mode 120000 tests/integration/targets/setup_snap/tasks/D-RedHat-9.0.yml diff --git a/.azure-pipelines/azure-pipelines.yml b/.azure-pipelines/azure-pipelines.yml index 7cfa691e4a..551b79cf8e 100644 --- a/.azure-pipelines/azure-pipelines.yml +++ b/.azure-pipelines/azure-pipelines.yml @@ -177,12 +177,12 @@ stages: test: macos/12.0 - name: RHEL 7.9 test: rhel/7.9 - - name: RHEL 8.5 - test: rhel/8.5 + - name: RHEL 9.0 + test: rhel/9.0 - name: FreeBSD 12.3 test: freebsd/12.3 - - name: FreeBSD 13.0 - test: freebsd/13.0 + - name: FreeBSD 13.1 + test: freebsd/13.1 groups: - 1 - 2 @@ -253,14 +253,14 @@ stages: test: centos7 - name: Fedora 34 test: fedora34 - - name: Fedora 35 - test: fedora35 + - name: Fedora 36 + test: fedora36 - name: openSUSE 15 test: opensuse15 - name: Ubuntu 18.04 test: ubuntu1804 - - name: Ubuntu 20.04 - test: ubuntu2004 + - name: Ubuntu 22.04 + test: ubuntu2204 - name: Alpine 3 test: alpine3 groups: diff --git a/changelogs/fragments/4700-code-changes.yml b/changelogs/fragments/4700-code-changes.yml new file mode 100644 index 0000000000..d1b281d876 --- /dev/null +++ b/changelogs/fragments/4700-code-changes.yml @@ -0,0 +1,3 @@ +bugfixes: + - "filesystem - improve error messages when output cannot be parsed by including newlines in escaped form (https://github.com/ansible-collections/community.general/pull/4700)." + - "filesystem - handle ``fatresize --info`` output lines without ``:`` (https://github.com/ansible-collections/community.general/pull/4700)." diff --git a/plugins/modules/system/filesystem.py b/plugins/modules/system/filesystem.py index 9fb7810249..6b38c58183 100644 --- a/plugins/modules/system/filesystem.py +++ b/plugins/modules/system/filesystem.py @@ -268,7 +268,7 @@ class Ext(Filesystem): if None not in (block_size, block_count): break else: - raise ValueError(out) + raise ValueError(repr(out)) return block_size * block_count @@ -319,7 +319,7 @@ class XFS(Filesystem): if None not in (block_size, block_count): break else: - raise ValueError(out) + raise ValueError(repr(out)) return block_size * block_count @@ -364,7 +364,7 @@ class Btrfs(Filesystem): for line in stdout.splitlines(): if "Device size" in line: return int(line.split()[-1]) - raise ValueError(stdout) + raise ValueError(repr(stdout)) class Ocfs2(Filesystem): @@ -405,7 +405,7 @@ class F2fs(Filesystem): if None not in (sector_size, sector_count): break else: - raise ValueError(out) + raise ValueError(repr(out)) return sector_size * sector_count @@ -428,12 +428,15 @@ class VFAT(Filesystem): dummy, out, dummy = self.module.run_command([cmd, '--info', str(dev)], check_rc=True, environ_update=self.LANG_ENV) fssize = None for line in out.splitlines()[1:]: - param, value = line.split(':', 1) - if param.strip() == 'Size': + parts = line.split(':', 1) + if len(parts) < 2: + continue + param, value = parts + if param.strip() in ('Size', 'Cur size'): fssize = int(value.strip()) break else: - raise ValueError(out) + raise ValueError(repr(out)) return fssize @@ -477,7 +480,7 @@ class UFS(Filesystem): if None not in (fragmentsize, providersize): break else: - raise ValueError(out) + raise ValueError(repr(out)) return fragmentsize * providersize diff --git a/tests/integration/targets/cargo/tasks/setup.yml b/tests/integration/targets/cargo/tasks/setup.yml index 77104f6dfd..5315349c12 100644 --- a/tests/integration/targets/cargo/tasks/setup.yml +++ b/tests/integration/targets/cargo/tasks/setup.yml @@ -7,8 +7,18 @@ - set_fact: has_cargo: true when: - - ansible_system != 'FreeBSD' or ansible_distribution_version is version('13.0', '>') + - ansible_system != 'FreeBSD' - ansible_distribution != 'MacOSX' - ansible_distribution != 'RedHat' or ansible_distribution_version is version('8.0', '>=') - ansible_distribution != 'CentOS' or ansible_distribution_version is version('7.0', '>=') - ansible_distribution != 'Ubuntu' or ansible_distribution_version is version('18', '>=') + +- block: + - name: Install rust (containing cargo) + package: + name: rust + state: present + - set_fact: + has_cargo: true + when: + - ansible_system == 'FreeBSD' and ansible_distribution_version is version('13.0', '>') diff --git a/tests/integration/targets/django_manage/aliases b/tests/integration/targets/django_manage/aliases index d01e476f95..174bc11337 100644 --- a/tests/integration/targets/django_manage/aliases +++ b/tests/integration/targets/django_manage/aliases @@ -7,3 +7,4 @@ skip/rhel8.2 skip/rhel8.3 skip/rhel8.4 skip/rhel8.5 +skip/rhel9.0 diff --git a/tests/integration/targets/filesystem/tasks/main.yml b/tests/integration/targets/filesystem/tasks/main.yml index 7de9df8e97..70ff890cc7 100644 --- a/tests/integration/targets/filesystem/tasks/main.yml +++ b/tests/integration/targets/filesystem/tasks/main.yml @@ -58,6 +58,9 @@ - 'not (item.0.key == "vfat" and ansible_distribution == "Debian")' # TODO: figure out why it fails, fix it! # vfat resizing fails on ArchLinux - 'not (item.0.key == "vfat" and ansible_distribution == "Archlinux")' # TODO: figure out why it fails, fix it! + # vfat resizing fails on Ubuntu 22.04 + - 'not (item.0.key == "vfat" and ansible_distribution == "Ubuntu" and (ansible_facts.distribution_major_version | int == 22))' + # TODO: figure out why it fails, fix it! # btrfs-progs cannot be installed on ArchLinux - 'not (item.0.key == "btrfs" and ansible_distribution == "Archlinux")' # TODO: figure out why it fails, fix it! diff --git a/tests/integration/targets/homectl/aliases b/tests/integration/targets/homectl/aliases index a2c5a3a804..de4b90786f 100644 --- a/tests/integration/targets/homectl/aliases +++ b/tests/integration/targets/homectl/aliases @@ -2,4 +2,5 @@ shippable/posix/group1 skip/aix skip/freebsd skip/osx -skip/macos \ No newline at end of file +skip/macos +skip/rhel9.0 # See https://www.reddit.com/r/Fedora/comments/si7nzk/homectl/ diff --git a/tests/integration/targets/homectl/tasks/main.yml b/tests/integration/targets/homectl/tasks/main.yml index ded6173759..18943a782d 100644 --- a/tests/integration/targets/homectl/tasks/main.yml +++ b/tests/integration/targets/homectl/tasks/main.yml @@ -174,3 +174,4 @@ when: - systemd_version.rc == 0 and (systemd_version.stdout | regex_search('[0-9][0-9][0-9]') | int >= 245) and homectl_version.rc == 0 - ansible_distribution != 'Archlinux' # TODO! + - ansible_distribution != 'Fedora' or ansible_distribution_major_version|int < 36 # TODO! diff --git a/tests/integration/targets/iso_extract/aliases b/tests/integration/targets/iso_extract/aliases index 5de0229f66..1a89e39873 100644 --- a/tests/integration/targets/iso_extract/aliases +++ b/tests/integration/targets/iso_extract/aliases @@ -1,4 +1,6 @@ shippable/posix/group1 +needs/target/setup_epel destructive skip/aix skip/osx # FIXME +skip/rhel9.0 # FIXME diff --git a/tests/integration/targets/iso_extract/meta/main.yml b/tests/integration/targets/iso_extract/meta/main.yml index 07990bd4ef..56bc554611 100644 --- a/tests/integration/targets/iso_extract/meta/main.yml +++ b/tests/integration/targets/iso_extract/meta/main.yml @@ -1,4 +1,3 @@ dependencies: - setup_pkg_mgr - - setup_epel - setup_remote_tmp_dir diff --git a/tests/integration/targets/iso_extract/tasks/main.yml b/tests/integration/targets/iso_extract/tasks/main.yml index 18fd9b37a9..15f270cb05 100644 --- a/tests/integration/targets/iso_extract/tasks/main.yml +++ b/tests/integration/targets/iso_extract/tasks/main.yml @@ -25,6 +25,13 @@ - set_fact: output_test_dir: '{{ remote_tmp_dir }}/test_iso_extract' +- name: Install EPEL repository (RHEL only) + include_role: + name: setup_epel + when: + - ansible_distribution in ['RedHat', 'CentOS'] + - ansible_distribution_major_version is version('9', '<') + - name: Install 7zip import_tasks: 7zip.yml diff --git a/tests/integration/targets/monit/tasks/main.yml b/tests/integration/targets/monit/tasks/main.yml index 21404fe15a..8f6baeebe8 100644 --- a/tests/integration/targets/monit/tasks/main.yml +++ b/tests/integration/targets/monit/tasks/main.yml @@ -7,6 +7,9 @@ - name: Install EPEL repository (RHEL only) include_role: name: setup_epel + when: + - ansible_distribution in ['RedHat', 'CentOS'] + - ansible_distribution_major_version is version('9', '<') - name: create required directories become: yes diff --git a/tests/integration/targets/mqtt/tasks/main.yml b/tests/integration/targets/mqtt/tasks/main.yml index c5dcf3bec7..ddd37c11e1 100644 --- a/tests/integration/targets/mqtt/tasks/main.yml +++ b/tests/integration/targets/mqtt/tasks/main.yml @@ -6,4 +6,4 @@ - include: ubuntu.yml when: - ansible_distribution == 'Ubuntu' - - ansible_distribution_release not in ['trusty', 'focal'] + - ansible_distribution_release not in ['focal', 'jammy'] diff --git a/tests/integration/targets/odbc/aliases b/tests/integration/targets/odbc/aliases index 4ced527402..6e13799f82 100644 --- a/tests/integration/targets/odbc/aliases +++ b/tests/integration/targets/odbc/aliases @@ -3,4 +3,5 @@ shippable/posix/group1 skip/osx skip/macos skip/rhel8.0 +skip/rhel9.0 skip/freebsd diff --git a/tests/integration/targets/pkgng/tasks/freebsd.yml b/tests/integration/targets/pkgng/tasks/freebsd.yml index f5274d5c5d..b06f5a0333 100644 --- a/tests/integration/targets/pkgng/tasks/freebsd.yml +++ b/tests/integration/targets/pkgng/tasks/freebsd.yml @@ -461,7 +461,10 @@ # NOTE: FreeBSD 12.0 test runner receives a "connection reset by peer" after ~20% downloaded so we are # only running this on 12.1 or higher # - when: ansible_distribution_version is version('12.01', '>=') + # NOTE: FreeBSD 13.1 fails to update the package catalogue for unknown reasons (someone with FreeBSD + # knowledge has to take a look) + # + when: ansible_distribution_version is version('12.01', '>=') and ansible_distribution_version is version('13.1', '<') block: - name: Setup testjail include: setup-testjail.yml diff --git a/tests/integration/targets/setup_epel/tasks/main.yml b/tests/integration/targets/setup_epel/tasks/main.yml index 21627cfa1d..b848ac2144 100644 --- a/tests/integration/targets/setup_epel/tasks/main.yml +++ b/tests/integration/targets/setup_epel/tasks/main.yml @@ -7,4 +7,14 @@ yum: name: https://s3.amazonaws.com/ansible-ci-files/test/integration/targets/setup_epel/epel-release-latest-{{ ansible_distribution_major_version }}.noarch.rpm disable_gpg_check: true - when: ansible_facts.distribution in ['RedHat', 'CentOS'] + when: + - ansible_facts.distribution in ['RedHat', 'CentOS'] + - ansible_facts.distribution_major_version == '6' + +- name: Install EPEL + yum: + name: https://ci-files.testing.ansible.com/test/integration/targets/setup_epel/epel-release-latest-{{ ansible_distribution_major_version }}.noarch.rpm + disable_gpg_check: true + when: + - ansible_facts.distribution in ['RedHat', 'CentOS'] + - ansible_facts.distribution_major_version != '6' diff --git a/tests/integration/targets/setup_openssl/vars/RedHat-9.yml b/tests/integration/targets/setup_openssl/vars/RedHat-9.yml new file mode 100644 index 0000000000..587309dc07 --- /dev/null +++ b/tests/integration/targets/setup_openssl/vars/RedHat-9.yml @@ -0,0 +1,4 @@ +cryptography_package_name: python-cryptography +cryptography_package_name_python3: python3-cryptography +openssl_package_name: openssl +cryptography_from_pip: false diff --git a/tests/integration/targets/setup_postgresql_db/vars/Ubuntu-22-py3.yml b/tests/integration/targets/setup_postgresql_db/vars/Ubuntu-22-py3.yml new file mode 100644 index 0000000000..b1521e4bc5 --- /dev/null +++ b/tests/integration/targets/setup_postgresql_db/vars/Ubuntu-22-py3.yml @@ -0,0 +1,8 @@ +postgresql_packages: + - "postgresql" + - "postgresql-common" + - "python3-psycopg2" + +pg_hba_location: "/etc/postgresql/14/main/pg_hba.conf" +pg_dir: "/var/lib/postgresql/14/main" +pg_ver: 14 diff --git a/tests/integration/targets/setup_snap/aliases b/tests/integration/targets/setup_snap/aliases new file mode 100644 index 0000000000..65e831523c --- /dev/null +++ b/tests/integration/targets/setup_snap/aliases @@ -0,0 +1 @@ +needs/target/setup_epel diff --git a/tests/integration/targets/setup_snap/meta/main.yml b/tests/integration/targets/setup_snap/meta/main.yml index 0e51c36ebd..5438ced5c3 100644 --- a/tests/integration/targets/setup_snap/meta/main.yml +++ b/tests/integration/targets/setup_snap/meta/main.yml @@ -1,3 +1,2 @@ dependencies: - setup_pkg_mgr - - setup_epel diff --git a/tests/integration/targets/setup_snap/tasks/D-RedHat-9.0.yml b/tests/integration/targets/setup_snap/tasks/D-RedHat-9.0.yml new file mode 120000 index 0000000000..0b06951496 --- /dev/null +++ b/tests/integration/targets/setup_snap/tasks/D-RedHat-9.0.yml @@ -0,0 +1 @@ +nothing.yml \ No newline at end of file diff --git a/tests/integration/targets/setup_snap/tasks/main.yml b/tests/integration/targets/setup_snap/tasks/main.yml index 26e02ddc56..6851a204f3 100644 --- a/tests/integration/targets/setup_snap/tasks/main.yml +++ b/tests/integration/targets/setup_snap/tasks/main.yml @@ -8,6 +8,13 @@ debug: msg: "Distribution '{{ ansible_facts.distribution }}', version '{{ ansible_facts.distribution_version }}', OS family '{{ ansible_facts.os_family }}'" +- name: Install EPEL repository (RHEL only) + include_role: + name: setup_epel + when: + - ansible_distribution in ['RedHat', 'CentOS'] + - ansible_distribution_major_version is version('9', '<') + - name: Include distribution specific tasks include_tasks: "{{ lookup('first_found', params) }}" vars: diff --git a/tests/integration/targets/ufw/aliases b/tests/integration/targets/ufw/aliases index 7ab34d8e5e..bb5347a578 100644 --- a/tests/integration/targets/ufw/aliases +++ b/tests/integration/targets/ufw/aliases @@ -3,10 +3,9 @@ skip/aix skip/osx skip/macos skip/freebsd -skip/rhel8.0 -skip/rhel8.0b -skip/rhel8.1b +skip/rhel8.0 # FIXME +skip/rhel9.0 # FIXME skip/docker needs/root -destructive needs/target/setup_epel +destructive diff --git a/tests/integration/targets/ufw/tasks/main.yml b/tests/integration/targets/ufw/tasks/main.yml index 3feb480cb0..ab9b109a18 100644 --- a/tests/integration/targets/ufw/tasks/main.yml +++ b/tests/integration/targets/ufw/tasks/main.yml @@ -8,7 +8,9 @@ - name: Install EPEL repository (RHEL only) include_role: name: setup_epel - when: ansible_distribution == 'RedHat' + when: + - ansible_distribution in ['RedHat', 'CentOS'] + - ansible_distribution_major_version is version('9', '<') - name: Install iptables (SuSE only) package: name: iptables