From 7e83a4375546fc89351f4c4d8f369e0dd7912ae3 Mon Sep 17 00:00:00 2001 From: Ruakij Date: Tue, 1 Nov 2022 08:45:48 +0100 Subject: [PATCH] Disable swap --- kubernetes/tasks/prerequisites/swap.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/kubernetes/tasks/prerequisites/swap.yml b/kubernetes/tasks/prerequisites/swap.yml index ae5a289..d4c9395 100644 --- a/kubernetes/tasks/prerequisites/swap.yml +++ b/kubernetes/tasks/prerequisites/swap.yml @@ -1,2 +1,10 @@ -- name: Disable swap - command: swapoff -a +- name: Disable swap-mounts + replace: + path: /etc/fstab + regexp: '^([ \t]*(?!#)\S+[ \t]+swap[ \t]+.*)' + replace: '# \1' + +- name: Disable active swap immediately + command: swapoff -va + changed_when: "command.stdout != ''" + register: command