Skip to content

Commit

Permalink
Merge pull request #8 from aarnaud/master
Browse files Browse the repository at this point in the history
Add peer port config + new options
  • Loading branch information
elboletaire authored Feb 2, 2018
2 parents d8657f1 + 9e6c432 commit 81e03eb
Show file tree
Hide file tree
Showing 14 changed files with 158 additions and 45 deletions.
25 changes: 18 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
services: docker

env:
- PLATFORM=debian-wheezy
- PLATFORM=debian-jessie
- PLATFORM=ubuntu-precise
- PLATFORM=ubuntu-trusty
- distribution: ubuntu
version: bionic
- distribution: ubuntu
version: xenial
- distribution: debian
version: stretch
- distribution: debian
version: jessie

sudo: required

language: python

services:
- docker
before_install:
- 'sudo docker pull ${distribution}:${version}'
- 'sudo docker build --no-cache --rm --file=tests/Dockerfile.${distribution}-${version} --tag=${distribution}-${version}:ansible tests'

script:
- docker build -f tests/$PLATFORM.Dockerfile -t test-$PLATFORM . && docker run --name $PLATFORM test-$PLATFORM
- container_id=$(mktemp)
- 'sudo docker run --detach --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:ro --volume="${PWD}":/etc/ansible/roles/testing_role:ro ${distribution}-${version}:ansible > "${container_id}"'
- 'sudo docker exec "$(cat ${container_id})" env ANSIBLE_FORCE_COLOR=1 ansible-playbook -v /etc/ansible/roles/testing_role/tests/test.yml --syntax-check'
- 'sudo docker exec "$(cat ${container_id})" env ANSIBLE_FORCE_COLOR=1 ansible-playbook -v /etc/ansible/roles/testing_role/tests/test.yml'
- 'sudo docker rm -f "$(cat ${container_id})"'
6 changes: 5 additions & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
transmission_user: "{{ ansible_user_id }}"
transmission_user: "debian-transmission"
transmission_group: "debian-transmission"
transmission_password: youShouldChangeThisUnlessDisablingAuth
transmission_url: '/transmission/'

Expand All @@ -26,3 +27,6 @@ transmission_speed_limit_down: 100

transmission_blocklist_enabled: false
transmission_blocklist_url: http://www.example.com/blocklist

transmission_peer_port: 51413
transmission_port_forwarding_enabled: false
6 changes: 6 additions & 0 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---

- name: "reload systemd"
systemd:
name: transmission-daemon.service
daemon_reload: yes
9 changes: 4 additions & 5 deletions meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@ galaxy_info:
author: Òscar Casajuana
description: Transmission for debian based systems
license: MIT
min_ansible_version: 1.2
min_ansible_version: 1.4
platforms:
- name: Ubuntu
versions:
- trusty
- utopic
- vivid
- xenial
- bionic
- name: Debian
versions:
- jessie
- wheezy
- stretch
categories:
- networking
dependencies: []
57 changes: 51 additions & 6 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,19 @@
ignore_errors: true
tags: transmission

- name: grep and register
shell: >
egrep "^{{ transmission_user }}:" /etc/passwd | awk -F: '{ printf $6 }'
changed_when: false
tags: transmission
register: _user_home

- name: Add downloads folder
file:
state: directory
path: "{{ transmission_download_dir }}"
owner: "{{ transmission_user }}"
group: debian-transmission
group: "{{ transmission_group }}"
mode: 0775
tags: transmission

Expand All @@ -28,7 +35,7 @@
state: directory
path: "{{ transmission_watch_dir }}"
owner: "{{ transmission_user }}"
group: debian-transmission
group: "{{ transmission_group }}"
mode: 0775
when: transmission_watch_dir_enabled
tags: transmission
Expand All @@ -38,24 +45,62 @@
state: directory
path: "{{ transmission_incomplete_dir }}"
owner: "{{ transmission_user }}"
group: debian-transmission
group: "{{ transmission_group }}"
mode: 0775
when: transmission_incomplete_dir_enabled
tags: transmission

- name: Add config directory
file:
state: directory
path: "{{ _user_home.stdout }}/.config/transmission-daemon"
owner: "{{ transmission_user }}"
group: "{{ transmission_group }}"
mode: 0755
tags: transmission

- name: Copy Transmission configuration
template:
src: etc/transmission-daemon/settings.json.j2
dest: /etc/transmission-daemon/settings.json
src: settings.json.j2
dest: "{{ _user_home.stdout }}/.config/transmission-daemon/settings.json"
owner: "{{ transmission_user }}"
group: "{{ transmission_group }}"
tags: transmission

- name: Add current user to transmission group
user:
name: "{{ transmission_user }}"
groups: debian-transmission
groups: "{{ transmission_group }}"
append: yes
tags: transmission

