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.
# 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*]
# (Optional) Whether to manage pipeline.yaml
# Defaults to false
@ -93,6 +98,11 @@
# Defaults to ['gnocchi://'], If you are using collector
# 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 (
Boolean $manage_service = true,
Boolean $enabled = true,
@ -104,11 +114,13 @@ class ceilometer::agent::notification (
$batch_timeout = $facts['os_service_default'],
$package_ensure = 'present',
Boolean $manage_event_pipeline = false,
Array[String[1]] $event_pipeline_publishers = ['gnocchi://'],
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,
Array[String[1]] $pipeline_publishers = ['gnocchi://'],
Optional[Hash] $pipeline_config = undef,
Array[String[1]] $pipeline_publishers = ['gnocchi://'],
$pipeline_cfg_file = $facts['os_service_default'],
) {
include ceilometer::deps
@ -154,6 +166,14 @@ class ceilometer::agent::notification (
group => $::ceilometer::params::group,
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 {
@ -173,6 +193,14 @@ class ceilometer::agent::notification (
group => $::ceilometer::params::group,
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 {

View File

@ -73,12 +73,21 @@
# This is used only if manage_polling is true.
# 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*]
# (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*]
# (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'].
#
class ceilometer::agent::polling (
@ -96,9 +105,11 @@ class ceilometer::agent::polling (
Boolean $manage_polling = false,
$polling_interval = 600,
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'],
$tenant_name_discovery = $facts['os_service_default'],
$pollsters_definitions_dirs = $facts['os_service_default'],
) inherits ceilometer {
include ceilometer::deps
@ -208,8 +219,9 @@ class ceilometer::agent::polling (
}
ceilometer_config {
'polling/batch_size': value => $batch_size;
'polling/tenant_name_discovery': value => $tenant_name_discovery;
'polling/batch_size': value => $batch_size;
'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
@ -284,5 +296,13 @@ class ceilometer::agent::polling (
selinux_ignore_defaults => true,
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/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('DEFAULT/event_pipeline_cfg_file').with_value('<SERVICE DEFAULT>')
is_expected.to contain_ceilometer_config('DEFAULT/pipeline_cfg_file').with_value('<SERVICE DEFAULT>')
end
context 'with disabled non-metric meters' do
@ -130,6 +132,7 @@ describe 'ceilometer::agent::notification' do
" publishers:",
" - gnocchi://",
])}
it { is_expected.to contain_ceilometer_config('DEFAULT/event_pipeline_cfg_file').with_value('/etc/ceilometer/event_pipeline.yaml') }
end
context "with multiple event_pipeline publishers specified" do
@ -153,6 +156,7 @@ describe 'ceilometer::agent::notification' do
" - notifier://",
" - notifier://?topic=alarm.all",
])}
it { is_expected.to contain_ceilometer_config('DEFAULT/event_pipeline_cfg_file').with_value('/etc/ceilometer/event_pipeline.yaml') }
end
context 'with event_pipeline and custom config' do
@ -185,13 +189,15 @@ sinks:
- gnocchi://
',
)}
it { is_expected.to contain_ceilometer_config('DEFAULT/event_pipeline_cfg_file').with_value('/etc/ceilometer/event_pipeline.yaml') }
end
context "with event_pipeline management disabled" do
before { params.merge!(
: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
context "with pipeline management enabled" do
@ -205,6 +211,7 @@ sinks:
'owner' => 'root',
'group' => 'ceilometer',
) }
it { is_expected.to contain_ceilometer_config('DEFAULT/pipeline_cfg_file').with_value('/etc/ceilometer/pipeline.yaml') }
end
context 'with pipeline and custom config' do
@ -237,13 +244,15 @@ sinks:
- gnocchi://
',
)}
it { is_expected.to contain_ceilometer_config('DEFAULT/pipeline_cfg_file').with_value('/etc/ceilometer/pipeline.yaml') }
end
context "with pipeline management disabled" do
before { params.merge!(
: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
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_not contain_file('polling') }
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
context 'when setting package_ensure' do
@ -113,6 +115,19 @@ describe 'ceilometer::agent::polling' do
}
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
before do
params.merge!(
@ -217,6 +232,7 @@ sources:
:selinux_ignore_defaults => true,
:tag => 'ceilometer-yamls',
)}
it { should contain_ceilometer_config('polling/cfg_file').with_value('/etc/ceilometer/polling.yaml') }
end
context 'with polling and basic custom settings' do
@ -240,6 +256,7 @@ sources:
:selinux_ignore_defaults => true,
:tag => 'ceilometer-yamls',
)}
it { should contain_ceilometer_config('polling/cfg_file').with_value('/etc/ceilometer/polling.yaml') }
end
context 'with polling and custom config' do
@ -269,6 +286,7 @@ sources:
- meterbar
',
)}
it { should contain_ceilometer_config('polling/cfg_file').with_value('/etc/ceilometer/polling.yaml') }
end
context 'with polling management disabled' do
@ -277,6 +295,7 @@ sources:
end
it { should_not contain_file('polling') }
it { should contain_ceilometer_config('polling/cfg_file').with_value('<SERVICE DEFAULT>') }
end
context 'when batch_size is set' do