refactor ♻️: Improve Kerberos configuration validation and extraction

Updated the Ansible playbook to validate the presence of the krb5.conf file, extract its path, and display it in a debug message. Additionally, added checks for the file's existence on disk and its contents to ensure proper Kerberos configuration.
This commit is contained in:
2025-11-06 06:30:35 +01:00
parent 2b97e9b61b
commit 7f560f7653

View File

@@ -5,8 +5,8 @@
{{
(
samba_provision_output.stdout
| regex_findall('(/[^\\s,"\']*krb5\\.conf)')
| map('regex_replace', "['\",]", '') # remove quotes and commas from matches
| regex_findall('(/[^\\s,"\']*/private/krb5\\.conf)')
| map('regex_replace', "['\",]", '')
| list
| default([])
)
@@ -16,10 +16,29 @@
}}
when: samba_provision_output.stdout is defined
- name: print krb5.conf path
ansible.builtin.debug:
msg: "Krb5.conf path: {{ krb5_conf_path }}"
- name: Show extracted krb5.conf path
ansible.builtin.debug:
msg: "Extracted krb5.conf path: {{ krb5_conf_path | default('N/A') }}"
- name: Check if krb5.conf exists on disk
ansible.builtin.stat:
path: "{{ krb5_conf_path }}"
register: krb5_conf_stat
when: krb5_conf_path != ''
- name: Validate krb5.conf presence
ansible.builtin.fail:
msg: "Kerberos configuration file was not found at {{ krb5_conf_path }}. Provision may have failed."
when:
- krb5_conf_path != ''
- not krb5_conf_stat.stat.exists | default(false)
- name: Confirm Kerberos configuration found
ansible.builtin.debug:
msg: "Kerberos configuration verified: {{ krb5_conf_path }}"
when: krb5_conf_stat.stat.exists | default(false)
- name: Copy krb5.conf to /etc/krb5.conf
ansible.builtin.copy:
src: '{{ krb5_conf_path }}'