lib/beaker/dsl/install_utils.rb in beaker-1.11.2 vs lib/beaker/dsl/install_utils.rb in beaker-1.12.0

- old
+ new

@@ -147,14 +147,18 @@ # (Otherwise uses individual hosts pe_ver) # @example # on host, "#{installer_cmd(host, opts)} -a #{host['working_dir']}/answers" # @api private def installer_cmd(host, opts) - version = opts[:pe_ver] || host['pe_ver'] + version = host['pe_ver'] || opts[:pe_ver] if host['platform'] =~ /windows/ version = opts[:pe_ver_win] || host['pe_ver'] "cd #{host['working_dir']} && cmd /C 'start /w msiexec.exe /qn /i puppet-enterprise-#{version}.msi PUPPET_MASTER_SERVER=#{master} PUPPET_AGENT_CERTNAME=#{host}'" + elsif host['platform'] =~ /osx/ + version = host['pe_ver'] || opts[:pe_ver] + "cd #{host['working_dir']} && hdiutil attach #{host['dist']}.dmg && installer -pkg /Volumes/puppet-enterprise-#{version}/puppet-enterprise-installer-#{version}.pkg -target /" + # Frictionless install didn't exist pre-3.2.0, so in that case we fall # through and do a regular install. elsif host['roles'].include? 'frictionless' and ! version_is_less(version, '3.2.0') "cd #{host['working_dir']} && curl -kO https://#{master}:8140/packages/#{version}/install.bash && bash install.bash" else @@ -178,19 +182,43 @@ http.start do |http| return http.head(url.request_uri).code == "200" end end + #Determine the PE package to download/upload on a mac host, download/upload that package onto the host. + # Assumed file name format: puppet-enterprise-3.3.0-rc1-559-g97f0833-osx-10.9-x86_64.dmg. + # @param [Host] host The mac host to download/upload and unpack PE onto + # @param [Hash{Symbol=>Symbol, String}] opts The options + # @option opts [String] :pe_dir Default directory or URL to pull PE package from + # (Otherwise uses individual hosts pe_dir) + # @api private + def fetch_puppet_on_mac(host, opts) + path = host['pe_dir'] || opts[:pe_dir] + local = File.directory?(path) + filename = "#{host['dist']}" + extension = ".dmg" + if local + if not File.exists?("#{path}/#{filename}#{extension}") + raise "attempting installation on #{host}, #{path}/#{filename}#{extension} does not exist" + end + scp_to host, "#{path}/#{filename}#{extension}", "#{host['working_dir']}/#{filename}#{extension}" + else + if not link_exists?("#{path}/#{filename}#{extension}") + raise "attempting installation on #{host}, #{path}/#{filename}#{extension} does not exist" + end + on host, "cd #{host['working_dir']}; curl -O #{path}/#{filename}#{extension}" + end + end + #Determine the PE package to download/upload on a windows host, download/upload that package onto the host. + #Assumed file name format: puppet-enterprise-3.3.0-rc1-559-g97f0833.msi # @param [Host] host The windows host to download/upload and unpack PE onto # @param [Hash{Symbol=>Symbol, String}] opts The options # @option opts [String] :pe_dir Default directory or URL to pull PE package from # (Otherwise uses individual hosts pe_dir) - # @option opts [String] :pe_ver Default PE version to install or upgrade to + # @option opts [String] :pe_ver_win Default PE version to install or upgrade to # (Otherwise uses individual hosts pe_ver) - # @option opts [String] :pe_ver_win Default PE version to install or upgrade to on Windows hosts - # (Otherwise uses individual Windows hosts pe_ver) # @api private def fetch_puppet_on_windows(host, opts) path = host['pe_dir'] || opts[:pe_dir] local = File.directory?(path) version = host['pe_ver'] || opts[:pe_ver_win] @@ -213,12 +241,10 @@ #and unpack it. # @param [Host] host The unix style host to download/upload and unpack PE onto # @param [Hash{Symbol=>Symbol, String}] opts The options # @option opts [String] :pe_dir Default directory or URL to pull PE package from # (Otherwise uses individual hosts pe_dir) - # @option opts [String] :pe_ver Default PE version to install or upgrade to - # (Otherwise uses individual hosts pe_ver) # @api private def fetch_puppet_on_unix(host, opts) path = host['pe_dir'] || opts[:pe_dir] local = File.directory?(path) filename = "#{host['dist']}" @@ -260,13 +286,14 @@ def fetch_puppet(hosts, opts) hosts.each do |host| # We install Puppet from the master for frictionless installs, so we don't need to *fetch* anything next if host['roles'].include? 'frictionless' and ! version_is_less(opts[:pe_ver] || host['pe_ver'], '3.2.0') - windows = host['platform'] =~ /windows/ - if windows + if host['platform'] =~ /windows/ fetch_puppet_on_windows(host, opts) + elsif host['platform'] =~ /osx/ + fetch_puppet_on_mac(host, opts) else fetch_puppet_on_unix(host, opts) end end end @@ -309,14 +336,17 @@ # Set PE distribution for all the hosts, create working dir use_all_tar = ENV['PE_USE_ALL_TAR'] == 'true' hosts.each do |host| host['pe_installer'] ||= 'puppet-enterprise-installer' - if host['platform'] !~ /windows/ + if host['platform'] !~ /windows|osx/ platform = use_all_tar ? 'all' : host['platform'] version = host['pe_ver'] || opts[:pe_ver] host['dist'] = "puppet-enterprise-#{version}-#{platform}" + elsif host['platform'] =~ /osx/ + version = host['pe_ver'] || opts[:pe_ver] + host['dist'] = "puppet-enterprise-#{version}-#{host['platform']}" end host['working_dir'] = "/tmp/" + Time.new.strftime("%Y-%m-%d_%H.%M.%S") #unique working dirs make me happy on host, "mkdir #{host['working_dir']}" end @@ -325,10 +355,17 @@ hosts.each do |host| # Database host was added in 3.0. Skip it if installing an older version next if host == database and host != master and host != dashboard and pre30database if host['platform'] =~ /windows/ on host, installer_cmd(host, opts) + elsif host['platform'] =~ /osx/ + on host, installer_cmd(host, opts) + #set the certname and master + on host, puppet("config set server #{master}") + on host, puppet("config set certname #{host}") + #run once to request cert + on host, puppet_agent('-t'), :acceptable_exit_codes => [1] else # We only need answers if we're using the classic installer version = host['pe_ver'] || opts[:pe_ver] if (! host['roles'].include? 'frictionless') || version_is_less(version, '3.2.0') answers = Beaker::Answers.answers(opts[:pe_ver] || host['pe_ver'], hosts, master_certname, opts) @@ -340,10 +377,9 @@ end on host, installer_cmd(host, opts) end end - # If we're installing a database version less than 3.0, ignore the database host install_hosts = hosts.dup install_hosts.delete(database) if pre30database and database != master and database != dashboard