Use anchor to require necessary packages

... so that correct packages are required without re-defining them in
resource implementations.

Change-Id: Iae4374a503cf46e3c774dad36f48f25526de765e
This commit is contained in:
Takashi Kajinami 2020-05-04 12:45:03 +09:00
parent 46bf71a56b
commit 35e4cb2a7d
2 changed files with 5 additions and 18 deletions

View File

@ -52,8 +52,8 @@ module PuppetX
defaultto('<SERVICE DEFAULT>') defaultto('<SERVICE DEFAULT>')
end end
autorequire(:package) do autorequire(:anchor) do
'keystone' ['keystone::install::end']
end end
end end
end end

View File

@ -1,16 +1,3 @@
require 'spec_helper'
# this hack is required for now to ensure that the path is set up correctly
# to retrieve the parent provider
$LOAD_PATH.push(
File.join(
File.dirname(__FILE__),
'..',
'..',
'fixtures',
'modules',
'inifile',
'lib')
)
require 'puppet' require 'puppet'
require 'puppet/type/keystone_config' require 'puppet/type/keystone_config'
@ -66,12 +53,12 @@ describe 'Puppet::Type.type(:keystone_config)' do
it 'should autorequire the package that install the file' do it 'should autorequire the package that install the file' do
catalog = Puppet::Resource::Catalog.new catalog = Puppet::Resource::Catalog.new
package = Puppet::Type.type(:package).new(:name => 'keystone') anchor = Puppet::Type.type(:anchor).new(:name => 'keystone::install::end')
catalog.add_resource package, @keystone_config catalog.add_resource anchor, @keystone_config
dependency = @keystone_config.autorequire dependency = @keystone_config.autorequire
expect(dependency.size).to eq(1) expect(dependency.size).to eq(1)
expect(dependency[0].target).to eq(@keystone_config) expect(dependency[0].target).to eq(@keystone_config)
expect(dependency[0].source).to eq(package) expect(dependency[0].source).to eq(anchor)
end end
end end