Add tag to package and service resources

In order to be able to take an action after all the packages of the
module have been installed/updated or all the services have been
started/restarted, we set a 'heat-package' and 'heat-service' tag
for each package and service of this module.

At the moment, there is a generic openstack tag that is not specific
enough if one wants to take action upon a single module change.

Use case :

If an action needs to be taken after all the packages have been
installed or updated : Package <| tag == 'heat-package' |> -> X

Change-Id: I38a6b422054dbf0fceacf6b7e329dbb3cb0fa9cb
This commit is contained in:
Yanis Guenane 2015-07-22 10:39:27 +02:00
parent c841398fd1
commit 0e850373a8
10 changed files with 26 additions and 14 deletions

View File

@ -81,7 +81,7 @@ class heat::api (
package { 'heat-api':
ensure => $package_ensure,
name => $::heat::params::api_package_name,
tag => 'openstack',
tag => ['openstack', 'heat-package'],
}
if $manage_service {
@ -101,6 +101,7 @@ class heat::api (
require => [Package['heat-common'],
Package['heat-api']],
subscribe => $::heat::subscribe_sync_db,
tag => 'heat-service',
}
heat_config {

View File

@ -84,7 +84,7 @@ class heat::api_cfn (
package { 'heat-api-cfn':
ensure => $package_ensure,
name => $::heat::params::api_cfn_package_name,
tag => 'openstack',
tag => ['openstack', 'heat-package'],
}
if $manage_service {
@ -104,6 +104,7 @@ class heat::api_cfn (
hasstatus => true,
hasrestart => true,
subscribe => $::heat::subscribe_sync_db,
tag => 'heat-service',
}
heat_config {

View File

@ -83,7 +83,7 @@ class heat::api_cloudwatch (
package { 'heat-api-cloudwatch':
ensure => $package_ensure,
name => $::heat::params::api_cloudwatch_package_name,
tag => 'openstack',
tag => ['openstack', 'heat-package'],
}
if $manage_service {
@ -104,6 +104,7 @@ class heat::api_cloudwatch (
hasstatus => true,
hasrestart => true,
subscribe => $::heat::subscribe_sync_db,
tag => 'heat-service',
}
heat_config {

View File

@ -116,7 +116,7 @@ class heat::engine (
package { 'heat-engine':
ensure => $package_ensure,
name => $::heat::params::engine_package_name,
tag => 'openstack',
tag => ['openstack', 'heat-package'],
notify => $::heat::subscribe_sync_db,
}
@ -145,6 +145,7 @@ class heat::engine (
Package['heat-common'],
Package['heat-engine']],
subscribe => $::heat::subscribe_sync_db,
tag => 'heat-service',
}
heat_config {

View File

@ -318,7 +318,7 @@ class heat(
package { 'heat-common':
ensure => $package_ensure,
name => $::heat::params::common_package_name,
tag => 'openstack',
tag => ['openstack', 'heat-package'],
}
Package['heat-common'] -> Heat_config<||>

View File

@ -74,7 +74,8 @@ describe 'heat::api_cfn' do
:name => platform_params[:api_service_name],
:enable => params[:enabled],
:hasstatus => true,
:hasrestart => true
:hasrestart => true,
:tag => 'heat-service',
)
is_expected.to contain_service('heat-api-cfn').that_subscribes_to('Exec[heat-dbsync]')
end
@ -95,7 +96,8 @@ describe 'heat::api_cfn' do
:name => platform_params[:api_service_name],
:enable => false,
:hasstatus => true,
:hasrestart => true
:hasrestart => true,
:tag => 'heat-service',
)
is_expected.to contain_service('heat-api-cfn').that_subscribes_to('Exec[heat-dbsync]')
end

View File

@ -74,7 +74,8 @@ describe 'heat::api_cloudwatch' do
:name => platform_params[:api_service_name],
:enable => params[:enabled],
:hasstatus => true,
:hasrestart => true
:hasrestart => true,
:tag => 'heat-service',
)
is_expected.to contain_service('heat-api-cloudwatch').that_subscribes_to('Exec[heat-dbsync]')
end
@ -95,7 +96,8 @@ describe 'heat::api_cloudwatch' do
:name => platform_params[:api_service_name],
:enable => false,
:hasstatus => true,
:hasrestart => true
:hasrestart => true,
:tag => 'heat-service',
)
is_expected.to contain_service('heat-api-cloudwatch').that_subscribes_to('Exec[heat-dbsync]')
end

View File

@ -76,7 +76,8 @@ describe 'heat::api' do
:enable => params[:enabled],
:hasstatus => true,
:hasrestart => true,
:require => ['Package[heat-common]', 'Package[heat-api]']
:require => ['Package[heat-common]', 'Package[heat-api]'],
:tag => 'heat-service',
)
is_expected.to contain_service('heat-api').that_subscribes_to('Exec[heat-dbsync]')
end
@ -99,6 +100,7 @@ describe 'heat::api' do
:hasstatus => true,
:hasrestart => true,
:require => ['Package[heat-common]', 'Package[heat-api]'],
:tag => 'heat-service',
)
is_expected.to contain_service('heat-api').that_subscribes_to('Exec[heat-dbsync]')
end

View File

@ -49,7 +49,7 @@ describe 'heat::engine' do
it { is_expected.to contain_package('heat-engine').with(
:ensure => 'present',
:name => os_params[:package_name],
:tag => 'openstack',
:tag => ['openstack', 'heat-package'],
:notify => 'Exec[heat-dbsync]'
) }
@ -62,7 +62,8 @@ describe 'heat::engine' do
:require => [ 'File[/etc/heat/heat.conf]',
'Package[heat-common]',
'Package[heat-engine]'],
:subscribe => 'Exec[heat-dbsync]'
:subscribe => 'Exec[heat-dbsync]',
:tag => 'heat-service',
) }
it { is_expected.to contain_heat_config('DEFAULT/auth_encryption_key').with_value( expected_params[:auth_encryption_key] ) }
@ -102,7 +103,8 @@ describe 'heat::engine' do
:require => [ 'File[/etc/heat/heat.conf]',
'Package[heat-common]',
'Package[heat-engine]'],
:subscribe => 'Exec[heat-dbsync]'
:subscribe => 'Exec[heat-dbsync]',
:tag => 'heat-service',
) }
end
context 'with $sync_db set to false in ::heat' do

View File

@ -126,7 +126,7 @@ describe 'heat' do
is_expected.to contain_package('heat-common').with(
:ensure => 'present',
:name => platform_params[:common_package_name],
:tag => 'openstack'
:tag => ['openstack', 'heat-package'],
)
end