update youtube-dl role #195

Merged
mg merged 1 commit from sdyd into master 2024-09-27 18:57:51 +02:00
2 changed files with 29 additions and 37 deletions

View file

@ -1,12 +1,12 @@
---
- name: download binary
- name: Ensure youtubedl(p) is present
become: true
ansible.builtin.get_url:
url: "{{ ytdl_dl_url }}"
dest: /usr/local/bin/yt-dlp
mode: "0750"
- name: install packages
- name: Ensure dependencies are present
become: true
ansible.builtin.package:
name:
@ -15,7 +15,7 @@
- python3-mutagen
state: present
- name: ensure dir exists
- name: Ensure directories exist
become: true
ansible.builtin.file:
path: "{{ ytdl_conf_dir }}"
@ -24,7 +24,7 @@
group: root
mode: "0755"
- name: template youtubedl video config
- name: Template youtubedl Video config
become: true
ansible.builtin.template:
src: youtube.txt
@ -36,7 +36,7 @@
- systemctl daemon-reload
when: ytdl_enable_video_download
- name: template youtubedl podcast config
- name: Template youtubedl Podcast config
become: true
ansible.builtin.template:
src: podcast.txt
@ -48,46 +48,26 @@
- systemctl daemon-reload
when: ytdl_enable_podcast_download
- name: template systemd services
- name: Ensure services are present
become: true
ansible.builtin.template:
src: "youtubedl.service.j2"
dest: "/etc/systemd/system/youtubedl.service"
src: "{{ item }}.j2"
dest: "/etc/systemd/system/{{ item }}"
owner: root
group: root
mode: "0644"
notify:
- systemctl daemon-reload
loop:
- youtubedl.service
- youtubedl.timer
- youtubedl_mail.service
when: ytdl_active
- name: template youtubedl timer
become: true
ansible.builtin.template:
src: "youtubedl.timer.j2"
dest: "/etc/systemd/system/youtubedl.timer"
owner: root
group: root
mode: "0644"
notify:
- systemctl daemon-reload
when: ytdl_active
- name: template youtube_mail.service.j2
become: true
ansible.builtin.template:
src: "youtubedl_mail.service.j2"
dest: "/etc/systemd/system/youtubedl_mail.service"
owner: root
group: root
mode: "0644"
notify:
- systemctl daemon-reload
when: ytdl_active
- name: systemctl enable timer units
- name: Ensure timer unit is enabled
become: true
ansible.builtin.systemd:
name: "youtubedl.timer"
name: youtubedl.timer
enabled: true
masked: false
state: started
@ -95,7 +75,19 @@
- systemctl daemon-reload
when: ytdl_active
- name: ensure youtubedl video config is absent
- name: Ensure service units are enabled
become: true
ansible.builtin.systemd:
name: "{{ item }}"
masked: false
enabled: true
loop:
- youtubedl.service
- youtubedl.timer
- youtubedl_mail.service
when: ytdl_active
- name: Ensure youtubedl Video config is absent
become: true
ansible.builtin.file:
state: absent
@ -104,7 +96,7 @@
- systemctl daemon-reload
when: not ytdl_enable_video_download
- name: ensure youtubedl podcast config is absent
- name: Ensure youtubedl Podcast config is absent
become: true
ansible.builtin.file:
state: absent

View file

@ -1,7 +1,7 @@
{{ file_header | default () }}
[Unit]
Description=Save podcats and videos with youtubedl.
Description=Save podcast and videos with youtubedl.
OnFailure=youtubedl_mail.service
[Service]