From 80e719a5976da5443c38cb4e72ad47d64b92c1e9 Mon Sep 17 00:00:00 2001 From: Simon Pasquier Date: Tue, 12 Jan 2016 11:08:17 +0100 Subject: [PATCH] Notify the Nagios URL to the Fuel API Once the plugin deployment has completed, it uses the Fuel API to register the Nagios URL. The end-users will get the information in the Fuel UI. This change also introduces the use of the primary role since only one node should be responsible for notifying the Fuel API. Change-Id: Ie5c2495b5bcbce4aec3d5dd2cae247884b231efe --- deployment_scripts/puppet/manifests/hiera.pp | 1 + .../puppet/manifests/nagios_dashboard_url.pp | 29 +++++++++++++++++++ deployment_tasks.yaml | 24 ++++++++++----- network_roles.yaml | 1 + node_roles.yaml | 2 +- tasks.yaml | 12 ++++++-- 6 files changed, 59 insertions(+), 10 deletions(-) create mode 100644 deployment_scripts/puppet/manifests/nagios_dashboard_url.pp diff --git a/deployment_scripts/puppet/manifests/hiera.pp b/deployment_scripts/puppet/manifests/hiera.pp index dd3ce46..3a1e687 100644 --- a/deployment_scripts/puppet/manifests/hiera.pp +++ b/deployment_scripts/puppet/manifests/hiera.pp @@ -21,6 +21,7 @@ $calculated_content = inline_template(' --- lma::corosync_roles: - infrastructure_alerting + - primary-infrastructure_alerting lma::infrastructure_alerting::vip: <%= @alerting_vip %> lma::infrastructure_alerting::vip_ns: infrastructure_alerting ') diff --git a/deployment_scripts/puppet/manifests/nagios_dashboard_url.pp b/deployment_scripts/puppet/manifests/nagios_dashboard_url.pp new file mode 100644 index 0000000..19e7ef5 --- /dev/null +++ b/deployment_scripts/puppet/manifests/nagios_dashboard_url.pp @@ -0,0 +1,29 @@ +# Copyright 2016 Mirantis, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +$deployment_id = hiera('deployment_id') +$master_ip = hiera('master_ip') +$vip = hiera('lma::infrastructure_alerting::vip') +$nagios_link_data = "{\"title\":\"Nagios\",\ +\"description\":\"Dashboard for visualizing alerts\",\ +\"url\":\"http://${vip}:8001/\"}" +$nagios_link_created_file = '/var/cache/nagios_link_created' + +exec { 'notify_nagios_url': + creates => $nagios_link_created_file, + command => "/usr/bin/curl -sL -w \"%{http_code}\" \ +-H 'Content-Type: application/json' -X POST -d '${nagios_link_data}' \ +http://${master_ip}:8000/api/clusters/${deployment_id}/plugin_links \ +-o /dev/null | /bin/grep 201 && /usr/bin/touch ${nagios_link_created_file}", +} diff --git a/deployment_tasks.yaml b/deployment_tasks.yaml index c942337..ce5bbf5 100644 --- a/deployment_tasks.yaml +++ b/deployment_tasks.yaml @@ -1,7 +1,7 @@ -- id: infrastructure_alerting +- id: primary-infrastructure_alerting type: group - role: [infrastructure_alerting] - tasks: + role: [primary-infrastructure_alerting] + tasks: &common_tasks - fuel_pkgs - hiera - globals @@ -15,9 +15,19 @@ strategy: type: one_by_one +- id: infrastructure_alerting + type: group + role: [infrastructure_alerting] + tasks: *common_tasks + required_for: [deploy_end] + requires: [deploy_start, primary-infrastructure_alerting] + parameters: + strategy: + type: parallel + - id: lma-alerting-hiera type: puppet - groups: [infrastructure_alerting] + groups: [primary-infrastructure_alerting, infrastructure_alerting] requires: [globals] required_for: [deploy_end] parameters: @@ -27,7 +37,7 @@ - id: lma-alerting-firewall type: puppet - groups: [infrastructure_alerting] + groups: [primary-infrastructure_alerting, infrastructure_alerting] requires: [netconfig] required_for: [deploy_end] parameters: @@ -37,7 +47,7 @@ - id: lma-alerting-cluster type: puppet - groups: [infrastructure_alerting] + groups: [primary-infrastructure_alerting, infrastructure_alerting] requires: [lma-alerting-firewall, lma-alerting-hiera] required_for: [deploy_end] parameters: @@ -49,7 +59,7 @@ - id: lma-alerting-vip type: puppet - groups: [infrastructure_alerting] + groups: [primary-infrastructure_alerting, infrastructure_alerting] requires: [lma-alerting-cluster] required_for: [deploy_end] parameters: diff --git a/network_roles.yaml b/network_roles.yaml index 45ec660..24c729a 100644 --- a/network_roles.yaml +++ b/network_roles.yaml @@ -8,4 +8,5 @@ namespace: "infrastructure_alerting" alias: "infrastructure_alerting" node_roles: + - "primary-infrastructure_alerting" - "infrastructure_alerting" diff --git a/node_roles.yaml b/node_roles.yaml index b5d5568..e33ef39 100644 --- a/node_roles.yaml +++ b/node_roles.yaml @@ -1,7 +1,7 @@ infrastructure_alerting: name: 'LMA Infrastructure Alerting' description: 'Install services for the infrastructure alerting' - has_primary: false + has_primary: true public_ip_required: false weight: 100 limits: diff --git a/tasks.yaml b/tasks.yaml index c909d69..f175e2b 100644 --- a/tasks.yaml +++ b/tasks.yaml @@ -1,7 +1,7 @@ # The following tasks are executed in the order they are declared # Priorities are important, this ensure that this plugin is deployed after # LMA Collector, InfluxDB and Elasticsearch. -- role: [infrastructure_alerting] +- role: [primary-infrastructure_alerting, infrastructure_alerting] stage: post_deployment/8101 type: puppet parameters: @@ -9,10 +9,18 @@ puppet_modules: puppet/modules timeout: 600 -- role: [infrastructure_alerting] +- role: [primary-infrastructure_alerting, infrastructure_alerting] stage: post_deployment/8101 type: puppet parameters: puppet_manifest: puppet/manifests/ha_services.pp puppet_modules: puppet/modules timeout: 600 + +- role: [primary-infrastructure_alerting] + stage: post_deployment/8101 + type: puppet + parameters: + puppet_manifest: puppet/manifests/nagios_dashboard_url.pp + puppet_modules: puppet/modules + timeout: 120