generate-puppetfile 0.9.6 → 0.9.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/lib/generate_puppetfile/bin.rb +22 -5
- data/lib/generate_puppetfile/version.rb +1 -1
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
ZjBlZWI4OGVhYjA2MTUyM2Q1MjY4YjBjZDQ0MjFkODE0YTE5ZTdlZg==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 046880c28c4dd0c6b7e9a4c90e0c367d7c3ff98f
|
4
|
+
data.tar.gz: f54a50e8fc4ea2cf60b7e3f1cf68f2a415ede968
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
Njc5MTdkNzljODNhMjZjYmY0NjhmZTliMTY5ZWZiM2VmYzIxZGUyMDU3NDcz
|
11
|
-
OTQyNWFhYWMxYTFmMmRkZTI4YTljODQ4MWNhNmQxMzA5MzQ0OTg=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
MTVkNmI4YzJlMGJjMmU2YmZhNjFiOTZiYmY1YmJlYTZlY2E0YjYzY2FhN2Zl
|
14
|
-
MWNhNmE0ZmIyNjQyMWRkNjhiMTgwYWVjMzc2N2IxZWU4NWY4OWVjYzUxNTMz
|
15
|
-
NGYzNTMxYmNlYmI0YjMyZDNlY2Q1NDFmODUyZjMzM2I1ZDA5YTg=
|
6
|
+
metadata.gz: 91f353684c05b1043a821ce7db214f073a380df2f99b105a05b1f23e18223048b749c11f2441578733ceb6fb4025f03d0bae36815c801cbf4ded8be18f279648
|
7
|
+
data.tar.gz: b05c4d699fb020dd5d2fecfe85f66871459dc4cc0c73e7cd2418c6ef50cafe8c6b755bff4687fea7f7acadabd50d1ef2748ebad0e90a91b687630a7b057bce98
|
@@ -4,14 +4,17 @@ require 'generate_puppetfile/optparser'
|
|
4
4
|
require 'fileutils'
|
5
5
|
require 'tempfile'
|
6
6
|
require 'json'
|
7
|
+
require 'mkmf'
|
7
8
|
|
8
9
|
module GeneratePuppetfile
|
9
10
|
# Internal: The Bin class contains the logic for calling generate_puppetfile at the command line
|
10
11
|
class Bin
|
11
|
-
|
12
|
+
Module_Regex = Regexp.new("mod ['\"]([a-z0-9_]+\/[a-z0-9_]+)['\"](, ['\"](\\d\.\\d\.\\d)['\"])?", Regexp::IGNORECASE)
|
12
13
|
@options = {} # Options hash
|
13
14
|
@workspace = nil # Working directory for module download and inspection
|
14
15
|
Silence = '>/dev/null 2>&1 '
|
16
|
+
Puppetfile_Header = '# Modules discovered by generate-puppetfile'
|
17
|
+
Extras_Note = '# Discovered elements from existing Puppetfile'
|
15
18
|
|
16
19
|
# Public: Initialize a new GeneratePuppetfile::Bin
|
17
20
|
#
|
@@ -38,6 +41,12 @@ module GeneratePuppetfile
|
|
38
41
|
return 1
|
39
42
|
end
|
40
43
|
|
44
|
+
if (! verify_puppet_exists())
|
45
|
+
$stderr.puts "generate-puppetfile: Could not find a 'puppet' executable."
|
46
|
+
$stderr.puts " Please make puppet available in your path before trying again."
|
47
|
+
return 1
|
48
|
+
end
|
49
|
+
|
41
50
|
forge_module_list = Array.new
|
42
51
|
|
43
52
|
if @args
|
@@ -148,14 +157,15 @@ Your Puppetfile has been generated. Copy and paste between the markers:
|
|
148
157
|
}
|
149
158
|
|
150
159
|
File.foreach(puppetfile) do |line|
|
151
|
-
if
|
160
|
+
if Module_Regex.match(line)
|
152
161
|
name = $1
|
153
162
|
print " #{name} looks like a forge module.\n" if @options[:debug]
|
154
163
|
puppetfile_contents[:modules].push(name)
|
155
164
|
else
|
156
165
|
next if line =~ /^forge/
|
157
166
|
next if line =~ /^\s+$/
|
158
|
-
next if line =~ /#
|
167
|
+
next if line =~ /#{Puppetfile_Header}/
|
168
|
+
next if line =~ /#{Extras_Note}/
|
159
169
|
|
160
170
|
puppetfile_contents[:extras].push(line)
|
161
171
|
end
|
@@ -164,6 +174,12 @@ Your Puppetfile has been generated. Copy and paste between the markers:
|
|
164
174
|
puppetfile_contents
|
165
175
|
end
|
166
176
|
|
177
|
+
# Public: Verify that Puppet is available in the path
|
178
|
+
def verify_puppet_exists()
|
179
|
+
MakeMakefile::Logging.instance_variable_set(:@logfile, File::NULL)
|
180
|
+
find_executable0('puppet')
|
181
|
+
end
|
182
|
+
|
167
183
|
# Public: Download the list of modules and their dependencies to @workspace
|
168
184
|
#
|
169
185
|
# module_list is an array of forge module names to be downloaded
|
@@ -173,6 +189,7 @@ Your Puppetfile has been generated. Copy and paste between the markers:
|
|
173
189
|
command = "puppet module install #{name} "
|
174
190
|
command += @modulepath + Silence
|
175
191
|
|
192
|
+
puts "Calling '#{command}'" if @options[:debug]
|
176
193
|
system(command)
|
177
194
|
end
|
178
195
|
end
|
@@ -202,12 +219,12 @@ Your Puppetfile has been generated. Copy and paste between the markers:
|
|
202
219
|
puppetfile_contents = <<-EOF
|
203
220
|
forge 'http://forge.puppetlabs.com'
|
204
221
|
|
205
|
-
#
|
222
|
+
#{Puppetfile_Header}
|
206
223
|
EOF
|
207
224
|
|
208
225
|
puppetfile_contents += generate_module_output()
|
209
226
|
|
210
|
-
puppetfile_contents += "#
|
227
|
+
puppetfile_contents += "#{Extras_Note}\n" unless extras == []
|
211
228
|
extras.each do |line|
|
212
229
|
puppetfile_contents += "#{line}"
|
213
230
|
end unless extras == []
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: generate-puppetfile
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rob Nelson
|
@@ -14,16 +14,16 @@ dependencies:
|
|
14
14
|
name: rake
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -74,8 +74,8 @@ executables:
|
|
74
74
|
extensions: []
|
75
75
|
extra_rdoc_files: []
|
76
76
|
files:
|
77
|
-
- README.md
|
78
77
|
- bin/generate-puppetfile
|
78
|
+
- README.md
|
79
79
|
- lib/generate_puppetfile.rb
|
80
80
|
- lib/generate_puppetfile/bin.rb
|
81
81
|
- lib/generate_puppetfile/optparser.rb
|
@@ -90,17 +90,17 @@ require_paths:
|
|
90
90
|
- lib
|
91
91
|
required_ruby_version: !ruby/object:Gem::Requirement
|
92
92
|
requirements:
|
93
|
-
- -
|
93
|
+
- - '>='
|
94
94
|
- !ruby/object:Gem::Version
|
95
95
|
version: '0'
|
96
96
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
97
|
requirements:
|
98
|
-
- -
|
98
|
+
- - '>='
|
99
99
|
- !ruby/object:Gem::Version
|
100
100
|
version: '0'
|
101
101
|
requirements: []
|
102
102
|
rubyforge_project:
|
103
|
-
rubygems_version: 2.
|
103
|
+
rubygems_version: 2.0.14
|
104
104
|
signing_key:
|
105
105
|
specification_version: 4
|
106
106
|
summary: Generate a Puppetfile
|