6078e8d9b978f5e70b61f7bbb4c3347d7259fbd0
This commit adds a new feature to the playbook that configures DNS settings for a Samba AD DC. It includes changes to the `defaults/main.yml` file, `tasks/install.yml`, `tasks/preparing.yml`, `tasks/verify.yml`, and `templates/resolv.conf.j2` files.
Ansible Role: samba_ad_dc
Ansible role to install, provision, and optionally remove a Samba Active Directory Domain Controller (AD DC) on Debian-based systems (e.g., Debian, Ubuntu).
✅ Features
- Installs and configures Samba as an AD Domain Controller
- Uses
samba-toolto provision the domain - Idempotent: Won't re-provision if already set up
- Reversible: Set
state: absentto cleanly remove Samba AD DC - Sets up
/etc/hostsand DNS resolver - Separate Kerberos configuration
- Logging of provisioning
- Molecule tests included for both
presentandabsentstates
📦 Role Variables
Main Variables
| Variable | Description | Default |
|---|---|---|
samba_ad_dc_state |
present to install, absent to remove |
present |
samba_realm |
Kerberos Realm (e.g., EXAMPLE.COM) |
EXAMPLE.COM |
samba_domain |
NetBIOS domain name (e.g., EXAMPLE) |
EXAMPLE |
samba_admin_password |
Admin password for the domain | StrongAdminPassword123! |
samba_dns_backend |
DNS backend (SAMBA_INTERNAL, BIND9_DLZ) |
SAMBA_INTERNAL |
samba_hostname |
Hostname for the server | inventory_hostname |
🧰 Example Playbook
- hosts: samba
become: true
roles:
- role: samba_ad_dc
vars:
samba_realm: "CORP.EXAMPLE.COM"
samba_domain: "CORP"
samba_admin_password: "SuperSecretPassw0rd!"
❌ Remove Samba AD DC
- hosts: samba
become: true
roles:
- role: samba_ad_dc
vars:
samba_ad_dc_state: absent
📁 Included Tasks
install.yml: Installs and provisions Samba AD
remove.yml: Stops and removes Samba AD
kerberos.yml: Configures Kerberos (/etc/krb5.conf)
verify.yml: Validates the installation (samba-tool, kinit)
dns_hosts.yml: Ensures /etc/hosts and DNS resolvers are set
logging.yml: Logs provisioning output
📄 Templates
smb.conf.j2: Samba configuration
krb5.conf.j2: Kerberos configuration
🔒 Security Notes
Passwords should be stored in Ansible Vault for production.
DNS and Kerberos configuration assumes internal AD DNS — adjust for external resolvers if needed.
🧩 Compatibility
OS: Debian 10/11/12+, Ubuntu 20.04/22.04+
Ansible: 2.9+
Description
Languages
Jinja
100%