Comment 2 for bug 1778098

Revision history for this message
Guilherme Steinmuller Pimentel (guilhermesp) wrote :

Hello! I reproduced the user story that Dmitriy R. stated in this bug. Thanks for that Dmitriy R. anyway!
I did it in one fresh osa-master installation.

Just a few notes:

1. First, I added a new empty variable in /etc/ansible/roles/os_horizon called "horizon_custom_theme_path:".

2. In /etc/openstack_deploy/ I created a directory called "horizon_custom_theme" and inside it I put a copy of the available themes in "{{ horizon_lib_dir }}/openstack_dashboard/themes" (just to see the files being copied i.e /etc/openstack_deploy/horizon_custom_theme/custom/* )

 obs: As stated here https://docs.openstack.org/horizon/latest/configuration/themes.html#inherit-from-an-existing-theme, the right way is to run "python manage.py collectstatic" after create your custom theme directory, but I didn't manage it to do it.

3. In /etc/openstack_deploy/user_variables.yml I added the following variables:

   - horizon_custom_theme_path: "/etc/openstack_deploy/horizon_custom_theme/"

   - horizon_default_theme: "custom"

   -horizon_custom_themes:
      custom_theme:
        theme_name: "custom"
        theme_label: "Custom"
        theme_path: "themes/"

4. In /etc/ansible/roles/os_horizon/tasks/horizon_post_install.yml I added the following task after "Drop horizon customization module" task, like:

- name: Drop horizon custom themes
  synchronize:
    src: "{{ horizon_custom_theme_path }}/{{ item.value.theme_name }}"
    dest: "{{ horizon_lib_dir }}/openstack_dashboard/{{ item.value.theme_path }}"
    times: yes
    archive: no
    recursive: yes
    delete: yes
    checksum: yes
  with_dict: "{{ horizon_custom_themes }}"
  notify: Restart apache2
  when: horizon_custom_themes is defined

  obs: I don't see reasons to add the task "Setting horizon permissions" right after "Drop horizon custom themes" task as the custom themes directories located in "{{ horizon_lib_dir }}/openstack_dashboard/themes" has root:root by default, didn't any effect changing to horizon:horizon, so my suggestion is to remove this task to avoid unnecessary tasks.

5. Then, I executed the setup-openstack.yml (with clean horizon container) and the custom theme were deployed correct in the right path inside horizon venv.

As mentioned in my 2nd step, I got the error bellow I think because I didn't manage to correct create the custom theme directory:

TASK [os_horizon : Ensure static files are collected and compressed] ********************************************************************************************************************
changed: [aio1_horizon_container-4d604984] => (item={'_ansible_no_log': False, 'item': '/openstack/venvs/horizon-18.0.0.0b3/bin/horizon-manage.py collectstatic --noinput', 'started': 1, '_ansible_ignore_errors': None, 'results_file': '/var/lib/horizon/.ansible_async/390504259645.12638', '_ansible_item_result': True, '_ansible_notify': ['Restart apache2'], 'ansible_job_id': '390504259645.12638', 'failed': False, 'changed': False, 'finished': 0, '_ansible_parsed': True})
FAILED - RETRYING: Ensure static files are collected and compressed (300 retries left).
FAILED - RETRYING: Ensure static files are collected and compressed (299 retries left).
FAILED - RETRYING: Ensure static files are collected and compressed (298 retries left).
FAILED - RETRYING: Ensure static files are collected and compressed (297 retries left).
FAILED - RETRYING: Ensure static files are collected and compressed (296 retries left).
FAILED - RETRYING: Ensure static files are collected and compressed (295 retries left).
FAILED - RETRYING: Ensure static files are collected and compressed (294 retries left).
FAILED - RETRYING: Ensure static files are collected and compressed (293 retries left).
FAILED - RETRYING: Ensure static files are collected and compressed (292 retries left).
FAILED - RETRYING: Ensure static files are collected and compressed (291 retries left).
FAILED - RETRYING: Ensure static files are collected and compressed (290 retries left).
failed: [aio1_horizon_container-4d604984] (item={'_ansible_no_log': False, 'item': '/openstack/venvs/horizon-18.0.0.0b3/bin/horizon-manage.py compress --force', 'started': 1, '_ansible_ignore_errors': None, 'results_file': '/var/lib/horizon/.ansible_async/715886674328.12728', '_ansible_item_result': True, '_ansible_notify': ['Restart apache2'], 'ansible_job_id': '715886674328.12728', 'failed': False, 'changed': False, 'finished': 0, '_ansible_parsed': True}) => {"ansible_job_id": "715886674328.12728", "attempts": 12, "changed": true, "cmd": ["/openstack/venvs/horizon-18.0.0.0b3/bin/horizon-manage.py", "compress", "--force"], "delta": "0:01:06.313143", "end": "2018-06-30 01:26:41.509463", "finished": 1, "item": {"ansible_job_id": "715886674328.12728", "changed": false, "failed": false, "finished": 0, "item": "/openstack/venvs/horizon-18.0.0.0b3/bin/horizon-manage.py compress --force", "results_file": "/var/lib/horizon/.ansible_async/715886674328.12728", "started": 1}, "msg": "non-zero return code", "rc": 1, "start": "2018-06-30 01:25:35.196320", "stderr": "CommandError: An error occurred during rendering /openstack/venvs/horizon-18.0.0.0b3/lib/python2.7/site-packages/openstack_dashboard/templates/_stylesheets.html: Couldn't find anything to import: /themes/custom/variables\nExtensions: <NamespaceAdapterExtension>, <DjangoExtension>, <CompassExtension>\nSearch path:\n \non line 1 of u'string:af878a4429fc501a:\\n // My Themes\\n@import \"/themes/custom/variables\";\\n\\n// Horizon\\n@import \"/dashboard/scss/horizon.s'", "stderr_lines": ["CommandError: An error occurred during rendering /openstack/venvs/horizon-18.0.0.0b3/lib/python2.7/site-packages/openstack_dashboard/templates/_stylesheets.html: Couldn't find anything to import: /themes/custom/variables", "Extensions: <NamespaceAdapterExtension>, <DjangoExtension>, <CompassExtension>", "Search path:", " ", "on line 1 of u'string:af878a4429fc501a:\\n // My Themes\\n@import \"/themes/custom/variables\";\\n\\n// Horizon\\n@import \"/dashboard/scss/horizon.s'"], "stdout": "Found 'compress' tags in:\n\t/openstack/venvs/horizon-18.0.0.0b3/lib/python2.7/site-packages/openstack_dashboard/templates/horizon/_scripts.html\n\t/openstack/venvs/horizon-18.0.0.0b3/lib/python2.7/site-packages/openstack_dashboard/templates/_stylesheets.html\n\t/openstack/venvs/horizon-18.0.0.0b3/lib/python2.7/site-packages/openstack_dashboard/templates/serial_console.html\n\t/openstack/venvs/horizon-18.0.0.0b3/lib/python2.7/site-packages/openstack_dashboard/templates/horizon/_conf.html\nCompressing... ", "stdout_lines": ["Found 'compress' tags in:", "\t/openstack/venvs/horizon-18.0.0.0b3/lib/python2.7/site-packages/openstack_dashboard/templates/horizon/_scripts.html", "\t/openstack/venvs/horizon-18.0.0.0b3/lib/python2.7/site-packages/openstack_dashboard/templates/_stylesheets.html", "\t/openstack/venvs/horizon-18.0.0.0b3/lib/python2.7/site-packages/openstack_dashboard/templates/serial_console.html", "\t/openstack/venvs/horizon-18.0.0.0b3/lib/python2.7/site-packages/openstack_dashboard/templates/horizon/_conf.html", "Compressing... "]}

RUNNING HANDLER [os_horizon : Restart apache2] ******************************************************************************************************************************************
changed: [aio1_horizon_container-4d604984]

PLAY RECAP ******************************************************************************************************************************************************************************
aio1_horizon_container-4d604984 : ok=48 changed=6 unreachable=0 failed=1