From c31bbc8e6e8f33f37c7fde8deb9cbe0a11c3af9c Mon Sep 17 00:00:00 2001 From: Joakim Soderlund Date: Sun, 29 Jul 2018 22:05:38 +0200 Subject: [PATCH] Add Ansible role for Deluge --- operations/deluge/defaults/main.yml | 10 +++ operations/deluge/handlers/main.yml | 11 +++ operations/deluge/tasks/conf.yml | 38 +++++++++++ operations/deluge/tasks/main.yml | 13 ++++ operations/deluge/tasks/make.yml | 9 +++ operations/deluge/tasks/prep.yml | 20 ++++++ operations/deluge/templates/config | 101 ++++++++++++++++++++++++++++ operations/deluge/templates/service | 16 +++++ operations/seeder.yml | 10 +++ 9 files changed, 228 insertions(+) create mode 100644 operations/deluge/defaults/main.yml create mode 100644 operations/deluge/handlers/main.yml create mode 100644 operations/deluge/tasks/conf.yml create mode 100644 operations/deluge/tasks/main.yml create mode 100644 operations/deluge/tasks/make.yml create mode 100644 operations/deluge/tasks/prep.yml create mode 100644 operations/deluge/templates/config create mode 100644 operations/deluge/templates/service create mode 100644 operations/seeder.yml diff --git a/operations/deluge/defaults/main.yml b/operations/deluge/defaults/main.yml new file mode 100644 index 0000000..f33c6f1 --- /dev/null +++ b/operations/deluge/defaults/main.yml @@ -0,0 +1,10 @@ +--- +# +# Deluge defaults. +# + +deluge: + user: debian-deluged + home: /var/lib/deluged + conf: /var/lib/deluged/config + auth: tunnel:tunnel:10 diff --git a/operations/deluge/handlers/main.yml b/operations/deluge/handlers/main.yml new file mode 100644 index 0000000..a00666b --- /dev/null +++ b/operations/deluge/handlers/main.yml @@ -0,0 +1,11 @@ +--- +# +# Deluge handlers. +# + +- name: Restart Deluge + systemd: + name: deluged + enabled: yes + daemon_reload: yes + state: restarted diff --git a/operations/deluge/tasks/conf.yml b/operations/deluge/tasks/conf.yml new file mode 100644 index 0000000..1976e02 --- /dev/null +++ b/operations/deluge/tasks/conf.yml @@ -0,0 +1,38 @@ +--- +# +# Configures Deluge. +# + +- name: Create config directory + file: + path: "{{ deluge.conf }}" + mode: 0755 + owner: "{{ deluge.user }}" + group: "{{ deluge.user }}" + state: directory + +- name: Configure daemon + template: + src: config + dest: "{{ deluge.conf }}/core.conf" + mode: 0644 + owner: root + group: "{{ deluge.user }}" + notify: Restart Deluge + +- name: Configure authentication + lineinfile: + line: "{{ deluge.auth }}" + dest: "{{ deluge.conf }}/auth" + mode: 0640 + owner: root + group: "{{ deluge.user }}" + create: yes + state: present + notify: Restart Deluge + +- name: Install service + template: + src: service + dest: /etc/systemd/system/deluged.service + notify: Restart Deluge diff --git a/operations/deluge/tasks/main.yml b/operations/deluge/tasks/main.yml new file mode 100644 index 0000000..5c3b84b --- /dev/null +++ b/operations/deluge/tasks/main.yml @@ -0,0 +1,13 @@ +--- +# +# Deluge tasks. +# + +- name: Prepare system + include: prep.yml + +- name: Install Deluge + include: make.yml + +- name: Configure Deluge + include: conf.yml diff --git a/operations/deluge/tasks/make.yml b/operations/deluge/tasks/make.yml new file mode 100644 index 0000000..346e5ca --- /dev/null +++ b/operations/deluge/tasks/make.yml @@ -0,0 +1,9 @@ +--- +# +# Builds and installs Deluge. +# + +- name: Install Deluge + apt: + name: deluged + state: present diff --git a/operations/deluge/tasks/prep.yml b/operations/deluge/tasks/prep.yml new file mode 100644 index 0000000..c592ae9 --- /dev/null +++ b/operations/deluge/tasks/prep.yml @@ -0,0 +1,20 @@ +--- +# +# Prepares system for Deluge. +# + +- name: Create UNIX group + group: + name: "{{ deluge.user }}" + system: yes + state: present + +- name: Create UNIX user + user: + name: "{{ deluge.user }}" + group: "{{ deluge.user }}" + home: "{{ deluge.home }}" + createhome: yes + skeleton: yes + system: yes + state: present diff --git a/operations/deluge/templates/config b/operations/deluge/templates/config new file mode 100644 index 0000000..c00034a --- /dev/null +++ b/operations/deluge/templates/config @@ -0,0 +1,101 @@ +{ + "file": 1, + "format": 1 +}{ + "info_sent": 0.0, + "lsd": false, + "max_download_speed": -1.0, + "send_info": false, + "natpmp": false, + "move_completed_path": "{{ deluge.home }}/storage", + "peer_tos": "0x00", + "enc_in_policy": 1, + "queue_new_to_top": false, + "ignore_limits_on_local_network": true, + "rate_limit_ip_overhead": false, + "daemon_port": 58846, + "torrentfiles_location": "{{ deluge.home }}/torrents", + "max_active_limit": -1, + "geoip_db_location": "/usr/share/GeoIP/GeoIP.dat", + "upnp": false, + "utpex": true, + "max_active_downloading": -1, + "max_active_seeding": -1, + "allow_remote": false, + "outgoing_ports": [ + 0, + 0 + ], + "enabled_plugins": [], + "max_half_open_connections": -1, + "download_location": "{{ deluge.home }}/storage", + "compact_allocation": false, + "max_upload_speed": -1.0, + "plugins_location": "{{ deluge.home }}/plugins", + "max_connections_global": -1, + "enc_prefer_rc4": true, + "cache_expiry": 28800, + "dht": true, + "stop_seed_at_ratio": false, + "stop_seed_ratio": -1.0, + "max_download_speed_per_torrent": -1, + "prioritize_first_last_pieces": false, + "max_upload_speed_per_torrent": -1, + "auto_managed": true, + "enc_level": 2, + "copy_torrent_file": true, + "max_connections_per_second": -1, + "listen_ports": [ + 6881, + 6891 + ], + "max_connections_per_torrent": -1, + "del_copy_torrent_file": false, + "move_completed": false, + "autoadd_enable": false, + "proxies": { + "peer": { + "username": "", + "password": "", + "hostname": "", + "type": 0, + "port": 8080 + }, + "web_seed": { + "username": "", + "password": "", + "hostname": "", + "type": 0, + "port": 8080 + }, + "tracker": { + "username": "", + "password": "", + "hostname": "", + "type": 0, + "port": 8080 + }, + "dht": { + "username": "", + "password": "", + "hostname": "", + "type": 0, + "port": 8080 + } + }, + "dont_count_slow_torrents": false, + "add_paused": false, + "random_outgoing_ports": true, + "max_upload_slots_per_torrent": -1, + "new_release_check": false, + "enc_out_policy": 1, + "seed_time_ratio_limit": -1.0, + "remove_seed_at_ratio": false, + "autoadd_location": "{{ deluge.home }}/watch", + "max_upload_slots_global": -1, + "seed_time_limit": -1, + "cache_size": 16384, + "share_ratio_limit": -1.0, + "random_port": true, + "listen_interface": "" +} diff --git a/operations/deluge/templates/service b/operations/deluge/templates/service new file mode 100644 index 0000000..1872e57 --- /dev/null +++ b/operations/deluge/templates/service @@ -0,0 +1,16 @@ +[Unit] +Description=Deluge Daemon +Documentation=man:deluged +After=network-online.target + +[Service] +Type=simple +User={{ deluge.user }} +Group={{ deluge.user }} +UMask=002 +ExecStart=/usr/bin/deluged -c {{ deluge.conf }} -d +Restart=on-failure +TimeoutStopSec=300 + +[Install] +WantedBy=multi-user.target diff --git a/operations/seeder.yml b/operations/seeder.yml new file mode 100644 index 0000000..b45d39a --- /dev/null +++ b/operations/seeder.yml @@ -0,0 +1,10 @@ +--- +# +# Configures seeders. +# + +- name: Seeder + hosts: seeders + roles: + - common + - deluge