Ease to switch themes of Horizon 99/28099/2
authorliyuenan <liyuenan@huawei.com>
Mon, 6 Feb 2017 09:12:50 +0000 (17:12 +0800)
committerliyuenan <liyuenan@huawei.com>
Wed, 8 Feb 2017 02:02:41 +0000 (10:02 +0800)
JIRA: -

Default Horizon theme is ubuntu. If you want to use openstack theme,
you can run `export ENABLE_UBUNTU_THEME=False` before deploy.

And if you want to change theme after you installed openstack, you need
to run this commands:
  1. access compass VM, password is root
      `ssh root@192.168.200.2`
  2. change path:
      `cd /var/ansible/run/openstack_newton-opnfv2`
  3. Edit the `group_vars/all` file, change `enable_ubuntu_theme` var:
      `enable_ubuntu_theme: False`
     if `enable_ubuntu_theme: True`, the Horizon theme is ubuntu, otherwise
     the Horizon theme is openstack.
  4. run ansible playbook:
       `ansible-playbook -i inventories/inventory.yml HA-ansible-multinodes.yml
        -t horizon_theme`

Change-Id: I5465107228af32a482879c8a058899494f33e2d0
Signed-off-by: liyuenan <liyuenan@huawei.com>
deploy/adapters/ansible/roles/dashboard/tasks/main.yml
deploy/adapters/ansible/roles/dashboard/templates/local_settings.py.j2

index 289bfa8..f52d802 100644 (file)
@@ -8,6 +8,8 @@
 ##############################################################################
 ---
 - include_vars: "{{ ansible_os_family }}.yml"
+  tags:
+    - horizon_theme
 
 - name: disable auto start
   copy:
     state=absent
   when: ansible_os_family == "Debian"
 
-- name: remove ubuntu theme
-  action:
-    "{{ ansible_pkg_mgr }} name=openstack-dashboard-ubuntu-theme state=absent"
-  when: ansible_os_family == 'Debian' and not enable_ubuntu_theme
-  notify:
-    - restart dashboard services
-
 - name: remove default apache2 config
   file:
     path: '{{ item }}'
@@ -78,6 +73,8 @@
   when: ansible_os_family == 'Debian'
   notify:
     - restart dashboard services
+  tags:
+    - horizon_theme
 
 - name: precompile horizon css
   shell: |
index 7278d5c..c9530b9 100644 (file)
@@ -97,6 +97,13 @@ DROPDOWN_MAX_ITEMS = 30
 
 TIME_ZONE = "UTC"
 
+{% if enable_ubuntu_theme == False %}
+AVAILABLE_THEMES = [
+    ('default', 'Default', 'themes/default'),
+    ('material', 'Material', 'themes/material'),
+]
+{% endif %}
+
 LOGGING = {
     'version': 1,
     'disable_existing_loggers': False,