I use the following ansible task to set up an MDB database for OpenLDAP:
- name: set up MDB database
shell: ldapadd -Y EXTERNAL -H ldapi:/// -f {{tmp_dir}}/mdb.ldif
However, once the DB has been setup, if I run the playbook again, I get the error:
<olcSuffix> namingContext "dc=test,dc=cluster" already served by a preceding mdb database
I obviously need to add a when
condition, so that the DB is only set up, if it does not already exist. However, I don't know what to test for. Should I add a custom fact based on, say, ldapsearch
, or is there a better way?