diff --git a/roles/vgpu/tasks/install-deb.yml b/roles/vgpu/tasks/install-deb.yml new file mode 100644 index 0000000..8ddcf58 --- /dev/null +++ b/roles/vgpu/tasks/install-deb.yml @@ -0,0 +1,18 @@ +--- +- name: Copy driver to remote host + ansible.builtin.copy: + src: "{{ vgpu_driver_url_components.path }}" + dest: "{{ dir_path }}" + mode: "0660" + register: copy_result + vars: + is_file: "{{ 'file' in vgpu_driver_url_components.scheme }}" + when: is_file + +- name: Install using apt + ansible.builtin.apt: + deb: "{{ copy_result.dest if is_file else vgpu_driver_url }}" + state: present + register: install_result + vars: + is_file: "{{ 'file' in vgpu_driver_url_components.scheme }}" diff --git a/roles/vgpu/tasks/install-zip.yml b/roles/vgpu/tasks/install-zip.yml new file mode 100644 index 0000000..4e6b4f0 --- /dev/null +++ b/roles/vgpu/tasks/install-zip.yml @@ -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 diff --git a/roles/vgpu/tasks/install.yml b/roles/vgpu/tasks/install.yml index 59e2b8a..f2d4052 100644 --- a/roles/vgpu/tasks/install.yml +++ b/roles/vgpu/tasks/install.yml @@ -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: