Update var names; allow state=absent in tasks

This commit is contained in:
Luke Yeager 2019-04-29 10:04:27 -07:00
parent bb6de2e239
commit b8ead6124c
7 changed files with 72 additions and 57 deletions

View File

@ -1,10 +1,19 @@
nvidia_driver_package_state: present
nvidia_driver_package_version: ''
nvidia_driver_persistence_mode_on: yes
nvidia_driver_skip_reboot: no
epel_baseurl: "https://download.fedoraproject.org/pub/epel/$releasever/$basearch/"
epel_gpgkey: "https://epel.mirror.constant.com//RPM-GPG-KEY-EPEL-{{ ansible_distribution_major_version }}"
rhel_cuda_baseurl: "https://developer.download.nvidia.com/compute/cuda/repos/{{ rhel_repo_dir }}/"
rhel_cuda_gpgkey: "https://developer.download.nvidia.com/compute/cuda/repos/{{ rhel_repo_dir }}/7fa2af80.pub"
ubuntu_cuda_gpgkey: "https://developer.download.nvidia.com/compute/cuda/repos/{{ ubuntu_repo_dir }}/7fa2af80.pub"
ubuntu_cuda_apt_key: "7fa2af80"
ubuntu_cuda_baseurl: "http://developer.download.nvidia.com/compute/cuda/repos/{{ ubuntu_repo_dir }}"
#
# Settings for airgapped systems
#
# RedHat family
nvidia_driver_rhel_epel_repo_baseurl: "https://download.fedoraproject.org/pub/epel/$releasever/$basearch/"
nvidia_driver_rhel_epel_repo_gpgkey: "https://epel.mirror.constant.com//RPM-GPG-KEY-EPEL-{{ ansible_distribution_major_version }}"
nvidia_driver_rhel_cuda_repo_baseurl: "https://developer.download.nvidia.com/compute/cuda/repos/{{ _rhel_repo_dir }}/"
nvidia_driver_rhel_cuda_repo_gpgkey: "https://developer.download.nvidia.com/compute/cuda/repos/{{ _rhel_repo_dir }}/7fa2af80.pub"
# Ubuntu
nvidia_driver_ubuntu_cuda_repo_gpgkey_url: "https://developer.download.nvidia.com/compute/cuda/repos/{{ _ubuntu_repo_dir }}/7fa2af80.pub"
nvidia_driver_ubuntu_cuda_repo_gpgkey_id: "7fa2af80"
nvidia_driver_ubuntu_cuda_repo_baseurl: "http://developer.download.nvidia.com/compute/cuda/repos/{{ _ubuntu_repo_dir }}"

View File

@ -1,4 +1,30 @@
---
- name: add epel repo
yum_repository:
name: epel
description: EPEL YUM repo
baseurl: "{{ nvidia_driver_rhel_epel_repo_baseurl }}"
gpgkey: "{{ nvidia_driver_rhel_epel_repo_gpgkey }}"
- name: install dependencies
yum:
name: dkms
state: latest
- name: add repo
yum_repository:
name: cuda
description: NVIDIA CUDA YUM Repo
baseurl: "{{ nvidia_driver_rhel_cuda_repo_baseurl }}"
gpgkey: "{{ nvidia_driver_rhel_cuda_repo_gpgkey }}"
- name: install driver packages
yum:
name: "{{ nvidia_driver_package_version | ternary('cuda-drivers='+nvidia_driver_package_version, 'cuda-drivers') }}"
state: "{{ nvidia_driver_package_state }}"
autoremove: "{{ nvidia_driver_package_state == 'absent' }}"
register: install_driver
# The driver package pulls in the latest kernel-headers package, but not the
# latest kernel. Check to see if there is a mismatch.

23
tasks/install-ubuntu.yml Normal file
View File

@ -0,0 +1,23 @@
---
- name: remove ppa
apt_repository:
repo: ppa:graphics-drivers/ppa
state: absent
- name: add key
apt_key:
url: "{{ nvidia_driver_ubuntu_cuda_repo_gpgkey_url }}"
id: "{{ nvidia_driver_ubuntu_cuda_repo_gpgkey_id }}"
- name: add repo
apt_repository:
repo: "deb {{ nvidia_driver_ubuntu_cuda_repo_baseurl }} /"
update_cache: yes
- name: install driver packages
apt:
name: "{{ nvidia_driver_package_version | ternary('cuda-drivers='+nvidia_driver_package_version, 'cuda-drivers') }}"
state: "{{ nvidia_driver_package_state }}"
autoremove: "{{ nvidia_driver_package_state == 'absent' }}"
purge: "{{ nvidia_driver_package_state == 'absent' }}"
register: install_driver

View File

@ -5,22 +5,12 @@
state: absent
ignore_errors: true
- name: ubuntu pre-install tasks
include_tasks: ubuntu-pre-install.yml
- name: ubuntu install tasks
include_tasks: install-ubuntu.yml
when: ansible_distribution == 'Ubuntu'
- name: redhat family pre-install tasks
include_tasks: redhat-pre-install.yml
when: ansible_os_family == 'RedHat'
- name: install driver packages
package:
name: "{{ nvidia_driver_package_version | ternary('cuda-drivers='+nvidia_driver_package_version, 'cuda-drivers') }}"
state: present
register: install_driver
- name: redhat family post-install tasks
include_tasks: redhat-post-install.yml
- name: redhat family install tasks
include_tasks: install-redhat.yml
when: ansible_os_family == 'RedHat'
- name: create persistenced override dir
@ -45,6 +35,7 @@
systemd:
name: nvidia-persistenced
enabled: yes
when: nvidia_driver_package_state != 'absent'
- name: reboot after driver install
reboot:

View File

@ -1,19 +0,0 @@
---
- name: add epel repo
yum_repository:
name: epel
description: EPEL YUM repo
baseurl: "{{ epel_baseurl }}"
gpgkey: "{{ epel_gpgkey }}"
- name: install dependencies
yum:
name: dkms
state: latest
- name: add repo
yum_repository:
name: cuda
description: NVIDIA CUDA YUM Repo
gpgkey: "{{ rhel_cuda_gpgkey }}"
baseurl: "{{ rhel_cuda_baseurl }}"

View File

@ -1,15 +0,0 @@
---
- name: remove ppa
apt_repository:
repo: ppa:graphics-drivers/ppa
state: absent
- name: add key
apt_key:
url: "{{ ubuntu_cuda_gpgkey }}"
id: "{{ ubuntu_cuda_apt_key }}"
- name: add repo
apt_repository:
repo: "deb {{ ubuntu_cuda_baseurl }} /"
update_cache: yes

View File

@ -1,2 +1,2 @@
ubuntu_repo_dir: "{{ ansible_distribution | lower }}{{ ansible_distribution_version | replace('.', '') }}/{{ ansible_architecture }}"
rhel_repo_dir: "rhel{{ ansible_distribution_major_version }}/{{ ansible_architecture }}"
_ubuntu_repo_dir: "{{ ansible_distribution | lower }}{{ ansible_distribution_version | replace('.', '') }}/{{ ansible_architecture }}"
_rhel_repo_dir: "rhel{{ ansible_distribution_major_version }}/{{ ansible_architecture }}"