Compare commits

..

37 Commits

Author SHA1 Message Date
b5b3d9384f style 💎: Improve regex pattern for extracting krb5 conf path
Updated the regular expression to correctly extract the absolute path of the krb5.conf file from the samba provision output. This change ensures that the extracted path is properly formatted and can be used in subsequent tasks.
2025-11-06 06:07:39 +01:00
b87ab88f52 style 💎: Update regex pattern for finding krb5.conf path
Updated the regular expression to correctly extract the krb5.conf path from the Samba provision output, ensuring consistency in the configuration file location.
2025-11-06 05:52:17 +01:00
6db8e3d015 style 💎: Improve krb5_conf_path extraction regex
Updated the regular expression to extract the absolute path of the krb5.conf file from the samba provision output, ensuring a more accurate and reliable value.
2025-11-05 22:59:54 +01:00
1bf10307a6 style 💎: Update regex pattern in kerberos.yml
Updated the regular expression to correctly extract the krb5.conf path from the Samba provision output. This change ensures that the correct path is used for setting the krb5_conf_path fact.
2025-11-05 22:52:07 +01:00
257d4b925d style 💎: Improve regex pattern for krb5_conf_path variable
Updated the regex pattern to correctly extract the krb5.conf path from the Samba provision output. This change ensures that the variable returns a list of paths even if only one is present.
2025-11-05 22:37:19 +01:00
bb99d469fe style 💎: Improve regex pattern for finding krb5.conf path
Updated the regex pattern to correctly extract the krb5.conf path from the `your_string_variable` value, ensuring a more reliable and consistent configuration setup.
2025-11-05 22:36:19 +01:00
bfdd2d07b3 style 💎: Update regex pattern for extracting krb5.conf path
Updated the regular expression to correctly extract the krb5.conf path from the provision output, ensuring consistency in variable assignment.
2025-11-05 22:20:09 +01:00
e74f9bdb31 feat : Add debug output for krb5.conf path
Added a debug output to display the path of krb5.conf, making it easier to diagnose issues with Samba provisioning.
2025-11-05 21:46:42 +01:00
9cad7d3b64 style 💎: Update regex search for krb5_conf_path
Updated the regex search pattern in the `krb5_conf_path` fact to ensure a list is returned even if no match is found, and added default values for clarity.
2025-11-05 21:37:57 +01:00
fc0aeb908e style 💎: Update regex pattern for krb5.conf path extraction
Updated the regular expression to extract the absolute path of the krb5.conf file from the provision output, ensuring consistency and accuracy in the extracted value.
2025-11-05 21:15:00 +01:00
a48b146e81 refactor ♻️: Improve krb5 configuration path extraction
Refactored the code to use a more robust regex pattern and added a default value for the extracted path.
2025-11-05 21:01:14 +01:00
38858590f8 feat : Add debug logging for samba provision output
Added a debug log to display the samba provision output, making it easier to diagnose issues with the provisioning process.
2025-11-05 20:49:08 +01:00
7205d9870e chore 📦: Update DNS resolver and Kerberos configuration
Updated the setup of DNS resolver and Kerberos configuration to ensure proper domain authentication. This change will improve the overall security of the system.
2025-11-05 20:41:42 +01:00
b9355e6539 feat : Added samba-ad-dc package to Samba packages list
Updated the default Samba configuration to include samba-ad-dc, a package required for Active Directory domain controllers.
2025-11-05 19:07:57 +01:00
0d6e747ba8 commit-message undefined: Improve Samba service management
Enhanced the provision.yml to properly stop and mask regular Samba services, while unmasking and enabling the Samba AD/DC service. This ensures a more robust setup for the domain controller.
2025-11-05 18:57:30 +01:00
767ebb022b refactor ♻️: Simplify Samba version verification and display logic
Renamed debug block to use Ansible debug output, removing unnecessary variables and improving readability. This change aims to make the code more maintainable and efficient.
2025-11-04 21:11:05 +01:00
6afc14a362 style 💎: Fix debug message formatting for Samba version display
Updated debug message to use the correct variable, `samba_version.stdout`, instead of `samba_new_version.stdout`.
2025-11-04 20:58:29 +01:00
e19c0f8b48 commit undefined: Fix Samba version detection and upgrade process
Updated the Ansible playbook to correctly detect the Samba version and perform an upgrade if necessary. The changes also include adding the Samba Team Debian GPG key, repository, and updating the APT cache.
2025-11-04 20:55:38 +01:00
a8a18f93df modified: tasks/install.yml 2025-11-04 20:46:05 +01:00
c76545e816 style 💎: Update Samba repository URL for Debian
Updated the Samba Team Debian repository URL to use the modern method, which includes a signed-by keyring. This change improves security and stability of the package installation process.
2025-11-04 20:38:03 +01:00
e70b483274 style 💎: Update Samba Team GPG key URL
Updated the URL for the Samba Team Debian GPG key to use a more reliable source, ensuring future installations can correctly verify the team's identity.
2025-11-04 20:32:24 +01:00
e150a3306d chore 📦: Update Samba package installation to use modern methods
Updated the Ansible playbook to use modern methods for adding the Samba Team Debian GPG key and repository, making it easier to upgrade to a newer version of Samba. This change also includes updating the APT cache when an upgrade is needed.
2025-11-04 20:27:20 +01:00
69e83cb83a style 💎: Improve Ansible playbook formatting and readability
Refactored the `tasks/preparing.yml` file to improve its structure, readability, and consistency with best practices. This includes updating variable names, adding whitespace, and standardizing indentation.
2025-11-04 20:21:02 +01:00
79fccba876 feat : Added provision step to stop Samba services before installation
Prevents potential conflicts during the installation process by stopping Samba services before provisioning. This ensures a smoother and more reliable setup. The new step is added at line 74 of tasks/install.yml.
2025-11-04 19:51:43 +01:00
47b0eef15d chore 📦: Update Samba package installation to handle known regression in certain builds
Added checks for Samba version 4.22.4 and updated package installation to upgrade if necessary, ensuring a stable build process.
2025-11-04 19:47:29 +01:00
a95fbd4822 Replaced " with ' 2025-11-04 19:22:07 +01:00
3e62e137da style 💎: Update debug message with correct variable usage
Fixed a typo in the debug message, updating it to use the correct variable `samba_domain_info.adminpass` instead of `addc_admin_password`. This ensures accurate output and prevents potential errors. The updated code will now correctly display the admin password for Samba AD DC.
2025-11-04 17:43:49 +01:00
e9382d195f style 💎: Update debug message with new variable
Updated the debug message to include a new variable, allowing for more flexibility in the output. This change improves the readability and maintainability of the Ansible playbook.
2025-11-03 21:11:30 +01:00
7374c1fb52 feat : Add debug message to display admin password
Added a debug message to the Ansible playbook to display the admin password from the Samba domain, allowing for easier testing and debugging of the Samba AD DC setup.
2025-11-03 21:05:33 +01:00
7fd16e195f style 💎: Update admin password in provision.yml
Updated the admin password variable in the provision.yml file to use a dynamically generated value, making it easier to manage and update passwords across different environments.
2025-11-03 20:56:50 +01:00
07d516d8ea style 💎: Update admin pass format in provision.yml
Updated the format of the admin pass variable to match the new expected format, ensuring consistency with other variables.
2025-11-03 20:47:57 +01:00
ba75d48ea6 feat : Stop Samba services before provisioning
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.
2025-11-03 19:46:40 +01:00
42da69befb style 💎: Improve service configuration for samba-ad-dc
Updated the service configuration to ensure proper stopping of samba-ad-dc before provisioning, improving overall installation stability and consistency.
2025-11-03 19:32:57 +01:00
f85c420c14 style 💎: Update install.yml to use consistent boolean values
Updated the 'ignore_errors' variable from 'yes' to a boolean value 'true' for consistency in the installation script.
2025-11-03 19:26:59 +01:00
92f2c4eb4b chore 📦: Update package list in defaults/main.yml
Updated the list of required packages for Samba, replacing 'dnsutils' with 'bind9-dnsutils'. This change ensures compatibility with the latest DNS server version. No functional changes were made.
2025-11-03 19:07:13 +01:00
d1961671d2 style 💎: Update package manager to use 'pkg' instead of 'pkf'
Switched from 'pkf' to 'pkg' in the Ansible playbook for installing required packages, ensuring consistency with other package managers.
2025-11-03 19:01:33 +01:00
d7efdd1d9a style 💎: Update package installation for samba packages
Updated the Ansible playbook to use apt instead of package for installing samba packages, adding additional options for improved efficiency and cleanup.
2025-11-03 18:42:52 +01:00
9 changed files with 193 additions and 64 deletions

