src.nth.io/

summaryrefslogtreecommitdiff
path: root/transmission/tasks/main.yaml
blob: 980ebd4c9e2ed4d105b63474ebb5c09abf317e13 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
---

- name: install transmission
  become: yes
  apt: name="transmission-daemon"
  notify: restart transmission service

- name: create data dir
  become: yes
  file:
    path: "{{transmission_download_dir}}"
    state: "directory"
    owner: "{{transmission_user}}"
    group: "{{transmission_user}}"
    mode: "0755"
    recurse: "yes"

- name: stop transmission service
  systemd: name="transmission-daemon" state="stopped" daemon_reload="yes"
  become: yes
  changed_when: false

- name: config ip whitelist
  become: yes
  lineinfile:
    path: "{{transmission_config}}"
    regexp: '^    "rpc-whitelist":'
    line: '    "rpc-whitelist": "127.0.0.1,192.168.*.*,10.0.*.*",'
    insertafter: ",$"
  notify: restart transmission service

- name: config umask
  become: yes
  lineinfile:
    path: "{{transmission_config}}"
    regexp: '^    "umask":'
    line: '    "umask": 2,'
    insertafter: ",$"
  notify: restart transmission service

- name: config port
  become: yes
  lineinfile:
    path: "{{transmission_config}}"
    regexp: '^    "rpc-port":'
    line: "    \"rpc-port\": {{transmission_port}},"
    insertafter: ",$"
  notify: restart transmission service

# the password is hashed at start of server so this always changes
- name: config password
  become: yes
  lineinfile:
    path: "{{transmission_config}}"
    regexp: '^    "rpc-password":'
    line: "    \"rpc-password\": \"{{transmission_passwd}}\","
    insertafter: ",$"
  changed_when: false

- name: config download dir
  become: yes
  lineinfile:
    path: "{{transmission_config}}"
    regexp: '^    "download-dir":'
    line: "    \"download-dir\": \"{{transmission_download_dir}}\","
    insertafter: ",$"
  notify: restart transmission service

- name: config disable seeding
  become: yes
  lineinfile:
    path: "{{transmission_config}}"
    regexp: '^    "idle-seeding-limit":'
    line: "    \"idle-seeding-limit\": 0,"
    insertafter: ",$"
  notify: restart transmission service

- name: config disable seeding
  become: yes
  lineinfile:
    path: "{{transmission_config}}"
    regexp: '^    "idle-seeding-limit-enabled":'
    line: "    \"idle-seeding-limit-enabled\": true,"
    insertafter: ",$"
  notify: restart transmission service

- name: Make transmission not wait for sd_notify
  become: yes
  copy:
    dest: "/etc/systemd/system/transmission-daemon.service.d/override.conf"
    mode: "0644"
    content: |
      [Service]
      Type=simple
  notify: restart transmission service

- name: start transmission service
  become: yes
  systemd: name="transmission-daemon" state="started" daemon_reload="yes"
  changed_when: false