summaryrefslogtreecommitdiffstats
path: root/roles/docker/tasks
diff options
context:
space:
mode:
Diffstat (limited to 'roles/docker/tasks')
-rw-r--r--roles/docker/tasks/configure_apt.yml15
-rw-r--r--roles/docker/tasks/configure_dnf.yml18
-rw-r--r--roles/docker/tasks/configure_yum.yml38
-rw-r--r--roles/docker/tasks/install_docker.yml14
-rw-r--r--roles/docker/tasks/install_podman.yml12
-rw-r--r--roles/docker/tasks/main.yml24
6 files changed, 121 insertions, 0 deletions
diff --git a/roles/docker/tasks/configure_apt.yml b/roles/docker/tasks/configure_apt.yml
new file mode 100644
index 0000000..3fd961a
--- /dev/null
+++ b/roles/docker/tasks/configure_apt.yml
@@ -0,0 +1,15 @@
+---
+# tasks file for ansible-role-cuda
+- name: Trust packaging key for Nvidia repositories (apt)
+ apt_key:
+ data: "{{ lookup('file', 'files/nvidia_docker_packaging_key.asc') }}"
+ id: "{{ nvidia_docker_packaging_key_id }}"
+ state: present
+
+- name: Configure Nvidia repository (apt)
+ apt_repository:
+ repo: "deb {{ nvidia_docker_repo_url }}/{{ nvidia_docker_repo_subfolder }} /"
+ filename: nvidia_docker
+ state: present
+
+# vim:ft=ansible:
diff --git a/roles/docker/tasks/configure_dnf.yml b/roles/docker/tasks/configure_dnf.yml
new file mode 100644
index 0000000..73ecb30
--- /dev/null
+++ b/roles/docker/tasks/configure_dnf.yml
@@ -0,0 +1,18 @@
+---
+- name: Import NVIDIA Docker repository gpg keys
+ rpm_key:
+ key: "{{ nvidia_docker_repo_url }}/{{ item }}/gpgkey"
+ state: present
+ with_items: "{{ nvidia_repos }}"
+ when: "'cuda' in group_names"
+
+- name: Configure Nvidia repositories (yum)
+ yum_repository:
+ name: "{{ item }}"
+ description: Official {{ item }} repository
+ baseurl: "{{ nvidia_docker_repo_url }}/{{ item }}/{{ nvidia_docker_repo_subfolder }}/x86_64/"
+ gpgkey: "{{ nvidia_docker_repo_url }}/{{ item }}/gpgkey"
+ gpgcheck: no
+ enabled: yes
+ with_items: "{{ nvidia_repos }}"
+ when: "'cuda' in group_names"
diff --git a/roles/docker/tasks/configure_yum.yml b/roles/docker/tasks/configure_yum.yml
new file mode 100644
index 0000000..99a2743
--- /dev/null
+++ b/roles/docker/tasks/configure_yum.yml
@@ -0,0 +1,38 @@
+---
+- name: Upload packaging key for docker repositories
+ copy:
+ src: docker_packaging_key.asc
+ dest: "{{ docker_rpm_key_path }}"
+ mode: 0644
+
+- name: Import Docker CE repository gpg key
+ rpm_key:
+ key: https://download.docker.com/linux/centos/gpg
+ state: present
+
+- name: Import NVIDIA Docker repository gpg keys
+ rpm_key:
+ key: "{{ nvidia_docker_repo_url }}/{{ item }}/gpgkey"
+ state: present
+ with_items: "{{ nvidia_repos }}"
+
+- name: Configure docker repositories (yum)
+ yum_repository:
+ name: "docker-ce-{{ item }}"
+ description: Official docker-ce repository
+ baseurl: "{{ docker_repo_url }}/{{ docker_repo_subfolder }}/x86_64/{{ item }}"
+ gpgkey: https://download.docker.com/linux/centos/gpg
+ gpgcheck: yes
+ enabled: yes
+ with_items:
+ - stable
+
+- name: Configure Nvidia repositories (yum)
+ yum_repository:
+ name: "{{ item }}"
+ description: Official {{ item }} repository
+ baseurl: "{{ nvidia_docker_repo_url }}/{{ item }}/{{ nvidia_docker_repo_subfolder }}/x86_64/"
+ gpgkey: "{{ nvidia_docker_repo_url }}/{{ item }}/gpgkey"
+ gpgcheck: no
+ enabled: yes
+ with_items: "{{ nvidia_repos }}"
diff --git a/roles/docker/tasks/install_docker.yml b/roles/docker/tasks/install_docker.yml
new file mode 100644
index 0000000..9ae0cb9
--- /dev/null
+++ b/roles/docker/tasks/install_docker.yml
@@ -0,0 +1,14 @@
+- name: Install requirements
+ package: name="{{ item }}" state=present
+ with_items:
+ - lvm2
+
+- name: Install nvidia docker
+ package: name="nvidia-docker2" state=present
+ notify:
+ - restart docker
+
+- name: Install additional packages
+ package: name="{{ item }}" state=present
+ with_items:
+ - docker-compose
diff --git a/roles/docker/tasks/install_podman.yml b/roles/docker/tasks/install_podman.yml
new file mode 100644
index 0000000..3498aa7
--- /dev/null
+++ b/roles/docker/tasks/install_podman.yml
@@ -0,0 +1,12 @@
+- name: Install docker packages
+ package: name="{{ item }}" state=present
+ with_items:
+ - podman
+ - buildah
+ - skopeo
+
+- name: Install NVIDIA packages
+ package: name="{{ item }}" state=present
+ with_items:
+ - nvidia-container-runtime
+ when: "'cuda' in group_names"
diff --git a/roles/docker/tasks/main.yml b/roles/docker/tasks/main.yml
new file mode 100644
index 0000000..f13f99f
--- /dev/null
+++ b/roles/docker/tasks/main.yml
@@ -0,0 +1,24 @@
+---
+- name: "Gather OS specific variables"
+ include_vars: "{{ item }}"
+ with_first_found:
+ - "{{ ansible_distribution|lower }}-{{ ansible_distribution_version }}.yml"
+ - "{{ ansible_distribution|lower }}-{{ ansible_distribution_major_version }}.yml"
+ - "{{ ansible_distribution|lower }}.yml"
+ - "{{ ansible_os_family|lower }}.yml"
+
+- include_tasks: configure_yum.yml
+ when: ansible_pkg_mgr == 'yum'
+
+- include_tasks: configure_dnf.yml
+ when: ansible_pkg_mgr == 'dnf'
+
+- include_tasks: configure_apt.yml
+ when: ansible_pkg_mgr == 'apt'
+
+- include_tasks: install_docker.yml
+ when: ansible_pkg_mgr == 'yum' or ansible_pkg_mgr == 'apt'
+
+- include_tasks: install_podman.yml
+ when: ansible_pkg_mgr == 'dnf'
+