--- - hosts: all gather_facts: no tasks: - name: Check if directory /home/back exists stat: path: /home/back register: home_back - name: Set correct group recursivly for directory /home/back file: group: back path: /home/back recurse: yes when: home_back.stat.exists