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
@@ -0,0 +1,98 @@
|
|
1
|
+
module Puppet::Util::Colors
|
2
|
+
BLACK = {:console => "\e[0;30m", :html => "color: #FFA0A0" }
|
3
|
+
RED = {:console => "\e[0;31m", :html => "color: #FFA0A0" }
|
4
|
+
GREEN = {:console => "\e[0;32m", :html => "color: #00CD00" }
|
5
|
+
YELLOW = {:console => "\e[0;33m", :html => "color: #FFFF60" }
|
6
|
+
BLUE = {:console => "\e[0;34m", :html => "color: #80A0FF" }
|
7
|
+
PURPLE = {:console => "\e[0;35m", :html => "color: #FFA500" }
|
8
|
+
CYAN = {:console => "\e[0;36m", :html => "color: #40FFFF" }
|
9
|
+
WHITE = {:console => "\e[0;37m", :html => "color: #FFFFFF" }
|
10
|
+
HBLACK = {:console => "\e[1;30m", :html => "color: #FFA0A0" }
|
11
|
+
HRED = {:console => "\e[1;31m", :html => "color: #FFA0A0" }
|
12
|
+
HGREEN = {:console => "\e[1;32m", :html => "color: #00CD00" }
|
13
|
+
HYELLOW = {:console => "\e[1;33m", :html => "color: #FFFF60" }
|
14
|
+
HBLUE = {:console => "\e[1;34m", :html => "color: #80A0FF" }
|
15
|
+
HPURPLE = {:console => "\e[1;35m", :html => "color: #FFA500" }
|
16
|
+
HCYAN = {:console => "\e[1;36m", :html => "color: #40FFFF" }
|
17
|
+
HWHITE = {:console => "\e[1;37m", :html => "color: #FFFFFF" }
|
18
|
+
BG_RED = {:console => "\e[0;41m", :html => "background: #FFA0A0"}
|
19
|
+
BG_GREEN = {:console => "\e[0;42m", :html => "background: #00CD00"}
|
20
|
+
BG_YELLOW = {:console => "\e[0;43m", :html => "background: #FFFF60"}
|
21
|
+
BG_BLUE = {:console => "\e[0;44m", :html => "background: #80A0FF"}
|
22
|
+
BG_PURPLE = {:console => "\e[0;45m", :html => "background: #FFA500"}
|
23
|
+
BG_CYAN = {:console => "\e[0;46m", :html => "background: #40FFFF"}
|
24
|
+
BG_WHITE = {:console => "\e[0;47m", :html => "background: #FFFFFF"}
|
25
|
+
BG_HRED = {:console => "\e[1;41m", :html => "background: #FFA0A0"}
|
26
|
+
BG_HGREEN = {:console => "\e[1;42m", :html => "background: #00CD00"}
|
27
|
+
BG_HYELLOW = {:console => "\e[1;43m", :html => "background: #FFFF60"}
|
28
|
+
BG_HBLUE = {:console => "\e[1;44m", :html => "background: #80A0FF"}
|
29
|
+
BG_HPURPLE = {:console => "\e[1;45m", :html => "background: #FFA500"}
|
30
|
+
BG_HCYAN = {:console => "\e[1;46m", :html => "background: #40FFFF"}
|
31
|
+
BG_HWHITE = {:console => "\e[1;47m", :html => "background: #FFFFFF"}
|
32
|
+
RESET = {:console => "\e[0m", :html => "" }
|
33
|
+
|
34
|
+
Colormap = {
|
35
|
+
:debug => WHITE,
|
36
|
+
:info => GREEN,
|
37
|
+
:notice => CYAN,
|
38
|
+
:warning => YELLOW,
|
39
|
+
:err => HPURPLE,
|
40
|
+
:alert => RED,
|
41
|
+
:emerg => HRED,
|
42
|
+
:crit => HRED,
|
43
|
+
|
44
|
+
:black => BLACK,
|
45
|
+
:red => RED,
|
46
|
+
:green => GREEN,
|
47
|
+
:yellow => YELLOW,
|
48
|
+
:blue => BLUE,
|
49
|
+
:purple => PURPLE,
|
50
|
+
:cyan => CYAN,
|
51
|
+
:white => WHITE,
|
52
|
+
:hblack => HBLACK,
|
53
|
+
:hred => HRED,
|
54
|
+
:hgreen => HGREEN,
|
55
|
+
:hyellow => HYELLOW,
|
56
|
+
:hblue => HBLUE,
|
57
|
+
:hpurple => HPURPLE,
|
58
|
+
:hcyan => HCYAN,
|
59
|
+
:hwhite => HWHITE,
|
60
|
+
:bg_red => BG_RED,
|
61
|
+
:bg_green => BG_GREEN,
|
62
|
+
:bg_yellow => BG_YELLOW,
|
63
|
+
:bg_blue => BG_BLUE,
|
64
|
+
:bg_purple => BG_PURPLE,
|
65
|
+
:bg_cyan => BG_CYAN,
|
66
|
+
:bg_white => BG_WHITE,
|
67
|
+
:bg_hred => BG_HRED,
|
68
|
+
:bg_hgreen => BG_HGREEN,
|
69
|
+
:bg_hyellow => BG_HYELLOW,
|
70
|
+
:bg_hblue => BG_HBLUE,
|
71
|
+
:bg_hpurple => BG_HPURPLE,
|
72
|
+
:bg_hcyan => BG_HCYAN,
|
73
|
+
:bg_hwhite => BG_HWHITE,
|
74
|
+
:reset => { :console => "\e[m", :html => "" }
|
75
|
+
}
|
76
|
+
|
77
|
+
def colorize(color, str)
|
78
|
+
case Puppet[:color]
|
79
|
+
when true, :ansi, "ansi", "yes"
|
80
|
+
console_color(color, str)
|
81
|
+
when :html, "html"
|
82
|
+
html_color(color, str)
|
83
|
+
else
|
84
|
+
str
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def console_color(color, str)
|
89
|
+
Colormap[color][:console] +
|
90
|
+
str.gsub(RESET[:console], Colormap[color][:console]) +
|
91
|
+
RESET[:console]
|
92
|
+
end
|
93
|
+
|
94
|
+
def html_color(color, str)
|
95
|
+
span = '<span style="%s">' % Colormap[color][:html]
|
96
|
+
"#{span}%s</span>" % str.gsub(/<span .*?<\/span>/, "</span>\\0#{span}")
|
97
|
+
end
|
98
|
+
end
|
data/lib/puppet/util/diff.rb
CHANGED
data/lib/puppet/util/log.rb
CHANGED
@@ -189,12 +189,16 @@ class Puppet::Util::Log
|
|
189
189
|
}
|
190
190
|
rescue => detail
|
191
191
|
if @destinations.empty?
|
192
|
-
Log.
|
192
|
+
Log.setup_default
|
193
193
|
Puppet.err detail.to_s
|
194
194
|
end
|
195
195
|
end
|
196
196
|
end
|
197
197
|
|
198
|
+
def self.setup_default
|
199
|
+
Log.newdestination(Puppet.features.syslog? ? :syslog : Puppet[:puppetdlog])
|
200
|
+
end
|
201
|
+
|
198
202
|
# Is the passed level a valid log level?
|
199
203
|
def self.validlevel?(level)
|
200
204
|
@levels.include?(level)
|
@@ -41,6 +41,8 @@ Puppet::Util::Log.newdesttype :syslog do
|
|
41
41
|
end
|
42
42
|
|
43
43
|
Puppet::Util::Log.newdesttype :file do
|
44
|
+
require 'fileutils'
|
45
|
+
|
44
46
|
def self.match?(obj)
|
45
47
|
Puppet::Util.absolute_path?(obj)
|
46
48
|
end
|
@@ -64,7 +66,7 @@ Puppet::Util::Log.newdesttype :file do
|
|
64
66
|
# We can't just use 'Config.use' here, because they've
|
65
67
|
# specified a "special" destination.
|
66
68
|
unless FileTest.exist?(File.dirname(path))
|
67
|
-
|
69
|
+
FileUtils.mkdir_p(File.dirname(path), :mode => 0755)
|
68
70
|
Puppet.info "Creating log directory #{File.dirname(path)}"
|
69
71
|
end
|
70
72
|
|
@@ -84,62 +86,53 @@ Puppet::Util::Log.newdesttype :file do
|
|
84
86
|
end
|
85
87
|
|
86
88
|
Puppet::Util::Log.newdesttype :console do
|
89
|
+
require 'puppet/util/colors'
|
90
|
+
include Puppet::Util::Colors
|
87
91
|
|
92
|
+
def initialize
|
93
|
+
# Flush output immediately.
|
94
|
+
$stdout.sync = true
|
95
|
+
end
|
88
96
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
BLUE = {:console => "[0;34m", :html => "80A0FF"}
|
93
|
-
PURPLE = {:console => "[0;35m", :html => "FFA500"}
|
94
|
-
CYAN = {:console => "[0;36m", :html => "40FFFF"}
|
95
|
-
WHITE = {:console => "[0;37m", :html => "FFFFFF"}
|
96
|
-
HRED = {:console => "[1;31m", :html => "FFA0A0"}
|
97
|
-
HGREEN = {:console => "[1;32m", :html => "00CD00"}
|
98
|
-
HYELLOW = {:console => "[1;33m", :html => "FFFF60"}
|
99
|
-
HBLUE = {:console => "[1;34m", :html => "80A0FF"}
|
100
|
-
HPURPLE = {:console => "[1;35m", :html => "FFA500"}
|
101
|
-
HCYAN = {:console => "[1;36m", :html => "40FFFF"}
|
102
|
-
HWHITE = {:console => "[1;37m", :html => "FFFFFF"}
|
103
|
-
RESET = {:console => "[0m", :html => "" }
|
104
|
-
|
105
|
-
Colormap = {
|
106
|
-
:debug => WHITE,
|
107
|
-
:info => GREEN,
|
108
|
-
:notice => CYAN,
|
109
|
-
:warning => YELLOW,
|
110
|
-
:err => HPURPLE,
|
111
|
-
:alert => RED,
|
112
|
-
:emerg => HRED,
|
113
|
-
:crit => HRED
|
114
|
-
}
|
115
|
-
|
116
|
-
def colorize(level, str)
|
117
|
-
case Puppet[:color]
|
118
|
-
when true, :ansi, "ansi", "yes"; console_color(level, str)
|
119
|
-
when :html, "html"; html_color(level, str)
|
97
|
+
def handle(msg)
|
98
|
+
if msg.source == "Puppet"
|
99
|
+
puts colorize(msg.level, "#{msg.level}: #{msg}")
|
120
100
|
else
|
121
|
-
|
101
|
+
puts colorize(msg.level, "#{msg.level}: #{msg.source}: #{msg}")
|
122
102
|
end
|
123
103
|
end
|
104
|
+
end
|
124
105
|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
def html_color(level, str)
|
130
|
-
%{<span style="color: %s">%s</span>} % [Colormap[level][:html], str]
|
131
|
-
end
|
106
|
+
Puppet::Util::Log.newdesttype :telly_prototype_console do
|
107
|
+
require 'puppet/util/colors'
|
108
|
+
include Puppet::Util::Colors
|
132
109
|
|
133
110
|
def initialize
|
134
111
|
# Flush output immediately.
|
112
|
+
$stderr.sync = true
|
135
113
|
$stdout.sync = true
|
136
114
|
end
|
137
115
|
|
138
116
|
def handle(msg)
|
139
|
-
|
140
|
-
|
117
|
+
error_levels = {
|
118
|
+
:warning => 'Warning',
|
119
|
+
:err => 'Error',
|
120
|
+
:alert => 'Alert',
|
121
|
+
:emerg => 'Emergency',
|
122
|
+
:crit => 'Critical'
|
123
|
+
}
|
124
|
+
|
125
|
+
str = msg.respond_to?(:multiline) ? msg.multiline : msg.to_s
|
126
|
+
|
127
|
+
case msg.level
|
128
|
+
when *error_levels.keys
|
129
|
+
$stderr.puts colorize(:hred, "#{error_levels[msg.level]}: #{str}")
|
130
|
+
when :info
|
131
|
+
$stdout.puts "#{colorize(:green, 'Info')}: #{str}"
|
132
|
+
when :debug
|
133
|
+
$stdout.puts "#{colorize(:cyan, 'Debug')}: #{str}"
|
141
134
|
else
|
142
|
-
puts
|
135
|
+
$stdout.puts str
|
143
136
|
end
|
144
137
|
end
|
145
138
|
end
|
@@ -167,7 +160,7 @@ Puppet::Util::Log.newdesttype :host do
|
|
167
160
|
@domain = Facter["domain"].value
|
168
161
|
@hostname += ".#{@domain}" if @domain
|
169
162
|
end
|
170
|
-
if msg.source
|
163
|
+
if Puppet::Util.absolute_path?(msg.source)
|
171
164
|
msg.source = @hostname + ":#{msg.source}"
|
172
165
|
elsif msg.source == "Puppet"
|
173
166
|
msg.source = @hostname + " #{msg.source}"
|
@@ -129,6 +129,38 @@ class IO
|
|
129
129
|
block_given? and lines.each {|line| yield line }
|
130
130
|
lines
|
131
131
|
end
|
132
|
+
|
133
|
+
def self.binread(name, length = nil, offset = 0)
|
134
|
+
File.open(name, 'rb') do |f|
|
135
|
+
f.seek(offset) if offset > 0
|
136
|
+
f.read(length)
|
137
|
+
end
|
138
|
+
end unless singleton_methods.include?(:binread)
|
139
|
+
|
140
|
+
def self.binwrite(name, string, offset = 0)
|
141
|
+
File.open(name, 'wb') do |f|
|
142
|
+
f.write(offset > 0 ? string[offset..-1] : string)
|
143
|
+
end
|
144
|
+
end unless singleton_methods.include?(:binwrite)
|
145
|
+
|
146
|
+
end
|
147
|
+
|
148
|
+
class Range
|
149
|
+
def intersection(other)
|
150
|
+
raise ArgumentError, 'value must be a Range' unless other.kind_of?(Range)
|
151
|
+
return unless other === self.first || self === other.first
|
152
|
+
|
153
|
+
start = [self.first, other.first].max
|
154
|
+
if self.exclude_end? && self.last <= other.last
|
155
|
+
start ... self.last
|
156
|
+
elsif other.exclude_end? && self.last >= other.last
|
157
|
+
start ... other.last
|
158
|
+
else
|
159
|
+
start .. [ self.last, other.last ].min
|
160
|
+
end
|
161
|
+
end unless method_defined? :intersection
|
162
|
+
|
163
|
+
alias_method :&, :intersection unless method_defined? :&
|
132
164
|
end
|
133
165
|
|
134
166
|
# Ruby 1.8.5 doesn't have tap
|
data/lib/puppet/util/pidlock.rb
CHANGED
@@ -1,10 +1,20 @@
|
|
1
1
|
require 'fileutils'
|
2
|
-
require 'puppet/util/anonymous_filelock'
|
3
2
|
|
4
|
-
class Puppet::Util::Pidlock
|
3
|
+
class Puppet::Util::Pidlock
|
4
|
+
attr_reader :lockfile
|
5
|
+
|
6
|
+
def initialize(lockfile)
|
7
|
+
@lockfile = lockfile
|
8
|
+
end
|
5
9
|
|
6
10
|
def locked?
|
7
11
|
clear_if_stale
|
12
|
+
return true if File.exists? @lockfile
|
13
|
+
|
14
|
+
# HACK! There was a temporary change to the lockfile behavior introduced in 2.7.10 and 2.7.11, and reverted
|
15
|
+
# in 2.7.12. We need to pull some chicanery to be backwards-compatible with those versions. For more info,
|
16
|
+
# see the comments on the method... and this hack should be removed for the 3.x series.
|
17
|
+
handle_2_7_10_disabled_lockfile
|
8
18
|
File.exists? @lockfile
|
9
19
|
end
|
10
20
|
|
@@ -13,36 +23,39 @@ class Puppet::Util::Pidlock < Puppet::Util::AnonymousFilelock
|
|
13
23
|
end
|
14
24
|
|
15
25
|
def anonymous?
|
16
|
-
false
|
26
|
+
return false unless File.exists?(@lockfile)
|
27
|
+
File.read(@lockfile) == ""
|
17
28
|
end
|
18
29
|
|
19
|
-
def lock
|
20
|
-
|
30
|
+
def lock(opts = {})
|
31
|
+
opts = {:anonymous => false}.merge(opts)
|
21
32
|
|
22
|
-
|
23
|
-
|
33
|
+
if locked?
|
34
|
+
mine?
|
35
|
+
else
|
36
|
+
if opts[:anonymous]
|
37
|
+
File.open(@lockfile, 'w') { |fd| true }
|
38
|
+
else
|
39
|
+
File.open(@lockfile, "w") { |fd| fd.write(Process.pid) }
|
40
|
+
end
|
41
|
+
true
|
42
|
+
end
|
24
43
|
end
|
25
44
|
|
26
45
|
def unlock(opts = {})
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
rescue SystemCallError => e
|
34
|
-
# This one is a real failure though. No idea what went wrong, but it
|
35
|
-
# is most likely "read only file(system)" or wrong permissions or
|
36
|
-
# something like that.
|
37
|
-
Puppet.err "Could not remove PID file #{@lockfile}: #{e}"
|
38
|
-
puts e.backtrace if Puppet[:trace]
|
39
|
-
end
|
46
|
+
return false unless locked?
|
47
|
+
|
48
|
+
opts = {:anonymous => false}.merge(opts)
|
49
|
+
|
50
|
+
if mine? or (opts[:anonymous] and anonymous?)
|
51
|
+
File.unlink(@lockfile)
|
40
52
|
true
|
41
53
|
else
|
42
54
|
false
|
43
55
|
end
|
44
56
|
end
|
45
57
|
|
58
|
+
private
|
46
59
|
def lock_pid
|
47
60
|
if File.exists? @lockfile
|
48
61
|
File.read(@lockfile).to_i
|
@@ -51,7 +64,6 @@ class Puppet::Util::Pidlock < Puppet::Util::AnonymousFilelock
|
|
51
64
|
end
|
52
65
|
end
|
53
66
|
|
54
|
-
private
|
55
67
|
def clear_if_stale
|
56
68
|
return if lock_pid.nil?
|
57
69
|
|
@@ -65,4 +77,41 @@ class Puppet::Util::Pidlock < Puppet::Util::AnonymousFilelock
|
|
65
77
|
File.unlink(@lockfile)
|
66
78
|
end
|
67
79
|
end
|
80
|
+
|
81
|
+
|
82
|
+
######################################################################################
|
83
|
+
# Backwards compatibility hack
|
84
|
+
######################################################################################
|
85
|
+
# A change to lockfile behavior was introduced in 2.7.10 and 2.7.11; basically,
|
86
|
+
# instead of using a single lockfile to indicate both administrative disabling of
|
87
|
+
# the agent *and* the case where an agent run is already in progress, we started using
|
88
|
+
# two separate lockfiles: the 'normal' one for the "run in progress" case, and a
|
89
|
+
# separate one with a ".disabled" extension to indicate administrative disabling.
|
90
|
+
#
|
91
|
+
# This was determined to cause incompatibilities with mcollective, so the behavior
|
92
|
+
# was reverted for 2.7.12. Unfortunately this leaves the possibility that someone
|
93
|
+
# may have run "agent --disable" to administratively disable a 2.7.10 or 2.7.11
|
94
|
+
# agent, and then upgraded to a newer version. This method exists only to
|
95
|
+
# provide backwards compatibility. Basically, it just recognizes the 2.7.10/2.7.11
|
96
|
+
# ".disabled" lock file, warns, and cleans it up.
|
97
|
+
#
|
98
|
+
# This should be removed for the 3.x series.
|
99
|
+
#
|
100
|
+
# For more information, please see tickets #12844, #3757, #4836, and #11057
|
101
|
+
#
|
102
|
+
# -- cprice 2012-03-01
|
103
|
+
#
|
104
|
+
def handle_2_7_10_disabled_lockfile
|
105
|
+
disabled_lockfile_path = @lockfile + ".disabled"
|
106
|
+
if (File.exists?(disabled_lockfile_path))
|
107
|
+
Puppet.warning("Found special lockfile '#{disabled_lockfile_path}'; this file was " +
|
108
|
+
"generated by a call to 'puppet agent --disable' in puppet 2.7.10 or 2.7.11. " +
|
109
|
+
"The expected lockfile path is '#{@lockfile}'; renaming the lock file.")
|
110
|
+
File.rename(disabled_lockfile_path, @lockfile)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
private :handle_2_7_10_disabled_lockfile
|
114
|
+
######################################################################################
|
115
|
+
# End backwards compatibility hack
|
116
|
+
######################################################################################
|
68
117
|
end
|
@@ -129,8 +129,10 @@ class Parser
|
|
129
129
|
def scan_top_level(container)
|
130
130
|
# use the module README as documentation for the module
|
131
131
|
comment = ""
|
132
|
-
|
133
|
-
|
132
|
+
%w{README README.rdoc}.each do |rfile|
|
133
|
+
readme = File.join(File.dirname(File.dirname(@input_file_name)), rfile)
|
134
|
+
comment = File.open(readme,"r") { |f| f.read } if FileTest.readable?(readme)
|
135
|
+
end
|
134
136
|
look_for_directives_in(container, comment) unless comment.empty?
|
135
137
|
|
136
138
|
# infer module name from directory
|
data/lib/puppet/util/selinux.rb
CHANGED
@@ -163,7 +163,7 @@ module Puppet::Util::SELinux
|
|
163
163
|
# Read all entries in /proc/mounts. The second column is the
|
164
164
|
# mountpoint and the third column is the filesystem type.
|
165
165
|
# We skip rootfs because it is always mounted at /
|
166
|
-
mounts.
|
166
|
+
mounts.each_line do |line|
|
167
167
|
params = line.split(' ')
|
168
168
|
next if params[2] == 'rootfs'
|
169
169
|
mntpoint[params[1]] = params[2]
|
@@ -56,18 +56,8 @@ module Puppet::Util::SUIDManager
|
|
56
56
|
def self.root?
|
57
57
|
return Process.uid == 0 unless Puppet.features.microsoft_windows?
|
58
58
|
|
59
|
-
require '
|
60
|
-
|
61
|
-
require 'facter'
|
62
|
-
|
63
|
-
majversion = Facter.value(:kernelmajversion)
|
64
|
-
return false unless majversion
|
65
|
-
|
66
|
-
# if Vista or later, check for unrestricted process token
|
67
|
-
return Win32::Security.elevated_security? unless majversion.to_f < 6.0
|
68
|
-
|
69
|
-
group = Sys::Admin.get_group("Administrators", :sid => Win32::Security::SID::BuiltinAdministrators)
|
70
|
-
group and group.members.index(Sys::Admin.get_login) != nil
|
59
|
+
require 'puppet/util/windows/user'
|
60
|
+
Puppet::Util::Windows::User.admin?
|
71
61
|
end
|
72
62
|
|
73
63
|
# Methods to handle changing uid/gid of the running process. In general,
|