Merge "Improve defining horizon_lib_dir"
This commit is contained in:
commit
1ed0cea42a
@ -144,7 +144,8 @@ horizon_allowed_hosts:
|
||||
- '*'
|
||||
|
||||
## Installation directories
|
||||
horizon_lib_dir: "{{ _horizon_lib_dir }}"
|
||||
# When horizon_lib_dir is not defined, it will be detected automatically
|
||||
#horizon_lib_dir: ""
|
||||
horizon_lib_wsgi_file: "{{ horizon_lib_dir }}/openstack_dashboard/wsgi.py"
|
||||
|
||||
horizon_endpoint_type: internalURL
|
||||
|
@ -40,5 +40,5 @@
|
||||
- Restart apache2
|
||||
|
||||
- name: Install horizon packages from PIP
|
||||
import_tasks: horizon_install_source.yml
|
||||
include_tasks: horizon_install_source.yml
|
||||
when: horizon_install_method == 'source'
|
||||
|
@ -13,28 +13,6 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
- name: Create horizon dir
|
||||
file:
|
||||
path: "{{ item.path }}"
|
||||
state: directory
|
||||
owner: "{{ item.owner|default(horizon_system_user_name) }}"
|
||||
group: "{{ item.group|default(horizon_system_group_name) }}"
|
||||
mode: "{{ item.mode|default('0755') }}"
|
||||
with_items:
|
||||
- { path: "/etc/pki/tls/certs", owner: "root", group: "root" }
|
||||
- { path: "/etc/pki/tls/private", owner: "root", group: "root" }
|
||||
when: ansible_facts['pkg_mgr'] == 'dnf'
|
||||
|
||||
- name: Create system links
|
||||
file:
|
||||
src: "{{ item.src }}"
|
||||
dest: "{{ item.dest }}"
|
||||
state: "link"
|
||||
with_items:
|
||||
- { src: "/etc/pki/tls/certs", dest: "/etc/ssl/certs" }
|
||||
- { src: "/etc/pki/tls/private", dest: "/etc/ssl/private" }
|
||||
when: ansible_facts['pkg_mgr'] == 'dnf'
|
||||
|
||||
# NOTE(jrosser)
|
||||
# horizon appears in u-c as is it used as a library for the horizon plugins
|
||||
# the new pip resolver will fail to install horizon if two contradictory
|
||||
@ -82,98 +60,3 @@
|
||||
- section: "horizon"
|
||||
option: "venv_tag"
|
||||
value: "{{ horizon_venv_tag }}"
|
||||
|
||||
- name: Find the venv's python version
|
||||
find:
|
||||
paths: "{{ horizon_bin | dirname }}/lib/"
|
||||
patterns: "python*"
|
||||
file_type: directory
|
||||
recurse: no
|
||||
register: _horizon_python_venv_details
|
||||
tags:
|
||||
- horizon-config
|
||||
|
||||
- name: Set python lib dir fact
|
||||
set_fact:
|
||||
horizon_lib_dir: "{{ _horizon_python_venv_details.files[0].path }}/dist-packages"
|
||||
tags:
|
||||
- horizon-config
|
||||
|
||||
- name: Create horizon link for venv
|
||||
file:
|
||||
src: "{{ horizon_lib_dir | dirname }}/site-packages"
|
||||
dest: "{{ horizon_lib_dir }}"
|
||||
owner: "{{ horizon_system_user_name }}"
|
||||
group: "{{ horizon_system_group_name }}"
|
||||
state: "link"
|
||||
|
||||
- name: Create static horizon dir
|
||||
file:
|
||||
path: "{{ item.path }}"
|
||||
state: "directory"
|
||||
owner: "{{ item.owner|default(horizon_system_user_name) }}"
|
||||
group: "{{ item.group|default(horizon_system_group_name) }}"
|
||||
with_items:
|
||||
- { path: "{{ horizon_lib_dir }}/static", mode: "2755" }
|
||||
- { path: "{{ horizon_lib_dir }}/openstack_dashboard", mode: "2755" }
|
||||
- { path: "{{ horizon_lib_dir }}/openstack_dashboard/local", mode: "2755" }
|
||||
- { path: "{{ horizon_lib_dir }}/openstack_dashboard/local/enabled", mode: "2755" }
|
||||
|
||||
- name: Registering dashboards
|
||||
find:
|
||||
paths: "{{ horizon_lib_dir }}"
|
||||
patterns: "^.*(dashboard|ui)$"
|
||||
file_type: directory
|
||||
use_regex: yes
|
||||
excludes: "openstack_dashboard"
|
||||
recurse: no
|
||||
register: found_dashboards
|
||||
|
||||
- name: Registering panels
|
||||
find:
|
||||
paths: |-
|
||||
{% set dashboard_path = [] %}
|
||||
{% for dashboard in found_dashboards.files %}
|
||||
{% for path in _dashboard_panels_location %}
|
||||
{% set _ = dashboard_path.append(dashboard.path + path) %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
{{ dashboard_path }}
|
||||
patterns: ["^_[0-9]{2,4}_.*.py$"]
|
||||
file_type: file
|
||||
use_regex: yes
|
||||
register: found_panels
|
||||
|
||||
- name: Registering policy files
|
||||
find:
|
||||
paths: |-
|
||||
{% set policy_path = [] %}
|
||||
{% for dashboard in found_dashboards.files %}
|
||||
{% for path in _dashboard_panels_location %}
|
||||
{% set _ = policy_path.append(dashboard.path + path) %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
{{ policy_path }}
|
||||
patterns: ["^.*_policy.(json|yaml)$"]
|
||||
file_type: file
|
||||
use_regex: yes
|
||||
register: found_policy
|
||||
|
||||
- name: Link policy files
|
||||
file:
|
||||
src: "{{ item.path }}"
|
||||
dest: "{{ horizon_lib_dir }}/openstack_dashboard/conf/{{ item.path|basename }}"
|
||||
state: link
|
||||
with_items: "{{ found_policy.files }}"
|
||||
notify:
|
||||
- Compile messages
|
||||
|
||||
- name: Enable project panels
|
||||
file:
|
||||
src: "{{ item.path }}"
|
||||
path: "{{ horizon_dashboard_panel_dir }}/{{ item.path|basename }}"
|
||||
state: link
|
||||
with_items: "{{ found_panels.files }}"
|
||||
notify:
|
||||
- Compile messages
|
||||
- Restart apache2
|
||||
|
@ -13,6 +13,23 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
- name: Define horizon_lib_dir when it's not set
|
||||
when: horizon_lib_dir is not defined
|
||||
block:
|
||||
- name: Find the venv's python version
|
||||
command: "{{ horizon_bin }}/{{ horizon_venv_python_executable }} -c 'import horizon; print(horizon.__file__)'"
|
||||
changed_when: false
|
||||
register: _horizon_python_venv_details
|
||||
|
||||
- name: Set python lib dir fact
|
||||
set_fact:
|
||||
horizon_lib_dir: "{{ _horizon_python_venv_details.stdout | dirname | dirname }}"
|
||||
|
||||
- name: Configure source-installed dashboards
|
||||
include_tasks: horizon_post_install_source.yml
|
||||
when: horizon_install_method == 'source'
|
||||
|
||||
# NOTE(noonedeadpunk): change of permission is required for collectstatic and compilemessages
|
||||
- name: Ensure horizon dirs are accessible by user
|
||||
file:
|
||||
path: "{{ item.path }}"
|
||||
@ -36,10 +53,16 @@
|
||||
group: "{{ horizon_system_group_name }}"
|
||||
mode: "{{ item.mode }}"
|
||||
with_items:
|
||||
- { src: "horizon_local_settings.py.j2", dest: "/etc/horizon/local_settings.py", owner: "root", mode: "0640", always_install: True }
|
||||
- { src: "horizon-manage.py.j2", dest: "{{ horizon_bin }}/horizon-manage.py", mode: "0755", always_install: "{{ (horizon_install_method == 'source') }}" }
|
||||
- { src: "80_admin_default_panel.py.j2", dest: "{{ horizon_lib_dir }}/openstack_dashboard/local/enabled/_80_admin_default_panel.py", mode: "0755", always_install: True }
|
||||
when: item.always_install
|
||||
- src: "horizon_local_settings.py.j2"
|
||||
dest: "/etc/horizon/local_settings.py"
|
||||
owner: "root"
|
||||
mode: "0640"
|
||||
- src: "horizon-manage.py.j2"
|
||||
dest: "{{ horizon_bin }}/horizon-manage.py"
|
||||
mode: "0755"
|
||||
- src: "80_admin_default_panel.py.j2"
|
||||
dest: "{{ horizon_lib_dir }}/openstack_dashboard/local/enabled/_80_admin_default_panel.py"
|
||||
mode: "0755"
|
||||
notify: Restart apache2
|
||||
|
||||
- name: Retrieve horizon policy files
|
||||
|
85
tasks/horizon_post_install_source.yml
Normal file
85
tasks/horizon_post_install_source.yml
Normal file
@ -0,0 +1,85 @@
|
||||
---
|
||||
# Copyright 2021, City Network International AB
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
- name: Create static horizon dir
|
||||
file:
|
||||
path: "{{ item.path }}"
|
||||
state: "directory"
|
||||
owner: "{{ item.owner|default(horizon_system_user_name) }}"
|
||||
group: "{{ item.group|default(horizon_system_group_name) }}"
|
||||
with_items:
|
||||
- { path: "{{ horizon_lib_dir }}/static", mode: "2755" }
|
||||
- { path: "{{ horizon_lib_dir }}/openstack_dashboard", mode: "2755" }
|
||||
- { path: "{{ horizon_lib_dir }}/openstack_dashboard/local", mode: "2755" }
|
||||
- { path: "{{ horizon_lib_dir }}/openstack_dashboard/local/enabled", mode: "2755" }
|
||||
|
||||
- name: Registering dashboards
|
||||
find:
|
||||
paths: "{{ horizon_lib_dir }}"
|
||||
patterns: "^.*(dashboard|ui)$"
|
||||
file_type: directory
|
||||
use_regex: yes
|
||||
excludes: "openstack_dashboard"
|
||||
recurse: no
|
||||
register: found_dashboards
|
||||
|
||||
- name: Registering panels
|
||||
find:
|
||||
paths: |-
|
||||
{% set dashboard_path = [] %}
|
||||
{% for dashboard in found_dashboards.files %}
|
||||
{% for path in _dashboard_panels_location %}
|
||||
{% set _ = dashboard_path.append(dashboard.path + path) %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
{{ dashboard_path }}
|
||||
patterns: ["^_[0-9]{2,4}_.*.py$"]
|
||||
file_type: file
|
||||
use_regex: yes
|
||||
register: found_panels
|
||||
|
||||
- name: Registering policy files
|
||||
find:
|
||||
paths: |-
|
||||
{% set policy_path = [] %}
|
||||
{% for dashboard in found_dashboards.files %}
|
||||
{% for path in _dashboard_panels_location %}
|
||||
{% set _ = policy_path.append(dashboard.path + path) %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
{{ policy_path }}
|
||||
patterns: ["^.*_policy.(json|yaml)$"]
|
||||
file_type: file
|
||||
use_regex: yes
|
||||
register: found_policy
|
||||
|
||||
- name: Link policy files
|
||||
file:
|
||||
src: "{{ item.path }}"
|
||||
dest: "{{ horizon_lib_dir }}/openstack_dashboard/conf/{{ item.path|basename }}"
|
||||
state: link
|
||||
with_items: "{{ found_policy.files }}"
|
||||
notify:
|
||||
- Compile messages
|
||||
|
||||
- name: Enable project panels
|
||||
file:
|
||||
src: "{{ item.path }}"
|
||||
path: "{{ horizon_dashboard_panel_dir }}/{{ item.path|basename }}"
|
||||
state: link
|
||||
with_items: "{{ found_panels.files }}"
|
||||
notify:
|
||||
- Compile messages
|
||||
- Restart apache2
|
@ -36,7 +36,20 @@
|
||||
owner: "{{ item.owner|default(horizon_system_user_name) }}"
|
||||
group: "{{ item.group|default(horizon_system_group_name) }}"
|
||||
mode: "{{ item.mode|default('0755') }}"
|
||||
when: item.condition | default(True)
|
||||
with_items:
|
||||
- { path: "/openstack/venvs", mode: "0755", owner: "root", group: "root" }
|
||||
- { path: "/etc/horizon", mode: "2750" }
|
||||
- { path: "{{ horizon_system_user_home }}", mode: "2755" }
|
||||
- { path: "/etc/pki/tls/certs", owner: "root", group: "root", condition: "{{ (ansible_facts['pkg_mgr'] == 'dnf') }}" }
|
||||
- { path: "/etc/pki/tls/private", owner: "root", group: "root", condition: "{{ (ansible_facts['pkg_mgr'] == 'dnf') }}" }
|
||||
|
||||
- name: Create system links
|
||||
file:
|
||||
src: "{{ item.src }}"
|
||||
dest: "{{ item.dest }}"
|
||||
state: "link"
|
||||
with_items:
|
||||
- { src: "/etc/pki/tls/certs", dest: "/etc/ssl/certs" }
|
||||
- { src: "/etc/pki/tls/private", dest: "/etc/ssl/private" }
|
||||
when: ansible_facts['pkg_mgr'] == 'dnf'
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!{{ horizon_bin }}/python
|
||||
#!{{ horizon_bin }}/{{ horizon_venv_python_executable }}
|
||||
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
|
@ -64,6 +64,3 @@ horizon_apache_modules:
|
||||
state: "present"
|
||||
- name: "headers"
|
||||
state: "present"
|
||||
|
||||
_horizon_lib_dir: "/usr/share/openstack-dashboard"
|
||||
horizon_dashboard_panel_dir: "{{ _horizon_lib_dir }}/openstack_dashboard/local/enabled"
|
||||
|
@ -16,6 +16,3 @@
|
||||
horizon_package_list: "{{ horizon_distro_packages + horizon_service_distro_packages }}"
|
||||
|
||||
_horizon_bin: "/usr/bin"
|
||||
horizon_manage: >-
|
||||
{{ ((ansible_facts['os_family'] | lower) == 'debian') | ternary('/usr/bin/python3', ansible_facts['python']['executable']) }}
|
||||
{{ horizon_lib_dir }}/manage.py
|
||||
|
@ -45,3 +45,6 @@ _horizon_translations_pull:
|
||||
branch: "{{ horizon_translations_project_version }}"
|
||||
enabled: True
|
||||
module: trove_dashboard
|
||||
|
||||
horizon_dashboard_panel_dir: "{{ horizon_lib_dir }}/openstack_dashboard/local/enabled"
|
||||
horizon_manage: "{{ horizon_bin }}/horizon-manage.py"
|
||||
|
@ -55,6 +55,3 @@ horizon_apache_default_sites:
|
||||
- "/etc/httpd/conf.d/userdir.conf"
|
||||
- "/etc/httpd/conf.d/welcome.conf"
|
||||
- "/etc/httpd/conf.d/ssl.conf"
|
||||
|
||||
_horizon_lib_dir: "/usr/share/openstack-dashboard"
|
||||
horizon_dashboard_panel_dir: "{{ _horizon_lib_dir }}/openstack_dashboard/local/enabled"
|
||||
|
@ -16,12 +16,6 @@
|
||||
horizon_package_list: "{{ horizon_distro_packages }}"
|
||||
_horizon_bin: "/openstack/venvs/horizon-{{ horizon_venv_tag }}/bin"
|
||||
|
||||
#NOTE(jrosser) for compatibility with py2 and py3 we detect the location of
|
||||
#this dir during the source install and set a fact(horizon_lib_dir)
|
||||
#_horizon_lib_dir: "{{ _horizon_bin | dirname }}/lib/python2.7/dist-packages"
|
||||
horizon_dashboard_panel_dir: "{{ horizon_lib_dir }}/openstack_dashboard/local/enabled"
|
||||
|
||||
horizon_manage: "{{ _horizon_bin }}/horizon-manage.py"
|
||||
_dashboard_panels_location:
|
||||
- "/enabled"
|
||||
- "/conf"
|
||||
|
Loading…
Reference in New Issue
Block a user