From acf7a29609c81529981b9e4a167c63faa78819d8 Mon Sep 17 00:00:00 2001 From: Dmitriy R Date: Thu, 26 Jul 2018 21:31:55 +0300 Subject: [PATCH] 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 --- defaults/main.yml | 10 +++++++--- .../drop-custom-themes-724c40e5cd69b8e2.yaml | 10 ++++++++++ tasks/horizon_post_install.yml | 19 +++++++++++++++++++ 3 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 releasenotes/notes/drop-custom-themes-724c40e5cd69b8e2.yaml diff --git a/defaults/main.yml b/defaults/main.yml index c7bc114c..bcf454b2 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -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: {} diff --git a/releasenotes/notes/drop-custom-themes-724c40e5cd69b8e2.yaml b/releasenotes/notes/drop-custom-themes-724c40e5cd69b8e2.yaml new file mode 100644 index 00000000..1d0c8e7e --- /dev/null +++ b/releasenotes/notes/drop-custom-themes-724c40e5cd69b8e2.yaml @@ -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 diff --git a/tasks/horizon_post_install.yml b/tasks/horizon_post_install.yml index 84a0e4fb..768967b1 100644 --- a/tasks/horizon_post_install.yml +++ b/tasks/horizon_post_install.yml @@ -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