From 25047cd99744190d923ecb1d81913e8a16d41e13 Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotyagov Date: Tue, 4 Jun 2024 19:47:13 +0200 Subject: [PATCH] Fix horizon distro installation for EL RDO is installing Horizon not under site-packages, but under /usr/share which makes it completely different logic, with default horizon-manage not working, as it can not import openstack_dashboard now, as Change-Id: I4c06b4b5a206b087a9fce856f5fec936e058e3f8 --- tasks/horizon_post_install.yml | 2 +- templates/horizon-manage.py.j2 | 3 +++ vars/distro_install.yml | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/tasks/horizon_post_install.yml b/tasks/horizon_post_install.yml index 70f6ec4e..69be571f 100644 --- a/tasks/horizon_post_install.yml +++ b/tasks/horizon_post_install.yml @@ -14,7 +14,7 @@ # limitations under the License. - name: Define horizon_lib_dir when it's not set - when: horizon_lib_dir is not defined + when: horizon_lib_dir is not defined or (horizon_lib_dir is defined and not horizon_lib_dir) block: - name: Find the venv's python version command: "{{ horizon_bin }}/{{ horizon_venv_python_executable }} -c 'import horizon; print(horizon.__file__)'" diff --git a/templates/horizon-manage.py.j2 b/templates/horizon-manage.py.j2 index a9a29240..32a651df 100644 --- a/templates/horizon-manage.py.j2 +++ b/templates/horizon-manage.py.j2 @@ -18,6 +18,9 @@ import sys from django.core.management import execute_from_command_line # noqa if __name__ == "__main__": +{% if horizon_install_method == 'distro' and (ansible_facts['os_family'] | lower == 'redhat') %} + sys.path.append('{{ horizon_lib_dir }}') +{% endif %} os.environ.setdefault("DJANGO_SETTINGS_MODULE", "openstack_dashboard.settings") execute_from_command_line(sys.argv) diff --git a/vars/distro_install.yml b/vars/distro_install.yml index 5dd9457b..5d77abc7 100644 --- a/vars/distro_install.yml +++ b/vars/distro_install.yml @@ -25,3 +25,5 @@ horizon_package_list: >- }} _horizon_bin: "/usr/bin" + +horizon_lib_dir: "{{ (ansible_facts['os_family'] | lower == 'redhat') | ternary('/usr/share/openstack-dashboard', None) }}"