Skip to content

Commit

Permalink
fixes #36 - tentative fix for this issue
Browse files Browse the repository at this point in the history
  • Loading branch information
jantman committed Nov 18, 2015
1 parent 57523d5 commit e8c5f51
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 23 deletions.
2 changes: 0 additions & 2 deletions lib/vagrant-r10k/action/deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ def call(env)
@logger.debug("vagrant::r10k::deploy: env_dir_path=#{config[:env_dir_path]}")
@logger.debug("vagrant::r10k::deploy: puppetfile_path=#{config[:puppetfile_path]}")
@logger.debug("vagrant::r10k::deploy: module_path=#{config[:module_path]}")
@logger.debug("vagrant::r10k::deploy: manifests=#{config[:manifests]}")
@logger.debug("vagrant::r10k::deploy: manifest_file=#{config[:manifest_file]}")
@logger.debug("vagrant::r10k::deploy: puppet_dir=#{config[:puppet_dir]}")

deploy(env, config)
Expand Down
4 changes: 1 addition & 3 deletions lib/vagrant-r10k/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,13 @@ def puppet_provisioner(env)
#
# @return [Hash]
def r10k_config(env)
ret = { :manifests => nil, :module_path => nil, :manifest_file => nil }
ret = { :module_path => nil }
ret[:env_dir_path] = env_dir(env)
ret[:puppetfile_path] = puppetfile_path(env)
prov = puppet_provisioner(env)
return nil if prov.nil?
ret[:module_path] = module_path(env, prov, ret[:env_dir_path])
return nil if ret[:module_path].nil?
ret[:manifest_file] = File.join(ret[:env_dir_path], prov.config.manifest_file)
ret[:manifests] = File.join(ret[:env_dir_path], prov.config.manifests_path[1])
ret[:puppet_dir] = File.join(ret[:env_dir_path], env[:machine].config.r10k.puppet_dir)
ret
end
Expand Down
31 changes: 19 additions & 12 deletions spec/acceptance/vagrant-r10k/vagrant-r10k_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,21 @@
it 'deploys Puppetfile modules in an environment' do
status("Test: vagrant up")
up_result = assert_execute('vagrant', 'up', "--provider=#{provider}", '--debug')
ensure_successful_run(up_result, environment.workdir)
ensure_successful_run(up_result, environment.workdir, expect_building=false, moddir='environments/myenv/modules', pupfile='environments/myenv/Puppetfile', do_ensure_ran=false)
expect(up_result.stdout).to include('Running provisioner: puppet')
expect(up_result.stdout).to include('Running Puppet with environment myenv')
expect(up_result.stdout).to include('vagrant-r10k puppet run')
status("Test: reviewboard module")
rb_dir = File.join(environment.workdir, 'puppet', 'modules', 'reviewboard')
rb_dir = File.join(environment.workdir, 'environments', 'myenv', 'modules', 'reviewboard')
expect(File.directory?(rb_dir)).to be_truthy
rb_result = assert_execute('bash', 'gitcheck.sh', 'puppet/modules/reviewboard')
rb_result = assert_execute('bash', 'gitcheck.sh', 'environments/myenv/modules/reviewboard')
expect(rb_result).to exit_with(0)
expect(rb_result.stdout).to match(/tag: v1\.0\.1 @ cdb8d7a186846b49326cec1cfb4623bd77529b04 \(origin: https:\/\/github\.com\/jantman\/puppet-reviewboard\.git\)/)

status("Test: nodemeister module")
nm_dir = File.join(environment.workdir, 'puppet', 'modules', 'nodemeister')
nm_dir = File.join(environment.workdir, 'environments', 'myenv', 'modules', 'nodemeister')
expect(File.directory?(nm_dir)).to be_truthy
nm_result = assert_execute('bash', 'gitcheck.sh', 'puppet/modules/nodemeister')
nm_result = assert_execute('bash', 'gitcheck.sh', 'environments/myenv/modules/nodemeister')
expect(nm_result).to exit_with(0)
expect(nm_result.stdout).to match(/tag: 0\.1\.0 @ 3a504b5f66ebe1853bda4ee065fce18118958d84 \(origin: https:\/\/github\.com\/jantman\/puppet-nodemeister\.git\)/)
end
Expand Down Expand Up @@ -218,7 +221,7 @@ def setup_before(skel_name, options)
end

