38 lines
1.1 KiB
YAML
38 lines
1.1 KiB
YAML
- name: Check for pending .pacnew files
|
|
ansible.builtin.find:
|
|
paths: /etc
|
|
patterns: "*.pacnew"
|
|
recurse: yes
|
|
register: pacnew_files
|
|
|
|
- name: Ensure pacnew.logs directory exists locally
|
|
ansible.builtin.file:
|
|
path: "{{ playbook_dir }}/pacnew.logs"
|
|
state: directory
|
|
mode: '0755'
|
|
delegate_to: localhost
|
|
run_once: true
|
|
become: no
|
|
|
|
- name: Save .pacnew list to file
|
|
ansible.builtin.copy:
|
|
content: "{{ pacnew_files.files | map(attribute='path') | join('\n') }}\n"
|
|
dest: "{{ playbook_dir }}/pacnew.logs/{{ inventory_hostname }}.pacnew"
|
|
mode: '0644'
|
|
delegate_to: localhost
|
|
become: no
|
|
when: pacnew_files.matched > 0
|
|
|
|
- name: Clean up old .pacnew list file if no .pacnew files exist
|
|
ansible.builtin.file:
|
|
path: "{{ playbook_dir }}/pacnew.logs/{{ inventory_hostname }}.pacnew"
|
|
state: absent
|
|
delegate_to: localhost
|
|
become: no
|
|
when: pacnew_files.matched == 0
|
|
|
|
- name: Alert if .pacnew files exist
|
|
ansible.builtin.debug:
|
|
msg: "Warning: The following .pacnew files require merging: {{ pacnew_files.files | map(attribute='path') | list }}"
|
|
when: pacnew_files.matched > 0
|