Implements custom theme distribution

Adds key ``theme_src_archive`` to ``horizon_custom_themes``,
which should point to archive with packed theme inside.
Archive should be placed on the deployment host and it
may be easily created by git-archive, or ansible git module.
Structure inside archive should be as a standard theme,
without any leading folders.

Unarchive is used instead of synchronize with flat files,
as synchronize establishes independent SSH connection
and doesn't use nspawn or any other methods from
custom ssh plugin and may case connection errors.
Recursive copy has limitations on number of files inside of the
directory. This limit is pretty high, but still it's a limit.

This method differs from uploading custom files, as themes may
have complex structure and include a lot of files.

As a result, if ``horizon_custom_themes`` contains
``theme_src_archive`` key, theme will be distributed by role.

Change-Id: Icbfff0793a703de94091cfdcdecf5a2c91bae4be
Related-Bug: 1778098
This commit is contained in:
Dmitriy R 2018-07-26 21:31:55 +03:00 committed by Dmitriy Rabotjagov
parent 9aadbba2f0
commit acf7a29609
3 changed files with 36 additions and 3 deletions

View File

@ -275,9 +275,12 @@ _horizon_available_themes:
theme_label: "Material"
theme_path: "themes/material"
# Add custom themes. Deployers need to place the theme directories
# and files on the horizon containers in:
# {{ horizon_lib_dir }}/openstack_dashboard/themes
# Add custom themes. Deployers need to place the archive, with the theme inside,
# into the directory, which is specified by theme_src_archive key.
# It should be an absolute path to the archive on the deployment host.
# Leading folders are not expected in the archive.
# Following archive formats are supported:
# .tar.gz, .tgz, .zip, .tar.bz, .tar.bz2, .tbz, .tbz2
# See https://docs.openstack.org/horizon/latest/configuration/themes.html
# for more details on custom themes
# Example:
@ -287,6 +290,7 @@ _horizon_available_themes:
# theme_name: "custom"
# theme_label: "Custom"
# theme_path: "themes/custom"
# theme_src_archive: "/etc/openstack_deploy/horizon/themes/custom.tar.gz"
#
horizon_custom_themes: {}

View File

@ -0,0 +1,10 @@
---
features:
- The ``os_horizon`` role now supports distribution of user custom themes.
Deployers can use the new key ``theme_src_archive`` of ``horizon_custom_themes``
dictionary to provide absolute path to the archived theme.
Only .tar.gz, .tgz, .zip, .tar.bz, .tar.bz2, .tbz, .tbz2 archives are supported.
Structure inside archive should be as a standard theme, without any leading folders.
fixes:
- Fixes bug https://bugs.launchpad.net/openstack-ansible/+bug/1778098 where playbook failed, if
``horizon_custom_themes`` is specified, and directory for theme is not provided

View File

@ -96,6 +96,25 @@
notify: Restart apache2
when: horizon_customization_module is defined
- name: Creating horizon custom theme path
file:
path: "{{ horizon_lib_dir }}/openstack_dashboard/{{ item.value.theme_path }}/"
state: directory
owner: "{{ horizon_system_user_name }}"
group: "{{ horizon_system_group_name }}"
mode: "0755"
with_dict: "{{ horizon_custom_themes }}"
- name: Drop horizon custom themes
unarchive:
src: "{{ item.value.theme_src_archive }}"
dest: "{{ horizon_lib_dir }}/openstack_dashboard/{{ item.value.theme_path }}/"
owner: "{{ horizon_system_user_name }}"
group: "{{ horizon_system_group_name }}"
with_dict: "{{ horizon_custom_themes }}"
when: item.value.theme_src_archive is defined
notify: Restart apache2
- name: Compile messages for translation
command: "{{ horizon_manage }} compilemessages"
become: yes