48 lines
1.8 KiB
YAML
48 lines
1.8 KiB
YAML
---
|
|
# tasks file for proxmox_storage
|
|
|
|
- name: Create a safety backup of Proxmox storage.cfg
|
|
ansible.builtin.copy:
|
|
src: /etc/pve/storage.cfg
|
|
dest: "/root/pve_storage.cfg.bak.{{ ansible_facts['date_time']['epoch'] }}"
|
|
remote_src: true
|
|
mode: '0600'
|
|
when: inventory_hostname == groups['proxmox'][0]
|
|
|
|
- name: Prevent Split-Brain by removing default local-lvm if managed by Linstor
|
|
ansible.builtin.shell: |
|
|
set -o pipefail
|
|
# Check if local-lvm is currently registered in Proxmox
|
|
if pvesm status | grep -q "^local-lvm "; then
|
|
pvesm remove local-lvm
|
|
echo "changed"
|
|
fi
|
|
args:
|
|
executable: /bin/bash
|
|
register: proxmox_storage_remove_local_lvm
|
|
changed_when: "'changed' in proxmox_storage_remove_local_lvm.stdout"
|
|
loop: "{{ linstor_storage_pools }}"
|
|
# Only run on Node 1, and ONLY if the loop detects the usage of the pve/data pool
|
|
when:
|
|
- inventory_hostname == groups['proxmox'][0]
|
|
- (item.vg_name == 'pve' and item.thin_name == 'data') or ('pve/data' in item.targets.values())
|
|
|
|
- name: Register LINSTOR resource groups in Proxmox GUI (pvesm)
|
|
ansible.builtin.shell: |
|
|
set -o pipefail
|
|
|
|
# We use the ha_vip variable, but gracefully fallback to Node 1's public IP if it's undefined
|
|
CONTROLLER="{{ ha_vip | default(hostvars[groups['proxmox'][0]].ansible_host) }}"
|
|
STORAGE_ID="ls-{{ item.rg_name }}"
|
|
|
|
if ! pvesm status | grep -q "^${STORAGE_ID} "; then
|
|
pvesm add drbd "${STORAGE_ID}" --controller "${CONTROLLER}" --resourcegroup "{{ item.rg_name }}" --content images,rootdir > /dev/null
|
|
echo "changed"
|
|
fi
|
|
args:
|
|
executable: /bin/bash
|
|
register: proxmox_storage_pvesm_add
|
|
changed_when: "'changed' in proxmox_storage_pvesm_add.stdout"
|
|
loop: "{{ linstor_storage_pools }}"
|
|
when: inventory_hostname == groups['proxmox'][0]
|