refactor ♻️: 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, removing unnecessary quotes and commas.
This commit is contained in:
2025-11-06 06:18:18 +01:00
parent 89e5606a4a
commit 2b97e9b61b

View File

@@ -2,13 +2,18 @@
- name: Extract absolute krb5.conf path from provision output
ansible.builtin.set_fact:
krb5_conf_path: >-
{{ (
{{
(
samba_provision_output.stdout
| regex_findall("(/[^\\s,'\"]+krb5\\.conf)")
| regex_findall('(/[^\\s,"\']*krb5\\.conf)')
| map('regex_replace', "['\",]", '') # remove quotes and commas from matches
| list
| default([])
| first
| default('')
) | replace(\"'\", '') | replace('\"', '') | replace(',', '') | trim }}
)
| first
| default('')
| trim
}}
when: samba_provision_output.stdout is defined
- name: print krb5.conf path