librarian-puppet 1.3.2 → 1.4.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 +1 -0
- data/README.md +29 -7
- data/lib/librarian/puppet/dsl.rb +1 -1
- data/lib/librarian/puppet/extension.rb +1 -1
- data/lib/librarian/puppet/source/forge.rb +10 -10
- data/lib/librarian/puppet/source/forge/repo.rb +2 -2
- data/lib/librarian/puppet/source/forge/repo_v3.rb +5 -0
- data/lib/librarian/puppet/source/githubtarball.rb +1 -1
- data/lib/librarian/puppet/source/githubtarball/repo.rb +1 -1
- data/lib/librarian/puppet/source/local.rb +22 -21
- data/lib/librarian/puppet/templates/Puppetfile +1 -1
- data/lib/librarian/puppet/util.rb +25 -9
- data/lib/librarian/puppet/version.rb +1 -1
- metadata +32 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc346f2177b53715db49807f07d06f48159669b5
|
4
|
+
data.tar.gz: 26ce629378954d0971ecb98232f826e6539e99e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 362ea152db680bd68ce4082ffbf39ba25132be50fb529a169ec7514779e66790ff92bec2c1e1d4c15752d9d4ee50cd35f88f62f26697b0c6ebb739574515089f
|
7
|
+
data.tar.gz: a14c13c99aeaab3f74b4ecadcece3654a37975fcf509808e6797c14aa8df07b18b3ff08b078a21000cfc44e70e237c328db796970e1c3072a167964d657f13df
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -30,8 +30,8 @@ and isolate a project's dependencies.
|
|
30
30
|
|
31
31
|
## Versions
|
32
32
|
|
33
|
-
Librarian-puppet >= 1.1.
|
34
|
-
Versions <
|
33
|
+
Librarian-puppet >= 2.0 (as well as 1.1, 1.2 and 1.3) requires Ruby 1.9 and uses the Puppet Forge API v3.
|
34
|
+
Versions < 2.0 work on Ruby 1.8.
|
35
35
|
|
36
36
|
See the [Changelog](Changelog.md) for more details.
|
37
37
|
|
@@ -55,7 +55,7 @@ as if the Puppetfile contained
|
|
55
55
|
|
56
56
|
### Example Puppetfile
|
57
57
|
|
58
|
-
forge "https://
|
58
|
+
forge "https://forgeapi.puppetlabs.com"
|
59
59
|
|
60
60
|
mod 'puppetlabs-razor'
|
61
61
|
mod 'puppetlabs-ntp', "0.0.3"
|
@@ -77,7 +77,7 @@ When fetching a module all dependencies specified in its
|
|
77
77
|
|
78
78
|
### Puppetfile Breakdown
|
79
79
|
|
80
|
-
forge "https://
|
80
|
+
forge "https://forgeapi.puppetlabs.com"
|
81
81
|
|
82
82
|
This declares that we want to use the official Puppet Labs Forge as our default
|
83
83
|
source when pulling down modules. If you run your own local forge, you may
|
@@ -167,10 +167,10 @@ source specified. This command writes the complete resolution into
|
|
167
167
|
Librarian-puppet support both v1 and v3 of the Puppet Forge API.
|
168
168
|
Specify a specific API version when installing modules:
|
169
169
|
|
170
|
-
$ librarian-puppet install --use-v1-api # this is default
|
171
|
-
$ librarian-puppet install --no-use-v1-api # use the v3 API
|
170
|
+
$ librarian-puppet install --use-v1-api # this is default; ignored for official Puppet Forge
|
171
|
+
$ librarian-puppet install --no-use-v1-api # use the v3 API; default for official Puppet Forge
|
172
172
|
|
173
|
-
Please note that this does not apply for the official Puppet Forge where v3 is used by default.
|
173
|
+
Please note that this does not apply for the official Puppet Forge, where v3 is used by default.
|
174
174
|
|
175
175
|
Get an overview of your `Puppetfile.lock` with:
|
176
176
|
|
@@ -256,6 +256,28 @@ Configuration can be set by passing specific options to other commands.
|
|
256
256
|
the environment or global config will be used.
|
257
257
|
|
258
258
|
|
259
|
+
## Rsync Option
|
260
|
+
|
261
|
+
The default convergence strategy between the cache and the module directory is
|
262
|
+
to execute an `rm -r` on the module directory and just `cp -r` from the cache.
|
263
|
+
This causes the module to be removed from the module path every time librarian
|
264
|
+
puppet updates, regardless of whether the content has changed. This can cause
|
265
|
+
some problems in environments with lots of change. The problem arises when the
|
266
|
+
module directory gets removed while Puppet is trying to read files inside it.
|
267
|
+
The `puppet master` process will lose its CWD and the catalog will fail to
|
268
|
+
compile. To avoid this, you can use `rsync` to implement a more conservative
|
269
|
+
convergence strategy. This will use `rsync` with the `-avz` and `--delete`
|
270
|
+
flags instead of a `rm -r` and `cp -r`. To use this feature, just set the
|
271
|
+
`rsync` configuration setting to `true`.
|
272
|
+
|
273
|
+
$ librarian-puppet config rsync true --global
|
274
|
+
|
275
|
+
Alternatively, using an environment variable:
|
276
|
+
|
277
|
+
LIBRARIAN_PUPPET_RSYNC='true'
|
278
|
+
|
279
|
+
Note that the directories will still be purged if you run librarian-puppet with
|
280
|
+
the --clean or --destructive flags.
|
259
281
|
|
260
282
|
## How to Contribute
|
261
283
|
|
data/lib/librarian/puppet/dsl.rb
CHANGED
@@ -20,7 +20,7 @@ module Librarian
|
|
20
20
|
if specfile.kind_of?(Pathname) and !File.exists?(specfile)
|
21
21
|
debug { "Specfile not found, using defaults: #{specfile}" }
|
22
22
|
specfile = Proc.new do
|
23
|
-
forge "
|
23
|
+
forge "http://forge.puppetlabs.com"
|
24
24
|
metadata
|
25
25
|
end
|
26
26
|
end
|
@@ -99,7 +99,7 @@ module Librarian
|
|
99
99
|
next if deps.include?(name)
|
100
100
|
|
101
101
|
deps << name
|
102
|
-
raise(Error, "Unable to find module #{name}") if index[name].nil?
|
102
|
+
raise(Error, "Unable to find module #{name}. Your Puppetfile may be out of sync with the lock, try running 'librarian-puppet install' first") if index[name].nil?
|
103
103
|
names.concat index[name].dependencies.map(&:name)
|
104
104
|
end
|
105
105
|
deps.to_a
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'uri'
|
2
2
|
require 'librarian/puppet/util'
|
3
3
|
require 'librarian/puppet/source/forge/repo_v1'
|
4
|
-
require 'librarian/puppet/source/forge/repo_v3'
|
4
|
+
# require 'librarian/puppet/source/forge/repo_v3'
|
5
5
|
|
6
6
|
module Librarian
|
7
7
|
module Puppet
|
@@ -53,10 +53,10 @@ module Librarian
|
|
53
53
|
def initialize(environment, uri, options = {})
|
54
54
|
self.environment = environment
|
55
55
|
|
56
|
-
if uri =~ %r{^http(s)?://forge\.puppetlabs\.com}
|
57
|
-
|
58
|
-
|
59
|
-
end
|
56
|
+
# if uri =~ %r{^http(s)?://forge\.puppetlabs\.com}
|
57
|
+
# uri = "https://forgeapi.puppetlabs.com"
|
58
|
+
# warn { "Replacing Puppet Forge API URL to use v3 #{uri}. You should update your Puppetfile" }
|
59
|
+
# end
|
60
60
|
|
61
61
|
@uri = URI::parse(uri)
|
62
62
|
@cache_path = nil
|
@@ -121,7 +121,7 @@ module Librarian
|
|
121
121
|
end
|
122
122
|
|
123
123
|
def install_path(name)
|
124
|
-
environment.install_path.join(
|
124
|
+
environment.install_path.join(module_name(name))
|
125
125
|
end
|
126
126
|
|
127
127
|
def fetch_version(name, version_uri)
|
@@ -151,11 +151,11 @@ module Librarian
|
|
151
151
|
|
152
152
|
unless @repo[name]
|
153
153
|
# if we are using the official Forge then use API v3, otherwise stick to v1 for now
|
154
|
-
if uri.hostname =~ /\.puppetlabs\.com$/ || !environment.use_v1_api
|
155
|
-
|
156
|
-
else
|
154
|
+
# if uri.hostname =~ /\.puppetlabs\.com$/ || !environment.use_v1_api
|
155
|
+
# @repo[name] = RepoV3.new(self, name)
|
156
|
+
# else
|
157
157
|
@repo[name] = RepoV1.new(self, name)
|
158
|
-
end
|
158
|
+
# end
|
159
159
|
end
|
160
160
|
@repo[name]
|
161
161
|
end
|
@@ -55,11 +55,11 @@ module Librarian
|
|
55
55
|
|
56
56
|
cache_version_unpacked! version
|
57
57
|
|
58
|
-
if install_path.exist?
|
58
|
+
if install_path.exist? && rsync? != true
|
59
59
|
install_path.rmtree
|
60
60
|
end
|
61
61
|
|
62
|
-
unpacked_path = version_unpacked_cache_path(version).join(
|
62
|
+
unpacked_path = version_unpacked_cache_path(version).join(module_name(name))
|
63
63
|
|
64
64
|
unless unpacked_path.exist?
|
65
65
|
raise Error, "#{unpacked_path} does not exist, something went wrong. Try removing it manually"
|
@@ -10,6 +10,11 @@ module Librarian
|
|
10
10
|
|
11
11
|
PuppetForge.user_agent = "librarian-puppet/#{Librarian::Puppet::VERSION}"
|
12
12
|
|
13
|
+
def initialize(source, name)
|
14
|
+
PuppetForge.host = source.uri.clone
|
15
|
+
super(source, name)
|
16
|
+
end
|
17
|
+
|
13
18
|
def get_versions
|
14
19
|
get_module.releases.map{|r| r.version}
|
15
20
|
end
|
@@ -19,8 +19,8 @@ module Librarian
|
|
19
19
|
warn { "Invalid module name '#{name}', you should qualify it with 'ORGANIZATION-#{name}' for resolution to work correctly" }
|
20
20
|
end
|
21
21
|
|
22
|
-
install_path = environment.install_path.join(
|
23
|
-
if install_path.exist?
|
22
|
+
install_path = environment.install_path.join(module_name(name))
|
23
|
+
if install_path.exist? && rsync? != true
|
24
24
|
debug { "Deleting #{relative_path_to(install_path)}" }
|
25
25
|
install_path.rmtree
|
26
26
|
end
|
@@ -55,7 +55,7 @@ module Librarian
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def forge_source
|
58
|
-
Forge.from_lock_options(environment, :remote => "https://
|
58
|
+
Forge.from_lock_options(environment, :remote => "https://forge.puppetlabs.com")
|
59
59
|
end
|
60
60
|
|
61
61
|
private
|
@@ -103,24 +103,25 @@ module Librarian
|
|
103
103
|
end
|
104
104
|
|
105
105
|
def parsed_metadata
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
106
|
+
if @metadata.nil?
|
107
|
+
@metadata = if metadata?
|
108
|
+
JSON.parse(File.read(metadata))
|
109
|
+
elsif modulefile?
|
110
|
+
# translate Modulefile to metadata.json
|
111
|
+
evaluated = evaluate_modulefile(modulefile)
|
112
|
+
{
|
113
|
+
'version' => evaluated.version,
|
114
|
+
'dependencies' => evaluated.dependencies.map do |dependency|
|
115
|
+
{
|
116
|
+
'name' => dependency.instance_variable_get(:@full_module_name),
|
117
|
+
'version_requirement' => dependency.instance_variable_get(:@version_requirement)
|
118
|
+
}
|
119
|
+
end
|
120
|
+
}
|
121
|
+
else
|
122
|
+
{}
|
123
|
+
end
|
124
|
+
@metadata['dependencies'] ||= []
|
124
125
|
end
|
125
126
|
@metadata
|
126
127
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'rsync'
|
2
|
+
|
1
3
|
module Librarian
|
2
4
|
module Puppet
|
3
5
|
|
@@ -13,16 +15,26 @@ module Librarian
|
|
13
15
|
environment.logger.warn(*args, &block)
|
14
16
|
end
|
15
17
|
|
18
|
+
def rsync?
|
19
|
+
environment.config_db.local['rsync'] == 'true'
|
20
|
+
end
|
21
|
+
|
16
22
|
# workaround Issue #173 FileUtils.cp_r will fail if there is a symlink that points to a missing file
|
17
23
|
# or when the symlink is copied before the target file when preserve is true
|
18
24
|
# see also https://tickets.opscode.com/browse/CHEF-833
|
25
|
+
#
|
26
|
+
# If the rsync configuration parameter is set, use rsync instead of FileUtils
|
19
27
|
def cp_r(src, dest)
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
28
|
+
if rsync?
|
29
|
+
Rsync.run(File.join(src, "/"), dest, ['-avz', '--delete'])
|
30
|
+
else
|
31
|
+
begin
|
32
|
+
FileUtils.cp_r(src, dest, :preserve => true)
|
33
|
+
rescue Errno::ENOENT
|
34
|
+
debug { "Failed to copy from #{src} to #{dest} preserving file types, trying again without preserving them" }
|
35
|
+
FileUtils.rm_rf(dest)
|
36
|
+
FileUtils.cp_r(src, dest)
|
37
|
+
end
|
26
38
|
end
|
27
39
|
end
|
28
40
|
|
@@ -39,10 +51,14 @@ module Librarian
|
|
39
51
|
name.sub('/','-')
|
40
52
|
end
|
41
53
|
|
42
|
-
# get the
|
43
|
-
def
|
44
|
-
name
|
54
|
+
# get the module name from organization-module
|
55
|
+
def module_name(name)
|
56
|
+
# module name can't have dashes, so let's assume it is everything after the last dash
|
57
|
+
name.rpartition('-').last
|
45
58
|
end
|
59
|
+
|
60
|
+
# deprecated
|
61
|
+
alias :organization_name :module_name
|
46
62
|
end
|
47
63
|
end
|
48
64
|
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: 1.
|
4
|
+
version: 1.4.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: 2014-
|
12
|
+
date: 2014-10-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: librarian
|
@@ -26,7 +26,21 @@ dependencies:
|
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: 0.1.2
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
|
-
name:
|
29
|
+
name: rsync
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - '>='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - '>='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: json
|
30
44
|
requirement: !ruby/object:Gem::Requirement
|
31
45
|
requirements:
|
32
46
|
- - '>='
|
@@ -137,6 +151,20 @@ dependencies:
|
|
137
151
|
- - '>='
|
138
152
|
- !ruby/object:Gem::Version
|
139
153
|
version: '0'
|
154
|
+
- !ruby/object:Gem::Dependency
|
155
|
+
name: simplecov
|
156
|
+
requirement: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - '>='
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: 0.9.0
|
161
|
+
type: :development
|
162
|
+
prerelease: false
|
163
|
+
version_requirements: !ruby/object:Gem::Requirement
|
164
|
+
requirements:
|
165
|
+
- - '>='
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: 0.9.0
|
140
168
|
description: |-
|
141
169
|
Simplify deployment of your Puppet infrastructure by
|
142
170
|
automatically pulling in modules from the forge and git repositories with
|
@@ -188,7 +216,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
188
216
|
requirements:
|
189
217
|
- - '>='
|
190
218
|
- !ruby/object:Gem::Version
|
191
|
-
version:
|
219
|
+
version: '0'
|
192
220
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
193
221
|
requirements:
|
194
222
|
- - '>='
|