librarian-puppet 1.0.6 → 1.0.7
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/README.md +9 -6
- data/lib/librarian/puppet/action.rb +1 -0
- data/lib/librarian/puppet/action/install.rb +24 -0
- data/lib/librarian/puppet/cli.rb +9 -5
- data/lib/librarian/puppet/dsl.rb +31 -3
- data/lib/librarian/puppet/extension.rb +3 -16
- data/lib/librarian/puppet/source/local.rb +1 -0
- data/lib/librarian/puppet/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 010735fe88618f0ecd15edc880fa37086546d776
|
4
|
+
data.tar.gz: fc6e6b124d06ef74f249b813486880649aee3dbd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d65097488d97abe1ca30a251d62e02f3b3cebf0fb7ed1f594c7d98e3adec4e578dddf4e4ed5ffd73ee1627bf5eb4524097359e8777fb368f258fd0eb174bdef4
|
7
|
+
data.tar.gz: 6ee5fc74eebe8a99f970affcfd53949fce28b3926bbd1c0d9bf740e5c24d4297c01e3679f72e4abec5e4076bcb4bed786124cc454fdd36debd3411eca0c3ed6d
|
data/README.md
CHANGED
@@ -37,17 +37,20 @@ See the [Changelog](Changelog.md) for more details.
|
|
37
37
|
|
38
38
|
## The Puppetfile
|
39
39
|
|
40
|
-
Every Puppet repository that uses Librarian-puppet
|
41
|
-
`Puppetfile` in the root directory of that repository.
|
42
|
-
|
40
|
+
Every Puppet repository that uses Librarian-puppet may have a file named
|
41
|
+
`Puppetfile`, `metadata.json` or `Modulefile` in the root directory of that repository.
|
42
|
+
The full specification
|
43
|
+
for which modules your puppet infrastructure repository depends goes in here.
|
43
44
|
|
44
|
-
### Simple
|
45
|
+
### Simple usage
|
45
46
|
|
46
|
-
|
47
|
+
If no Puppetfile is present, `librarian-puppet` will download all the dependencies
|
48
|
+
listed in your `metadata.json` or `Modulefile` from the Puppet Forge,
|
49
|
+
as if the Puppetfile contained
|
47
50
|
|
48
51
|
forge "https://forgeapi.puppetlabs.com"
|
49
52
|
|
50
|
-
|
53
|
+
metadata
|
51
54
|
|
52
55
|
|
53
56
|
### Example Puppetfile
|
@@ -0,0 +1 @@
|
|
1
|
+
require "librarian/puppet/action/install"
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Librarian
|
2
|
+
module Puppet
|
3
|
+
module Action
|
4
|
+
class Install < Librarian::Action::Install
|
5
|
+
|
6
|
+
private
|
7
|
+
|
8
|
+
def create_install_path
|
9
|
+
install_path.rmtree if install_path.exist? && destructive?
|
10
|
+
install_path.mkpath
|
11
|
+
end
|
12
|
+
|
13
|
+
def destructive?
|
14
|
+
environment.config_db.local['destructive'] == 'true'
|
15
|
+
end
|
16
|
+
|
17
|
+
def check_specfile
|
18
|
+
# don't fail if Puppetfile doesn't exist as we'll use the Modulefile or metadata.json
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/librarian/puppet/cli.rb
CHANGED
@@ -2,6 +2,7 @@ require 'librarian/helpers'
|
|
2
2
|
|
3
3
|
require 'librarian/cli'
|
4
4
|
require 'librarian/puppet'
|
5
|
+
require 'librarian/puppet/action'
|
5
6
|
|
6
7
|
module Librarian
|
7
8
|
module Puppet
|
@@ -47,11 +48,6 @@ module Librarian
|
|
47
48
|
option "use-v1-api", :type => :boolean, :default => true
|
48
49
|
def install
|
49
50
|
|
50
|
-
unless File.exist?('Puppetfile')
|
51
|
-
say "Could not find Puppetfile in #{Dir.pwd}", :red
|
52
|
-
exit 1
|
53
|
-
end
|
54
|
-
|
55
51
|
ensure!
|
56
52
|
clean! if options["clean"]
|
57
53
|
unless options["destructive"].nil?
|
@@ -89,6 +85,14 @@ module Librarian
|
|
89
85
|
def version
|
90
86
|
say "librarian-puppet v#{Librarian::Puppet::VERSION}"
|
91
87
|
end
|
88
|
+
|
89
|
+
private
|
90
|
+
|
91
|
+
# override the actions to use our own
|
92
|
+
|
93
|
+
def install!(options = { })
|
94
|
+
Action::Install.new(environment, options).run
|
95
|
+
end
|
92
96
|
end
|
93
97
|
end
|
94
98
|
end
|
data/lib/librarian/puppet/dsl.rb
CHANGED
@@ -17,6 +17,14 @@ module Librarian
|
|
17
17
|
def run(specfile = nil, sources = [])
|
18
18
|
specfile, sources = nil, specfile if specfile.kind_of?(Array) && sources.empty?
|
19
19
|
|
20
|
+
if specfile.kind_of?(Pathname) and !File.exists?(specfile)
|
21
|
+
debug { "Specfile not found, using defaults: #{specfile}" }
|
22
|
+
specfile = Proc.new do
|
23
|
+
forge "http://forge.puppetlabs.com"
|
24
|
+
metadata
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
20
28
|
Target.new(self).tap do |target|
|
21
29
|
target.precache_sources(sources)
|
22
30
|
debug_named_source_cache("Pre-Cached Sources", target)
|
@@ -30,17 +38,20 @@ module Librarian
|
|
30
38
|
end
|
31
39
|
|
32
40
|
class Receiver < Librarian::Dsl::Receiver
|
33
|
-
attr_reader :specfile
|
41
|
+
attr_reader :specfile, :working_path
|
34
42
|
|
35
43
|
# save the specfile and call librarian
|
36
44
|
def run(specfile = nil)
|
45
|
+
@working_path = specfile.kind_of?(Pathname) ? specfile.parent : Pathname.new(Dir.pwd)
|
37
46
|
@specfile = specfile
|
38
47
|
super
|
39
48
|
end
|
40
49
|
|
41
50
|
# implement the 'modulefile' syntax for Puppetfile
|
42
51
|
def modulefile
|
43
|
-
|
52
|
+
f = modulefile_path
|
53
|
+
raise Error, "Modulefile file does not exist: #{f}" unless File.exists?(f)
|
54
|
+
File.read(f).lines.each do |line|
|
44
55
|
regexp = /\s*dependency\s+('|")([^'"]+)\1\s*(?:,\s*('|")([^'"]+)\3)?/
|
45
56
|
regexp =~ line && mod($2, $4)
|
46
57
|
end
|
@@ -48,11 +59,28 @@ module Librarian
|
|
48
59
|
|
49
60
|
# implement the 'metadata' syntax for Puppetfile
|
50
61
|
def metadata
|
51
|
-
|
62
|
+
f = working_path.join('metadata.json')
|
63
|
+
unless File.exists?(f)
|
64
|
+
msg = "Metadata file does not exist: #{f}"
|
65
|
+
# try modulefile, in case we don't have a Puppetfile and we are using the default template
|
66
|
+
if File.exists?(modulefile_path)
|
67
|
+
modulefile
|
68
|
+
return
|
69
|
+
else
|
70
|
+
raise Error, msg
|
71
|
+
end
|
72
|
+
end
|
73
|
+
dependencyList = JSON.parse(File.read(f))['dependencies']
|
52
74
|
dependencyList.each do |d|
|
53
75
|
mod(d['name'], d['version_requirement'])
|
54
76
|
end
|
55
77
|
end
|
78
|
+
|
79
|
+
private
|
80
|
+
|
81
|
+
def modulefile_path
|
82
|
+
working_path.join('Modulefile')
|
83
|
+
end
|
56
84
|
end
|
57
85
|
end
|
58
86
|
end
|
@@ -13,6 +13,9 @@ module Librarian
|
|
13
13
|
def initialize(name, requirement, source)
|
14
14
|
assert_name_valid! name
|
15
15
|
|
16
|
+
# Issue #235 fail if forge source is not defined
|
17
|
+
raise Error, "forge entry is not defined in Puppetfile" if source.instance_of?(Array) && source.empty?
|
18
|
+
|
16
19
|
# let's settle on provider-module syntax instead of provider/module
|
17
20
|
self.name = normalize_name(name)
|
18
21
|
self.requirement = Requirement.new(requirement)
|
@@ -80,22 +83,6 @@ module Librarian
|
|
80
83
|
end
|
81
84
|
end
|
82
85
|
|
83
|
-
module Action
|
84
|
-
class Install < Base
|
85
|
-
|
86
|
-
private
|
87
|
-
|
88
|
-
def create_install_path
|
89
|
-
install_path.rmtree if install_path.exist? && destructive?
|
90
|
-
install_path.mkpath
|
91
|
-
end
|
92
|
-
|
93
|
-
def destructive?
|
94
|
-
environment.config_db.local['destructive'] == 'true'
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
86
|
class ManifestSet
|
100
87
|
include Librarian::Puppet::Util
|
101
88
|
|
@@ -94,6 +94,7 @@ module Librarian
|
|
94
94
|
metadata = ::Puppet::ModuleTool::Metadata.new
|
95
95
|
begin
|
96
96
|
::Puppet::ModuleTool::ModulefileReader.evaluate(metadata, modulefile)
|
97
|
+
raise SyntaxError, "Missing version" unless metadata.version
|
97
98
|
rescue ArgumentError, SyntaxError => error
|
98
99
|
warn { "Unable to parse #{modulefile}, ignoring: #{error}" }
|
99
100
|
if metadata.respond_to? :version=
|
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.0.
|
4
|
+
version: 1.0.7
|
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-
|
12
|
+
date: 2014-08-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: librarian
|
@@ -154,6 +154,8 @@ files:
|
|
154
154
|
- README.md
|
155
155
|
- bin/librarian-puppet
|
156
156
|
- lib/librarian/puppet.rb
|
157
|
+
- lib/librarian/puppet/action.rb
|
158
|
+
- lib/librarian/puppet/action/install.rb
|
157
159
|
- lib/librarian/puppet/cli.rb
|
158
160
|
- lib/librarian/puppet/dsl.rb
|
159
161
|
- lib/librarian/puppet/environment.rb
|