Merge pull request #13 from salt-formulas/pr/extend_check_options

Allow multiple vrrp scripts and weight
diff --git a/README.rst b/README.rst
index 34d67ac..6cbb4bb 100644
--- a/README.rst
+++ b/README.rst
@@ -120,7 +120,11 @@
             - 192.168.10.1
             - 192.168.10.2
             interface: eth0
-            track_script: check_random_exit
+            track_script:
+              check_random_exit:
+                interval: 10
+              check_port:
+                weight: 50
         vrrp_scripts:
           check_haproxy:
             name: check_pidof
@@ -148,6 +152,7 @@
             content: |
               #!/bin/bash
               exit $(($RANDOM%2))
+            weight: 50
 
 
 Read more
diff --git a/keepalived/files/keepalived.conf b/keepalived/files/keepalived.conf
index cc3c3d5..2eec609 100644
--- a/keepalived/files/keepalived.conf
+++ b/keepalived/files/keepalived.conf
@@ -9,9 +9,9 @@
 {%- endif %}
   script "/usr/local/bin/vrrp_script_{{ name }}.sh '{{ "' '".join(script.get('args', [])|sequence) }}'"
   interval {{ script.get('interval', 2) }} # check every Ns
-  weight {{ script.get('weight', 2) }}
   fall {{ script.get('fall', 2) }}   # require N failures for KO
   rise {{ script.get('rise', 2) }}   # require N successes for OK
+  {% if script.weight is defined %}weight {{ script.weight }}{% endif %}
 }
 {%- endfor %}
 
@@ -49,7 +49,13 @@
     }
     {%- if instance.track_script is defined %}
     track_script {
+    {%- if instance.track_script is mapping %}
+    {%- for track_script_name, track_script in instance.get('track_script', {}).iteritems() %}
+      {{ track_script_name }}{% if track_script.weight is defined %} weight {{ track_script.weight }}{% endif %}
+    {%- endfor %}
+    {%- else %}
       {{ instance.track_script }}
+    {%- endif %}
     }
     {%- endif %}
 }
diff --git a/tests/pillar/keepalived_cluster.sls b/tests/pillar/keepalived_cluster.sls
index 73de34c..01833f2 100644
--- a/tests/pillar/keepalived_cluster.sls
+++ b/tests/pillar/keepalived_cluster.sls
@@ -36,7 +36,11 @@
         - 192.168.13.1
         - 192.168.13.2
         interface: eth0
-        track_script: check_mysql_cluster
+        track_script:
+          check_haproxy:
+            interval: 10
+          check_mysql_cluster:
+            weight: 50
       VIP4:
         priority: 100
         virtual_router_id: 14
@@ -45,7 +49,10 @@
         - 192.168.14.1
         - 192.168.14.2
         interface: eth0
-        track_script: check_ssh_port
+        track_script:
+          check_haproxy: None
+          check_ssh_port:
+            weight: 50
     vrrp_scripts:
       check_ssh_port:
         name: check_port