Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not pass the module_repository in PE >=3.2 #190

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/librarian/puppet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@

PUPPET_VERSION=out.split(' ').first.strip

if out =~ /Puppet Enterprise/
PE_VERSION=out.match(/\(Puppet Enterprise (.+)\)/)[1].gsub(/[^\d\.]/,'') rescue nil
end

require 'librarian/puppet/extension'
require 'librarian/puppet/version'

Expand Down
21 changes: 20 additions & 1 deletion lib/librarian/puppet/source/forge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,13 @@ def cache_version_unpacked!(version)

target = vendored?(name, version) ? vendored_path(name, version) : name

command = "puppet module install --version #{version} --target-dir '#{path}' --modulepath '#{path}' --module_working_dir '#{path}' --force '#{target}'"
# Newer verisons of PMT expect a different API.
# Until librarian is updated let puppet decide where the module_repository is
unless pmt_uses_v3?
command << " --module_repository '#{source}'"
end

command = "puppet module install --version #{version} --target-dir '#{path}' --module_repository '#{source}' --modulepath '#{path}' --module_working_dir '#{path}' --ignore-dependencies '#{target}'"
debug { "Executing puppet module install for #{name} #{version}" }
output = `#{command}`

Expand All @@ -126,6 +131,20 @@ def check_puppet_module_options
end
end

def pmt_uses_v3?
if defined?(PE_VERSION) && !PE_VERSION.nil?
min_version = Gem::Version.create('3.2.0')
pe_version = Gem::Version.create(PE_VERSION)

return pe_version >= min_version
end

# TODO: Future versions of open source Puppet module tool will also
# use v3 API, checks for that version snould be made here.

return false
end

def vendored?(name, version)
vendored_path(name, version).exist?
end
Expand Down