Skip to content

Commit

Permalink
fix: add support for EL10
Browse files Browse the repository at this point in the history
According to the Ansible team, support for listing platforms in
role `meta/main.yml` files is being removed.
Instead, they recommend using `galaxy_tags`

https://github.com/ansible/ansible/blob/stable-2.17/changelogs/CHANGELOG-v2.17.rst
"Remove the galaxy_info field platforms from the role templates"
ansible/ansible#82453

Many roles already have tags such as "rhel", "redhat", "centos", and "fedora".
I propose that we ensure all of the system roles have these tags.
Some of our roles support Suse, Debian, Ubuntu, and others.
We should add tags for those e.g. the ssh role already has tags for "debian" and "ubuntu".

In addition - for each version listed under `platforms.EL` - add a tag like `elN`.

Q: Why not use a delimiter between the platform and the version e.g. `el-10`?

This is not allowed by ansible-lint:

```
meta-no-tags: Tags must contain lowercase letters and digits only., invalid: 'el-10'
meta/main.yml:1
```

So we cannot use uppercase letters either.

Q: Why not use our own meta/main.yml field?

No other fields are allowed by ansible-lint:

```
syntax-check[specific]: 'myfield' is not a valid attribute for a RoleMetadata
```

Q: Why not use some other field?

There are no other applicable or suitable fields.

Q: What happens when we want to support versions like `N.M`?

Use the word "dot" instead of "." e.g. `el10dot3`.
Similarly - use "dash" instead of "-".

We do not need tags such as `fedoraall`.
The `fedora` tag implies that the role works on all supported versions of fedora.
Otherwise, use tags such as `fedora40` if the role only supports specific versions.

In addition - for roles that have different variable files for EL9, create
the corresponding EL10 files.

Change find_unused_disk.py so that it will never return a nvme disk unless it
is specifically asked for that type of disk.  The issue was that every test
was using an nvme disk.

Signed-off-by: Rich Megginson <[email protected]>
  • Loading branch information
richm committed Jun 27, 2024
1 parent bb51979 commit 14e7d0b
Show file tree
Hide file tree
Showing 21 changed files with 210 additions and 73 deletions.
3 changes: 3 additions & 0 deletions .ostree/packages-runtime-CentOS-10.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
kmod-kvdo
python3-blivet
vdo
3 changes: 3 additions & 0 deletions .ostree/packages-runtime-RedHat-10.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
kmod-kvdo
python3-blivet
vdo
1 change: 1 addition & 0 deletions .ostree/packages-testing-CentOS-10.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
util-linux-core
1 change: 1 addition & 0 deletions .ostree/packages-testing-RedHat-10.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
util-linux-core
33 changes: 25 additions & 8 deletions library/find_unused_disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Check warning on line 140 in library/find_unused_disk.py

View check run for this annotation

Codecov / codecov/patch

library/find_unused_disk.py#L140

Added line #L140 was not covered by tests
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)

Check warning on line 150 in library/find_unused_disk.py

View check run for this annotation

Codecov / codecov/patch

library/find_unused_disk.py#L150

Added line #L150 was not covered by tests
if not line:
continue

m = re.search(r'NAME="(?P<path>[^"]*)" TYPE="(?P<type>[^"]*)" SIZE="(?P<size>\d+)" FSTYPE="(?P<fstype>[^"]*)" LOG[_-]SEC="(?P<ssize>\d+)"', line)
if m is None:
module.log("Line did not match: " + line)
info.append("Line did not match: %s" % line)

Check warning on line 157 in library/find_unused_disk.py

View check run for this annotation

Codecov / codecov/patch

library/find_unused_disk.py#L157

Added line #L157 was not covered by tests
continue

if m.group('type') != "disk":
info.append("Line type [%s] is not disk: %s" % (m.group('type'), line))

Check warning on line 161 in library/find_unused_disk.py

View check run for this annotation

Codecov / codecov/patch

library/find_unused_disk.py#L161

Added line #L161 was not covered by tests
continue

disks[m.group('path')] = {"type": m.group('type'), "size": m.group('size'),
Expand All @@ -165,38 +169,49 @@ def get_disks(module):

def filter_disks(module):
disks = {}
info = []

Check warning on line 172 in library/find_unused_disk.py

View check run for this annotation

Codecov / codecov/patch

library/find_unused_disk.py#L172

Added line #L172 was not covered by tests
max_size = Size(module.params['max_size'])

for path, attrs in get_disks(module).items():
for path, attrs in get_disks(module, info).items():

Check warning on line 175 in library/find_unused_disk.py

View check run for this annotation

Codecov / codecov/patch

library/find_unused_disk.py#L175

Added line #L175 was not covered by tests
if is_ignored(path):
info.append('Disk [%s] attrs [%s] is ignored' % (path, attrs))

Check warning on line 177 in library/find_unused_disk.py

View check run for this annotation

Codecov / codecov/patch

library/find_unused_disk.py#L177

Added line #L177 was not covered by tests
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 \

Check warning on line 183 in library/find_unused_disk.py

View check run for this annotation

Codecov / codecov/patch

library/find_unused_disk.py#L183

Added line #L183 was not covered by tests
interface is None and is_device_interface(module, path, 'nvme'):
info.append('Disk [%s] attrs [%s] is not an interface [%s]' % (path, attrs, interface))

Check warning on line 185 in library/find_unused_disk.py

View check run for this annotation

Codecov / codecov/patch

library/find_unused_disk.py#L185

Added line #L185 was not covered by tests
continue

if attrs["fstype"]:
info.append('Disk [%s] attrs [%s] has fstype' % (path, attrs))

Check warning on line 189 in library/find_unused_disk.py

View check run for this annotation

Codecov / codecov/patch

library/find_unused_disk.py#L189

Added line #L189 was not covered by tests
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))

