2026-02-07 08:29:45 +01:00
|
|
|
---
|
2026-02-07 08:45:57 +01:00
|
|
|
- name: swap | Set vm.swappiness
|
|
|
|
|
ansible.posix.sysctl:
|
2026-02-07 08:29:45 +01:00
|
|
|
name: vm.swappiness
|
|
|
|
|
value: "{{ proxmox_swapiness }}"
|
|
|
|
|
state: present
|
|
|
|
|
reload: yes
|
|
|
|
|
|
2026-02-12 21:29:59 +01:00
|
|
|
- name: swap | Gather active swaps
|
2026-02-12 21:32:17 +01:00
|
|
|
ansible.builtin.command: swapon --noheadings --show=NAME
|
2026-02-12 21:29:59 +01:00
|
|
|
register: active_swaps
|
|
|
|
|
changed_when: false
|
|
|
|
|
|
2026-02-07 08:45:57 +01:00
|
|
|
- name: swap | Disable swap if host has enough RAM
|
|
|
|
|
ansible.builtin.command: swapoff -a
|
2026-02-07 08:29:45 +01:00
|
|
|
when:
|
|
|
|
|
- proxmox_disable_swap
|
|
|
|
|
- ansible_memtotal_mb >= proxmox_min_ram_mb_for_no_swap
|
2026-02-14 08:39:57 +01:00
|
|
|
- active_swaps.stdout | bool
|
|
|
|
|
changed_when: active_swaps.stdout | bool
|
2026-02-07 08:29:45 +01:00
|
|
|
|
2026-02-12 21:29:59 +01:00
|
|
|
- name: swap | Comment swap entries in fstab
|
2026-02-07 08:45:57 +01:00
|
|
|
ansible.builtin.replace:
|
2026-02-07 08:29:45 +01:00
|
|
|
path: /etc/fstab
|
2026-02-12 21:29:59 +01:00
|
|
|
regexp: '^(\s*)(?!#)(\S+\s+\S+\s+swap\s+.*)$'
|
|
|
|
|
replace: '\1# \2'
|
2026-02-07 08:29:45 +01:00
|
|
|
when:
|
|
|
|
|
- proxmox_disable_swap
|
|
|
|
|
- ansible_memtotal_mb >= proxmox_min_ram_mb_for_no_swap
|