From 60ae5731793f874db77ce89a1b46504b874e86d5 Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotjagov Date: Thu, 28 Feb 2019 11:42:47 +0200 Subject: [PATCH] Moved compilemessages to handlers As there were 2 compilemessages tasks in different places and one of them was executed on every launch, in order to remove dublicated code and ease it's maintenance, this task was moved to handlers. Change-Id: Ic9c0de9248c8bd3cd796aa2a338cc57afba57446 --- handlers/main.yml | 9 +++++++++ tasks/horizon_install.yml | 3 +++ tasks/horizon_install_source.yml | 4 +++- tasks/horizon_post_install.yml | 14 -------------- tasks/horizon_translations_update.yml | 14 ++++---------- tasks/main.yml | 13 ------------- 6 files changed, 19 insertions(+), 38 deletions(-) diff --git a/handlers/main.yml b/handlers/main.yml index 794a9142..7e4a2895 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -13,6 +13,15 @@ # See the License for the specific language governing permissions and # limitations under the License. +- name: Compile messages + command: "{{ horizon_manage }} compilemessages" + become: yes + become_user: "{{ horizon_system_user_name }}" + args: + chdir: "{{ horizon_lib_dir }}/" + listen: + - "venv changed" + - name: Restart apache2 service: name: "{{ horizon_system_service_name }}" diff --git a/tasks/horizon_install.yml b/tasks/horizon_install.yml index d246568a..f60180a9 100644 --- a/tasks/horizon_install.yml +++ b/tasks/horizon_install.yml @@ -59,6 +59,9 @@ until: install_packages is success retries: 5 delay: 2 + notify: + - Compile messages + - Restart apache2 - name: Install horizon packages from PIP include_tasks: horizon_install_source.yml diff --git a/tasks/horizon_install_source.yml b/tasks/horizon_install_source.yml index 2bae11ae..f6e6b8e4 100644 --- a/tasks/horizon_install_source.yml +++ b/tasks/horizon_install_source.yml @@ -139,4 +139,6 @@ path: "{{ horizon_dashboard_panel_dir }}/{{ item.path|basename }}" state: link with_items: "{{ found_panels.files }}" - notify: Restart apache2 + notify: + - Compile messages + - Restart apache2 diff --git a/tasks/horizon_post_install.yml b/tasks/horizon_post_install.yml index 460200ae..0d6ecaf9 100644 --- a/tasks/horizon_post_install.yml +++ b/tasks/horizon_post_install.yml @@ -107,20 +107,6 @@ when: item.value.theme_src_archive is defined notify: Restart apache2 -- name: Compile messages for translation - command: "{{ horizon_manage }} compilemessages" - become: yes - become_user: "{{ horizon_system_user_name }}" - args: - chdir: "{{ item }}" - changed_when: false - with_items: - - "{{ horizon_python_lib_dir }}/horizon" - - "{{ horizon_lib_dir }}/openstack_dashboard" - register: async_compile_messages - async: 600 - poll: 0 - - name: Collect and compress static files command: "{{ item }}" become: yes diff --git a/tasks/horizon_translations_update.yml b/tasks/horizon_translations_update.yml index d9134de9..172cf7d4 100644 --- a/tasks/horizon_translations_update.yml +++ b/tasks/horizon_translations_update.yml @@ -14,20 +14,14 @@ # limitations under the License. - name: Perform a Zanata Pull Catalog - command: "{{ horizon_bin }}/horizon-manage.py pull_catalog -p {{ translation.project }} -m {{ translation.module }} -b {{ (translation.branch | default(horizon_translations_project_version)) | replace('/', '-') }}" + command: "{{ horizon_manage }} pull_catalog -p {{ translation.project }} -m {{ translation.module }} -b {{ (translation.branch | default(horizon_translations_project_version)) | replace('/', '-') }}" args: chdir: "{{ horizon_lib_dir }}/" - changed_when: false with_items: "{{ horizon_translations_pull }}" loop_control: loop_var: translation when: - translation.enabled | bool - -- name: Perform Zanata Compile Messages - command: "{{ horizon_bin }}/horizon-manage.py compilemessages" - args: - chdir: "{{ horizon_lib_dir }}/" - tags: - - skip_ansible_lint - notify: Restart apache2 + notify: + - Compile messages + - Restart apache2 diff --git a/tasks/main.yml b/tasks/main.yml index 699b834c..04c89bb1 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -85,19 +85,6 @@ tags: - horizon-config -- name: Ensure messages are compiled for translation - async_status: - jid: "{{ item.ansible_job_id }}" - become: yes - become_user: "{{ horizon_system_user_name }}" - register: async_compile_messages_check - until: async_compile_messages_check.finished - retries: 300 - with_items: - - "{{ async_compile_messages.results }}" - tags: - - horizon-config - # NOTE(mhayden): The async_status check here must be done as the horizon user # since the original task ran as that user. This task will fail if it is run # as root because the async status file is within the horizon user's home