From fa9a8edeb026f45d720d6753357c9f1234b17963 Mon Sep 17 00:00:00 2001 From: Jakub Kadlcik Date: Thu, 13 Feb 2025 16:14:47 +0100 Subject: [PATCH] dnf-automatic: create a drop-in for the Mon..Fri configuration See https://github.com/fedora-copr/copr/issues/3623#issuecomment-2656844947 --- roles/dnf-automatic/tasks/main.yml | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/roles/dnf-automatic/tasks/main.yml b/roles/dnf-automatic/tasks/main.yml index f3d5d36b99..f39eff322a 100644 --- a/roles/dnf-automatic/tasks/main.yml +++ b/roles/dnf-automatic/tasks/main.yml @@ -7,10 +7,17 @@ # - name: Install and configure dnf-automatic when: ansible_pkg_mgr == 'dnf' + + vars: + dnf: "{{ 5 if (ansible_distribution_major_version | int >= 41 and ansible_distribution == 'Fedora') else 4 }}" + package: "{{ 'dnf5-plugin-automatic' if dnf == '5' else 'dnf-automatic' }}" + timer: "{{ 'dnf5-automatic.timer' if dnf == '5' else 'dnf-automatic-install.timer' }}" + confdir: "/etc/systemd/system/{{ timer }}.d" + block: - name: Install dnf-automatic ansible.builtin.dnf: - name: "{{ 'dnf5-plugin-automatic' if (ansible_distribution_major_version | int >= 41 and ansible_distribution == 'Fedora') else 'dnf-automatic' }}" + name: "{{ package }}" state: present disablerepo: updates tags: @@ -24,9 +31,15 @@ tags: - config + - name: Create directory for drop-in units + ansible.builtin.file: + path: "{{ confdir }}" + state: directory + mode: "755" + - name: Set dnf-automatic to execute only on Mon-Fri community.general.ini_file: - path: "{{ '/usr/lib/systemd/system/dnf5-automatic.timer' if (ansible_distribution_major_version | int >= 41 and ansible_distribution == 'Fedora') else '/usr/lib/systemd/system/dnf-automatic-install.timer' }}" + path: "{{ confdir }}/weekdays.conf" section: Timer option: OnCalendar value: Mon..Fri *-*-* 6:00:00 @@ -37,7 +50,7 @@ - name: Enable and start dnf-automatic timer ansible.builtin.service: - name: "{{ 'dnf5-automatic.timer' if (ansible_distribution_major_version | int >= 41 and ansible_distribution == 'Fedora') else 'dnf-automatic-install.timer' }}" + name: "{{ timer }}" enabled: true state: started tags: