diff --git a/tasks/install-redhat.yml b/tasks/install-redhat.yml index 7870178..6df75be 100644 --- a/tasks/install-redhat.yml +++ b/tasks/install-redhat.yml @@ -47,11 +47,27 @@ gpgkey: "{{ nvidia_driver_rhel_cuda_repo_gpgkey }}" environment: "{{proxy_env if proxy_env is defined else {}}}" -- name: install driver packages +- name: install driver packages RHEL/CentOS 7 and older yum: name: "{{ nvidia_driver_package_version | ternary('nvidia-driver-latest-dkms-'+nvidia_driver_package_version, 'nvidia-driver-latest-dkms') }}" state: "{{ nvidia_driver_package_state }}" autoremove: "{{ nvidia_driver_package_state == 'absent' }}" - register: install_driver + register: install_driver_rhel7 + environment: "{{proxy_env if proxy_env is defined else {}}}" + when: ansible_distribution_major_version < '8' + +- name: install driver packages RHEL/CentOS 8 and newer + dnf: + name: "{{ nvidia_driver_package_version | ternary('@nvidia-driver:'+nvidia_driver_package_version, '@nvidia-driver:latest-dkms') }}" + state: "{{ nvidia_driver_package_state }}" + autoremove: "{{ nvidia_driver_package_state == 'absent' }}" + register: install_driver_rhel8 environment: "{{proxy_env if proxy_env is defined else {}}}" + when: ansible_distribution_major_version > '7' +- name: Set install_driver.changed var for RHEL 7/8 + debug: + msg: Driver installed for RHEL + when: install_driver_rhel7.changed or install_driver_rhel8.changed + register: install_driver + changed_when: install_driver_rhel7.changed or install_driver_rhel8.changed