cleanup and descritive README
This commit is contained in:
parent
ed40c478e9
commit
44e8e027e4
24 changed files with 1605 additions and 2 deletions
9
ansible/roles/docker_ce_install/files/daemon.json
Executable file
9
ansible/roles/docker_ce_install/files/daemon.json
Executable file
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"default-runtime": "nvidia",
|
||||
"runtimes": {
|
||||
"nvidia": {
|
||||
"args": [],
|
||||
"path": "nvidia-container-runtime"
|
||||
}
|
||||
}
|
||||
}
|
||||
0
ansible/roles/docker_ce_install/handlers/main.yml
Executable file
0
ansible/roles/docker_ce_install/handlers/main.yml
Executable file
102
ansible/roles/docker_ce_install/tasks/main.yml
Executable file
102
ansible/roles/docker_ce_install/tasks/main.yml
Executable file
|
|
@ -0,0 +1,102 @@
|
|||
---
|
||||
- name: Install docker dependencies
|
||||
ansible.builtin.apt:
|
||||
pkg:
|
||||
- apt-transport-https
|
||||
- ca-certificates
|
||||
- curl
|
||||
- gnupg-agent
|
||||
- software-properties-common
|
||||
- python3-docker
|
||||
update_cache: true
|
||||
|
||||
- name: Prepare keyrings directory
|
||||
ansible.builtin.file:
|
||||
path: /etc/apt/keyrings
|
||||
state: directory
|
||||
mode: '0755'
|
||||
|
||||
- name: Add Docker and Nvidia GPG apt Key
|
||||
block:
|
||||
- name: Get keys via download
|
||||
ansible.builtin.get_url:
|
||||
url: "{{ item.url }}"
|
||||
dest: /etc/apt/keyrings/{{ item.keyfile }}
|
||||
mode: "a+r"
|
||||
with_items:
|
||||
- { url: https://download.docker.com/linux/ubuntu/gpg, keyfile: "docker.asc"}
|
||||
- name: Add keys to apt key
|
||||
ansible.builtin.apt_key:
|
||||
url: "{{ item }}"
|
||||
state: present
|
||||
keyring:
|
||||
with_items:
|
||||
- https://download.docker.com/linux/ubuntu/gpg
|
||||
- https://nvidia.github.io/libnvidia-container/gpgkey
|
||||
- name: Add repos
|
||||
ansible.builtin.apt_repository:
|
||||
repo: "deb {{ item.repo }}"
|
||||
state: present
|
||||
with_items:
|
||||
- repo: "[arch=amd64 signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu {{ ansible_facts['distribution_release'] }} stable"
|
||||
- repo: "https://nvidia.github.io/libnvidia-container/stable/deb/amd64 /"
|
||||
|
||||
- name: Install docker
|
||||
ansible.builtin.apt:
|
||||
name: "{{ item }}"
|
||||
state: present
|
||||
update_cache: true
|
||||
with_items:
|
||||
- docker-ce
|
||||
- docker-ce-cli
|
||||
- containerd.io
|
||||
- docker-buildx-plugin
|
||||
- nvidia-container-toolkit
|
||||
|
||||
- name: Configure nvidia-container-toolkit
|
||||
ansible.builtin.command:
|
||||
cmd: nvidia-ctk runtime configure --runtime=docker
|
||||
register: nvidia_container_toolkit_configure
|
||||
|
||||
- name: Start and enable docker-rootful service
|
||||
ansible.builtin.systemd:
|
||||
name: "{{ item }}"
|
||||
state: restarted
|
||||
enabled: true
|
||||
with_items:
|
||||
- docker.service
|
||||
- docker.socket
|
||||
|
||||
- name: Deploy daemon.json
|
||||
ansible.builtin.copy:
|
||||
src: daemon.json
|
||||
dest: /etc/docker/daemon.json
|
||||
mode: '0644'
|
||||
|
||||
- name: Check nvidia-container-toolkit deployment
|
||||
block:
|
||||
- name: Deploy nvidia test containe
|
||||
ansible.builtin.shell:
|
||||
cmd: "sudo docker run --rm --runtime=nvidia --gpus all nvidia/cuda:11.6.2-base-ubuntu20.04 nvidia-smi"
|
||||
register: nvidia_container_toolkit_configure
|
||||
- name: Print result of nvidia-ctk runtime configure --runtime=docker
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ nvidia_container_toolkit_configure }}"
|
||||
|
||||
- name: Prepare docker group
|
||||
ansible.builtin.user:
|
||||
name: "{{ item }}"
|
||||
group: docker
|
||||
append: true
|
||||
state: present
|
||||
with_items:
|
||||
- blurringtool
|
||||
|
||||
- name: Start and enable docker-rootful service
|
||||
ansible.builtin.systemd:
|
||||
name: "{{ item }}"
|
||||
state: started
|
||||
enabled: true
|
||||
with_items:
|
||||
- docker.service
|
||||
- docker.socket
|
||||
Loading…
Add table
Add a link
Reference in a new issue