The slapd server won't start if the replhosts_sanity can't be resolved to an ip address. This happens, because the fqdn of the hostname behind the provider label is wrapped to the next line.
I configured replication and used a long fqdn (Kubernetes StatefulSet Service) which will be wrapped by the slapd automatically.
+ var_true FALSE
+ '[' FALSE = TRUE ']'
+ '[' FALSE = true ']'
+ '[' FALSE = YES ']'
+ '[' FALSE = yes ']'
+ '[' -e /etc/openldap/slapd.d/docker-openldap-was-started-with-replication ']'
+ set +e
++ grep -o ++ awk -h -F '[//]' '{ print $3 }'
'provider=ldap.*//.*.' '/etc/openldap/slapd.d/cn=config/olcDatabase={-1}frontend.ldif' '/etc/openldap/slapd.d/cn=config/olcDatabase={0}config.ldif' '/etc/openldap/slapd.d/cn=config/olcDatabase={1}mdb.ldif' '/etc/openldap/slapd.d/cn=config/olcDatabase={2}monitor.ldif'
++ awk -F binddn '{ print $1 }'
++ awk '!a[$0]++'
++ sed 's/ / /g'
++ ++ tr '\n' ' '
awk '!a[$0]++'
+ replhosts_sanity='openldap-0.openldap-headless.startse openldap-1.openldap-headless.startse '
+ '[' '!' -z 'openldap-0.openldap-headless.startse openldap-1.openldap-headless.startse ' ']'
+ for sanity_host in $replhosts_sanity
+ [[ openldap-0.openldap-headless.startse =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]
++ getent hosts openldap-0.openldap-headless.startse
++ awk '{ print $1 }'
+ sanity_ip=
+ '[' -z '' ']'
+ exit 1
[cont-init.d] 10-openldap: exited 1.
olcDbIndex: entryCSN eq
olcDbIndex: entryUUID eq
olcDbIndex: objectClass eq
olcAccess: {0}to attrs=userPassword,shadowLastChange by self =xw by dn="cn=a
dmin,dc=xxxxxxxxx,dc=xx,dc=com" write by anonymous auth by * none
olcAccess: {1}to * by self write by dn="cn=admin,dc=xxxxxxxxx,dc=xx,dc=com"
write by * read
olcAccess: {2}to * by self read by dn="cn=admin,dc=xxxxxxxxx,dc=xx,dc=com" w
rite by dn="cn=reader,dc=xxxxxxxxx,dc=xx,dc=com" read by * none
olcSyncrepl: {0}rid=101 provider=ldap://openldap-0.openldap-headless.startse
ite.svc.cluster.local binddn="cn=admin,dc=xxxxxxxxx,dc=xx,dc=com" bindmetho
d=simple credentials=PASSWORD1 searchbase="dc=xxxxxxxxx,dc=xx,dc=com" type=
refreshAndPersist interval=00:00:00:10 retry="60 +" timeout=1 tls_reqcert=n
ever
olcSyncrepl: {1}rid=102 provider=ldap://openldap-1.openldap-headless.startse
ite.svc.cluster.local binddn="cn=admin,dc=xxxxxxxxx,dc=xx,dc=com" bindmetho
d=simple credentials=PASSWORD1 searchbase="dc=xxxxxxxxx,dc=xx,dc=com" type=
refreshAndPersist interval=00:00:00:10 retry="60 +" timeout=1 tls_reqcert=n
ever
olcMirrorMode: TRUE
entryCSN: 20210507110835.079923Z#000000#002#000000
modifiersName: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth
The lines have to be joined before trying to grep the content or the regex has to be extended so that multiple lines are joined correctly.
I found the following as a description how openldap actually splits the lines automatically:
OpenLDAP deletes the first white space of a continuation line and joins all lines.