Skip to content

Commit de270bf

Browse files
committed
Support kernel checks with mismatching version length
4.18.0-553.16.1.el8_9.x86_64 4.18.0-553.el8_9.x86_64 These would fail with the error: '<' not supported between instances of 'str' and 'int'. as the community.general.version_sort was trying to compare the `el8_9` of the latter with the `16` of the former. Strip the last two chunks so we just compare numbers.
1 parent 1a15e4c commit de270bf

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

ansible/roles/ofed/tasks/install.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@
1010

1111
- name: Check current kernel is newest installed
1212
assert:
13-
that: _ofed_loaded_kernel.stdout == _ofed_dnf_kernels_newest
13+
that: _ofed_kernel_current == _ofed_dnf_kernels_newest
1414
fail_msg: "Kernel {{ _ofed_loaded_kernel.stdout }} is loaded but newer {{ _ofed_dnf_kernels_newest }} is installed: consider rebooting?"
1515
vars:
16+
_ofed_kernel_current: >-
17+
{{ _ofed_loaded_kernel.stdout | regex_replace('\.(?:.(?!\.))+$', '') | regex_replace('\.(?:.(?!\.))+$', '') }}
1618
_ofed_dnf_kernels_newest: >-
17-
{{ _ofed_dnf_kernels.stdout_lines[1:] | map('regex_replace', '^\w+\.(\w+)\s+(\S+)\s+\S+\s*$', '\2.\1') | community.general.version_sort | last }}
19+
{{ _ofed_dnf_kernels.stdout_lines[1:] | map('split') | map(attribute=1) | map('regex_replace', '\.(?:.(?!\.))+$', '') | community.general.version_sort | last }}
1820
# dnf line format e.g. "kernel.x86_64 4.18.0-513.18.1.el8_9 @baseos "
1921

2022
- name: Enable epel

0 commit comments

Comments
 (0)