From b9c49227bbb8dd55ba3cbefec52fd68a4b47583b Mon Sep 17 00:00:00 2001 From: Guillaume Abrioux Date: Mon, 24 Jun 2019 22:30:23 +0200 Subject: [PATCH] facts: fix bug in grafana_server_addr fact setting If no grafana-server group is defined while an mgr group is, that task will fail because `hostvars[groups[grafana_server_group_name][0]` can't return anything since `groups['grafana-server']` will be a non existing key. Signed-off-by: Guillaume Abrioux (cherry picked from commit 366b309c12adfcef7dba3548ad3f05000148e867) --- roles/ceph-facts/tasks/facts.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/roles/ceph-facts/tasks/facts.yml b/roles/ceph-facts/tasks/facts.yml index 987c11181..e76b915d8 100644 --- a/roles/ceph-facts/tasks/facts.yml +++ b/roles/ceph-facts/tasks/facts.yml @@ -305,5 +305,7 @@ - name: set grafana_server_addr fact set_fact: - grafana_server_addr: "{{ (hostvars[groups[grafana_server_group_name][0] | default(groups[mgr_group_name][0])])['ansible_all_ipv4_addresses'] | ipaddr(public_network) | first }}" - when: groups.get(grafana_server_group_name, []) | length > 0 or groups.get(mgr_group_name, []) | length > 0 + grafana_server_addr: "{{ (hostvars[groups[grafana_server_group_name][0] if groups.get(grafana_server_group_name, []) | length > 0 else groups[mgr_group_name][0]])['ansible_all_ipv4_addresses'] | ipaddr(public_network) | first }}" + when: + - (groups.get(grafana_server_group_name, []) | length > 0 or groups.get(mgr_group_name, []) | length > 0) + - dashboard_enabled | bool