mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-09-10 12:27:15 +02:00
Shortened service- to svc-
This commit is contained in:
57
roles/svc-openldap/tasks/reset_admin_passwords.yml
Normal file
57
roles/svc-openldap/tasks/reset_admin_passwords.yml
Normal file
@@ -0,0 +1,57 @@
|
||||
---
|
||||
# Reset both Database and Configuration Admin passwords in LDAP via LDAPI
|
||||
# roles/svc-openldap/tasks/reset_admin_passwords.yml
|
||||
|
||||
- name: "Query available LDAP databases"
|
||||
shell: |
|
||||
docker exec {{ applications[application_id].hostname }} \
|
||||
ldapsearch -Y EXTERNAL -H ldapi:/// -LLL -b cn=config "(olcDatabase=*)" dn
|
||||
register: ldap_databases
|
||||
|
||||
- name: "Determine data backend DN (mdb)"
|
||||
set_fact:
|
||||
data_backend_dn: >-
|
||||
{{ ldap_databases.stdout_lines
|
||||
| select('search','^dn: olcDatabase=.*mdb')
|
||||
| map('regex_replace','^dn: ','')
|
||||
| list
|
||||
| first }}
|
||||
|
||||
- name: "Determine config backend DN"
|
||||
set_fact:
|
||||
config_backend_dn: >-
|
||||
{{ ldap_databases.stdout_lines
|
||||
| select('search','^dn: olcDatabase=\{[0-9]+\}config,cn=config$')
|
||||
| map('regex_replace','^dn: ','')
|
||||
| list
|
||||
| first }}
|
||||
|
||||
- name: "Generate hash for Database Admin password"
|
||||
shell: |
|
||||
docker exec {{ applications[application_id].hostname }} \
|
||||
slappasswd -s "{{ ldap.bind_credential }}"
|
||||
register: database_admin_pw_hash
|
||||
|
||||
- name: "Reset Database Admin password in LDAP (olcRootPW)"
|
||||
shell: |
|
||||
docker exec -i {{ applications[application_id].hostname }} ldapmodify -Y EXTERNAL -H ldapi:/// <<EOF
|
||||
dn: {{ data_backend_dn }}
|
||||
changetype: modify
|
||||
replace: olcRootPW
|
||||
olcRootPW: {{ database_admin_pw_hash.stdout }}
|
||||
EOF
|
||||
|
||||
- name: "Generate hash for Configuration Admin password"
|
||||
shell: |
|
||||
docker exec {{ applications[application_id].hostname }} \
|
||||
slappasswd -s "{{ applications[application_id].credentials.administrator_password }}"
|
||||
register: config_admin_pw_hash
|
||||
|
||||
- name: "Reset Configuration Admin password in LDAP (olcRootPW)"
|
||||
shell: |
|
||||
docker exec -i {{ applications[application_id].hostname }} ldapmodify -Y EXTERNAL -H ldapi:/// <<EOF
|
||||
dn: {{ config_backend_dn }}
|
||||
changetype: modify
|
||||
replace: olcRootPW
|
||||
olcRootPW: {{ config_admin_pw_hash.stdout }}
|
||||
EOF
|
Reference in New Issue
Block a user