librarian-puppet 1.3.2 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6fc5dec8784fe45347e3f68e2664be05cbcf0a9b
4
- data.tar.gz: aaa2dfce9b9b7060e0e3e0b4aa9ef99b4e33a766
3
+ metadata.gz: bc346f2177b53715db49807f07d06f48159669b5
4
+ data.tar.gz: 26ce629378954d0971ecb98232f826e6539e99e4
5
5
  SHA512:
6
- metadata.gz: 23f0cd3a1f2a549be38aad58c3b3ebdf4d5e01471655d7318b1dce1ed10b5db1b4454fae8aae5b38c695144dae18018af4e472de97e1f0d1d5d603784587e2ec
7
- data.tar.gz: 6fd3e484ad7b992afaf0d5c02bab4d3def309cbc667d20811f6323bf5a1161f3bcc756feb4577576ee1cbd26da17abcc912d1242bdde9081d461f4e2ca44b0ed
6
+ metadata.gz: 362ea152db680bd68ce4082ffbf39ba25132be50fb529a169ec7514779e66790ff92bec2c1e1d4c15752d9d4ee50cd35f88f62f26697b0c6ebb739574515089f
7
+ data.tar.gz: a14c13c99aeaab3f74b4ecadcece3654a37975fcf509808e6797c14aa8df07b18b3ff08b078a21000cfc44e70e237c328db796970e1c3072a167964d657f13df
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
1
  pkg/
2
2
  Gemfile.lock
3
3
  tmp/
4
+ coverage/
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.0 requires Ruby 1.9 and uses the Puppet Forge API v3.
34
- Versions < 1.1.0 works on Ruby 1.8.
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://forge.puppetlabs.com"
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://forge.puppetlabs.com"
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
 
@@ -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 "https://forgeapi.puppetlabs.com"
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
- uri = "https://forgeapi.puppetlabs.com"
58
- warn { "Replacing Puppet Forge API URL to use v3 #{uri}. You should update your Puppetfile" }
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(organization_name(name))
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
- @repo[name] = RepoV3.new(self, name)
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(organization_name(name))
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
@@ -98,7 +98,7 @@ module Librarian
98
98
  end
99
99
 
100
100
  def install_path(name)
101
- environment.install_path.join(organization_name(name))
101
+ environment.install_path.join(module_name(name))
102
102
  end
103
103
 
104
104
  def fetch_version(name, version_uri)
@@ -48,7 +48,7 @@ module Librarian
48
48
 
49
49
  cache_version_unpacked! version
50
50
 
51
- if install_path.exist?
51
+ if install_path.exist? && rsync? != true
52
52
  install_path.rmtree
53
53
  end
54
54
 
@@ -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(organization_name(name))
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://forgeapi.puppetlabs.com")
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
- @metadata ||= if metadata?
107
- JSON.parse(File.read(metadata))
108
- elsif modulefile?
109
- # translate Modulefile to metadata.json
110
- evaluated = evaluate_modulefile(modulefile)
111
- {
112
- 'version' => evaluated.version,
113
- 'dependencies' => evaluated.dependencies.map do |dependency|
114
- {
115
- 'name' => dependency.instance_variable_get(:@full_module_name),
116
- 'version_requirement' => dependency.instance_variable_get(:@version_requirement)
117
- }
118
- end
119
- }
120
- else
121
- {
122
- 'dependencies' => []
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,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  #^syntax detection
3
3
 
4
- forge "https://forgeapi.puppetlabs.com"
4
+ forge "https://forge.puppetlabs.com"
5
5
 
6
6
  # use dependencies defined in metadata.json
7
7
  metadata
@@ -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
- begin
21
- FileUtils.cp_r(src, dest, :preserve => true)
22
- rescue Errno::ENOENT
23
- debug { "Failed to copy from #{src} to #{dest} preserving file types, trying again without preserving them" }
24
- FileUtils.rm_rf(dest)
25
- FileUtils.cp_r(src, dest)
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 organization name from organization-module
43
- def organization_name(name)
44
- name.split('-',2).last
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
@@ -1,5 +1,5 @@
1
1
  module Librarian
2
2
  module Puppet
3
- VERSION = "1.3.2"
3
+ VERSION = "1.4.0"
4
4
  end
5
5
  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.3.2
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-08-18 00:00:00.000000000 Z
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: puppet_forge
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: 1.9.0
219
+ version: '0'
192
220
  required_rubygems_version: !ruby/object:Gem::Requirement
193
221
  requirements:
194
222
  - - '>='