From f1fefb7014b02a33ade4dd74a33c357550297647 Mon Sep 17 00:00:00 2001 From: Simo Tuomisto Date: Thu, 8 Apr 2021 10:48:57 +0300 Subject: [PATCH] Added better kernel searching for idempotency --- molecule/default/verify.yml | 9 +++++---- tasks/install_runfile.yml | 24 +++++++++++++++++------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/molecule/default/verify.yml b/molecule/default/verify.yml index 9521d16..e321c63 100644 --- a/molecule/default/verify.yml +++ b/molecule/default/verify.yml @@ -15,9 +15,10 @@ hosts: centos7_cuda_run tasks: - name: Check that NVIDIA kernel module has been installed - stat: - path: /lib/modules/{{ cuda_driver_kernel_version }}/video/nvidia.ko - register: nvidia_module_file + find: + path: /lib/modules/{{ cuda_driver_kernel_version }} + patterns: nvidia.ko + register: nvidia_module_find - name: Verify that kernel module exists assert: - that: nvidia_module_file.stat.exists + that: nvidia_module_find.matched > 0 diff --git a/tasks/install_runfile.yml b/tasks/install_runfile.yml index 5ce1d47..4ede7fc 100644 --- a/tasks/install_runfile.yml +++ b/tasks/install_runfile.yml @@ -32,9 +32,11 @@ cuda_driver_kernel_version: "{{ cuda_driver_kernel_version | default(cuda_driver_kernel_running.stdout, true) }}" - name: "Check NVIDIA kernel module" - stat: - path: /lib/modules/{{ cuda_driver_kernel_version }}/video/nvidia.ko - register: cuda_driver_kernel_module + find: + path: "/lib/modules/{{ cuda_driver_kernel_version }}" + patterns: nvidia.ko + recurse: true + register: cuda_driver_kernel_module_find - name: "Check CUDA toolkit path" stat: @@ -43,9 +45,15 @@ - name: "Determine if driver and toolkit are installed" set_fact: - cuda_driver_installed: "{{ cuda_driver_kernel_module.stat.exists }}" + cuda_driver_installed: "{{ cuda_driver_kernel_module_find.matched > 0 }}" cuda_toolkit_installed: "{{ cuda_toolkit_path.stat.exists }}" +- name: "Print information about installed features" + debug: + msg: + - "Driver installed: {{ cuda_driver_installed }}" + - "Toolkit installed: {{ cuda_toolkit_installed }}" + - name: "Create temporary directory for runfile" file: path: /tmp/cuda_runfile @@ -95,9 +103,11 @@ msg: "Building driver {{ cuda_driver_runfile }} for kernel {{ cuda_driver_kernel_version }}" - name: "Install driver" - command: bash {{ cuda_driver_runfile }} --silent --kernel-name={{ cuda_driver_kernel_version }} --kernel-source-path=/usr/src/kernels/{{ cuda_driver_kernel_version }} {{ "--no-drm" if cuda_runfile_disable_nvidia_drm else "" }} - - when: cuda_runfile_driver and not cuda_driver_installed + command: > + bash {{ cuda_driver_runfile }} --silent + --kernel-name={{ cuda_driver_kernel_version }} + --kernel-source-path=/usr/src/kernels/{{ cuda_driver_kernel_version }} + {{ "--no-drm" if cuda_runfile_disable_nvidia_drm else "" }} - name: "Install nvidia-persistenced systemd-file" copy: