mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-09-24 19:16:26 +02:00
svc-db-openldap: make LDIF import idempotent, unify container var, and tidy role
- Add handlers/main.yml to load memberof/refint modules and import groups via docker exec - Use OPENLDAP_CONTAINER consistently (replace OPENLDAP_NAME) - Rename tasks/ldifs_creation.yml -> tasks/_ldifs_creation.yml and update includes - Drop default param from get_app_conf calls; add explicit meta: flush_handlers - docker-compose: honor OPENLDAP_NETWORK_EXPOSE_LOCAL | bool; minor formatting - env template: formatting/comments consistency - Remove unused 01_rbac_group.ldif.j2; rename 02_rbac_roles -> 01_rbac_roles and fix filter to LDAP - vars: rename OPENLDAP_NAME -> OPENLDAP_CONTAINER; prune LDIF schema type Conversation: https://chatgpt.com/share/68d1d25d-e788-800f-bfb6-13b1f5bc6121
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
|
||||
- name: "Query available LDAP databases"
|
||||
shell: |
|
||||
docker exec {{ OPENLDAP_NAME }} \
|
||||
docker exec {{ OPENLDAP_CONTAINER }} \
|
||||
ldapsearch -Y EXTERNAL -H ldapi:/// -LLL -b cn=config "(olcDatabase=*)" dn
|
||||
register: ldap_databases
|
||||
|
||||
@@ -27,13 +27,13 @@
|
||||
|
||||
- name: "Generate hash for Database Admin password"
|
||||
shell: |
|
||||
docker exec {{ OPENLDAP_NAME }} \
|
||||
docker exec {{ OPENLDAP_CONTAINER }} \
|
||||
slappasswd -s "{{ LDAP.BIND_CREDENTIAL }}"
|
||||
register: database_admin_pw_hash
|
||||
|
||||
- name: "Reset Database Admin password in LDAP (olcRootPW)"
|
||||
shell: |
|
||||
docker exec -i {{ OPENLDAP_NAME }} ldapmodify -Y EXTERNAL -H ldapi:/// <<EOF
|
||||
docker exec -i {{ OPENLDAP_CONTAINER }} ldapmodify -Y EXTERNAL -H ldapi:/// <<EOF
|
||||
dn: {{ data_backend_dn }}
|
||||
changetype: modify
|
||||
replace: olcRootPW
|
||||
@@ -42,13 +42,13 @@
|
||||
|
||||
- name: "Generate hash for Configuration Admin password"
|
||||
shell: |
|
||||
docker exec {{ OPENLDAP_NAME }} \
|
||||
docker exec {{ OPENLDAP_CONTAINER }} \
|
||||
slappasswd -s "{{ applications | get_app_conf(application_id, 'credentials.administrator_password', True) }}"
|
||||
register: config_admin_pw_hash
|
||||
|
||||
- name: "Reset Configuration Admin password in LDAP (olcRootPW)"
|
||||
shell: |
|
||||
docker exec -i {{ OPENLDAP_NAME }} ldapmodify -Y EXTERNAL -H ldapi:/// <<EOF
|
||||
docker exec -i {{ OPENLDAP_CONTAINER }} ldapmodify -Y EXTERNAL -H ldapi:/// <<EOF
|
||||
dn: {{ config_backend_dn }}
|
||||
changetype: modify
|
||||
replace: olcRootPW
|
||||
|
@@ -38,22 +38,22 @@
|
||||
include_tasks: 01_credentials.yml
|
||||
when:
|
||||
- OPENLDAP_NETWORK_SWITCH_LOCAL | bool
|
||||
- applications | get_app_conf(application_id, 'provisioning.credentials', True)
|
||||
- applications | get_app_conf(application_id, 'provisioning.credentials')
|
||||
|
||||
- name: "create directory {{OPENLDAP_LDIF_PATH_HOST}}{{item}}"
|
||||
- name: "create directory {{ OPENLDAP_LDIF_PATH_HOST }}{{ item }}"
|
||||
file:
|
||||
path: "{{OPENLDAP_LDIF_PATH_HOST}}{{item}}"
|
||||
path: "{{ OPENLDAP_LDIF_PATH_HOST }}{{ item }}"
|
||||
state: directory
|
||||
mode: "0755"
|
||||
loop: "{{OPENLDAP_LDIF_TYPES}}"
|
||||
loop: "{{ OPENLDAP_LDIF_TYPES }}"
|
||||
|
||||
- name: "Import LDIF Configuration"
|
||||
include_tasks: ldifs_creation.yml
|
||||
include_tasks: _ldifs_creation.yml
|
||||
loop:
|
||||
- configuration
|
||||
loop_control:
|
||||
loop_var: folder
|
||||
when: applications | get_app_conf(application_id, 'provisioning.configuration', True)
|
||||
when: applications | get_app_conf(application_id, 'provisioning.configuration')
|
||||
|
||||
- name: flush LDIF handlers
|
||||
meta: flush_handlers
|
||||
@@ -66,20 +66,22 @@
|
||||
|
||||
- name: "Include Schemas (if enabled)"
|
||||
include_tasks: 02_schemas.yml
|
||||
when: applications | get_app_conf(application_id, 'provisioning.schemas', True)
|
||||
when: applications | get_app_conf(application_id, 'provisioning.schemas')
|
||||
|
||||
- name: "Import LDAP Entries (if enabled)"
|
||||
include_tasks: 03_users.yml
|
||||
when: applications | get_app_conf(application_id, 'provisioning.users', True)
|
||||
when: applications | get_app_conf(application_id, 'provisioning.users')
|
||||
|
||||
- name: "Import LDIF Data (if enabled)"
|
||||
include_tasks: ldifs_creation.yml
|
||||
include_tasks: _ldifs_creation.yml
|
||||
loop:
|
||||
- groups
|
||||
loop_control:
|
||||
loop_var: folder
|
||||
when: applications | get_app_conf(application_id, 'provisioning.groups', True)
|
||||
when: applications | get_app_conf(application_id, 'provisioning.groups')
|
||||
|
||||
- meta: flush_handlers
|
||||
|
||||
- name: "Add Objects to all users"
|
||||
include_tasks: 04_update.yml
|
||||
when: applications | get_app_conf(application_id, 'provisioning.update', True)
|
||||
when: applications | get_app_conf(application_id, 'provisioning.update')
|
Reference in New Issue
Block a user