commit 531a4828f73937bce179b88496ca49296743320c
parent 671ad7177aa1a4f3288172d2e9c34082115049d6
Author: MichaĆ M. Sapka <michal@sapka.me>
Date: Wed, 29 Mar 2023 14:50:16 +0200
Add basic torrent role
Diffstat:
4 files changed, 47 insertions(+), 0 deletions(-)
diff --git a/hosts b/hosts
@@ -3,3 +3,6 @@
[dnses]
10.0.3.0
+
+[torrents]
+10.0.3.1
diff --git a/roles/rtorrent/files/rtorrent b/roles/rtorrent/files/rtorrent
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+. /etc/rc.subr
+
+name="rtorrent"
+rcvar="rtorrent_enable"
+rtorrent_user="root"
+rtorrent_command="/usr/local/bin/adguardhome"
+pidfile="/var/run/${name}.pid"
+command="/usr/sbin/daemon"
+command_args="-P ${pidfile} -r -f ${rtorrent_command}"
+
+load_rc_config $name
+: ${rtorrent_enable:=no}
+
+run_rc_command "$1"
+
+
diff --git a/roles/rtorrent/tasks/main.yaml b/roles/rtorrent/tasks/main.yaml
@@ -0,0 +1,21 @@
+---
+- name: Install FreeBSD packages
+ become: true
+ community.general.pkgng:
+ state: present
+ name:
+ - rtorrent
+ when: ansible_distribution == "FreeBSD"
+- name: Copy the adguard rc
+ become: true
+ ansible.builtin.copy: src=rtorrent dest=/etc/rc.d/
+- name: Enable rtorrent service
+ become: true
+ community.general.sysrc:
+ name: rtorrent_enable
+ value: "YES"
+- name: Start service rtorrent
+ become: true
+ ansible.builtin.service:
+ name: rtorrent
+ state: started
diff --git a/site.yml b/site.yml
@@ -13,3 +13,8 @@
name: DNS role
roles:
- adguard
+
+- hosts: torrents
+ name: Torrent role
+ roles:
+ - rtorrent