diff --git a/ansible/roles/vitrage/handlers/main.yml b/ansible/roles/vitrage/handlers/main.yml index 06ddd25a11..5cbb6d0562 100644 --- a/ansible/roles/vitrage/handlers/main.yml +++ b/ansible/roles/vitrage/handlers/main.yml @@ -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: diff --git a/ansible/roles/vitrage/tasks/config.yml b/ansible/roles/vitrage/tasks/config.yml index 42c739af11..07ff0de082 100644 --- a/ansible/roles/vitrage/tasks/config.yml +++ b/ansible/roles/vitrage/tasks/config.yml @@ -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: diff --git a/ansible/roles/vitrage/tasks/precheck.yml b/ansible/roles/vitrage/tasks/precheck.yml index e91ab4d8d8..63f52c2e7c 100644 --- a/ansible/roles/vitrage/tasks/precheck.yml +++ b/ansible/roles/vitrage/tasks/precheck.yml @@ -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 diff --git a/ansible/roles/vitrage/templates/vitrage-graph.json.j2 b/ansible/roles/vitrage/templates/vitrage-graph.json.j2 index 9f576f3e77..59b350712e 100644 --- a/ansible/roles/vitrage/templates/vitrage-graph.json.j2 +++ b/ansible/roles/vitrage/templates/vitrage-graph.json.j2 @@ -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 }}", diff --git a/ansible/roles/vitrage/templates/vitrage.conf.j2 b/ansible/roles/vitrage/templates/vitrage.conf.j2 index dd87af560c..def9f284e0 100644 --- a/ansible/roles/vitrage/templates/vitrage.conf.j2 +++ b/ansible/roles/vitrage/templates/vitrage.conf.j2 @@ -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 %}