--- - name: (samba-server.yml) Ensure samba share directories exists file: path: "/data/shares/{{ item.name }}" owner: "root" group: "{{ item.group }}" mode: '2770' state: directory with_items: "{{ samba_shares }}" loop_control: label: '{{ item.name }}' tags: - samba-shares - name: (samba-server.yml) Checki if file '/etc/samba/smbconf.ORIG' exists stat: path: /etc/samba/smb.conf.ORIG register: etc_samba_smb_conf_ORIG tags: - samba-config - name: (samba-server.yml) Backup installation version of file '/etc/samba/smb.conf' command: cp -a /etc/samba/smb.conf /etc/samba/smb.conf.ORIG when: etc_samba_smb_conf_ORIG.stat.exists == False tags: - samba-config - name: (samba-server.yml) Create new smb.conf from template smb.conf.j2 template: src: etc/samba/smb.conf.j2 dest: /etc/samba/smb.conf owner: root group: root mode: 0644 #backup: yes notify: "Reload samba config" tags: - samba-config