beaker 1.10.0 → 1.11.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YmMxMzJlYWRhZjA1M2U5OWUxMGRhZWQ0NWU1Njg2MjA2OGUzNDRkOA==
4
+ NGI2MDZhMzFhYTIwNGMwNzViMzQ4MjU5NjczOWJhMmY3OGNmOWU2ZQ==
5
5
  data.tar.gz: !binary |-
6
- MzBiMjE4MGVmM2YyOTBiNmUzNzcwNGJhMWYyNTMzYzA0YmI1YzMzMQ==
6
+ MWM4MTYyNjdlYzM2NWNhYmU2OWFkMjc1NjhlZTZkNjI4MzRlOTNkNA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YzIyOWQ2MGVkNzk2MWZkZTY2NmQ4YzY1NmRjMGI4ZGMxMzEwNjc2YmI1NWFk
10
- MjEzY2NhYjdhNjI0MjNjMDIwN2U4MDk5YzEwY2NhNDk2NTg0NWIxMmY4OTFj
11
- YTI2MThkNGExNjVmYjIwNmU4OGY5YjQ5NDA0MTY4ZGE1OGI3NGE=
9
+ MjY3ZDE5N2MwYjEzMzYxYzk0ZGE3YTA1MzE4NjBjY2UyMzU0OTA3YjFjNzYw
10
+ NWUxZDJlYWM1N2JjYWM2YWU5YjJlMzRjZTNiMGViNjQ3ZTUzNzI1MTUxNGVk
11
+ ZmRjYzIzMDZlOGU5M2M5NzEzNmI5MTM1NGEyN2VmMDc3MGM1M2U=
12
12
  data.tar.gz: !binary |-
13
- YmE3OGU1MGIzMmRjMmM1MGM3MTcwMjdmODM5MzYyYzQ0ZWQyMWQ5N2E4YjQ3
14
- NDE2MzQ1YmU0ZDIxOWEwYTAxZDliOTBkOTEwMTQ2ZDJmMTQyNmQ3ZTI3MWU5
15
- YWQ1YWE3N2QwYmMyYTRkZjQwMjk2MGJlMGZjMjA4ODVjODEzMDQ=
13
+ MWU4NmVmN2I0MTQyMjgzZDk1YzI5NGZmOWJiZGEwMGU1MzZmMGI0OTg5NjI4
14
+ MzNiMTVhNWQ4M2JhMTIzM2E0YTM3MDI3YzFjMjU0NzRjNzI5MGYyN2U4MjNi
15
+ NjEzNWRiODVjY2UxNGVkOTA1MjU0MWM3OGY2YWY0Zjg3MGFmZjM=
@@ -2,10 +2,10 @@ before_install:
2
2
  - gem update --system 2.2.1
3
3
  - gem --version
4
4
  language: ruby
5
- script: "bundle exec rspec"
5
+ script: "bundle exec rake travis"
6
6
  notifications:
7
7
  email: false
8
8
  rvm:
9
9
  - 2.0.0
10
10
  - 1.9.3
11
- - 1.8.7
11
+ - 1.8.7-p374
data/Rakefile CHANGED
@@ -5,6 +5,15 @@ task :spec do
5
5
  Rake::Task['test:spec'].invoke
6
6
  end
7
7
 
8
+ task :yard do
9
+ Rake::Task['docs:gen'].invoke
10
+ end
11
+
12
+ task :travis do
13
+ Rake::Task['yard'].invoke unless RUBY_VERSION < '1.9'
14
+ Rake::Task['spec'].invoke
15
+ end
16
+
8
17
  namespace :test do
9
18
  desc 'Run specs (with coverage on 1.9), alias `spec` & the default'
10
19
  task :spec do
@@ -63,7 +72,11 @@ namespace :docs do
63
72
  task :gen => 'docs:clear' do
64
73
  original_dir = Dir.pwd
65
74
  Dir.chdir( File.expand_path(File.dirname(__FILE__)) )
66
- sh 'bundle exec yard doc'
75
+ output = `bundle exec yard doc`
76
+ puts output
77
+ if output =~ /\[warn\]|\[error\]/
78
+ raise "Errors/Warnings during yard documentation generation"
79
+ end
67
80
  Dir.chdir( original_dir )
68
81
  end
69
82
 
@@ -39,8 +39,9 @@ Gem::Specification.new do |s|
39
39
  s.add_runtime_dependency 'rbvmomi', '1.8.1'
