2025-05-13 21:20:00 +02:00

44 lines
1.2 KiB
YAML
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
# tasks file for proxmox
- name: Add Proxmox VE host as HA group
ansible.builtin.blockinfile:
path: /etc/pve/ha/groups.cfg
append_newline: true
prepend_newline: true
block: |
group: {{ proxmox_instance_node }}
nodes {{ proxmox_instance_node }}
nofailback 0
restricted 0
marker: "# {mark} {{ proxmox_instance_node }}"
become: true
delegate_to: "{{ proxmox_delegate_to }}"
- name: Add instance in HA
ansible.builtin.blockinfile:
path: /etc/pve/ha/resources.cfg
append_newline: true
prepend_newline: true
block: |
vm: {{ proxmox_instance_vmid }}
comment: {{ inventory_hostname }}
group {{ proxmox_instance_ha.group }}
max_restart {{ proxmox_instance_ha.max_restart }}
max_relocate {{ proxmox_instance_ha.max_relocate }}
state {{ proxmox_instance_ha.state }}
marker: "# {mark} {{ inventory_hostname }}"
become: true
delegate_to: "{{ proxmox_delegate_to }}"
- name: Add ansible managed header
ansible.builtin.lineinfile:
path: "{{ item }}"
line: "# Ansible managed"
insertafter: BOF
become: true
loop:
- /etc/pve/ha/groups.cfg
- /etc/pve/ha/resources.cfg
delegate_to: "{{ proxmox_delegate_to }}"