Add remove playbook/role

This commit is contained in:
2025-02-27 16:30:50 -05:00
parent f314e943f5
commit 54d44730fe
4 changed files with 68 additions and 0 deletions

View File

@ -0,0 +1,38 @@
---
- name: Check previous log file
ansible.builtin.stat:
path: "/var/log/rear/rear-{{ ansible_hostname }}.log"
register: old_rear_log
- name: Backup ReaR log file
when:
- old_rear_log['stat']['exists']
block:
- name: Copy old ReaR log file to backup location
ansible.builtin.copy:
src: "/var/log/rear/rear-{{ ansible_hostname }}.log"
dest: "/var/log/rear-{{ ansible_hostname }}-{{ '%Y-%m-%d' | strftime(old_rear_log['stat']['mtime']) }}.log"
mode: "0644"
backup: true
remote_src: true
- name: Remove old ReaR log file
ansible.builtin.file:
path: "/var/log/rear/rear-{{ ansible_hostname }}.log"
state: absent
- name: Remove files
ansible.builtin.file:
path: "{{ item }}"
state: absent
loop:
- "/boot/rear-initrd.cgz"
- "/boot/rear-kernel"
- "/etc/rear"
- "/tmp/rear"
- "/var/lib/rear"
- name: Remove Grub2 config
ansible.builtin.file:
path: "/etc/grub.d/45_rear"
notify: Rebuild Grub2