Allow states using curl to retry if transient problem.

Change-Id: Ibd9016530083127fc2b6274897a51dfca5d01f7b
diff --git a/README.rst b/README.rst
index 854da83..027b030 100644
--- a/README.rst
+++ b/README.rst
@@ -264,6 +264,16 @@
             database: mydb1
             privilege: all
 
+InfluxDB client state's that uses curl can be forced to retry query if curl call fails:
+
+.. code-block:: yaml
+
+    influxdb:
+      client:
+        enabled: true
+        retry:
+          count: 3
+          delay: 3
 
 Create an continuous queries:
 
diff --git a/influxdb/client.sls b/influxdb/client.sls
index 3015a53..566c516 100644
--- a/influxdb/client.sls
+++ b/influxdb/client.sls
@@ -2,7 +2,7 @@
 
 {%- if client.get('enabled') %}
 
-{%- set curl_command = 'curl' %}
+{%- set curl_command = 'curl --retry {} --retry-delay {}'.format(client.retry.count, client.retry.delay) %}
 {%- if grains.get('noservices') %}
 {%- set curl_command = 'true ' + curl_command %}
 {%- endif %}
diff --git a/influxdb/map.jinja b/influxdb/map.jinja
index 83047b6..80c64a9 100644
--- a/influxdb/map.jinja
+++ b/influxdb/map.jinja
@@ -52,6 +52,10 @@
 
 {%- set client = salt['grains.filter_by']({
     'default': {
+      'retry': {
+          'count': 0,
+          'delay': 0
+      }
     },
 }, merge=salt['pillar.get']('influxdb:client')) %}
 
diff --git a/tests/pillar/client.sls b/tests/pillar/client.sls
index d352076..ca190c0 100644
--- a/tests/pillar/client.sls
+++ b/tests/pillar/client.sls
@@ -1,6 +1,9 @@
 influxdb:
   client:
     enabled: true
+    retry:
+      count: 3
+      delay: 3
     server:
       protocol: http
       host: 127.0.0.1