42 lines
1.3 KiB
YAML
42 lines
1.3 KiB
YAML
# The metrics run after apt-daily (update) and apt-daily-upgrade (upgrade), so they show the state apt
|
|
# just reached without a timer of their own. The "-" lets a failing metrics run leave apt's units green.
|
|
- name: Create the textfile directory
|
|
ansible.builtin.file:
|
|
path: "{{ apt_updates_textfile_dir }}"
|
|
state: directory
|
|
mode: "0755"
|
|
|
|
- name: Install the apt metrics script
|
|
ansible.builtin.template:
|
|
src: apt-updates-metrics.j2
|
|
dest: /usr/local/sbin/apt-updates-metrics
|
|
mode: "0755"
|
|
|
|
- name: Create the apt timers' drop-in directories
|
|
ansible.builtin.file:
|
|
path: /etc/systemd/system/{{ item }}.service.d
|
|
state: directory
|
|
mode: "0755"
|
|
loop:
|
|
- apt-daily
|
|
- apt-daily-upgrade
|
|
|
|
- name: Run the apt metrics after the apt timers' services
|
|
ansible.builtin.copy:
|
|
dest: /etc/systemd/system/{{ item }}.service.d/apt-updates-metrics.conf
|
|
mode: "0644"
|
|
content: |
|
|
[Service]
|
|
ExecStartPost=-/usr/local/sbin/apt-updates-metrics
|
|
loop:
|
|
- apt-daily
|
|
- apt-daily-upgrade
|
|
register: apt_updates_dropins
|
|
|
|
- name: Reload systemd after the apt metrics drop-ins
|
|
ansible.builtin.systemd:
|
|
daemon_reload: true
|
|
when: apt_updates_dropins.changed
|
|
# Check mode does not write the drop-ins.
|
|
ignore_errors: "{{ ansible_check_mode }}"
|