puppet 2.7.11 → 2.7.12
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of puppet might be problematic. Click here for more details.
- data/CHANGELOG +188 -0
- data/conf/osx/createpackage.sh +1 -0
- data/conf/redhat/puppet.spec +12 -9
- data/conf/suse/puppet.spec +4 -1
- data/install.rb +9 -22
- data/lib/puppet.rb +1 -31
- data/lib/puppet/agent.rb +3 -5
- data/lib/puppet/agent/locker.rb +15 -1
- data/lib/puppet/application.rb +7 -4
- data/lib/puppet/application/agent.rb +4 -25
- data/lib/puppet/application/apply.rb +3 -3
- data/lib/puppet/application/device.rb +2 -16
- data/lib/puppet/application/doc.rb +2 -2
- data/lib/puppet/application/face_base.rb +22 -5
- data/lib/puppet/application/filebucket.rb +2 -0
- data/lib/puppet/application/inspect.rb +2 -1
- data/lib/puppet/application/kick.rb +25 -9
- data/lib/puppet/application/queue.rb +0 -23
- data/lib/puppet/configurer.rb +1 -0
- data/lib/puppet/configurer/downloader.rb +7 -3
- data/lib/puppet/defaults.rb +34 -29
- data/lib/puppet/face/ca.rb +1 -1
- data/lib/puppet/face/catalog.rb +1 -0
- data/lib/puppet/face/file/store.rb +1 -1
- data/lib/puppet/face/module/list.rb +23 -3
- data/lib/puppet/face/module/search.rb +21 -32
- data/lib/puppet/face/module/uninstall.rb +56 -15
- data/lib/puppet/file_bucket/dipper.rb +2 -2
- data/lib/puppet/file_serving/base.rb +6 -5
- data/lib/puppet/file_serving/configuration/parser.rb +1 -1
- data/lib/puppet/file_serving/content.rb +1 -1
- data/lib/puppet/forge.rb +153 -0
- data/lib/puppet/{module_tool → forge}/cache.rb +1 -2
- data/lib/puppet/{module_tool → forge}/repository.rb +46 -4
- data/lib/puppet/indirector/exec.rb +1 -1
- data/lib/puppet/indirector/file_bucket_file/file.rb +3 -3
- data/lib/puppet/interface/action.rb +6 -2
- data/lib/puppet/module.rb +70 -10
- data/lib/puppet/module_tool.rb +2 -38
- data/lib/puppet/module_tool/applications.rb +15 -11
- data/lib/puppet/module_tool/applications/application.rb +2 -5
- data/lib/puppet/module_tool/applications/cleaner.rb +1 -1
- data/lib/puppet/module_tool/applications/installer.rb +10 -45
- data/lib/puppet/module_tool/applications/searcher.rb +2 -26
- data/lib/puppet/module_tool/applications/uninstaller.rb +39 -13
- data/lib/puppet/module_tool/applications/unpacker.rb +1 -1
- data/lib/puppet/module_tool/dependency.rb +1 -1
- data/lib/puppet/network/authconfig.rb +1 -1
- data/lib/puppet/network/handler/fileserver.rb +1 -1
- data/lib/puppet/network/http/handler.rb +4 -1
- data/lib/puppet/network/http/webrick.rb +4 -2
- data/lib/puppet/node/environment.rb +32 -6
- data/lib/puppet/parameter/path.rb +0 -4
- data/lib/puppet/parser/ast/relationship.rb +3 -16
- data/lib/puppet/parser/collector.rb +5 -3
- data/lib/puppet/parser/compiler.rb +2 -1
- data/lib/puppet/parser/functions/file.rb +1 -1
- data/lib/puppet/parser/functions/generate.rb +8 -2
- data/lib/puppet/parser/grammar.ra +16 -15
- data/lib/puppet/parser/parser.rb +959 -881
- data/lib/puppet/parser/relationship.rb +32 -15
- data/lib/puppet/parser/resource.rb +0 -1
- data/lib/puppet/parser/type_loader.rb +1 -2
- data/lib/puppet/provider/augeas/augeas.rb +17 -29
- data/lib/puppet/provider/exec/windows.rb +25 -3
- data/lib/puppet/provider/file/posix.rb +1 -1
- data/lib/puppet/provider/file/windows.rb +1 -1
- data/lib/puppet/provider/group/windows_adsi.rb +1 -1
- data/lib/puppet/provider/package/aix.rb +1 -1
- data/lib/puppet/provider/package/appdmg.rb +1 -1
- data/lib/puppet/provider/package/dpkg.rb +1 -1
- data/lib/puppet/provider/package/gem.rb +21 -23
- data/lib/puppet/provider/package/macports.rb +1 -1
- data/lib/puppet/provider/package/msi.rb +7 -1
- data/lib/puppet/provider/package/openbsd.rb +13 -16
- data/lib/puppet/provider/package/pacman.rb +1 -1
- data/lib/puppet/provider/package/pip.rb +3 -0
- data/lib/puppet/provider/package/pkg.rb +1 -1
- data/lib/puppet/provider/package/pkgdmg.rb +1 -1
- data/lib/puppet/provider/package/pkgutil.rb +1 -1
- data/lib/puppet/provider/package/portage.rb +2 -2
- data/lib/puppet/provider/package/rpm.rb +1 -1
- data/lib/puppet/provider/package/sun.rb +1 -1
- data/lib/puppet/provider/package/zypper.rb +35 -3
- data/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +6 -2
- data/lib/puppet/provider/selmodule/semodule.rb +2 -2
- data/lib/puppet/provider/service/base.rb +1 -1
- data/lib/puppet/provider/service/launchd.rb +4 -0
- data/lib/puppet/provider/service/src.rb +2 -2
- data/lib/puppet/provider/service/upstart.rb +1 -1
- data/lib/puppet/provider/service/windows.rb +5 -4
- data/lib/puppet/provider/user/aix.rb +3 -3
- data/lib/puppet/provider/user/pw.rb +6 -0
- data/lib/puppet/provider/user/windows_adsi.rb +1 -1
- data/lib/puppet/resource/catalog.rb +6 -6
- data/lib/puppet/resource/type.rb +2 -0
- data/lib/puppet/ssl/certificate_request.rb +0 -70
- data/lib/puppet/transaction.rb +1 -1
- data/lib/puppet/transaction/report.rb +3 -2
- data/lib/puppet/type.rb +1 -1
- data/lib/puppet/type/cron.rb +5 -2
- data/lib/puppet/type/exec.rb +8 -0
- data/lib/puppet/type/file.rb +27 -18
- data/lib/puppet/type/file/checksum.rb +2 -2
- data/lib/puppet/type/file/content.rb +14 -9
- data/lib/puppet/type/file/ensure.rb +5 -4
- data/lib/puppet/type/file/group.rb +10 -2
- data/lib/puppet/type/file/mode.rb +46 -18
- data/lib/puppet/type/file/owner.rb +10 -2
- data/lib/puppet/type/file/source.rb +27 -40
- data/lib/puppet/type/file/target.rb +6 -6
- data/lib/puppet/type/group.rb +13 -9
- data/lib/puppet/type/k5login.rb +1 -1
- data/lib/puppet/type/package.rb +24 -8
- data/lib/puppet/type/scheduled_task.rb +77 -131
- data/lib/puppet/type/service.rb +22 -8
- data/lib/puppet/type/user.rb +29 -9
- data/lib/puppet/util.rb +24 -33
- data/lib/puppet/util/colors.rb +98 -0
- data/lib/puppet/util/diff.rb +3 -1
- data/lib/puppet/util/log.rb +5 -1
- data/lib/puppet/util/log/destinations.rb +37 -44
- data/lib/puppet/util/monkey_patches.rb +32 -0
- data/lib/puppet/util/pidlock.rb +70 -21
- data/lib/puppet/util/rdoc/parser.rb +4 -2
- data/lib/puppet/util/selinux.rb +1 -1
- data/lib/puppet/util/suidmanager.rb +2 -12
- data/lib/puppet/util/windows.rb +2 -0
- data/lib/puppet/util/windows/process.rb +33 -0
- data/lib/puppet/util/windows/security.rb +6 -4
- data/lib/puppet/util/windows/user.rb +44 -0
- data/lib/semver.rb +55 -4
- data/spec/fixtures/unit/provider/package/openbsd/pkginfo.detail +19 -0
- data/spec/fixtures/unit/provider/package/openbsd/pkginfo.list +10 -0
- data/spec/fixtures/unit/provider/package/openbsd/pkginfo.query +1 -0
- data/spec/fixtures/unit/provider/package/zypper/zypper-list-updates-SLES11sp1.out +369 -0
- data/spec/integration/defaults_spec.rb +10 -0
- data/spec/integration/indirector/direct_file_server_spec.rb +1 -1
- data/spec/integration/module_tool_spec.rb +10 -12
- data/spec/integration/parser/compiler_spec.rb +147 -0
- data/spec/integration/type/file_spec.rb +1 -1
- data/spec/integration/util/windows/user_spec.rb +59 -0
- data/spec/lib/puppet/face/basetest.rb +5 -0
- data/spec/lib/puppet_spec/modules.rb +26 -0
- data/spec/spec_helper.rb +25 -0
- data/spec/unit/agent/locker_spec.rb +12 -0
- data/spec/unit/agent_backward_compatibility_spec.rb +152 -0
- data/spec/unit/agent_spec.rb +28 -8
- data/spec/unit/application/agent_spec.rb +4 -36
- data/spec/unit/application/device_spec.rb +55 -10
- data/spec/unit/application/face_base_spec.rb +32 -10
- data/spec/unit/application/filebucket_spec.rb +5 -0
- data/spec/unit/application/kick_spec.rb +6 -0
- data/spec/unit/application_spec.rb +8 -1
- data/spec/unit/configurer/downloader_spec.rb +4 -5
- data/spec/unit/face/ca_spec.rb +15 -4
- data/spec/unit/file_bucket/dipper_spec.rb +1 -1
- data/spec/unit/file_serving/base_spec.rb +60 -42
- data/spec/unit/file_serving/configuration/parser_spec.rb +5 -3
- data/spec/unit/file_serving/content_spec.rb +26 -27
- data/spec/unit/file_serving/metadata_spec.rb +22 -21
- data/spec/unit/forge/repository_spec.rb +86 -0
- data/spec/unit/forge_spec.rb +114 -0
- data/spec/unit/indirector/exec_spec.rb +8 -6
- data/spec/unit/indirector/facts/inventory_active_record_spec.rb +0 -1
- data/spec/unit/indirector/file_bucket_file/file_spec.rb +1 -1
- data/spec/unit/indirector/node/exec_spec.rb +1 -1
- data/spec/unit/indirector/resource/active_record_spec.rb +0 -4
- data/spec/unit/interface/action_builder_spec.rb +7 -5
- data/spec/unit/module_spec.rb +228 -9
- data/spec/unit/module_tool/application_spec.rb +3 -3
- data/spec/unit/module_tool/uninstaller_spec.rb +107 -27
- data/spec/unit/module_tool_spec.rb +0 -33
- data/spec/unit/network/authconfig_spec.rb +22 -21
- data/spec/unit/network/http/webrick_spec.rb +13 -9
- data/spec/unit/node/environment_spec.rb +159 -66
- data/spec/unit/parser/collector_spec.rb +16 -8
- data/spec/unit/parser/functions/generate_spec.rb +60 -18
- data/spec/unit/parser/resource_spec.rb +44 -0
- data/spec/unit/provider/augeas/augeas_spec.rb +160 -179
- data/spec/unit/provider/confine/feature_spec.rb +3 -5
- data/spec/unit/provider/package/dpkg_spec.rb +4 -2
- data/spec/unit/provider/package/gem_spec.rb +59 -43
- data/spec/unit/provider/package/openbsd_spec.rb +114 -0
- data/spec/unit/provider/package/pacman_spec.rb +1 -1
- data/spec/unit/provider/package/pip_spec.rb +10 -4
- data/spec/unit/provider/package/zypper_spec.rb +56 -14
- data/spec/unit/provider/selmodule_spec.rb +3 -3
- data/spec/unit/provider/service/launchd_spec.rb +22 -21
- data/spec/unit/provider/service/{upstart.rb → upstart_spec.rb} +7 -3
- data/spec/unit/provider/user/pw_spec.rb +19 -0
- data/spec/unit/resource/catalog_spec.rb +3 -3
- data/spec/unit/semver_spec.rb +117 -24
- data/spec/unit/transaction/report_spec.rb +11 -1
- data/spec/unit/type/cron_spec.rb +200 -213
- data/spec/unit/type/exec_spec.rb +7 -0
- data/spec/unit/type/file/content_spec.rb +2 -2
- data/spec/unit/type/file_spec.rb +12 -9
- data/spec/unit/type/package_spec.rb +25 -0
- data/spec/unit/type/schedule_spec.rb +31 -31
- data/spec/unit/util/diff_spec.rb +30 -0
- data/spec/unit/util/execution_stub_spec.rb +1 -2
- data/spec/unit/util/log/destinations_spec.rb +51 -0
- data/spec/unit/util/log_spec.rb +17 -1
- data/spec/unit/util/monkey_patches_spec.rb +119 -0
- data/spec/unit/util/rdoc/parser_spec.rb +25 -1
- data/spec/unit/util/selinux_spec.rb +2 -2
- data/spec/unit/util/suidmanager_spec.rb +6 -51
- data/spec/unit/util_spec.rb +82 -24
- data/test/lib/puppettest/certificates.rb +16 -0
- data/test/lib/puppettest/servertest.rb +4 -0
- data/test/util/pidlock.rb +125 -0
- metadata +23 -14
- data/ext/puppetstoredconfigclean.rb +0 -103
- data/lib/puppet/agent/disabler.rb +0 -27
- data/lib/puppet/util/anonymous_filelock.rb +0 -36
- data/spec/unit/agent/disabler_spec.rb +0 -60
- data/spec/unit/module_tool/repository_spec.rb +0 -52
- data/spec/unit/util/anonymous_filelock_spec.rb +0 -78
- data/spec/unit/util/pidlock_spec.rb +0 -208
@@ -2,13 +2,19 @@ require 'net/http'
|
|
2
2
|
require 'digest/sha1'
|
3
3
|
require 'uri'
|
4
4
|
|
5
|
-
|
5
|
+
require 'puppet/module_tool/utils'
|
6
|
+
|
7
|
+
module Puppet::Forge
|
8
|
+
# Directory names that should not be checksummed.
|
9
|
+
ARTIFACTS = ['pkg', /^\./, /^~/, /^#/, 'coverage']
|
10
|
+
FULL_MODULE_NAME_PATTERN = /\A([^-\/|.]+)[-|\/](.+)\z/
|
11
|
+
REPOSITORY_URL = Puppet.settings[:module_repository]
|
6
12
|
|
7
13
|
# = Repository
|
8
14
|
#
|
9
15
|
# This class is a file for accessing remote repositories with modules.
|
10
16
|
class Repository
|
11
|
-
include Utils::Interrogation
|
17
|
+
include Puppet::Module::Tool::Utils::Interrogation
|
12
18
|
|
13
19
|
attr_reader :uri, :cache
|
14
20
|
|
@@ -19,6 +25,42 @@ module Puppet::Module::Tool
|
|
19
25
|
@cache = Cache.new(self)
|
20
26
|
end
|
21
27
|
|
28
|
+
# Read HTTP proxy configurationm from Puppet's config file, or the
|
29
|
+
# http_proxy environment variable.
|
30
|
+
def http_proxy_env
|
31
|
+
proxy_env = ENV["http_proxy"] || ENV["HTTP_PROXY"] || nil
|
32
|
+
begin
|
33
|
+
return URI.parse(proxy_env) if proxy_env
|
34
|
+
rescue URI::InvalidURIError
|
35
|
+
return nil
|
36
|
+
end
|
37
|
+
return nil
|
38
|
+
end
|
39
|
+
|
40
|
+
def http_proxy_host
|
41
|
+
env = http_proxy_env
|
42
|
+
|
43
|
+
if env and env.host then
|
44
|
+
return env.host
|
45
|
+
end
|
46
|
+
|
47
|
+
if Puppet.settings[:http_proxy_host] == 'none'
|
48
|
+
return nil
|
49
|
+
end
|
50
|
+
|
51
|
+
return Puppet.settings[:http_proxy_host]
|
52
|
+
end
|
53
|
+
|
54
|
+
def http_proxy_port
|
55
|
+
env = http_proxy_env
|
56
|
+
|
57
|
+
if env and env.port then
|
58
|
+
return env.port
|
59
|
+
end
|
60
|
+
|
61
|
+
return Puppet.settings[:http_proxy_port]
|
62
|
+
end
|
63
|
+
|
22
64
|
# Return a Net::HTTPResponse read for this +request+.
|
23
65
|
#
|
24
66
|
# Options:
|
@@ -37,8 +79,8 @@ module Puppet::Module::Tool
|
|
37
79
|
def read_response(request)
|
38
80
|
begin
|
39
81
|
Net::HTTP::Proxy(
|
40
|
-
|
41
|
-
|
82
|
+
http_proxy_host,
|
83
|
+
http_proxy_port
|
42
84
|
).start(@uri.host, @uri.port) do |http|
|
43
85
|
http.request(request)
|
44
86
|
end
|
@@ -28,7 +28,7 @@ class Puppet::Indirector::Exec < Puppet::Indirector::Terminus
|
|
28
28
|
raise Puppet::DevError, "Exec commands must be an array" unless external_command.is_a?(Array)
|
29
29
|
|
30
30
|
# Make sure it's fully qualified.
|
31
|
-
raise ArgumentError, "You must set the exec parameter to a fully qualified command" unless external_command[0]
|
31
|
+
raise ArgumentError, "You must set the exec parameter to a fully qualified command" unless Puppet::Util.absolute_path?(external_command[0])
|
32
32
|
|
33
33
|
# Add our name to it.
|
34
34
|
external_command << name
|
@@ -27,7 +27,7 @@ module Puppet::FileBucketFile
|
|
27
27
|
raise "could not find diff_with #{request.options[:diff_with]}" unless ::File.exists?(file2_path)
|
28
28
|
return `diff #{file_path.inspect} #{file2_path.inspect}`
|
29
29
|
else
|
30
|
-
contents =
|
30
|
+
contents = IO.binread(file_path)
|
31
31
|
Puppet.info "FileBucket read #{checksum}"
|
32
32
|
model.new(contents)
|
33
33
|
end
|
@@ -55,7 +55,7 @@ module Puppet::FileBucketFile
|
|
55
55
|
paths_path = ::File.join(dir_path, 'paths')
|
56
56
|
return false unless ::File.exists?(paths_path)
|
57
57
|
::File.open(paths_path) do |f|
|
58
|
-
f.
|
58
|
+
f.each_line do |line|
|
59
59
|
return true if line.chomp == files_original_path
|
60
60
|
end
|
61
61
|
end
|
@@ -122,7 +122,7 @@ module Puppet::FileBucketFile
|
|
122
122
|
# If conflict_check is enabled, verify that the passed text is
|
123
123
|
# the same as the text in our file.
|
124
124
|
def verify_identical_file!(bucket_file)
|
125
|
-
disk_contents =
|
125
|
+
disk_contents = IO.binread(path_for(bucket_file.bucket_path, bucket_file.checksum_data, 'contents'))
|
126
126
|
|
127
127
|
# If the contents don't match, then we've found a conflict.
|
128
128
|
# Unlikely, but quite bad.
|
@@ -74,8 +74,12 @@ class Puppet::Interface::Action
|
|
74
74
|
msg += ", not #{proc.class.name}" unless proc.nil?
|
75
75
|
raise ArgumentError, msg
|
76
76
|
end
|
77
|
-
|
78
|
-
|
77
|
+
|
78
|
+
if proc.arity != 1 and proc.arity != (@positional_arg_count + 1)
|
79
|
+
msg = "the when_rendering method for the #{@face.name} face #{name} action "
|
80
|
+
msg += "takes either just one argument, the result of when_invoked, "
|
81
|
+
msg += "or the result plus the #{@positional_arg_count} arguments passed "
|
82
|
+
msg += "to the when_invoked block, not "
|
79
83
|
if proc.arity < 0 then
|
80
84
|
msg += "a variable number"
|
81
85
|
else
|
data/lib/puppet/module.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
require 'puppet/util/logging'
|
2
|
+
require 'semver'
|
3
|
+
require 'puppet/module_tool/applications'
|
2
4
|
|
3
5
|
# Support for modules
|
4
6
|
class Puppet::Module
|
@@ -30,6 +32,7 @@ class Puppet::Module
|
|
30
32
|
attr_reader :name, :environment
|
31
33
|
attr_writer :environment
|
32
34
|
|
35
|
+
attr_accessor :dependencies, :forge_name
|
33
36
|
attr_accessor :source, :author, :version, :license, :puppetversion, :summary, :description, :project_page
|
34
37
|
|
35
38
|
def has_metadata?
|
@@ -38,6 +41,8 @@ class Puppet::Module
|
|
38
41
|
return false unless FileTest.exist?(metadata_file)
|
39
42
|
|
40
43
|
metadata = PSON.parse File.read(metadata_file)
|
44
|
+
|
45
|
+
|
41
46
|
return metadata.is_a?(Hash) && !metadata.keys.empty?
|
42
47
|
end
|
43
48
|
|
@@ -56,7 +61,6 @@ class Puppet::Module
|
|
56
61
|
load_metadata if has_metadata?
|
57
62
|
|
58
63
|
validate_puppet_version
|
59
|
-
validate_dependencies
|
60
64
|
end
|
61
65
|
|
62
66
|
FILETYPES.each do |type|
|
@@ -107,7 +111,9 @@ class Puppet::Module
|
|
107
111
|
|
108
112
|
def load_metadata
|
109
113
|
data = PSON.parse File.read(metadata_file)
|
110
|
-
[
|
114
|
+
@forge_name = data['name'].gsub('-', '/') if data['name']
|
115
|
+
|
116
|
+
[:source, :author, :version, :license, :puppetversion, :dependencies].each do |attr|
|
111
117
|
unless value = data[attr.to_s]
|
112
118
|
unless attr == :puppetversion
|
113
119
|
raise MissingMetadata, "No #{attr} module metadata provided for #{self.name}"
|
@@ -154,18 +160,72 @@ class Puppet::Module
|
|
154
160
|
result
|
155
161
|
end
|
156
162
|
|
157
|
-
def
|
158
|
-
|
163
|
+
def dependencies_as_modules
|
164
|
+
dependent_modules = []
|
165
|
+
dependencies and dependencies.each do |dep|
|
166
|
+
author, dep_name = dep["name"].split('/')
|
167
|
+
found_module = environment.module(dep_name)
|
168
|
+
dependent_modules << found_module if found_module
|
169
|
+
end
|
170
|
+
|
171
|
+
dependent_modules
|
172
|
+
end
|
173
|
+
|
174
|
+
def required_by
|
175
|
+
environment.module_requirements[self.forge_name] || {}
|
176
|
+
end
|
177
|
+
|
178
|
+
def has_local_changes?
|
179
|
+
changes = Puppet::Module::Tool::Applications::Checksummer.run(path)
|
180
|
+
!changes.empty?
|
181
|
+
end
|
159
182
|
|
160
|
-
|
161
|
-
|
162
|
-
|
183
|
+
def unmet_dependencies
|
184
|
+
return [] unless dependencies
|
185
|
+
|
186
|
+
unmet_dependencies = []
|
187
|
+
|
188
|
+
dependencies.each do |dependency|
|
189
|
+
forge_name = dependency['name']
|
190
|
+
author, dep_name = forge_name.split('/')
|
191
|
+
version_string = dependency['version_requirement']
|
192
|
+
|
193
|
+
equality, dep_version = version_string ? version_string.split("\s") : [nil, nil]
|
194
|
+
|
195
|
+
unless dep_mod = environment.module(dep_name)
|
196
|
+
msg = "Missing dependency `#{dep_name}`:\n"
|
197
|
+
msg += " `#{self.name}` (#{self.version}) requires `#{forge_name}` (#{version_string})\n"
|
198
|
+
unmet_dependencies << { :name => forge_name, :error => msg }
|
199
|
+
next
|
163
200
|
end
|
164
201
|
|
165
|
-
if
|
166
|
-
|
202
|
+
if dep_version && !dep_mod.version
|
203
|
+
msg = "Unversioned dependency `#{dep_mod.name}`:\n"
|
204
|
+
msg += " `#{self.name}` (#{self.version}) requires `#{forge_name}` (#{version_string})\n"
|
205
|
+
unmet_dependencies << { :name => forge_name, :error => msg }
|
206
|
+
next
|
207
|
+
end
|
208
|
+
|
209
|
+
if dep_version
|
210
|
+
begin
|
211
|
+
required_version_semver = SemVer.new(dep_version)
|
212
|
+
actual_version_semver = SemVer.new(dep_mod.version)
|
213
|
+
rescue ArgumentError
|
214
|
+
msg = "Non semantic version dependency `#{dep_mod.name}` (#{dep_mod.version}):\n"
|
215
|
+
msg += " `#{self.name}` (#{self.version}) requires `#{forge_name}` (#{version_string})\n"
|
216
|
+
unmet_dependencies << { :name => forge_name, :error => msg }
|
217
|
+
next
|
218
|
+
end
|
219
|
+
|
220
|
+
if !actual_version_semver.send(equality, required_version_semver)
|
221
|
+
msg = "Version dependency mismatch `#{dep_mod.name}` (#{dep_mod.version}):\n"
|
222
|
+
msg += " `#{self.name}` (#{self.version}) requires `#{forge_name}` (#{version_string})\n"
|
223
|
+
unmet_dependencies << { :name => forge_name, :error => msg }
|
224
|
+
next
|
225
|
+
end
|
167
226
|
end
|
168
227
|
end
|
228
|
+
unmet_dependencies
|
169
229
|
end
|
170
230
|
|
171
231
|
def validate_puppet_version
|
@@ -191,7 +251,7 @@ class Puppet::Module
|
|
191
251
|
end
|
192
252
|
|
193
253
|
def assert_validity
|
194
|
-
raise InvalidName, "Invalid module name; module names must be alphanumeric (plus '-'), not '#{name}'" unless name =~ /^[-\w]+$/
|
254
|
+
raise InvalidName, "Invalid module name #{name}; module names must be alphanumeric (plus '-'), not '#{name}'" unless name =~ /^[-\w]+$/
|
195
255
|
end
|
196
256
|
|
197
257
|
def ==(other)
|
data/lib/puppet/module_tool.rb
CHANGED
@@ -37,42 +37,6 @@ module Puppet
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
# Read HTTP proxy configurationm from Puppet's config file, or the
|
41
|
-
# http_proxy environment variable.
|
42
|
-
def self.http_proxy_env
|
43
|
-
proxy_env = ENV["http_proxy"] || ENV["HTTP_PROXY"] || nil
|
44
|
-
begin
|
45
|
-
return URI.parse(proxy_env) if proxy_env
|
46
|
-
rescue URI::InvalidURIError
|
47
|
-
return nil
|
48
|
-
end
|
49
|
-
return nil
|
50
|
-
end
|
51
|
-
|
52
|
-
def self.http_proxy_host
|
53
|
-
env = http_proxy_env
|
54
|
-
|
55
|
-
if env and env.host then
|
56
|
-
return env.host
|
57
|
-
end
|
58
|
-
|
59
|
-
if Puppet.settings[:http_proxy_host] == 'none'
|
60
|
-
return nil
|
61
|
-
end
|
62
|
-
|
63
|
-
return Puppet.settings[:http_proxy_host]
|
64
|
-
end
|
65
|
-
|
66
|
-
def self.http_proxy_port
|
67
|
-
env = http_proxy_env
|
68
|
-
|
69
|
-
if env and env.port then
|
70
|
-
return env.port
|
71
|
-
end
|
72
|
-
|
73
|
-
return Puppet.settings[:http_proxy_port]
|
74
|
-
end
|
75
|
-
|
76
40
|
def self.find_module_root(path)
|
77
41
|
for dir in [path, Dir.pwd].compact
|
78
42
|
if File.exist?(File.join(dir, 'Modulefile'))
|
@@ -87,11 +51,11 @@ end
|
|
87
51
|
|
88
52
|
# Load remaining libraries
|
89
53
|
require 'puppet/module_tool/applications'
|
90
|
-
require 'puppet/module_tool/cache'
|
91
54
|
require 'puppet/module_tool/checksums'
|
92
55
|
require 'puppet/module_tool/contents_description'
|
93
56
|
require 'puppet/module_tool/dependency'
|
94
57
|
require 'puppet/module_tool/metadata'
|
95
58
|
require 'puppet/module_tool/modulefile'
|
96
|
-
require 'puppet/module_tool/repository'
|
97
59
|
require 'puppet/module_tool/skeleton'
|
60
|
+
require 'puppet/forge/cache'
|
61
|
+
require 'puppet/forge'
|
@@ -1,13 +1,17 @@
|
|
1
|
-
module
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
1
|
+
require 'puppet/module'
|
2
|
+
|
3
|
+
class Puppet::Module
|
4
|
+
module Tool
|
5
|
+
module Applications
|
6
|
+
require 'puppet/module_tool/applications/application'
|
7
|
+
require 'puppet/module_tool/applications/builder'
|
8
|
+
require 'puppet/module_tool/applications/checksummer'
|
9
|
+
require 'puppet/module_tool/applications/cleaner'
|
10
|
+
require 'puppet/module_tool/applications/generator'
|
11
|
+
require 'puppet/module_tool/applications/installer'
|
12
|
+
require 'puppet/module_tool/applications/searcher'
|
13
|
+
require 'puppet/module_tool/applications/unpacker'
|
14
|
+
require 'puppet/module_tool/applications/uninstaller'
|
15
|
+
end
|
12
16
|
end
|
13
17
|
end
|
@@ -1,10 +1,11 @@
|
|
1
1
|
require 'net/http'
|
2
2
|
require 'semver'
|
3
|
+
require 'puppet/module_tool/utils/interrogation'
|
3
4
|
|
4
5
|
module Puppet::Module::Tool
|
5
6
|
module Applications
|
6
7
|
class Application
|
7
|
-
include Utils::Interrogation
|
8
|
+
include Puppet::Module::Tool::Utils::Interrogation
|
8
9
|
|
9
10
|
def self.run(*args)
|
10
11
|
new(*args).run
|
@@ -16,10 +17,6 @@ module Puppet::Module::Tool
|
|
16
17
|
@options = options
|
17
18
|
end
|
18
19
|
|
19
|
-
def repository
|
20
|
-
@repository ||= Repository.new(@options[:module_repository])
|
21
|
-
end
|
22
|
-
|
23
20
|
def run
|
24
21
|
raise NotImplementedError, "Should be implemented in child classes."
|
25
22
|
end
|
@@ -2,7 +2,7 @@ module Puppet::Module::Tool
|
|
2
2
|
module Applications
|
3
3
|
class Cleaner < Application
|
4
4
|
def run
|
5
|
-
Puppet::
|
5
|
+
Puppet::Forge::Cache.clean
|
6
6
|
|
7
7
|
# Return a status Hash containing the status of the clean command
|
8
8
|
# and a status message. This return value is used by the module_tool
|
@@ -7,22 +7,26 @@ module Puppet::Module::Tool
|
|
7
7
|
class Installer < Application
|
8
8
|
|
9
9
|
def initialize(name, options = {})
|
10
|
+
@forge = Puppet::Forge::Forge.new
|
11
|
+
@install_params = {}
|
12
|
+
|
10
13
|
if File.exist?(name)
|
11
14
|
if File.directory?(name)
|
12
15
|
# TODO Unify this handling with that of Unpacker#check_clobber!
|
13
16
|
raise ArgumentError, "Module already installed: #{name}"
|
14
17
|
end
|
15
|
-
@source = :filesystem
|
16
18
|
@filename = File.expand_path(name)
|
19
|
+
@install_params[:source] = :filesystem
|
20
|
+
@install_params[:filename] = @filename
|
17
21
|
parse_filename!
|
18
22
|
else
|
19
|
-
@source = :repository
|
23
|
+
@install_params[:source] = :repository
|
20
24
|
begin
|
21
|
-
@
|
25
|
+
@install_params[:author], @install_params[:modname] = Puppet::Module::Tool::username_and_modname_from(name)
|
22
26
|
rescue ArgumentError
|
23
27
|
raise "Could not install module with invalid name: #{name}"
|
24
28
|
end
|
25
|
-
@version_requirement = options[:version]
|
29
|
+
@install_params[:version_requirement] = options[:version]
|
26
30
|
end
|
27
31
|
super(options)
|
28
32
|
end
|
@@ -32,27 +36,9 @@ module Puppet::Module::Tool
|
|
32
36
|
end
|
33
37
|
|
34
38
|
def run
|
35
|
-
|
36
|
-
when :repository
|
37
|
-
if match['file']
|
38
|
-
begin
|
39
|
-
cache_path = repository.retrieve(match['file'])
|
40
|
-
rescue OpenURI::HTTPError => e
|
41
|
-
raise RuntimeError, "Could not install module: #{e.message}"
|
42
|
-
end
|
43
|
-
module_dir = Unpacker.run(cache_path, options)
|
44
|
-
else
|
45
|
-
raise RuntimeError, "Malformed response from module repository."
|
46
|
-
end
|
47
|
-
when :filesystem
|
48
|
-
repository = Repository.new('file:///')
|
49
|
-
uri = URI.parse("file://#{URI.escape(File.expand_path(@filename))}")
|
50
|
-
cache_path = repository.retrieve(uri)
|
51
|
-
module_dir = Unpacker.run(cache_path, options)
|
52
|
-
else
|
53
|
-
raise ArgumentError, "Could not determine installation source"
|
54
|
-
end
|
39
|
+
cache_path = @forge.get_release_package(@install_params)
|
55
40
|
|
41
|
+
module_dir = Unpacker.run(cache_path, options)
|
56
42
|
# Return the Pathname object representing the path to the installed
|
57
43
|
# module. This return value is used by the module_tool face install
|
58
44
|
# action, and displayed to on the console.
|
@@ -63,27 +49,6 @@ module Puppet::Module::Tool
|
|
63
49
|
#
|
64
50
|
module_dir
|
65
51
|
end
|
66
|
-
|
67
|
-
private
|
68
|
-
|
69
|
-
def match
|
70
|
-
return @match ||= begin
|
71
|
-
url = repository.uri + "/users/#{@username}/modules/#{@module_name}/releases/find.json"
|
72
|
-
if @version_requirement
|
73
|
-
url.query = "version=#{URI.escape(@version_requirement)}"
|
74
|
-
end
|
75
|
-
begin
|
76
|
-
raw_result = read_match(url)
|
77
|
-
rescue => e
|
78
|
-
raise ArgumentError, "Could not find a release for this module (#{e.message})"
|
79
|
-
end
|
80
|
-
@match = PSON.parse(raw_result)
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
def read_match(url)
|
85
|
-
return url.read
|
86
|
-
end
|
87
52
|
end
|
88
53
|
end
|
89
54
|
end
|