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 }}'