diff --git a/manifests/profile/base/metrics/collectd.pp b/manifests/profile/base/metrics/collectd.pp index 088e6e2b1..29fb96854 100644 --- a/manifests/profile/base/metrics/collectd.pp +++ b/manifests/profile/base/metrics/collectd.pp @@ -47,6 +47,92 @@ # [*collectd_securitylevel*] # (Optional) String. # +# [*gnocchi_auth_mode*] +# (Optional) String. Type of authentication Gnocchi server is using. +# Supported values are 'simple' and 'keystone'. +# Defaults to 'simple' +# +# [*gnocchi_protocol*] +# (Optional) String. API protocol Gnocchi server is using. +# Defaults to 'http' +# +# [*gnocchi_server*] +# (Optional) String. The name or address of a gnocchi endpoint to +# which we should send metrics. +# Defaults to undef +# +# [*gnocchi_port*] +# (Optional) Integer. The port to which we will connect on the +# Gnocchi server. +# Defaults to 8041 +# +# [*gnocchi_user*] +# (Optional) String. Username for authenticating to the remote +# Gnocchi server using simple authentication. +# Defaults to undef +# +# [*gnocchi_keystone_auth_url*] +# (Optional) String. Keystone endpoint URL to authenticate to. +# Defaults to undef +# +# [*gnocchi_keystone_user_name*] +# (Optional) String. Username for authenticating to Keystone. +# Defaults to undef +# +# [*gnocchi_keystone_user_id*] +# (Optional) String. User ID for authenticating to Keystone. +# Defaults to undef +# +# [*gnocchi_keystone_password*] +# (Optional) String. Password for authenticating to Keystone +# Defaults to undef +# +# [*gnocchi_keystone_project_id*] +# (Optional) String. Project ID for authenticating to Keystone. +# Defaults to undef +# +# [*gnocchi_keystone_project_name*] +# (Optional) String. Project name for authenticating to Keystone. +# Defaults to undef +# +# [*gnocchi_keystone_user_domain_id*] +# (Optional) String. User domain ID for authenticating to Keystone. +# Defaults to undef +# +# [*gnocchi_keystone_user_domain_name*] +# (Optional) String. User domain name for authenticating to Keystone. +# Defaults to undef +# +# [*gnocchi_keystone_project_domain_id*] +# (Optional) String. Project domain ID for authenticating to Keystone. +# Defaults to undef +# +# [*gnocchi_keystone_project_domain_name*] +# (Optional) String. Project domain name for authenticating to Keystone. +# Defaults to undef +# +# [*gnocchi_keystone_region_name*] +# (Optional) String. Region name for authenticating to Keystone. +# Defaults to undef +# +# [*gnocchi_keystone_interface*] +# (Optional) String. Type of Keystone endpoint to authenticate to. +# Defaults to undef +# +# [*gnocchi_keystone_endpoint*] +# (Optional) String. Explicitly state Gnocchi server URL if you want +# to override Keystone value +# Defaults to undef +# +# [*gnocchi_resource_type*] +# (Optional) String. Default resource type created by the collectd-gnocchi +# plugin in Gnocchi to store hosts. +# Defaults to 'collectd' +# +# [*gnocchi_batch_size*] +# (Optional) String. Minimum number of values Gnocchi should batch. +# Defaults to 10 +# # [*service_names*] # (Optional) List of strings. A list of active services in this tripleo # deployment. This is used to look up service-specific plugins that @@ -60,6 +146,26 @@ class tripleo::profile::base::metrics::collectd ( $collectd_username = undef, $collectd_password = undef, $collectd_securitylevel = undef, + $gnocchi_auth_mode = 'simple', + $gnocchi_protocol = 'http', + $gnocchi_server = undef, + $gnocchi_port = 8041, + $gnocchi_user = undef, + $gnocchi_keystone_auth_url = undef, + $gnocchi_keystone_user_name = undef, + $gnocchi_keystone_user_id = undef, + $gnocchi_keystone_password = undef, + $gnocchi_keystone_project_id = undef, + $gnocchi_keystone_project_name = undef, + $gnocchi_keystone_user_domain_id = undef, + $gnocchi_keystone_user_domain_name = undef, + $gnocchi_keystone_project_domain_id = undef, + $gnocchi_keystone_project_domain_name = undef, + $gnocchi_keystone_region_name = undef, + $gnocchi_keystone_interface = undef, + $gnocchi_keystone_endpoint = undef, + $gnocchi_resource_type = 'collectd', + $gnocchi_batch_size = 10, $service_names = hiera('service_names', []) ) { if $step >= 3 { @@ -107,6 +213,34 @@ class tripleo::profile::base::metrics::collectd ( port => $_collectd_port, securitylevel => $_collectd_securitylevel, } + } elsif !empty($gnocchi_server) or !empty($gnocchi_keystone_auth_url) { + if !empty($gnocchi_server) { + $gci_server = $gnocchi_server + } else { + $gci_server = $gnocchi_keystone_auth_url + } + ::tripleo::profile::base::metrics::collectd::gnocchi { $gci_server: + auth_mode => $gnocchi_auth_mode, + protocol => $gnocchi_protocol, + server => $gnocchi_server, + port => $gnocchi_port, + user => $gnocchi_user, + keystone_auth_url => $gnocchi_keystone_auth_url, + keystone_user_name => $gnocchi_keystone_user_name, + keystone_user_id => $gnocchi_keystone_user_id, + keystone_password => $gnocchi_keystone_password, + keystone_project_id => $gnocchi_keystone_project_id, + keystone_project_name => $gnocchi_keystone_project_name, + keystone_user_domain_id => $gnocchi_keystone_user_domain_id, + keystone_user_domain_name => $gnocchi_keystone_user_domain_name, + keystone_project_domain_id => $gnocchi_keystone_project_domain_id, + keystone_project_domain_name => $gnocchi_keystone_project_domain_name, + keystone_region_name => $gnocchi_keystone_region_name, + keystone_interface => $gnocchi_keystone_interface, + keystone_endpoint => $gnocchi_keystone_endpoint, + resource_type => $gnocchi_resource_type, + batch_size => $gnocchi_batch_size, + } } } } diff --git a/manifests/profile/base/metrics/collectd/gnocchi.pp b/manifests/profile/base/metrics/collectd/gnocchi.pp new file mode 100644 index 000000000..c4a0fd2e3 --- /dev/null +++ b/manifests/profile/base/metrics/collectd/gnocchi.pp @@ -0,0 +1,152 @@ +# Copyright 2017 Red Hat, 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. +# +# == Define: tripleo::profile::base::metrics::collectd::gnocchi +# +# This is used to create configuration file for collectd-gnocchi plugin +# +# === Parameters +# +# [*ensure*] +# (Optional) String. Action to perform with gnocchi plugin +# configuration file. +# Defaults to 'present' +# +# [*order*] +# (Optional) String. Prefix for gnocchi plugin configuration file. +# Defaults to '00' +# +# [*auth_mode*] +# (Optional) String. Type of authentication Gnocchi server is using. +# Supported values are 'simple' and 'keystone'. +# Defaults to 'simple' +# +# [*protocol*] +# (Optional) String. API protocol Gnocchi server is using. +# Defaults to 'http' +# +# [*server*] +# (Optional) String. The name or address of a gnocchi endpoint to +# which we should send metrics. +# Defaults to undef +# +# [*port*] +# (Optional) Integer. The port to which we will connect on the +# Gnocchi server. +# Defaults to 8041 +# +# [*user*] +# (Optional) String. Username for authenticating to the remote +# Gnocchi server using simple authentication. +# Defaults to undef +# +# [*keystone_auth_url*] +# (Optional) String. Keystone endpoint URL to authenticate to. +# Defaults to undef +# +# [*keystone_user_name*] +# (Optional) String. Username for authenticating to Keystone. +# Defaults to undef +# +# [*keystone_user_id*] +# (Optional) String. User ID for authenticating to Keystone. +# Defaults to undef +# +# [*keystone_password*] +# (Optional) String. Password for authenticating to Keystone +# Defaults to undef +# +# [*keystone_project_id*] +# (Optional) String. Project ID for authenticating to Keystone. +# Defaults to undef +# +# [*keystone_project_name*] +# (Optional) String. Project name for authenticating to Keystone. +# Defaults to undef +# +# [*keystone_user_domain_id*] +# (Optional) String. User domain ID for authenticating to Keystone. +# Defaults to undef +# +# [*keystone_user_domain_name*] +# (Optional) String. User domain name for authenticating to Keystone. +# Defaults to undef +# +# [*keystone_project_domain_id*] +# (Optional) String. Project domain ID for authenticating to Keystone. +# Defaults to undef +# +# [*keystone_project_domain_name*] +# (Optional) String. Project domain name for authenticating to Keystone. +# Defaults to undef +# +# [*keystone_region_name*] +# (Optional) String. Region name for authenticating to Keystone. +# Defaults to undef +# +# [*keystone_interface*] +# (Optional) String. Type of Keystone endpoint to authenticate to. +# Defaults to undef +# +# [*keystone_endpoint*] +# (Optional) String. Explicitly state Gnocchi server URL if you want +# to override Keystone value +# Defaults to undef +# +# [*resource_type*] +# (Optional) String. Default resource type created by the collectd-gnocchi +# plugin in Gnocchi to store hosts. +# Defaults to 'collectd' +# +# [*batch_size*] +# (Optional) String. Minimum number of values Gnocchi should batch. +# Defaults to 10 +# +define tripleo::profile::base::metrics::collectd::gnocchi ( + $ensure = 'present', + $order = '00', + $auth_mode = 'simple', + $protocol = 'http', + $server = undef, + $port = undef, + $user = undef, + $keystone_auth_url = undef, + $keystone_user_name = undef, + $keystone_user_id = undef, + $keystone_password = undef, + $keystone_project_id = undef, + $keystone_project_name = undef, + $keystone_user_domain_id = undef, + $keystone_user_domain_name = undef, + $keystone_project_domain_id = undef, + $keystone_project_domain_name = undef, + $keystone_region_name = undef, + $keystone_interface = undef, + $keystone_endpoint = undef, + $resource_type = 'collectd', + $batch_size = 10, +) { + include ::collectd + + package { ['python-collectd-gnocchi', 'collectd-python']: + ensure => $ensure, + } + + collectd::plugin { 'python': + ensure => $ensure, + order => $order, + content => template('tripleo/collectd/collectd-gnocchi.conf.erb'), + require => Package['python-collectd-gnocchi'] + } +} diff --git a/templates/collectd/collectd-gnocchi.conf.erb b/templates/collectd/collectd-gnocchi.conf.erb new file mode 100644 index 000000000..4dd3d33ca --- /dev/null +++ b/templates/collectd/collectd-gnocchi.conf.erb @@ -0,0 +1,62 @@ + + Import "collectd_gnocchi" + +<%- if @auth_mode == 'simple' %> + ### Basic authentication + Endpoint "<%= @protocol %>://<%= @server %>:<%= @port %>" + <%- if @user %> + User "<%= @user %>" + <%- end -%> +<%- elsif @auth_mode == 'keystone' %> + ### Keystone authentication + Auth_Mode "keystone" + Auth_Url "<%= @keystone_auth_url %>" + <%- if @keystone_user_name %> + Username "<%= @keystone_user_name %>" + <%- end -%> + <%- if @keystone_user_id %> + User_Id "<%= @keystone_user_id %>" + <%- end -%> + <%- if @keystone_project_id %> + Project_Id "<%= @keystone_project_id %>" + <%- end -%> + <%- if @keystone_project_name %> + Project_Name "<%= @keystone_project_name %>" + <%- end -%> + <%- if @keystone_password %> + Password "<%= @keystone_password %>" + <%- end -%> + <%- if @keystone_user_domain_id %> + User_Domain_Id "<%= @keystone_user_domain_id %>" + <%- end -%> + <%- if @keystone_user_domain_name %> + User_Domain_Name "<%= @keystone_user_domain_name %>" + <%- end -%> + <%- if @keystone_project_domain_id %> + Project_Domain_Id "<%= @keystone_project_domain_id %>" + <%- end -%> + <%- if @keystone_project_domain_name %> + Project_Domain_Name "<%= @keystone_project_domain_name %>" + <%- end -%> + <%- if @keystone_region_name %> + Region_Name "<%= @keystone_region_name %>" + <%- end -%> + <%- if @keystone_interface %> + Interface "<%= @keystone_interface %>" + <%- end -%> + <%- if @keystone_endpoint %> + Endpoint "<%= @keystone_endpoint %>" + <%- end -%> +<%- end -%> + +<%- if @resource_type %> + ## Default resource type created by the plugin in Gnocchi + ## to store hosts + ResourceType "<%= @resource_type %>" +<%- end -%> +<%- if @batch_size %> + ## Minimum number of values to batch + BatchSize <%= @batch_size %> +<%- end -%> + +