integration-playbook: Idempotent Swapping

If the playbook is run multiple times or a host already has
swap configured, re-adding swap over the existing file
will cause untold problems.  Also, it will not persist across
reboots unless added to fstab.

Avoid this by checking if any swap is active. If not
create a unique swapfile and format it.  Then enable
it to persist across reboots.

Signed-off-by: Chris Evich <cevich@redhat.com>
This commit is contained in:
Chris Evich 2017-09-20 17:34:01 -04:00
parent b3ceb2a450
commit b198c57cfb
3 changed files with 47 additions and 7 deletions

View file

@ -72,13 +72,8 @@
async: 600
poll: 10
- name: Setup swap to prevent kernel firing off the OOM killer
shell: |
truncate -s 8G /root/swap && \
export SWAPDEV=$(losetup --show -f /root/swap | head -1) && \
mkswap $SWAPDEV && \
swapon $SWAPDEV && \
swapon --show
- name: Check / setup swap
include: "swap.yml"
- name: ensure directories exist as needed
file: