Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for .deb #13

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions roles/vgpu/tasks/install-deb.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
- name: Copy driver to remote host
ansible.builtin.copy:
src: "{{ vgpu_driver_url_components.path }}"
dest: "{{ dir_path }}"
mode: "0660"
vars:
is_file: "{{ 'file' in vgpu_driver_url_components.scheme }}"
when: is_file

- name: Install using apt
ansible.builtin.apt:
deb: "{{ dir_path if is_file else vgpu_driver_url }}"
state: present
register: install_result
vars:
is_file: "{{ 'file' in vgpu_driver_url_components.scheme }}"
32 changes: 32 additions & 0 deletions roles/vgpu/tasks/install-zip.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
- name: Extract driver
ansible.builtin.unarchive:
src: "{{ vgpu_driver_url_components.path if is_file else vgpu_driver_url }}"
dest: "{{ dir_path }}"
owner: root
group: root
creates: "{{ dir_path }}/Host_Drivers"
remote_src: "{{ omit if is_file else true }}"
vars:
is_file: "{{ 'file' in vgpu_driver_url_components.scheme }}"

- name: Find .run script
ansible.builtin.find:
paths: "{{ dir_path }}/Host_Drivers"
patterns: "*.run"
register: find_result

- name: Set execute bit
ansible.builtin.file:
path: "{{ install_script }}"
mode: u+x

- name: Run the install script
# NOTE: This compiles for currently running kernel, can force with --kernel-name
ansible.builtin.shell: |-
{{ install_script }} -q {% if vgpu_driver_dkms %}--dkms{% endif %} --tmpdir {{ tmp_path }} --ui none --disable-nouveau --no-nouveau-check && touch {{ install_script }}.complete
args:
creates: "{{ omit if vgpu_driver_force_install else install_script ~ '.complete' }}"
environment:
TMPDIR: "{{ tmp_path }}"
register: install_result
36 changes: 6 additions & 30 deletions roles/vgpu/tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,37 +31,13 @@
group: root
mode: "770"

- name: Extract driver
ansible.builtin.unarchive:
src: "{{ vgpu_driver_url_components.path if is_file else vgpu_driver_url }}"
dest: "{{ dir_path }}"
owner: root
group: root
creates: "{{ dir_path }}/Host_Drivers"
remote_src: "{{ omit if is_file else true }}"
vars:
is_file: "{{ 'file' in vgpu_driver_url_components.scheme }}"

- name: Find .run script
ansible.builtin.find:
paths: "{{ dir_path }}/Host_Drivers"
patterns: "*.run"
register: find_result

- name: Set execute bit
ansible.builtin.file:
path: "{{ install_script }}"
mode: u+x
- name: Intall a zip
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo

ansible.builtin.include_tasks: install-zip.yml
when: vgpu_driver_url[-3:] == "zip"

- name: Run the install script
# NOTE: This compiles for currently running kernel, can force with --kernel-name
ansible.builtin.shell: |-
{{ install_script }} -q {% if vgpu_driver_dkms %}--dkms{% endif %} --tmpdir {{ tmp_path }} --ui none --disable-nouveau --no-nouveau-check && touch {{ install_script }}.complete
args:
creates: "{{ omit if vgpu_driver_force_install else install_script ~ '.complete' }}"
environment:
TMPDIR: "{{ tmp_path }}"
register: install_result
- name: Intall a .deb
ansible.builtin.include_tasks: install-deb.yml
when: vgpu_driver_url[-3:] == "deb"

- name: Reboot after driver install # noqa: no-handler
ansible.builtin.reboot:
Expand Down