diff --git a/manifests/agent/polling.pp b/manifests/agent/polling.pp index 22eeefb2..4a2a4289 100644 --- a/manifests/agent/polling.pp +++ b/manifests/agent/polling.pp @@ -40,6 +40,14 @@ # * libvirt_metadata: get instances from libvirt metadata # but without instance metadata (recommended for Gnocchi backend). # +# [*manage_polling*] +# (Optional) Whether to manage polling.yaml +# Defaults to false +# +# [*polling_interval*] +# (Optional) Number of seconds between polling cycle +# Defaults to 600 seconds, used only if manage_polling is true. +# class ceilometer::agent::polling ( $manage_service = true, $enabled = true, @@ -49,6 +57,8 @@ class ceilometer::agent::polling ( $ipmi_namespace = true, $coordination_url = undef, $instance_discovery_method = $::os_service_default, + $manage_polling = false, + $polling_interval = 600, ) inherits ceilometer { include ::ceilometer::deps @@ -127,4 +137,13 @@ class ceilometer::agent::polling ( 'coordination/backend_url': value => $coordination_url } } + + if $manage_polling { + file { 'polling': + ensure => present, + path => $::ceilometer::params::polling, + content => template('ceilometer/polling.yaml.erb'), + selinux_ignore_defaults => true, + } + } } diff --git a/manifests/params.pp b/manifests/params.pp index 9a026a2b..4550dbd6 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -11,6 +11,7 @@ class ceilometer::params { $user = 'ceilometer' $event_pipeline = '/etc/ceilometer/event_pipeline.yaml' $pipeline = '/etc/ceilometer/pipeline.yaml' + $polling = '/etc/ceilometer/polling.yaml' $client_package_name = 'python-ceilometerclient' case $::osfamily { diff --git a/spec/classes/ceilometer_agent_polling_spec.rb b/spec/classes/ceilometer_agent_polling_spec.rb index cf236357..306c69ba 100644 --- a/spec/classes/ceilometer_agent_polling_spec.rb +++ b/spec/classes/ceilometer_agent_polling_spec.rb @@ -117,6 +117,24 @@ describe 'ceilometer::agent::polling' do end end + context "with polling management enabled" do + before { params.merge!( + :manage_polling => true + ) } + + it { is_expected.to contain_file('polling').with( + 'path' => '/etc/ceilometer/polling.yaml', + ) } + end + + context "with polling management disabled" do + before { params.merge!( + :manage_polling => false + ) } + + it { is_expected.not_to contain_file('polling') } + end + it 'configures central agent' do is_expected.to contain_ceilometer_config('coordination/backend_url').with_value( params[:coordination_url] ) end diff --git a/templates/polling.yaml.erb b/templates/polling.yaml.erb new file mode 100644 index 00000000..1af34f77 --- /dev/null +++ b/templates/polling.yaml.erb @@ -0,0 +1,6 @@ +--- +sources: + - name: all_pollsters + interval: <%= @polling_interval %> + meters: + - "*"