From 3e8c34b46cb19776bccbb68cf25eecac4a3b5f87 Mon Sep 17 00:00:00 2001 From: Michael Grote Date: Fri, 27 Sep 2024 18:56:36 +0200 Subject: [PATCH] ff --- roles/mgrote_youtubedl/tasks/main.yml | 64 ++++++++----------- .../templates/youtubedl.service.j2 | 2 +- 2 files changed, 29 insertions(+), 37 deletions(-) diff --git a/roles/mgrote_youtubedl/tasks/main.yml b/roles/mgrote_youtubedl/tasks/main.yml index c4f4f39b..ae222b9d 100644 --- a/roles/mgrote_youtubedl/tasks/main.yml +++ b/roles/mgrote_youtubedl/tasks/main.yml @@ -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 diff --git a/roles/mgrote_youtubedl/templates/youtubedl.service.j2 b/roles/mgrote_youtubedl/templates/youtubedl.service.j2 index ccd74d34..c255ddfc 100644 --- a/roles/mgrote_youtubedl/templates/youtubedl.service.j2 +++ b/roles/mgrote_youtubedl/templates/youtubedl.service.j2 @@ -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] -- 2.43.0