--- - name: Update and upgrade packages apt: update_cache: true upgrade: true autoremove: true become: true - name: Install Samba dependencies apt: name: "{{ samba.dependencies }}" state: present become: true - name: Add group "{{ samba.group }}" group: name: "{{ samba.group }}" state: present become: true - name: Change permission on share file: path: "{{ samba.media_dir }}" group: "{{ samba.group }}" mode: "2770" become: true - name: Add user "{{ samba.user }}" user: name: "{{ samba.user }}" shell: "/sbin/nologin" groups: "{{ samba.group }}" append: true become: true register: new_user - name: Add password to "{{ samba.user }}" shell: cmd: smbpasswd -a "{{ samba.user }}" stdin: "{{ host.samba.password }}\n{{ host.samba.password }}" become: true when: new_user.changed