2023-10-25 22:26:17 +02:00
|
|
|
---
|
2024-09-27 18:56:36 +02:00
|
|
|
- name: Ensure youtubedl(p) is present
|
2023-10-25 22:26:17 +02:00
|
|
|
become: true
|
|
|
|
ansible.builtin.get_url:
|
|
|
|
url: "{{ ytdl_dl_url }}"
|
|
|
|
dest: /usr/local/bin/yt-dlp
|
|
|
|
mode: "0750"
|
|
|
|
|
2024-09-27 18:56:36 +02:00
|
|
|
- name: Ensure dependencies are present
|
2023-10-25 22:26:17 +02:00
|
|
|
become: true
|
|
|
|
ansible.builtin.package:
|
|
|
|
name:
|
|
|
|
- ffmpeg
|
|
|
|
- brotli
|
|
|
|
- python3-mutagen
|
|
|
|
state: present
|
|
|
|
|
2024-09-27 18:56:36 +02:00
|
|
|
- name: Ensure directories exist
|
2023-10-25 22:26:17 +02:00
|
|
|
become: true
|
|
|
|
ansible.builtin.file:
|
|
|
|
path: "{{ ytdl_conf_dir }}"
|
|
|
|
state: directory
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: "0755"
|
|
|
|
|
2024-09-27 18:56:36 +02:00
|
|
|
- name: Template youtubedl Video config
|
2023-10-25 22:26:17 +02:00
|
|
|
become: true
|
|
|
|
ansible.builtin.template:
|
2023-12-22 12:26:15 +01:00
|
|
|
src: youtube.txt
|
|
|
|
dest: "{{ ytdl_conf_dir }}/youtube.txt"
|
2023-10-25 22:26:17 +02:00
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: "0644"
|
|
|
|
notify:
|
|
|
|
- systemctl daemon-reload
|
2023-12-22 12:26:15 +01:00
|
|
|
when: ytdl_enable_video_download
|
|
|
|
|
2024-09-27 18:56:36 +02:00
|
|
|
- name: Template youtubedl Podcast config
|
2023-12-22 12:26:15 +01:00
|
|
|
become: true
|
|
|
|
ansible.builtin.template:
|
|
|
|
src: podcast.txt
|
|
|
|
dest: "{{ ytdl_conf_dir }}/podcast.txt"
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: "0644"
|
|
|
|
notify:
|
|
|
|
- systemctl daemon-reload
|
|
|
|
when: ytdl_enable_podcast_download
|
2023-10-25 22:26:17 +02:00
|
|
|
|
2024-09-27 18:56:36 +02:00
|
|
|
- name: Ensure services are present
|
2023-10-25 22:26:17 +02:00
|
|
|
become: true
|
|
|
|
ansible.builtin.template:
|
2024-09-27 18:56:36 +02:00
|
|
|
src: "{{ item }}.j2"
|
|
|
|
dest: "/etc/systemd/system/{{ item }}"
|
2023-10-25 22:26:17 +02:00
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: "0644"
|
|
|
|
notify:
|
|
|
|
- systemctl daemon-reload
|
2024-09-27 18:56:36 +02:00
|
|
|
loop:
|
|
|
|
- youtubedl.service
|
|
|
|
- youtubedl.timer
|
|
|
|
- youtubedl_mail.service
|
2023-10-25 22:26:17 +02:00
|
|
|
when: ytdl_active
|
|
|
|
|
2024-09-27 18:56:36 +02:00
|
|
|
- name: Ensure timer unit is enabled
|
2023-10-25 22:26:17 +02:00
|
|
|
become: true
|
2024-09-27 18:56:36 +02:00
|
|
|
ansible.builtin.systemd:
|
|
|
|
name: youtubedl.timer
|
|
|
|
enabled: true
|
|
|
|
masked: false
|
|
|
|
state: started
|
2023-10-25 22:26:17 +02:00
|
|
|
notify:
|
|
|
|
- systemctl daemon-reload
|
|
|
|
when: ytdl_active
|
|
|
|
|
2024-09-27 18:56:36 +02:00
|
|
|
- name: Ensure service units are enabled
|
2023-10-25 22:26:17 +02:00
|
|
|
become: true
|
|
|
|
ansible.builtin.systemd:
|
2024-09-27 18:56:36 +02:00
|
|
|
name: "{{ item }}"
|
2023-10-25 22:26:17 +02:00
|
|
|
masked: false
|
2024-09-27 18:56:36 +02:00
|
|
|
enabled: true
|
|
|
|
loop:
|
|
|
|
- youtubedl.service
|
|
|
|
- youtubedl.timer
|
|
|
|
- youtubedl_mail.service
|
2023-10-25 22:26:17 +02:00
|
|
|
when: ytdl_active
|
2023-12-22 12:26:15 +01:00
|
|
|
|
2024-09-27 18:56:36 +02:00
|
|
|
- name: Ensure youtubedl Video config is absent
|
2023-12-22 12:26:15 +01:00
|
|
|
become: true
|
|
|
|
ansible.builtin.file:
|
|
|
|
state: absent
|
|
|
|
path: "{{ ytdl_conf_dir }}/youtube.txt"
|
|
|
|
notify:
|
|
|
|
- systemctl daemon-reload
|
|
|
|
when: not ytdl_enable_video_download
|
|
|
|
|
2024-09-27 18:56:36 +02:00
|
|
|
- name: Ensure youtubedl Podcast config is absent
|
2023-12-22 12:26:15 +01:00
|
|
|
become: true
|
|
|
|
ansible.builtin.file:
|
|
|
|
state: absent
|
|
|
|
path: "{{ ytdl_conf_dir }}/podcast.txt"
|
|
|
|
notify:
|
|
|
|
- systemctl daemon-reload
|
|
|
|
when: not ytdl_enable_podcast_download
|
|
|
|
...
|