Use anchor to require necessary packages

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

Change-Id: I581b2b19f0d707c74db7de055399209d221b158c
This commit is contained in:
Takashi Kajinami 2020-05-04 14:56:14 +09:00
parent c60261e068
commit 7d079648ff
4 changed files with 10 additions and 10 deletions

View File

@ -45,8 +45,8 @@ Puppet::Type.newtype(:congress_api_paste_ini) do
defaultto('<SERVICE DEFAULT>')
end
autorequire(:package) do
'congress-server'
autorequire(:anchor) do
['congress::install::end']
end
end

View File

@ -46,8 +46,8 @@ Puppet::Type.newtype(:congress_config) do
defaultto('<SERVICE DEFAULT>')
end
autorequire(:package) do
'congress'
autorequire(:anchor) do
['congress::install::end']
end
end

View File

@ -23,12 +23,12 @@ describe 'Puppet::Type.type(:congress_api_paste_ini)' do
it 'should autorequire the package that install the file' do
catalog = Puppet::Resource::Catalog.new
package = Puppet::Type.type(:package).new(:name => 'congress-server')
catalog.add_resource package, @congress_api_paste_ini
anchor = Puppet::Type.type(:anchor).new(:name => 'congress::install::end')
catalog.add_resource anchor, @congress_api_paste_ini
dependency = @congress_api_paste_ini.autorequire
expect(dependency.size).to eq(1)
expect(dependency[0].target).to eq(@congress_api_paste_ini)
expect(dependency[0].source).to eq(package)
expect(dependency[0].source).to eq(anchor)
end
end

View File

@ -52,12 +52,12 @@ describe 'Puppet::Type.type(:congress_config)' do
it 'should autorequire the package that install the file' do
catalog = Puppet::Resource::Catalog.new
package = Puppet::Type.type(:package).new(:name => 'congress')
catalog.add_resource package, @congress_config
anchor = Puppet::Type.type(:anchor).new(:name => 'congress::install::end')
catalog.add_resource anchor, @congress_config
dependency = @congress_config.autorequire
expect(dependency.size).to eq(1)
expect(dependency[0].target).to eq(@congress_config)
expect(dependency[0].source).to eq(package)
expect(dependency[0].source).to eq(anchor)
end