Skip to content
This repository has been archived by the owner on Sep 24, 2019. It is now read-only.

Commit

Permalink
Merge pull request #2 from puppetlabs/fix_hiera_and_paths
Browse files Browse the repository at this point in the history
Fix hieraconf and pathing
  • Loading branch information
hunner committed Jun 11, 2015
2 parents 8b79bda + e30bf5f commit bf2a4d6
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 73 deletions.
45 changes: 0 additions & 45 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,48 +1,3 @@
source ENV['GEM_SOURCE'] || "https://rubygems.org"

gemspec
#def location_for(place, fake_version = nil)
# if place =~ /^(git:[^#]*)#(.*)/
# [fake_version, { :git => $1, :branch => $2, :require => false }].compact
# elsif place =~ /^file:\/\/(.*)/
# ['>= 0', { :path => File.expand_path($1), :require => false }]
# else
# [place, { :require => false }]
# end
#end
#
#group :development, :unit_tests do
# gem 'rspec-core', '3.1.7', :require => false
# gem 'puppetlabs_spec_helper', :require => false
# gem 'simplecov', :require => false
# gem 'puppet_facts', :require => false
# gem 'json', :require => false
#end
#
#group :system_tests do
# if beaker_version = ENV['BEAKER_VERSION']
# gem 'beaker', *location_for(beaker_version)
# end
# if beaker_rspec_version = ENV['BEAKER_RSPEC_VERSION']
# gem 'beaker-rspec', *location_for(beaker_rspec_version)
# else
# gem 'beaker-rspec', :require => false
# end
# gem 'serverspec', :require => false
#end
#
#
#
#if facterversion = ENV['FACTER_GEM_VERSION']
# gem 'facter', facterversion, :require => false
#else
# gem 'facter', :require => false
#end
#
#if puppetversion = ENV['PUPPET_GEM_VERSION']
# gem 'puppet', puppetversion, :require => false
#else
# gem 'puppet', :require => false
#end
#
## vim:ft=ruby
2 changes: 1 addition & 1 deletion beaker-puppet_install_helper.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = "beaker-puppet_install_helper"
s.version = '0.1.1'
s.version = '0.1.2'
s.authors = ["Puppetlabs"]
s.email = ["[email protected]"]
s.homepage = "https://github.com/puppetlabs/beaker-puppet_install_helper"
Expand Down
18 changes: 10 additions & 8 deletions lib/beaker/puppet_install_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module Beaker::PuppetInstallHelper
def run_puppet_install_helper(type_arg=find_install_type,version=ENV["PUPPET_VERSION"])
run_puppet_install_helper_on(hosts,type_arg,version)
run_puppet_install_helper_on(default,type_arg,version)
end

