stackhpc / ansible-role-libvirt-host

This role configures a host as a Libvirt/KVM hypervisor. It can also configure storage pools and networks on the host.
36 stars 32 forks source link

Latest version no longer works on Fedora 36 (note: I am aware this is not a supported distro) #57

Open benblasco opened 2 years ago

benblasco commented 2 years ago

The latest version of the role can no longer be deployed on Fedora hosts because of changes to the role intended to support RHEL/CentOS 7 and 8. Running the role fails because the distribution_major_version variable lookup now fails.

I can see under the vars/RedHat.yml directory there are some variables that are set differently based on whether it's RHEL/CentOS 7 or 8, and this breaks installs for Fedora hosts, which are also in the RHEL family. Please note that I was able to work around the issue by adding the following to the playbook that calls the role:

   - name: Override the OS version so the role works
     set_fact:
       ansible_facts:
         os_family: RedHat
         distribution: RedHat
         distribution_major_version: 8
         distribution_version: 8
         python:
           version:
             major: 3

However the above totally clobbers the entire ansible_facts dictionary, which may have some as yet unforeseen effects. I am currently looking to find whether I can edit individual variables without overriding the rest of the dictionary.

If anybody is interested in this use case please let me know. The role otherwise works extremely well on Fedora hosts and I am very grateful for the effort put into it by the StackHPC team!

I would be happy to possibly contribute to the role to add (limited) support for Fedora hosts if I can just get the role to "pretend" that a Fedora host is a RHEL/CentOS 8 host.

markgoddard commented 2 years ago

Hi @benblasco, we don't generally use Fedora, but would be happy to accept any reasonable changes to make it work.

benblasco commented 2 years ago

Hi Mark, Please keep this open as I am working on a more elegant way to introduce (limited) Fedora support.

benblasco commented 2 years ago

Hi Mark,

I have made a slight change to the solution which I presented above, which avoids clobbering any variables that don't need to be overwritten/overridden. The change is simply to switch to the ansible.utils.update_fact module, as documented here:

ansible.utils.update_fact module – Update currently set facts

Here's my code snippet from the playbook, which I have tested successfully on Fedora 36:

  pre_tasks:

   - name: Override the OS version so the role works
     ansible.utils.update_fact:
       updates:
         - path: ansible_facts.os_family
           value: RedHat
         - path: ansible_facts.distribution
           value: RedHat
         - path: ansible_facts.distribution_major_version
           value: 8
         - path: ansible_facts.distribution_version
           value: 8

Do you think there's a suitable location where I could add this information for others to consume? Something similar may also be an easy way to enable some rudimentary RHEL/CentOS Stream/Rocky/Alma 9 support for the role. Happy to contribute if you think it's suitable!

markgoddard commented 2 years ago

Hi @benblasco, that approach does seem better than the original. Feel free to propose adding this to the end of the README.

benblasco commented 2 years ago

Will do. Will write it up and send a PR after Sep 12 as I'm currently mostly offline. Thank you for your feedback!

benblasco commented 1 year ago

Hi @markgoddard Just confirming that it worked for me on Fedora 38 with the changes above. I should probably get onto that PR.