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 'tuskar-package' and 'tuskar-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 == 'tuskar-package' |> -> X

Change-Id: Ie80cdb04a7b9d5adb87bf13ab1adee963adae6af
This commit is contained in:
Yanis Guenane 2015-07-22 17:07:10 +02:00
parent 2da6a5cbcd
commit 8dba39eefa
4 changed files with 16 additions and 4 deletions

View File

@ -68,6 +68,7 @@ define tuskar::generic_service(
ensure => $package_ensure,
name => $package_name,
notify => Service[$tuskar_title],
tag => ['openstack', 'tuskar-package'],
}
}
}
@ -86,6 +87,7 @@ define tuskar::generic_service(
name => $service_name,
enable => $enabled,
hasstatus => true,
tag => 'tuskar-service',
}
}
}

View File

@ -39,12 +39,14 @@ class tuskar::ui (
package { 'tuskar-ui':
ensure => $package_ensure,
name => $::tuskar::params::ui_package_name,
tag => ['openstack', 'tuskar-package'],
}
if $extras {
package { 'tuskar-ui-extras':
ensure => $package_ensure,
name => $::tuskar::params::ui_extras_package_name,
tag => ['openstack', 'tuskar-package'],
}
}

View File

@ -12,6 +12,7 @@ describe 'tuskar::ui' do
should contain_package('tuskar-ui').with(
:name => platform_params[:ui_package_name],
:ensure => 'present',
:tag => ['openstack', 'tuskar-package'],
)
should_not contain_package('tuskar-ui-extras')
end
@ -25,10 +26,12 @@ describe 'tuskar::ui' do
should contain_package('tuskar-ui').with(
:name => platform_params[:ui_package_name],
:ensure => 'present',
:tag => ['openstack', 'tuskar-package'],
)
should contain_package('tuskar-ui-extras').with(
:name => platform_params[:ui_extras_package_name],
:ensure => 'present',
:tag => ['openstack', 'tuskar-package'],
)
end
end
@ -41,6 +44,7 @@ describe 'tuskar::ui' do
should contain_package('tuskar-ui').with(
:name => platform_params[:ui_package_name],
:ensure => 'absent',
:tag => ['openstack', 'tuskar-package'],
)
end
end

View File

@ -11,13 +11,15 @@ shared_examples 'generic Tuskar service' do |service|
is_expected.to contain_package(service[:name]).with({
:name => service[:package_name],
:ensure => 'present',
:notify => "Service[#{service[:name]}]"
:notify => "Service[#{service[:name]}]",
:tag => ['openstack', 'tuskar-package'],
})
is_expected.to contain_service(service[:name]).with({
:name => service[:service_name],
:ensure => 'stopped',
:hasstatus => true,
:enable => false
:enable => false,
:tag => 'tuskar-service',
})
end
end
@ -32,13 +34,15 @@ shared_examples 'generic Tuskar service' do |service|
is_expected.to contain_package(service[:name]).with({
:name => service[:package_name],
:ensure => '2014.1-1',
:notify => "Service[#{service[:name]}]"
:notify => "Service[#{service[:name]}]",
:tag => ['openstack', 'tuskar-package'],
})
is_expected.to contain_service(service[:name]).with({
:name => service[:service_name],
:ensure => 'running',
:hasstatus => true,
:enable => true
:enable => true,
:tag => 'tuskar-service',
})
end
end