From 165b6a8381e2b1b62c32ccdfc917772840c8e6c0 Mon Sep 17 00:00:00 2001 From: Douglas Holt Date: Wed, 9 Jun 2021 19:48:43 +0000 Subject: [PATCH 1/2] Add support for RHEL/CentOS 8 --- tasks/install-redhat.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tasks/install-redhat.yml b/tasks/install-redhat.yml index 7870178..4808f62 100644 --- a/tasks/install-redhat.yml +++ b/tasks/install-redhat.yml @@ -47,11 +47,20 @@ 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 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 + environment: "{{proxy_env if proxy_env is defined else {}}}" + when: ansible_distribution_major_version > '7' From 1593a2fd28b4771aabe872ffec05ee23f025634f Mon Sep 17 00:00:00 2001 From: Adam Tetelman Date: Thu, 10 Jun 2021 10:39:00 -0700 Subject: [PATCH 2/2] split rhel7/rhel8 install_driver register to avoid overwriting the value when skipped --- tasks/install-redhat.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tasks/install-redhat.yml b/tasks/install-redhat.yml index 4808f62..6df75be 100644 --- a/tasks/install-redhat.yml +++ b/tasks/install-redhat.yml @@ -52,7 +52,7 @@ 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' @@ -61,6 +61,13 @@ 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 + 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