From b17d3d74eb5a9e7640d94f98f6b27ce4891b3c26 Mon Sep 17 00:00:00 2001 From: "Suren A. Chilingaryan" Date: Sun, 6 Oct 2019 04:37:01 +0200 Subject: Integration of CentOS8 and ipecompute nodes --- roles/docker/defaults/main.yml | 8 ++++++++ roles/docker/handlers/main.yml | 4 ++++ roles/docker/tasks/configure_apt.yml | 15 ++++++++++++++ roles/docker/tasks/configure_dnf.yml | 18 +++++++++++++++++ roles/docker/tasks/configure_yum.yml | 38 +++++++++++++++++++++++++++++++++++ roles/docker/tasks/install_docker.yml | 14 +++++++++++++ roles/docker/tasks/install_podman.yml | 12 +++++++++++ roles/docker/tasks/main.yml | 24 ++++++++++++++++++++++ roles/docker/vars/centos-7.yml | 3 +++ roles/docker/vars/centos-8.yml | 11 ++++++++++ 10 files changed, 147 insertions(+) create mode 100644 roles/docker/defaults/main.yml create mode 100644 roles/docker/handlers/main.yml create mode 100644 roles/docker/tasks/configure_apt.yml create mode 100644 roles/docker/tasks/configure_dnf.yml create mode 100644 roles/docker/tasks/configure_yum.yml create mode 100644 roles/docker/tasks/install_docker.yml create mode 100644 roles/docker/tasks/install_podman.yml create mode 100644 roles/docker/tasks/main.yml create mode 100644 roles/docker/vars/centos-7.yml create mode 100644 roles/docker/vars/centos-8.yml (limited to 'roles/docker') diff --git a/roles/docker/defaults/main.yml b/roles/docker/defaults/main.yml new file mode 100644 index 0000000..a5bcb04 --- /dev/null +++ b/roles/docker/defaults/main.yml @@ -0,0 +1,8 @@ +--- +docker_repo_url: "https://download.docker.com/linux" +nvidia_docker_repo_url: "https://nvidia.github.io" + +nvidia_repos: + - libnvidia-container + - nvidia-container-runtime + - nvidia-docker diff --git a/roles/docker/handlers/main.yml b/roles/docker/handlers/main.yml new file mode 100644 index 0000000..3eb0349 --- /dev/null +++ b/roles/docker/handlers/main.yml @@ -0,0 +1,4 @@ +--- +- name: restart docker + systemd: name="docker" daemon_reload="yes" state="restarted" + become: yes 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' + diff --git a/roles/docker/vars/centos-7.yml b/roles/docker/vars/centos-7.yml new file mode 100644 index 0000000..e681468 --- /dev/null +++ b/roles/docker/vars/centos-7.yml @@ -0,0 +1,3 @@ +--- +nvidia_docker_repo_subfolder: centos7 +docker_repo_subfolder: centos/7 diff --git a/roles/docker/vars/centos-8.yml b/roles/docker/vars/centos-8.yml new file mode 100644 index 0000000..d4d24fe --- /dev/null +++ b/roles/docker/vars/centos-8.yml @@ -0,0 +1,11 @@ +--- +# While we have RHEL8 repo, in fact it references centos7 packages +# https://nvidia.github.io/nvidia-docker/rhel8.0/nvidia-docker.repo +# nvidia_docker_repo_subfolder: rhel8.0 +nvidia_docker_repo_subfolder: centos7 +#docker_repo_subfolder: centos/8 + + +nvidia_repos: + - libnvidia-container + - nvidia-container-runtime -- cgit v1.2.3