dnf-automatic: create a drop-in for the Mon..Fri configuration
See https://github.com/fedora-copr/copr/issues/3623#issuecomment-2656844947
This commit is contained in:
parent
3602ac8f97
commit
fa9a8edeb0
1 changed files with 16 additions and 3 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue