beaker-puppet_install_helper 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MTE3YjkzOTlhZjAwYjAyYzI5NmJmY2U4ZjNhYzBjNmRmODA1NThlNA==
5
+ data.tar.gz: !binary |-
6
+ MTdlYjcxZTJkZTc4YTg4YzlkYzAwYjBiNGUyYTZiZDljMmU2NDA1ZQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ ZjYxZTAyNmM5ZjViMjQ4MTRmMDQxMjBhYjYxZWEyOWM3YjhmMzgyODYwMzU5
10
+ NzBkZWQxMTY4YjMxY2VjYzMzNmIyMGIyZjc3OTYxOTNiOGFiMzk2ZjdhMjRi
11
+ YmVkYTczNDJmYmRhZmMzOTJiMzU4MDY5Nzc2YTkwMjdhNWJmMGM=
12
+ data.tar.gz: !binary |-
13
+ NmU3MDRiZWYwZDFhYTliYmUxY2FmZDA0MTUyOGRjYTA2MDg4OWI0YjY5ZGY3
14
+ MTUwMGZlZTNlMTYwZjUwYWU4YTIyMGUxNWE1OWM0OGQ1ZDIxZWMwMzAyNjVm
15
+ NDY0Y2Q1NjkyOTZiY2IwMzE4ZmRmZTJkYzU1NzVkM2ZlOWQyMGM=
@@ -0,0 +1,3 @@
1
+ Gemfile.lock
2
+ .bundle
3
+ *.swp
data/Gemfile ADDED
@@ -0,0 +1,48 @@
1
+ source ENV['GEM_SOURCE'] || "https://rubygems.org"
2
+
3
+ gemspec
4
+ #def location_for(place, fake_version = nil)
5
+ # if place =~ /^(git:[^#]*)#(.*)/
6
+ # [fake_version, { :git => $1, :branch => $2, :require => false }].compact
7
+ # elsif place =~ /^file:\/\/(.*)/
8
+ # ['>= 0', { :path => File.expand_path($1), :require => false }]
9
+ # else
10
+ # [place, { :require => false }]
11
+ # end
12
+ #end
13
+ #
14
+ #group :development, :unit_tests do
15
+ # gem 'rspec-core', '3.1.7', :require => false
16
+ # gem 'puppetlabs_spec_helper', :require => false
17
+ # gem 'simplecov', :require => false
18
+ # gem 'puppet_facts', :require => false
19
+ # gem 'json', :require => false
20
+ #end
21
+ #
22
+ #group :system_tests do
23
+ # if beaker_version = ENV['BEAKER_VERSION']
24
+ # gem 'beaker', *location_for(beaker_version)
25
+ # end
26
+ # if beaker_rspec_version = ENV['BEAKER_RSPEC_VERSION']
27
+ # gem 'beaker-rspec', *location_for(beaker_rspec_version)
28
+ # else
29
+ # gem 'beaker-rspec', :require => false
30
+ # end
31
+ # gem 'serverspec', :require => false
32
+ #end
33
+ #
34
+ #
35
+ #
36
+ #if facterversion = ENV['FACTER_GEM_VERSION']
37
+ # gem 'facter', facterversion, :require => false
38
+ #else
39
+ # gem 'facter', :require => false
40
+ #end
41
+ #
42
+ #if puppetversion = ENV['PUPPET_GEM_VERSION']
43
+ # gem 'puppet', puppetversion, :require => false
44
+ #else
45
+ # gem 'puppet', :require => false
46
+ #end
47
+ #
48
+ ## vim:ft=ruby
@@ -0,0 +1,22 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "beaker-puppet_install_helper"
3
+ s.version = '0.1.0'
4
+ s.authors = ["Puppetlabs"]
5
+ s.email = ["hunter@puppetlabs.com"]
6
+ s.homepage = "https://github.com/puppetlabs/beaker-puppet_install_helper"
7
+ s.summary = %q{Puppet install helper for Beaker}
8
+ s.description = %q{Puppet install helper for Beaker, see https://github.com/puppetlabs/beaker}
9
+ s.license = 'Apache-2'
10
+
11
+
12
+ s.files = `git ls-files`.split("\n")
13
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
15
+ s.require_paths = ["lib"]
16
+
17
+ ## Testing dependencies
18
+ s.add_development_dependency 'rspec'
19
+
20
+ # Run time dependencies
21
+ s.add_runtime_dependency 'beaker', '~> 2.0'
22
+ end
@@ -0,0 +1,68 @@
1
+ require 'beaker'
2
+
3
+ module Beaker::PuppetInstallHelper
4
+ def run_puppet_install_helper(type_arg=find_install_type,version=ENV["PUPPET_VERSION"])
5
+ run_puppet_install_helper_on(hosts,type_arg,version)
6
+ end
7
+
8
+ # Takes a host(s) object, install type string, and install version string.
9
+ # - Type defaults to PE for PE nodes, and foss otherwise.
10
+ # - Version will default to the latest 3x foss/pe package, depending on type
11
+ def run_puppet_install_helper_on(hosts,type_arg=find_install_type,version=ENV["PUPPET_VERSION"])
12
+ # Short circuit based on rspec-system and beaker variables
13
+ return if ENV["RS_PROVISION"] == "no" or ENV["BEAKER_provision"] == "no"
14
+
15
+ type = type_arg || find_install_type
16
+
17
+ # Example environment variables to be read:
18
+ # PUPPET_VERSION=3.8.1 <-- for foss/pe/gem
19
+ # PUPPET_VERSION=4.1.0 <-- for agent/gem
20
+ # PUPPET_VERSION=1.0.1 <-- for agent
21
+ #
22
+ # PUPPET_INSTALL_TYPE=pe
23
+ # PUPPET_INSTALL_TYPE=foss
24
+ # PUPPET_INSTALL_TYPE=agent
25
+
26
+ case type
27
+ when "pe"
28
+ # This will skip hosts that are not supported
29
+ install_pe_on(hosts,{"pe_ver" => version})
30
+ when "foss"
31
+ foss_opts = {
32
+ :version => version,
33
+ :default_action => "gem_install",
34
+ }
35
+
36
+ install_puppet_on(hosts, foss_opts)
37
+ Array(hosts).each do |host|
38
+ if fact_on(host,"osfamily") != "windows"
39
+ on host, "mkdir -p #{host["distmoduledir"]}"
40
+ on host, "touch #{host["hieraconf"]}"
41
+ end
42
+ if fact_on(host, "operatingsystem") == "Debian"
43
+ on host, "echo 'export PATH=/var/lib/gems/1.8/bin/:${PATH}' >> ~/.bashrc"
44
+ end
45
+ if fact_on(host, "operatingsystem") == "Solaris"
46
+ on host, "echo 'export PATH=/opt/puppet/bin:/var/ruby/1.8/gem_home/bin:${PATH}' >> ~/.bashrc"
47
+ end
48
+ end
49
+ when "agent"
50
+ # This will fail on hosts that are not supported; use foss and specify a 4.x version instead
51
+ install_puppet_agent_on(hosts, {:version => version})
52
+ else
53
+ raise ArgumentError, "Type must be pe, foss, or agent; got #{type.inspect}"
54
+ end
55
+ end
56
+
57
+ def find_install_type
58
+ if type = ENV["PUPPET_INSTALL_TYPE"]
59
+ type
60
+ elsif default.is_pe?
61
+ "pe"
62
+ else
63
+ "foss"
64
+ end
65
+ end
66
+ end
67
+
68
+ include Beaker::PuppetInstallHelper
@@ -0,0 +1 @@
1
+ require 'beaker/puppet_install_helper'
@@ -0,0 +1,87 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'beaker::puppet_install_helper' do
4
+ let :subject do
5
+ Class.new { include Beaker::PuppetInstallHelper }
6
+ end
7
+ let :hosts do
8
+ host = { "distmoduledir" => "/dne", "hieraconf" => "/dne" }
9
+ [ host, host, host, ]
10
+ end
11
+ before :each do
12
+ allow(subject).to receive(:on)
13
+ allow(subject).to receive(:fact_on)
14
+ end
15
+ after :each do
16
+ ENV.delete("PUPPET_VERSION")
17
+ ENV.delete("PUPPET_INSTALL_TYPE")
18
+ end
19
+ describe '#run_puppet_install_helper' do
20
+ before :each do
21
+ expect(subject).to receive(:default).and_return(double(:is_pe? => false))
22
+ expect(subject).to receive(:hosts).and_return(hosts)
23
+ end
24
+ it 'calls run_puppet_install_helper_on on each host' do
25
+ expect(subject).to receive(:run_puppet_install_helper_on).with(hosts,"foss",nil)
26
+ subject.run_puppet_install_helper
27
+ end
28
+ it 'calls run_puppet_install_helper_on on each host with a version ' do
29
+ ENV["PUPPET_VERSION"] = "4.1.0"
30
+ expect(subject).to receive(:run_puppet_install_helper_on).with(hosts,"foss","4.1.0")
31
+ subject.run_puppet_install_helper
32
+ end
33
+ end
34
+ describe '#run_puppet_install_helper_on' do
35
+ context "for default" do
36
+ it "uses foss by default for non-pe nodes" do
37
+ expect(subject).to receive(:default).and_return(double(:is_pe? => false))
38
+ expect(subject).to receive(:install_puppet_on).with(hosts,{:version => nil,:default_action => "gem_install"})
39
+ subject.run_puppet_install_helper_on(hosts)
40
+ end
41
+ it "uses PE by default for PE nodes" do
42
+ expect(subject).to receive(:default).and_return(double(:is_pe? => true))
43
+ expect(subject).to receive(:install_pe_on).with(hosts,{"pe_ver" => nil})
44
+ subject.run_puppet_install_helper_on(hosts)
45
+ end
46
+ end
47
+ context "for foss" do
48
+ it "uses foss explicitly" do
49
+ ENV["PUPPET_INSTALL_TYPE"] = "foss"
50
+ expect(subject).to receive(:install_puppet_on).with(hosts,{:version => nil,:default_action => "gem_install"})
51
+ subject.run_puppet_install_helper_on(hosts)
52
+ end
53
+ it "uses foss with a version" do
54
+ ENV["PUPPET_INSTALL_TYPE"] = "foss"
55
+ ENV["PUPPET_VERSION"] = "3.8.1"
56
+ expect(subject).to receive(:install_puppet_on).with(hosts,{:version => "3.8.1",:default_action => "gem_install"})
57
+ subject.run_puppet_install_helper_on(hosts)
58
+ end
59
+ end
60
+ context "for PE" do
61
+ it "uses PE explicitly" do
62
+ ENV["PUPPET_INSTALL_TYPE"] = "pe"
63
+ expect(subject).to receive(:install_pe_on).with(hosts,{"pe_ver" => nil})
64
+ subject.run_puppet_install_helper_on(hosts)
65
+ end
66
+ it "uses PE with a version" do
67
+ ENV["PUPPET_INSTALL_TYPE"] = "pe"
68
+ ENV["PUPPET_VERSION"] = "3.8.1"
69
+ expect(subject).to receive(:install_pe_on).with(hosts,{"pe_ver" => "3.8.1"})
70
+ subject.run_puppet_install_helper_on(hosts)
71
+ end
72
+ end
73
+ context "for puppet-agent" do
74
+ it "uses agent explicitly" do
75
+ ENV["PUPPET_INSTALL_TYPE"] = "agent"
76
+ expect(subject).to receive(:install_puppet_agent_on).with(hosts,{:version => nil})
77
+ subject.run_puppet_install_helper_on(hosts)
78
+ end
79
+ it "uses foss with a version" do
80
+ ENV["PUPPET_INSTALL_TYPE"] = "agent"
81
+ ENV["PUPPET_VERSION"] = "1.1.0"
82
+ expect(subject).to receive(:install_puppet_agent_on).with(hosts,{:version => "1.1.0"})
83
+ subject.run_puppet_install_helper_on(hosts)
84
+ end
85
+ end
86
+ end
87
+ end
metadata ADDED
@@ -0,0 +1,81 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: beaker-puppet_install_helper
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Puppetlabs
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-06-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ! '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: beaker
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '2.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '2.0'
41
+ description: Puppet install helper for Beaker, see https://github.com/puppetlabs/beaker
42
+ email:
43
+ - hunter@puppetlabs.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - .gitignore
49
+ - Gemfile
50
+ - beaker-puppet_install_helper.gemspec
51
+ - lib/beaker/puppet_install_helper.rb
52
+ - spec/spec_helper.rb
53
+ - spec/unit/beaker/puppet_install_helper_spec.rb
54
+ homepage: https://github.com/puppetlabs/beaker-puppet_install_helper
55
+ licenses:
56
+ - Apache-2
57
+ metadata: {}
58
+ post_install_message:
59
+ rdoc_options: []
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ! '>='
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ! '>='
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ requirements: []
73
+ rubyforge_project:
74
+ rubygems_version: 2.4.5
75
+ signing_key:
76
+ specification_version: 4
77
+ summary: Puppet install helper for Beaker
78
+ test_files:
79
+ - spec/spec_helper.rb
80
+ - spec/unit/beaker/puppet_install_helper_spec.rb
81
+ has_rdoc: