2025-09-30 17:40:18 +02:00
|
|
|
---
|
2025-11-05 21:37:57 +01:00
|
|
|
- name: Extract absolute krb5.conf path from provision output
|
2025-10-19 22:25:19 +02:00
|
|
|
ansible.builtin.set_fact:
|
2025-11-05 21:01:14 +01:00
|
|
|
krb5_conf_path: >-
|
2025-11-06 06:18:18 +01:00
|
|
|
{{
|
|
|
|
|
(
|
2025-11-06 06:13:41 +01:00
|
|
|
samba_provision_output.stdout
|
2025-11-06 06:37:23 +01:00
|
|
|
| regex_findall('(/[^\\s,"'']*/private/krb5\\.conf)')
|
2025-11-06 06:18:18 +01:00
|
|
|
| list
|
2025-11-05 22:37:19 +01:00
|
|
|
| default([])
|
2025-11-06 06:18:18 +01:00
|
|
|
)
|
|
|
|
|
| first
|
2025-11-06 17:13:16 +01:00
|
|
|
| default('/var/lib/samba/private/krb5.conf')
|
2025-11-06 06:18:18 +01:00
|
|
|
| trim
|
|
|
|
|
}}
|
2025-10-19 22:25:19 +02:00
|
|
|
when: samba_provision_output.stdout is defined
|
2025-11-06 17:13:54 +01:00
|
|
|
# the regex doesnt actually work
|
2025-11-06 06:30:35 +01:00
|
|
|
|
|
|
|
|
- name: Show extracted krb5.conf path
|
2025-11-05 21:46:42 +01:00
|
|
|
ansible.builtin.debug:
|
2025-11-06 06:30:35 +01:00
|
|
|
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 != ''
|
2025-11-05 21:46:42 +01:00
|
|
|
|
2025-11-06 06:30:35 +01:00
|
|
|
- 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)
|
2025-11-06 06:37:23 +01:00
|
|
|
|
2025-10-19 22:25:19 +02:00
|
|
|
- name: Copy krb5.conf to /etc/krb5.conf
|
|
|
|
|
ansible.builtin.copy:
|
2025-11-04 19:22:07 +01:00
|
|
|
src: '{{ krb5_conf_path }}'
|
2025-09-30 17:40:18 +02:00
|
|
|
dest: /etc/krb5.conf
|
|
|
|
|
owner: root
|
|
|
|
|
group: root
|
|
|
|
|
mode: '0644'
|
2025-10-19 22:25:19 +02:00
|
|
|
# Only run this if the provision was successful (changed)
|
|
|
|
|
when: samba_provision_output.changed
|