From da1fa3f5787f57f1d24604d592074c4b98073954 Mon Sep 17 00:00:00 2001 From: Doug Szumski Date: Tue, 17 Jul 2018 12:01:23 +0100 Subject: [PATCH] Support deploying Monasca Notification engine The Monasca Notification engine generates alerts such as Slack notifications from alerts. Change-Id: I84861d5feefe6b6f38acc4dd71e94c386d40b562 Partially-Implements: blueprint monasca-roles --- ansible/inventory/all-in-one | 3 +++ ansible/inventory/multinode | 3 +++ ansible/roles/monasca/defaults/main.yml | 15 +++++++++++ ansible/roles/monasca/handlers/main.yml | 20 +++++++++++++++ ansible/roles/monasca/tasks/config.yml | 20 +++++++++++++++ ansible/roles/monasca/tasks/deploy.yml | 6 +++-- .../monasca-notification.json.j2 | 18 +++++++++++++ .../monasca-notification/notification.conf.j2 | 25 +++++++++++++++++++ ...monasca-notification-03283c42a8df3d71.yaml | 7 ++++++ 9 files changed, 115 insertions(+), 2 deletions(-) create mode 100644 ansible/roles/monasca/templates/monasca-notification/monasca-notification.json.j2 create mode 100644 ansible/roles/monasca/templates/monasca-notification/notification.conf.j2 create mode 100644 releasenotes/notes/add-monasca-notification-03283c42a8df3d71.yaml diff --git a/ansible/inventory/all-in-one b/ansible/inventory/all-in-one index e72a49ddd5..10f2bfa2cb 100644 --- a/ansible/inventory/all-in-one +++ b/ansible/inventory/all-in-one @@ -464,6 +464,9 @@ monasca [monasca-thresh:children] monasca +[monasca-notification:children] +monasca + # Storm [storm-worker:children] storm diff --git a/ansible/inventory/multinode b/ansible/inventory/multinode index a7969b9342..b13725f3cd 100644 --- a/ansible/inventory/multinode +++ b/ansible/inventory/multinode @@ -473,6 +473,9 @@ monasca [monasca-thresh:children] monasca +[monasca-notification:children] +monasca + # Storm [storm-worker:children] storm diff --git a/ansible/roles/monasca/defaults/main.yml b/ansible/roles/monasca/defaults/main.yml index 547180e45d..7d3f013ba4 100644 --- a/ansible/roles/monasca/defaults/main.yml +++ b/ansible/roles/monasca/defaults/main.yml @@ -61,6 +61,16 @@ monasca_services: - "monasca_thresh:/var/lib/monasca-thresh/" - "kolla_logs:/var/log/kolla" dimensions: "{{ monasca_thresh_dimensions }}" + monasca-notification: + container_name: monasca_notification + group: monasca-notification + enabled: true + image: "{{ monasca_notification_image_full }}" + volumes: + - "{{ node_config_directory }}/monasca-notification/:{{ container_config_directory }}/:ro" + - "/etc/localtime:/etc/localtime:ro" + - "kolla_logs:/var/log/kolla" + dimensions: "{{ monasca_notification_dimensions }}" #################### # Databases @@ -119,12 +129,17 @@ monasca_thresh_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ monasca_thresh_tag: "{{ monasca_tag }}" monasca_thresh_image_full: "{{ monasca_thresh_image }}:{{ monasca_thresh_tag }}" +monasca_notification_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ monasca_install_type }}-monasca-notification" +monasca_notification_tag: "{{ monasca_tag }}" +monasca_notification_image_full: "{{ monasca_notification_image }}:{{ monasca_notification_tag }}" + monasca_api_dimensions: "{{ default_container_dimensions }}" monasca_log_api_dimensions: "{{ default_container_dimensions }}" monasca_log_transformer_dimensions: "{{ default_container_dimensions }}" monasca_log_persister_dimensions: "{{ default_container_dimensions }}" monasca_log_metrics_dimensions: "{{ default_container_dimensions }}" monasca_thresh_dimensions: "{{ default_container_dimensions }}" +monasca_notification_dimensions: "{{ default_container_dimensions }}" #################### diff --git a/ansible/roles/monasca/handlers/main.yml b/ansible/roles/monasca/handlers/main.yml index e02ad4aad1..97f8a0a122 100644 --- a/ansible/roles/monasca/handlers/main.yml +++ b/ansible/roles/monasca/handlers/main.yml @@ -130,3 +130,23 @@ or monasca_thresh_confs.changed | bool or monasca_thresh_storm_conf.changed | bool or monasca_thresh_container.changed | bool + +- name: Restart monasca-notification container + vars: + service_name: "monasca-notification" + service: "{{ monasca_services[service_name] }}" + config_json: "{{ monasca_config_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}" + monasca_notification_container: "{{ check_monasca_containers.results|selectattr('item.key', 'equalto', service_name)|first }}" + kolla_docker: + action: "recreate_or_restart_container" + common_options: "{{ docker_common_options }}" + name: "{{ service.container_name }}" + image: "{{ service.image }}" + volumes: "{{ service.volumes }}" + when: + - kolla_action != "config" + - inventory_hostname in groups[service.group] + - service.enabled | bool + - config_json.changed | bool + or monasca_notification_confs.changed | bool + or monasca_notification_container.changed | bool diff --git a/ansible/roles/monasca/tasks/config.yml b/ansible/roles/monasca/tasks/config.yml index dc070b4481..b28d444e1e 100644 --- a/ansible/roles/monasca/tasks/config.yml +++ b/ansible/roles/monasca/tasks/config.yml @@ -216,6 +216,26 @@ notify: - Restart monasca-thresh container +- name: Copying over monasca-notification config + vars: + service: "{{ monasca_services['monasca-notification'] }}" + merge_configs: + sources: + - "{{ role_path }}/templates/monasca-notification/{{ item }}.j2" + - "{{ node_custom_config }}/monasca/{{ item }}" + - "{{ node_custom_config }}/monasca/{{ inventory_hostname }}/{{ item }}" + dest: "{{ node_config_directory }}/monasca-notification/{{ item }}" + mode: "0660" + become: true + register: monasca_notification_confs + with_items: + - notification.conf + when: + - inventory_hostname in groups[service['group']] + - service.enabled | bool + notify: + - Restart monasca-notification container + - name: Check monasca containers become: true kolla_docker: diff --git a/ansible/roles/monasca/tasks/deploy.yml b/ansible/roles/monasca/tasks/deploy.yml index 3732a6418d..155175f620 100644 --- a/ansible/roles/monasca/tasks/deploy.yml +++ b/ansible/roles/monasca/tasks/deploy.yml @@ -9,7 +9,8 @@ inventory_hostname in groups['monasca-log-transformer'] or inventory_hostname in groups['monasca-log-persister'] or inventory_hostname in groups['monasca-log-metrics'] or - inventory_hostname in groups['monasca-thresh'] + inventory_hostname in groups['monasca-thresh'] or + inventory_hostname in groups['monasca-notification'] - include_tasks: bootstrap.yml when: inventory_hostname in groups['monasca-api'] @@ -23,4 +24,5 @@ inventory_hostname in groups['monasca-log-transformer'] or inventory_hostname in groups['monasca-log-persister'] or inventory_hostname in groups['monasca-log-metrics'] or - inventory_hostname in groups['monasca-thresh'] + inventory_hostname in groups['monasca-thresh'] or + inventory_hostname in groups['monasca-notification'] diff --git a/ansible/roles/monasca/templates/monasca-notification/monasca-notification.json.j2 b/ansible/roles/monasca/templates/monasca-notification/monasca-notification.json.j2 new file mode 100644 index 0000000000..329f10375e --- /dev/null +++ b/ansible/roles/monasca/templates/monasca-notification/monasca-notification.json.j2 @@ -0,0 +1,18 @@ +{ + "command": "monasca-notification /etc/monasca/notification.conf", + "config_files": [ + { + "source": "{{ container_config_directory }}/notification.conf", + "dest": "/etc/monasca/notification.conf", + "owner": "monasca", + "perm": "0600" + } + ], + "permissions": [ + { + "path": "/var/log/kolla/monasca", + "owner": "monasca:kolla", + "recurse": true + } + ] +} diff --git a/ansible/roles/monasca/templates/monasca-notification/notification.conf.j2 b/ansible/roles/monasca/templates/monasca-notification/notification.conf.j2 new file mode 100644 index 0000000000..9e7d7d3b80 --- /dev/null +++ b/ansible/roles/monasca/templates/monasca-notification/notification.conf.j2 @@ -0,0 +1,25 @@ +[DEFAULT] +log_file = monasca-notification.log +log_dir = /var/log/kolla/monasca +debug = {{ monasca_logging_debug }} + +[kafka] +url = {{ monasca_kafka_servers }} +alarm_topic = {{ monasca_alarm_state_transitions_topic }} +notification_topic = {{ monasca_alarm_notifications_topic }} +notification_retry_topic = {{ monasca_alarm_notifications_retry_topic }} +periodic = {{ monasca_periodic_notifications_period }}:{{ monasca_periodic_notifications_topic }} + +[mysql] +host = {{ database_address }} +port = {{ database_port }} +user = {{ monasca_database_user }} +passwd = {{ monasca_database_password }} +db = {{ monasca_database_name }} + +[statsd] +# TODO(dszumski): Enable when statsd is deployed +enable = false + +[zookeeper] +url = {{ monasca_zookeeper_servers }} diff --git a/releasenotes/notes/add-monasca-notification-03283c42a8df3d71.yaml b/releasenotes/notes/add-monasca-notification-03283c42a8df3d71.yaml new file mode 100644 index 0000000000..aab4c19bdd --- /dev/null +++ b/releasenotes/notes/add-monasca-notification-03283c42a8df3d71.yaml @@ -0,0 +1,7 @@ +--- +features: + - | + Add support for deploying the Monasca Notification service. The + Notification service is responsible for notifiying users when + an alert, as defined via the Monasca API, is generated by the + Monasca Thresh topology.