Add parameters to customize config file paths

... and also set the cfg_file options to ensure that the generated
files are used.

Change-Id: I228647f8f4ab36d9affac25c36cc2aeacbf36781
This commit is contained in:
Takashi Kajinami 2024-04-25 14:50:36 +09:00
parent 4a252aafcf
commit 94cc530955
5 changed files with 94 additions and 9 deletions

View File

@ -78,6 +78,11 @@
# for alarms. # for alarms.
# Defaults to ['gnocchi://'], # Defaults to ['gnocchi://'],
# #
# [*event_pipeline_cfg_file*]
# (Optional) Configuration file for event pipeline definition. This parameter
# has no effect when manage_event_pipeline is true.
# Defaults to $facts['os_service_default'].
#
# [*manage_pipeline*] # [*manage_pipeline*]
# (Optional) Whether to manage pipeline.yaml # (Optional) Whether to manage pipeline.yaml
# Defaults to false # Defaults to false
@ -93,6 +98,11 @@
# Defaults to ['gnocchi://'], If you are using collector # Defaults to ['gnocchi://'], If you are using collector
# override this to notifier:// instead. # override this to notifier:// instead.
# #
# [*pipeline_cfg_file*]
# (Optional) Configuration file for pipeline definition. This parameter has
# no effect when manage_pipeline is true.
# Defaults to $facts['os_service_default'].
#
class ceilometer::agent::notification ( class ceilometer::agent::notification (
Boolean $manage_service = true, Boolean $manage_service = true,
Boolean $enabled = true, Boolean $enabled = true,
@ -104,11 +114,13 @@ class ceilometer::agent::notification (
$batch_timeout = $facts['os_service_default'], $batch_timeout = $facts['os_service_default'],
$package_ensure = 'present', $package_ensure = 'present',
Boolean $manage_event_pipeline = false, Boolean $manage_event_pipeline = false,
Array[String[1]] $event_pipeline_publishers = ['gnocchi://'],
Optional[Hash] $event_pipeline_config = undef, Optional[Hash] $event_pipeline_config = undef,
Array[String[1]] $event_pipeline_publishers = ['gnocchi://'],
$event_pipeline_cfg_file = $facts['os_service_default'],
Boolean $manage_pipeline = false, Boolean $manage_pipeline = false,
Array[String[1]] $pipeline_publishers = ['gnocchi://'],
Optional[Hash] $pipeline_config = undef, Optional[Hash] $pipeline_config = undef,
Array[String[1]] $pipeline_publishers = ['gnocchi://'],
$pipeline_cfg_file = $facts['os_service_default'],
) { ) {
include ceilometer::deps include ceilometer::deps
@ -154,6 +166,14 @@ class ceilometer::agent::notification (
group => $::ceilometer::params::group, group => $::ceilometer::params::group,
tag => 'ceilometer-yamls', tag => 'ceilometer-yamls',
} }
ceilometer_config {
'DEFAULT/event_pipeline_cfg_file': value => $::ceilometer::params::event_pipeline;
}
} else {
ceilometer_config {
'DEFAULT/event_pipeline_cfg_file': value => $event_pipeline_cfg_file;
}
} }
if $manage_pipeline { if $manage_pipeline {
@ -173,6 +193,14 @@ class ceilometer::agent::notification (
group => $::ceilometer::params::group, group => $::ceilometer::params::group,
tag => 'ceilometer-yamls', tag => 'ceilometer-yamls',
} }
ceilometer_config {
'DEFAULT/pipeline_cfg_file': value => $::ceilometer::params::pipeline;
}
} else {
ceilometer_config {
'DEFAULT/pipeline_cfg_file': value => $pipeline_cfg_file;
}
} }
ceilometer_config { ceilometer_config {

View File

@ -73,12 +73,21 @@
# This is used only if manage_polling is true. # This is used only if manage_polling is true.
# Defaults to undef # Defaults to undef
# #
# [*cfg_file*]
# (Optional) Configuration file for polling definition.
# This parameter has no effect when manage_polling is true.
# Defaults to $facts['os_service_default'].
#
# [*batch_size*] # [*batch_size*]
# (Optional) Batch size of samples to send to notification agent. # (Optional) Batch size of samples to send to notification agent.
# Defaults to $facts['os_service_default'] # Defaults to $facts['os_service_default'].
# #
# [*tenant_name_discovery*] # [*tenant_name_discovery*]
# (optional) Identify user and project names from polled metrics. # (Optional) Identify user and project names from polled metrics.
# 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']. # Defaults to $facts['os_service_default'].
# #
class ceilometer::agent::polling ( class ceilometer::agent::polling (
@ -96,9 +105,11 @@ class ceilometer::agent::polling (
Boolean $manage_polling = false, Boolean $manage_polling = false,
$polling_interval = 600, $polling_interval = 600,
Array[String[1]] $polling_meters = $::ceilometer::params::polling_meters, Array[String[1]] $polling_meters = $::ceilometer::params::polling_meters,
Optional[Hash]$polling_config = undef, Optional[Hash] $polling_config = undef,
$cfg_file = $facts['os_service_default'],
$batch_size = $facts['os_service_default'], $batch_size = $facts['os_service_default'],
$tenant_name_discovery = $facts['os_service_default'], $tenant_name_discovery = $facts['os_service_default'],
$pollsters_definitions_dirs = $facts['os_service_default'],
) inherits ceilometer { ) inherits ceilometer {
include ceilometer::deps include ceilometer::deps
@ -210,6 +221,7 @@ class ceilometer::agent::polling (
ceilometer_config { ceilometer_config {
'polling/batch_size': value => $batch_size; 'polling/batch_size': value => $batch_size;
'polling/tenant_name_discovery': value => $tenant_name_discovery; 'polling/tenant_name_discovery': value => $tenant_name_discovery;
'polling/pollsters_definitions_dirs': value => join(any2array($pollsters_definitions_dirs), ',');
} }
# TODO(tkajinam): Remove this after 2024.1 release # TODO(tkajinam): Remove this after 2024.1 release
@ -284,5 +296,13 @@ class ceilometer::agent::polling (
selinux_ignore_defaults => true, selinux_ignore_defaults => true,
tag => 'ceilometer-yamls', tag => 'ceilometer-yamls',
} }
ceilometer_config {
'polling/cfg_file': value => $::ceilometer::params::polling;
}
} else {
ceilometer_config {
'polling/cfg_file': value => $cfg_file;
}
} }
} }

View File

@ -0,0 +1,9 @@
---
features:
- |
The following parameters have been added.
- ``ceilometer::agent::notification::event_pipeline_cfg_file``
- ``ceilometer::agent::notification::pipeline_cfg_file``
- ``ceilometer::agent::polling::cfg_file``
- ``ceilometer::agent::polling::pollsters_definitions_dirs``

View File

@ -50,6 +50,8 @@ describe 'ceilometer::agent::notification' do
is_expected.to contain_ceilometer_config('notification/disable_non_metric_meters').with_value('<SERVICE DEFAULT>') is_expected.to contain_ceilometer_config('notification/disable_non_metric_meters').with_value('<SERVICE DEFAULT>')
is_expected.to contain_ceilometer_config('notification/batch_size').with_value('<SERVICE DEFAULT>') is_expected.to contain_ceilometer_config('notification/batch_size').with_value('<SERVICE DEFAULT>')
is_expected.to contain_ceilometer_config('notification/batch_timeout').with_value('<SERVICE DEFAULT>') is_expected.to contain_ceilometer_config('notification/batch_timeout').with_value('<SERVICE DEFAULT>')
is_expected.to contain_ceilometer_config('DEFAULT/event_pipeline_cfg_file').with_value('<SERVICE DEFAULT>')
is_expected.to contain_ceilometer_config('DEFAULT/pipeline_cfg_file').with_value('<SERVICE DEFAULT>')
end end
context 'with disabled non-metric meters' do context 'with disabled non-metric meters' do
@ -130,6 +132,7 @@ describe 'ceilometer::agent::notification' do
" publishers:", " publishers:",
" - gnocchi://", " - gnocchi://",
])} ])}
it { is_expected.to contain_ceilometer_config('DEFAULT/event_pipeline_cfg_file').with_value('/etc/ceilometer/event_pipeline.yaml') }
end end
context "with multiple event_pipeline publishers specified" do context "with multiple event_pipeline publishers specified" do
@ -153,6 +156,7 @@ describe 'ceilometer::agent::notification' do
" - notifier://", " - notifier://",
" - notifier://?topic=alarm.all", " - notifier://?topic=alarm.all",
])} ])}
it { is_expected.to contain_ceilometer_config('DEFAULT/event_pipeline_cfg_file').with_value('/etc/ceilometer/event_pipeline.yaml') }
end end
context 'with event_pipeline and custom config' do context 'with event_pipeline and custom config' do
@ -185,6 +189,7 @@ sinks:
- gnocchi:// - gnocchi://
', ',
)} )}
it { is_expected.to contain_ceilometer_config('DEFAULT/event_pipeline_cfg_file').with_value('/etc/ceilometer/event_pipeline.yaml') }
end end
context "with event_pipeline management disabled" do context "with event_pipeline management disabled" do
@ -192,6 +197,7 @@ sinks:
:manage_event_pipeline => false :manage_event_pipeline => false
) } ) }
it { is_expected.not_to contain_file('event_pipeline') } it { is_expected.not_to contain_file('event_pipeline') }
it { is_expected.to contain_ceilometer_config('DEFAULT/event_pipeline_cfg_file').with_value('<SERVICE DEFAULT>') }
end end
context "with pipeline management enabled" do context "with pipeline management enabled" do
@ -205,6 +211,7 @@ sinks:
'owner' => 'root', 'owner' => 'root',
'group' => 'ceilometer', 'group' => 'ceilometer',
) } ) }
it { is_expected.to contain_ceilometer_config('DEFAULT/pipeline_cfg_file').with_value('/etc/ceilometer/pipeline.yaml') }
end end
context 'with pipeline and custom config' do context 'with pipeline and custom config' do
@ -237,6 +244,7 @@ sinks:
- gnocchi:// - gnocchi://
', ',
)} )}
it { is_expected.to contain_ceilometer_config('DEFAULT/pipeline_cfg_file').with_value('/etc/ceilometer/pipeline.yaml') }
end end
context "with pipeline management disabled" do context "with pipeline management disabled" do
@ -244,6 +252,7 @@ sinks:
:manage_pipeline => false :manage_pipeline => false
) } ) }
it { is_expected.not_to contain_file('pipeline') } it { is_expected.not_to contain_file('pipeline') }
it { is_expected.to contain_ceilometer_config('DEFAULT/event_pipeline_cfg_file').with_value('<SERVICE DEFAULT>') }
end end
context 'with workers' do context 'with workers' do

