role slapd: can load additionnal schema and load arbitrary ldif files to be put in template directory

This commit is contained in:
2019-07-17 18:34:15 +02:00
parent 39a49698bc
commit 2ee476a4ef
6 changed files with 91 additions and 12 deletions

View File

@@ -25,14 +25,11 @@
olcRootDN: "{{ ldap_admin_dn }}"
olcRootPW: "{{ ldap_admin_password }}"
- name: check if schema cosine is loaded
stat:
path: /etc/openldap/slapd.d/cn=config/cn=schema/cn={1}cosine.ldif
register: result
- name: import mandatory schema
command: "ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/cosine.ldif"
when: result.stat.exists==False
- name: load additionnal schema
include_tasks: import_ldap_schema.yml
loop: "{{ ldap_schemas }}"
loop_control:
loop_var: schema
- name: create suffix
ldap_entry:
@@ -54,4 +51,31 @@
copy:
dest: /root/.ldap.secrets
mode: 0600
content: "{{ ldap_admin_password }}"
content: "{{ ldap_admin_password }}"
- name: import data
block:
- name: create initial directory
file:
path: /root/Ldif
state: directory
mode: 0700
- name: send ldif files
template:
src: "{{ item }}"
dest: /root/Ldif/
mode: 0600
with_fileglob: "templates/[0-9]*.ldif"
- name: get list of ldif files
find:
paths: /root/Ldif
patterns: "*.ldif"
file_type: file
register: ldif_list
- name: import ldif files
command: "ldapadd -y /root/.ldap.secrets -xD {{ ldap_admin_dn }} -f {{ item .path}}"
with_items: "{{ ldif_list.files }}"
when: import_data == true