commit d6cbefbf62473c28e47fe6fbd1c64490e88ee15b Author: Matt Layher Date: Fri Apr 15 20:32:33 2016 -0400 *, rtorrent: initial commit diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..031350d --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,10 @@ +MIT License +=========== + +Copyright (C) 2016 Matt Layher + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..4b06716 --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +ansible +======= + +Ansible playbooks used to configure Matt Layher's machines. +MIT Licensed. diff --git a/playbooks/rtorrent/rtorrent.rc.j2 b/playbooks/rtorrent/rtorrent.rc.j2 new file mode 100644 index 0000000..308ffea --- /dev/null +++ b/playbooks/rtorrent/rtorrent.rc.j2 @@ -0,0 +1,48 @@ +# {{ ansible_managed }} +# rtorrent configuration, Matt Layher, 2016-04-15 + +# +# Dynamic configurations. +# + +# Configure global upload and download rates in KiB. "0" is unlimited. +download_rate = {{ rtorrent_download_rate }} +upload_rate = {{ rtorrent_upload_rate }} + +# Listen on a single port. +port_range = {{ rtorrent_port }}-{{ rtorrent_port }} +port_random = no + +# Files and session directory configurations. +directory = {{ rtorrent_path_files }} +session = {{ rtorrent_path_session }} + +# Watch directory configuration. +schedule = watch_directory,5,5,load_start="{{ rtorrent_path_watch }}/*.torrent" +schedule = untied_directory,5,5,stop_untied= +schedule = tied_directory,5,5,start_tied= + +# Halt further downloads when disk space is low. +schedule = low_diskspace,5,60,close_low_diskspace={{ rtorrent_low_diskspace }} + +# Delete file data when a torrent is removed. +system.method.set_key = event.download.erased,remove_erased,"execute=rm,-rf,--,$d.get_base_path={{ rtorrent_path_files }}" + +{% if rtorrent_scgi_port is defined %} +# SCGI interface configuration. +scgi_port = {{ rtorrent_scgi_port }} + +{% endif %} +# +# Static configurations. +# + +# Check hash on completed torrents. +check_hash = yes + +# Use encryption whenever possible. +encryption = allow_incoming,try_outgoing,enable_retry + +# Disable DHT and peer exchange. +dht = disable +peer_exchange = no diff --git a/playbooks/rtorrent/rtorrent.yml b/playbooks/rtorrent/rtorrent.yml new file mode 100644 index 0000000..4c0b364 --- /dev/null +++ b/playbooks/rtorrent/rtorrent.yml @@ -0,0 +1,36 @@ +--- +- hosts: rtorrent + vars: + # Client configurations + - rtorrent_port: 58575 + - rtorrent_download_rate: 10000 + - rtorrent_upload_rate: 400 + - rtorrent_low_diskspace: "1G" + # Path configurations + - rtorrent_path_root: "/mnt/rtorrent" + - rtorrent_path_files: "{{ rtorrent_path_root }}/files" + - rtorrent_path_session: "{{ rtorrent_path_root }}/.session" + - rtorrent_path_watch: "{{ rtorrent_path_root }}/watch" + tasks: + - name: install rtorrent + apt: pkg=rtorrent state=installed + register: rtorrentinstalled + + - name: fail the play if rtorrent could not be installed + when: rtorrentinstalled|failed + fail: msg="failed to install rtorrent" + + - name: create rtorrent user + user: name=rtorrent shell=/bin/false comment="rtorrent service user" + + - name: create rtorrent configuration + template: src=rtorrent.rc.j2 dest=/home/rtorrent/.rtorrent.rc owner=rtorrent group=rtorrent mode=0755 + + - name: create files directory + file: path={{ rtorrent_path_files }} state=directory owner=rtorrent group=rtorrent mode=0755 + + - name: create watch directory + file: path={{ rtorrent_path_watch }} state=directory owner=rtorrent group=rtorrent mode=0755 + + - name: create session directory + file: path={{ rtorrent_path_session }} state=directory owner=rtorrent group=rtorrent mode=0755