# checks for a successful up run with r10k deployment and puppet provisioning
def ensure_successful_run(up_result, workdir)
def ensure_successful_run(up_result, workdir, expect_building=true, moddir='puppet/modules', pupfile='puppet/Puppetfile', do_ensure_ran=true)
expect(up_result).to exit_with(0)
# version checks
expect(up_result.stderr).to include('global: - r10k = 1.5.1')
Expand All @@ -235,16 +238,20 @@ def ensure_successful_run(up_result, workdir)
# modulegetter BEFORE ConfigValidate
expect(up_result.stderr).to match(%r"(?!ConfigValidate)+default: vagrant-r10k: Deploy finished.*Vagrant::Action::Builtin::ConfigValidate"m), "modulegetter runs before ConfigValidate"
# other checks
expect(up_result.stdout).to include('vagrant-r10k: Building the r10k module path with puppet provisioner module_path "puppet/modules"')
expect(up_result.stdout).to include("vagrant-r10k: Beginning r10k deploy of puppet modules into #{workdir}/puppet/modules using #{workdir}/puppet/Puppetfile")
if expect_building then
expect(up_result.stdout).to include('vagrant-r10k: Building the r10k module path with puppet provisioner module_path "puppet/modules"')
end
expect(up_result.stdout).to include("vagrant-r10k: Beginning r10k deploy of puppet modules into #{workdir}/#{moddir} using #{workdir}/#{pupfile}")
expect(up_result.stdout).to include('vagrant-r10k: Deploy finished')
# file tests
expect(File).to exist("#{workdir}/puppet/modules/reviewboard/Modulefile")
expect(File).to exist("#{workdir}/puppet/modules/nodemeister/Modulefile")
expect(File).to exist("#{workdir}/puppet/modules/nodemeister/manifests/init.pp")
expect(File).to exist("#{workdir}/#{moddir}/reviewboard/Modulefile")
expect(File).to exist("#{workdir}/#{moddir}/nodemeister/Modulefile")
expect(File).to exist("#{workdir}/#{moddir}/nodemeister/manifests/init.pp")

# ensure puppet ran
ensure_puppet_ran(up_result)
if do_ensure_ran then
ensure_puppet_ran(up_result)
end
end

# ensure that r10k didnt run
Expand Down
3 changes: 0 additions & 3 deletions spec/unit/action_deploy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@
:puppetfile_path => 'puppetfile/path',
:module_path => 'module/path',
:manifests => 'manifests',
:manifest_file => 'manifest/file',
:puppet_dir => 'puppet/dir',
}}
let(:pf_dbl) { double }
Expand Down Expand Up @@ -184,8 +183,6 @@
expect(logger).to receive(:debug).once.ordered.with("vagrant::r10k::deploy: env_dir_path=env/dir/path")
expect(logger).to receive(:debug).once.ordered.with("vagrant::r10k::deploy: puppetfile_path=puppetfile/path")
expect(logger).to receive(:debug).once.ordered.with("vagrant::r10k::deploy: module_path=module/path")
expect(logger).to receive(:debug).once.ordered.with("vagrant::r10k::deploy: manifests=manifests")
expect(logger).to receive(:debug).once.ordered.with("vagrant::r10k::deploy: manifest_file=manifest/file")
expect(logger).to receive(:debug).once.ordered.with("vagrant::r10k::deploy: puppet_dir=puppet/dir")
expect(subject).to receive(:deploy).with(env, config).once
expect(app).to receive(:call).once.with(env)
Expand Down
3 changes: 0 additions & 3 deletions spec/unit/helpers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@
context 'no methods return nil' do
before do
prov_dbl = double
prov_dbl.stub_chain(:config, :manifest_file).and_return('manifest/file')
prov_dbl.stub_chain(:config, :manifests_path).and_return([0, 'manifests/path'])
allow_any_instance_of(VagrantPlugins::R10k::Helpers).to receive(:env_dir).and_return('/my/env/dir')
allow_any_instance_of(VagrantPlugins::R10k::Helpers).to receive(:puppetfile_path).and_return('puppet/file/path')
Expand All @@ -228,8 +227,6 @@
:env_dir_path => '/my/env/dir',
:puppetfile_path => 'puppet/file/path',
:module_path => 'module/path',
:manifest_file => '/my/env/dir/manifest/file',
:manifests => '/my/env/dir/manifests/path',
:puppet_dir => '/my/env/dir/puppet/dir',
})
end
Expand Down

0 comments on commit e8c5f51

Please sign in to comment.