Files
fedora-infra_ansible/tasks/swap.yml
Miroslav Suchý 1c2cfed97a Revert "try this"
This reverts commit 68ff759fc4ec7bab9d305635bb37efba04efbbec.
2020-04-24 21:34:25 +02:00

58 lines
1.1 KiB
YAML

# use variables:
# swap_file_size_mb
# swap_file_path
- name: Create swap file
command:
cmd: "dd if=/dev/zero of={{ swap_file_path }} bs=1024 count={{ swap_file_size_mb }}k"
creates: "{{ swap_file_path }}"
tags:
- swap.file.create
- swap
- name: Change swap file permissions
file: path="{{ swap_file_path }}"
owner=root
group=root
mode=0600
tags:
- swap.file.permissions
- swap
- name: Check swap file type
command: file {{ swap_file_path }}
register: swapfile
changed_when: False
tags:
- swap.file.mkswap
- swap
- name: Make swap file
filesystem:
fstype: swap
dev: "{{ swap_file_path }}"
when: swapfile.stdout.find('swap file') == -1
tags:
- swap.file.mkswap
- swap
- name: Write swap entry in fstab
mount: path=none
src={{ swap_file_path }}
fstype=swap
opts=sw
passno=0
dump=0
state=present
tags:
- swap.fstab
- swap
- name: Mount swap
command: "swapon {{ swap_file_path }}"
when: ansible_swaptotal_mb|int < 1
tags:
- swap.file.swapon
- swap