40
40
  s.add_runtime_dependency 'blimpy', '~> 0.6'
41
41
  s.add_runtime_dependency 'fission', '~> 0.4'
42
- s.add_runtime_dependency 'google-api-client', '~> 0.6.4'
42
+ s.add_runtime_dependency 'google-api-client', '~> 0.7.1'
43
43
  s.add_runtime_dependency 'aws-sdk', '~> 1.38'
44
+ s.add_runtime_dependency 'docker-api' unless RUBY_VERSION < '1.9'
44
45
 
45
46
  # These are transitive dependencies that we include or pin to because...
46
47
  # Ruby 1.8 compatibility
@@ -46,13 +46,13 @@ module Beaker
46
46
  master_a[:q_puppetmaster_dnsaltnames]+=","+master['ip']
47
47
  end
48
48
 
49
- dashboard_user = "'#{ENV['q_puppet_enterpriseconsole_auth_user_email'] || 'admin@example.com'}'"
50
- smtp_host = "'#{ENV['q_puppet_enterpriseconsole_smtp_host'] || dashboard}'"
51
- dashboard_password = ENV['q_puppet_enterpriseconsole_auth_password'] || '~!@#$%^*-/ aZ'
52
- smtp_port = "'#{ENV['q_puppet_enterpriseconsole_smtp_port'] || 25}'"
53
- smtp_username = ENV['q_puppet_enterpriseconsole_smtp_username']
54
- smtp_password = ENV['q_puppet_enterpriseconsole_smtp_password']
55
- smtp_use_tls = "'#{ENV['q_puppet_enterpriseconsole_smtp_use_tls'] || 'n'}'"
49
+ dashboard_user = "'#{options[:answers][:q_puppet_enterpriseconsole_auth_user_email]}'"
50
+ smtp_host = "'#{options[:answers][:q_puppet_enterpriseconsole_smtp_host] || dashboard}'"
51
+ dashboard_password = options[:answers][:q_puppet_enterpriseconsole_auth_password]
52
+ smtp_port = "'#{options[:answers][:q_puppet_enterpriseconsole_smtp_port]}'"
53
+ smtp_username = options[:answers][:q_puppet_enterpriseconsole_smtp_username]
54
+ smtp_password = options[:answers][:q_puppet_enterpriseconsole_smtp_password]
55
+ smtp_use_tls = "'#{options[:answers][:q_puppet_enterpriseconsole_smtp_use_tls]}'"
56
56
 
