- name: Install Samba ansible.builtin.apt: name: samba state: present - name: Create Samba users ansible.builtin.command: "smbpasswd -a -s {{ item.name }}" args: stdin: "{{ item.password }}\n{{ item.password }}" loop: "{{ samba.users }}" register: samba_users changed_when: "'User added' in samba_users.stdout" - name: Ensure share directories exist ansible.builtin.file: path: "{{ item.path }}" state: directory mode: 0755 loop: "{{ samba.shares }}" - name: Configure Samba shares ansible.builtin.template: src: smb.conf.j2 dest: /etc/samba/smb.conf notify: samba_restart