xbazzi e7ba86f10a
All checks were successful
Simple Mirror to GitHub / mirror (push) Successful in 35s
Feat: add scylladb + a bunch of stuff I forgot to commit earlier
2025-08-21 23:43:52 -06:00

133 lines
3.6 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.vm_roles"
loop: "{{ vms }}"
loop_control:
label: "{{ item.vmid }}"
ignore_errors: true
- 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.vm_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.vm_roles"
loop: "{{ vms }}"
loop_control:
label: "{{ item.vmid }}"
# - 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 --noheadings | grep vm || true
# register: lvs_output
# changed_when: false
# - name: Debug current LV list
# debug:
# var: lvs_output.stdout_lines
# - name: Create logical volume for Docker (only on owning node)
# 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.vm_roles"
# - inventory_hostname == item.node
# loop: "{{ vms }}"
# loop_control:
# label: "lv_docker_{{ item.vmid }}"
# ignore_errors: false
# - name: Ensure VM exists before attaching disk
# ansible.builtin.command: >
# qm config {{ item.vmid }}
# register: vm_check
# failed_when: vm_check.rc != 0 and 'no such VM' not in vm_check.stderr
# changed_when: false
# when:
# - "'docker' in item.vm_roles"
# - inventory_hostname == item.node
# loop: "{{ vms }}"
# loop_control:
# label: "check_vm_{{ 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
# args:
# executable: /bin/bash
# delegate_to: "{{ item.node }}"
# run_once: false
# loop: "{{ vms }}"
# when:
# - "'docker' in item.vm_roles"
# retries: 5
# delay: 3
# register: disk_attach_result
# until: disk_attach_result.rc == 0
# loop_control:
# label: "attach_vm_{{ item.vmid }}"
# - name: Create logical volume for DB (only on owning node)
# 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.vm_roles"
# - inventory_hostname == item.node
# loop: "{{ vms }}"
# loop_control:
# label: "lv_db_{{ item.vmid }}"