diff --git a/.ostree/packages-runtime-CentOS-10.txt b/.ostree/packages-runtime-CentOS-10.txt new file mode 100644 index 00000000..fb2dccef --- /dev/null +++ b/.ostree/packages-runtime-CentOS-10.txt @@ -0,0 +1,3 @@ +kmod-kvdo +python3-blivet +vdo diff --git a/.ostree/packages-runtime-RedHat-10.txt b/.ostree/packages-runtime-RedHat-10.txt new file mode 100644 index 00000000..fb2dccef --- /dev/null +++ b/.ostree/packages-runtime-RedHat-10.txt @@ -0,0 +1,3 @@ +kmod-kvdo +python3-blivet +vdo diff --git a/.ostree/packages-testing-CentOS-10.txt b/.ostree/packages-testing-CentOS-10.txt new file mode 100644 index 00000000..37010e37 --- /dev/null +++ b/.ostree/packages-testing-CentOS-10.txt @@ -0,0 +1 @@ +util-linux-core diff --git a/.ostree/packages-testing-RedHat-10.txt b/.ostree/packages-testing-RedHat-10.txt new file mode 100644 index 00000000..37010e37 --- /dev/null +++ b/.ostree/packages-testing-RedHat-10.txt @@ -0,0 +1 @@ +util-linux-core diff --git a/library/find_unused_disk.py b/library/find_unused_disk.py index 270fb589..9decabd8 100644 --- a/library/find_unused_disk.py +++ b/library/find_unused_disk.py @@ -132,29 +132,33 @@ def get_sys_name(disk_path): return os.path.normpath(node_dir + '/' + os.readlink(disk_path)) -def get_partitions(disk_path): +def get_partitions(disk_path, info): sys_name = get_sys_name(disk_path) partitions = list() for filename in os.listdir(SYS_CLASS_BLOCK + sys_name): if re.match(sys_name + r'p?\d+$', filename): + info.append("filename [%s] is a partition" % filename) partitions.append(filename) return partitions -def get_disks(module): +def get_disks(module, info): buf = module.run_command(["lsblk", "-p", "--pairs", "--bytes", "-o", "NAME,TYPE,SIZE,FSTYPE,LOG-SEC"])[1] disks = dict() for line in buf.splitlines(): + info.append("Line: %s" % line) if not line: continue m = re.search(r'NAME="(?P[^"]*)" TYPE="(?P[^"]*)" SIZE="(?P\d+)" FSTYPE="(?P[^"]*)" LOG[_-]SEC="(?P\d+)"', line) if m is None: module.log("Line did not match: " + line) + info.append("Line did not match: %s" % line) continue if m.group('type') != "disk": + info.append("Line type [%s] is not disk: %s" % (m.group('type'), line)) continue disks[m.group('path')] = {"type": m.group('type'), "size": m.group('size'), @@ -165,38 +169,49 @@ def get_disks(module): def filter_disks(module): disks = {} + info = [] max_size = Size(module.params['max_size']) - for path, attrs in get_disks(module).items(): + for path, attrs in get_disks(module, info).items(): if is_ignored(path): + info.append('Disk [%s] attrs [%s] is ignored' % (path, attrs)) continue interface = module.params['with_interface'] - if interface is not None and not is_device_interface(module, path, interface): + # do not use nvme unless explicitly asked to + if interface is not None and not is_device_interface(module, path, interface) or \ + interface is None and is_device_interface(module, path, 'nvme'): + info.append('Disk [%s] attrs [%s] is not an interface [%s]' % (path, attrs, interface)) continue if attrs["fstype"]: + info.append('Disk [%s] attrs [%s] has fstype' % (path, attrs)) continue if Size(attrs["size"]).bytes < Size(module.params['min_size']).bytes: + info.append('Disk [%s] attrs [%s] size is less than requested' % (path, attrs)) continue if max_size.bytes > 0 and Size(attrs["size"]).bytes > max_size.bytes: + info.append('Disk [%s] attrs [%s] size is greater than requested' % (path, attrs)) continue - if get_partitions(path): + if get_partitions(path, info): + info.append('Disk [%s] attrs [%s] has partitions' % (path, attrs)) continue if not no_holders(get_sys_name(path)): + info.append('Disk [%s] attrs [%s] has holders' % (path, attrs)) continue if not can_open(path): + info.append('Disk [%s] attrs [%s] cannot be opened exclusively' % (path, attrs)) continue disks[path] = attrs - return disks + return disks, info def run_module(): @@ -211,7 +226,8 @@ def run_module(): result = dict( changed=False, - disks=[] + disks=[], + info=[], ) module = AnsibleModule( @@ -219,7 +235,7 @@ def run_module(): supports_check_mode=True ) - disks = filter_disks(module) + disks, info = filter_disks(module) if module.params['match_sector_size']: # pick the most disks with the same sector size @@ -238,6 +254,7 @@ def run_module(): else: result['disks'] = sorted(disks)[:int(module.params['max_return'])] + result['info'] = info module.exit_json(**result) diff --git a/meta/main.yml b/meta/main.yml index 3bf09190..e4831a39 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -2,8 +2,6 @@ galaxy_info: author: David Lehman description: Configure volumes and filesystems - galaxy_tags: ['system', 'lvm', 'storage', 'redhat', - 'rhel', 'fedora', 'centos'] company: Red Hat, Inc. license: MIT min_ansible_version: "2.9" @@ -16,3 +14,15 @@ galaxy_info: - "7" - "8" - "9" + galaxy_tags: + - centos + - el7 + - el8 + - el9 + - el10 + - fedora + - lvm + - redhat + - rhel + - storage + - system diff --git a/tests/test-verify-pool-members.yml b/tests/test-verify-pool-members.yml index 1994c9a2..d56ebf45 100644 --- a/tests/test-verify-pool-members.yml +++ b/tests/test-verify-pool-members.yml @@ -85,9 +85,9 @@ loop_control: loop_var: st_pool_pv when: - - grow_supported.stdout | trim == 'True' - - storage_test_pool.type == "lvm" - - storage_test_pool.grow_to_fill | bool + - grow_supported.stdout | trim == 'True' + - storage_test_pool.type == "lvm" + - storage_test_pool.grow_to_fill | bool - name: Check MD RAID include_tasks: verify-pool-md.yml diff --git a/tests/test-verify-volume-fs.yml b/tests/test-verify-volume-fs.yml index 63b2770a..3ded452f 100644 --- a/tests/test-verify-volume-fs.yml +++ b/tests/test-verify-volume-fs.yml @@ -3,29 +3,29 @@ - name: Check volume filesystem when: storage_test_volume.type != "stratis" block: - - name: Verify fs type - assert: - that: storage_test_blkinfo.info[storage_test_volume._device].fstype == - storage_test_volume.fs_type or - (storage_test_blkinfo.info[storage_test_volume._device].fstype | length - == 0 and storage_test_volume.fs_type == "unformatted") - when: - - storage_test_volume.fs_type - - _storage_test_volume_present + - name: Verify fs type + assert: + that: storage_test_blkinfo.info[storage_test_volume._device].fstype == + storage_test_volume.fs_type or + (storage_test_blkinfo.info[storage_test_volume._device].fstype | length + == 0 and storage_test_volume.fs_type == "unformatted") + when: + - storage_test_volume.fs_type + - _storage_test_volume_present - # label - - name: Verify fs label - assert: - that: storage_test_blkinfo.info[storage_test_volume._device].label == - storage_test_volume.fs_label - msg: >- - Volume '{{ storage_test_volume.name }}' labels do not match when they - should - ('{{ storage_test_blkinfo.info[storage_test_volume._device].label }}', - '{{ storage_test_volume.fs_label }}') - when: - - _storage_test_volume_present | bool - # label for GFS2 is set manually with the extra `-t` fs_create_options - # so we can't verify it here because it was not set with fs_label so - # the label from blkinfo doesn't match the expected "empty" fs_label - - storage_test_volume.fs_type != "gfs2" + # label + - name: Verify fs label + assert: + that: storage_test_blkinfo.info[storage_test_volume._device].label == + storage_test_volume.fs_label + msg: >- + Volume '{{ storage_test_volume.name }}' labels do not match when they + should + ('{{ storage_test_blkinfo.info[storage_test_volume._device].label }}', + '{{ storage_test_volume.fs_label }}') + when: + - _storage_test_volume_present | bool + # label for GFS2 is set manually with the extra `-t` fs_create_options + # so we can't verify it here because it was not set with fs_label so + # the label from blkinfo doesn't match the expected "empty" fs_label + - storage_test_volume.fs_type != "gfs2" diff --git a/tests/tests_create_lvm_cache_then_remove.yml b/tests/tests_create_lvm_cache_then_remove.yml index 6b5d0a51..dd3fe595 100644 --- a/tests/tests_create_lvm_cache_then_remove.yml +++ b/tests/tests_create_lvm_cache_then_remove.yml @@ -41,14 +41,12 @@ - name: Set distribution version set_fact: - is_rhel9: "{{ (ansible_facts.distribution == 'CentOS' or - ansible_facts.distribution == 'Enterprise Linux' or - ansible_facts.distribution == 'RedHat') and - ansible_facts.distribution_major_version == '9' }}" - is_rhel8: "{{ (ansible_facts.distribution == 'CentOS' or - ansible_facts.distribution == 'Enterprise Linux' or - ansible_facts.distribution == 'RedHat') and - ansible_facts.distribution_major_version == '8' }}" + is_rhel10: "{{ (ansible_facts['os_family'] == 'RedHat') and + ansible_facts.distribution_major_version == '10' }}" + is_rhel9: "{{ (ansible_facts['os_family'] == 'RedHat') and + ansible_facts.distribution_major_version == '9' }}" + is_rhel8: "{{ (ansible_facts['os_family'] == 'RedHat') and + ansible_facts.distribution_major_version == '8' }}" is_fedora: "{{ ansible_facts.distribution == 'Fedora' }}" - name: Get unused disks @@ -94,7 +92,8 @@ - name: Run test on supported platforms when: ((is_fedora and blivet_pkg_version is version("3.5.0-1", ">=")) or (is_rhel8 and blivet_pkg_version is version("3.4.0-10", ">=")) or - (is_rhel9 and blivet_pkg_version is version("3.4.0-14", ">="))) + (is_rhel9 and blivet_pkg_version is version("3.4.0-14", ">=")) or + is_rhel10) block: - name: Attach the cache to the 'test' LV created above include_role: diff --git a/tests/tests_create_raid_pool_then_remove.yml b/tests/tests_create_raid_pool_then_remove.yml index 2b12209d..15a43e81 100644 --- a/tests/tests_create_raid_pool_then_remove.yml +++ b/tests/tests_create_raid_pool_then_remove.yml @@ -44,12 +44,12 @@ - name: Set distribution version set_fact: - is_rhel9: "{{ (ansible_facts.distribution == 'CentOS' or - ansible_facts.distribution == 'RedHat') and - ansible_facts.distribution_major_version == '9' }}" - is_rhel8: "{{ (ansible_facts.distribution == 'CentOS' or - ansible_facts.distribution == 'RedHat') and - ansible_facts.distribution_major_version == '8' }}" + is_rhel10: "{{ (ansible_facts['os_family'] == 'RedHat') and + ansible_facts.distribution_major_version == '10' }}" + is_rhel9: "{{ (ansible_facts['os_family'] == 'RedHat') and + ansible_facts.distribution_major_version == '9' }}" + is_rhel8: "{{ (ansible_facts['os_family'] == 'RedHat') and + ansible_facts.distribution_major_version == '8' }}" is_fedora: "{{ ansible_facts.distribution == 'Fedora' }}" - name: Get unused disks @@ -247,7 +247,8 @@ - name: Run test on supported platforms when: ((is_fedora and blivet_pkg_version is version("3.7.1-2", ">=")) or (is_rhel8 and blivet_pkg_version is version("3.6.0-5", ">=")) or - (is_rhel9 and blivet_pkg_version is version("3.6.0-6", ">="))) + (is_rhel9 and blivet_pkg_version is version("3.6.0-6", ">=")) or + is_rhel10) block: - name: Create a RAID0 lvm raid device with custom stripe size include_role: diff --git a/tests/tests_lvm_pool_members.yml b/tests/tests_lvm_pool_members.yml index 320626e8..7d907d78 100644 --- a/tests/tests_lvm_pool_members.yml +++ b/tests/tests_lvm_pool_members.yml @@ -44,8 +44,11 @@ ((is_fedora and blivet_pkg_version is version("3.4.3-1", ">=")) or (is_rhel7 and blivet_pkg_version is version("3.4.0-10", ">=")) or (is_rhel8 and blivet_pkg_version is version("3.4.0-10", ">=")) or - (is_rhel9 and blivet_pkg_version is version("3.4.0-14", ">=")))) + (is_rhel9 and blivet_pkg_version is version("3.4.0-14", ">=")) or + is_rhel10)) vars: + is_rhel10: "{{ ansible_facts['os_family'] == 'RedHat' and + ansible_facts['distribution_major_version'] == '10' }}" is_rhel9: "{{ ansible_facts['os_family'] == 'RedHat' and ansible_facts['distribution_major_version'] == '9' }}" is_rhel8: "{{ ansible_facts['os_family'] == 'RedHat' and diff --git a/tests/tests_lvm_pool_pv_grow_nvme_generated.yml b/tests/tests_lvm_pool_pv_grow_nvme_generated.yml new file mode 100644 index 00000000..e97f15e2 --- /dev/null +++ b/tests/tests_lvm_pool_pv_grow_nvme_generated.yml @@ -0,0 +1,15 @@ +--- +# This file was generated by generate_tests.py +- name: Run test tests_lvm_pool_pv_grow.yml for nvme + hosts: all + tags: + - tests::nvme + tasks: + - name: Set disk interface for test + set_fact: + storage_test_use_interface: "nvme" + +- name: Import playbook + import_playbook: tests_lvm_pool_pv_grow.yml + tags: + - tests::nvme diff --git a/tests/tests_lvm_pool_pv_grow_scsi_generated.yml b/tests/tests_lvm_pool_pv_grow_scsi_generated.yml new file mode 100644 index 00000000..6e33b199 --- /dev/null +++ b/tests/tests_lvm_pool_pv_grow_scsi_generated.yml @@ -0,0 +1,15 @@ +--- +# This file was generated by generate_tests.py +- name: Run test tests_lvm_pool_pv_grow.yml for scsi + hosts: all + tags: + - tests::scsi + tasks: + - name: Set disk interface for test + set_fact: + storage_test_use_interface: "scsi" + +- name: Import playbook + import_playbook: tests_lvm_pool_pv_grow.yml + tags: + - tests::scsi diff --git a/tests/tests_lvm_pool_shared.yml b/tests/tests_lvm_pool_shared.yml index 062ce3ab..474f6852 100644 --- a/tests/tests_lvm_pool_shared.yml +++ b/tests/tests_lvm_pool_shared.yml @@ -61,13 +61,11 @@ - name: Set distribution version set_fact: - is_rhel9: "{{ (ansible_facts.distribution == 'CentOS' or - ansible_facts.distribution == 'Enterprise Linux' or - ansible_facts.distribution == 'RedHat') and + is_rhel10: "{{ (ansible_facts['os_family'] == 'RedHat') and + ansible_facts.distribution_major_version == '10' }}" + is_rhel9: "{{ (ansible_facts['os_family'] == 'RedHat') and ansible_facts.distribution_major_version == '9' }}" - is_rhel8: "{{ (ansible_facts.distribution == 'CentOS' or - ansible_facts.distribution == 'Enterprise Linux' or - ansible_facts.distribution == 'RedHat') and + is_rhel8: "{{ (ansible_facts['os_family'] == 'RedHat') and ansible_facts.distribution_major_version == '8' }}" is_fedora: "{{ ansible_facts.distribution == 'Fedora' }}" @@ -76,7 +74,8 @@ when: ((is_fedora and blivet_pkg_version is version("3.8.2-1", "<")) or (is_rhel8 and blivet_pkg_version is version("3.6.0-8", "<")) or (is_rhel9 and - blivet_pkg_version is version("3.6.0-11", "<"))) + blivet_pkg_version is version("3.6.0-11", "<")) + or is_rhel10) - name: Create cluster ansible.builtin.include_role: diff --git a/tests/tests_resize.yml b/tests/tests_resize.yml index 1cd21763..22d1b329 100644 --- a/tests/tests_resize.yml +++ b/tests/tests_resize.yml @@ -333,11 +333,11 @@ - name: Set distribution version set_fact: - is_rhel9: "{{ (ansible_facts.distribution == 'CentOS' or - ansible_facts.distribution == 'RedHat') and + is_rhel10: "{{ (ansible_facts['os_family'] == 'RedHat') and + ansible_facts.distribution_major_version == '10' }}" + is_rhel9: "{{ (ansible_facts['os_family'] == 'RedHat') and ansible_facts.distribution_major_version == '9' }}" - is_rhel8: "{{ (ansible_facts.distribution == 'CentOS' or - ansible_facts.distribution == 'RedHat') and + is_rhel8: "{{ (ansible_facts['os_family'] == 'RedHat') and ansible_facts.distribution_major_version == '8' }}" is_fedora: "{{ ansible_facts.distribution == 'Fedora' }}" @@ -346,7 +346,8 @@ - name: Run test on supported platforms when: ((is_fedora and blivet_pkg_version is version("3.7.1-3", ">=")) or (is_rhel8 and blivet_pkg_version is version("3.6.0-6", ">=")) or - (is_rhel9 and blivet_pkg_version is version("3.6.0-8", ">="))) + (is_rhel9 and blivet_pkg_version is version("3.6.0-8", ">=")) or + is_rhel10) block: - name: >- Create one LVM logical volume under one volume group with size diff --git a/tests/tests_stratis.yml b/tests/tests_stratis.yml index b68f02d2..431268ef 100644 --- a/tests/tests_stratis.yml +++ b/tests/tests_stratis.yml @@ -40,14 +40,11 @@ - name: Set distribution version set_fact: - is_rhel7: "{{ (ansible_facts.distribution == 'CentOS' or - ansible_facts.distribution == 'RedHat') and + is_rhel7: "{{ (ansible_facts['os_family'] == 'RedHat') and ansible_facts.distribution_major_version == '7' }}" - is_rhel9: "{{ (ansible_facts.distribution == 'CentOS' or - ansible_facts.distribution == 'RedHat') and + is_rhel9: "{{ (ansible_facts['os_family'] == 'RedHat') and ansible_facts.distribution_major_version == '9' }}" - is_rhel10: "{{ (ansible_facts.distribution == 'CentOS' or - ansible_facts.distribution == 'RedHat') and + is_rhel10: "{{ (ansible_facts['os_family'] == 'RedHat') and ansible_facts.distribution_major_version == '10' }}" is_fedora: "{{ ansible_facts.distribution == 'Fedora' }}" diff --git a/tests/tests_stratis_nvme_generated.yml b/tests/tests_stratis_nvme_generated.yml new file mode 100644 index 00000000..42d65a5b --- /dev/null +++ b/tests/tests_stratis_nvme_generated.yml @@ -0,0 +1,15 @@ +--- +# This file was generated by generate_tests.py +- name: Run test tests_stratis.yml for nvme + hosts: all + tags: + - tests::nvme + tasks: + - name: Set disk interface for test + set_fact: + storage_test_use_interface: "nvme" + +- name: Import playbook + import_playbook: tests_stratis.yml + tags: + - tests::nvme diff --git a/tests/tests_stratis_scsi_generated.yml b/tests/tests_stratis_scsi_generated.yml new file mode 100644 index 00000000..03f51d5f --- /dev/null +++ b/tests/tests_stratis_scsi_generated.yml @@ -0,0 +1,15 @@ +--- +# This file was generated by generate_tests.py +- name: Run test tests_stratis.yml for scsi + hosts: all + tags: + - tests::scsi + tasks: + - name: Set disk interface for test + set_fact: + storage_test_use_interface: "scsi" + +- name: Import playbook + import_playbook: tests_stratis.yml + tags: + - tests::scsi diff --git a/vars/AlmaLinux_10.yml b/vars/AlmaLinux_10.yml new file mode 100644 index 00000000..17f05ec0 --- /dev/null +++ b/vars/AlmaLinux_10.yml @@ -0,0 +1,14 @@ +--- +blivet_package_list: + - python3-blivet + - libblockdev-crypto + - libblockdev-dm + - libblockdev-lvm + - libblockdev-mdraid + - libblockdev-swap + - xfsprogs + - stratisd + - stratis-cli +# vdo not yet available on el10 +# - vdo +# - kmod-kvdo diff --git a/vars/CentOS_10.yml b/vars/CentOS_10.yml new file mode 100644 index 00000000..17f05ec0 --- /dev/null +++ b/vars/CentOS_10.yml @@ -0,0 +1,14 @@ +--- +blivet_package_list: + - python3-blivet + - libblockdev-crypto + - libblockdev-dm + - libblockdev-lvm + - libblockdev-mdraid + - libblockdev-swap + - xfsprogs + - stratisd + - stratis-cli +# vdo not yet available on el10 +# - vdo +# - kmod-kvdo diff --git a/vars/RedHat_10.yml b/vars/RedHat_10.yml new file mode 100644 index 00000000..17f05ec0 --- /dev/null +++ b/vars/RedHat_10.yml @@ -0,0 +1,14 @@ +--- +blivet_package_list: + - python3-blivet + - libblockdev-crypto + - libblockdev-dm + - libblockdev-lvm + - libblockdev-mdraid + - libblockdev-swap + - xfsprogs + - stratisd + - stratis-cli +# vdo not yet available on el10 +# - vdo +# - kmod-kvdo