Skip to content

Commit

Permalink
Add support for .deb
Browse files Browse the repository at this point in the history
  • Loading branch information
technowhizz committed Aug 3, 2023
1 parent 2c761b7 commit 8eab588
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 30 deletions.
18 changes: 18 additions & 0 deletions roles/vgpu/tasks/install-deb.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
- name: Copy driver to remote host
ansible.builtin.copy:
src: "{{ vgpu_driver_url_components.path }}"
dest: "{{ dir_path }}"
owner: root
group: root
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
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

0 comments on commit 8eab588

Please sign in to comment.