From ba75d48ea6a448826df00cf4cfcdffcf4000722e Mon Sep 17 00:00:00 2001 From: Jose Date: Mon, 3 Nov 2025 19:46:40 +0100 Subject: [PATCH] =?UTF-8?q?feat=20=E2=9C=A8:=20Stop=20Samba=20services=20b?= =?UTF-8?q?efore=20provisioning?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added a new task to stop relevant Samba services before provisioning, ensuring a clean environment for the AD DC setup. This change improves the overall stability and reliability of the provisioning process. --- tasks/install.yml | 11 +++++++++++ tasks/provision.yml | 10 ++++++++++ 2 files changed, 21 insertions(+) diff --git a/tasks/install.yml b/tasks/install.yml index 3a0e06c..2e566e4 100644 --- a/tasks/install.yml +++ b/tasks/install.yml @@ -20,6 +20,17 @@ # enabled: no # ignore_errors: true +- name: Stop Samba services before provisioning + ansible.builtin.service: + name: "{{ item }}" + state: stopped + ignore_errors: true + loop: + - samba-ad-dc + - smbd + - nmbd + - winbind + diff --git a/tasks/provision.yml b/tasks/provision.yml index 4dfed80..de0d4c3 100644 --- a/tasks/provision.yml +++ b/tasks/provision.yml @@ -4,6 +4,16 @@ path: /var/lib/samba/private/adsync.conf register: samba_provisioned +- name: Remove smb.conf if server role conflicts + ansible.builtin.shell: | + if grep -q "server role = standalone server" /etc/samba/smb.conf 2>/dev/null; then + mv /etc/samba/smb.conf /etc/samba/smb.conf.bak.$(date +%s) + fi + args: + executable: /bin/bash + changed_when: false + when: not samba_provisioned.stat.exists + - name: Provision the Samba AD DC ansible.builtin.command: > samba-tool domain provision