librarian-puppet 4.0.1 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/lib/librarian/puppet/action/install.rb +1 -1
- data/lib/librarian/puppet/cli.rb +2 -2
- data/lib/librarian/puppet/dsl.rb +1 -24
- data/lib/librarian/puppet/source/forge/repo.rb +0 -36
- data/lib/librarian/puppet/source/forge.rb +1 -21
- data/lib/librarian/puppet/source/local.rb +0 -59
- data/lib/librarian/puppet/templates/Puppetfile +0 -3
- data/lib/librarian/puppet/util.rb +0 -3
- data/lib/librarian/puppet/version.rb +1 -1
- data/lib/librarian/puppet.rb +0 -24
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 713a6dde7be0283a093bb67bfe50a58bd2c44b079d1246a7ab10c16101ab7b98
|
4
|
+
data.tar.gz: f4f7b30eeb1f2cd4be07c60d36caa935e62e3ea14df89649d58f59732a73c4bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9b87dfc7a3f1fe67e808d14fc05f6945af63e74558dc75230063e87f82ee050747c2cb3f5d5d7938be56e0c9d21216f7436cd6315b1d8b64d72e411f213e4da
|
7
|
+
data.tar.gz: b2c87bc6e9bfd0e8d9f20467552e7c98b8da6d17bf5abf70ee78ab8019883d6c55a6343ac7c2ab498283cacae3d8113dddbc816db583b23484d1427e855b64b5
|
data/README.md
CHANGED
@@ -36,6 +36,8 @@ and isolate a project's dependencies.
|
|
36
36
|
|
37
37
|
## Versions
|
38
38
|
|
39
|
+
Librarian-Puppet 5.0.0 and newer requires Ruby >= 2.7 and Puppet >= 6. Use version 4.0.1 if you need support for Puppet 6 or Ruby 2.6 or earlier.
|
40
|
+
|
39
41
|
Librarian-Puppet 4.0.0 and newer requires Ruby >= 2.5 and Puppet >= 5. Use version 3.0.1 is you need support for Puppet 3 or Puppet 4, or Ruby 2.4 or earlier.
|
40
42
|
|
41
43
|
Librarian-Puppet 3.0.0 and newer requires Ruby >= 2.0. Use version 2.2.4 if you need support for Puppet 3.7 or earlier, or Ruby 1.9 or earlier. Note that [Puppet 4.10 and newer require Ruby 2.1](https://puppet.com/docs/puppet/4.10/system_requirements.html#prerequisites) or newer.
|
@@ -204,10 +206,8 @@ source specified. This command writes the complete resolution into
|
|
204
206
|
Librarian-puppet support both v1 and v3 of the Puppet Forge API.
|
205
207
|
Specify a specific API version when installing modules:
|
206
208
|
|
207
|
-
$ librarian-puppet install --use-v1-api #
|
208
|
-
$ librarian-puppet install --no-use-v1-api # use the v3 API;
|
209
|
-
|
210
|
-
Please note that this does not apply for the official Puppet Forge, where v3 is used by default.
|
209
|
+
$ librarian-puppet install --use-v1-api # use the v1 API
|
210
|
+
$ librarian-puppet install --no-use-v1-api # use the v3 API; this is the default
|
211
211
|
|
212
212
|
Get an overview of your `Puppetfile.lock` with:
|
213
213
|
|
data/lib/librarian/puppet/cli.rb
CHANGED
@@ -46,7 +46,7 @@ module Librarian
|
|
46
46
|
option "path", :type => :string
|
47
47
|
option "destructive", :type => :boolean, :default => false
|
48
48
|
option "local", :type => :boolean, :default => false
|
49
|
-
option "use-v1-api", :type => :boolean, :default =>
|
49
|
+
option "use-v1-api", :type => :boolean, :default => false
|
50
50
|
def install
|
51
51
|
|
52
52
|
ensure!
|
@@ -73,7 +73,7 @@ module Librarian
|
|
73
73
|
desc "update", "Updates and installs the dependencies you specify."
|
74
74
|
option "verbose", :type => :boolean, :default => false
|
75
75
|
option "line-numbers", :type => :boolean, :default => false
|
76
|
-
option "use-v1-api", :type => :boolean, :default =>
|
76
|
+
option "use-v1-api", :type => :boolean, :default => false
|
77
77
|
def update(*names)
|
78
78
|
|
79
79
|
environment.config_db.local['use-v1-api'] = options['use-v1-api'] ? '1' : nil
|
data/lib/librarian/puppet/dsl.rb
CHANGED
@@ -78,28 +78,11 @@ module Librarian
|
|
78
78
|
super
|
79
79
|
end
|
80
80
|
|
81
|
-
# implement the 'modulefile' syntax for Puppetfile
|
82
|
-
def modulefile
|
83
|
-
f = modulefile_path
|
84
|
-
raise Error, "Modulefile file does not exist: #{f}" unless File.exist?(f)
|
85
|
-
File.read(f).lines.each do |line|
|
86
|
-
regexp = /\s*dependency\s+('|")([^'"]+)\1\s*(?:,\s*('|")([^'"]+)\3)?/
|
87
|
-
regexp =~ line && mod($2, $4)
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
81
|
# implement the 'metadata' syntax for Puppetfile
|
92
82
|
def metadata
|
93
83
|
f = working_path.join('metadata.json')
|
94
84
|
unless File.exist?(f)
|
95
|
-
|
96
|
-
# try modulefile, in case we don't have a Puppetfile and we are using the default template
|
97
|
-
if File.exist?(modulefile_path)
|
98
|
-
modulefile
|
99
|
-
return
|
100
|
-
else
|
101
|
-
raise Error, msg
|
102
|
-
end
|
85
|
+
raise Error, "Metadata file does not exist: #{f}"
|
103
86
|
end
|
104
87
|
begin
|
105
88
|
json = JSON.parse(File.read(f))
|
@@ -111,12 +94,6 @@ module Librarian
|
|
111
94
|
mod(d['name'], d['version_requirement'])
|
112
95
|
end
|
113
96
|
end
|
114
|
-
|
115
|
-
private
|
116
|
-
|
117
|
-
def modulefile_path
|
118
|
-
working_path.join('Modulefile')
|
119
|
-
end
|
120
97
|
end
|
121
98
|
end
|
122
99
|
end
|
@@ -73,40 +73,12 @@ module Librarian
|
|
73
73
|
path = version_unpacked_cache_path(version)
|
74
74
|
return if path.directory?
|
75
75
|
|
76
|
-
# The puppet module command is only available from puppet versions >= 2.7.13
|
77
|
-
#
|
78
|
-
# Specifying the version in the gemspec would force people to upgrade puppet while it's still usable for git
|
79
|
-
# So we do some more clever checking
|
80
|
-
#
|
81
|
-
# Executing older versions or via puppet-module tool gives an exit status = 0 .
|
82
|
-
#
|
83
|
-
check_puppet_module_options
|
84
|
-
|
85
76
|
path.mkpath
|
86
77
|
|
87
78
|
target = vendored?(name, version) ? vendored_path(name, version).to_s : name
|
88
79
|
|
89
|
-
# can't pass the default v3 forge url (http://forgeapi.puppetlabs.com)
|
90
|
-
# to clients that use the v1 API (https://forge.puppet.com)
|
91
|
-
# nor the other way around
|
92
80
|
module_repository = source.uri.to_s
|
93
81
|
|
94
|
-
if Forge.client_api_version() > 1 and module_repository =~ %r{^http(s)?://forge\.puppetlabs\.com}
|
95
|
-
module_repository = "https://forgeapi.puppetlabs.com"
|
96
|
-
warn { "Replacing Puppet Forge API URL to use v3 #{module_repository} as required by your client version #{Librarian::Puppet.puppet_version}" }
|
97
|
-
end
|
98
|
-
|
99
|
-
m = module_repository.match(%r{^http(s)?://forge(api)?\.puppetlabs\.com})
|
100
|
-
if Forge.client_api_version() == 1 and m
|
101
|
-
ssl = m[1]
|
102
|
-
# Puppet 2.7 can't handle the 302 returned by the https url, so stick to http
|
103
|
-
if ssl and Librarian::Puppet::puppet_gem_version < Gem::Version.create('3.0.0')
|
104
|
-
warn { "Using plain http as your version of Puppet #{Librarian::Puppet::puppet_gem_version} can't download from forge.puppetlabs.com using https" }
|
105
|
-
ssl = nil
|
106
|
-
end
|
107
|
-
module_repository = "http#{ssl}://forge.puppetlabs.com"
|
108
|
-
end
|
109
|
-
|
110
82
|
command = %W{puppet module install --version #{version} --target-dir}
|
111
83
|
command.push(*[path.to_s, "--module_repository", module_repository, "--modulepath", path.to_s, "--module_working_dir", path.to_s, "--ignore-dependencies", target])
|
112
84
|
debug { "Executing puppet module install for #{name} #{version}: #{command.join(" ").gsub(module_repository, source.to_s)}" }
|
@@ -131,14 +103,6 @@ module Librarian
|
|
131
103
|
|
132
104
|
end
|
133
105
|
|
134
|
-
def check_puppet_module_options
|
135
|
-
min_version = Gem::Version.create('2.7.13')
|
136
|
-
|
137
|
-
if Librarian::Puppet.puppet_gem_version < min_version
|
138
|
-
raise Error, "To get modules from the forge, we use the puppet faces module command. For this you need at least puppet version 2.7.13 and you have #{Librarian::Puppet.puppet_version}"
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
106
|
def vendor_cache(name, version)
|
143
107
|
url = url(name, version)
|
144
108
|
path = vendored_path(name, version).to_s
|
@@ -37,21 +37,6 @@ module Librarian
|
|
37
37
|
|
38
38
|
new(environment, uri, options)
|
39
39
|
end
|
40
|
-
|
41
|
-
def client_api_version()
|
42
|
-
version = 1
|
43
|
-
pe_version = Librarian::Puppet.puppet_version.match(/\(Puppet Enterprise (.+)\)/)
|
44
|
-
|
45
|
-
# Puppet 3.6.0+ uses api v3
|
46
|
-
if Librarian::Puppet::puppet_gem_version >= Gem::Version.create('3.6.0.a')
|
47
|
-
version = 3
|
48
|
-
# Puppet enterprise 3.2.0+ uses api v3
|
49
|
-
elsif pe_version and Gem::Version.create(pe_version[1].strip) >= Gem::Version.create('3.2.0')
|
50
|
-
version = 3
|
51
|
-
end
|
52
|
-
return version
|
53
|
-
end
|
54
|
-
|
55
40
|
end
|
56
41
|
|
57
42
|
attr_accessor :environment
|
@@ -61,11 +46,6 @@ module Librarian
|
|
61
46
|
def initialize(environment, uri, options = {})
|
62
47
|
self.environment = environment
|
63
48
|
|
64
|
-
if uri =~ %r{^http(s)?://forge\.puppetlabs\.com}
|
65
|
-
uri = "https://forgeapi.puppetlabs.com"
|
66
|
-
warn { "Replacing Puppet Forge API URL to use v3 #{uri}. You should update your Puppetfile" }
|
67
|
-
end
|
68
|
-
|
69
49
|
@uri = URI::parse(uri)
|
70
50
|
@cache_path = nil
|
71
51
|
end
|
@@ -160,7 +140,7 @@ module Librarian
|
|
160
140
|
unless @repo[name]
|
161
141
|
# If we are using the official Forge then use API v3, otherwise use the preferred api
|
162
142
|
# as defined by the CLI option use_v1_api
|
163
|
-
if
|
143
|
+
if !environment.use_v1_api
|
164
144
|
@repo[name] = RepoV3.new(self, name)
|
165
145
|
else
|
166
146
|
@repo[name] = RepoV1.new(self, name)
|
@@ -67,45 +67,6 @@ module Librarian
|
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
|
-
def require_puppet
|
71
|
-
begin
|
72
|
-
require 'puppet'
|
73
|
-
require 'puppet/module_tool'
|
74
|
-
rescue LoadError
|
75
|
-
$stderr.puts <<-EOF
|
76
|
-
Unable to load puppet, the puppet gem is required for :git and :path source.
|
77
|
-
Install it with: gem install puppet
|
78
|
-
EOF
|
79
|
-
exit 1
|
80
|
-
end
|
81
|
-
true
|
82
|
-
end
|
83
|
-
|
84
|
-
def evaluate_modulefile(modulefile)
|
85
|
-
@@require_puppet ||= require_puppet
|
86
|
-
|
87
|
-
metadata = ::Puppet::ModuleTool::Metadata.new
|
88
|
-
|
89
|
-
# Puppet 4 does not have the class
|
90
|
-
unless defined? ::Puppet::ModuleTool::ModulefileReader
|
91
|
-
warn { "Can't parse Modulefile in Puppet >= 4.0 and you are using #{Librarian::Puppet::puppet_version}. Ignoring dependencies in #{modulefile}" }
|
92
|
-
return metadata
|
93
|
-
end
|
94
|
-
|
95
|
-
begin
|
96
|
-
::Puppet::ModuleTool::ModulefileReader.evaluate(metadata, modulefile)
|
97
|
-
raise SyntaxError, "Missing version" unless metadata.version
|
98
|
-
rescue ArgumentError, SyntaxError => error
|
99
|
-
warn { "Unable to parse #{modulefile}, ignoring: #{error}" }
|
100
|
-
if metadata.respond_to? :version=
|
101
|
-
metadata.version = '0.0.1' # puppet < 3.6
|
102
|
-
else
|
103
|
-
metadata.update({'version' => '0.0.1'}) # puppet >= 3.6
|
104
|
-
end
|
105
|
-
end
|
106
|
-
metadata
|
107
|
-
end
|
108
|
-
|
109
70
|
def parsed_metadata
|
110
71
|
if @metadata.nil?
|
111
72
|
@metadata = if metadata?
|
@@ -114,18 +75,6 @@ module Librarian
|
|
114
75
|
rescue JSON::ParserError => e
|
115
76
|
raise Error, "Unable to parse json file #{metadata}: #{e}"
|
116
77
|
end
|
117
|
-
elsif modulefile?
|
118
|
-
# translate Modulefile to metadata.json
|
119
|
-
evaluated = evaluate_modulefile(modulefile)
|
120
|
-
{
|
121
|
-
'version' => evaluated.version,
|
122
|
-
'dependencies' => evaluated.dependencies.map do |dependency|
|
123
|
-
{
|
124
|
-
'name' => dependency.instance_variable_get(:@full_module_name),
|
125
|
-
'version_requirement' => dependency.instance_variable_get(:@version_requirement)
|
126
|
-
}
|
127
|
-
end
|
128
|
-
}
|
129
78
|
else
|
130
79
|
{}
|
131
80
|
end
|
@@ -134,14 +83,6 @@ module Librarian
|
|
134
83
|
@metadata
|
135
84
|
end
|
136
85
|
|
137
|
-
def modulefile
|
138
|
-
File.join(filesystem_path, 'Modulefile')
|
139
|
-
end
|
140
|
-
|
141
|
-
def modulefile?
|
142
|
-
File.exist?(modulefile)
|
143
|
-
end
|
144
|
-
|
145
86
|
def metadata
|
146
87
|
File.join(filesystem_path, 'metadata.json')
|
147
88
|
end
|
data/lib/librarian/puppet.rb
CHANGED
@@ -8,29 +8,5 @@ require 'librarian/action/install'
|
|
8
8
|
|
9
9
|
module Librarian
|
10
10
|
module Puppet
|
11
|
-
@@puppet_version = nil
|
12
|
-
|
13
|
-
# Output of puppet --version, typically x.y.z
|
14
|
-
# For Puppet Enterprise it contains the PE version too, ie. 3.4.3 (Puppet Enterprise 3.2.1)
|
15
|
-
def puppet_version
|
16
|
-
return @@puppet_version unless @@puppet_version.nil?
|
17
|
-
|
18
|
-
begin
|
19
|
-
@@puppet_version = Librarian::Posix.run!(%W{puppet --version}).strip
|
20
|
-
rescue Errno::ENOENT, Librarian::Posix::CommandFailure => error
|
21
|
-
msg = "Unable to load puppet. Please install it using native packages for your platform (eg .deb, .rpm, .dmg, etc)."
|
22
|
-
msg += "\npuppet --version returned #{error.status}" if error.respond_to? :status
|
23
|
-
msg += "\n#{error.message}" unless error.message.nil?
|
24
|
-
$stderr.puts msg
|
25
|
-
exit 1
|
26
|
-
end
|
27
|
-
return @@puppet_version
|
28
|
-
end
|
29
|
-
|
30
|
-
# Puppet version x.y.z translated as a Gem version
|
31
|
-
def puppet_gem_version
|
32
|
-
Gem::Version.create(puppet_version.split(' ').first.strip.gsub('-', '.'))
|
33
|
-
end
|
34
|
-
|
35
11
|
end
|
36
12
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: librarian-puppet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 5.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Sharpe
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2023-
|
12
|
+
date: 2023-05-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: librarianp
|
@@ -48,7 +48,7 @@ dependencies:
|
|
48
48
|
version: '2.1'
|
49
49
|
- - "<"
|
50
50
|
- !ruby/object:Gem::Version
|
51
|
-
version: '
|
51
|
+
version: '5'
|
52
52
|
type: :runtime
|
53
53
|
prerelease: false
|
54
54
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -58,7 +58,7 @@ dependencies:
|
|
58
58
|
version: '2.1'
|
59
59
|
- - "<"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '5'
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
63
|
name: rake
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|
@@ -244,7 +244,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
244
244
|
requirements:
|
245
245
|
- - ">="
|
246
246
|
- !ruby/object:Gem::Version
|
247
|
-
version: 2.
|
247
|
+
version: '2.7'
|
248
248
|
- - "<"
|
249
249
|
- !ruby/object:Gem::Version
|
250
250
|
version: '4'
|