From d3126d4e6257c3ff3e116d207b70bbbd2137ea2e Mon Sep 17 00:00:00 2001 From: prameswar Date: Tue, 25 Oct 2016 22:50:09 +0530 Subject: [PATCH] grafana added to haproxy to listen on VIP Closes-bug: #1636579 Change-Id: I5628196885bddebab84abb71c89753582123418c (cherry picked from commit c1d80d3410a5f719f6b56f827158d96e2c9b793b) --- ansible/group_vars/all.yml | 2 ++ .../roles/grafana/templates/grafana.ini.j2 | 2 +- .../roles/haproxy/templates/haproxy.cfg.j2 | 20 +++++++++++++++++++ ansible/roles/prechecks/tasks/port_checks.yml | 16 +++++++++++++++ 4 files changed, 39 insertions(+), 1 deletion(-) diff --git a/ansible/group_vars/all.yml b/ansible/group_vars/all.yml index 07aebcb77a..0aff5cc586 100644 --- a/ansible/group_vars/all.yml +++ b/ansible/group_vars/all.yml @@ -200,6 +200,8 @@ etcd_peer_port: "2380" kuryr_port: "23750" +grafana_server_port: "3000" + public_protocol: "{{ 'https' if kolla_enable_tls_external | bool else 'http' }}" internal_protocol: "http" admin_protocol: "http" diff --git a/ansible/roles/grafana/templates/grafana.ini.j2 b/ansible/roles/grafana/templates/grafana.ini.j2 index b7f10f638c..6128a48d19 100644 --- a/ansible/roles/grafana/templates/grafana.ini.j2 +++ b/ansible/roles/grafana/templates/grafana.ini.j2 @@ -6,7 +6,7 @@ plugins = /var/lib/grafana/plugins [server] protocol = http http_addr = {{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['address'] }} -http_port = 3000 +http_port = {{ grafana_server_port }} router_logging = true diff --git a/ansible/roles/haproxy/templates/haproxy.cfg.j2 b/ansible/roles/haproxy/templates/haproxy.cfg.j2 index ae8526ee05..d760e75ac0 100644 --- a/ansible/roles/haproxy/templates/haproxy.cfg.j2 +++ b/ansible/roles/haproxy/templates/haproxy.cfg.j2 @@ -289,6 +289,26 @@ listen heat_api_cfn_external {% endif %} {% endif %} +{% if enable_grafana | bool %} +listen grafana_server + bind {{ kolla_internal_vip_address }}:{{ grafana_server_port }} + http-request del-header X-Forwarded-Proto + http-request set-header X-Forwarded-Proto https if { ssl_fc } +{% for host in groups['grafana'] %} + server {{ hostvars[host]['ansible_hostname'] }} {{ hostvars[host]['ansible_' + hostvars[host]['api_interface']]['ipv4']['address'] }}:{{ grafana_server_port }} check inter 2000 rise 2 fall 5 +{% endfor %} +{% if haproxy_enable_external_vip | bool %} + +listen grafana_server_external + bind {{ kolla_external_vip_address }}:{{ grafana_server_port }} {{ tls_bind_info }} + http-request del-header X-Forwarded-Proto + http-request set-header X-Forwarded-Proto https if { ssl_fc } +{% for host in groups['grafana'] %} + server {{ hostvars[host]['ansible_hostname'] }} {{ hostvars[host]['ansible_' + hostvars[host]['api_interface']]['ipv4']['address'] }}:{{ grafana_server_port }} check inter 2000 rise 2 fall 5 +{% endfor %} +{% endif %} +{% endif %} + {% if enable_ironic | bool %} listen ironic_api bind {{ kolla_internal_vip_address }}:{{ ironic_api_port }} diff --git a/ansible/roles/prechecks/tasks/port_checks.yml b/ansible/roles/prechecks/tasks/port_checks.yml index c0f2bd88f6..ccc6e11cbc 100644 --- a/ansible/roles/prechecks/tasks/port_checks.yml +++ b/ansible/roles/prechecks/tasks/port_checks.yml @@ -537,6 +537,22 @@ state: stopped when: inventory_hostname in groups['haproxy'] +- name: Checking free port for Grafana server + wait_for: + host: "{{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['address'] }}" + port: "{{ grafana_server_port }}" + connect_timeout: 1 + state: stopped + when: inventory_hostname in groups['grafana'] + +- name: Checking free port for Grafana server HAProxy + wait_for: + host: "{{ kolla_internal_vip_address }}" + port: "{{ grafana_server_port }}" + connect_timeout: 1 + state: stopped + when: inventory_hostname in groups['haproxy'] + - name: Checking free port for Senlin API wait_for: host: "{{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['address'] }}"