57
57
  console_a = {
58
58
  :q_puppet_enterpriseconsole_install => 'y',
@@ -47,13 +47,13 @@ module Beaker
47
47
  master_a[:q_puppetmaster_dnsaltnames]+=","+master['ip']
48
48
  end
49
49
 
50
- dashboard_user = "'#{ENV['q_puppet_enterpriseconsole_auth_user_email'] || 'admin@example.com'}'"
51
- smtp_host = "'#{ENV['q_puppet_enterpriseconsole_smtp_host'] || dashboard}'"
52
- dashboard_password = ENV['q_puppet_enterpriseconsole_auth_password'] || '~!@#$%^*-/ aZ'
53
- smtp_port = "'#{ENV['q_puppet_enterpriseconsole_smtp_port'] || 25}'"
54
- smtp_username = ENV['q_puppet_enterpriseconsole_smtp_username']
55
- smtp_password = ENV['q_puppet_enterpriseconsole_smtp_password']
56
- smtp_use_tls = "'#{ENV['q_puppet_enterpriseconsole_smtp_use_tls'] || 'n'}'"
50
+ dashboard_user = "'#{options[:answers][:q_puppet_enterpriseconsole_auth_user_email]}'"
51
+ smtp_host = "'#{options[:answers][:q_puppet_enterpriseconsole_smtp_host] || dashboard}'"
52
+ dashboard_password = options[:answers][:q_puppet_enterpriseconsole_auth_password]
53
+ smtp_port = "'#{options[:answers][:q_puppet_enterpriseconsole_smtp_port]}'"
54
+ smtp_username = options[:answers][:q_puppet_enterpriseconsole_smtp_username]
55
+ smtp_password = options[:answers][:q_puppet_enterpriseconsole_smtp_password]
56
+ smtp_use_tls = "'#{options[:answers][:q_puppet_enterpriseconsole_smtp_use_tls]}'"
57
57
 
58
58
  console_a = {
59
59
  :q_puppet_enterpriseconsole_install => 'y',
@@ -22,7 +22,7 @@ module Beaker
22
22
  agent_a = {
23
23
  :q_puppetagent_install => 'y',
24
24
  :q_puppet_cloud_install => 'y',
25
- :q_verify_packages => ENV['q_verify_packages'] || 'y',
25
+ :q_verify_packages => options[:answers][:q_verify_packages],
26
26
  :q_puppet_symlinks_install => 'y',
27
27
  :q_puppetagent_certname => host,
28
28
  :q_puppetagent_server => master_certname,
@@ -66,8 +66,8 @@ module Beaker
66
66
  end
67
67
 
68
68
  # Common answers for console and database
69
- dashboard_password = "'#{ENV['q_puppet_enterpriseconsole_auth_password'] || '~!@#$%^*-/ aZ'}'"
70
- puppetdb_password = "'#{ENV['q_puppetdb_password'] || '~!@#$%^*-/ aZ'}'"
69
+ dashboard_password = "'#{options[:answers][:q_puppet_enterpriseconsole_auth_password]}'"
70
+ puppetdb_password = "'#{options[:answers][:q_puppetdb_password]}'"
71
71
 
72
72
  console_database_a = {
73
73
  :q_puppetdb_database_name => 'pe-puppetdb',
@@ -85,13 +85,14 @@ module Beaker
85
85
  }
86
86
 
87
87
  # Console only answers
88
- dashboard_user = "'#{ENV['q_puppet_enterpriseconsole_auth_user_email'] || 'admin@example.com'}'"
88
+ dashboard_user = "'#{options[:answers][:q_puppet_enterpriseconsole_auth_user_email]}'"
89
89
 
90
- smtp_host = "'#{ENV['q_puppet_enterpriseconsole_smtp_host'] || dashboard}'"
91
- smtp_port = "'#{ENV['q_puppet_enterpriseconsole_smtp_port'] || 25}'"
92
- smtp_username = ENV['q_puppet_enterpriseconsole_smtp_username']
93
- smtp_password = ENV['q_puppet_enterpriseconsole_smtp_password']
94
- smtp_use_tls = "'#{ENV['q_puppet_enterpriseconsole_smtp_use_tls'] || 'n'}'"
90
+
91
+ smtp_host = "'#{options[:answers][:q_puppet_enterpriseconsole_smtp_host] || dashboard}'"
92
+ smtp_port = "'#{options[:answers][:q_puppet_enterpriseconsole_smtp_port]}'"
93
+ smtp_username = options[:answers][:q_puppet_enterpriseconsole_smtp_username]
94
+ smtp_password = options[:answers][:q_puppet_enterpriseconsole_smtp_password]
95
+ smtp_use_tls = "'#{options[:answers][:q_puppet_enterpriseconsole_smtp_use_tls]}'"
95
96
 
96
97
  console_a = {
97
98
  :q_puppet_enterpriseconsole_install => 'y',
@@ -13,6 +13,7 @@ module Beaker
13
13
  # To mix this is into a class you need the following:
14
14
  # * a method *hosts* that yields any hosts implementing
15
15
  # {Beaker::Host}'s interface to act upon.
16
+ # * a method *options* that provides an options hash, see {Beaker::Options::OptionsHash}
16
17
  # * a method *logger* that yields a logger implementing
17
18
  # {Beaker::Logger}'s interface.
18
19
  # * the module {Beaker::DSL::Roles} that provides access to the various hosts implementing
@@ -245,7 +246,7 @@ module Beaker
245
246
  # @param [String] path The path to the generated repository config
246
247
  # files. ex: /myproject/pkg/repo_configs
247
248
  # @param [String] name A human-readable name for the repository
248
- # @param [String[ version The version of the project, as used by the
249
+ # @param [String] version The version of the project, as used by the
249
250
  # packaging tools. This can be determined with
250
251
  # `rake pl:print_build_params` from the packaging
251
252
  # repo.
@@ -667,7 +668,7 @@ module Beaker
667
668
  # :expect_failures to create the full list of
668
669
  # passing exit codes.
669
670
  #
670
- # @options opts [Hash] :environment Additional environment variables to be
671
+ # @option opts [Hash] :environment Additional environment variables to be
671
672
  # passed to the 'puppet apply' command
672
673
  #
673
674
  # @option opts [Boolean] :catch_failures (false) By default `puppet
@@ -698,6 +699,11 @@ module Beaker
698
699
  # from Puppet verion 3.2
699
700
  # By default it will use the 'current' parser.
700
701
  #
702
+ # @option opts [String] :modulepath The search path for modules, as
703
+ # a list of directories separated by the system
704
+ # path separator character. (The POSIX path separator
705
+ # is ‘:’, and the Windows path separator is ‘;’.)
706
+ #
701
707
  # @param [Block] block This method will yield to a block of code passed
702
708
  # by the caller; this can be used for additional
703
709
  # validation, etc.
@@ -716,6 +722,7 @@ module Beaker
716
722
  args << "--parseonly" if opts[:parseonly]
717
723
  args << "--trace" if opts[:trace]
718
724
  args << "--parser future" if opts[:future_parser]
725
+ args << "--modulepath #{opts[:modulepath]}" if opts[:modulepath]
719
726
 
720
727
  # From puppet help:
721
728
  # "... an exit code of '2' means there were changes, an exit code of
@@ -860,8 +867,12 @@ module Beaker
860
867
  # forge api v3 canonical source is forgeapi.puppetlabs.com
861
868
  #
862
869
  # @param machine [String] the host to perform the stub on
863
- def stub_forge_on(machine)
864
- @forge_ip ||= Resolv.getaddress(forge)
870
+ # @param forge_host [String] The URL to use as the forge alias, will default to using :forge_host in the
871
+ # global options hash
872
+ def stub_forge_on(machine, forge_host = nil)
873
+ #use global options hash
874
+ forge_host ||= options[:forge_host]
875
+ @forge_ip ||= Resolv.getaddress(forge_host)
865
876
  stub_hosts_on(machine, 'forge.puppetlabs.com' => @forge_ip)
866
877
  stub_hosts_on(machine, 'forgeapi.puppetlabs.com' => @forge_ip)
867
878
  end
@@ -870,8 +881,10 @@ module Beaker
870
881
  # the forge alias.
871
882
  #
872
883
  # @see #stub_forge_on
873
- def stub_forge
874
- stub_forge_on(default)
884
+ def stub_forge(forge_host = nil)
885
+ #use global options hash
886
+ forge_host ||= options[:forge_host]
887
+ stub_forge_on(default, forge_host)
875
888
  end
876
889
 
877
890
  def sleep_until_puppetdb_started(host)
@@ -1009,6 +1022,124 @@ module Beaker
1009
1022
  end
1010
1023
 
1011
1024
 
1025
+ #Install local module for acceptance testing
1026
+ # should be used as a presuite to ensure local module is copied to the hosts you want, particularly masters
1027
+ # @api dsl
1028
+ # @param [Host, Array<Host>, String, Symbol] host
1029
+ # One or more hosts to act upon,
1030
+ # or a role (String or Symbol) that identifies one or more hosts.
1031
+ # @option opts [String] :source ('./')
1032
+ # The current directory where the module sits, otherwise will try
1033
+ # and walk the tree to figure out
1034
+ # @option opts [String] :module_name (nil)
1035
+ # Name which the module should be installed under, please do not include author,
1036
+ # if none is provided it will attempt to parse the metadata.json and then the Modulefile to determine
1037
+ # the name of the module
1038
+ # @option opts [String] :target_module_path (host['puppetpath']/modules)
1039
+ # Location where the module should be installed, will default
1040
+ # to host['puppetpath']/modules
1041
+ # @raise [ArgumentError] if not host is provided or module_name is not provided and can not be found in Modulefile
1042
+ #
1043
+ def copy_root_module_to(host, opts = {})
1044
+ if !host
1045
+ raise(ArgumentError, "Host must be defined")
1046
+ end
1047
+ source = opts[:source] || parse_for_moduleroot(Dir.getwd)
1048
+ target_module_path = opts[:target_module_path] || "#{host['puppetpath']}/modules"
1049
+
1050
+ module_name = opts[:module_name] || parse_for_modulename(source)
1051
+ if !module_name
1052
+ logger.debug('Still unable to determine the modulename')
1053
+ raise(ArgumentError, "Unable to determine the module name, please update your call of puppet_module_install")
1054
+ end
1055
+
1056
+ module_dir = File.join(target_module_path, module_name)
1057
+ on host, "mkdir -p #{target_module_path}"
1058
+ ['manifests', 'lib', 'templates', 'metadata.json', 'Modulefile', 'files', 'Gemfile'].each do |item|
1059
+ item_source = File.join(source, item)
1060
+ if File.exists? item_source
1061
+ options = {}
1062
+ if File.directory? item_source
1063
+ on host, "mkdir -p #{File.join(module_dir, item)}"
1064
+ options = { :mkdir => true }
1065
+ end
1066
+ host.do_scp_to(item_source, module_dir, options)
1067
+ end
1068
+ end
1069
+ end
1070
+
1071
+
1072
+ #Recursive method for finding the module root
1073
+ # Assumes that a Modulefile exists
1074
+ # @param [String] possible_module_directory
1075
+ # will look for Modulefile and if none found go up one level and try again until root is reached
1076
+ #
1077
+ # @return [String,nil]
1078
+ def parse_for_moduleroot(possible_module_directory)
1079
+ if File.exists?("#{possible_module_directory}/Modulefile")
1080
+ possible_module_directory
1081
+ elsif possible_module_directory === '/'
1082
+ logger.error "At root, can't parse for another directory"
1083
+ nil
1084
+ else
1085
+ logger.debug "No Modulefile found at #{possible_module_directory}, moving up"
1086
+ parse_for_moduleroot File.expand_path(File.join(possible_module_directory,'..'))
1087
+ end
1088
+ end
1089
+
1090
+
1091
+ #Parse root directory of a module for module name
1092
+ # Searches for metadata.json and then if none found, Modulefile and parses for the Name attribute
1093
+ # @param [String] root_module_dir
1094
+ # @return [String] module name
1095
+ def parse_for_modulename(root_module_dir)
1096
+ module_name = nil
1097
+ if File.exists?("#{root_module_dir}/metadata.json")
1098
+ logger.debug "Attempting to parse Modulename from metadata.json"
1099
+ module_json = JSON.parse (File.read "#{root_module_dir}/metadata.json")
1100
+ if(module_json.has_key?('name'))
1101
+ module_name = get_module_name(module_json['name'])
1102
+ end
1103
+ end
1104
+ if !module_name && File.exists?("#{root_module_dir}/Modulefile")
1105
+ logger.debug "Attempting to parse Modulename from Modulefile"
1106
+ if /^name\s+'?(\w+-\w+)'?\s*$/i.match(File.read("#{root_module_dir}/Modulefile"))
1107
+ module_name = get_module_name(Regexp.last_match[1])
1108
+ end
1109
+ end
1110
+ if !module_name
1111
+ logger.debug "Unable to determine name, returning null"
1112
+ end
1113
+ module_name
1114
+ end
1115
+
1116
+ #Parse modulename from the pattern 'Auther-ModuleName'
1117
+ #
1118
+ # @param [String] author_module_name <Author>-<ModuleName> pattern
1119
+ #
1120
+ # @return [String,nil]
1121
+ #
1122
+ def get_module_name(author_module_name)
1123
+ split_name = split_author_modulename(author_module_name)
1124
+ if split_name
1125
+ split_name[:module]
1126
+ end
1127
+ end
1128
+
1129
+ #Split the Author-Name into a hash
1130
+ # @param [String] author_module_attr
1131
+ #
1132
+ # @return [Hash<Symbol,String>,nil] :author and :module symbols will be returned
1133
+ #
1134
+ def split_author_modulename(author_module_attr)
1135
+ result = /(\w+)-(\w+)/.match(author_module_attr)
1136
+ if result
1137
+ {:author => result[1], :module => result[2]}
1138
+ else
1139
+ nil
1140
+ end
1141
+ end
1142
+
1012
1143
  end
1013
1144
  end
1014
1145
  end
@@ -6,6 +6,14 @@ module Beaker
6
6
  # This module contains methods to help cloning, extracting git info,
7
7
  # ordering of Puppet packages, and installing ruby projects that
8
8
  # contain an `install.rb` script.
9
+ #
10
+ # To mix this is into a class you need the following:
11
+ # * a method *hosts* that yields any hosts implementing
12
+ # {Beaker::Host}'s interface to act upon.
13
+ # * a method *options* that provides an options hash, see {Beaker::Options::OptionsHash}
14
+ # * the module {Beaker::DSL::Roles} that provides access to the various hosts implementing
15
+ # {Beaker::Host}'s interface to act upon
16
+ # * the module {Beaker::DSL::Wrappers} the provides convenience methods for {Beaker::DSL::Command} creation
9
17
  module InstallUtils
10
18
 
11
19
  # The default install path
@@ -132,18 +140,18 @@ module Beaker
132
140
  #Create the PE install command string based upon the host and options settings
133
141
  # @param [Host] host The host that PE is to be installed on
134
142
  # For UNIX machines using the full PE installer, the host object must have the 'pe_installer' field set correctly.
135
- # @param [Hash{Symbol=>String}] options The options
136
- # @option options [String] :pe_ver_win Default PE version to install or upgrade to on Windows hosts
143
+ # @param [Hash{Symbol=>String}] opts The options
144
+ # @option opts [String] :pe_ver_win Default PE version to install or upgrade to on Windows hosts
137
145
  # (Othersie uses individual Windows hosts pe_ver)
138
- # @option options [String :pe_ver Default PE version to install or upgrade to
146
+ # @option opts [String :pe_ver Default PE version to install or upgrade to
139
147
  # (Otherwise uses individual hosts pe_ver)
140
148
  # @example
141
- # on host, "#{installer_cmd(host, options)} -a #{host['working_dir']}/answers"
149
+ # on host, "#{installer_cmd(host, opts)} -a #{host['working_dir']}/answers"
142
150
  # @api private
143
- def installer_cmd(host, options)
144
- version = options[:pe_ver] || host['pe_ver']
151
+ def installer_cmd(host, opts)
152
+ version = opts[:pe_ver] || host['pe_ver']
145
153
  if host['platform'] =~ /windows/
146
- version = options[:pe_ver_win] || host['pe_ver']
154
+ version = opts[:pe_ver_win] || host['pe_ver']
147
155
  "cd #{host['working_dir']} && cmd /C 'start /w msiexec.exe /qn /i puppet-enterprise-#{version}.msi PUPPET_MASTER_SERVER=#{master} PUPPET_AGENT_CERTNAME=#{host}'"
148
156
  # Frictionless install didn't exist pre-3.2.0, so in that case we fall
149
157
  # through and do a regular install.
@@ -174,18 +182,18 @@ module Beaker
174
182
 
175
183
  #Determine the PE package to download/upload on a windows host, download/upload that package onto the host.
176
184
  # @param [Host] host The windows host to download/upload and unpack PE onto
177
- # @param [Hash{Symbol=>Symbol, String}] options The options
178
- # @option options [String] :pe_dir Default directory or URL to pull PE package from
185
+ # @param [Hash{Symbol=>Symbol, String}] opts The options
186
+ # @option opts [String] :pe_dir Default directory or URL to pull PE package from
179
187
  # (Otherwise uses individual hosts pe_dir)
180
- # @option options [String] :pe_ver Default PE version to install or upgrade to
188
+ # @option opts [String] :pe_ver Default PE version to install or upgrade to
181
189
  # (Otherwise uses individual hosts pe_ver)
182
- # @option options [String] :pe_ver_win Default PE version to install or upgrade to on Windows hosts
190
+ # @option opts [String] :pe_ver_win Default PE version to install or upgrade to on Windows hosts
183
191
  # (Otherwise uses individual Windows hosts pe_ver)
184
192
  # @api private
185
- def fetch_puppet_on_windows(host, options)
186
- path = options[:pe_dir] || host['pe_dir']
193
+ def fetch_puppet_on_windows(host, opts)
194
+ path = opts[:pe_dir] || host['pe_dir']
187
195
  local = File.directory?(path)
188
- version = options[:pe_ver_win] || host['pe_ver']
196
+ version = opts[:pe_ver_win] || host['pe_ver']
189
197
  filename = "puppet-enterprise-#{version}"
190
198
  extension = ".msi"
191
199
  if local
@@ -204,14 +212,14 @@ module Beaker
204
212
  #Determine the PE package to download/upload on a unix style host, download/upload that package onto the host
205
213
  #and unpack it.
206
214
  # @param [Host] host The unix style host to download/upload and unpack PE onto
207
- # @param [Hash{Symbol=>Symbol, String}] options The options
208
- # @option options [String] :pe_dir Default directory or URL to pull PE package from
215
+ # @param [Hash{Symbol=>Symbol, String}] opts The options
216
+ # @option opts [String] :pe_dir Default directory or URL to pull PE package from
209
217
  # (Otherwise uses individual hosts pe_dir)
210
- # @option options [String] :pe_ver Default PE version to install or upgrade to
218
+ # @option opts [String] :pe_ver Default PE version to install or upgrade to
211
219
  # (Otherwise uses individual hosts pe_ver)
212
220
  # @api private
213
- def fetch_puppet_on_unix(host, options)
214
- path = options[:pe_dir] || host['pe_dir']
221
+ def fetch_puppet_on_unix(host, opts)
222
+ path = opts[:pe_dir] || host['pe_dir']
215
223
  local = File.directory?(path)
216
224
  filename = "#{host['dist']}"
217
225
  if local
@@ -241,24 +249,24 @@ module Beaker
241
249
  #Determine the PE package to download/upload per-host, download/upload that package onto the host
242
250
  #and unpack it.
243
251
  # @param [Array<Host>] hosts The hosts to download/upload and unpack PE onto
244
- # @param [Hash{Symbol=>Symbol, String}] options The options
245
- # @option options [String] :pe_dir Default directory or URL to pull PE package from
252
+ # @param [Hash{Symbol=>Symbol, String}] opts The options
253
+ # @option opts [String] :pe_dir Default directory or URL to pull PE package from
246
254
  # (Otherwise uses individual hosts pe_dir)
247
- # @option options [String] :pe_ver Default PE version to install or upgrade to
255
+ # @option opts [String] :pe_ver Default PE version to install or upgrade to
248
256
  # (Otherwise uses individual hosts pe_ver)
249
- # @option options [String] :pe_ver_win Default PE version to install or upgrade to on Windows hosts
257
+ # @option opts [String] :pe_ver_win Default PE version to install or upgrade to on Windows hosts
250
258
  # (Otherwise uses individual Windows hosts pe_ver)
251
259
  # @api private
252
- def fetch_puppet(hosts, options)
260
+ def fetch_puppet(hosts, opts)
253
261
  hosts.each do |host|
254
262
  # We install Puppet from the master for frictionless installs, so we don't need to *fetch* anything
255
- next if host['roles'].include? 'frictionless' and ! version_is_less(options[:pe_ver] || host['pe_ver'], '3.2.0')
263
+ next if host['roles'].include? 'frictionless' and ! version_is_less(opts[:pe_ver] || host['pe_ver'], '3.2.0')
256
264
 
257
265
  windows = host['platform'] =~ /windows/
258
266
  if windows
259
- fetch_puppet_on_windows(host, options)
267
+ fetch_puppet_on_windows(host, opts)
260
268
  else
261
- fetch_puppet_on_unix(host, options)
269
+ fetch_puppet_on_unix(host, opts)
262
270
  end
263
271
  end
264
272
  end
@@ -276,26 +284,28 @@ module Beaker
276
284
 
277
285
  #Perform a Puppet Enterprise upgrade or install
278
286
  # @param [Array<Host>] hosts The hosts to install or upgrade PE on
279
- # @param [Hash{Symbol=>Symbol, String}] options The options
280
- # @option options [String] :pe_dir Default directory or URL to pull PE package from
287
+ # @param [Hash{Symbol=>Symbol, String}] opts The options
288
+ # @option opts [String] :pe_dir Default directory or URL to pull PE package from
281
289
  # (Otherwise uses individual hosts pe_dir)
282
- # @option options [String] :pe_ver Default PE version to install or upgrade to
290
+ # @option opts [String] :pe_ver Default PE version to install or upgrade to
283
291
  # (Otherwise uses individual hosts pe_ver)
284
- # @option options [String] :pe_ver_win Default PE version to install or upgrade to on Windows hosts
292
+ # @option opts [String] :pe_ver_win Default PE version to install or upgrade to on Windows hosts
285
293
  # (Otherwise uses individual Windows hosts pe_ver)
286
- # @option options [Symbol] :type (:install) One of :upgrade or :install
294
+ # @option opts [Symbol] :type (:install) One of :upgrade or :install
295
+ # @option opts [Hash<String>] :answers Pre-set answers based upon ENV vars and defaults
296
+ # (See {Beaker::Options::Presets.env_vars})
287
297
  #
288
298
  # @example
289
299
  # do_install(hosts, {:type => :upgrade, :pe_dir => path, :pe_ver => version, :pe_ver_win => version_win})
290
300
  #
291
301
  # @api private
292
302
  #
293
- def do_install hosts, options = {}
294
- options[:type] = options[:type] || :install
303
+ def do_install hosts, opts = {}
304
+ opts[:type] = opts[:type] || :install
295
305
  hostcert='uname | grep -i sunos > /dev/null && hostname || hostname -s'
296
306
  master_certname = on(master, hostcert).stdout.strip
297
- pre30database = version_is_less(options[:pe_ver] || database['pe_ver'], '3.0')
298
- pre30master = version_is_less(options[:pe_ver] || master['pe_ver'], '3.0')
307
+ pre30database = version_is_less(opts[:pe_ver] || database['pe_ver'], '3.0')
308
+ pre30master = version_is_less(opts[:pe_ver] || master['pe_ver'], '3.0')
299
309
 
300
310
  # Set PE distribution for all the hosts, create working dir
301
311
  use_all_tar = ENV['PE_USE_ALL_TAR'] == 'true'
@@ -303,25 +313,25 @@ module Beaker
303
313
  host['pe_installer'] ||= 'puppet-enterprise-installer'
304
314
  if host['platform'] !~ /windows/
305
315
  platform = use_all_tar ? 'all' : host['platform']
306
- version = options[:pe_ver] || host['pe_ver']
316
+ version = opts[:pe_ver] || host['pe_ver']
307
317
  host['dist'] = "puppet-enterprise-#{version}-#{platform}"
308
318
  end
309
319
  host['working_dir'] = "/tmp/" + Time.new.strftime("%Y-%m-%d_%H.%M.%S") #unique working dirs make me happy
310
320
  on host, "mkdir #{host['working_dir']}"
311
321
  end
312
322
 
313
- fetch_puppet(hosts, options)
323
+ fetch_puppet(hosts, opts)
314
324
 
315
325
  hosts.each do |host|
316
326
  # Database host was added in 3.0. Skip it if installing an older version
317
327
  next if host == database and host != master and host != dashboard and pre30database
318
328
  if host['platform'] =~ /windows/
319
- on host, installer_cmd(host, options)
329
+ on host, installer_cmd(host, opts)
320
330
  else
321
331
  # We only need answers if we're using the classic installer
322
- version = options[:pe_ver] || host['pe_ver']
332
+ version = opts[:pe_ver] || host['pe_ver']
323
333
  if (! host['roles'].include? 'frictionless') || version_is_less(version, '3.2.0')
324
- answers = Beaker::Answers.answers(options[:pe_ver] || host['pe_ver'], hosts, master_certname, options)
334
+ answers = Beaker::Answers.answers(opts[:pe_ver] || host['pe_ver'], hosts, master_certname, opts)
325
335
  create_remote_file host, "#{host['working_dir']}/answers", Beaker::Answers.answer_string(host, answers)
326
336
  else
327
337
  # If We're *not* running the classic installer, we want
@@ -329,7 +339,7 @@ module Beaker
329
339
  deploy_frictionless_to_master(host)
330
340
  end
331
341
 
332
- on host, installer_cmd(host, options)
342
+ on host, installer_cmd(host, opts)
333
343
  end
334
344
  end
335
345
 
@@ -440,7 +450,7 @@ module Beaker
440
450
  # @return nil
441
451
  def install_puppet
442
452
  hosts.each do |host|
443
- if host['platform'] =~ /el-(5|6)/
453
+ if host['platform'] =~ /el-(5|6|7)/
444
454
  relver = $1
445
455
  on host, "rpm -ivh http://yum.puppetlabs.com/puppetlabs-release-el-#{relver}.noarch.rpm"
446
456
  on host, 'yum install -y puppet'
@@ -449,6 +459,9 @@ module Beaker
449
459
  on host, "rpm -ivh http://yum.puppetlabs.com/puppetlabs-release-fedora-#{relver}.noarch.rpm"
450
460
  on host, 'yum install -y puppet'
451
461
  elsif host['platform'] =~ /(ubuntu|debian)/
462
+ if ! host.check_for_package 'lsb-release'
463
+ host.install_package('lsb-release')
464
+ end
452
465
  if ! host.check_for_package 'curl'
453
466
  on host, 'apt-get install -y curl'
454
467
  end
@@ -484,7 +497,8 @@ module Beaker
484
497
  Beaker::Options::PEVersionScraper.load_pe_version(host[:pe_dir] || options[:pe_dir], options[:pe_version_file])
485
498
  end
486
499
  end
487
- do_install sorted_hosts
500
+ #send in the global options hash
501
+ do_install sorted_hosts, options
488
502
  end
489
503
 
490
504
  #Upgrade PE based upon host configuration and options
@@ -512,7 +526,8 @@ module Beaker
512
526
  host['pe_installer'] ||= 'puppet-enterprise-upgrader'
513
527
  end
514
528
  end
515
- do_install(sorted_hosts, {:type => :upgrade})
529
+ #send in the global options hash
530
+ do_install(sorted_hosts, options.merge({:type => :upgrade}))
516
531
  end
517
532
  end
518
533
  end