Support parameters to enable TLS prometheus scrape endpoints

Depends-on: https://review.opendev.org/945437
Change-Id: Ie329defefcf4bd5f2068af342832bb5d8f9b944e
This commit is contained in:
Takashi Kajinami
2025-05-02 22:46:46 +09:00
parent b0873d2cd9
commit 45404d03c4
3 changed files with 39 additions and 1 deletions

View File

@@ -105,6 +105,20 @@
# metrics will be exposed. # metrics will be exposed.
# Defaults to $facts['os_service_default']. # Defaults to $facts['os_service_default'].
# #
# [*prometheus_tls_enable*]
# (Optional) Whether it will expose tls metrics or not.
# Defaults to $facts['os_service_default'].
#
# [*prometheus_tls_certfile*]
# (Optional) The certificate file to allow this ceilometer to expose tls
# scrape endpoints.
# Defaults to $facts['os_service_default'].
#
# [*prometheus_tls_keyfile*]
# (Optional) The private key to allow this ceilometer to expose tls scrape
# endpoints.
# Defaults to $facts['os_service_default'].
#
# [*pollsters_definitions_dirs*] # [*pollsters_definitions_dirs*]
# (Optional) List of directories with YAML files used to create pollsters. # (Optional) List of directories with YAML files used to create pollsters.
# Defaults to $facts['os_service_default']. # Defaults to $facts['os_service_default'].
@@ -138,6 +152,9 @@ class ceilometer::agent::polling (
$enable_notifications = $facts['os_service_default'], $enable_notifications = $facts['os_service_default'],
$enable_prometheus_exporter = $facts['os_service_default'], $enable_prometheus_exporter = $facts['os_service_default'],
$prometheus_listen_addresses = $facts['os_service_default'], $prometheus_listen_addresses = $facts['os_service_default'],
$prometheus_tls_enable = $facts['os_service_default'],
$prometheus_tls_certfile = $facts['os_service_default'],
$prometheus_tls_keyfile = $facts['os_service_default'],
$pollsters_definitions_dirs = $facts['os_service_default'], $pollsters_definitions_dirs = $facts['os_service_default'],
# DEPRECATED PARAMETERS # DEPRECATED PARAMETERS
$tenant_name_discovery = undef, $tenant_name_discovery = undef,
@@ -265,6 +282,9 @@ Use the identity_name_discovery parameter instead.")
'polling/enable_notifications': value => $enable_notifications; 'polling/enable_notifications': value => $enable_notifications;
'polling/enable_prometheus_exporter': value => $enable_prometheus_exporter; 'polling/enable_prometheus_exporter': value => $enable_prometheus_exporter;
'polling/prometheus_listen_addresses': value => join(any2array($prometheus_listen_addresses), ','); 'polling/prometheus_listen_addresses': value => join(any2array($prometheus_listen_addresses), ',');
'polling/prometheus_tls_enable': value => $prometheus_tls_enable;
'polling/prometheus_tls_certfile': value => $prometheus_tls_certfile;
'polling/prometheus_tls_keyfile': value => $prometheus_tls_keyfile;
} }
if $manage_service { if $manage_service {

View File

@@ -0,0 +1,9 @@
---
features:
- |
The following parameters have been added to
the ``ceilometer::agent::polling`` class.
- ``prometheus_tls_enable``
- ``prometheus_tls_certfile``
- ``prometheus_tls_keyfile``

View File

@@ -77,6 +77,9 @@ describe 'ceilometer::agent::polling' do
it { should contain_ceilometer_config('polling/enable_notifications').with_value('<SERVICE DEFAULT>') } it { should contain_ceilometer_config('polling/enable_notifications').with_value('<SERVICE DEFAULT>') }
it { should contain_ceilometer_config('polling/enable_prometheus_exporter').with_value('<SERVICE DEFAULT>') } it { should contain_ceilometer_config('polling/enable_prometheus_exporter').with_value('<SERVICE DEFAULT>') }
it { should contain_ceilometer_config('polling/prometheus_listen_addresses').with_value('<SERVICE DEFAULT>') } it { should contain_ceilometer_config('polling/prometheus_listen_addresses').with_value('<SERVICE DEFAULT>') }
it { should contain_ceilometer_config('polling/prometheus_tls_enable').with_value('<SERVICE DEFAULT>') }
it { should contain_ceilometer_config('polling/prometheus_tls_certfile').with_value('<SERVICE DEFAULT>') }
it { should contain_ceilometer_config('polling/prometheus_tls_keyfile').with_value('<SERVICE DEFAULT>') }
it { should contain_ceilometer_config('polling/pollsters_definitions_dirs').with_value('<SERVICE DEFAULT>') } it { should contain_ceilometer_config('polling/pollsters_definitions_dirs').with_value('<SERVICE DEFAULT>') }
it { should contain_ceilometer_config('polling/cfg_file').with_value('<SERVICE DEFAULT>') } it { should contain_ceilometer_config('polling/cfg_file').with_value('<SERVICE DEFAULT>') }
end end
@@ -110,11 +113,14 @@ describe 'ceilometer::agent::polling' do
context 'when common parameters are set' do context 'when common parameters are set' do
before do before do
params.merge!( params.merge!(
:identity_name_discovery => true, :identity_name_discovery => true,
:ignore_disabled_projects => false, :ignore_disabled_projects => false,
:enable_notifications => true, :enable_notifications => true,
:enable_prometheus_exporter => false, :enable_prometheus_exporter => false,
:prometheus_listen_addresses => ['127.0.0.1:9101'], :prometheus_listen_addresses => ['127.0.0.1:9101'],
:prometheus_tls_enable => false,
:prometheus_tls_certfile => 'certfile',
:prometheus_tls_keyfile => 'keyfile',
:pollsters_definitions_dirs => ['/etc/ceilometer/pollsters.d', '/etc/ceilometer/mypollsters.d'] :pollsters_definitions_dirs => ['/etc/ceilometer/pollsters.d', '/etc/ceilometer/mypollsters.d']
) )
end end
@@ -125,6 +131,9 @@ describe 'ceilometer::agent::polling' do
should contain_ceilometer_config('polling/enable_notifications').with_value(true) should contain_ceilometer_config('polling/enable_notifications').with_value(true)
should contain_ceilometer_config('polling/enable_prometheus_exporter').with_value(false) should contain_ceilometer_config('polling/enable_prometheus_exporter').with_value(false)
should contain_ceilometer_config('polling/prometheus_listen_addresses').with_value('127.0.0.1:9101') should contain_ceilometer_config('polling/prometheus_listen_addresses').with_value('127.0.0.1:9101')
should contain_ceilometer_config('polling/prometheus_tls_enable').with_value(false)
should contain_ceilometer_config('polling/prometheus_tls_certfile').with_value('certfile')
should contain_ceilometer_config('polling/prometheus_tls_keyfile').with_value('keyfile')
should contain_ceilometer_config('polling/pollsters_definitions_dirs').with_value( should contain_ceilometer_config('polling/pollsters_definitions_dirs').with_value(
'/etc/ceilometer/pollsters.d,/etc/ceilometer/mypollsters.d') '/etc/ceilometer/pollsters.d,/etc/ceilometer/mypollsters.d')
} }