diff --git a/group_vars/all.yml.sample b/group_vars/all.yml.sample index ab26caa9e..df680253e 100644 --- a/group_vars/all.yml.sample +++ b/group_vars/all.yml.sample @@ -704,6 +704,7 @@ dummy: # Choose http or https # For https, you should set dashboard.crt/key and grafana.crt/key #dashboard_protocol: http +#dashboard_url: "{{ ansible_hostname }}" #dashboard_port: 8443 #dashboard_admin_user: admin #dashboard_admin_password: admin diff --git a/group_vars/rhcs.yml.sample b/group_vars/rhcs.yml.sample index 2442a5335..893ec3d5e 100644 --- a/group_vars/rhcs.yml.sample +++ b/group_vars/rhcs.yml.sample @@ -704,6 +704,7 @@ ceph_docker_registry: "registry.access.redhat.com" # Choose http or https # For https, you should set dashboard.crt/key and grafana.crt/key #dashboard_protocol: http +#dashboard_url: "{{ ansible_hostname }}" #dashboard_port: 8443 #dashboard_admin_user: admin #dashboard_admin_password: admin diff --git a/infrastructure-playbooks/dashboard.yml b/infrastructure-playbooks/dashboard.yml index 496311980..dd6c48d6c 100644 --- a/infrastructure-playbooks/dashboard.yml +++ b/infrastructure-playbooks/dashboard.yml @@ -32,7 +32,7 @@ status: "Complete" end: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}" -- hosts: '{{ groups["grafana-server"][0] | default(groups["mgrs"][0]) | default(groups["mons"][0]) | default(omit) }}' +- hosts: "{{ grafana_server_group_name }}" become: true pre_tasks: - name: set ceph grafana install 'In Progress' @@ -67,7 +67,7 @@ status: "Complete" end: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}" -- hosts: '{{ groups["mgrs"][0] | default(groups["mons"][0]) | default(omit) }}' +- hosts: "{{ grafana_server_group_name }}" become: true pre_tasks: - name: set ceph dashboard install 'In Progress' diff --git a/roles/ceph-dashboard/tasks/configure_dashboard.yml b/roles/ceph-dashboard/tasks/configure_dashboard.yml index 63a600899..7e08dca7d 100644 --- a/roles/ceph-dashboard/tasks/configure_dashboard.yml +++ b/roles/ceph-dashboard/tasks/configure_dashboard.yml @@ -90,10 +90,6 @@ delegate_to: "{{ groups[mon_group_name][0] }}" until: ac_result.rc == 0 -- name: set grafana url to grafana instance - set_fact: - dashboard_url: "{{ hostvars[(groups[grafana_server_group_name][0] | default(groups[mgr_group_name][0]) | default(groups[mon_group_name][0]))]['ansible_hostname'] }}" - - name: set grafana url command: "{{ container_exec_cmd }} ceph dashboard set-grafana-api-url {{ dashboard_protocol }}://{{ dashboard_url }}:{{ grafana_port }}/" delegate_to: "{{ groups[mon_group_name][0] }}" diff --git a/roles/ceph-defaults/defaults/main.yml b/roles/ceph-defaults/defaults/main.yml index e72d07271..d350ca394 100644 --- a/roles/ceph-defaults/defaults/main.yml +++ b/roles/ceph-defaults/defaults/main.yml @@ -696,6 +696,7 @@ dashboard_enabled: True # Choose http or https # For https, you should set dashboard.crt/key and grafana.crt/key dashboard_protocol: http +dashboard_url: "{{ ansible_hostname }}" dashboard_port: 8443 dashboard_admin_user: admin dashboard_admin_password: admin diff --git a/roles/ceph-facts/tasks/facts.yml b/roles/ceph-facts/tasks/facts.yml index f787abdc7..bd86a98b2 100644 --- a/roles/ceph-facts/tasks/facts.yml +++ b/roles/ceph-facts/tasks/facts.yml @@ -305,17 +305,17 @@ - name: set grafana_server_addr fact - ipv4 set_fact: - 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 }}" + grafana_server_addr: "{{ hostvars[inventory_hostname]['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) + - groups.get(grafana_server_group_name, []) | length > 0 - ip_version == 'ipv4' - dashboard_enabled | bool - name: set grafana_server_addr fact - ipv6 set_fact: - 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_ipv6_addresses'] | ipaddr(public_network) | last | ipwrap }}" + grafana_server_addr: "{{ hostvars[inventory_hostname]['ansible_all_ipv6_addresses'] | ipaddr(public_network) | last | ipwrap }}" when: - - (groups.get(grafana_server_group_name, []) | length > 0 or groups.get(mgr_group_name, []) | length > 0) + - groups.get(grafana_server_group_name, []) | length > 0 - ip_version == 'ipv6' - dashboard_enabled | bool