- name: Enable & (Re)Start 'transmission-daemon' systemd service, if transmission_enabled
  systemd:
    daemon_reload: yes
    name: transmission-daemon
    enabled: yes
    state: restarted
  when: transmission_enabled

- debug:
    var: transmission_kalite_languages

- name: Add PAUSED KA Lite torrent(s) to transmission-daemon's queue
  shell: >
    /usr/bin/transmission-remote
    --start-paused
    -n {{ transmission_username }}:{{ transmission_password }}
    -a https://pantry.learningequality.org/downloads/ka-lite/{{ transmission_kalite_version }}/content/ka-lite-0.17-resized-videos-{{ item }}.torrent
  with_items: "{{ transmission_kalite_languages }}"
  when: transmission_enabled and transmission_provision and transmission_kalite_languages is defined and transmission_kalite_languages is not none    # '!= None' also works (i.e. to avoid var value 'null', with type 'NoneType')
  ignore_errors: yes

- name: Disable & Stop 'transmission-daemon' service, if not transmission_enabled
  systemd:
    daemon_reload: yes
    name: transmission-daemon
    enabled: no
    state: stopped
  when: not transmission_enabled
