ansible/roles/kerberos/keytab/tasks/main.yml
Timo Makinen 25417ed9eb kerberos/keytab: No need to check if spn exists
Running ktadd will fail anyway if no principal is found from server.
2021-03-11 05:12:47 +00:00

31 lines
948 B
YAML

---
- name: check if keytab exists
stat:
path: "{{ keytab }}"
register: keytab_status
check_mode: false
- block:
- block:
- name: "add principal to keytab"
command: "kadmin.local ktadd -k /tmp/{{ inventory_hostname }}.kt \
{{ item }}"
with_items: "{{ principals }}"
- name: get keytab
command: "base64 /tmp/{{ inventory_hostname }}.kt"
register: keytab_data
- name: delete temporary file
file:
path: "/tmp/{{ inventory_hostname }}.kt"
state: absent
delegate_to: ldap01.home.foo.sh
- name: deploy keytab file
shell: "umask 077 && echo '{{ keytab_data.stdout }}' | base64 -d > {{keytab }}"
when: not keytab_status.stat.exists
- name: check keytab permissions
file:
path: "{{ keytab }}"
mode: "{% if group == ansible_wheel %}0600{% else %}0640{% endif %}"
owner: root
group: "{{ group }}"