Skip to content
This repository has been archived by the owner on Sep 10, 2020. It is now read-only.

Enable swap for TB #108

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions roles/crawler/tasks/enable-swap-for-tb.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
# Tor Browser requires swap and may experience irregular errors without it.
# Credit to Parménides GV (https://github.com/parmegv) for this tasklist.

- name: Create swap file.
command: fallocate -l {{ (ansible_memtotal_mb / 1000 / 2)|round(0, 'ceil')|int }}G /swapfile
creates=/swapfile
when: ansible_swaptotal_mb < 1
register: swapfile_created

- name: Set swapfile permissions.
file: path=/swapfile
mode=0600
when: swapfile_created.changed

- name: Format swapfile as swap.
command: mkswap /swapfile
when: swapfile_created.changed

- name: Add swap to fstab.
mount: name=swapfile
src=/swapfile
fstype=swap
opts=sw
passno=0
dump=0
state=present
when: swapfile_created.changed

- name: Enable swap.
command: swapon /swapfile
when: swapfile_created.changed
1 change: 1 addition & 0 deletions roles/crawler/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- include: configure.yml
tags: configure
- include: download-verify-tbb.yml
- include: enable-swap-for-tb.yml
- include: download-verify-tor.yml
- include: build-install-tor.yml
- include: install-systemd-unit.yml
Expand Down