Adding ability to set timeout for vrrp scripts

  Currently, there is no way to set timeout, at
  one of the customer envs, we have faced an issue,
  where haproxy check script, was hanging  indefinitely,
  due to memory issues. Timeout option, greatly helped
  and mitigated this problem for us.

Change-Id: I0aebd16086545e6b770fe297a8bca227974b0065
diff --git a/README.rst b/README.rst
index 93831e2..f7c4fa1 100644
--- a/README.rst
+++ b/README.rst
@@ -182,6 +182,7 @@
               - available_when_readonly=0
           check_random_exit:
             interval: 10
+            timeout: 5
             content: |
               #!/bin/bash
               exit $(($RANDOM%2))
diff --git a/keepalived/files/keepalived.conf b/keepalived/files/keepalived.conf
index e70334b..190f22a 100644
--- a/keepalived/files/keepalived.conf
+++ b/keepalived/files/keepalived.conf
@@ -11,6 +11,7 @@
   interval {{ script.get('interval', 2) }} # check every Ns
   fall {{ script.get('fall', 2) }}   # require N failures for KO
   rise {{ script.get('rise', 2) }}   # require N successes for OK
+  {% if script.timeout is defined %}timeout {{ script.timeout }} # default timeout for script {% endif %}
   {% if script.weight is defined %}weight {{ script.weight }}{% endif %}
 }
 {%- endfor %}
diff --git a/tests/pillar/keepalived_cluster.sls b/tests/pillar/keepalived_cluster.sls
index 2035d90..e4ae67e 100644
--- a/tests/pillar/keepalived_cluster.sls
+++ b/tests/pillar/keepalived_cluster.sls
@@ -78,6 +78,7 @@
           - haproxy
       check_random_exit:
         interval: 10
+        timeout: 5
         content: |
           #!/bin/bash
           exit $(($RANDOM%2))