136 lines
3.6 KiB
YAML
136 lines
3.6 KiB
YAML
- name: check/create instance
|
|
hosts: logdetective
|
|
user: root
|
|
gather_facts: False
|
|
vars:
|
|
drive_device: /dev/nvme1n1
|
|
vars_files:
|
|
- /srv/web/infra/ansible/vars/global.yml
|
|
- /srv/private/ansible/vars.yml
|
|
|
|
handlers:
|
|
- import_tasks: "{{ handlers_path }}/restart_services.yml"
|
|
|
|
tasks:
|
|
- import_tasks: "{{ tasks_path }}/aws_cloud.yml"
|
|
when: datacenter == 'aws'
|
|
|
|
- import_tasks: "{{ tasks_path }}/swap.yml"
|
|
when:
|
|
- datacenter == 'aws'
|
|
- swap_file_size_mb is defined
|
|
|
|
- name: cloud basic setup
|
|
hosts: logdetective
|
|
become: True
|
|
become_user: root
|
|
gather_facts: True
|
|
vars_files:
|
|
- /srv/web/infra/ansible/vars/global.yml
|
|
- /srv/private/ansible/vars.yml
|
|
|
|
pre_tasks:
|
|
- import_tasks: "{{ tasks_path }}/yumrepos.yml"
|
|
|
|
|
|
tasks:
|
|
- import_tasks: "{{ tasks_path }}/cloud_setup_basic.yml"
|
|
- name: Install basic packages
|
|
ansible.builtin.dnf:
|
|
name:
|
|
- python3-pip
|
|
- python3-devel
|
|
- pciutils
|
|
- git
|
|
- podman
|
|
- podman-compose
|
|
- wget
|
|
- gcc-c++
|
|
|
|
- name: Download and install cuda drivers repo
|
|
ansible.builtin.dnf:
|
|
name: https://developer.download.nvidia.com/compute/cuda/12.5.1/local_installers/cuda-repo-fedora39-12-5-local-12.5.1_555.42.06-1.x86_64.rpm
|
|
|
|
- name: Install cuda drivers
|
|
ansible.builtin.dnf:
|
|
name:
|
|
- cuda-toolkit-12-5
|
|
- nvidia-driver:open-dkms
|
|
register: cuda_installation
|
|
|
|
- name: Restart the system
|
|
ansible.builtin.reboot:
|
|
when: cuda_installation.changed
|
|
|
|
- name: Verify presence of secondary drive
|
|
ansible.builtin.stat:
|
|
path: "{{ drive_device }}"
|
|
register: drive
|
|
|
|
- name: Ensure state of secondary drive
|
|
when: drive.stat.isblk and drive.stat.writeable
|
|
block:
|
|
- name: Ensure filesystem and format
|
|
community.general.filesystem:
|
|
dev: "{{ drive_device }}"
|
|
fstype: ext4
|
|
force: false # Explicit better than implicit
|
|
|
|
- name: Ensure mountpoint
|
|
ansible.builtin.file:
|
|
path: /mnt/srv
|
|
state: directory
|
|
|
|
- name: Mount the drive on boot
|
|
ansible.posix.mount:
|
|
src: "{{ drive_device }}"
|
|
boot: true
|
|
state: mounted
|
|
fstype: ext4
|
|
|
|
# Split for better readability
|
|
- name: Ensure cache directories on secondary drive
|
|
when: drive.stat.isblk and drive.stat.writeable
|
|
block:
|
|
- name: Create pip cache dir
|
|
ansible.builtin.file:
|
|
state: directory
|
|
path: /mnt/srv/.cache/pip
|
|
mode: "0777"
|
|
recurse: true
|
|
|
|
- name: Set pip cache location to secondary drive
|
|
ansible.builtin.shell:
|
|
export PIP_CACHE_DIR=/mnt/srv/.cache/pip
|
|
|
|
- name: Create Hugging Face cache dir
|
|
ansible.bulitin.file:
|
|
state: directory
|
|
path: /mnt/srv/.cache/huggingface
|
|
mode: "0777"
|
|
recurse: true
|
|
|
|
- name: Set Hugging Face cache location to the secondary drive
|
|
ansible.builtin.shell:
|
|
export HUGGINGFACE_HUB_CACHE=/mnt/srv/.cache/huggingface
|
|
|
|
# this should be set to ansible_hostname
|
|
# - name: "set hostname (required by some services, at least postfix need it)"
|
|
# hostname: name="{{copr_hostbase}}.cloud.fedoraproject.org"
|
|
# when: env != 'production'
|
|
|
|
- name: provision instance
|
|
hosts: logdetective
|
|
become: True
|
|
become_user: root
|
|
gather_facts: True
|
|
|
|
vars_files:
|
|
- /srv/web/infra/ansible/vars/global.yml
|
|
- /srv/private/ansible/vars.yml
|
|
- /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml
|
|
|
|
# Roles are run first, before tasks, regardless of where you place them here.
|
|
roles:
|
|
- base
|
|
- nagios_client
|