From 04dfdbd3994c8bfe219a1e8871716b98eefa5080 Mon Sep 17 00:00:00 2001 From: Ryan Cavicchioni Date: Tue, 30 Aug 2022 07:51:17 -0500 Subject: [PATCH] add swap role --- roles/swap/defaults/main.yaml | 3 +++ roles/swap/tasks/main.yaml | 15 +++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 roles/swap/defaults/main.yaml create mode 100644 roles/swap/tasks/main.yaml diff --git a/roles/swap/defaults/main.yaml b/roles/swap/defaults/main.yaml new file mode 100644 index 0000000..f7108b6 --- /dev/null +++ b/roles/swap/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +swap_enabled: true +swap_file_path: /swapfile diff --git a/roles/swap/tasks/main.yaml b/roles/swap/tasks/main.yaml new file mode 100644 index 0000000..2173b98 --- /dev/null +++ b/roles/swap/tasks/main.yaml @@ -0,0 +1,15 @@ +--- +- name: manage swap + command: swapoff -a + when: not swap_enabled + +- name: manage swapfile + file: + path: "{{ swap_file_path }}" + state: absent + +- name: manage fstab + lineinfile: + path: /etc/fstab + regexp: swap + state: absent