summaryrefslogtreecommitdiffstats
path: root/roles/bittorrent/tasks/update.yml
blob: 01e57779b0454952695df5394152ade5a735d479 (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
- name: Récupération de la liste des torrents disponibles
  shell: curl -sS https://torrents.fedoraproject.org/torrents/ | grep torrent | grep -v Index | awk '{ print $6 }' | cut -d '"' -f2 | sed 's/.torrent//' | egrep -vi 'alpha|beta' |grep 37
  args:
    executable: /usr/bin/zsh
  run_once: true
  register: torrentlist

- name: Vérifier la présence de tous les torrents
  shell: transmission-remote -l | grep '{{ item }}'
  args:
    executable: /usr/bin/zsh
  loop: "{{ torrentlist.stdout_lines }}"
  register: torrentpresence
  changed_when: "torrentpresence.rc == 1"
  failed_when: False

- name: Génération du fichier de statistiques de partage
  template:
    src: transmission-stats.txt.j2
    dest: /root/transmission-stats.txt

- name: Récupération du fichier de statistiques
  fetch:
    src: /root/transmission-stats.txt
    dest: roles/bittorrent/files/stats/

- name: Mise à jour de transmission-daemon
  command: transmission-remote -a https://torrents.fedoraproject.org/torrents/'{{ item }}'.torrent
  loop: "{{ torrentlist.stdout_lines }}"
  register: addtorrent
  when: torrentpresence is changed
  until: addtorrent is changed
  retries: 3
  delay: 30