View File

@@ -1,31 +1,31 @@
# AD Provisioning details
# Hostname = DC1
addc_hostname: "DC1"
addc_hostname: 'DC1'
# DC local IP Address = 10.99.0.1
addc_ansible_host: "10.99.0.1"
addc_ansible_host: '10.99.0.1'
# NetBIOS domain name (Workgroup).
addc_netbios_domain: "SAMDOM"
addc_netbios_domain: 'SAMDOM'
# Top level Domain = EXAMPLE.COM
addc_tld: "EXAMPLE.COM"
addc_tld: 'EXAMPLE.COM'
# Authentication Domain = SAMDOM.EXAMPLE.COM
addc_auth_domain: "{{ addc_netbios_domain | upper }}.{{ addc_tld | upper }}"
addc_auth_domain: '{{ addc_netbios_domain | upper }}.{{ addc_tld | upper }}'
addc_admin_password: "Passw0rd"
addc_dns_backend: "SAMBA_INTERNAL"
addc_server_role: "dc"
addc_admin_password: 'Passw0rd'
addc_dns_backend: 'SAMBA_INTERNAL'
addc_server_role: 'dc'
addc_ip_network_prefix: "{{ addc_ansible_host.split('.')[:3] | join('.') }}"
addc_ip_last_octet: "{{ addc_ansible_host.split('.')[-1] }}"
addc_reverse_zone_name: "{{ addc_ip_network_prefix.split('.') | reverse | join('.') }}.in-addr.arpa"
samba_domain_info:
realm: "{{ addc_auth_domain | upper }}"
domain: "{{ addc_netbios_domain | upper }}"
realm: '{{ addc_auth_domain | upper }}'
domain: '{{ addc_netbios_domain | upper }}'
server_role: "{{ addc_server_role | default('dc') }}"
dns_backend: "{{ addc_dns_backend | default('SAMBA_INTERNAL') }}"
adminpass: "{{ addc_admin_password }}"
adminpass: '{{ addc_admin_password }}'
interfaces: "{{ samba_iface_list | join(' ') }}"
bind_interfaces_only: "yes"
bind_interfaces_only: 'yes'
samba_iface_list:
- lo
@@ -40,12 +40,14 @@ samba_packages:
- libnss-winbind
- krb5-config
- krb5-user
- dnsutils
- bind9-dnsutils
# - dnsutils
- python3-setproctitle
# - smbclient
- samba-ad-dc
# template for /etc/resolv.conf
location_internal_dns: 192.168.1.1
location_external_dns: 8.8.8.8
backup_path: "/path/to/your/backup/directory"
backup_path: '/path/to/your/backup/directory'

