Skip to content

Commit 36d9cf0

Browse files
authored
Merge pull request #191 from stackhpc/horizon-themes-wallaby
horizon: Support custom themes
2 parents 7cf6223 + 16ae437 commit 36d9cf0

File tree

6 files changed

+61
-0
lines changed

6 files changed

+61
-0
lines changed

ansible/roles/horizon/defaults/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ horizon_services:
7575
horizon_keystone_domain_choices:
7676
Default: default
7777

78+
horizon_custom_themes: []
79+
7880
####################
7981
# Database
8082
####################

ansible/roles/horizon/tasks/config.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,22 @@
129129
notify:
130130
- Restart horizon container
131131

132+
- name: Copying over custom themes
133+
become: true
134+
vars:
135+
horizon: "{{ horizon_services['horizon'] }}"
136+
copy:
137+
src: "{{ node_custom_config }}/horizon/themes/{{ item.name }}"
138+
dest: "{{ node_config_directory }}/horizon/themes/"
139+
mode: 0660
140+
when:
141+
- horizon.enabled | bool
142+
- inventory_hostname in groups[horizon.group]
143+
- horizon_custom_themes | length > 0
144+
with_items: "{{ horizon_custom_themes }}"
145+
notify:
146+
- Restart horizon container
147+
132148
- include_tasks: copy-certs.yml
133149
when:
134150
- kolla_copy_ca_into_containers | bool or horizon_enable_tls_backend | bool

ansible/roles/horizon/templates/horizon.json.j2

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@
4141
"dest": "/etc/horizon/certs/horizon-key.pem",
4242
"owner": "horizon",
4343
"perm": "0600"
44+
}{% endif %}{% if horizon_custom_themes | length > 0 %},
45+
{
46+
"source": "{{ container_config_directory}}/themes",
47+
"dest": "/etc/openstack-dashboard/themes",
48+
"owner": "horizon",
49+
"perm": "0600"
4450
}{% endif %}
4551
]
4652
}

ansible/roles/horizon/templates/local_settings.j2

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,15 @@ POLICY_FILES_PATH = '/etc/openstack-dashboard'
515515
# ('default', 'Default', 'themes/default'),
516516
# ('material', 'Material', 'themes/material'),
517517
#]
518+
{% if horizon_custom_themes | length > 0 %}
519+
AVAILABLE_THEMES = [
520+
('default', 'Default', 'themes/default'),
521+
('material', 'Material', 'themes/material'),
522+
{% for theme in horizon_custom_themes %}
523+
('{{ theme.name|e }}', '{{ theme.label|e }}', '/etc/openstack-dashboard/themes/{{ theme.name|e }}'),
524+
{% endfor %}
525+
]
526+
{% endif %}
518527

519528
LOGGING = {
520529
'version': 1,

doc/source/reference/shared-services/horizon-guide.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,27 @@ a file named custom_local_settings should be created under the directory
2727
('material', 'Material', 'themes/material'),
2828
]
2929
30+
As a result material theme will be the only one available, and used by default.
31+
Other way of setting default theme is shown in the next section.
32+
33+
Adding custom themes
34+
--------------------
35+
36+
It is possible to add custom themes to be available for Horizon
37+
by using ``horizon_custom_themes`` configuration variable in ``globals.yml``.
38+
This entry updates AVAILABLE_THEMES adding the new theme at the list end.
39+
40+
.. code-block:: yaml
41+
42+
horizon_custom_themes:
43+
- name: my_custom_theme
44+
label: CustomTheme
45+
46+
Theme files have to be copied into:
47+
``{{ node_custom_config }}/horizon/themes/my_custom_theme``.
48+
The new theme can be set as default in custom_local_settings:
49+
50+
.. code-block:: python
51+
52+
DEFAULT_THEME = 'my_custom_theme'
53+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
features:
3+
- |
4+
``horizon`` deployment now supports custom themes.

0 commit comments

Comments
 (0)