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.

Change-Id: If9726035d1fae0ec78aead38eb85f4d30a45a07c
This commit is contained in:
Jesse Pretorius 2017-07-10 12:25:15 +01:00 committed by Jesse Pretorius (odyssey4me)
parent 88d8b84d5d
commit faa5b91e1f
3 changed files with 13 additions and 15 deletions

View File

@ -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) }}"

View File

@ -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"

View File

@ -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
@ -101,9 +102,10 @@
- horizon-config
- include: horizon_translations_update.yml
static: no
when: horizon_translations_update | bool
tags:
- horizon-translations-update
- horizon-config
- name: Flush handlers
meta: flush_handlers