Skip to content

Commit 5ab6061

Browse files
committed
(maint) pass full inventory path to task
1 parent 43df54f commit 5ab6061

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

lib/puppet_litmus/rake_helper.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def provision(provisioner, platform, inventory_vars)
6868
raise "the provision module was not found in #{DEFAULT_CONFIG_DATA['modulepath']}, please amend the .fixtures.yml file" unless
6969
File.directory?(File.join(DEFAULT_CONFIG_DATA['modulepath'], 'provision'))
7070

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

7474
task_name = provisioner_task(provisioner)
@@ -123,7 +123,7 @@ def tear_down(node_name, inventory_hash)
123123
# how do we know what provisioner to use
124124
add_platform_field(inventory_hash, node_name)
125125

126-
params = { 'action' => 'tear_down', 'node_name' => node_name, 'inventory' => Dir.pwd }
126+
params = { 'action' => 'tear_down', 'node_name' => node_name, 'inventory' => File.join(Dir.pwd, 'spec', 'fixtures', 'litmus_inventory.yaml') }
127127
node_facts = facts_from_node(inventory_hash, node_name)
128128
bolt_result = run_task(provisioner_task(node_facts['provisioner']), 'localhost', params, config: DEFAULT_CONFIG_DATA, inventory: nil)
129129
raise_bolt_errors(bolt_result, "tear_down of #{node_name} failed.")

spec/lib/puppet_litmus/rake_helper_spec.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
end
2525

2626
RSpec.describe PuppetLitmus::RakeHelper do
27+
inventory_file = File.join(Dir.pwd, 'spec', 'fixtures', 'litmus_inventory.yaml')
28+
let(:inventory_file) { inventory_file }
29+
2730
context 'with provision_list' do
2831
let(:provision_hash) { { 'default' => { 'provisioner' => 'docker', 'images' => ['waffleimage/centos7'] } } }
2932
let(:results) { [] }
@@ -42,15 +45,15 @@
4245
inventory_vars: nil,
4346
provision_hash: { 'default' => { 'provisioner' => 'docker', 'images' => ['waffleimage/centos7'] } },
4447
results: [],
45-
params: { 'action' => 'provision', 'platform' => 'waffleimage/centos7', 'inventory' => Dir.pwd }
48+
params: { 'action' => 'provision', 'platform' => 'waffleimage/centos7', 'inventory' => inventory_file }
4649
},
4750
{
4851
provisioner: 'vagrant',
4952
platform: 'centos7',
5053
inventory_vars: nil,
5154
provision_hash: { 'default' => { 'provisioner' => 'vagrant', 'images' => ['centos7'] } },
5255
results: [],
53-
params: { 'action' => 'provision', 'platform' => 'centos7', 'inventory' => Dir.pwd }
56+
params: { 'action' => 'provision', 'platform' => 'centos7', 'inventory' => inventory_file }
5457
}
5558
].freeze
5659

@@ -68,7 +71,7 @@
6871
[{ 'uri' => 'some.host', 'facts' => { 'provisioner' => 'docker', 'container_name' => 'foo', 'platform' => 'some.host' } }] }] }
6972
end
7073
let(:targets) { ['some.host'] }
71-
let(:params) { { 'action' => 'tear_down', 'node_name' => 'some.host', 'inventory' => Dir.pwd } }
74+
let(:params) { { 'action' => 'tear_down', 'node_name' => 'some.host', 'inventory' => inventory_file } }
7275

7376
it 'calls function' do
7477
allow(File).to receive(:directory?).with(File.join(described_class::DEFAULT_CONFIG_DATA['modulepath'], 'provision')).and_return(true)
@@ -89,7 +92,7 @@
8992
] }] }
9093
end
9194
let(:targets) { ['one.host'] }
92-
let(:params) { { 'action' => 'tear_down', 'node_name' => 'one.host', 'inventory' => Dir.pwd } }
95+
let(:params) { { 'action' => 'tear_down', 'node_name' => 'one.host', 'inventory' => inventory_file } }
9396

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

0 commit comments

Comments
 (0)