-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9f7d10e
commit c7b2147
Showing
13 changed files
with
149 additions
and
175 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,10 @@ | ||
# Fresh install | ||
1. Go Root: | ||
``` | ||
sudo su | ||
``` | ||
2. Install Ansible: | ||
``` | ||
sudo apt install -y software-properties-common | ||
sudo add-apt-repository --yes --update ppa:ansible/ansible | ||
sudo apt install -y ansible | ||
``` | ||
3. Git Clone Repo: | ||
``` | ||
git clone https://github.com/ && | ||
cd ansibledirectory | ||
``` | ||
4. Setup Docker with Ansible: | ||
``` | ||
ansible-playbook docker.yaml | ||
``` | ||
5. Setup Nvidia drivers: | ||
``` | ||
ansible-playbook nvidia.yaml | ||
``` | ||
6. Reboot the system for the changes to take effect: | ||
``` | ||
sudo reboot | ||
``` | ||
7. Install Nvidia container runtime for docker: | ||
``` | ||
ansible-playbook nvidia-container.yaml | ||
``` | ||
# Install ansible on your local pc/laptop | ||
```brew install ansible``` | ||
# Add some info to inventories/hosts.ini | ||
To ansible_host add Domain or IP address of your server | ||
To ansible_user add name of user from your server | ||
To ansible_become_password add password from your server | ||
# Add your ssh key to ssh-agent localy | ||
```ssh-add ~/.ssh/id_rsa``` | ||
# Start script | ||
```ansible-playbook -i inventories/hosts.ini install.yaml``` |
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
- name: Install | ||
hosts: all | ||
become: yes | ||
roles: | ||
- install |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[main] | ||
server ansible_host= ansible_user= ansible_become_password= |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
--- | ||
- name: Update package list | ||
become: yes | ||
apt: | ||
update_cache: yes | ||
|
||
- name: Install required packages | ||
become: yes | ||
apt: | ||
name: | ||
- ca-certificates | ||
- curl | ||
- net-tools | ||
- apt-transport-https | ||
- software-properties-common | ||
- python3-pip | ||
- virtualenv | ||
- python3-setuptools | ||
- gnupg-agent | ||
- autoconf | ||
- dpkg-dev | ||
- file | ||
- g++ | ||
- gcc | ||
- libc-dev | ||
- make | ||
- pkg-config | ||
- re2c | ||
- wget | ||
|
||
- name: Create /etc/apt/keyrings directory | ||
become: yes | ||
file: | ||
path: /etc/apt/keyrings | ||
state: directory | ||
mode: "0755" | ||
|
||
- name: Download and install Docker GPG keyring | ||
become: yes | ||
shell: "curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor --yes -o /etc/apt/keyrings/docker.gpg" | ||
|
||
- name: Add Repo | ||
ansible.builtin.apt_repository: | ||
filename: docker.gpg | ||
repo: "deb [arch={{ 'arm64' if ansible_architecture == 'aarch64' else 'amd64' }} signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu {{ ansible_distribution_release }} stable" | ||
state: present | ||
|
||
- name: Update package | ||
become: yes | ||
apt: | ||
update_cache: yes | ||
|
||
- name: Install docker | ||
ansible.builtin.apt: | ||
name: ["docker-ce", "docker-ce-cli", "containerd.io"] | ||
state: latest | ||
update_cache: true | ||
|
||
- name: Install docker-compose from official github repo | ||
ansible.builtin.get_url: | ||
url: https://github.com/docker/compose/releases/download/1.29.2/docker-compose-Linux-x86_64 | ||
dest: /usr/local/bin/docker-compose | ||
mode: "u+x,g+x" | ||
|
||
- name: Install Docker Module for Python | ||
ansible.builtin.pip: | ||
name: docker |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
- import_tasks: docker.yaml | ||
- import_tasks: nvidia.yaml | ||
- import_tasks: nvidia-container.yaml |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- | ||
- name: Add NVIDIA Docker GPG key | ||
ansible.builtin.apt_key: | ||
url: "https://nvidia.github.io/nvidia-docker/gpgkey" | ||
state: present | ||
|
||
- name: Add NVIDIA Docker repository | ||
ansible.builtin.get_url: | ||
url: "https://nvidia.github.io/nvidia-docker/{{ ansible_distribution|lower }}{{ ansible_distribution_version }}/nvidia-docker.list" | ||
dest: "/etc/apt/sources.list.d/nvidia-docker.list" | ||
mode: "0644" | ||
owner: "root" | ||
group: "root" | ||
|
||
- name: Update apt cache | ||
ansible.builtin.apt: | ||
update_cache: yes | ||
|
||
- name: Install NVIDIA container runtime | ||
ansible.builtin.apt: | ||
name: nvidia-container-runtime | ||
state: present | ||
|
||
- name: Restart Docker service | ||
ansible.builtin.systemd: | ||
name: docker | ||
state: restarted | ||
|
||
- name: Run NVIDIA container | ||
ansible.builtin.command: | ||
cmd: "docker run --gpus all nvidia/cuda:12.3.1-base-ubuntu22.04 nvidia-smi" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
- name: Add Nvidia Graphics Drivers PPA | ||
ansible.builtin.apt_repository: | ||
repo: "ppa:graphics-drivers/ppa" | ||
state: present | ||
filename: nvidia-graphics-drivers-ppa | ||
|
||
- name: Install Ubuntu drivers | ||
ansible.builtin.apt: | ||
name: ubuntu-drivers-common | ||
state: present | ||
|
||
- name: Install Nvidia driver version custom | ||
ansible.builtin.apt: | ||
name: nvidia-driver-530 | ||
state: present | ||
|
||
- name: Reboot server | ||
ansible.builtin.reboot: | ||
reboot_timeout: 600 | ||
ignore_errors: yes | ||
|
||
- name: Wait for the server to be back online | ||
ansible.builtin.wait_for_connection: | ||
timeout: 300 | ||
|
||
- name: Continue tasks after reboot | ||
ansible.builtin.shell: | | ||
echo "Server is back online, continuing tasks..." |