diff --git a/ansible/roles/horizon/handlers/main.yml b/ansible/roles/horizon/handlers/main.yml index 852e777b85..8d6df8518f 100644 --- a/ansible/roles/horizon/handlers/main.yml +++ b/ansible/roles/horizon/handlers/main.yml @@ -17,5 +17,6 @@ - horizon_config_json | changed or horizon_conf | changed or horizon_local_settings | changed + or horizon_custom_local_settings | changed or policy_jsons | changed or check_horizon_container | changed diff --git a/ansible/roles/horizon/tasks/config.yml b/ansible/roles/horizon/tasks/config.yml index d52761aada..45a4d1c133 100644 --- a/ansible/roles/horizon/tasks/config.yml +++ b/ansible/roles/horizon/tasks/config.yml @@ -98,6 +98,25 @@ notify: - Restart horizon container +- name: Copying over custom_local_settings + become: true + vars: + horizon: "{{ horizon_services['horizon'] }}" + template: + src: "{{ item }}" + dest: "{{ node_config_directory }}/horizon/custom_local_settings" + mode: "0660" + with_first_found: + - "{{ node_custom_config }}/horizon/{{ inventory_hostname }}/custom_local_settings" + - "{{ node_custom_config }}/horizon/custom_local_settings" + - "custom_local_settings.j2" + register: horizon_custom_local_settings + when: + - horizon.enabled | bool + - inventory_hostname in groups[horizon.group] + notify: + - Restart horizon container + - name: Copying over existing policy file become: true vars: diff --git a/ansible/roles/horizon/templates/custom_local_settings.j2 b/ansible/roles/horizon/templates/custom_local_settings.j2 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ansible/roles/horizon/templates/horizon.json.j2 b/ansible/roles/horizon/templates/horizon.json.j2 index b565070761..90775ace05 100644 --- a/ansible/roles/horizon/templates/horizon.json.j2 +++ b/ansible/roles/horizon/templates/horizon.json.j2 @@ -49,6 +49,12 @@ "dest": "/etc/openstack-dashboard/local_settings", "owner": "horizon", "perm": "0600" + }, + { + "source": "{{ container_config_directory }}/custom_local_settings", + "dest": "/etc/openstack-dashboard/custom_local_settings", + "owner": "horizon", + "perm": "0600" } ] } diff --git a/ansible/roles/horizon/templates/local_settings.j2 b/ansible/roles/horizon/templates/local_settings.j2 index 9ce7357066..50e26ee1dd 100644 --- a/ansible/roles/horizon/templates/local_settings.j2 +++ b/ansible/roles/horizon/templates/local_settings.j2 @@ -841,3 +841,6 @@ KEY_MANAGER = { 'project_domain_name': '{{ default_project_domain_name }}' } {% endif %} + +# Allow operators to overwrite variables (LP: #1769970). +from custom_local_settings import * diff --git a/doc/source/reference/horizon-guide.rst b/doc/source/reference/horizon-guide.rst new file mode 100644 index 0000000000..450d408edb --- /dev/null +++ b/doc/source/reference/horizon-guide.rst @@ -0,0 +1,30 @@ +.. _horizon-guide: + +================ +Horizon in Kolla +================ + +Overview +~~~~~~~~ + +Kolla can deploy a full working Horizon dashboard setup in either +a **all-in-one** or **multinode** setup. + +Extending the default local_settings options +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +It is possible to extend the default configuration options for +Horizon by using a custom python settings file that will override +the default options set on the local_settings file. + +As an example, for setting a different (material) theme as the default one, +a file named custom_local_settings should be created under the directory +``{{ node_custom_config }}/horizon/`` with the following contents: + +.. code-block:: python + + AVAILABLE_THEMES = [ + ('material', 'Material', 'themes/material'), + ] + +.. end diff --git a/doc/source/reference/index.rst b/doc/source/reference/index.rst index 92fbc5bf90..b9d041d6df 100644 --- a/doc/source/reference/index.rst +++ b/doc/source/reference/index.rst @@ -26,3 +26,4 @@ Projects Deployment References vmware-guide tacker-guide xenserver-guide + horizon-guide diff --git a/releasenotes/notes/add-horizon-custom-settings-file-d5dfab8a1a3b4ee7.yaml b/releasenotes/notes/add-horizon-custom-settings-file-d5dfab8a1a3b4ee7.yaml new file mode 100644 index 0000000000..ba08dd4dfd --- /dev/null +++ b/releasenotes/notes/add-horizon-custom-settings-file-d5dfab8a1a3b4ee7.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + The settings file ``{{ node_custom_config}}/horizon/custom_local_settings`` can be + used in Horizon to overwrite the default local_settings without a need to sync it at image build time.