From efcf1d85845949c7281b527777ceaf11e908d86e Mon Sep 17 00:00:00 2001 From: Dejan Menges Date: Tue, 18 May 2021 15:54:05 +0200 Subject: [PATCH] Don't create swap if swap is already there --- roles/third_party/linux/swap-setup/tasks/main.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/roles/third_party/linux/swap-setup/tasks/main.yml b/roles/third_party/linux/swap-setup/tasks/main.yml index c8e2f4db..2a4938de 100644 --- a/roles/third_party/linux/swap-setup/tasks/main.yml +++ b/roles/third_party/linux/swap-setup/tasks/main.yml @@ -1,3 +1,9 @@ +- name: Check if swap is already configured on the server + shell: /usr/bin/cat /proc/swaps | grep -v Filename + #changed_when: true + register: swap_is_already_configured + ignore_errors: true + - name: Verify if swap is already configured by Ansible stat: path: "{{ __swapfile_success }}" @@ -7,3 +13,4 @@ include_tasks: configure_swap.yml when: - not swap_configured_by_ansible.stat.exists + - swap_is_already_configured.rc != 0