summaryrefslogtreecommitdiffstats
path: root/roles/common-LDAP
diff options
context:
space:
mode:
Diffstat (limited to 'roles/common-LDAP')
-rwxr-xr-xroles/common-LDAP/files/usr/local/sbin/slapcat-all.sh18
-rw-r--r--roles/common-LDAP/tasks/main.yml6
2 files changed, 24 insertions, 0 deletions
diff --git a/roles/common-LDAP/files/usr/local/sbin/slapcat-all.sh b/roles/common-LDAP/files/usr/local/sbin/slapcat-all.sh
new file mode 100755
index 0000000..4e5b5e4
--- /dev/null
+++ b/roles/common-LDAP/files/usr/local/sbin/slapcat-all.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+# Usage: slapcat-all.sh DIR
+# Save all LDAP databases in DIR: DIR/0.ldif, DIR/1.ldif, ...
+
+set -ue
+PATH=/usr/sbin:/sbin:/usr/bin:/bin
+
+target="$1"
+umask 0077
+
+slapcat -n0 -l"$target/0.ldif"
+n=$(grep -Ec '^dn:\s+olcDatabase={[1-9][0-9]*}' "$target/0.ldif")
+
+while [ $n -gt 0 ]; do
+ slapcat -n$n -l"$target/$n.ldif"
+ n=$(( $n - 1 ))
+done
diff --git a/roles/common-LDAP/tasks/main.yml b/roles/common-LDAP/tasks/main.yml
index aa2f721..2eb0dfb 100644
--- a/roles/common-LDAP/tasks/main.yml
+++ b/roles/common-LDAP/tasks/main.yml
@@ -127,3 +127,9 @@
- name: Remove the rootDN under the 'config' database
openldap: name="olcDatabase={0}config,cn=config" delete=olcRootDN,olcRootPW
+
+- name: Copy /usr/local/sbin/slapcat-all.sh
+ copy: src=usr/local/sbin/slapcat-all.sh
+ dest=/usr/local/sbin/slapcat-all.sh
+ owner=root group=root
+ mode=0755