View File

@@ -1,12 +1,12 @@
---
- name: Check if backup directory exists
stat:
path: "{{ backup_path }}"
path: '{{ backup_path }}'
register: backup_dir_stat
- name: Check if backup directory is not empty
find:
paths: "{{ backup_path }}"
paths: '{{ backup_path }}'
file_type: any
recurse: false
when: backup_dir_stat.stat.exists and backup_dir_stat.stat.isdir
@@ -15,8 +15,8 @@
- name: Check if each required file exists
stat:
path: "{{ dir_path }}/{{ item }}"
loop: "{{ backup_required_files }}"
path: '{{ dir_path }}/{{ item }}'
loop: '{{ backup_required_files }}'
register: required_file_stats
- name: Determine missing files
@@ -52,5 +52,5 @@
- name: Debug - Show final result
debug:
msg: "Backup directory exists and is not empty."
msg: 'Backup directory exists and is not empty.'
when: backup_dir_valid | default(false)

View File

@@ -1,17 +1,123 @@
---
- name: Install required packages
ansible.builtin.package:
name: "{{ samba_packages }}"
ansible.builtin.apt:
pkg: '{{ samba_packages }}'
state: latest
update_cache: yes
autoclean: yes
autoremove: yes
purge: true
- name: Stop samba-ad-dc before provisioning (if running)
ansible.builtin.service:
name: samba-ad-dc
# - name: Install required packages
# ansible.builtin.package:
# name: '{{ samba_packages }}'
# state: latest
# - name: Stop samba-ad-dc before provisioning (if running)
# ansible.builtin.service:
# name: samba-ad-dc
# state: stopped
# enabled: no
# ignore_errors: true
# known regression in certain Samba 4.22.x builds
# - name: Check installed Samba version
# ansible.builtin.command: samba --version
# register: samba_version
# changed_when: false
# failed_when: false
# - name: Show installed Samba version
# ansible.builtin.debug:
# msg: "Samba version: {{ samba_version.stdout }}"
# - name: Warn if Samba version is 4.22.4
# ansible.builtin.debug:
# msg: "⚠️ Detected buggy Samba version 4.22.4 — upgrade recommended!"
# when: "'4.22.4' in samba_version.stdout"
# - name: Add Samba Team Debian GPG key (modern method)
# ansible.builtin.get_url:
# # url: https://pkg.samba.org/keys/samba-pubkey.asc
# url: https://download.samba.org/pub/samba/samba-pubkey.asc
# dest: /usr/share/keyrings/samba-team-archive-keyring.gpg
# mode: '0644'
# when: "'4.22.4' in samba_version.stdout"
# - name: Add Samba Team Debian repository (modern method)
# ansible.builtin.apt_repository:
# # repo: "deb [signed-by=/usr/share/keyrings/samba-team-archive-keyring.gpg] http://pkg.samba.org/packages/debian {{ ansible_lsb.codename | default('bookworm') }} samba-422"
# repo: "deb [signed-by=/usr/share/keyrings/samba-team-archive-keyring.gpg] http://download.samba.org/pub/samba/packages/debian {{ ansible_distribution_release }} samba-422"
# state: present
# filename: samba-team
# when: "'4.22.4' in samba_version.stdout"
# - name: Add Samba Team Debian GPG key (only if upgrade is needed)
# ansible.builtin.apt_key:
# url: https://pkg.samba.org/keys/samba-pubkey.asc
# state: present
# when: "'4.22.4' in samba_version.stdout"
# - name: Add Samba Team Debian repository (only if upgrade is needed)
# ansible.builtin.apt_repository:
# repo: "deb http://pkg.samba.org/packages/debian $(lsb_release -cs) samba-422"
# state: present
# filename: samba-team
# when: "'4.22.4' in samba_version.stdout"
# - name: Update APT cache (only if upgrade is needed)
# ansible.builtin.apt:
# update_cache: yes
# when: "'4.22.4' in samba_version.stdout"
# - name: Upgrade Samba packages if version is 4.22.4
# ansible.builtin.apt:
# name:
# - samba
# - samba-dsdb-modules
# - samba-common-bin
# - python3-samba
# state: latest
# when: "'4.22.4' in samba_version.stdout"
# - name: Verify installed Samba version
# ansible.builtin.command: samba --version
# register: samba_version
# changed_when: false
# - name: Display upgraded Samba version
# ansible.builtin.debug:
# msg: "✅ Samba version after upgrade: {{ samba_version.stdout }}"
# - name: Stop Samba services before provisioning
# ansible.builtin.service:
# name: '{{ item }}'
# state: stopped
# ignore_errors: true
# loop:
# - samba-ad-dc
# - smbd
# - nmbd
# - winbind
- name: Disable and stop regular Samba services
ansible.builtin.systemd:
name: "{{ item }}"
enabled: false
state: stopped
enabled: no
ignore_errors: yes
masked: true
loop:
- smbd
- nmbd
- winbind
- name: Unmask and enable Samba AD/DC service (but do not start it)
ansible.builtin.systemd:
name: samba-ad-dc
masked: false
enabled: true
state: stopped
@@ -27,7 +133,7 @@
# - name: Deploy smb.conf
# ansible.builtin.template:
# src: smb.conf.j2
# dest: "{{ samba_conf_path }}"
# dest: '{{ samba_conf_path }}'
# owner: root
# group: root
# mode: '0644'

