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) }}"