ceph / ceph-ansible

Ansible playbooks to deploy Ceph, the distributed filesystem.
Apache License 2.0
1.69k stars 1.01k forks source link

Provide dashboard with server_addr #5546

Closed amarao closed 3 years ago

amarao commented 4 years ago

Currently ceph-ansible does not set mgr/dashboard/server_addr variable for dashboard.

This cause following code inside ceph mgr:

        self.set_uri('http://{0}:{1}/'.format(
            socket.getfqdn() if server_addr in ['::', '0.0.0.0'] else server_addr,
            server_port
        ))

(src/pybind/mgr/prometheus/module.py)

Additionally, any attempt to access dashboard through bare IP cause redirect to a proper name (socket.getfqdn())

So, if mgr has hostname set to something unreslovable , f.e. to just mon1 without FQDN, dashboard is sending redirect to http://mon1:8443/ (which can not be resolved from operator browser and fails).

I plan to add an additional variable dashboard_server_addr. If it's defined, it will do ceph config set mgr mgr/dashboard/server_addr, and allow operators to set any name they want.

My problem will be solved by setting dashboard_server_addr: {{ ansible_host }} in group_vars for mgrs. Some other people may find other creative use for this variable too.

Before writing the actual patch, I want to ask if my idea worth trying. Is it?

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

amarao commented 4 years ago

As you wish. I have this code fixed for myself.

mistur commented 3 years ago

@amarao Could you share your code, please? I hit the same bug, Thanks a lot! Yoann

amarao commented 3 years ago

We had moved to different code by now, but my old patch looks like this: (it may be broken and you need to tweak it):

--- a/vendor/github.com/ceph/ceph-ansible/roles/ceph-dashboard/tasks/configure_dashboard.yml
+++ b/vendor/github.com/ceph/ceph-ansible/roles/ceph-dashboard/tasks/configure_dashboard.yml
+- name: Configure dashboard address
+  run_once: true
+  when: dashboard_addr is defined
+  block:
+    - name: get current dashboard address
+      command: "{{ container_exec_cmd }} ceph --cluster {{ cluster }} config get mgr mgr/dashboard/server_addr"
+
+      register: dashboard_addr_result
+    - name: set current dashboard address
+      command: "{{ container_exec_cmd }} ceph --cluster {{ cluster }} config set mgr mgr/dashboard/server_addr {{ dashboard_addr }}"
+      when: dashboard_addr not in dashboard_addr_result.stdout
guits commented 3 years ago

I'm definitely not a dashboard expert, so I might be missing something. what's the issue with https://github.com/ceph/ceph-ansible/blob/master/roles/ceph-dashboard/tasks/configure_dashboard.yml#L150-L155 ?

amarao commented 3 years ago

It's really an antique issue. At the moment of reporting there were no such thing, I fixed it, time passed, it was fixed in upstream. @mistur asked me for my fix, which I gave (may be they still use an older version?).

I think this issue can be closed.

guits commented 3 years ago

yeh I think @mistur is using an older version, let's close this one.

mistur commented 3 years ago

Hello, Thanks for the reply, It on a fresh deployment of Ceph Pacific 16.2.6 with ceph-ansible stable6.0 stable and ansible 2.9

(ansible2.9) floki@icitsrv5:~/ceph-ansible$ ceph --version
ceph version 16.2.6 (ee28fb57e47e9f88813e24bbf4c14496ca299d31) pacific (stable)
(ansible2.9) floki@icitsrv5:~/ceph-ansible$ ansible --version
/home/floki/ceph-ansible/ansible2.9/local/lib/python2.7/site-packages/ansible/parsing/vault/__init__.py:41: CryptographyDeprecationWarning: Python 2 is no longer supported by the Python core team. Support for it is now deprecated in cryptography, and will be removed in the next release.
  from cryptography.exceptions import InvalidSignature
ansible 2.9.0
  config file = /home/floki/ceph-ansible/ansible.cfg
  configured module search path = [u'/home/floki/ceph-ansible/library']
  ansible python module location = /home/floki/ceph-ansible/ansible2.9/local/lib/python2.7/site-packages/ansible
  executable location = /home/floki/ceph-ansible/ansible2.9/bin/ansible
  python version = 2.7.17 (default, Feb 27 2021, 15:10:58) [GCC 7.5.0]
(ansible2.9) floki@icitsrv5:~/ceph-ansible$ git branch
  master
* stable-6.0
(ansible2.9) floki@icitsrv5:~/ceph-ansible$ 

and I got this :


TASK [ceph-dashboard : config the current dashboard backend] *********************************************************************************************************************************************************************************************************************************************************************************************************************************
Thursday 07 October 2021  09:58:54 +0200 (0:00:01.037)       0:02:42.161 ****** 
fatal: [iccluster152.iccluster.epfl.ch]: FAILED! => 
  msg: |-
    The task includes an option with an undefined variable. The error was: 'ansible.vars.hostvars.HostVarsVars object' has no attribute 'dashboard_server_addr'

    The error appears to be in '/home/floki/ceph-ansible/roles/ceph-dashboard/tasks/configure_dashboard.yml': line 150, column 3, but may
    be elsewhere in the file depending on the exact syntax problem.

    The offending line appears to be:

    - name: config the current dashboard backend
      ^ here

Best regards,

Yoann

mistur commented 3 years ago

Here the config : cluster-floki.zip Best, Yoann

amarao commented 3 years ago

as I said, it's our own internal patch, and it's up to you how to adopt it into old code you run. I'd say start from defining dashboard_server_addr in whatever place you find deemed.

mistur commented 3 years ago

I tried but it has no effect, I'll investigate deeper, Thanks. Best, Yoann

guits commented 3 years ago

@mistur could you share the full log?

mistur commented 3 years ago

@guits I try to apply the entire playbook instead of limit to monitoring host only and I didn't get the error

Playbook execution OK : ansible-playbook site.yml

Playbook execution Non OK : ansible-playbook --limit monitoring

ansible-monitoring.log

until it works by running the entire playbook, it's OK, I just need to understand why Grafana does not load default dasboard.

Thanks for you help,

Best regards,

Yoann