---
# Installation
- name: Install Transmission
  apt:
    name: transmission-daemon
    state: present
  tags: transmission

# Configuration
- name: Make sure transmission is not running
  service:
    name: transmission-daemon
    state: stopped
  ignore_errors: true
  tags: transmission

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

- name: Add watch dir
  file:
    state: directory
    path: "{{ transmission_watch_dir }}"
    owner: "{{ transmission_user }}"
    group: debian-transmission
  when: transmission_watch_dir_enabled
  tags: transmission

- name: Add incomplete folder
  file:
    state: directory
    path: "{{ transmission_incomplete_dir }}"
    owner: "{{ transmission_user }}"
    group: debian-transmission
    mode: 0775
  when: transmission_incomplete_dir_enabled
  tags: transmission

- name: Copy Transmission configuration
  template:
    src: settings.json
    dest: /etc/transmission-daemon/settings.json
  tags: transmission

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

# Service start
- name: Start transmission
  service:
    name: transmission-daemon
    state: started
  ignore_errors: true
  tags: transmission

---
# Installation
- name: Install Transmission
  apt:
    name: transmission-daemon
    state: present
  tags: transmission

# Configuration
- name: Make sure transmission is not running
  service:
    name: transmission-daemon
    state: stopped
  ignore_errors: true
  tags: transmission

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

- name: Add watch dir
  file:
    state: directory
    path: "{{ transmission_watch_dir }}"
    owner: "{{ transmission_user }}"
    group: debian-transmission
    mode: 0775
  when: transmission_watch_dir_enabled
  tags: transmission

- name: Add incomplete folder
  file:
    state: directory
    path: "{{ transmission_incomplete_dir }}"
    owner: "{{ transmission_user }}"
    group: debian-transmission
    mode: 0775
  when: transmission_incomplete_dir_enabled
  tags: transmission

- name: Copy Transmission configuration
  template:
    src: settings.json
    dest: /etc/transmission-daemon/settings.json
  tags: transmission

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

# Service start
- name: Start transmission
  service:
    name: transmission-daemon
    state: started
  ignore_errors: true
  tags: transmission

Set mode for watch dir
Set mode for watch dir
