added ansible for deployment in private infrastrucutre

This commit is contained in:
2021-05-21 12:44:15 +04:00
parent 64bc064e56
commit 616f161c36
51 changed files with 864 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
# The `cuda` Role
The `cuda` role installs the Nvidia CUDA GPU repository and drivers.
This role may be executed independently by running:
```bash
$ ansible-playbook packages.yml --tags "cuda"
```
On execution, this role installs the following directly to the remote machine's operating system:
### Apt Repositories (Debian/Ubuntu)
- Nvidia CUDA
### Apt GPG Signing Keys (Debian/Ubuntu)
- cudatools <cudatools@nvidia.com>
### Operating System Packages (Debian/Ubuntu)
- cuda v10.x

View File

View File

@@ -0,0 +1,5 @@
---
# CUDA Driver Setup
- name: reboot the machine
reboot:
listen: "reboot the machine"

View File

View File

@@ -0,0 +1,22 @@
---
# Cuda Driver Package Installation
- name: copy the CUDA repo onto the machine
copy:
src: "{{ cuda.apt.repo }}"
dest: "{{ general.working_dir }}/{{ cuda.apt.repo }}"
- name: get the CUDA signing key
apt_key:
state: present
url: "{{ cuda.apt.signing_key_url }}"
- name: add the CUDA repo
apt:
deb: "{{ general.working_dir }}/{{ cuda.apt.repo }}"
state: present
- name: install the CUDA drivers
apt:
name: "{{ cuda.apt.package }}"
update_cache: yes
notify: "reboot the machine"

View File

@@ -0,0 +1,3 @@
---
- import_tasks: debian.yml
when: ansible_facts['os_family']|lower == 'debian' # debian, ubuntu

View File

View File

@@ -0,0 +1,9 @@
---
cuda:
apt:
package: cuda=10.* # known good with 10.0.130-1
repo: cuda-repo-ubuntu1804_10.0.130-1_amd64.deb # Network install
signing_key_url: https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub
general:
working_dir: /tmp

View File

@@ -0,0 +1,33 @@
# The `docker` Role
The `docker` role installs the Docker CE repository and runtime packages.
This role may be executed independently by running:
```bash
$ ansible-playbook packages.yml --tags "docker"
```
On execution, this role installs the following directly to the remote machine's operating system:
### Apt Repositories (Debian/Ubuntu)
- Docker CE
### Apt GPG Signing Keys (Debian/Ubuntu)
- Docker Release (CE deb) <docker@docker.com>
### Operating System Packages (Debian/Ubuntu)
- docker-ce v5:18.x
### System Services
- `docker` (enabled and started)
### User Groups
- docker
All users listed under `secrets.users` in `secrets.yml` will be added to the `docker` group.

View File

View File

View File

View File

View File

@@ -0,0 +1,17 @@
---
# Docker Package Installation
- name: add Docker's official GPG key
apt_key:
state: present
url: "{{ docker.apt.signing_key_url }}"
- name: add Docker apt repository
apt_repository:
repo: "{{ docker.apt.repo }}"
state: present
- name: install Docker CE
apt:
name: "{{ docker.apt.package }}"
state: present
update_cache: yes

View File

@@ -0,0 +1,23 @@
---
# General Docker Setup
- import_tasks: debian.yml
when: ansible_facts['os_family']|lower == 'debian' # debian, ubuntu
- name: ensure the docker service starts at boot
systemd:
name: "{{ docker.service_name }}"
enabled: yes
state: started
- name: create Docker group to avoid running as root
group:
name: "{{ docker.group_name }}"
state: present
- name: add users to Docker group
user:
append: yes
groups:
- "{{ docker.group_name }}"
name: "{{ item }}"
loop: "{{ users }}"

View File

View File

@@ -0,0 +1,8 @@
---
docker:
apt:
package: docker-ce=5:18.* # known good with 5:18.09.1~3-0~ubuntu-bionic
repo: deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable
signing_key_url: https://download.docker.com/linux/ubuntu/gpg
group_name: docker
service_name: docker

View File

@@ -0,0 +1,31 @@
# The `nvidia` Role
The `nvidia` role installs the Nvidia Docker runtime, enabling access to Nvidia CUDA GPU hardware from within Docker containers.
This role may be executed independently by running:
```bash
$ ansible-playbook packages.yml --tags "nvidia"
```
On execution, this role installs the following directly to the remote machine's operating system:
### Apt Repositories (Debian/Ubuntu)
- libnvidia_container
- nvidia_container_runtime
- nvidia_docker
### Apt GPG Signing Keys (Debian/Ubuntu)
- NVIDIA CORPORATION (Open Source Projects) <cudatools@nvidia.com>
### Operating System Packages (Debian/Ubuntu)
- nvidia-docker2 v2.x
Containers are launched with the Nvidia Docker runtime by passing the `--runtime=nvidia` flag, e.g.,
```bash
$ docker run --rm --runtime=nvidia nvidia/cuda nvidia-smi
```

View File

View File

View File

@@ -0,0 +1,6 @@
---
- name: reload the docker service
systemd:
name: docker
state: reloaded
listen: "reload the docker service"

View File

View File

