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.
This commit is contained in:
2025-11-05 21:01:14 +01:00
parent 38858590f8
commit a48b146e81

View File

@@ -1,9 +1,10 @@
---
- 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 krb5.conf path from provision output (robust)
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_search('generated at ([^\n]+/krb5\\.conf)', '\\1')
| first) | default('', true) }}
when: samba_provision_output.stdout is defined
- name: Copy krb5.conf to /etc/krb5.conf