--- - name: Remove unwanted system packages apt: name: "{{ cleanup_packages }}" state: absent autoremove: "{{ cleanup_autoremove }}" purge: true when: cleanup_packages | length > 0 - name: Remove specific SSH authorized keys (if any defined) authorized_key: user: root key: "{{ item }}" state: absent loop: "{{ cleanup_ssh_keys | default([]) }}" when: cleanup_ssh_keys | length > 0 - name: Prune unused Docker containers command: docker container prune -f when: cleanup_docker and cleanup_docker_containers changed_when: true - name: Prune unused Docker images command: docker image prune -af when: cleanup_docker and cleanup_docker_images changed_when: true - name: Prune unused Docker volumes command: docker volume prune -f when: cleanup_docker and cleanup_docker_volumes changed_when: true - name: Prune unused Docker networks command: docker network prune -f when: cleanup_docker and cleanup_docker_networks changed_when: true - name: Remove custom directories (use with caution!) file: path: "{{ item }}" state: absent loop: "{{ cleanup_directories | default([]) }}" when: cleanup_directories | length > 0