Method to override the default ceilometer meters.yaml via Kolla-ansible
Similar to what we did here: https://review.opendev.org/#/c/655276 but, for ceilometer/data/meters.d/meters.yaml file. The idea is to create a method for operators to manage custom meters YAML files via Kolla-ansible. To do that, we enable them (operators) to use a folder called by default "meters.d" in their local ceilometer configurations, where all of the custom meters YAML files will be read from. If this folder exist and has YAML files in it, we copy them for the default "/etc/ceilometer/meters.d" path in the containers. We do not inject things in the container though. We copy the files for the control node, and then we map them via ceilometer*.json container configuration files. Change-Id: I712edcf39bfdb64887e25437f0aff30a45a829dd Signed-off-by: Rafael Weingärtner <rafael@apache.org>
This commit is contained in:
parent
fe71a5c059
commit
f0e19ba647
@ -99,3 +99,5 @@ ceilometer_git_repository: "{{ kolla_dev_repos_git }}/ceilometer"
|
||||
ceilometer_dev_repos_pull: "{{ kolla_dev_repos_pull }}"
|
||||
ceilometer_dev_mode: "{{ kolla_dev_mode }}"
|
||||
ceilometer_source_version: "{{ kolla_source_version }}"
|
||||
|
||||
ceilometer_custom_meters_local_folder: "meters.d"
|
||||
|
@ -12,7 +12,53 @@
|
||||
- item.value.enabled | bool
|
||||
with_dict: "{{ ceilometer_services }}"
|
||||
|
||||
- name: Check custom polling.yaml exists
|
||||
- name: Check if the folder for custom meter definitions exist
|
||||
local_action: stat path="{{ node_custom_config }}/ceilometer/{{ ceilometer_custom_meters_local_folder }}"
|
||||
register: ceilometer_custom_meters_folder
|
||||
|
||||
- name: Set variable that indicates if we have a folder for custom meter YAML files
|
||||
set_fact:
|
||||
custom_meter_folder_exist: "{{ ceilometer_custom_meters_folder.stat.exists and ceilometer_custom_meters_folder.stat.isdir }}"
|
||||
|
||||
- name: Find all *.yaml files in custom meter definitions folder (if the folder exist)
|
||||
local_action: find paths="{{ node_custom_config }}/ceilometer/{{ ceilometer_custom_meters_local_folder }}" patterns="*.yaml"
|
||||
register: ceilometer_custom_meters_folder_found_files
|
||||
when: custom_meter_folder_exist
|
||||
|
||||
- name: Set the variable that control the copy of custom meter definitions
|
||||
set_fact:
|
||||
should_copy_custom_meter_definitions: "{{ custom_meter_folder_exist and ceilometer_custom_meters_folder_found_files.matched > 0 }}"
|
||||
|
||||
- name: Create default folder for custom meter definitions
|
||||
file:
|
||||
path: "{{ node_config_directory }}/{{ item.key }}/meters.d"
|
||||
state: "directory"
|
||||
owner: "{{ config_owner_user }}"
|
||||
group: "{{ config_owner_group }}"
|
||||
mode: "0770"
|
||||
become: true
|
||||
with_dict: "{{ ceilometer_services }}"
|
||||
when:
|
||||
- should_copy_custom_meter_definitions
|
||||
- inventory_hostname in groups[item.value.group]
|
||||
- item.value.enabled | bool
|
||||
|
||||
- name: Copying custom meter definitions to Ceilometer
|
||||
copy:
|
||||
src: "{{ node_custom_config }}/ceilometer/{{ ceilometer_custom_meters_local_folder }}/"
|
||||
dest: "{{ node_config_directory }}/{{ item.key }}/meters.d"
|
||||
force: True
|
||||
mode: "0660"
|
||||
become: true
|
||||
when:
|
||||
- should_copy_custom_meter_definitions
|
||||
- inventory_hostname in groups[item.value.group]
|
||||
- item.value.enabled | bool
|
||||
with_dict: "{{ ceilometer_services }}"
|
||||
notify:
|
||||
- "Restart {{ item.key }} container"
|
||||
|
||||
- name: Check if custom polling.yaml exists
|
||||
local_action: stat path="{{ node_custom_config }}/ceilometer/polling.yaml"
|
||||
register: ceilometer_polling_file
|
||||
|
||||
|
@ -18,6 +18,12 @@
|
||||
"dest": "/etc/ceilometer/{{ ceilometer_policy_file }}",
|
||||
"owner": "ceilometer",
|
||||
"perm": "0600"
|
||||
}{% endif %}{% if should_copy_custom_meter_definitions %},
|
||||
{
|
||||
"source": "{{ container_config_directory }}/meters.d",
|
||||
"dest": "/etc/ceilometer/meters.d",
|
||||
"owner": "ceilometer",
|
||||
"perm": "0700"
|
||||
}{% endif %},
|
||||
{
|
||||
"source": "{{ container_config_directory }}/pipeline.yaml",
|
||||
|
@ -18,6 +18,12 @@
|
||||
"dest": "/etc/ceilometer/{{ ceilometer_policy_file }}",
|
||||
"owner": "ceilometer",
|
||||
"perm": "0600"
|
||||
}{% endif %}{% if should_copy_custom_meter_definitions %},
|
||||
{
|
||||
"source": "{{ container_config_directory }}/meters.d",
|
||||
"dest": "/etc/ceilometer/meters.d",
|
||||
"owner": "ceilometer",
|
||||
"perm": "0700"
|
||||
}{% endif %},
|
||||
{
|
||||
"source": "{{ container_config_directory }}/pipeline.yaml",
|
||||
|
@ -18,6 +18,12 @@
|
||||
"dest": "/etc/ceilometer/{{ ceilometer_policy_file }}",
|
||||
"owner": "ceilometer",
|
||||
"perm": "0600"
|
||||
}{% endif %}{% if should_copy_custom_meter_definitions %},
|
||||
{
|
||||
"source": "{{ container_config_directory }}/meters.d",
|
||||
"dest": "/etc/ceilometer/meters.d",
|
||||
"owner": "ceilometer",
|
||||
"perm": "0700"
|
||||
}{% endif %}
|
||||
],
|
||||
"permissions": [
|
||||
|
Loading…
Reference in New Issue
Block a user