librarian-puppet 4.0.1 → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +10 -3
- data/README.md +7 -7
- data/lib/librarian/puppet/action/install.rb +1 -1
- data/lib/librarian/puppet/cli.rb +2 -2
- data/lib/librarian/puppet/dsl.rb +2 -25
- data/lib/librarian/puppet/source/forge/repo.rb +0 -36
- data/lib/librarian/puppet/source/forge/repo_v3.rb +3 -1
- data/lib/librarian/puppet/source/forge.rb +1 -21
- data/lib/librarian/puppet/source/local.rb +0 -59
- data/lib/librarian/puppet/templates/Puppetfile +1 -4
- data/lib/librarian/puppet/util.rb +0 -3
- data/lib/librarian/puppet/version.rb +1 -1
- data/lib/librarian/puppet.rb +0 -24
- metadata +14 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba4f67ad2636c73bc1518abdf5e8830f1825aeba7b901a6da47979bcaeb5a6a7
|
4
|
+
data.tar.gz: b43000021593835a648e2021762ee09b6f860162b22149f724faf697c6cdaadb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1306cd3266b6587d4077a66b8f2282b400ffce1ee1eaa87844e261c9f9e9b39926776ea2c76d5d89d7c11958cc9c367fafbb4b9d7be0eb5375795cc2f05eab62
|
7
|
+
data.tar.gz: 805bb0d66ec1df38c5d9a268dbed29d04d0fbe597e5a6ccfc0502c048287c7bfe537687cc0adf44a1fac77e577069d0e7f9c2c58643300f99ea6b208838466fc
|
data/.gitignore
CHANGED
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.
|
@@ -57,14 +59,14 @@ If no Puppetfile is present, `librarian-puppet` will download all the dependenci
|
|
57
59
|
listed in your `metadata.json` or `Modulefile` from the Puppet Forge,
|
58
60
|
as if the Puppetfile contained
|
59
61
|
|
60
|
-
forge "https://forgeapi.
|
62
|
+
forge "https://forgeapi.puppet.com"
|
61
63
|
|
62
64
|
metadata
|
63
65
|
|
64
66
|
|
65
67
|
### Example Puppetfile
|
66
68
|
|
67
|
-
forge "https://forgeapi.
|
69
|
+
forge "https://forgeapi.puppet.com"
|
68
70
|
|
69
71
|
mod 'puppetlabs-razor'
|
70
72
|
mod 'puppetlabs-ntp', "0.0.3"
|
@@ -90,7 +92,7 @@ When fetching a module all dependencies specified in its
|
|
90
92
|
|
91
93
|
### Puppetfile Breakdown
|
92
94
|
|
93
|
-
forge "https://forgeapi.
|
95
|
+
forge "https://forgeapi.puppet.com"
|
94
96
|
|
95
97
|
This declares that we want to use the official Puppet Labs Forge as our default
|
96
98
|
source when pulling down modules. If you run your own local forge, you may
|
@@ -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
@@ -7,7 +7,7 @@ module Librarian
|
|
7
7
|
module Puppet
|
8
8
|
class Dsl < Librarian::Dsl
|
9
9
|
|
10
|
-
FORGE_URL = "https://forgeapi.
|
10
|
+
FORGE_URL = "https://forgeapi.puppet.com"
|
11
11
|
|
12
12
|
dependency :mod
|
13
13
|
|
@@ -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
|
@@ -40,7 +40,9 @@ module Librarian
|
|
40
40
|
def get_module
|
41
41
|
begin
|
42
42
|
@module ||= PuppetForge::V3::Module.find(name)
|
43
|
-
|
43
|
+
# https://github.com/puppetlabs/forge-ruby/pull/104/files starting with version 5, PuppetForge::ModuleNotFound is raised
|
44
|
+
# previous versions raise Faraday::ResourceNotFound
|
45
|
+
rescue Faraday::ResourceNotFound, PuppetForge::ModuleNotFound => e
|
44
46
|
raise(Error, "Unable to find module '#{name}' on #{source}")
|
45
47
|
end
|
46
48
|
@module
|
@@ -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
|
@@ -1,14 +1,11 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
#^syntax detection
|
3
3
|
|
4
|
-
forge "https://forgeapi.
|
4
|
+
forge "https://forgeapi.puppet.com"
|
5
5
|
|
6
6
|
# use dependencies defined in metadata.json
|
7
7
|
metadata
|
8
8
|
|
9
|
-
# use dependencies defined in Modulefile
|
10
|
-
# modulefile
|
11
|
-
|
12
9
|
# A module from the Puppet Forge
|
13
10
|
# mod 'puppetlabs-stdlib'
|
14
11
|
|
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,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: librarian-puppet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 5.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Sharpe
|
8
8
|
- Carlos Sanchez
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2025-03-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: librarianp
|
@@ -45,20 +45,20 @@ dependencies:
|
|
45
45
|
requirements:
|
46
46
|
- - ">="
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: '2
|
48
|
+
version: '2'
|
49
49
|
- - "<"
|
50
50
|
- !ruby/object:Gem::Version
|
51
|
-
version: '
|
51
|
+
version: '7'
|
52
52
|
type: :runtime
|
53
53
|
prerelease: false
|
54
54
|
version_requirements: !ruby/object:Gem::Requirement
|
55
55
|
requirements:
|
56
56
|
- - ">="
|
57
57
|
- !ruby/object:Gem::Version
|
58
|
-
version: '2
|
58
|
+
version: '2'
|
59
59
|
- - "<"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '7'
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
63
|
name: rake
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|
@@ -153,16 +153,16 @@ dependencies:
|
|
153
153
|
name: mocha
|
154
154
|
requirement: !ruby/object:Gem::Requirement
|
155
155
|
requirements:
|
156
|
-
- - "
|
156
|
+
- - "~>"
|
157
157
|
- !ruby/object:Gem::Version
|
158
|
-
version: 2.
|
158
|
+
version: '2.7'
|
159
159
|
type: :development
|
160
160
|
prerelease: false
|
161
161
|
version_requirements: !ruby/object:Gem::Requirement
|
162
162
|
requirements:
|
163
|
-
- - "
|
163
|
+
- - "~>"
|
164
164
|
- !ruby/object:Gem::Version
|
165
|
-
version: 2.
|
165
|
+
version: '2.7'
|
166
166
|
- !ruby/object:Gem::Dependency
|
167
167
|
name: simplecov
|
168
168
|
requirement: !ruby/object:Gem::Requirement
|
@@ -236,7 +236,7 @@ homepage: https://github.com/voxpupuli/librarian-puppet
|
|
236
236
|
licenses:
|
237
237
|
- MIT
|
238
238
|
metadata: {}
|
239
|
-
post_install_message:
|
239
|
+
post_install_message:
|
240
240
|
rdoc_options: []
|
241
241
|
require_paths:
|
242
242
|
- lib
|
@@ -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'
|
@@ -255,7 +255,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
255
255
|
version: '0'
|
256
256
|
requirements: []
|
257
257
|
rubygems_version: 3.2.33
|
258
|
-
signing_key:
|
258
|
+
signing_key:
|
259
259
|
specification_version: 4
|
260
260
|
summary: Bundler for your Puppet modules
|
261
261
|
test_files: []
|