Created
February 20, 2020 05:45
-
-
Save metasikander/f5bb6d57195db276443d5faea6ac69a1 to your computer and use it in GitHub Desktop.
an ansible playbook to set up a swapfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- name: Swapfile playbook | |
hosts: all | |
become: yes | |
tasks: | |
- name: create swapfile | |
command: fallocate -l 2G /swapfile | |
args: | |
creates: /swapfile | |
- name: swapfile access rights | |
file: | |
path: /swapfile | |
owner: root | |
group: root | |
mode: 0600 | |
- name: mkswap | |
command: mkswap /swapfile | |
ignore_errors: yes | |
- name: swapon | |
command: swapon /swapfile | |
ignore_errors: yes | |
- name: add to fstab | |
lineinfile: | |
path: /etc/fstab | |
line: /swapfile none swap defaults 0 0 | |
create: yes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment