Skip to content

Instantly share code, notes, and snippets.

@metasikander
Created February 20, 2020 05:45
Show Gist options
  • Select an option

  • Save metasikander/f5bb6d57195db276443d5faea6ac69a1 to your computer and use it in GitHub Desktop.

Select an option

Save metasikander/f5bb6d57195db276443d5faea6ac69a1 to your computer and use it in GitHub Desktop.

Revisions

  1. metasikander created this gist Feb 20, 2020.
    30 changes: 30 additions & 0 deletions swapfile.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    ---
    - 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