redhat-cop / infra.leapp

Collection of Ansible roles for automating RHEL in-place upgrades using Leapp.
MIT License
44 stars 34 forks source link

Fix Post-Upgrade Kernel Validation on Ansible 2.14+ #146

Closed blainestory closed 7 months ago

blainestory commented 7 months ago

When I upgrade a host, it fails during post-upgrade tasks with the following error:

TASK [infra.leapp.upgrade : Validate running kernel matches OS version] ********
fatal: [host01.example.org]: FAILED! => {"msg": "The conditional check ''el8' in ansible_kernel' failed. The error was: Conditional is marked as unsafe, and cannot be evaluated."}

I believe the issue stems from a vulnerability fix introduced in Ansible 2.14.12 (first bullet under Playbook section): https://docs.ansible.com/ansible/latest/porting_guides/porting_guide_core_2.14.html#playbook

Wasn't sure if a new task was warranted as the workaround was to do another set_fact including the 'el' string.

swapdisk commented 7 months ago

May a suggest rather than introducing a new rhel_dest_kernel_check fact, just change the assertion conditional at line 17 to this?...

        that: "'el' ~ rhel_dest_major_version in ansible_kernel"
blainestory commented 7 months ago

Thank you for the suggestion, @swapdisk. That was more in line with what I was hoping to achieve. This was the first I had seen the ~ character in YAML.

I can confirm it works on Ansible 2.15. I was able to upgrade a test RHEL7 box with no issues.

swapdisk commented 7 months ago

@blainestory, LGTM. Thank you for the contribution.

@djdanielsson, does this work for you now?