From 45404d03c44a5b5f31102c445939b33f0ee8c8c2 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Fri, 2 May 2025 22:46:46 +0900 Subject: [PATCH] Support parameters to enable TLS prometheus scrape endpoints Depends-on: https://review.opendev.org/945437 Change-Id: Ie329defefcf4bd5f2068af342832bb5d8f9b944e --- manifests/agent/polling.pp | 20 +++++++++++++++++++ .../prometheus-tls-dde2d2c352dbb220.yaml | 9 +++++++++ spec/classes/ceilometer_agent_polling_spec.rb | 11 +++++++++- 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/prometheus-tls-dde2d2c352dbb220.yaml diff --git a/manifests/agent/polling.pp b/manifests/agent/polling.pp index f2b9b801..c01f1995 100644 --- a/manifests/agent/polling.pp +++ b/manifests/agent/polling.pp @@ -105,6 +105,20 @@ # metrics will be exposed. # 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*] # (Optional) List of directories with YAML files used to create pollsters. # Defaults to $facts['os_service_default']. @@ -138,6 +152,9 @@ class ceilometer::agent::polling ( $enable_notifications = $facts['os_service_default'], $enable_prometheus_exporter = $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'], # DEPRECATED PARAMETERS $tenant_name_discovery = undef, @@ -265,6 +282,9 @@ Use the identity_name_discovery parameter instead.") 'polling/enable_notifications': value => $enable_notifications; 'polling/enable_prometheus_exporter': value => $enable_prometheus_exporter; '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 { diff --git a/releasenotes/notes/prometheus-tls-dde2d2c352dbb220.yaml b/releasenotes/notes/prometheus-tls-dde2d2c352dbb220.yaml new file mode 100644 index 00000000..3e12a299 --- /dev/null +++ b/releasenotes/notes/prometheus-tls-dde2d2c352dbb220.yaml @@ -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`` diff --git a/spec/classes/ceilometer_agent_polling_spec.rb b/spec/classes/ceilometer_agent_polling_spec.rb index c1b58fc0..1e6d26c9 100644 --- a/spec/classes/ceilometer_agent_polling_spec.rb +++ b/spec/classes/ceilometer_agent_polling_spec.rb @@ -77,6 +77,9 @@ describe 'ceilometer::agent::polling' do it { should contain_ceilometer_config('polling/enable_notifications').with_value('') } it { should contain_ceilometer_config('polling/enable_prometheus_exporter').with_value('') } it { should contain_ceilometer_config('polling/prometheus_listen_addresses').with_value('') } + it { should contain_ceilometer_config('polling/prometheus_tls_enable').with_value('') } + it { should contain_ceilometer_config('polling/prometheus_tls_certfile').with_value('') } + it { should contain_ceilometer_config('polling/prometheus_tls_keyfile').with_value('') } it { should contain_ceilometer_config('polling/pollsters_definitions_dirs').with_value('') } it { should contain_ceilometer_config('polling/cfg_file').with_value('') } end @@ -110,11 +113,14 @@ describe 'ceilometer::agent::polling' do context 'when common parameters are set' do before do params.merge!( - :identity_name_discovery => true, + :identity_name_discovery => true, :ignore_disabled_projects => false, :enable_notifications => true, :enable_prometheus_exporter => false, :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'] ) 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_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_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( '/etc/ceilometer/pollsters.d,/etc/ceilometer/mypollsters.d') }