librarian-puppet 1.0.5 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/librarian/puppet/dsl.rb +8 -0
- data/lib/librarian/puppet/source/forge.rb +1 -1
- data/lib/librarian/puppet/source/forge/repo.rb +1 -1
- data/lib/librarian/puppet/source/githubtarball.rb +1 -1
- data/lib/librarian/puppet/source/local.rb +39 -18
- data/lib/librarian/puppet/templates/Puppetfile +4 -1
- data/lib/librarian/puppet/util.rb +5 -0
- data/lib/librarian/puppet/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f2563b5575e2082f80e0b75f8b1ece49f070a8a
|
4
|
+
data.tar.gz: c37295903ceab4b3406d28f3f90537cd2efa20a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c9a691b88c4813bc4dc9d90011bc194f8ccf3452ca21eb79359a95652294d049b238b955b3d6fd9fc0f13eebf44ac9e698d60621e683a29675675a20b11c9e6
|
7
|
+
data.tar.gz: 28e9ee98ba396f257dbf233550bc5983c335fe1d85da95e1d5d3621770ef904925b86654c833253dafd446f41a98ebd54e1b5f8457d1e135b7a775e4b2ae9a3d
|
data/README.md
CHANGED
@@ -9,7 +9,7 @@ librarian-puppet to manage the puppet modules your infrastructure depends on,
|
|
9
9
|
whether the modules come from the [Puppet Forge](https://forge.puppetlabs.com/),
|
10
10
|
Git repositories or a just a path.
|
11
11
|
|
12
|
-
* Librarian-puppet can reuse the dependencies listed in your Modulefile
|
12
|
+
* Librarian-puppet can reuse the dependencies listed in your `Modulefile` or `metadata.json`
|
13
13
|
* Forge modules can be installed from [Puppetlabs Forge](https://forge.puppetlabs.com/) or an internal Forge such as [Pulp](http://www.pulpproject.org/)
|
14
14
|
* Git modules can be installed from a branch, tag or specific commit, optionally using a path inside the repository
|
15
15
|
* Modules can be installed from GitHub using tarballs, without needing Git installed
|
@@ -70,7 +70,7 @@ This Puppetfile will download all the dependencies listed in your Modulefile fro
|
|
70
70
|
### Recursive module dependency resolution
|
71
71
|
|
72
72
|
When fetching a module all dependencies specified in its
|
73
|
-
`Modulefile` and `Puppetfile` will be resolved and installed.
|
73
|
+
`Modulefile`, `metadata.json` and `Puppetfile` will be resolved and installed.
|
74
74
|
|
75
75
|
### Puppetfile Breakdown
|
76
76
|
|
data/lib/librarian/puppet/dsl.rb
CHANGED
@@ -45,6 +45,14 @@ module Librarian
|
|
45
45
|
regexp =~ line && mod($2, $4)
|
46
46
|
end
|
47
47
|
end
|
48
|
+
|
49
|
+
# implement the 'metadata' syntax for Puppetfile
|
50
|
+
def metadata
|
51
|
+
dependencyList = JSON.parse(File.read(Pathname.new(specfile).parent.join('metadata.json')))['dependencies']
|
52
|
+
dependencyList.each do |d|
|
53
|
+
mod(d['name'], d['version_requirement'])
|
54
|
+
end
|
55
|
+
end
|
48
56
|
end
|
49
57
|
end
|
50
58
|
end
|
@@ -59,7 +59,7 @@ module Librarian
|
|
59
59
|
install_path.rmtree
|
60
60
|
end
|
61
61
|
|
62
|
-
unpacked_path = version_unpacked_cache_path(version).join(name
|
62
|
+
unpacked_path = version_unpacked_cache_path(version).join(organization_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"
|
@@ -1,16 +1,5 @@
|
|
1
1
|
require 'librarian/puppet/util'
|
2
2
|
|
3
|
-
begin
|
4
|
-
require 'puppet'
|
5
|
-
require 'puppet/module_tool'
|
6
|
-
rescue LoadError
|
7
|
-
$stderr.puts <<-EOF
|
8
|
-
Unable to load puppet, the puppet gem is required for :git and :path source.
|
9
|
-
Install it with: gem install puppet
|
10
|
-
EOF
|
11
|
-
exit 1
|
12
|
-
end
|
13
|
-
|
14
3
|
module Librarian
|
15
4
|
module Puppet
|
16
5
|
module Source
|
@@ -30,7 +19,7 @@ module Librarian
|
|
30
19
|
warn { "Invalid module name '#{name}', you should qualify it with 'ORGANIZATION-#{name}' for resolution to work correctly" }
|
31
20
|
end
|
32
21
|
|
33
|
-
install_path = environment.install_path.join(name
|
22
|
+
install_path = environment.install_path.join(organization_name(name))
|
34
23
|
if install_path.exist?
|
35
24
|
debug { "Deleting #{relative_path_to(install_path)}" }
|
36
25
|
install_path.rmtree
|
@@ -48,13 +37,21 @@ module Librarian
|
|
48
37
|
def fetch_dependencies(name, version, extra)
|
49
38
|
dependencies = Set.new
|
50
39
|
|
51
|
-
if
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
40
|
+
dependencyList = if metadata?
|
41
|
+
JSON.parse(File.read(metadata))['dependencies']
|
42
|
+
elsif modulefile?
|
43
|
+
evaluate_modulefile(modulefile).dependencies.map do |dependency|
|
44
|
+
{
|
45
|
+
'name' => dependency.instance_variable_get(:@full_module_name),
|
46
|
+
'version_requirement' => dependency.instance_variable_get(:@version_requirement)
|
47
|
+
}
|
57
48
|
end
|
49
|
+
else []
|
50
|
+
end
|
51
|
+
|
52
|
+
dependencyList.each do |d|
|
53
|
+
gem_requirement = Requirement.new(d['version_requirement']).gem_requirement
|
54
|
+
dependencies << Dependency.new(d['name'], gem_requirement, forge_source)
|
58
55
|
end
|
59
56
|
|
60
57
|
if specfile?
|
@@ -77,7 +74,23 @@ module Librarian
|
|
77
74
|
evaluate_modulefile(modulefile).version
|
78
75
|
end
|
79
76
|
|
77
|
+
def require_puppet
|
78
|
+
begin
|
79
|
+
require 'puppet'
|
80
|
+
require 'puppet/module_tool'
|
81
|
+
rescue LoadError
|
82
|
+
$stderr.puts <<-EOF
|
83
|
+
Unable to load puppet, the puppet gem is required for :git and :path source.
|
84
|
+
Install it with: gem install puppet
|
85
|
+
EOF
|
86
|
+
exit 1
|
87
|
+
end
|
88
|
+
true
|
89
|
+
end
|
90
|
+
|
80
91
|
def evaluate_modulefile(modulefile)
|
92
|
+
@@require_puppet ||= require_puppet
|
93
|
+
|
81
94
|
metadata = ::Puppet::ModuleTool::Metadata.new
|
82
95
|
begin
|
83
96
|
::Puppet::ModuleTool::ModulefileReader.evaluate(metadata, modulefile)
|
@@ -100,6 +113,14 @@ module Librarian
|
|
100
113
|
File.exists?(modulefile)
|
101
114
|
end
|
102
115
|
|
116
|
+
def metadata
|
117
|
+
File.join(filesystem_path, 'metadata.json')
|
118
|
+
end
|
119
|
+
|
120
|
+
def metadata?
|
121
|
+
File.exists?(metadata)
|
122
|
+
end
|
123
|
+
|
103
124
|
def specfile
|
104
125
|
File.join(filesystem_path, environment.specfile_name)
|
105
126
|
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.0.
|
4
|
+
version: 1.0.6
|
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-08-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: librarian
|