From 7f560f7653a02235d40b1e57bbbc54b057397ed7 Mon Sep 17 00:00:00 2001 From: Jose Date: Thu, 6 Nov 2025 06:30:35 +0100 Subject: [PATCH] =?UTF-8?q?refactor=20=E2=99=BB=EF=B8=8F:=20Improve=20Kerb?= =?UTF-8?q?eros=20configuration=20validation=20and=20extraction?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- tasks/kerberos.yml | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/tasks/kerberos.yml b/tasks/kerberos.yml index 09feaa4..075ed8e 100644 --- a/tasks/kerberos.yml +++ b/tasks/kerberos.yml @@ -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 }}'