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