copr: backend: detect swap is enabled before disabling it

I am not opening a question whether disabling swap is a good idea,
I'm just want to make the execution of the playbook idempotent.
This commit is contained in:
Pavel Raiskup 2019-08-11 09:51:37 +02:00 committed by Pierre-Yves Chibon
parent 7ddd7caf1c
commit 1c3b58a671

View file

@ -247,7 +247,12 @@
fstype: swap
state: absent
- name: detect if swap is enabled
shell: test -n "$(swapon -s)"
register: swap_enabled
changed_when: false
failed_when: false
- name: disable swap so that OOM killer can do his job
command: "{{ item }}"
with_items:
- swapoff -a
command: swapoff -a
when: swap_enabled.rc != 0