Check warning on line 193 in library/find_unused_disk.py

View check run for this annotation

Codecov / codecov/patch

library/find_unused_disk.py#L193

Added line #L193 was not covered by tests
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))

Check warning on line 197 in library/find_unused_disk.py

View check run for this annotation

Codecov / codecov/patch

library/find_unused_disk.py#L197

Added line #L197 was not covered by tests
continue

if get_partitions(path):
if get_partitions(path, info):
info.append('Disk [%s] attrs [%s] has partitions' % (path, attrs))

Check warning on line 201 in library/find_unused_disk.py

View check run for this annotation

Codecov / codecov/patch

library/find_unused_disk.py#L200-L201

Added lines #L200 - L201 were not covered by tests
continue

if not no_holders(get_sys_name(path)):
info.append('Disk [%s] attrs [%s] has holders' % (path, attrs))

Check warning on line 205 in library/find_unused_disk.py

View check run for this annotation

Codecov / codecov/patch

library/find_unused_disk.py#L205

Added line #L205 was not covered by tests
continue

if not can_open(path):
info.append('Disk [%s] attrs [%s] cannot be opened exclusively' % (path, attrs))

Check warning on line 209 in library/find_unused_disk.py

View check run for this annotation

Codecov / codecov/patch

library/find_unused_disk.py#L209

Added line #L209 was not covered by tests
continue

disks[path] = attrs

return disks
return disks, info

Check warning on line 214 in library/find_unused_disk.py

View check run for this annotation

Codecov / codecov/patch

library/find_unused_disk.py#L214

Added line #L214 was not covered by tests


def run_module():
Expand All @@ -211,15 +226,16 @@ def run_module():

result = dict(
changed=False,
disks=[]
disks=[],
info=[],
)

module = AnsibleModule(
argument_spec=module_args,
supports_check_mode=True
)

disks = filter_disks(module)
disks, info = filter_disks(module)

Check warning on line 238 in library/find_unused_disk.py

View check run for this annotation

Codecov / codecov/patch

library/find_unused_disk.py#L238

Added line #L238 was not covered by tests

if module.params['match_sector_size']:
# pick the most disks with the same sector size
Expand All @@ -238,6 +254,7 @@ def run_module():
else:
result['disks'] = sorted(disks)[:int(module.params['max_return'])]

result['info'] = info

Check warning on line 257 in library/find_unused_disk.py

View check run for this annotation

Codecov / codecov/patch

library/find_unused_disk.py#L257

Added line #L257 was not covered by tests
module.exit_json(**result)


Expand Down
14 changes: 12 additions & 2 deletions meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
galaxy_info:
author: David Lehman <[email protected]>
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"
Expand All @@ -16,3 +14,15 @@ galaxy_info:
- "7"
- "8"
- "9"
galaxy_tags:
- centos
- el7
- el8
- el9
- el10
- fedora
- lvm
- redhat
- rhel
- storage
- system
6 changes: 3 additions & 3 deletions tests/test-verify-pool-members.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
50 changes: 25 additions & 25 deletions tests/test-verify-volume-fs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
17 changes: 8 additions & 9 deletions tests/tests_create_lvm_cache_then_remove.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
15 changes: 8 additions & 7 deletions tests/tests_create_raid_pool_then_remove.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
5 changes: 4 additions & 1 deletion tests/tests_lvm_pool_members.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions tests/tests_lvm_pool_pv_grow_nvme_generated.yml
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions tests/tests_lvm_pool_pv_grow_scsi_generated.yml
Original file line number Diff line number Diff line change
@@ -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
13 changes: 6 additions & 7 deletions tests/tests_lvm_pool_shared.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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' }}"

Expand All @@ -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:
Expand Down
11 changes: 6 additions & 5 deletions tests/tests_resize.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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' }}"

Expand All @@ -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
Expand Down
9 changes: 3 additions & 6 deletions tests/tests_stratis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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' }}"

Expand Down
Loading

0 comments on commit 14e7d0b

Please sign in to comment.