Created
April 9, 2018 16:59
-
-
Save dholt/08163bc0b1d37415d890f4afc1673fab to your computer and use it in GitHub Desktop.
Simple Ansible playbook for installing nvidia-docker-2 and setting it as the default runtime for Docker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- hosts: all | |
become: true | |
become_method: sudo | |
vars: | |
daemon_json: | |
bip: 192.168.99.1/24 | |
default-runtime: nvidia | |
runtimes: | |
nvidia: | |
path: /usr/bin/nvidia-container-runtime | |
runtimeArgs: [] | |
tasks: | |
- name: remove nvidia-docker v1 | |
apt: | |
name: nvidia-docker | |
state: removed | |
purge: yes | |
- name: nvidia-docker | apt key | |
apt_key: | |
url: https://nvidia.github.io/nvidia-docker/gpgkey | |
state: present | |
- name: nvidia-docker | apt repo | |
apt_repository: | |
repo: "{{ item }}" | |
state: present | |
filename: 'nvidia-docker' | |
update_cache: yes | |
with_items: | |
- "deb https://nvidia.github.io/libnvidia-container/ubuntu16.04/amd64 /" | |
- "deb https://nvidia.github.io/nvidia-container-runtime/ubuntu16.04/amd64 /" | |
- "deb https://nvidia.github.io/nvidia-docker/ubuntu16.04/amd64 /" | |
- name: nvidia-docker | install | |
apt: | |
name: "{{ item }}" | |
state: present | |
with_items: | |
- "nvidia-docker2=2.0.2+docker17.03.2-1" | |
- "nvidia-container-runtime=1.1.1+docker17.03.2-1" | |
- name: set docker default runtime | |
copy: | |
content: "{{ daemon_json | to_nice_json }}" | |
dest: /etc/docker/daemon.json | |
owner: root | |
group: root | |
mode: 0644 | |
- name: docker | restart service | |
service: name=docker state=restarted enabled=yes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment