--- - name: Docker cleanup on all hosts hosts: docker_hosts become: yes gather_facts: no tasks: - name: Prune with docker CLI shell: | docker image prune -f docker network prune -f docker builder prune -f register: prune_result changed_when: "'Total reclaimed space' in prune_result.stdout" - name: Show prune output debug: var: prune_result.stdout_lines when: prune_result.stdout_lines | length > 0