aipackage/ansible/roles/base/tasks/main.yml

99 lines
2.4 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
# Base role: OS updates, essential packages, Python/Miniconda
- name: Update apt cache
apt:
update_cache: yes
cache_valid_time: 3600
- name: Upgrade all packages (this takes 1020 min on first run, please wait...)
apt:
upgrade: dist
autoremove: yes
- name: Install essential system packages
apt:
name:
- curl
- wget
- git
- build-essential
- ca-certificates
- gnupg
- lsb-release
- software-properties-common
- unzip
- htop
- net-tools
- jq
- python3-pip
- python3-venv
state: present
- name: Create cezen user
user:
name: cezen
shell: /bin/bash
home: /opt/cezen
create_home: yes
groups: sudo
append: yes
- name: Create cezen directories
file:
path: "{{ item }}"
state: directory
owner: cezen
group: cezen
mode: "0755"
loop:
- /opt/cezen
- /opt/cezen/models
- /opt/cezen/data
- /opt/cezen/logs
- name: Download Miniconda
get_url:
url: https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
dest: /tmp/miniconda.sh
mode: "0755"
retries: 3
delay: 10
- name: Install Miniconda
become_user: cezen
command: bash /tmp/miniconda.sh -b -p /opt/cezen/miniconda
args:
creates: /opt/cezen/miniconda/bin/conda
- name: Add conda to cezen PATH
lineinfile:
path: /opt/cezen/.bashrc
line: 'export PATH="/opt/cezen/miniconda/bin:$PATH"'
create: yes
owner: cezen
- name: Accept Anaconda Terms of Service (required since 2024)
become_user: cezen
shell: |
/opt/cezen/miniconda/bin/conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/main
/opt/cezen/miniconda/bin/conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/r
changed_when: false
- name: Create cezen conda environment (Python 3.11)
become_user: cezen
command: /opt/cezen/miniconda/bin/conda create -n cezen python=3.11 -y
args:
creates: /opt/cezen/miniconda/envs/cezen
- name: Install LangChain + LlamaIndex + HuggingFace in conda env (510 min, please wait...)
become_user: cezen
shell: |
/opt/cezen/miniconda/bin/conda run -n cezen pip install \
langchain langchain-community llama-index \
transformers huggingface-hub \
peft bitsandbytes accelerate \
fastapi uvicorn[standard] \
sentence-transformers
retries: 3
delay: 15