Use anchor to require necessary packages

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

Change-Id: I536d77e157d96211e317297cefd321d6a7d6a98f
This commit is contained in:
Takashi Kajinami 2020-05-04 15:11:01 +09:00
parent aab4bb0501
commit a503ac22c3
8 changed files with 25 additions and 20 deletions

View File

@ -45,7 +45,7 @@ Puppet::Type.newtype(:murano_cfapi_config) do
defaultto('<SERVICE DEFAULT>')
end
autorequire(:package) do
'murano-common'
autorequire(:anchor) do
['murano::install::end']
end
end

View File

@ -45,7 +45,7 @@ Puppet::Type.newtype(:murano_cfapi_paste_ini_config) do
defaultto('<SERVICE DEFAULT>')
end
autorequire(:package) do
'murano-common'
autorequire(:anchor) do
['murano::install::end']
end
end

View File

@ -45,7 +45,7 @@ Puppet::Type.newtype(:murano_config) do
defaultto('<SERVICE DEFAULT>')
end
autorequire(:package) do
'murano-common'
autorequire(:anchor) do
['murano::install::end']
end
end

View File

@ -45,7 +45,8 @@ Puppet::Type.newtype(:murano_paste_ini_config) do
defaultto('<SERVICE DEFAULT>')
end
autorequire(:package) do
'murano-common'
autorequire(:anchor) do
['murano::install::end']
end
end

View File

@ -1,5 +1,6 @@
require 'puppet'
require 'puppet/type/murano_cfapi_config'
describe 'Puppet::Type.type(:murano_cfapi_config)' do
before :each do
@murano_cfapi_config = Puppet::Type.type(:murano_cfapi_config).new(:name => 'DEFAULT/foo', :value => 'bar')
@ -52,11 +53,11 @@ describe 'Puppet::Type.type(:murano_cfapi_config)' do
it 'should autorequire the package that install the file' do
catalog = Puppet::Resource::Catalog.new
package = Puppet::Type.type(:package).new(:name => 'murano-common')
catalog.add_resource package, @murano_cfapi_config
anchor = Puppet::Type.type(:anchor).new(:name => 'murano::install::end')
catalog.add_resource anchor, @murano_cfapi_config
dependency = @murano_cfapi_config.autorequire
expect(dependency.size).to eq(1)
expect(dependency[0].target).to eq(@murano_cfapi_config)
expect(dependency[0].source).to eq(package)
expect(dependency[0].source).to eq(anchor)
end
end

View File

@ -1,5 +1,6 @@
require 'puppet'
require 'puppet/type/murano_cfapi_paste_ini_config'
describe 'Puppet::Type.type(:murano_cfapi_paste_ini_config)' do
before :each do
@murano_cfapi_paste_ini_config = Puppet::Type.type(:murano_cfapi_paste_ini_config).new(:name => 'DEFAULT/foo', :value => 'bar')
@ -52,11 +53,11 @@ describe 'Puppet::Type.type(:murano_cfapi_paste_ini_config)' do
it 'should autorequire the package that install the file' do
catalog = Puppet::Resource::Catalog.new
package = Puppet::Type.type(:package).new(:name => 'murano-common')
catalog.add_resource package, @murano_cfapi_paste_ini_config
anchor = Puppet::Type.type(:anchor).new(:name => 'murano::install::end')
catalog.add_resource anchor, @murano_cfapi_paste_ini_config
dependency = @murano_cfapi_paste_ini_config.autorequire
expect(dependency.size).to eq(1)
expect(dependency[0].target).to eq(@murano_cfapi_paste_ini_config)
expect(dependency[0].source).to eq(package)
expect(dependency[0].source).to eq(anchor)
end
end

View File

@ -1,5 +1,6 @@
require 'puppet'
require 'puppet/type/murano_config'
describe 'Puppet::Type.type(:murano_config)' do
before :each do
@murano_config = Puppet::Type.type(:murano_config).new(:name => 'DEFAULT/foo', :value => 'bar')
@ -52,11 +53,11 @@ describe 'Puppet::Type.type(:murano_config)' do
it 'should autorequire the package that install the file' do
catalog = Puppet::Resource::Catalog.new
package = Puppet::Type.type(:package).new(:name => 'murano-common')
catalog.add_resource package, @murano_config
anchor = Puppet::Type.type(:anchor).new(:name => 'murano::install::end')
catalog.add_resource anchor, @murano_config
dependency = @murano_config.autorequire
expect(dependency.size).to eq(1)
expect(dependency[0].target).to eq(@murano_config)
expect(dependency[0].source).to eq(package)
expect(dependency[0].source).to eq(anchor)
end
end

View File

@ -1,5 +1,6 @@
require 'puppet'
require 'puppet/type/murano_paste_ini_config'
describe 'Puppet::Type.type(:murano_paste_ini_config)' do
before :each do
@murano_paste_ini_config = Puppet::Type.type(:murano_paste_ini_config).new(:name => 'DEFAULT/foo', :value => 'bar')
@ -52,11 +53,11 @@ describe 'Puppet::Type.type(:murano_paste_ini_config)' do
it 'should autorequire the package that install the file' do
catalog = Puppet::Resource::Catalog.new
package = Puppet::Type.type(:package).new(:name => 'murano-common')
catalog.add_resource package, @murano_paste_ini_config
anchor = Puppet::Type.type(:anchor).new(:name => 'murano::install::end')
catalog.add_resource anchor, @murano_paste_ini_config
dependency = @murano_paste_ini_config.autorequire
expect(dependency.size).to eq(1)
expect(dependency[0].target).to eq(@murano_paste_ini_config)
expect(dependency[0].source).to eq(package)
expect(dependency[0].source).to eq(anchor)
end
end