--- - hosts: samba tasks: - name: Install Samba Packages become: yes apt: name: ['samba', 'smbclient','winbind','krb5-user','krb5-config','krb5-locales','winbind','libpam-winbind','libnss-winbind','dnsutils'] state: present update_cache: true - name: stop samba services become: yes command: systemctl stop "{{ item }}" ignore_errors: true with_items: - samba-ad-dc.service - smbd.service - nmbd.service - winbind.service - name: disable samba services become: yes command: systemctl disable "{{ item }}" ignore_errors: true with_items: - samba-ad-dc.service - smbd.service - nmbd.service - winbind.service - name: set nsswitch service to use DNS resolution become: yes lineinfile: path: /etc/nsswitch.conf state: present regexp: '^hosts:' line: 'hosts: files dns mdns4_minimal [NOTFOUND=return]' - name: check if smb.conf exists stat: path: /etc/samba/smb.conf register: stat_result - name: rename default smb.conf become: yes shell: mv /etc/samba/smb.conf /etc/samba/smb.conf.backup ignore_errors: true tags: remove_default_samba_config - name: delete default kerberos configuration if it exists become: yes file: state: absent path: "/etc/krb5.conf" tags: remove_default_samba_config