@@ -0,0 +1,31 @@
---
# Nvidia Docker Runtime Installation
- name: get the NVIDIA signing key
apt_key:
state: present
url: "{{ nvidia.apt.signing_key_url }}"
- name: add the libnvidia-container repo
apt_repository:
filename: "{{ nvidia.apt.repo_filename }}"
repo: "{{ nvidia.apt.repos.libnvidia_container }}"
state: present
- name: add the nvidia-container-runtime repo
apt_repository:
filename: "{{ nvidia.apt.repo_filename }}"
repo: "{{ nvidia.apt.repos.nvidia_container_runtime }}"
state: present
- name: add the nvidia-docker repo
apt_repository:
filename: "{{ nvidia.apt.repo_filename }}"
repo: "{{ nvidia.apt.repos.nvidia_docker }}"
state: present
- name: install the nvidia-docker2 runtime
apt:
name: "{{ nvidia.apt.package }}"
state: present
update_cache: yes
notify: "reload the docker service"

View File

@@ -0,0 +1,4 @@
---
# Nvidia Docker Runtime Setup
- import_tasks: debian.yml
when: ansible_facts['os_family']|lower == 'debian' # debian, ubuntu

View File

View File

@@ -0,0 +1,10 @@
---
nvidia:
apt:
package: nvidia-docker2=2.* # known good with 2.0.3+docker18.09.1-1
repo_filename: nvidia_github_io_nvidia_docker_ubuntu18_04_nvidia_docker.list
repos:
libnvidia_container: deb https://nvidia.github.io/libnvidia-container/ubuntu18.04/$(ARCH) /
nvidia_container_runtime: deb https://nvidia.github.io/nvidia-container-runtime/ubuntu18.04/$(ARCH) /
nvidia_docker: deb https://nvidia.github.io/nvidia-docker/ubuntu18.04/$(ARCH) /
signing_key_url: https://nvidia.github.io/nvidia-docker/gpgkey

View File

@@ -0,0 +1,26 @@
# The `packages` Role
The `packages` role installs the operating system and Python pre-requisites that are required to execute the other roles.
This role may be executed independently by running:
```bash
$ ansible-playbook packages.yml --tags "packages"
```
On execution, this role installs the following directly to the remote machine's operating system:
### Operating System Packages (Debian/Ubuntu)
- apt-transport-https v1.x
- ca-certificates v20180409
- curl v7.x
- gnupg-agent v2.x
- python-apt v1.x
- python-pip v9.x
- python-setuptools v39.x
- software-properties-common v0.96.24.32.7
### Python (pip) Packages
- docker v3.7.0 or greater

View File

View File

View File

View File

View File

@@ -0,0 +1,12 @@
---
# General Dependencies
- name: install general apt dependencies
apt:
name: "{{ general.dependencies.apt }}"
state: present
update_cache: yes
- name: install general pip dependencies for Ansible
pip:
name: "{{ general.dependencies.pip }}"
state: present

View File

@@ -0,0 +1,3 @@
---
- import_tasks: debian.yml
when: ansible_facts['os_family']|lower == 'debian' # debian, ubuntu

View File

View File

@@ -0,0 +1,17 @@
---
# General Dependencies
general:
dependencies:
apt:
- apt-transport-https=1.* # known good with 1.6.6ubuntu0.1 all
- ca-certificates=20180409 # known good with 20180409
- curl=7.* # known good with 7.58.0-2ubuntu3.5
- gnupg-agent=2.* # known good with 2.2.4-1ubuntu1.2
- python3-apt=1.* # known good with 1.6.3
- python3-pip=9.* # known good with 9.0.1-2.3~ubuntu1
- python3-setuptools=39.* # known good with 39.0.1-2
- software-properties-common=0.96.24.32.7 # known good with 0.96.24.32.7
- git
- golang
pip:
- docker>=3.7.0 # known good with 3.7.0

View File

View File

@@ -0,0 +1,16 @@
motd file = /etc/rsyncd.motd
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
[jupyter_data]
path = /nfs/jupyter/data
comment = Jupyter data files
uid = nobody
gid = nobody
read only = yes
list = yes
auth users = @rsync:ro
secrets file = /etc/rsyncd.secrets
hosts allow = 192.168.1.0/24
hosts deny = 0.0.0.0/0

View File

@@ -0,0 +1,5 @@
---
- name: restart the rsync service
systemd:
name: "{{ rsync.service_name }}"
state: restarted

View File

View File

@@ -0,0 +1,26 @@
---
# Configure the rsync daemon on the master
- name: copy rsync.conf up to the server
copy:
src: "{{ rsync.config_file.src }}"
dest: "{{ rsync.config_file.dest }}"
notify:
- restart the rsync service
when: inventory_hostname == rsync.master
- name: configure rsync on the server
service:
enabled: yes
name: "{{ rsync.service_name }}"
state: started
when: inventory_hostname == rsync.master
# Synchronize the data folder across hosts
- name: synchronize the data folder
delegate_to: "{{ rsync.master }}"
synchronize:
src: "{{ sync.source }}"
dest: "{{ sync.destination }}"
rsync_opts: "{{ rsync.options }}"
use_ssh_args: yes
when: inventory_hostname != rsync.master

View File

View File

@@ -0,0 +1,10 @@
---
rsync:
config_file:
src: rsyncd.conf
dest: /etc/rsyncd.conf
master: ml1
options:
- "-e ssh"
- "--no-motd"
service_name: rsync