From fd3afadf28bbd19b3e8d257463f3a7f6d62a577c Mon Sep 17 00:00:00 2001 From: Lennart Betz Date: Sun, 5 Mar 2023 09:13:15 +0100 Subject: [PATCH] Add missing parameters to graphite module class --- manifests/module/graphite.pp | 38 ++++++++++++++++++++++++++++++++++- spec/classes/graphite_spec.rb | 17 ++++++++++++++-- 2 files changed, 52 insertions(+), 3 deletions(-) diff --git a/manifests/module/graphite.pp b/manifests/module/graphite.pp index 80500f5d..655f99dd 100644 --- a/manifests/module/graphite.pp +++ b/manifests/module/graphite.pp @@ -24,6 +24,9 @@ # @param url # URL to your Graphite Web/API. # +# @param insecure +# Do not verify the TLS certificate. +# # @param user # A user with access to your Graphite Web via HTTP basic authentication. # @@ -36,6 +39,18 @@ # @param graphite_writer_service_name_template # The value of your icinga 2 GraphiteWriter's attribute `service_name_template` (if specified). # +# @param customvar_obscured_check_command +# The Icinga custom variable with the `actual` check command obscured by e.g. check_by_ssh. +# +# @param default_time_range_unit +# Set unit for the time range. +# +# @param default_time_range +# Set the displayed time range. +# +# @param disable_no_graphs +# Do not display empty graphs. +# # @note Here the official [Graphite module documentation](https://www.icinga.com/docs/graphite/latest/) can be found. # # @example @@ -52,10 +67,18 @@ Enum['git', 'none', 'package'] $install_method = 'git', String $package_name = 'icingaweb2-module-graphite', Optional[String] $url = undef, + Optional[Boolean] $insecure = undef, Optional[String] $user = undef, Optional[Icingaweb2::Secret] $password = undef, Optional[String] $graphite_writer_host_name_template = undef, - Optional[String] $graphite_writer_service_name_template = undef + Optional[String] $graphite_writer_service_name_template = undef, + Optional[String] $customvar_obscured_check_command = undef, + Optional[Enum[ + 'minutes', 'hours', 'days', + 'weeks', 'months', 'years' + ]] $default_time_range_unit = undef, + Optional[Integer[1]] $default_time_range = undef, + Optional[Boolean] $disable_no_graphs = undef, ) { icingaweb2::assert_module() @@ -66,11 +89,19 @@ 'url' => $url, 'user' => $user, 'password' => icingaweb2::unwrap($password), + 'insecure' => $insecure, } $icinga_settings = { 'graphite_writer_host_name_template' => $graphite_writer_host_name_template, 'graphite_writer_service_name_template' => $graphite_writer_service_name_template, + 'customvar_obscured_check_command' => $customvar_obscured_check_command, + } + + $ui_settings = { + 'default_time_range' => $default_time_range, + 'default_time_range_unit' => $default_time_range_unit, + 'disable_no_graphs_found' => $disable_no_graphs, } $settings = { @@ -84,6 +115,11 @@ 'target' => "${module_conf_dir}/config.ini", 'settings' => delete_undef_values($icinga_settings), }, + 'module-graphite-ui' => { + 'section_name' => 'ui', + 'target' => "${module_conf_dir}/config.ini", + 'settings' => delete_undef_values($ui_settings), + }, } icingaweb2::module { 'graphite': diff --git a/spec/classes/graphite_spec.rb b/spec/classes/graphite_spec.rb index 114e9e0f..242e751d 100644 --- a/spec/classes/graphite_spec.rb +++ b/spec/classes/graphite_spec.rb @@ -35,10 +35,15 @@ { git_revision: 'v0.9.0', url: 'http://localhost', + insecure: false, user: 'foo', password: 'bar', graphite_writer_host_name_template: 'foobar', graphite_writer_service_name_template: 'barfoo', + customvar_obscured_check_command: 'baz', + default_time_range: 10, + default_time_range_unit: 'hours', + disable_no_graphs: true, } end @@ -52,7 +57,14 @@ is_expected.to contain_icingaweb2__inisection('module-graphite-graphite') .with_section_name('graphite') .with_target('/etc/icingaweb2/modules/graphite/config.ini') - .with_settings('url' => 'http://localhost', 'user' => 'foo', 'password' => 'bar') + .with_settings('url' => 'http://localhost', 'insecure' => false, 'user' => 'foo', 'password' => 'bar') + } + + it { + is_expected.to contain_icingaweb2__inisection('module-graphite-ui') + .with_section_name('ui') + .with_target('/etc/icingaweb2/modules/graphite/config.ini') + .with_settings('default_time_range' => 10, 'default_time_range_unit' => 'hours', 'disable_no_graphs_found' => true) } it { @@ -60,7 +72,8 @@ .with_section_name('icinga') .with_target('/etc/icingaweb2/modules/graphite/config.ini') .with_settings('graphite_writer_host_name_template' => 'foobar', - 'graphite_writer_service_name_template' => 'barfoo') + 'graphite_writer_service_name_template' => 'barfoo', + 'customvar_obscured_check_command' => 'baz') } end end