Skip to content

Commit

Permalink
Change distro dispatch method
Browse files Browse the repository at this point in the history
  • Loading branch information
doganulus committed Mar 23, 2024
1 parent dfcc624 commit b14d888
Show file tree
Hide file tree
Showing 17 changed files with 45 additions and 28 deletions.
4 changes: 2 additions & 2 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cuda_install_packages: []
cuda_install_nvarch: "{{ lookup('ansible.builtin.env', 'NVARCH', default='x86_64') }}"
cuda_install_distro: "{{ cuda_install_distribution_map[cuda_install_distribution_tag] }}"
cuda_install_nvarch: "{{ lookup('ansible.builtin.env', 'CUDA_ARCH', default='x86_64') }}"
cuda_install_distro: "{{ lookup('ansible.builtin.env', 'CUDA_DISTRO') }}"

cuda_install_nvidia_cuda_repos: https://developer.download.nvidia.com/compute/cuda/repos
cuda_install_debian_family_keyring_filename: cuda-keyring_1.1-1_all.deb
Expand Down
3 changes: 2 additions & 1 deletion molecule/default/verify.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
---
- name: Verify
hosts: all
gather_facts: false
tasks:
- name: Verify CUDA Toolkit
- name: Verify CUDA installation
ansible.builtin.command:
cmd: "/usr/local/cuda-12.4/bin/nvcc --version"
changed_when: false
Expand Down
4 changes: 2 additions & 2 deletions tasks/debian_family_install.yml → tasks/debian-family.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
- name: debian_family_install | Install cuda-keyring
- name: debian-family | Install CUDA keyring
become: true
ansible.builtin.apt:
deb: "{{ cuda_install_debian_family_keyring_file_url }}"

- name: debian_family_install | Install CUDA packages via apt
- name: debian-family | Install CUDA packages via apt
become: true
ansible.builtin.apt:
name: "{{ cuda_install_packages }}"
Expand Down
28 changes: 26 additions & 2 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,28 @@
---
- name: Dispatch to distro family specific tasks
- name: Include distribution specific variables
ansible.builtin.include_vars:
file: "{{ lookup('ansible.builtin.first_found', search_hierarchy) }}"
vars:
search_hierarchy:
files:
- "{{ ansible_distribution | lower | replace('_', '-') | replace(' ', '-') }}-{{ ansible_distribution_version }}.yml"
- "{{ ansible_distribution | lower | replace('_', '-') | replace(' ', '-') }}-{{ ansible_distribution_major_version }}.yml"
- "{{ ansible_distribution | lower | replace('_', '-') | replace(' ', '-') }}.yml"
- "{{ ansible_os_family | lower | replace('_', '-') | replace(' ', '-') }}-family.yml"
- "default_distro.yml"
paths:
- 'vars'

- name: Perform distribution specific tasks
ansible.builtin.include_tasks:
file: "{{ ansible_os_family | lower | replace('_', '-') | replace(' ', '-') }}_family_install.yml"
file: "{{ lookup('ansible.builtin.first_found', search_hierarchy) }}"
vars:
search_hierarchy:
files:
- "{{ ansible_distribution | lower | replace('_', '-') | replace(' ', '-') }}-{{ ansible_distribution_version }}.yml"
- "{{ ansible_distribution | lower | replace('_', '-') | replace(' ', '-') }}-{{ ansible_distribution_major_version }}.yml"
- "{{ ansible_distribution | lower | replace('_', '-') | replace(' ', '-') }}.yml"
- "{{ ansible_os_family | lower | replace('_', '-') | replace(' ', '-') }}-family.yml"
- "default_distro.yml"
paths:
- 'tasks'
4 changes: 2 additions & 2 deletions tasks/redhat_family_install.yml → tasks/redhat-family.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
- name: redhat_family_install | Download the CUDA repository file
- name: redhat-family | Download the CUDA repository file
ansible.builtin.get_url:
url: "{{ cuda_install_redhat_family_repo_baseurl }}"
dest: /etc/yum.repos.d/nvidia_cuda.repo
mode: '0644'

- name: redhat_family_install | Install CUDA packages via yum
- name: redhat-family | Install CUDA packages via yum
become: true
ansible.builtin.yum:
name: "{{ cuda_install_packages }}"
Expand Down
1 change: 1 addition & 0 deletions vars/debian-10.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cuda_install_distro: debian10
1 change: 1 addition & 0 deletions vars/debian-11.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cuda_install_distro: debian11
1 change: 1 addition & 0 deletions vars/debian-12.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cuda_install_distro: debian12
1 change: 1 addition & 0 deletions vars/fedora-39.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cuda_install_distro: fedora39
19 changes: 0 additions & 19 deletions vars/main.yml

This file was deleted.

1 change: 1 addition & 0 deletions vars/redhat-8.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cuda_install_distro: rhel8
1 change: 1 addition & 0 deletions vars/redhat-9.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cuda_install_distro: rhel9
1 change: 1 addition & 0 deletions vars/rocky-8.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cuda_install_distro: rhel8
1 change: 1 addition & 0 deletions vars/rocky-9.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cuda_install_distro: rhel9
1 change: 1 addition & 0 deletions vars/ubuntu-20.04.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cuda_install_distro: ubuntu2004
1 change: 1 addition & 0 deletions vars/ubuntu-22.04.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cuda_install_distro: ubuntu2204
1 change: 1 addition & 0 deletions vars/ubuntu-24.04.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cuda_install_distro: ubuntu2404

0 comments on commit b14d888

Please sign in to comment.