View File

@@ -1,14 +1,23 @@
---
- name: Extract krb5.conf path from provision output
# The samba-tool output usually contains the path on a specific line.
# We extract the path using regex and the 'search' filter.
- name: Extract absolute krb5.conf path from provision output
ansible.builtin.set_fact:
krb5_conf_path: "{{ samba_provision_output.stdout | regex_search('krb5.conf file is located at (.*)', '\\1') | first }}"
krb5_conf_path: >-
{{ (
samba_provision_output.stdout
| regex_findall("(/[^\\s,'\"]+krb5\\.conf)")
| default([])
| first
| default('')
) | replace(\"'\", '') | replace('\"', '') | replace(',', '') | trim }}
when: samba_provision_output.stdout is defined
- name: print krb5.conf path
ansible.builtin.debug:
msg: "Krb5.conf path: {{ krb5_conf_path }}"
- name: Copy krb5.conf to /etc/krb5.conf
ansible.builtin.copy:
src: "{{ krb5_conf_path }}"
src: '{{ krb5_conf_path }}'
dest: /etc/krb5.conf
owner: root
group: root

View File

@@ -1,5 +1,4 @@
---
- name: Prepare for Samba AD DC
include_tasks: preparing.yml

View File

@@ -17,7 +17,7 @@
- name: Set the path variable, failing if not found
ansible.builtin.set_fact:
ntp_signd_path: "{{ find_ntp_signd.files[0].path }}"
ntp_signd_path: '{{ find_ntp_signd.files[0].path }}'
# This conditional logic ensures the playbook stops if the directory is missing,
# or if more than one directory named 'ntp_signd' is found (which is unlikely/undesirable).
when: find_ntp_signd.matched == 1
@@ -25,7 +25,7 @@
- name: Verify permissions on the detected 'ntp_signd' directory
ansible.builtin.stat:
path: "{{ ntp_signd_path }}"
path: '{{ ntp_signd_path }}'
register: ntp_signd_stats
- name: Assert that the permissions allow read access
@@ -34,8 +34,8 @@
# Check if the directory exists and has permissions that grant read/execute to 'other' (r-x)
- ntp_signd_stats.stat.exists
- ntp_signd_stats.stat.mode is search('[rwx-]{2}[rwx-]{2}[4-7]')
fail_msg: "FATAL: The detected ntp_signd directory ({{ ntp_signd_path }}) does not have necessary read permissions (mode: {{ ntp_signd_stats.stat.mode }})."
success_msg: "SUCCESS: Permissions on {{ ntp_signd_path }} are correctly configured."
fail_msg: 'FATAL: The detected ntp_signd directory ({{ ntp_signd_path }}) does not have necessary read permissions (mode: {{ ntp_signd_stats.stat.mode }}).'
success_msg: 'SUCCESS: Permissions on {{ ntp_signd_path }} are correctly configured.'
- name: Configure ntp.conf for Active Directory Domain Controller (AD DC)
ansible.builtin.template:

View File

@@ -48,7 +48,7 @@
- name: Set /etc/hosts entry for Samba AD DC
ansible.builtin.lineinfile:
path: /etc/hosts
line: "{{ addc_ansible_host }} {{ addc_hostname | upper }}.{{ addc_tld | lower }} {{ addc_hostname | upper }}"
line: '{{ addc_ansible_host }} {{ addc_hostname | upper }}.{{ addc_tld | lower }} {{ addc_hostname | upper }}'
state: present
create: yes
@@ -68,22 +68,22 @@
- name: Remove smb.conf using discovered path
ansible.builtin.file:
path: "{{ smb_conf_path.stdout }}"
path: '{{ smb_conf_path.stdout }}'
state: absent
# Remove all Samba database files, such as *.tdb and *.ldb files
- name: Get Samba directories from smbd -b
ansible.builtin.shell: smbd -b | egrep "LOCKDIR|STATEDIR|CACHEDIR|PRIVATE_DIR" | awk '{print $2}'
ansible.builtin.shell: smbd -b | egrep 'LOCKDIR|STATEDIR|CACHEDIR|PRIVATE_DIR' | awk '{print $2}'
register: samba_dirs
changed_when: false
failed_when: samba_dirs.rc != 0
- name: Filter existing directories
ansible.builtin.find:
paths: "{{ item }}"
paths: '{{ item }}'
file_type: directory
recurse: no
loop: "{{ samba_dirs.stdout_lines }}"
loop: '{{ samba_dirs.stdout_lines }}'
register: existing_dirs
- name: Collect existing directories
@@ -92,21 +92,21 @@
- name: Find *.tdb and *.ldb files
ansible.builtin.find:
paths: "{{ item }}"
patterns: "*.tdb,*.ldb"
paths: '{{ item }}'
patterns: '*.tdb,*.ldb'
recurse: yes
use_regex: false
loop: "{{ valid_dirs }}"
loop: '{{ valid_dirs }}'
register: db_files
- name: Remove found tdb/ldb files
ansible.builtin.file:
path: "{{ item.path }}"
path: '{{ item.path }}'
state: absent
loop: "{{ db_files.results | map(attribute='files') | sum(start=[]) }}"
when: item.path is defined
- name: Report removed files
ansible.builtin.debug:
msg: "Removed: {{ item.path }}"
msg: 'Removed: {{ item.path }}'
loop: "{{ db_files.results | map(attribute='files') | sum(start=[]) }}"

View File

@@ -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
@@ -12,12 +22,15 @@
--domain={{ samba_domain_info.domain }}
--server-role={{ samba_domain_info.server_role }}
--dns-backend={{ samba_domain_info.dns_backend }}
--adminpass={{ samba_domain_info.adminpass }}
--option="interfaces={{ samba_domain_info.interfaces }}"
--option="bind interfaces only={{ samba_domain_info.bind_interfaces_only }}"
--adminpass='{{ addc_admin_password }}'
--option='interfaces={{ samba_domain_info.interfaces }}'
--option='bind interfaces only={{ samba_domain_info.bind_interfaces_only }}'
when: not samba_provisioned.stat.exists
register: samba_provision_output
changed_when: samba_provision_output.rc == 0
no_log: false # You may toggle this if password should be hidden
- name: print provision output
ansible.builtin.debug:
msg: "Provisioning output: {{samba_provision_output}}"

View File

@@ -8,10 +8,10 @@
- name: Create the reverse DNS zone {{ addc_reverse_zone_name }}
community.general.expect:
# Note: The 'expect' module is in the 'community.general' collection
command: "samba-tool dns zonecreate {{ addc_ansible_host }} {{ addc_reverse_zone_name }} -U Administrator"
command: 'samba-tool dns zonecreate {{ addc_ansible_host }} {{ addc_reverse_zone_name }} -U Administrator'
responses:
# Use the '(?i)' flag for case-insensitive matching of the prompt.
'(?i)password for.*:': "{{ addc_admin_password }}"
'(?i)password for.*:': '{{ addc_admin_password }}'
no_log: true # Highly recommended to prevent the password from appearing in logs
- name: Create the PTR (reverse) DNS record
@@ -25,7 +25,7 @@
-U Administrator
responses:
# Expects the standard Samba password prompt
'(?i)password for.*:': "{{ addc_admin_password }}"
'(?i)password for.*:': '{{ addc_admin_password }}'
no_log: true # Hide sensitive data from logs
@@ -36,7 +36,7 @@
- name: Report the results of the smbclient verification
ansible.builtin.debug:
msg: "Samba Shares found: {{ smbclient_output.stdout }}"
msg: 'Samba Shares found: {{ smbclient_output.stdout }}'
- name: Verify Samba AD authentication by accessing the netlogon share
community.general.expect:
@@ -45,7 +45,7 @@
command: smbclient //localhost/netlogon -UAdministrator -c 'ls'
responses:
# Use the (?i) flag for case-insensitive matching of the prompt.
'(?i)password:': "{{ addc_admin_password }}"
'(?i)password:': '{{ addc_admin_password }}'
no_log: true # CRITICAL: Prevents the password from being logged
register: auth_verification
changed_when: false # This is a verification/check, not a change
@@ -77,7 +77,7 @@
ansible.builtin.command: host -t A {{ addc_hostname | lower }}.{{ addc_auth_domain | lower }}.
register: a_record_check
changed_when: false
failed_when: "{{ addc_ansible_host }} not in a_record_check.stdout"
failed_when: '{{ addc_ansible_host }} not in a_record_check.stdout'
- name: Debug - Show A Record check result
ansible.builtin.debug:
@@ -102,14 +102,14 @@
responses:
# Expects the standard Kerberos password prompt
# The (?i) flag ensures case-insensitive matching.
'(?i)password for administrator.*:': "{{ addc_admin_password }}"
'(?i)password for administrator.*:': '{{ addc_admin_password }}'
no_log: true # CRITICAL: Prevents the password from being logged
register: kinit_check
changed_when: false # This is a verification/check, not a change
- name: Debug - Show kinit verification result (should be empty on success)
ansible.builtin.debug:
msg: "Kerberos kinit verification successful. Output: {{ kinit_check.stdout }}"
msg: 'Kerberos kinit verification successful. Output: {{ kinit_check.stdout }}'
- name: Optional - Show the cached Kerberos ticket
ansible.builtin.command: klist
@@ -136,11 +136,11 @@
# - name: Assert that the domain is provisioned
# assert:
# that:
# - "'Netbios name' in domain_info.stdout"
# - "'Server Role: ACTIVE DIRECTORY DOMAIN CONTROLLER' in domain_info.stdout"
# - ''Netbios name' in domain_info.stdout'
# - ''Server Role: ACTIVE DIRECTORY DOMAIN CONTROLLER' in domain_info.stdout'
# - name: Attempt kinit with administrator
# command: echo "{{ samba_admin_password }}" | kinit administrator@{{ samba_realm }}
# command: echo '{{ samba_admin_password }}' | kinit administrator@{{ samba_realm }}
# register: kinit_result
# changed_when: false
# failed_when: kinit_result.rc != 0
@@ -153,7 +153,7 @@
# - name: Assert Kerberos ticket exists
# assert:
# that:
# - "'krbtgt/{{ samba_realm }}@{{ samba_realm }}' in klist_result.stdout"
# - ''krbtgt/{{ samba_realm }}@{{ samba_realm }}' in klist_result.stdout'
# - name: Check Samba AD DC service status
# service_facts:
@@ -161,5 +161,5 @@
# - name: Assert samba-ad-dc service is active
# assert:
# that:
# - "'samba-ad-dc' in ansible_facts.services"
# - ''samba-ad-dc' in ansible_facts.services'
# - ansible_facts.services['samba-ad-dc'].state == 'running'