---
- name: Setup Nvidia GPU drivers
  hosts: nvidia
  tasks:
    - name: nVidia CUDA Repo
      ansible.builtin.yum_repository:
        name: cuda-rhel9-x86_64
        description: cuda-rhel9-x86_64
        baseurl: https://developer.download.nvidia.com/compute/cuda/repos/rhel9/x86_64
        gpgkey: https://developer.download.nvidia.com/compute/cuda/repos/rhel9/x86_64/D42D0685.pub

    - name: Enable CRB repo
      ansible.builtin.ini_file:
        path: /etc/yum.repos.d/{{ repo_file }}
        section: "{{ repo_id }}"
        option: enabled
        value: "1"
        no_extra_spaces: true
      vars:
        repo_id: crb
        repo_file: rocky.repo

    - name: NVidia Driver RPMs
      ansible.builtin.package:
        name: 
          - gcc
          - make
          - dkms
          - kernel-devel
          - kernel-headers
          - cuda-toolkit
          # nvidia-smi
          - nvidia-container-toolkit
        state: present
        update_cache: false
      # when: 0 > 1

    - name: NVidia Kernel Module
      ansible.builtin.dnf:
        name: '@nvidia-driver:580-dkms'
        state: present
        update_cache: false
      # when: 0 > 1
      #
      # Add:
      # dkms autoinstall -k $(uname -r)

