aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Cholewiński <harry666t@gmail.com>2016-01-13 21:56:15 +0100
committerKamil Cholewiński <harry666t@gmail.com>2016-01-13 21:56:15 +0100
commite9430733065e779fa4b12a0146a2437581196fff (patch)
tree11c31536fccaa4f0b267b254a79792692063e919
parent16921c36ee0ef2e0920139e9903be711166f9c17 (diff)
downloadcookbook-e9430733065e779fa4b12a0146a2437581196fff.zip
cookbook-e9430733065e779fa4b12a0146a2437581196fff.tar.gz
cookbook-e9430733065e779fa4b12a0146a2437581196fff.tar.bz2
New role: transmission-daemon
-rw-r--r--os_vars/Debian.yml1
-rw-r--r--os_vars/OpenBSD.yml1
-rw-r--r--roles/transmission-daemon/defaults/main.yml4
-rw-r--r--roles/transmission-daemon/handlers/main.yml3
-rw-r--r--roles/transmission-daemon/meta/main.yml2
-rw-r--r--roles/transmission-daemon/tasks/main.yml51
-rw-r--r--roles/transmission-daemon/vars/Debian.yml7
-rw-r--r--roles/transmission-daemon/vars/OpenBSD.yml7
8 files changed, 76 insertions, 0 deletions
diff --git a/os_vars/Debian.yml b/os_vars/Debian.yml
index 934f8a0..552c3a8 100644
--- a/os_vars/Debian.yml
+++ b/os_vars/Debian.yml
@@ -1,6 +1,7 @@
---
paths:
nologin: /usr/sbin/nologin
+ service: /etc/service
packages:
essentials:
diff --git a/os_vars/OpenBSD.yml b/os_vars/OpenBSD.yml
index ac4f832..3107e5b 100644
--- a/os_vars/OpenBSD.yml
+++ b/os_vars/OpenBSD.yml
@@ -1,6 +1,7 @@
---
paths:
nologin: /sbin/nologin
+ service: /var/service
packages:
essentials: []
diff --git a/roles/transmission-daemon/defaults/main.yml b/roles/transmission-daemon/defaults/main.yml
new file mode 100644
index 0000000..a4683c9
--- /dev/null
+++ b/roles/transmission-daemon/defaults/main.yml
@@ -0,0 +1,4 @@
+---
+transmission:
+ path: /var/lib/transmission-daemon
+ host_whitelist: [127.*.*.*]
diff --git a/roles/transmission-daemon/handlers/main.yml b/roles/transmission-daemon/handlers/main.yml
new file mode 100644
index 0000000..f157077
--- /dev/null
+++ b/roles/transmission-daemon/handlers/main.yml
@@ -0,0 +1,3 @@
+---
+- name: Restart transmission-daemon
+ command: sv restart transmission-daemon
diff --git a/roles/transmission-daemon/meta/main.yml b/roles/transmission-daemon/meta/main.yml
new file mode 100644
index 0000000..23d65c7
--- /dev/null
+++ b/roles/transmission-daemon/meta/main.yml
@@ -0,0 +1,2 @@
+---
+dependencies: []
diff --git a/roles/transmission-daemon/tasks/main.yml b/roles/transmission-daemon/tasks/main.yml
new file mode 100644
index 0000000..fb1dc8d
--- /dev/null
+++ b/roles/transmission-daemon/tasks/main.yml
@@ -0,0 +1,51 @@
+---
+- name: Include OS-specific vars
+ include_vars: "{{ ansible_distribution }}.yml"
+ tags: config
+
+- name: Install transmission-daemon
+ action:
+ module: "{{ ansible_pkg_mgr }}"
+ name: "{{ item }}"
+ state: latest
+ with_items: packages.transmission_daemon
+ notify: Restart transmission-daemon
+ tags: install
+
+- name: Disable transmission-daemon init script
+ when: ansible_distribution == "Debian"
+ service: name=transmission-daemon enabled=no state=stopped
+ tags: install
+
+- name: Create transmission-daemon runit directory
+ file:
+ dest: "{{ paths.service }}/transmission-daemon"
+ state: directory
+ tags: install
+
+- name: Install transmission-daemon runit script
+ copy:
+ dest: "{{ paths.service }}/transmission-daemon/run"
+ mode: "0744"
+ content: |
+ #!/bin/sh
+ mkdir -p {{ transmission.path }}/incomplete
+ chown -R {{ transmission.user }}:{{ transmission.group }} \
+ {{ transmission.path }}
+ chmod -R ug=rwX,o=rX {{ transmission.path }}
+ exec >&2
+ exec 2> /var/log/transmission-daemon.log
+ exec chpst \
+ -n 4 -p 24 -o 256 \
+ -u {{ transmission.user }}:{{ transmission.group }} \
+ transmission-daemon -f \
+ --encryption-required \
+ -c {{ transmission.path }} \
+ --incomplete-dir {{ transmission.path }}/incomplete \
+ --download-dir {{ transmission.path }} \
+ --log-error \
+ --allowed "{{ transmission.host_whitelist | join(',') }}"
+ notify: Restart transmission-daemon
+ tags: [install, config]
+
+- meta: flush_handlers
diff --git a/roles/transmission-daemon/vars/Debian.yml b/roles/transmission-daemon/vars/Debian.yml
new file mode 100644
index 0000000..7dcd310
--- /dev/null
+++ b/roles/transmission-daemon/vars/Debian.yml
@@ -0,0 +1,7 @@
+---
+transmission:
+ user: debian-transmission
+ group: debian-transmission
+
+packages:
+ transmission_daemon: [transmission-daemon]
diff --git a/roles/transmission-daemon/vars/OpenBSD.yml b/roles/transmission-daemon/vars/OpenBSD.yml
new file mode 100644
index 0000000..b459ae2
--- /dev/null
+++ b/roles/transmission-daemon/vars/OpenBSD.yml
@@ -0,0 +1,7 @@
+---
+transmission:
+ user: _transmission
+ group: _transmission
+
+packages:
+ transmission_daemon: [transmission]