aboutsummaryrefslogtreecommitdiffstats
path: root/roles/freeipa_keytab/tasks
diff options
context:
space:
mode:
authorStonewall Jackson <stonewall@sacredheartsc.com>2023-02-04 01:23:43 -0500
committerStonewall Jackson <stonewall@sacredheartsc.com>2023-02-04 01:52:13 -0500
commit0261e875679f1bf63c8d689da7fc7e014597885d (patch)
tree3f19cd74a0c1070944f75437f30b098d6ef2ffcb /roles/freeipa_keytab/tasks
downloadselfhosted-0261e875679f1bf63c8d689da7fc7e014597885d.tar.gz
selfhosted-0261e875679f1bf63c8d689da7fc7e014597885d.zip
initial commit
Diffstat (limited to 'roles/freeipa_keytab/tasks')
-rw-r--r--roles/freeipa_keytab/tasks/main.yml37
1 files changed, 37 insertions, 0 deletions
diff --git a/roles/freeipa_keytab/tasks/main.yml b/roles/freeipa_keytab/tasks/main.yml
new file mode 100644
index 0000000..3b09e44
--- /dev/null
+++ b/roles/freeipa_keytab/tasks/main.yml
@@ -0,0 +1,37 @@
+- name: check if principal exists in keytab
+ shell:
+ cmd: >
+ klist -kt {{ keytab_path }}
+ | awk -v p={{ keytab_principal }}@{{ freeipa_realm }}
+ '$4 == p { rc=1 } END { exit !rc }'
+ failed_when: false
+ changed_when: false
+ register: keytab_principal_exists
+
+- name: retrieve keytab
+ shell:
+ cmd: >
+ kinit -fpa -l 1m {{ '-k' if use_system_keytab else ipa_user }} &&
+ ipa-getkeytab -p {{ keytab_principal }} -k {{ keytab_path }} &&
+ kdestroy
+ stdin: '{{ omit if use_system_keytab else ipa_pass }}'
+ when: keytab_principal_exists.rc != 0
+
+- name: set keytab owner
+ file:
+ path: '{{ keytab_path }}'
+ owner: '{{ keytab_owner }}'
+ group: '{{ keytab_group }}'
+ mode: '{{ keytab_mode }}'
+ setype: krb5_keytab_t
+
+- name: set selinux context for keytab
+ sefcontext:
+ target: '{{ keytab_path }}'
+ setype: krb5_keytab_t
+ state: present
+ register: keytab_sefcontext
+
+- name: apply selinux context to keytab
+ command: 'restorecon {{ keytab_path }}'
+ when: keytab_sefcontext.changed