From 2743465bdcc51a5fe17320abbb365302f598bf5f Mon Sep 17 00:00:00 2001 From: Xav Paice Date: Tue, 2 Sep 2014 20:59:29 +1200 Subject: [PATCH] Add package_ensure where missing This adds package_ensure parameter to: * ceilometer::agent::central * ceilometer::agent::compute * ceilometer::agent::notification * ceilometer::api * ceilometer::collector Change-Id: I3a982882c37a24737d71f9af93d7aa0d7200bdf4 --- manifests/agent/central.pp | 12 +++++++++--- manifests/agent/compute.pp | 13 +++++++++---- manifests/agent/notification.pp | 15 ++++++++++++--- manifests/api.pp | 7 ++++++- manifests/collector.pp | 9 ++++++++- spec/classes/ceilometer_agent_central_spec.rb | 5 +++-- spec/classes/ceilometer_agent_compute_spec.rb | 5 +++-- .../classes/ceilometer_agent_notification_spec.rb | 4 +++- spec/classes/ceilometer_api_spec.rb | 5 +++-- spec/classes/ceilometer_collector_spec.rb | 4 +++- 10 files changed, 59 insertions(+), 20 deletions(-) diff --git a/manifests/agent/central.pp b/manifests/agent/central.pp index 7c17d8c1..c42d9060 100644 --- a/manifests/agent/central.pp +++ b/manifests/agent/central.pp @@ -9,9 +9,15 @@ # (optional) Whether the service should be managed by Puppet. # Defaults to true. # +# [*package_ensure*] +# (optional) ensure state for package. +# Defaults to 'present' +# + class ceilometer::agent::central ( - $manage_service = true, - $enabled = true, + $manage_service = true, + $enabled = true, + $package_ensure = 'present', ) { include ceilometer::params @@ -20,7 +26,7 @@ class ceilometer::agent::central ( Package['ceilometer-agent-central'] -> Service['ceilometer-agent-central'] package { 'ceilometer-agent-central': - ensure => installed, + ensure => $package_ensure, name => $::ceilometer::params::agent_central_package_name, } diff --git a/manifests/agent/compute.pp b/manifests/agent/compute.pp index 31048360..d9d922f9 100644 --- a/manifests/agent/compute.pp +++ b/manifests/agent/compute.pp @@ -1,4 +1,4 @@ -# The ceilometer::agent::compute class installs the ceilometer compute agent +#The ceilometer::agent::compute class installs the ceilometer compute agent # Include this class on all nova compute nodes # # == Parameters @@ -10,9 +10,14 @@ # (optional) Whether the service should be managed by Puppet. # Defaults to true. # +# [*package_ensure*] +# (optional) ensure state for package. +# Defaults to 'present' +# class ceilometer::agent::compute ( - $manage_service = true, - $enabled = true, + $manage_service = true, + $enabled = true, + $package_ensure = 'present', ) inherits ceilometer { include ceilometer::params @@ -21,7 +26,7 @@ class ceilometer::agent::compute ( Package['ceilometer-agent-compute'] -> Service['ceilometer-agent-compute'] package { 'ceilometer-agent-compute': - ensure => installed, + ensure => $package_ensure, name => $::ceilometer::params::agent_compute_package_name, } diff --git a/manifests/agent/notification.pp b/manifests/agent/notification.pp index f8c2631c..9a692244 100644 --- a/manifests/agent/notification.pp +++ b/manifests/agent/notification.pp @@ -39,20 +39,29 @@ # (optional) Save event details. # Defaults to false # +# [*package_ensure*] +# (optional) ensure state for package. +# Defaults to 'present' +# class ceilometer::agent::notification ( $manage_service = true, $enabled = true, $ack_on_event_error = true, - $store_events = false + $store_events = false, + $package_ensure = 'present', ) { include ceilometer::params Ceilometer_config<||> ~> Service['ceilometer-agent-notification'] - Package[$::ceilometer::params::agent_notification_package_name] -> Service['ceilometer-agent-notification'] - ensure_packages([$::ceilometer::params::agent_notification_package_name]) + Package[$::ceilometer::params::agent_notification_package_name] -> + Service['ceilometer-agent-notification'] + + ensure_resource('package', [$::ceilometer::params::agent_notification_package_name], + { ensure => $package_ensure } + ) if $manage_service { if $enabled { diff --git a/manifests/api.pp b/manifests/api.pp index 70e2bdf4..0b833380 100644 --- a/manifests/api.pp +++ b/manifests/api.pp @@ -47,10 +47,15 @@ # (optional) The ceilometer api port. # Defaults to 8777 # +# [*package_ensure*] +# (optional) ensure state for package. +# Defaults to 'present' +# class ceilometer::api ( $manage_service = true, $enabled = true, + $package_ensure = 'present', $keystone_host = '127.0.0.1', $keystone_port = '35357', $keystone_auth_admin_prefix = false, @@ -72,7 +77,7 @@ class ceilometer::api ( Package['ceilometer-api'] -> Ceilometer_config<||> Package['ceilometer-api'] -> Service['ceilometer-api'] package { 'ceilometer-api': - ensure => installed, + ensure => $package_ensure, name => $::ceilometer::params::api_package_name, } diff --git a/manifests/collector.pp b/manifests/collector.pp index 8e1f6fcb..440538c5 100644 --- a/manifests/collector.pp +++ b/manifests/collector.pp @@ -9,9 +9,14 @@ # (optional) Whether the service should be managed by Puppet. # Defaults to true. # +# [*package_ensure*] +# (optional) ensure state for package. +# Defaults to 'present' +# class ceilometer::collector ( $manage_service = true, $enabled = true, + $package_ensure = 'present', ) { include ceilometer::params @@ -19,7 +24,9 @@ class ceilometer::collector ( Ceilometer_config<||> ~> Service['ceilometer-collector'] Package[$::ceilometer::params::collector_package_name] -> Service['ceilometer-collector'] - ensure_packages([$::ceilometer::params::collector_package_name]) + ensure_resource( 'package', [$::ceilometer::params::collector_package_name], + { ensure => $package_ensure } + ) if $manage_service { if $enabled { diff --git a/spec/classes/ceilometer_agent_central_spec.rb b/spec/classes/ceilometer_agent_central_spec.rb index 8a45c35e..0e20c0bd 100644 --- a/spec/classes/ceilometer_agent_central_spec.rb +++ b/spec/classes/ceilometer_agent_central_spec.rb @@ -8,7 +8,8 @@ describe 'ceilometer::agent::central' do let :params do { :enabled => true, - :manage_service => true } + :manage_service => true, + :package_ensure => 'latest' } end shared_examples_for 'ceilometer-agent-central' do @@ -17,7 +18,7 @@ describe 'ceilometer::agent::central' do it 'installs ceilometer-agent-central package' do should contain_package('ceilometer-agent-central').with( - :ensure => 'installed', + :ensure => 'latest', :name => platform_params[:agent_package_name], :before => 'Service[ceilometer-agent-central]' ) diff --git a/spec/classes/ceilometer_agent_compute_spec.rb b/spec/classes/ceilometer_agent_compute_spec.rb index e68d91e9..c0dd64ed 100644 --- a/spec/classes/ceilometer_agent_compute_spec.rb +++ b/spec/classes/ceilometer_agent_compute_spec.rb @@ -9,8 +9,9 @@ describe 'ceilometer::agent::compute' do end let :params do - { :enabled => true, - :manage_service => true } + { :enabled => true, + :manage_service => true, + :package_ensure => 'installed' } end shared_examples_for 'ceilometer-agent-compute' do diff --git a/spec/classes/ceilometer_agent_notification_spec.rb b/spec/classes/ceilometer_agent_notification_spec.rb index 8646c28e..62ca2889 100644 --- a/spec/classes/ceilometer_agent_notification_spec.rb +++ b/spec/classes/ceilometer_agent_notification_spec.rb @@ -38,7 +38,9 @@ describe 'ceilometer::agent::notification' do it { should contain_class('ceilometer::params') } it 'installs ceilometer agent notification package' do - should contain_package(platform_params[:agent_notification_package_name]) + should contain_package(platform_params[:agent_notification_package_name]).with( + :ensure => 'present' + ) end it 'configures notifications parameters in ceilometer.conf' do diff --git a/spec/classes/ceilometer_api_spec.rb b/spec/classes/ceilometer_api_spec.rb index 66a9c181..eeefd016 100644 --- a/spec/classes/ceilometer_api_spec.rb +++ b/spec/classes/ceilometer_api_spec.rb @@ -16,7 +16,8 @@ describe 'ceilometer::api' do :keystone_password => 'ceilometer-passw0rd', :keystone_tenant => 'services', :host => '0.0.0.0', - :port => '8777' + :port => '8777', + :package_ensure => 'latest', } end @@ -31,7 +32,7 @@ describe 'ceilometer::api' do it 'installs ceilometer-api package' do should contain_package('ceilometer-api').with( - :ensure => 'installed', + :ensure => 'latest', :name => platform_params[:api_package_name] ) end diff --git a/spec/classes/ceilometer_collector_spec.rb b/spec/classes/ceilometer_collector_spec.rb index 72f2510e..72b5668f 100644 --- a/spec/classes/ceilometer_collector_spec.rb +++ b/spec/classes/ceilometer_collector_spec.rb @@ -16,7 +16,9 @@ describe 'ceilometer::collector' do it { should contain_class('ceilometer::params') } it 'installs ceilometer-collector package' do - should contain_package(platform_params[:collector_package_name]) + should contain_package(platform_params[:collector_package_name]).with( + :ensure => 'present' + ) end it 'configures ceilometer-collector service' do