2025-07-16 17:14:16 -06:00

56 lines
1.4 KiB
YAML

---
- name: Install LVM tools (if not present)
ansible.builtin.package:
name: lvm2
state: present
- name: Check current LVs for VMs
ansible.builtin.shell: >
lvs -o lv_name | grep vm
register: lvs_output
- debug:
var: lvs_output.stdout_lines
- debug:
msg: "vm-{{ item.vmid }}-disk-{{ pve_docker_disk_id }}"
loop: "{{ vms }}"
loop_control:
label: "{{ item.vmid }}"
- name: Create logical volume for Docker
community.general.lvol:
lv: "vm-{{ item.vmid }}-disk-{{ pve_docker_disk_id }}"
vg: "{{ pve_vg }}"
shrink: false
size: "{{ pve_docker_lv_size }}"
state: present
when: "'docker' in item.roles"
loop: "{{ vms }}"
loop_control:
label: "{{ item.vmid }}"
- name: Attach Docker disk to VM
ansible.builtin.shell: >
qm set {{ item.vmid }}
--scsi{{ pve_docker_disk_id }}
ha-lvm:vm-{{ item.vmid }}-disk-{{ pve_docker_disk_id }},cache=writeback,discard=on,iothread=1,ssd=1
delegate_to: "{{ item.node }}"
run_once: true
loop: "{{ vms }}"
when: "'docker' in item.roles"
loop_control:
label: "VM {{ item.vmid }} on {{ item.node }}"
- name: Create logical volume for DB
community.general.lvol:
lv: "vm-{{ item.vmid }}-disk-{{ pve_db_disk_id }}"
vg: "{{ pve_vg }}"
shrink: false
size: "{{ pve_db_lv_size }}"
state: present
when: "'db' in item.roles"
loop: "{{ vms }}"
loop_control:
label: "{{ item.vmid }}"