Files
homelab/ansible/roles/trek/tasks/main.yml
T
2026-04-12 22:18:17 +01:00

54 lines
1.3 KiB
YAML

---
- name: Add data disk to VM for trek
community.proxmox.proxmox_disk:
api_host: "{{ proxmox_api_host }}"
api_user: "{{ proxmox_api_user }}"
api_token_id: "{{ proxmox_api_token_id }}"
api_token_secret: "{{ proxmox_api_token_secret }}"
vmid: "{{ app_data_disks.trek.vmid }}"
disk: "{{ app_data_disks.trek.disk_id }}"
storage: "{{ app_data_disks.trek.storage }}"
size: "{{ app_data_disks.trek.size }}"
state: present
delegate_to: localhost
become: no
run_once: true
ignore_errors: yes
register: disk_result
- name: Display disk creation result
debug:
var: disk_result
- name: Wait for data disk to be available
wait_for:
path: "{{ app_data_disks.trek.device }}"
state: present
timeout: 30
- name: Check if data disk is formatted
command: "blkid {{ app_data_disks.trek.device }}"
register: disk_formatted
failed_when: false
changed_when: false
- name: Format data disk with ext4
filesystem:
fstype: ext4
dev: "{{ app_data_disks.trek.device }}"
when: disk_formatted.rc != 0
- name: Create trek data mount point
file:
path: "{{ app_data_disks.trek.mount_point }}"
state: directory
mode: "0755"
- name: Mount data disk
mount:
path: "{{ app_data_disks.trek.mount_point }}"
src: "{{ app_data_disks.trek.device }}"
fstype: ext4
state: mounted
opts: defaults