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
@@ -3,19 +3,20 @@ class Puppet::Parser::Relationship
|
|
3
3
|
|
4
4
|
PARAM_MAP = {:relationship => :before, :subscription => :notify}
|
5
5
|
|
6
|
-
def
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
if target.is_a?(Puppet::Parser::Collector)
|
13
|
-
targets = target.collected.values
|
6
|
+
def arrayify(resources)
|
7
|
+
case resources
|
8
|
+
when Puppet::Parser::Collector
|
9
|
+
resources.collected.values
|
10
|
+
when Array
|
11
|
+
resources
|
14
12
|
else
|
15
|
-
|
13
|
+
[resources]
|
16
14
|
end
|
17
|
-
|
18
|
-
|
15
|
+
end
|
16
|
+
|
17
|
+
def evaluate(catalog)
|
18
|
+
arrayify(source).each do |s|
|
19
|
+
arrayify(target).each do |t|
|
19
20
|
mk_relationship(s, t, catalog)
|
20
21
|
end
|
21
22
|
end
|
@@ -30,14 +31,30 @@ class Puppet::Parser::Relationship
|
|
30
31
|
end
|
31
32
|
|
32
33
|
def mk_relationship(source, target, catalog)
|
33
|
-
|
34
|
+
# REVISIT: In Ruby 1.8 we applied `to_s` to source and target, rather than
|
35
|
+
# `join` without an argument. In 1.9 the behaviour of Array#to_s changed,
|
36
|
+
# and it gives a different representation than just concat the stringified
|
37
|
+
# elements.
|
38
|
+
#
|
39
|
+
# This restores the behaviour, but doesn't address the underlying question
|
40
|
+
# of what would happen when more than one item was passed in that array.
|
41
|
+
# (Hint: this will not end well.)
|
42
|
+
#
|
43
|
+
# See http://projects.puppetlabs.com/issues/12076 for the ticket tracking
|
44
|
+
# the fact that we should dig out the sane version of this behaviour, then
|
45
|
+
# implement it - where we don't risk breaking a stable release series.
|
46
|
+
# --daniel 2012-01-21
|
47
|
+
source = source.is_a?(Array) ? source.join : source.to_s
|
48
|
+
target = target.is_a?(Array) ? target.join : target.to_s
|
49
|
+
|
50
|
+
unless source_resource = catalog.resource(source)
|
34
51
|
raise ArgumentError, "Could not find resource '#{source}' for relationship on '#{target}'"
|
35
52
|
end
|
36
|
-
unless target_resource = catalog.resource(target
|
53
|
+
unless target_resource = catalog.resource(target)
|
37
54
|
raise ArgumentError, "Could not find resource '#{target}' for relationship from '#{source}'"
|
38
55
|
end
|
39
|
-
Puppet.debug "Adding relationship from #{source
|
56
|
+
Puppet.debug "Adding relationship from #{source} to #{target} with '#{param_name}'"
|
40
57
|
source_resource[param_name] ||= []
|
41
|
-
source_resource[param_name] << target
|
58
|
+
source_resource[param_name] << target
|
42
59
|
end
|
43
60
|
end
|
@@ -80,8 +80,7 @@ class Puppet::Parser::TypeLoader
|
|
80
80
|
|
81
81
|
loaded_asts = []
|
82
82
|
files.each do |file|
|
83
|
-
|
84
|
-
unless file =~ regex
|
83
|
+
unless Puppet::Util.absolute_path?(file)
|
85
84
|
file = File.join(dir, file)
|
86
85
|
end
|
87
86
|
@loading_helper.do_once(file) do
|
@@ -285,10 +285,10 @@ Puppet::Type.type(:augeas).provide(:augeas) do
|
|
285
285
|
|
286
286
|
unless force
|
287
287
|
# If we have a verison of augeas which is at least 0.3.6 then we
|
288
|
-
# can make the changes now
|
289
|
-
# actually do the save.
|
288
|
+
# can make the changes now and see if changes were made.
|
290
289
|
if return_value and versioncmp(get_augeas_version, "0.3.6") >= 0
|
291
290
|
debug("Will attempt to save and only run if files changed")
|
291
|
+
# Execute in NEWFILE mode so we can show a diff
|
292
292
|
set_augeas_save_mode(SAVE_NEWFILE)
|
293
293
|
do_execute_changes
|
294
294
|
save_result = @aug.save
|
@@ -298,13 +298,11 @@ Puppet::Type.type(:augeas).provide(:augeas) do
|
|
298
298
|
if saved_files.size > 0
|
299
299
|
root = resource[:root].sub(/^\/$/, "")
|
300
300
|
saved_files.each do |key|
|
301
|
-
saved_file = @aug.get(key).
|
301
|
+
saved_file = @aug.get(key).sub(/^\/files/, root)
|
302
302
|
if Puppet[:show_diff]
|
303
303
|
notice "\n" + diff(saved_file, saved_file + ".augnew")
|
304
304
|
end
|
305
|
-
|
306
|
-
File.delete(saved_file + ".augnew")
|
307
|
-
end
|
305
|
+
File.delete(saved_file + ".augnew")
|
308
306
|
end
|
309
307
|
debug("Files changed, should execute")
|
310
308
|
return_value = true
|
@@ -323,32 +321,22 @@ Puppet::Type.type(:augeas).provide(:augeas) do
|
|
323
321
|
end
|
324
322
|
|
325
323
|
def execute_changes
|
326
|
-
#
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
unless saved_files.empty?
|
331
|
-
saved_files.each do |key|
|
332
|
-
root = resource[:root].sub(/^\/$/, "")
|
333
|
-
saved_file = @aug.get(key).to_s.sub(/^\/files/, root)
|
334
|
-
if File.exists?(saved_file + ".augnew")
|
335
|
-
success = File.rename(saved_file + ".augnew", saved_file)
|
336
|
-
debug(saved_file + ".augnew moved to " + saved_file)
|
337
|
-
fail("Rename failed with return code #{success}") if success != 0
|
338
|
-
end
|
339
|
-
end
|
340
|
-
else
|
341
|
-
debug("No saved files, re-executing augeas")
|
342
|
-
set_augeas_save_mode(SAVE_OVERWRITE) if versioncmp(get_augeas_version, "0.3.6") >= 0
|
343
|
-
do_execute_changes
|
344
|
-
success = @aug.save
|
345
|
-
fail("Save failed with return code #{success}") if success != true
|
346
|
-
end
|
347
|
-
ensure
|
348
|
-
close_augeas
|
324
|
+
# Workaround Augeas bug where changing the save mode doesn't trigger a
|
325
|
+
# reload of the previously saved file(s) when we call Augeas#load
|
326
|
+
@aug.match("/augeas/events/saved").each do |file|
|
327
|
+
@aug.rm("/augeas#{@aug.get(file)}/mtime")
|
349
328
|
end
|
350
329
|
|
330
|
+
# Reload augeas, and execute the changes for real
|
331
|
+
set_augeas_save_mode(SAVE_OVERWRITE) if versioncmp(get_augeas_version, "0.3.6") >= 0
|
332
|
+
@aug.load
|
333
|
+
do_execute_changes
|
334
|
+
success = @aug.save
|
335
|
+
fail("Save failed with return code #{success}") if success != true
|
336
|
+
|
351
337
|
:executed
|
338
|
+
ensure
|
339
|
+
close_augeas
|
352
340
|
end
|
353
341
|
|
354
342
|
# Actually execute the augeas changes.
|
@@ -6,9 +6,31 @@ Puppet::Type.type(:exec).provide :windows, :parent => Puppet::Provider::Exec do
|
|
6
6
|
confine :operatingsystem => :windows
|
7
7
|
defaultfor :operatingsystem => :windows
|
8
8
|
|
9
|
-
desc
|
10
|
-
|
11
|
-
|
9
|
+
desc <<-EOT
|
10
|
+
Execute external binaries on Windows systems. As with the `posix`
|
11
|
+
provider, this provider directly calls the command with the arguments
|
12
|
+
given, without passing it through a shell or performing any interpolation.
|
13
|
+
To use shell built-ins --- that is, to emulate the `shell` provider on
|
14
|
+
Windows --- a command must explicitly invoke the shell:
|
15
|
+
|
16
|
+
exec {'echo foo':
|
17
|
+
command => 'cmd.exe /c echo "foo"',
|
18
|
+
}
|
19
|
+
|
20
|
+
If no extension is specified for a command, Windows will use the `PATHEXT`
|
21
|
+
environment variable to locate the executable.
|
22
|
+
|
23
|
+
**Note on PowerShell scripts:** PowerShell's default `restricted`
|
24
|
+
execution policy doesn't allow it to run saved scripts. To run PowerShell
|
25
|
+
scripts, specify the `remotesigned` execution policy as part of the
|
26
|
+
command:
|
27
|
+
|
28
|
+
exec { 'test':
|
29
|
+
path => 'C:/Windows/System32/WindowsPowerShell/v1.0',
|
30
|
+
command => 'powershell -executionpolicy remotesigned -file C:/test.ps1',
|
31
|
+
}
|
32
|
+
|
33
|
+
EOT
|
12
34
|
|
13
35
|
# Verify that we have the executable
|
14
36
|
def checkexe(command)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'puppet/util/adsi'
|
2
2
|
|
3
3
|
Puppet::Type.type(:group).provide :windows_adsi do
|
4
|
-
desc "
|
4
|
+
desc "Local group management for Windows. Nested groups are not supported."
|
5
5
|
|
6
6
|
defaultfor :operatingsystem => :windows
|
7
7
|
confine :operatingsystem => :windows
|
@@ -30,7 +30,7 @@ Puppet::Type.type(:package).provide :aix, :parent => Puppet::Provider::Package d
|
|
30
30
|
|
31
31
|
updates = {}
|
32
32
|
sources.each do |source|
|
33
|
-
execute(self.srclistcmd(source)).
|
33
|
+
execute(self.srclistcmd(source)).each_line do |line|
|
34
34
|
if line =~ /^[^#][^:]*:([^:]*):([^:]*)/
|
35
35
|
current = {}
|
36
36
|
current[:name] = $1
|
@@ -58,7 +58,7 @@ Puppet::Type.type(:package).provide(:appdmg, :parent => Puppet::Provider::Packag
|
|
58
58
|
if %r{\A[A-Za-z][A-Za-z0-9+\-\.]*://} =~ cached_source
|
59
59
|
cached_source = "/tmp/#{name}"
|
60
60
|
begin
|
61
|
-
curl "-o", cached_source, "-C", "-", "-k", "-s", "--url", source
|
61
|
+
curl "-o", cached_source, "-C", "-", "-k", "-L", "-s", "--url", source
|
62
62
|
Puppet.debug "Success: curl transfered [#{name}]"
|
63
63
|
rescue Puppet::ExecutionFailure
|
64
64
|
Puppet.debug "curl did not transfer [#{name}]. Falling back to slower open-uri transfer methods."
|
@@ -24,7 +24,7 @@ Puppet::Type.type(:package).provide :dpkg, :parent => Puppet::Provider::Package
|
|
24
24
|
hash = {}
|
25
25
|
|
26
26
|
# now turn each returned line into a package object
|
27
|
-
process.
|
27
|
+
process.each_line { |line|
|
28
28
|
if hash = parse_line(line)
|
29
29
|
packages << new(hash)
|
30
30
|
end
|
@@ -12,33 +12,26 @@ Puppet::Type.type(:package).provide :gem, :parent => Puppet::Provider::Package d
|
|
12
12
|
|
13
13
|
commands :gemcmd => "gem"
|
14
14
|
|
15
|
-
def self.gemlist(
|
16
|
-
|
15
|
+
def self.gemlist(options)
|
16
|
+
gem_list_command = [command(:gemcmd), "list"]
|
17
17
|
|
18
|
-
if
|
19
|
-
|
18
|
+
if options[:local]
|
19
|
+
gem_list_command << "--local"
|
20
20
|
else
|
21
|
-
|
21
|
+
gem_list_command << "--remote"
|
22
22
|
end
|
23
23
|
|
24
|
-
if name =
|
25
|
-
|
24
|
+
if name = options[:justme]
|
25
|
+
gem_list_command << name + "$"
|
26
26
|
end
|
27
27
|
|
28
28
|
begin
|
29
|
-
list = execute(
|
30
|
-
if gemhash = gemsplit(set)
|
31
|
-
gemhash[:provider] = :gem
|
32
|
-
gemhash
|
33
|
-
else
|
34
|
-
nil
|
35
|
-
end
|
36
|
-
end.compact
|
29
|
+
list = execute(gem_list_command).lines.map {|set| gemsplit(set) }
|
37
30
|
rescue Puppet::ExecutionFailure => detail
|
38
31
|
raise Puppet::Error, "Could not list gems: #{detail}"
|
39
32
|
end
|
40
33
|
|
41
|
-
if
|
34
|
+
if options[:justme]
|
42
35
|
return list.shift
|
43
36
|
else
|
44
37
|
return list
|
@@ -46,14 +39,19 @@ Puppet::Type.type(:package).provide :gem, :parent => Puppet::Provider::Package d
|
|
46
39
|
end
|
47
40
|
|
48
41
|
def self.gemsplit(desc)
|
49
|
-
|
50
|
-
|
51
|
-
when
|
42
|
+
# `gem list` when output console has a line like:
|
43
|
+
# *** LOCAL GEMS ***
|
44
|
+
# but when it's not to the console that line
|
45
|
+
# and all blank lines are stripped
|
46
|
+
# so we don't need to check for them
|
47
|
+
|
48
|
+
if desc =~ /^(\S+)\s+\((.+)\)/
|
52
49
|
name = $1
|
53
|
-
|
54
|
-
|
55
|
-
:name
|
56
|
-
:ensure
|
50
|
+
versions = $2.split(/,\s*/)
|
51
|
+
{
|
52
|
+
:name => name,
|
53
|
+
:ensure => versions,
|
54
|
+
:provider => :gem
|
57
55
|
}
|
58
56
|
else
|
59
57
|
Puppet.warning "Could not match #{desc}"
|
@@ -46,7 +46,7 @@ Puppet::Type.type(:package).provide :macports, :parent => Puppet::Provider::Pack
|
|
46
46
|
|
47
47
|
def self.instances
|
48
48
|
packages = []
|
49
|
-
port("-q", :installed).
|
49
|
+
port("-q", :installed).each_line do |line|
|
50
50
|
if hash = parse_installed_query_line(line)
|
51
51
|
packages << new(hash)
|
52
52
|
end
|
@@ -1,7 +1,13 @@
|
|
1
1
|
require 'puppet/provider/package'
|
2
2
|
|
3
3
|
Puppet::Type.type(:package).provide(:msi, :parent => Puppet::Provider::Package) do
|
4
|
-
desc "
|
4
|
+
desc "Windows package management by installing and removing MSIs.
|
5
|
+
|
6
|
+
This provider requires a `source` attribute, and will accept paths to local
|
7
|
+
files or files on mapped drives.
|
8
|
+
|
9
|
+
This provider cannot uninstall arbitrary MSI packages; it can only uninstall
|
10
|
+
packages which were originally installed by Puppet."
|
5
11
|
|
6
12
|
confine :operatingsystem => :windows
|
7
13
|
defaultfor :operatingsystem => :windows
|
@@ -22,7 +22,7 @@ Puppet::Type.type(:package).provide :openbsd, :parent => Puppet::Provider::Packa
|
|
22
22
|
hash = {}
|
23
23
|
|
24
24
|
# now turn each returned line into a package object
|
25
|
-
process.
|
25
|
+
process.each_line { |line|
|
26
26
|
if match = regex.match(line.split[0])
|
27
27
|
fields.zip(match.captures) { |field,value|
|
28
28
|
hash[field] = value
|
@@ -49,7 +49,7 @@ Puppet::Type.type(:package).provide :openbsd, :parent => Puppet::Provider::Packa
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def self.listcmd
|
52
|
-
[command(:pkginfo), "
|
52
|
+
[command(:pkginfo), "-a"]
|
53
53
|
end
|
54
54
|
|
55
55
|
def install
|
@@ -57,28 +57,29 @@ Puppet::Type.type(:package).provide :openbsd, :parent => Puppet::Provider::Packa
|
|
57
57
|
|
58
58
|
unless @resource[:source]
|
59
59
|
raise Puppet::Error,
|
60
|
-
|
60
|
+
"You must specify a package source for BSD packages"
|
61
61
|
end
|
62
62
|
|
63
|
-
if @resource[:source][-1,1] == ::File::
|
64
|
-
e_vars = {
|
65
|
-
full_name = [ @resource[:name], get_version || @resource[:ensure], @resource[:flavor] ].join('-').chomp('-')
|
63
|
+
if @resource[:source][-1,1] == ::File::SEPARATOR
|
64
|
+
e_vars = { 'PKG_PATH' => @resource[:source] }
|
65
|
+
full_name = [ @resource[:name], get_version || @resource[:ensure], @resource[:flavor] ].join('-').chomp('-').chomp('-')
|
66
66
|
else
|
67
67
|
e_vars = {}
|
68
68
|
full_name = @resource[:source]
|
69
69
|
end
|
70
70
|
|
71
|
-
|
71
|
+
Puppet::Util::Execution::withenv(e_vars) { pkgadd full_name }
|
72
72
|
end
|
73
73
|
|
74
74
|
def get_version
|
75
|
-
execpipe([command(:pkginfo), "
|
75
|
+
execpipe([command(:pkginfo), "-I", @resource[:name]]) do |process|
|
76
76
|
# our regex for matching pkg_info output
|
77
77
|
regex = /^(.*)-(\d[^-]*)[-]?(\D*)(.*)$/
|
78
78
|
fields = [ :name, :version, :flavor ]
|
79
79
|
master_version = 0
|
80
|
+
version = -1
|
80
81
|
|
81
|
-
process.
|
82
|
+
process.each_line do |line|
|
82
83
|
if match = regex.match(line.split[0])
|
83
84
|
# now we return the first version, unless ensure is latest
|
84
85
|
version = match.captures[1]
|
@@ -89,6 +90,7 @@ Puppet::Type.type(:package).provide :openbsd, :parent => Puppet::Provider::Packa
|
|
89
90
|
end
|
90
91
|
|
91
92
|
return master_version unless master_version == 0
|
93
|
+
return '' if version == -1
|
92
94
|
raise Puppet::Error, "#{version} is not available for this package"
|
93
95
|
end
|
94
96
|
rescue Puppet::ExecutionFailure
|
@@ -96,17 +98,12 @@ Puppet::Type.type(:package).provide :openbsd, :parent => Puppet::Provider::Packa
|
|
96
98
|
end
|
97
99
|
|
98
100
|
def query
|
99
|
-
hash = {}
|
100
|
-
info = pkginfo @resource[:name]
|
101
|
-
|
102
101
|
# Search for the version info
|
103
|
-
if
|
104
|
-
|
102
|
+
if pkginfo(@resource[:name]) =~ /Information for (inst:)?#{@resource[:name]}-(\S+)/
|
103
|
+
return { :ensure => $2 }
|
105
104
|
else
|
106
105
|
return nil
|
107
106
|
end
|
108
|
-
|
109
|
-
hash
|
110
107
|
end
|
111
108
|
|
112
109
|
def uninstall
|
@@ -50,8 +50,11 @@ Puppet::Type.type(:package).provide :pip,
|
|
50
50
|
def latest
|
51
51
|
client = XMLRPC::Client.new2("http://pypi.python.org/pypi")
|
52
52
|
client.http_header_extra = {"Content-Type" => "text/xml"}
|
53
|
+
client.timeout = 10
|
53
54
|
result = client.call("package_releases", @resource[:name])
|
54
55
|
result.first
|
56
|
+
rescue Timeout::Error => detail
|
57
|
+
raise Puppet::Error, "Timeout while contacting pypi.python.org: #{detail}";
|
55
58
|
end
|
56
59
|
|
57
60
|
# Install a package. The ensure parameter may specify installed,
|