From e4ff13c56a38707e08cfc00b6eb377b2469fb750 Mon Sep 17 00:00:00 2001 From: Jesse Pretorius Date: Mon, 10 Jul 2017 12:25:15 +0100 Subject: [PATCH] Optimise the role execution This patch does the following: - Instead of scoping to the inventory group name, we scope to the play hosts. This allows the execution of the role using limits to still execute the necessary tasks. - A little style update is done to improve readability. - Some includes are changed from static to dynamic to improve execution speed. - The tag for the translations async finalisation is changed to 'horizon-config' to match the rest of the config related tasks, including the task which starts the async process. - The enabling and starting up of Apache is moved to the handler so that it's all done in one task. Conflicts: >------tasks/main.yml Change-Id: If9726035d1fae0ec78aead38eb85f4d30a45a07c (cherry picked from commit faa5b91e1f7df68547c74879fe55d40afed3ac63) --- handlers/main.yml | 2 ++ tasks/horizon_apache.yml | 14 ++++---------- tasks/main.yml | 9 +++++---- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/handlers/main.yml b/handlers/main.yml index df3c0fd8..9361f796 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -16,4 +16,6 @@ - name: Restart apache2 service: name: "{{ horizon_system_service_name }}" + enabled: yes state: "restarted" + daemon_reload: "{{ (ansible_service_mgr == 'systemd') | ternary('yes', omit) }}" diff --git a/tasks/horizon_apache.yml b/tasks/horizon_apache.yml index b0dc41b7..d682e3f2 100644 --- a/tasks/horizon_apache.yml +++ b/tasks/horizon_apache.yml @@ -41,8 +41,8 @@ template: src: "{{ item.src }}" dest: "{{ item.dest }}" - owner: "{{ item.owner|default(horizon_system_user_name) }}" - group: "{{ item.group|default(horizon_system_group_name) }}" + owner: "{{ item.owner | default(horizon_system_user_name) }}" + group: "{{ item.group | default(horizon_system_group_name) }}" with_items: "{{ horizon_apache_configs }}" notify: Restart apache2 @@ -83,17 +83,11 @@ line: "ServerSignature {{ horizon_apache_serversignature }}" notify: Restart apache2 -# Removing the Listen from apache config to prevent conflick with ports.conf on CentOS -- name: remove Listen from Apache config +# Removing the Listen from apache config to prevent conflicts with ports.conf on CentOS +- name: Remove Listen from Apache config lineinfile: dest: "{{ horizon_apache_security_conf }}" regexp: '^(Listen.*)' backrefs: yes line: '#\1' notify: Restart apache2 - -- name: Load service - service: - name: "{{ horizon_system_service_name }}" - enabled: "yes" - state: "started" diff --git a/tasks/main.yml b/tasks/main.yml index fb0a567c..1c6c55cd 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -37,28 +37,29 @@ - horizon-config - include: horizon_db_setup.yml - when: inventory_hostname == groups['horizon_all'][0] + static: no + when: inventory_hostname == ansible_play_hosts[0] tags: - horizon-config - include: horizon_ssl_self_signed.yml static: no when: - - not horizon_external_ssl|bool + - not horizon_external_ssl | bool - horizon_user_ssl_cert is not defined or horizon_user_ssl_key is not defined tags: - horizon-config - include: horizon_ssl_user_provided.yml static: no - when: not horizon_external_ssl|bool + when: not horizon_external_ssl | bool tags: - horizon-config - name: Update the ca certificates command: "update-ca-certificates -f" when: - - not horizon_external_ssl|bool + - not horizon_external_ssl | bool - ansible_pkg_mgr == 'apt' tags: - horizon-config