Skip to content

Commit

Permalink
(maint) Update beaker to support pupppet5 style installation
Browse files Browse the repository at this point in the history
  • Loading branch information
melissa committed Sep 25, 2017
1 parent 9f651dc commit e07c7f9
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 8 deletions.
37 changes: 29 additions & 8 deletions lib/beaker-puppet/install_utils/foss_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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 )

Expand Down
11 changes: 11 additions & 0 deletions spec/beaker-puppet/install_utils/foss_utils_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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' }

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e07c7f9

Please sign in to comment.