Fix grains generation
diff --git a/haproxy/meta/sensu.yml b/haproxy/meta/sensu.yml
index 4f373ab..65d5ff7 100644
--- a/haproxy/meta/sensu.yml
+++ b/haproxy/meta/sensu.yml
@@ -1,24 +1,25 @@
{%- from "haproxy/map.jinja" import proxy with context -%}
{%- from "linux/map.jinja" import network with context -%}
{%- if grains.ipv4[0] == '127.0.0.1' %}{% set address = grains.ipv4[1] %}{% else %}{% set address = grains.ipv4[0] %}{% endif %}
-local_haproxy_server_proc:
- command: "PATH=$PATH:/usr/lib64/nagios/plugins:/usr/lib/nagios/plugins check_procs -C haproxy -u haproxy -c 1:1"
- interval: 60
- occurrences: 1
- subscribers:
- - local-haproxy-server
-{# remote_haproxy_proxy_metrics_{{ network.fqdn }}:
- command: "PATH=$PATH:/etc/sensu/plugins haproxy-metrics.rb -c {{ address }} -P 9600 -u admin -p admin"
- interval: 60
- occurrences: 1
- subscribers:
- - remote_network
-remote_haproxy_proxy_status_{{ network.fqdn }}:
- command: "PATH=$PATH:/etc/sensu/plugins check-haproxy.rb -S {{ address }} -P 9600 -u admin -p admin -A"
- interval: 60
- occurrences: 1
- subscribers:
- - remote_network #}
+check:
+ local_haproxy_server_proc:
+ command: "PATH=$PATH:/usr/lib64/nagios/plugins:/usr/lib/nagios/plugins check_procs -C haproxy -u haproxy -c 1:1"
+ interval: 60
+ occurrences: 1
+ subscribers:
+ - local-haproxy-server
+ {# remote_haproxy_proxy_metrics_{{ network.fqdn }}:
+ command: "PATH=$PATH:/etc/sensu/plugins haproxy-metrics.rb -c {{ address }} -P 9600 -u admin -p admin"
+ interval: 60
+ occurrences: 1
+ subscribers:
+ - remote_network
+ remote_haproxy_proxy_status_{{ network.fqdn }}:
+ command: "PATH=$PATH:/etc/sensu/plugins check-haproxy.rb -S {{ address }} -P 9600 -u admin -p admin -A"
+ interval: 60
+ occurrences: 1
+ subscribers:
+ - remote_network #}
{%- for listen_name, listen in proxy.get('listen', {}).iteritems() %}
{%- if listen.get('check', True) %}
{%- if listen.binds.0.address|length == 1 or listen.binds.0.address == '0.0.0.0' %}
@@ -27,19 +28,19 @@
{%- set address = listen.binds.0.address %}
{%- endif %}
{%- if listen.type in ['general-service', 'openstack-service', 'http', 'contrail-api', 'admin'] %}
-remote_haproxy_proxy_http_{{ listen_name }}_{{ network.fqdn }}:
- command: "PATH=$PATH:/usr/lib64/nagios/plugins:/usr/lib/nagios/plugins check_http -H {{ address }} -p {{ listen.binds.0.port }} -w 5 -c 10"
- interval: 60
- occurrences: 1
- subscribers:
- - remote-network
+ remote_haproxy_proxy_http_{{ listen_name }}_{{ network.fqdn }}:
+ command: "PATH=$PATH:/usr/lib64/nagios/plugins:/usr/lib/nagios/plugins check_http -H {{ address }} -p {{ listen.binds.0.port }} -w 5 -c 10"
+ interval: 60
+ occurrences: 1
+ subscribers:
+ - remote-network
{%- else %}
-remote_haproxy_proxy_tcp_{{ listen_name }}_{{ network.fqdn }}:
- command: "PATH=$PATH:/usr/lib64/nagios/plugins:/usr/lib/nagios/plugins check_tcp -H {{ address }} -p {{ listen.binds.0.port }} -w 5 -c 10"
- interval: 60
- occurrences: 1
- subscribers:
- - remote-network
+ remote_haproxy_proxy_tcp_{{ listen_name }}_{{ network.fqdn }}:
+ command: "PATH=$PATH:/usr/lib64/nagios/plugins:/usr/lib/nagios/plugins check_tcp -H {{ address }} -p {{ listen.binds.0.port }} -w 5 -c 10"
+ interval: 60
+ occurrences: 1
+ subscribers:
+ - remote-network
{%- endif %}
{%- endif %}
{%- endfor %}
\ No newline at end of file
diff --git a/haproxy/meta/sphinx.yml b/haproxy/meta/sphinx.yml
index 0b44c6a..2ab947a 100644
--- a/haproxy/meta/sphinx.yml
+++ b/haproxy/meta/sphinx.yml
@@ -1,30 +1,31 @@
{%- from "haproxy/map.jinja" import proxy with context %}
{%- from "linux/map.jinja" import network with context -%}
-name: HAProxy
-description: The Reliable, High Performance TCP/HTTP Load Balancer.
-role:
- proxy:
- name: proxy
- param:
- version:
- value: "{{ salt['cmd.run']('haproxy -v')|replace("HA-Proxy version ", '') }}"
- endpoint:
- {%- for listen_name, listen in proxy.get('listen', {}).iteritems() %}
- {%- if listen.get('check', True) %}
- {%- if listen.binds.0.address in ['0.0.0.0', '*'] %}
- {% if grains.ipv4[0] == '127.0.0.1' %}{% set address = grains.ipv4[1] %}{% else %}{% set address = grains.ipv4[0] %}{% endif %}
- {%- else %}
- {%- set address = listen.binds.0.address %}
- {%- endif %}
- {{ listen_name }}_{{ listen.type }}:
- name: {{ listen_name }}
- type: {{ listen.type }}
- {%- if listen.type in ['general-service', 'openstack-service', 'http', 'contrail-api', 'admin'] %}
- address: "http://{{ listen.binds.0.address }}:{{ listen.binds.0.port }}/"
- protocol: http
+doc:
+ name: HAProxy
+ description: The Reliable, High Performance TCP/HTTP Load Balancer.
+ role:
+ proxy:
+ name: proxy
+ param:
+ version:
+ value: "{{ salt['cmd.run']('haproxy -v')|replace("HA-Proxy version ", '') }}"
+ endpoint:
+ {%- for listen_name, listen in proxy.get('listen', {}).iteritems() %}
+ {%- if listen.get('check', True) %}
+ {%- if listen.binds.0.address in ['0.0.0.0', '*'] %}
+ {% if grains.ipv4[0] == '127.0.0.1' %}{% set address = grains.ipv4[1] %}{% else %}{% set address = grains.ipv4[0] %}{% endif %}
{%- else %}
- address: "{{ listen.binds.0.address }}:{{ listen.binds.0.port }}"
- protocol: tcp
+ {%- set address = listen.binds.0.address %}
{%- endif %}
- {%- endif %}
- {%- endfor %}
\ No newline at end of file
+ {{ listen_name }}_{{ listen.type }}:
+ name: {{ listen_name }}
+ type: {{ listen.type }}
+ {%- if listen.type in ['general-service', 'openstack-service', 'http', 'contrail-api', 'admin'] %}
+ address: "http://{{ listen.binds.0.address }}:{{ listen.binds.0.port }}/"
+ protocol: http
+ {%- else %}
+ address: "{{ listen.binds.0.address }}:{{ listen.binds.0.port }}"
+ protocol: tcp
+ {%- endif %}
+ {%- endif %}
+ {%- endfor %}
\ No newline at end of file