# Takes a host(s) object, install type string, and install version string.
Expand All @@ -26,26 +26,26 @@ def run_puppet_install_helper_on(hosts,type_arg=find_install_type,version=ENV["P
case type
when "pe"
# This will skip hosts that are not supported
install_pe_on(hosts,{"pe_ver" => version})
add_pe_defaults_on(hosts)
add_puppet_paths_on(hosts)
install_pe_on(Array(hosts),{"pe_ver" => version})
when "foss"
opts = {
:version => version,
:default_action => "gem_install",
}

install_puppet_on(hosts, opts)
# XXX install_puppet_on() will only add_aio_defaults_on when the nodeset
# type == 'aio', but we don't want to depend on that.
if opts[:version] and not version_is_less(opts[:version], '4.0.0')
add_aio_defaults_on(hosts)
else
add_foss_defaults_on(hosts)
add_puppet_paths_on(hosts)
end
add_puppet_paths_on(hosts)
Array(hosts).each do |host|
if fact_on(host,"osfamily") != "windows"
on host, "mkdir -p #{host["distmoduledir"]}"
on host, "touch #{host["hieraconf"]}"
# XXX Maybe this can just be removed? What PE/puppet version needs
# it?
on host, "touch #{host.puppet["hiera_config"]}"
end
if fact_on(host, "operatingsystem") == "Debian"
on host, "echo 'export PATH=/var/lib/gems/1.8/bin/:${PATH}' >> ~/.bashrc"
Expand All @@ -57,6 +57,8 @@ def run_puppet_install_helper_on(hosts,type_arg=find_install_type,version=ENV["P
when "agent"
# This will fail on hosts that are not supported; use foss and specify a 4.x version instead
install_puppet_agent_on(hosts, {:version => version})
# XXX install_puppet_agent_on() will only add_aio_defaults_on when the
# nodeset type == 'aio', but we don't want to depend on that.
add_aio_defaults_on(hosts)
add_puppet_paths_on(hosts)
else
Expand Down
31 changes: 12 additions & 19 deletions spec/unit/beaker/puppet_install_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@
Class.new { include Beaker::PuppetInstallHelper }
end
let :hosts do
host = { "distmoduledir" => "/dne", "hieraconf" => "/dne" }
[ host, host, host, ]
foss_host = double(:is_pe? => false)
pe_host = double(:is_pe? => true)
allow(foss_host).to receive(:[]).with("distmoduledir").and_return("/dne")
allow(foss_host).to receive(:puppet).and_return({"hiera_config" => "/dne"})
allow(pe_host).to receive(:[]).with("distmoduledir").and_return("/dne")
allow(pe_host).to receive(:puppet).and_return({"hiera_config" => "/dne"})
[foss_host, pe_host]
end
before :each do
allow(subject).to receive(:on)
Expand All @@ -18,50 +23,42 @@
end
describe '#run_puppet_install_helper' do
before :each do
allow(subject).to receive(:default).and_return(double(:is_pe? => false))
allow(subject).to receive(:hosts).and_return(hosts)
allow(subject).to receive(:default).and_return(hosts[0])
end
it 'calls run_puppet_install_helper_on on each host' do
expect(subject).to receive(:run_puppet_install_helper_on).with(hosts,"foss",nil)
expect(subject).to receive(:run_puppet_install_helper_on).with(hosts[0],"foss",nil)
subject.run_puppet_install_helper
end
it 'calls run_puppet_install_helper_on on each host with a version ' do
ENV["PUPPET_VERSION"] = "4.1.0"
expect(subject).to receive(:run_puppet_install_helper_on).with(hosts,"foss","4.1.0")
expect(subject).to receive(:run_puppet_install_helper_on).with(hosts[0],"foss","4.1.0")
subject.run_puppet_install_helper
end
end
describe '#run_puppet_install_helper_on' do
context "for default" do
it "uses foss by default for non-pe nodes" do
expect(subject).to receive(:default).and_return(double(:is_pe? => false))
expect(subject).to receive(:default).and_return(hosts[0])
expect(subject).to receive(:install_puppet_on).with(hosts,{:version => nil,:default_action => "gem_install"})
expect(subject).to receive(:add_foss_defaults_on).with(hosts)
expect(subject).to receive(:add_puppet_paths_on).with(hosts)
subject.run_puppet_install_helper_on(hosts)
end
it "uses PE by default for PE nodes" do
expect(subject).to receive(:default).and_return(double(:is_pe? => true))
expect(subject).to receive(:default).and_return(hosts[1])
expect(subject).to receive(:install_pe_on).with(hosts,{"pe_ver" => nil})
expect(subject).to receive(:add_pe_defaults_on).with(hosts)
expect(subject).to receive(:add_puppet_paths_on).with(hosts)
subject.run_puppet_install_helper_on(hosts)
end
end
context "for foss" do
it "uses foss explicitly" do
ENV["PUPPET_INSTALL_TYPE"] = "foss"
expect(subject).to receive(:install_puppet_on).with(hosts,{:version => nil,:default_action => "gem_install"})
expect(subject).to receive(:add_foss_defaults_on).with(hosts)
expect(subject).to receive(:add_puppet_paths_on).with(hosts)
subject.run_puppet_install_helper_on(hosts)
end
it "uses foss with a version" do
ENV["PUPPET_INSTALL_TYPE"] = "foss"
ENV["PUPPET_VERSION"] = "3.8.1"
expect(subject).to receive(:install_puppet_on).with(hosts,{:version => "3.8.1",:default_action => "gem_install"})
expect(subject).to receive(:add_foss_defaults_on).with(hosts)
expect(subject).to receive(:add_puppet_paths_on).with(hosts)
subject.run_puppet_install_helper_on(hosts)
end
it "uses foss with a >4 version detects AIO" do
Expand All @@ -77,16 +74,12 @@
it "uses PE explicitly" do
ENV["PUPPET_INSTALL_TYPE"] = "pe"
expect(subject).to receive(:install_pe_on).with(hosts,{"pe_ver" => nil})
expect(subject).to receive(:add_pe_defaults_on).with(hosts)
expect(subject).to receive(:add_puppet_paths_on).with(hosts)
subject.run_puppet_install_helper_on(hosts)
end
it "uses PE with a version" do
ENV["PUPPET_INSTALL_TYPE"] = "pe"
ENV["PUPPET_VERSION"] = "3.8.1"
expect(subject).to receive(:install_pe_on).with(hosts,{"pe_ver" => "3.8.1"})
expect(subject).to receive(:add_pe_defaults_on).with(hosts)
expect(subject).to receive(:add_puppet_paths_on).with(hosts)
subject.run_puppet_install_helper_on(hosts)
end
end
Expand Down

0 comments on commit bf2a4d6

Please sign in to comment.