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

89 lines
2.1 KiB
YAML

---
# MinIO — S3-compatible object storage for model artifacts and datasets
- name: Download MinIO server binary
get_url:
url: https://dl.min.io/server/minio/release/linux-amd64/minio
dest: /usr/local/bin/minio
mode: "0755"
retries: 3
delay: 10
- name: Download MinIO client (mc)
get_url:
url: https://dl.min.io/client/mc/release/linux-amd64/mc
dest: /usr/local/bin/mc
mode: "0755"
retries: 3
delay: 10
- name: Create MinIO data directories
file:
path: "{{ item }}"
state: directory
owner: cezen
group: cezen
mode: "0750"
loop:
- /opt/cezen/data/minio
- /opt/cezen/data/minio/models
- /opt/cezen/data/minio/datasets
- name: Create MinIO environment file
copy:
dest: /etc/default/minio
content: |
MINIO_ROOT_USER=cezenadmin
MINIO_ROOT_PASSWORD=Cezen@2024!
MINIO_VOLUMES="/opt/cezen/data/minio"
MINIO_OPTS="--console-address :9001"
mode: "0640"
owner: cezen
group: cezen
- name: Create MinIO systemd service
copy:
dest: /etc/systemd/system/minio.service
content: |
[Unit]
Description=MinIO Object Storage
Documentation=https://docs.min.io
Wants=network-online.target
After=network-online.target
[Service]
User=cezen
Group=cezen
EnvironmentFile=/etc/default/minio
ExecStartPre=/bin/bash -c "if [ -z \"${MINIO_VOLUMES}\" ]; then echo 'Variable MINIO_VOLUMES not set'; exit 1; fi"
ExecStart=/usr/local/bin/minio server ${MINIO_VOLUMES} ${MINIO_OPTS}
Restart=always
RestartSec=5
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target
mode: "0644"
- name: Enable and start MinIO
systemd:
name: minio
enabled: yes
state: started
daemon_reload: yes
- name: Wait for MinIO to be ready
wait_for:
host: localhost
port: 9001
timeout: 60
ignore_errors: true
- name: Configure mc client with local MinIO
become_user: cezen
shell: |
mc alias set local http://localhost:9000 cezenadmin 'Cezen@2024!'
mc mb local/models --ignore-existing
mc mb local/datasets --ignore-existing
retries: 3
delay: 5