Skip to content

Commit

Permalink
Merge pull request #552 from h0tw1r3/inventory
Browse files Browse the repository at this point in the history
pass full inventory path to task
  • Loading branch information
jordanbreen28 authored Jul 9, 2024
2 parents 4043b2c + 50e8c0d commit dc6cefe
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions lib/puppet_litmus/rake_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def provision(provisioner, platform, inventory_vars)
raise "the provision module was not found in #{DEFAULT_CONFIG_DATA['modulepath']}, please amend the .fixtures.yml file" unless
File.directory?(File.join(DEFAULT_CONFIG_DATA['modulepath'], 'provision'))

params = { 'action' => 'provision', 'platform' => platform, 'inventory' => Dir.pwd }
params = { 'action' => 'provision', 'platform' => platform, 'inventory' => File.join(Dir.pwd, 'spec', 'fixtures', 'litmus_inventory.yaml') }
params['vars'] = inventory_vars unless inventory_vars.nil?

task_name = provisioner_task(provisioner)
Expand Down Expand Up @@ -120,7 +120,7 @@ def tear_down(node_name, inventory_hash)
# how do we know what provisioner to use
add_platform_field(inventory_hash, node_name)

params = { 'action' => 'tear_down', 'node_name' => node_name, 'inventory' => Dir.pwd }
params = { 'action' => 'tear_down', 'node_name' => node_name, 'inventory' => File.join(Dir.pwd, 'spec', 'fixtures', 'litmus_inventory.yaml') }
node_facts = facts_from_node(inventory_hash, node_name)
bolt_result = run_task(provisioner_task(node_facts['provisioner']), 'localhost', params, config: DEFAULT_CONFIG_DATA, inventory: nil)
raise_bolt_errors(bolt_result, "tear_down of #{node_name} failed.")
Expand Down
13 changes: 8 additions & 5 deletions spec/lib/puppet_litmus/rake_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
end

RSpec.describe PuppetLitmus::RakeHelper do
inventory_file = File.join(Dir.pwd, 'spec', 'fixtures', 'litmus_inventory.yaml')
let(:inventory_file) { inventory_file }

context 'with provision_list' do
let(:provision_hash) { { 'default' => { 'provisioner' => 'docker', 'images' => ['waffleimage/centos7'] } } }
let(:results) { [] }
Expand All @@ -42,23 +45,23 @@
inventory_vars: nil,
provision_hash: { 'default' => { 'provisioner' => 'docker', 'images' => ['waffleimage/centos7'] } },
results: [],
params: { 'action' => 'provision', 'platform' => 'waffleimage/centos7', 'inventory' => Dir.pwd }
params: { 'action' => 'provision', 'platform' => 'waffleimage/centos7', 'inventory' => inventory_file }
},
{
provisioner: 'vagrant',
platform: 'centos7',
inventory_vars: nil,
provision_hash: { 'default' => { 'provisioner' => 'vagrant', 'images' => ['centos7'] } },
results: [],
params: { 'action' => 'provision', 'platform' => 'centos7', 'inventory' => Dir.pwd }
params: { 'action' => 'provision', 'platform' => 'centos7', 'inventory' => inventory_file }
},
{
provisioner: 'lxd',
platform: 'images:centos/7',
inventory_vars: nil,
provision_hash: { 'default' => { 'provisioner' => 'lxd', 'images' => ['images:centos/7'] } },
results: [],
params: { 'action' => 'provision', 'platform' => 'images:centos/7', 'inventory' => Dir.pwd }
params: { 'action' => 'provision', 'platform' => 'images:centos/7', 'inventory' => inventory_file }
}
].freeze

Expand All @@ -76,7 +79,7 @@
[{ 'uri' => 'some.host', 'facts' => { 'provisioner' => 'docker', 'container_name' => 'foo', 'platform' => 'some.host' } }] }] }
end
let(:targets) { ['some.host'] }
let(:params) { { 'action' => 'tear_down', 'node_name' => 'some.host', 'inventory' => Dir.pwd } }
let(:params) { { 'action' => 'tear_down', 'node_name' => 'some.host', 'inventory' => inventory_file } }

it 'calls function' do
allow(File).to receive(:directory?).with(File.join(described_class::DEFAULT_CONFIG_DATA['modulepath'], 'provision')).and_return(true)
Expand All @@ -97,7 +100,7 @@
] }] }
end
let(:targets) { ['one.host'] }
let(:params) { { 'action' => 'tear_down', 'node_name' => 'one.host', 'inventory' => Dir.pwd } }
let(:params) { { 'action' => 'tear_down', 'node_name' => 'one.host', 'inventory' => inventory_file } }

it 'calls function' do
allow(File).to receive(:directory?).with(File.join(described_class::DEFAULT_CONFIG_DATA['modulepath'], 'provision')).and_return(true)
Expand Down

0 comments on commit dc6cefe

Please sign in to comment.