Skip to content

Commit

Permalink
nvidia: add nvidia-purge tag
Browse files Browse the repository at this point in the history
nvidia: fail when a Nvidia GPU could not be detected
  • Loading branch information
saltydk committed Sep 22, 2024
1 parent 1507129 commit a5ad249
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions roles/nvidia/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,13 @@
fi
register: lspci_resp

- name: Fail if no GPU was detected
ansible.builtin.fail:
msg: "No Nvidia GPU could be detected."
when: not ('NVIDIA' in lspci_resp.stdout)

- name: Nvidia Setup block
when: (ansible_distribution == 'Ubuntu') and ('NVIDIA' in lspci_resp.stdout)
when: ('NVIDIA' in lspci_resp.stdout)
block:
- name: Fetch NVIDIA driver patch script
ansible.builtin.uri:
Expand Down Expand Up @@ -85,7 +90,7 @@
else 'not installed' }}"

- name: Nvidia Purge Drivers Tasks
when: (nvidia_installed_driver_version != nvidia_driver_version) and (nvidia_installed_driver_version | length > 0) and ('nvidia' in ansible_run_tags) and (nvidia_driver_version | lower != 'ignore')
when: ('nvidia-purge' in ansible_run_tags) or ((nvidia_installed_driver_version != nvidia_driver_version) and (nvidia_installed_driver_version | length > 0) and ('nvidia' in ansible_run_tags) and (nvidia_driver_version | lower != 'ignore'))
block:
- name: Purge Nvidia APT packages
ansible.builtin.shell: "dpkg --force-depends -P $(dpkg -l | grep nvidia | awk '{print $2}')"
Expand Down
2 changes: 1 addition & 1 deletion saltbox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
- { role: mount_templates, tags: ['core', 'saltbox', 'mediabox', 'feederbox', 'mounts', 'mount-templates'] }
- { role: remote, tags: ['core', 'saltbox', 'mediabox', 'feederbox', 'mounts'] }
- { role: unionfs, tags: ['core', 'saltbox', 'mediabox', 'feederbox', 'mounts'] }
- { role: nvidia, tags: ['core', 'saltbox', 'mediabox', 'feederbox', 'docker', 'nvidia'], when: ['use_nvidia'] }
- { role: nvidia, tags: ['core', 'saltbox', 'mediabox', 'feederbox', 'docker', 'nvidia', 'nvidia-purge'], when: ['use_nvidia'] }
- { role: docker, tags: ['core', 'saltbox', 'mediabox', 'feederbox', 'docker', 'docker-filesystem-resize'] }
- { role: scripts, tags: ['core', 'saltbox', 'mediabox', 'feederbox', 'scripts'] }
- { role: sandbox, tags: ['core', 'saltbox', 'mediabox', 'feederbox', 'sandbox'] }
Expand Down

0 comments on commit a5ad249

Please sign in to comment.