Execution
Date 23 Jan 2026 07:05:19 +0000
Duration 00:02:51.56
Controller ssh-gw-4.layershift.com
User root
Versions
Ansible 2.16.11
ara 1.7.4 / 1.7.4
Python 3.10.10
Summary
396 Hosts
2 Tasks
789 Results
1 Plays
1 Files
0 Records

File: /home/ssh-gateway/ansible/kuly/zz-rm-logrotate.yaml

---
- name: Remove timestamped Ansible-like backup files in /etc/logrotate.d
  hosts: all
  gather_facts: false
  vars:
    logrotate_dir: /etc/logrotate.d
    base_names:
      - alt-php80-fpm.logrotate
      - alt-php81-fpm.logrotate
      - alt-php82-fpm.logrotate
      - alt-php83-fpm.logrotate
      - alt-php84-fpm.logrotate
      - alt-php85-fpm.logrotate

  tasks:
    - name: Find and delete backup files matching base names
      ansible.builtin.find:
        paths: "{{ logrotate_dir }}"
        patterns: "{{ item }}.*~"
        file_type: file
      register: found_backups
      loop: "{{ base_names }}"
      loop_control:
        label: "{{ item }}"

    - name: Delete matched backup files
      ansible.builtin.file:
        path: "{{ backup_file.path }}"
        state: absent
      loop: "{{ found_backups.results | map(attribute='files') | flatten }}"
      loop_control:
        loop_var: backup_file