From e07c7f9586d1a991426525c4b979c9eac2da9b7a Mon Sep 17 00:00:00 2001 From: Melissa Stone Date: Fri, 22 Sep 2017 23:10:26 +0000 Subject: [PATCH] (maint) Update beaker to support pupppet5 style installation --- lib/beaker-puppet/install_utils/foss_utils.rb | 37 +++++++++++++++---- .../install_utils/foss_utils_spec.rb | 11 ++++++ 2 files changed, 40 insertions(+), 8 deletions(-) diff --git a/lib/beaker-puppet/install_utils/foss_utils.rb b/lib/beaker-puppet/install_utils/foss_utils.rb index bbb07e7d..96e8903a 100644 --- a/lib/beaker-puppet/install_utils/foss_utils.rb +++ b/lib/beaker-puppet/install_utils/foss_utils.rb @@ -438,7 +438,9 @@ def configure_puppet_on(hosts, opts = {}) # @api private def install_puppet_from_rpm_on( hosts, opts ) block_on hosts do |host| - if host[:type] == 'aio' + if opts[:puppet_collection] && opts[:puppet_collection].match(/puppet\d*/) + install_puppetlabs_release_repo(host,opts[:puppet_collection],opts) + elsif host[:type] == 'aio' install_puppetlabs_release_repo(host,'pc1',opts) else install_puppetlabs_release_repo(host,nil,opts) @@ -592,7 +594,11 @@ def install_puppet_agent_from_msi_on(hosts, opts) # @api private def install_a_puppet_msi_on(hosts, opts) block_on hosts do |host| - link = "#{opts[:win_download_url]}/#{host['dist']}.msi" + if opts[:puppet_collection] && opts[:puppet_collection].match(/puppet\d*/) + link = "#{opts[:win_download_url]}/#{opts[:puppet_collection]}/#{host['dist']}.msi" + else + link = "#{opts[:win_download_url]}/#{host['dist']}.msi" + end if not link_exists?( link ) raise "Puppet MSI at #{link} does not exist!" end @@ -709,14 +715,18 @@ def install_puppet_from_dmg_on( hosts, opts ) # @api private def install_puppet_agent_from_dmg_on(hosts, opts) opts[:puppet_collection] ||= 'PC1' - opts[:puppet_collection] = opts[:puppet_collection].upcase #needs to be upcase, more lovely consistency + opts[:puppet_collection] = opts[:puppet_collection].upcase if opts[:puppet_collection].match(/pc1/i) block_on hosts do |host| add_role(host, 'aio') #we are installing agent, so we want aio role variant, version, arch, codename = host['platform'].to_array - download_url = "#{opts[:mac_download_url]}/#{version}/#{opts[:puppet_collection]}/#{arch}" + if opts[:puppet_collection].match(/puppet\d*/) + download_url = "#{opts[:mac_download_url]}/#{opts[:puppet_collection]}/#{version}/#{arch}" + else + download_url = "#{opts[:mac_download_url]}/#{version}/#{opts[:puppet_collection]}/#{arch}" + end latest = get_latest_puppet_agent_build_from_url(download_url) @@ -913,7 +923,7 @@ def install_puppet_from_gem_on( hosts, opts ) def install_puppetlabs_release_repo_on( hosts, repo = nil, opts = options ) block_on hosts do |host| variant, version, arch, codename = host['platform'].to_array - repo_name = repo.nil? ? '' : '-' + repo + repo_name = repo || opts[:puppet_collection] || '' opts = FOSS_DEFAULT_DOWNLOAD_URLS.merge(opts) case variant @@ -927,8 +937,14 @@ def install_puppetlabs_release_repo_on( hosts, repo = nil, opts = options ) variant_url_value = 'cisco-wrlinux' version = '7' end - remote = "%s/puppetlabs-release%s-%s-%s.noarch.rpm" % - [opts[:release_yum_repo_url], repo_name, variant_url_value, version] + if repo_name.match(/puppet\d*/) + remote = "%s/%s/%s-release-%s-%s.noarch.rpm" % + [opts[:release_yum_repo_url], repo_name, repo_name, variant_url_value, version] + else + repo_name = '-' + repo_name unless repo_name.empty? + remote = "%s/puppetlabs-release%s-%s-%s.noarch.rpm" % + [opts[:release_yum_repo_url], repo_name, variant_url_value, version] + end if variant == 'cisco_nexus' # cisco nexus requires using yum to install the repo @@ -943,7 +959,12 @@ def install_puppetlabs_release_repo_on( hosts, repo = nil, opts = options ) end when /^(debian|ubuntu|cumulus|huaweios)$/ - deb = "puppetlabs-release%s-%s.deb" % [repo_name, codename] + if repo_name.match(/puppet\d*/) + deb = "%s-release-%s.deb" % [repo_name, codename] + else + repo_name = '-' + repo_name unless repo_name.empty? + deb = "puppetlabs-release%s-%s.deb" % [repo_name, codename] + end remote = URI.join( opts[:release_apt_repo_url], deb ) diff --git a/spec/beaker-puppet/install_utils/foss_utils_spec.rb b/spec/beaker-puppet/install_utils/foss_utils_spec.rb index 9bb8e92e..ca6260da 100644 --- a/spec/beaker-puppet/install_utils/foss_utils_spec.rb +++ b/spec/beaker-puppet/install_utils/foss_utils_spec.rb @@ -68,6 +68,11 @@ def logger :working_dir => '/tmp', :type => 'foss', :dist => 'puppet-enterprise-3.1.0-rc0-230-g36c9e5c-centos-6-i386' } ) } + let(:el6hostpuppet) { make_host( 'el6hostpuppet', { :platform => Beaker::Platform.new('el-6-i386'), + :pe_ver => '3.0', + :working_dir => '/tmp', + :type => 'puppet', + :dist => 'puppet-enterprise-3.1.0-rc0-230-g36c9e5c-centos-6-i386' } ) } let(:win_temp) { 'C:\\Windows\\Temp' } @@ -281,6 +286,12 @@ def logger subject.install_puppet_from_rpm_on( el6hostfoss, {} ) end + + it 'installs puppet release repo when puppet' do + expect(subject).to receive(:install_puppetlabs_release_repo).with(el6hostpuppet,'puppet',{:puppet_collection => 'puppet'}) + + subject.install_puppet_from_rpm_on( el6hostpuppet, {:puppet_collection => 'puppet'} ) + end end context 'install_puppet_from_freebsd_ports_on' do