kolla-ansible/ansible/roles/cloudkitty/tasks/config.yml
Radosław Piliszek 53376aed8f Performance: Don't notify handlers during config
This patch builds upon genconfig optimisation and it takes it
further by not having genconfig ever touch the handlers!
Calling the handlers and skipping them created an unnecessary slow down
if only config was ran. It also depends on the config checking fix.

This gets us closer to the single responsibility principle -
config only generates the config, container checks only validate
whether container restart is needed.

And this also means that we will have single place were containers
are restarted, were we can fix the ansible quirk of it restarting
the whole group even when one container changed in the following patches.

The only exception is the loadbalance role. As the loadbalancer services
have their config altered by other roles registering their services
using loadbalancer-config. This is in contrast to typical roles,
which do config in one step and can then run check-containers in
the next step.

Fixes some handlers that were missing the necessary guard,
making genconfig actually able to restart some containers.

Future work:
- optimise config by doing local generation and mass rsync
- support for reloads
- unconditional restart/reload (separate action)
- make 'reconfigure' act like 'genconfig' + 'deploy-containers'
  - this would avoid calling bootstrapping each time but might
    be tricky as it would break current compatibility
  - could call this 'reconfigure-containers' and deprecate
    'reconfigure'
- fix the ansible quirk that notifies more handlers then intended

Change-Id: I0ce24043ae5486b2b55489ba40abe2b96b0991a6
Partially-Implements: blueprint performance-improvements
Co-Authored-By: Roman Krček <roman.krcek@tietoevry.com>
2024-12-01 22:16:38 +01:00

97 lines
3.3 KiB
YAML

---
- name: Ensuring config directories exist
file:
path: "{{ node_config_directory }}/{{ item.key }}"
state: "directory"
owner: "{{ config_owner_user }}"
group: "{{ config_owner_group }}"
mode: "0770"
become: true
with_dict: "{{ cloudkitty_services | select_services_enabled_and_mapped_to_host }}"
- name: Check if policies shall be overwritten
stat:
path: "{{ item }}"
delegate_to: localhost
run_once: True
register: cloudkitty_policy
with_first_found:
- files: "{{ supported_policy_format_list }}"
paths:
- "{{ node_custom_config }}/cloudkitty/"
skip: true
- name: Set cloudkitty policy file
set_fact:
cloudkitty_policy_file: "{{ cloudkitty_policy.results.0.stat.path | basename }}"
cloudkitty_policy_file_path: "{{ cloudkitty_policy.results.0.stat.path }}"
when:
- cloudkitty_policy.results
- name: Check if custom {{ cloudkitty_custom_metrics_yaml_file }} exists
stat:
path: "{{ node_custom_config }}/cloudkitty/{{ cloudkitty_custom_metrics_yaml_file }}"
delegate_to: localhost
register: cloudkitty_custom_metrics_file
- name: Copying {{ cloudkitty_custom_metrics_yaml_file }} if it exists
copy:
src: "{{ node_custom_config }}/cloudkitty/{{ cloudkitty_custom_metrics_yaml_file }}"
dest: "{{ node_config_directory }}/{{ item.key }}/{{ cloudkitty_custom_metrics_yaml_file }}"
mode: "0660"
become: true
when:
- cloudkitty_custom_metrics_file.stat.exists
with_dict: "{{ cloudkitty_services | select_services_enabled_and_mapped_to_host }}"
- name: Are we using {{ cloudkitty_custom_metrics_yaml_file }}?
set_fact:
cloudkitty_custom_metrics_used: "{{ cloudkitty_custom_metrics_file.stat.exists }}"
- include_tasks: copy-certs.yml
when:
- kolla_copy_ca_into_containers | bool
- name: Copying over config.json files for services
template:
src: "{{ item.key }}.json.j2"
dest: "{{ node_config_directory }}/{{ item.key }}/config.json"
mode: "0660"
become: true
with_dict: "{{ cloudkitty_services | select_services_enabled_and_mapped_to_host }}"
- name: Copying over cloudkitty.conf
vars:
service_name: "{{ item.key }}"
merge_configs:
sources:
- "{{ role_path }}/templates/cloudkitty.conf.j2"
- "{{ node_custom_config }}/global.conf"
- "{{ node_custom_config }}/cloudkitty.conf"
- "{{ node_custom_config }}/cloudkitty/{{ item.key }}.conf"
- "{{ node_custom_config }}/cloudkitty/{{ inventory_hostname }}/cloudkitty.conf"
dest: "{{ node_config_directory }}/{{ item.key }}/cloudkitty.conf"
mode: "0660"
become: true
with_dict: "{{ cloudkitty_services | select_services_enabled_and_mapped_to_host }}"
- name: Copying over wsgi-cloudkitty.conf
vars:
service: "{{ cloudkitty_services['cloudkitty-api'] }}"
template:
src: "wsgi-cloudkitty.conf.j2"
dest: "{{ node_config_directory }}/cloudkitty-api/wsgi-cloudkitty.conf"
mode: "0660"
become: true
when: service | service_enabled_and_mapped_to_host
- name: Copying over existing policy file
template:
src: "{{ cloudkitty_policy_file_path }}"
dest: "{{ node_config_directory }}/{{ item.key }}/{{ cloudkitty_policy_file }}"
mode: "0660"
become: true
when:
- cloudkitty_policy_file is defined
with_dict: "{{ cloudkitty_services | select_services_enabled_and_mapped_to_host }}"