Add check for OpenLDAP service availability
Change-Id: I1280972dbafe51ff35394c3b1bd13c7f3e8309dd
Related-prod: PROD-28725 (PROD:28725)
diff --git a/openldap/client.sls b/openldap/client.sls
index c5b028c..aa7b78f 100644
--- a/openldap/client.sls
+++ b/openldap/client.sls
@@ -8,6 +8,17 @@
{%- if client.entry is defined %}
+openldap_wait_for_server_{{ client.server.host }}:
+ cmd.run:
+ - name: '/usr/bin/ldapsearch -x -H ldap://{{ client.server.host }}{% if client.server.port is defined %}:{{ client.server.port }}{% endif %} > /dev/null || [ $? -eq 32 ]] && true'
+ - retry:
+ attempts: 4
+ interval: 5
+ splay: 5
+ {%- if grains.get('noservices', False) %}
+ - onlyif: 'false'
+ {%- endif %}
+
{%- macro process_entry(entry, tree) %}
{%- for name, param in entry.iteritems() %}
{%- set dn = param.get('type', 'cn') + "=" + name + "," + tree %}
@@ -55,6 +66,8 @@
{%- if grains.get('noservices', False) %}
- onlyif: 'false'
{%- endif %}
+ - onfail:
+ - cmd: openldap_wait_for_server_{{ client.server.host }}
{%- if param.entry is defined %}
{{ process_entry(param.entry, param.get('type', 'cn') + "=" + name + "," + tree) }}