slapd: can take a list of ldif file to be injected as a list variable
This commit is contained in:
@@ -33,6 +33,8 @@ defined in vars/main.yml and vars/CentOS.yml
|
|||||||
* ldap_ssl_cert_path - {{ ldap_ssl_dir }}/{{ ansible_fqdn }}_fullchain.pem
|
* ldap_ssl_cert_path - {{ ldap_ssl_dir }}/{{ ansible_fqdn }}_fullchain.pem
|
||||||
* ldap_ssl_cacert_path - {{ ldap_ssl_dir }}/{{ ansible_fqdn }}_fullchain.pem
|
* ldap_ssl_cacert_path - {{ ldap_ssl_dir }}/{{ ansible_fqdn }}_fullchain.pem
|
||||||
* ldap_ssl_key_path - {{ ldap_ssl_dir }}/{{ ansible_fqdn }}_privkey.pem
|
* ldap_ssl_key_path - {{ ldap_ssl_dir }}/{{ ansible_fqdn }}_privkey.pem
|
||||||
|
* ldap_ldif_files - optional list of ldif files to send to server and inject.
|
||||||
|
Will be templated. need absolute path
|
||||||
|
|
||||||
|
|
||||||
Dependencies
|
Dependencies
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
- name: debug
|
|
||||||
debug:
|
|
||||||
msg: "schema {{ schema }}"
|
|
||||||
|
|
||||||
- name: check if schema is loaded
|
- name: check if schema is loaded
|
||||||
command: "ldapsearch -LLL -Y EXTERNAL -H ldapi:/// -b cn=schema,cn=config dn"
|
command: "ldapsearch -LLL -Y EXTERNAL -H ldapi:/// -b cn=schema,cn=config dn"
|
||||||
register: ldap_schema_list
|
register: ldap_schema_list
|
||||||
|
changed_when
|
||||||
|
|
||||||
- name: import additional schemas
|
- name: import additional schemas
|
||||||
command: "ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/{{ schema }}.ldif"
|
command: "ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/{{ schema }}.ldif"
|
||||||
|
|||||||
9
tasks/inject_ldif.yml
Normal file
9
tasks/inject_ldif.yml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
- name: copy ldif files
|
||||||
|
copy:
|
||||||
|
src: "{{ ldap_ldif_dir }}/{{ ldif }}"
|
||||||
|
dest: "/root/Ldif/{{ ldif }}"
|
||||||
|
|
||||||
|
- name: import additional schemas
|
||||||
|
command: "ldapadd -s /root/.ldap.secret -D {{ ldap_admin_dn }} -x /root/Ldif/{{ ldif }} -c"
|
||||||
|
ignore_error: true
|
||||||
|
|
||||||
@@ -62,12 +62,13 @@
|
|||||||
state: directory
|
state: directory
|
||||||
mode: 0700
|
mode: 0700
|
||||||
|
|
||||||
|
block:
|
||||||
- name: send ldif files
|
- name: send ldif files
|
||||||
template:
|
template:
|
||||||
src: "{{ item }}"
|
src: "{{ item }}"
|
||||||
dest: /root/Ldif/
|
dest: /root/Ldif/
|
||||||
mode: 0600
|
mode: 0600
|
||||||
with_fileglob: "templates/[0-9]*.ldif"
|
loop: "{{ ldap_ldif_files }}"
|
||||||
|
|
||||||
- name: get list of ldif files
|
- name: get list of ldif files
|
||||||
find:
|
find:
|
||||||
@@ -77,9 +78,10 @@
|
|||||||
register: ldif_list
|
register: ldif_list
|
||||||
|
|
||||||
- name: import ldif files
|
- name: import ldif files
|
||||||
command: "ldapadd -y /root/.ldap.secrets -xD {{ ldap_admin_dn }} -f {{ item .path}}"
|
command: "ldapadd -y -c /root/.ldap.secrets -xD {{ ldap_admin_dn }} -f {{ item .path}}"
|
||||||
with_items: "{{ ldif_list.files }}"
|
with_items: "{{ ldif_list.files }}"
|
||||||
when: import_data == true
|
ignore_errors: true
|
||||||
|
when: ldap_ldif_files is defined
|
||||||
|
|
||||||
- name: configure replication provider
|
- name: configure replication provider
|
||||||
include_tasks: replication_provider.yml
|
include_tasks: replication_provider.yml
|
||||||
@@ -118,9 +120,14 @@
|
|||||||
- name: send ldif file
|
- name: send ldif file
|
||||||
template:
|
template:
|
||||||
src: ssl.ldif
|
src: ssl.ldif
|
||||||
dest: /root/Ldif/
|
dest: /root/
|
||||||
|
|
||||||
- name: import ldif
|
- name: import ldif
|
||||||
command: ldapmodify -c -Y EXTERNAL -H ldapi:/// -f /root/Ldif/ssl.ldif
|
command: ldapmodify -c -Y EXTERNAL -H ldapi:/// -f /root/ssl.ldif
|
||||||
|
|
||||||
|
- name: remove ldif
|
||||||
|
file:
|
||||||
|
path: /root/ssl.ldif
|
||||||
|
state: absent
|
||||||
when: ldap_have_ssl
|
when: ldap_have_ssl
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user