- name: Setup samba
  tags: samba
  become: true
  block:

    - name: Install samba
      ansible.builtin.apt:
        name: samba
        state: present

    - name: Copy smb.conf
      ansible.builtin.template:
        src: templates/smb.conf.j2
        dest: /etc/samba/smb.conf
        mode: 0644
      notify: reload smbd.service

    - name: mkdir private
      ansible.builtin.file:
        path: "/etc/samba/private/"
        state: directory
        mode: '0750'

    - name: copy user passwords
      ansible.builtin.copy:
        src: "{{ inventory_hostname }}/passdb.tdb"
        dest: /etc/samba/private/passdb.tdb
        mode: '0600'
        # never overwrite local changes:
        force: false