- name: "Create transmission-daemon overwrite systemd config directory"
file:
path: "/etc/systemd/system/transmission-daemon.service.d"
state: directory
mode: 0755
tags: transmission

- name: "Change transmission-daemon systemd user"
ini_file:
path: /etc/systemd/system/transmission-daemon.service.d/user.conf
section: Service
option: User
value: "{{ transmission_user }}"
notify: reload systemd
tags: transmission

- name: "Change transmission-daemon systemd timer group"
ini_file:
path: /etc/systemd/system/transmission-daemon.service.d/group.conf
section: Service
option: Group
value: "{{ transmission_group }}"
notify: reload systemd
tags: transmission

- meta: flush_handlers

# Service start
- name: Start transmission
service:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@
"peer-id-ttl-hours": 6,
"peer-limit-global": 200,
"peer-limit-per-torrent": 50,
"peer-port": 51413,
"peer-port": {{ transmission_peer_port }},
"peer-port-random-high": 65535,
"peer-port-random-low": 49152,
"peer-port-random-on-start": false,
"peer-socket-tos": "default",
"pex-enabled": true,
"port-forwarding-enabled": false,
"port-forwarding-enabled": {{ transmission_port_forwarding_enabled | lower }},
"preallocation": 1,
"prefetch-enabled": 1,
"queue-stalled-enabled": true,
Expand All @@ -46,6 +46,8 @@
"rpc-authentication-required": {{ transmission_rpc_auth_required | lower }},
"rpc-bind-address": "0.0.0.0",
"rpc-enabled": true,
"rpc-host-whitelist": "",
"rpc-host-whitelist-enabled": false,
"rpc-password": "{{ transmission_password }}",
"rpc-port": 9091,
"rpc-url": "{{ transmission_url }}",
Expand Down
17 changes: 17 additions & 0 deletions tests/Dockerfile.debian-jessie
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM debian:jessie

RUN apt-get update -y && apt-get upgrade -y && apt-get install -y --no-install-recommends \
build-essential \
libffi-dev \
libssl-dev \
python-dev \
python-pip \
git \
systemd \
&& rm -rf /var/lib/apt/lists/*

RUN pip install --upgrade setuptools && pip install ansible

RUN mkdir -p /etc/ansible && echo "[local]\nlocalhost ansible_connection=local" > /etc/ansible/hosts

ENTRYPOINT ["/bin/systemd"]
17 changes: 17 additions & 0 deletions tests/Dockerfile.debian-stretch
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM debian:stretch

RUN apt-get update -y && apt-get upgrade -y && apt-get install -y --no-install-recommends \
build-essential \
libffi-dev \
libssl-dev \
python-dev \
python-pip \
git \
systemd \
&& rm -rf /var/lib/apt/lists/*

RUN pip install --upgrade setuptools && pip install ansible

RUN mkdir -p /etc/ansible && echo "[local]\nlocalhost ansible_connection=local" > /etc/ansible/hosts

ENTRYPOINT ["/bin/systemd"]
18 changes: 18 additions & 0 deletions tests/Dockerfile.ubuntu-bionic
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM ubuntu:bionic

RUN apt-get update -y && apt-get upgrade -y && apt-get install -y --no-install-recommends \
build-essential \
libffi-dev \
libssl-dev \
python-dev \
python-pip \
python-pkg-resources \
git \
systemd \
&& rm -rf /var/lib/apt/lists/*

RUN pip2 install --upgrade pip setuptools wheel && pip2 install ansible && mkdir -p /etc/ansible/

RUN echo "[local]\nlocalhost ansible_connection=local" > /etc/ansible/hosts

ENTRYPOINT ["/bin/systemd"]
18 changes: 18 additions & 0 deletions tests/Dockerfile.ubuntu-xenial
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM ubuntu:xenial

RUN apt-get update -y && apt-get upgrade -y && apt-get install -y --no-install-recommends \
build-essential \
libffi-dev \
libssl-dev \
python-dev \
python-pip \
python-pkg-resources \
git \
systemd \
&& rm -rf /var/lib/apt/lists/*

RUN pip2 install --upgrade pip setuptools wheel && pip2 install ansible && mkdir -p /etc/ansible/

RUN echo "[local]\nlocalhost ansible_connection=local" > /etc/ansible/hosts

ENTRYPOINT ["/bin/systemd"]
6 changes: 0 additions & 6 deletions tests/debian-jessie.Dockerfile

This file was deleted.

6 changes: 0 additions & 6 deletions tests/debian-wheezy.Dockerfile

This file was deleted.

6 changes: 0 additions & 6 deletions tests/ubuntu-precise.Dockerfile

This file was deleted.

6 changes: 0 additions & 6 deletions tests/ubuntu-trusty.Dockerfile

This file was deleted.

0 comments on commit 81e03eb

Please sign in to comment.