geerlingguy.swap
Ansible Role: Swap
This Ansible Role sets up swap space on Linux systems.
Requirements
None.
Role Variables
Here are the variables you can use, along with their default values (check defaults/main.yml
for more details):
swap_file_path:
/swapfile
This is where the swap file will be located on the server.swap_file_size_mb:
'512'
This is the size of the swap file in mebibytes.swap_swappiness:
'60'
This sets thevm.swappiness
value in the system configuration.swap_file_state:
present
Set this toabsent
if you want to remove the swap file and disable swap. Usually, you would set it topresent
.swap_file_create_command:
"dd if=/dev/zero of={{ swap_file_path }} bs=1M count={{ swap_file_size_mb }}"
This is the command for creating the swap file. You can usefallocate
for faster creation, but it may result in inconsistencies compared todd
.
Dependencies
None.
Example Playbook
- hosts: all
vars:
swap_file_size_mb: '1024'
roles:
- geerlingguy.swap
License
MIT / BSD
Author Information
This role was created in 2018 by Jeff Geerling, the author of Ansible for DevOps.
Swap file and swap management for Linux.
ansible-galaxy install geerlingguy.swap