feat : Check domain before provisioning Samba AD DC

Added a check to ensure the domain is not already provisioned before running the samba-tool domain provision command. This prevents duplicate provisions and ensures consistency in the domain setup.
This commit is contained in:
2025-11-02 17:42:35 +01:00
parent 843ebd52a8
commit 570500c886

View File

@@ -1,4 +1,9 @@
---
- name: check if domain already provisioned
ansible.builtin.stat:
path: /var/lib/samba/private/adsync.conf
register: samba_provisioned
- name: Provision the Samba AD DC
ansible.builtin.command: >
samba-tool domain provision
@@ -10,6 +15,7 @@
--adminpass={{ addc_admin_password }}
--option="interfaces=lo eth0"
--option="bind interfaces only=yes"
when: not samba_provisioned.stat.exists
register: samba_provision_output
changed_when: samba_provision_output.rc == 0
no_log: true # You may toggle this if password should be hidden