[Vitrage] Add Prometheus datasource configuration

Vitrage supports new Prometheus configuration now [1].
Kolla should allow user to configure this configuration
file.

[1] https://review.openstack.org/#/c/630514/

Change-Id: I84072d90b0342c6d460ee733ba646a5fb787faa9
This commit is contained in:
Kien Nguyen 2019-01-24 17:38:13 +07:00
parent 4a127d4bd9
commit f77c67fa0e
5 changed files with 42 additions and 5 deletions

View File

@ -57,6 +57,7 @@
vitrage_conf: "{{ vitrage_confs.results|selectattr('item.key', 'equalto', service_name)|first }}"
policy_overwriting: "{{ vitrage_policy_overwriting.results|selectattr('item.key', 'equalto', service_name)|first }}"
vitrage_graph_container: "{{ check_vitrage_containers.results|selectattr('item.key', 'equalto', service_name)|first }}"
vitrage_prometheus_conf: "{{ vitrage_prometheus_conf.results|selectattr('item.key', 'equalto', service_name)|first }}"
become: true
kolla_docker:
action: "recreate_or_restart_container"
@ -73,6 +74,7 @@
or vitrage_conf.changed | bool
or policy_overwriting.changed | bool
or vitrage_graph_container.changed | bool
or vitrage_prometheus_conf.changed | bool
- name: Restart vitrage-ml container
vars:

View File

@ -33,7 +33,7 @@
template:
src: "{{ item.key }}.json.j2"
dest: "{{ node_config_directory }}/{{ item.key }}/config.json"
mode: "0770"
mode: "0660"
become: true
register: vitrage_config_jsons
when:
@ -58,7 +58,7 @@
- "{{ node_config_directory }}/config/vitrage/{{ item.key }}.conf"
- "{{ node_config_directory }}/config/vitrage/{{ inventory_hostname }}/vitrage.conf"
dest: "{{ node_config_directory }}/{{ item.key }}/vitrage.conf"
mode: "0770"
mode: "0660"
become: true
register: vitrage_confs
when:
@ -75,18 +75,34 @@
template:
src: "wsgi-vitrage.conf.j2"
dest: "{{ node_config_directory }}/{{ item }}/wsgi-vitrage.conf"
mode: "0770"
mode: "0660"
become: true
with_items:
- "vitrage-api"
notify:
- Restart vitrage-api container
- name: Copying over prometheus_conf.yml file for service
vars:
service: "{{ vitrage_services['vitrage-graph'] }}"
template:
src: "{{ node_custom_config }}/vitrage/prometheus_conf.yaml"
dest: "{{ node_config_directory }}/vitrage-graph/prometheus_conf.yaml"
mode: "0660"
become: true
register: vitrage_prometheus_conf
when:
- enable_vitrage_prometheus_datasource | bool
- inventory_hostname in groups[service.group]
- service.enabled | bool
notify:
- Restart vitrage-graph container
- name: Copying over existing policy file
template:
src: "{{ vitrage_policy_file_path }}"
dest: "{{ node_config_directory }}/{{ item.key }}/{{ vitrage_policy_file }}"
mode: "0770"
mode: "0660"
become: true
register: vitrage_policy_overwriting
when:

View File

@ -14,3 +14,11 @@
when:
- container_facts['vitrage_api'] is not defined
- inventory_hostname in groups['vitrage-api']
- name: Checking custom prometheus_conf.yaml exists
local_action: stat_path="{{ node_custom_config }}/vitrage/prometheus_conf.yaml"
register: result
run_once: true
failed_when: not result.stat.exists
when:
- enable_vitrage_prometheus_datasource | bool

View File

@ -6,7 +6,13 @@
"dest": "/etc/vitrage/vitrage.conf",
"owner": "vitrage",
"perm": "0644"
}{% if vitrage_policy_file is defined %},
}{% if enable_vitrage_prometheus_datasource | bool %},
{
"source": "{{ container_config_directory }}/prometheus_conf.yaml",
"dest": "/etc/vitrage/prometheus_conf.yaml",
"owner": "vitrage",
"perm": "0644"
}{% endif %}{% if vitrage_policy_file is defined %},
{
"source": "{{ container_config_directory }}/{{ vitrage_policy_file }}",
"dest": "/etc/vitrage/{{ vitrage_policy_file }}",

View File

@ -82,3 +82,8 @@ trace_sqlalchemy = true
hmac_keys = {{ osprofiler_secret }}
connection_string = {{ osprofiler_backend_connection_string }}
{% endif %}
{% if enable_vitrage_prometheus_datasource | bool %}
[prometheus]
config_file = /etc/vitrage/prometheus_conf.yaml
{% endif %}