From b4be442e7fd854bad7e62671ff1b20d8ff62d35d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20V=C3=A1vra?= Date: Thu, 3 Oct 2024 11:03:01 +0200 Subject: [PATCH] provision: Set samba as dns for the host in idmci Samba role needs to handle dns on the machine to work properly. The upstrem dns is set as forwarder for the samba. --- src/ansible/roles/samba/tasks/main.yml | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/ansible/roles/samba/tasks/main.yml b/src/ansible/roles/samba/tasks/main.yml index 16df907..4eab5da 100644 --- a/src/ansible/roles/samba/tasks/main.yml +++ b/src/ansible/roles/samba/tasks/main.yml @@ -62,12 +62,13 @@ # In containers the file is a mounted from outside so # we change the content. - name: Change resolv.conf - lineinfile: + blockinfile: path: /etc/resolv.conf insertbefore: BOF - line: "nameserver {{ hostvars[groups.dns.0]['ansible_facts']['default_ipv4']['address'] }}" + block: | + nameserver 127.0.0.1 + nameserver {{ hostvars[groups.dns.0]['ansible_facts']['default_ipv4']['address'] }} when: - - '"resolv.conf" in mounts.stdout' - '"dns" in groups and groups["dns"]' - name: Remove systemd-resolved package ansible.builtin.package: @@ -87,6 +88,17 @@ args: creates: /etc/samba/smb.conf +- name: Set forwarder to dns server + ini_file: + path: /etc/samba/smb.conf + section: global + option: "dns forwarder" + value: "{{ hostvars[groups.dns.0]['ansible_facts']['default_ipv4']['address'] }}" + mode: '0600' + backup: no + when: + - '"dns" in groups and groups["dns"]' + - name: Setup Kerberos copy: src: /var/lib/samba/private/krb5.conf