infra: HA-Ressource und Node-Affinity per pve-host statt tofu, Infra-IP im Inventar
ci / test (push) Successful in 29s

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Robert Rapp
2026-10-12 19:41:17 +02:00
co-authored by Claude Opus 5.5
parent 23d6e36028
commit bf20da1629
3 changed files with 47 additions and 11 deletions
@@ -121,3 +121,41 @@
- (item.0.value.vmid | string) + '.conf' in local_cts.stdout_lines
- (item.0.value.vmid | string) + '-' + (idx | string) not in pvesr_jobs.stdout
changed_when: true
- name: HA-Konfiguration lesen
ansible.builtin.command: ha-manager config
register: ha_config
check_mode: false
changed_when: false
- name: Infra-Gäste unter HA stellen (erst wenn der Container auf diesem Knoten existiert)
ansible.builtin.command: >
ha-manager add ct:{{ item.value.vmid }} --state started --max_restart 1 --max_relocate 1
--comment 'knaster {{ item.key }}'
loop: "{{ knaster_pve.containers | dict2items }}"
when:
- item.value.ha | default(false)
- item.value.node == inventory_hostname
- (item.value.vmid | string) + '.conf' in local_cts.stdout_lines
- ('ct:' + (item.value.vmid | string)) not in ha_config.stdout
changed_when: true
- name: HA-Regeln lesen
ansible.builtin.command: ha-manager rules config
register: ha_rules
check_mode: false
changed_when: false
# Strikt: Die Gäste liegen auf tank, den gibt es nur auf dem Heimatknoten und den Replikationszielen
- name: Node-Affinity für Infra-Gäste (Heimatknoten bevorzugt, sonst Replikationsziele)
ansible.builtin.command: >
ha-manager rules add node-affinity knaster-{{ item.key }} --resources ct:{{ item.value.vmid }}
--nodes {{ ([item.value.node ~ ':2'] + (item.value.replicate_to | map('regex_replace', '$', ':1') | list)) | join(',') }}
--strict 1 --comment 'knaster {{ item.key }}'
loop: "{{ knaster_pve.containers | dict2items }}"
when:
- item.value.ha | default(false)
- item.value.node == inventory_hostname
- (item.value.vmid | string) + '.conf' in local_cts.stdout_lines
- ('knaster-' + item.key) not in ha_rules.stdout
changed_when: true