--- - name: Install samba and required tools apt: name: "{{ item }}" state: present loop: "{{ samba_packages }}" tags: samba - name: Install nsswitch passwd config lineinfile: dest: /etc/nsswitch.conf regexp: "^passwd:" line: "passwd{{ ':' }} files winbind" notify: Restart samba tags: - samba - nsswitch - name: Install nsswitch group config lineinfile: dest: /etc/nsswitch.conf regexp: "^group:" line: "group{{ ':' }} files winbind" notify: Restart samba tags: - samba - nsswitch - name: Install nsswitch shadow config lineinfile: dest: /etc/nsswitch.conf regexp: "^shadow:" line: "shadow{{ ':' }} files winbind" notify: Restart samba tags: - samba - nsswitch - name: Install samba configuration template: src: smb.conf.j2 dest: /etc/samba/smb.conf mode: 0644 owner: root group: root notify: Restart samba tags: - samba - smbconf - name: Enable samba services service: name: "{{ item }}" enabled: yes loop: "{{ samba_daemons }}" tags: samba - name: Join domain shell: "net ads join -U {{ ad_admin_username }}%{{ ad_admin_password }}" notify: Restart samba register: join_domain tags: samba