You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.7 KiB
47 lines
1.7 KiB
5 years ago
|
---
|
||
|
|
||
|
- name: Install transmission daemon
|
||
|
yum: name=transmission-daemon state=present
|
||
|
|
||
|
- name: Create user
|
||
|
user: name={{ transmission_user }} comment="Transmission Daemon" system=yes shell=/sbin/nologin
|
||
|
|
||
|
- name: Create directories
|
||
|
file: path={{ transmission_data_dir }}/{{ item }} state=directory owner={{ transmission_user }}
|
||
|
with_items:
|
||
|
- finished
|
||
|
- incomplete
|
||
|
- watch
|
||
|
|
||
|
- name: Deploy default config
|
||
|
template: src=sysconfig.j2 dest=/etc/sysconfig/transmission
|
||
|
notify: restart transmission
|
||
|
|
||
|
- name: Override default systemd unit
|
||
|
template: src=transmission-daemon.service.j2 dest=/etc/systemd/system/transmission-daemon.service
|
||
|
register: transmission_unit
|
||
|
notify: restart transmission
|
||
|
|
||
|
- name: Handle transmission port
|
||
|
iptables_raw:
|
||
|
name: transmission_port
|
||
|
state: "{{ (transmission_src_ip | length > 0) | ternary('present','absent') }}"
|
||
|
rules: |
|
||
|
-A INPUT -m state --state NEW -p tcp --dport {{ transmission_port }} -s {{ transmission_src_ip | join(',') }} -j ACCEPT
|
||
|
-A INPUT -p udp --dport {{ transmission_port }} -s {{ transmission_src_ip | join(',') }} -j ACCEPT
|
||
|
when: iptables_manage | default(True)
|
||
|
|
||
|
- name: Handle transmission RPC port
|
||
|
iptables_raw:
|
||
|
name=transmission_rpc_port
|
||
|
state={{ (transmission_rpc_src_ip | length > 0) | ternary('present','absent') }}
|
||
|
rules="-A INPUT -m state --state NEW -p tcp --dport {{ transmission_rpc_port }} -s {{ transmission_rpc_src_ip | join(',') }} -j ACCEPT"
|
||
|
when: iptables_manage | default(True)
|
||
|
|
||
|
- name: Reload systemd
|
||
|
command: systemctl daemon-reload
|
||
|
when: transmission_unit.changed
|
||
|
|
||
|
- name: Start and enable the service
|
||
|
service: name=transmission-daemon state=started enabled=yes
|