keytab: Try make code cleaner
This commit is contained in:
parent
872115a9a9
commit
981b954682
2 changed files with 38 additions and 41 deletions
1
roles/keytab/files/empty.keytab
Normal file
1
roles/keytab/files/empty.keytab
Normal file
|
@ -0,0 +1 @@
|
||||||
|
|
|
@ -5,50 +5,46 @@
|
||||||
register: keytab_status
|
register: keytab_status
|
||||||
check_mode: false
|
check_mode: false
|
||||||
|
|
||||||
- name: Create temporary file
|
- name: Create keytab
|
||||||
ansible.builtin.tempfile:
|
block:
|
||||||
state: file
|
- name: Create temporary file
|
||||||
register: tempfile
|
ansible.builtin.tempfile:
|
||||||
when: not keytab_status.stat.exists
|
state: file
|
||||||
|
register: tempfile
|
||||||
|
|
||||||
- name: Initialize keytab
|
- name: Initialize keytab
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
dest: tempfile.path
|
dest: "{{ tempfile.path }}"
|
||||||
content: "\\0005\\0002\\c"
|
src: empty.keytab
|
||||||
mode: "0600"
|
mode: "0600"
|
||||||
owner: root
|
owner: root
|
||||||
group: "{{ ansible_wheel }}"
|
group: "{{ ansible_wheel }}"
|
||||||
when: not keytab_status.stat.exists
|
|
||||||
|
|
||||||
- name: Add principal to keytab
|
- name: Add principal to keytab
|
||||||
ansible.builtin.command:
|
ansible.builtin.command:
|
||||||
argv:
|
argv:
|
||||||
- kadmin.local
|
- kadmin.local
|
||||||
- -x
|
- -x
|
||||||
- host=ldaps://ldap01.foo.sh
|
- host=ldaps://ldap01.foo.sh
|
||||||
- ktadd
|
- ktadd
|
||||||
- -k
|
- -k
|
||||||
- "{{ tempfile.path }}"
|
- "{{ tempfile.path }}"
|
||||||
- "{{ item }}"
|
- "{{ item }}"
|
||||||
with_items: "{{ keytab_principals }}"
|
with_items: "{{ keytab_principals }}"
|
||||||
|
|
||||||
|
- name: Get keytab
|
||||||
|
ansible.builtin.command:
|
||||||
|
argv:
|
||||||
|
- base64
|
||||||
|
- "{{ tempfile.path }}"
|
||||||
|
register: keytab_data
|
||||||
|
|
||||||
|
- name: Delete temporary file
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "{{ tempfile.path }}"
|
||||||
|
state: absent
|
||||||
|
when: not keytab_status.stat.exists
|
||||||
delegate_to: ldap01.home.foo.sh
|
delegate_to: ldap01.home.foo.sh
|
||||||
when: not keytab_status.stat.exists
|
|
||||||
|
|
||||||
- name: Get keytab
|
|
||||||
ansible.builtin.command:
|
|
||||||
argv:
|
|
||||||
- base64
|
|
||||||
- "{{ tempfile.path }}"
|
|
||||||
register: keytab_data
|
|
||||||
delegate_to: ldap01.home.foo.sh
|
|
||||||
when: not keytab_status.stat.exists
|
|
||||||
|
|
||||||
- name: Delete temporary file
|
|
||||||
ansible.builtin.file:
|
|
||||||
path: "{{ tempfile.path }}"
|
|
||||||
state: absent
|
|
||||||
delegate_to: ldap01.home.foo.sh
|
|
||||||
when: not keytab_status.stat.exists
|
|
||||||
|
|
||||||
- name: Deploy keytab file
|
- name: Deploy keytab file
|
||||||
ansible.builtin.shell: >-
|
ansible.builtin.shell: >-
|
||||||
|
|
Loading…
Add table
Reference in a new issue