View File

@ -73,6 +73,8 @@ describe 'ceilometer::agent::polling' do
it { should contain_ceilometer_config('polling/batch_size').with_value('<SERVICE DEFAULT>') } it { should contain_ceilometer_config('polling/batch_size').with_value('<SERVICE DEFAULT>') }
it { should_not contain_file('polling') } it { should_not contain_file('polling') }
it { should contain_ceilometer_config('polling/tenant_name_discovery').with_value('<SERVICE DEFAULT>') } it { should contain_ceilometer_config('polling/tenant_name_discovery').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>') }
end end
context 'when setting package_ensure' do context 'when setting package_ensure' do
@ -113,6 +115,19 @@ describe 'ceilometer::agent::polling' do
} }
end end
context 'when pollsters_definitions_dirs is set' do
before do
params.merge!(
:pollsters_definitions_dirs => ['/etc/ceilometer/pollsters.d', '/etc/ceilometer/mypollsters.d']
)
end
it {
should contain_ceilometer_config('polling/pollsters_definitions_dirs').with_value(
'/etc/ceilometer/pollsters.d,/etc/ceilometer/mypollsters.d')
}
end
context 'with compute namespace disabled' do context 'with compute namespace disabled' do
before do before do
params.merge!( params.merge!(
@ -217,6 +232,7 @@ sources:
:selinux_ignore_defaults => true, :selinux_ignore_defaults => true,
:tag => 'ceilometer-yamls', :tag => 'ceilometer-yamls',
)} )}
it { should contain_ceilometer_config('polling/cfg_file').with_value('/etc/ceilometer/polling.yaml') }
end end
context 'with polling and basic custom settings' do context 'with polling and basic custom settings' do
@ -240,6 +256,7 @@ sources:
:selinux_ignore_defaults => true, :selinux_ignore_defaults => true,
:tag => 'ceilometer-yamls', :tag => 'ceilometer-yamls',
)} )}
it { should contain_ceilometer_config('polling/cfg_file').with_value('/etc/ceilometer/polling.yaml') }
end end
context 'with polling and custom config' do context 'with polling and custom config' do
@ -269,6 +286,7 @@ sources:
- meterbar - meterbar
', ',
)} )}
it { should contain_ceilometer_config('polling/cfg_file').with_value('/etc/ceilometer/polling.yaml') }
end end
context 'with polling management disabled' do context 'with polling management disabled' do
@ -277,6 +295,7 @@ sources:
end end
it { should_not contain_file('polling') } it { should_not contain_file('polling') }
it { should contain_ceilometer_config('polling/cfg_file').with_value('<SERVICE DEFAULT>') }
end end
context 'when batch_size is set' do context 'when batch_size is set' do