Ansible - Create Multiple Folders If Don't Exist
Answer : Using Ansible modules, you don't need to check if something exist or not, you just describe the desired state, so: - name: create directory if they don't exist file: path: "{{ item }}" state: directory owner: root group: root mode: 0775 loop: - /data/directory - /data/another Ansible - Creating multiple folders without changing permissions of previously existing. Working fine for me. Hope this works for you as well just try. --- - name: "Creating multiple by checking folders" hosts: your_host_name tasks: - block: - name: "Checking folders" stat: path: "{{item}}" register: folder_stats with_items: - ["/var/www/f1","/var/www/f2","/var/www/f3","/var/www/f4"] - name: "Creating multiple folders without disturbing previous permissions" file: path: "{{item.item}}" state: direc...