puppet 0.25.1 → 0.25.2
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 +159 -135
- data/Rakefile +4 -1
- data/conf/gentoo/conf.d/puppetmaster +1 -1
- data/conf/osx/createpackage.sh +12 -0
- data/conf/osx/preflight +4 -0
- data/conf/redhat/puppet.spec +12 -2
- data/conf/redhat/server.init +1 -0
- data/conf/redhat/server.sysconfig +1 -1
- data/ext/ldap/puppet.schema +5 -9
- data/ext/puppetlast +2 -1
- data/ext/rack/README +2 -2
- data/ext/regexp_nodes/classes/databases +2 -0
- data/ext/regexp_nodes/classes/webservers +2 -0
- data/ext/regexp_nodes/parameters/environment/prod +1 -0
- data/ext/regexp_nodes/parameters/environment/qa +3 -0
- data/ext/regexp_nodes/regexp_nodes.rb +215 -0
- data/lib/puppet.rb +1 -1
- data/lib/puppet/agent.rb +2 -2
- data/lib/puppet/application/puppet.rb +1 -1
- data/lib/puppet/application/puppetd.rb +1 -1
- data/lib/puppet/application/puppetdoc.rb +4 -3
- data/lib/puppet/application/puppetrun.rb +5 -14
- data/lib/puppet/application/ralsh.rb +9 -25
- data/lib/puppet/configurer.rb +2 -1
- data/lib/puppet/configurer/fact_handler.rb +8 -6
- data/lib/puppet/daemon.rb +2 -2
- data/lib/puppet/defaults.rb +21 -2
- data/lib/puppet/external/pson/common.rb +1 -1
- data/lib/puppet/external/pson/pure.rb +3 -3
- data/lib/puppet/feature/base.rb +3 -0
- data/lib/puppet/feature/selinux.rb +3 -0
- data/lib/puppet/feature/zlib.rb +6 -0
- data/lib/puppet/file_serving/base.rb +16 -1
- data/lib/puppet/file_serving/metadata.rb +46 -9
- data/lib/puppet/file_serving/mount/file.rb +4 -1
- data/lib/puppet/indirector/catalog/active_record.rb +5 -0
- data/lib/puppet/indirector/envelope.rb +1 -3
- data/lib/puppet/indirector/indirection.rb +13 -16
- data/lib/puppet/indirector/node/ldap.rb +7 -4
- data/lib/puppet/indirector/ssl_file.rb +1 -1
- data/lib/puppet/network/authstore.rb +48 -118
- data/lib/puppet/network/client/resource.rb +2 -15
- data/lib/puppet/network/format.rb +2 -12
- data/lib/puppet/network/format_handler.rb +15 -1
- data/lib/puppet/network/formats.rb +19 -4
- data/lib/puppet/network/handler/fileserver.rb +1 -0
- data/lib/puppet/network/http/handler.rb +1 -0
- data/lib/puppet/network/http/rack/httphandler.rb +0 -18
- data/lib/puppet/network/http/rack/rest.rb +4 -4
- data/lib/puppet/network/http/rack/xmlrpc.rb +4 -4
- data/lib/puppet/network/http/webrick.rb +2 -1
- data/lib/puppet/network/server.rb +1 -1
- data/lib/puppet/node/environment.rb +20 -9
- data/lib/puppet/parameter.rb +17 -1
- data/lib/puppet/parser/ast/boolean_operator.rb +2 -2
- data/lib/puppet/parser/ast/leaf.rb +5 -1
- data/lib/puppet/parser/ast/resourceparam.rb +4 -0
- data/lib/puppet/parser/ast/selector.rb +4 -0
- data/lib/puppet/parser/functions/generate.rb +2 -2
- data/lib/puppet/parser/functions/shellquote.rb +1 -1
- data/lib/puppet/property.rb +3 -11
- data/lib/puppet/provider/cron/crontab.rb +2 -0
- data/lib/puppet/provider/host/parsed.rb +9 -9
- data/lib/puppet/provider/package/blastwave.rb +7 -6
- data/lib/puppet/provider/package/portage.rb +23 -27
- data/lib/puppet/provider/package/rug.rb +1 -1
- data/lib/puppet/provider/package/sun.rb +5 -3
- data/lib/puppet/provider/service/daemontools.rb +1 -1
- data/lib/puppet/provider/service/debian.rb +1 -1
- data/lib/puppet/provider/service/runit.rb +1 -1
- data/lib/puppet/provider/ssh_authorized_key/parsed.rb +2 -1
- data/lib/puppet/provider/sshkey/parsed.rb +3 -5
- data/lib/puppet/provider/zone/solaris.rb +1 -1
- data/lib/puppet/rails.rb +9 -2
- data/lib/puppet/rails/benchmark.rb +1 -1
- data/lib/puppet/rails/host.rb +2 -7
- data/lib/puppet/rails/resource.rb +20 -26
- data/lib/puppet/resource/catalog.rb +3 -3
- data/lib/puppet/resource/reference.rb +13 -25
- data/lib/puppet/ssl/certificate.rb +3 -2
- data/lib/puppet/ssl/host.rb +14 -33
- data/lib/puppet/sslcertificates.rb +1 -5
- data/lib/puppet/sslcertificates/ca.rb +8 -7
- data/lib/puppet/transaction.rb +15 -12
- data/lib/puppet/type.rb +12 -5
- data/lib/puppet/type/file.rb +26 -32
- data/lib/puppet/type/file/content.rb +5 -5
- data/lib/puppet/type/file/ensure.rb +6 -17
- data/lib/puppet/type/file/mode.rb +18 -1
- data/lib/puppet/type/file/source.rb +12 -12
- data/lib/puppet/type/host.rb +6 -9
- data/lib/puppet/type/k5login.rb +1 -1
- data/lib/puppet/type/maillist.rb +4 -7
- data/lib/puppet/type/port.rb +6 -5
- data/lib/puppet/type/resources.rb +12 -12
- data/lib/puppet/type/sshkey.rb +5 -5
- data/lib/puppet/type/tidy.rb +9 -2
- data/lib/puppet/type/yumrepo.rb +3 -1
- data/lib/puppet/util.rb +64 -56
- data/lib/puppet/util/backups.rb +2 -1
- data/lib/puppet/util/filetype.rb +46 -0
- data/lib/puppet/util/log.rb +10 -18
- data/lib/puppet/util/log_paths.rb +14 -0
- data/lib/puppet/util/methodhelper.rb +3 -4
- data/lib/puppet/util/monkey_patches.rb +8 -0
- data/lib/puppet/util/rdoc/generators/puppet_generator.rb +5 -3
- data/lib/puppet/util/rdoc/parser.rb +32 -16
- data/lib/puppet/util/reference.rb +6 -3
- data/lib/puppet/util/selinux.rb +21 -14
- data/lib/puppet/util/settings.rb +30 -25
- data/lib/puppet/util/settings/file_setting.rb +7 -4
- data/lib/puppet/util/subclass_loader.rb +1 -1
- data/lib/puppet/util/suidmanager.rb +11 -1
- data/lib/puppet/util/tagging.rb +22 -4
- data/man/man8/filebucket.8 +23 -18
- data/man/man8/pi.8 +42 -20
- data/man/man8/puppet.8 +47 -32
- data/man/man8/puppet.conf.8 +807 -764
- data/man/man8/puppetca.8 +24 -14
- data/man/man8/puppetd.8 +33 -16
- data/man/man8/puppetdoc.8 +71 -18
- data/man/man8/puppetmasterd.8 +18 -25
- data/man/man8/puppetqd.8 +60 -0
- data/man/man8/puppetrun.8 +27 -14
- data/man/man8/ralsh.8 +33 -40
- data/spec/integration/bin/puppetmasterd.rb +3 -2
- data/spec/integration/defaults.rb +11 -0
- data/spec/integration/file_serving/metadata.rb +1 -0
- data/spec/integration/indirector/file_content/file_server.rb +2 -1
- data/spec/integration/ssl/certificate_request.rb +2 -0
- data/spec/integration/type/file.rb +20 -1
- data/spec/shared_behaviours/file_serving.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/unit/application/puppet.rb +11 -30
- data/spec/unit/application/puppetd.rb +1 -0
- data/spec/unit/application/puppetdoc.rb +13 -4
- data/spec/unit/application/puppetmasterd.rb +1 -0
- data/spec/unit/application/puppetrun.rb +12 -2
- data/spec/unit/application/ralsh.rb +39 -22
- data/spec/unit/configurer.rb +6 -0
- data/spec/unit/configurer/fact_handler.rb +15 -1
- data/spec/unit/file_serving/metadata.rb +128 -16
- data/spec/unit/file_serving/mount/file.rb +8 -0
- data/spec/unit/indirector/catalog/active_record.rb +20 -1
- data/spec/unit/indirector/catalog/compiler.rb +2 -1
- data/spec/unit/indirector/indirection.rb +29 -18
- data/spec/unit/indirector/node/ldap.rb +20 -6
- data/spec/unit/network/authstore.rb +197 -0
- data/spec/unit/network/format_handler.rb +28 -8
- data/spec/unit/network/formats.rb +31 -0
- data/spec/unit/network/http/handler.rb +10 -0
- data/spec/unit/network/http/webrick.rb +2 -2
- data/spec/unit/network/rest_authconfig.rb +2 -2
- data/spec/unit/network/rights.rb +1 -1
- data/spec/unit/node/environment.rb +39 -23
- data/spec/unit/other/selinux.rb +2 -2
- data/spec/unit/parameter.rb +8 -0
- data/spec/unit/parser/ast/leaf.rb +9 -0
- data/spec/unit/parser/ast/selector.rb +8 -1
- data/spec/unit/parser/lexer.rb +1 -1
- data/spec/unit/parser/resource.rb +11 -0
- data/spec/unit/parser/resource/reference.rb +13 -1
- data/spec/unit/property.rb +6 -0
- data/spec/unit/provider/mount/parsed.rb +3 -1
- data/spec/unit/provider/service/debian.rb +1 -1
- data/spec/unit/provider/ssh_authorized_key/parsed.rb +9 -1
- data/spec/unit/provider/sshkey/parsed.rb +19 -0
- data/spec/unit/rails.rb +22 -9
- data/spec/unit/rails/resource.rb +20 -0
- data/spec/unit/ssl/host.rb +19 -57
- data/spec/unit/transaction.rb +39 -4
- data/spec/unit/type.rb +9 -0
- data/spec/unit/type/file/content.rb +29 -0
- data/spec/unit/type/maillist.rb +42 -0
- data/spec/unit/type/resources.rb +66 -1
- data/spec/unit/type/tidy.rb +14 -1
- data/spec/unit/util/autoload.rb +2 -0
- data/spec/unit/util/ldap/connection.rb +1 -1
- data/spec/unit/util/log.rb +14 -0
- data/spec/unit/util/monkey_patches.rb +103 -0
- data/spec/unit/util/queue.rb +10 -2
- data/spec/unit/util/selinux.rb +61 -2
- data/spec/unit/util/settings.rb +19 -0
- data/spec/unit/util/settings/file_setting.rb +25 -0
- data/spec/unit/util/tagging.rb +10 -0
- data/tasks/rake/changelog.rake +15 -0
- data/tasks/rake/ci.rake +22 -0
- data/tasks/rake/dailybuild.rake +9 -0
- data/tasks/rake/gem.rake +46 -0
- data/tasks/rake/git_workflow.rake +121 -0
- data/tasks/rake/metrics.rake +6 -0
- data/tasks/rake/sign.rake +14 -0
- data/tasks/rake/testbranch.rake +16 -0
- data/tasks/rake/tracdocs.rake +8 -0
- data/test/data/providers/ssh_authorized_key/parsed/authorized_keys +1 -0
- metadata +1042 -1288
- data/ext/bin/sleeper +0 -67
- data/ext/module_puppet +0 -209
@@ -27,25 +27,12 @@ class Puppet::Network::Client::Resource < Puppet::Network::Client
|
|
27
27
|
def describe(type, name, retrieve = false, ignore = false)
|
28
28
|
Puppet.info "Describing %s[%s]" % [type.to_s.capitalize, name]
|
29
29
|
text = @driver.describe(type, name, retrieve, ignore, "yaml")
|
30
|
-
|
31
|
-
object = nil
|
32
|
-
if @local
|
33
|
-
object = text
|
34
|
-
else
|
35
|
-
object = YAML::load(Base64.decode64(text))
|
36
|
-
end
|
37
|
-
|
38
|
-
return object
|
30
|
+
@local ? text : YAML::load(Base64.decode64(text))
|
39
31
|
end
|
40
32
|
|
41
33
|
def list(type, ignore = false, base = false)
|
42
34
|
bucket = @driver.list(type, ignore, base, "yaml")
|
43
|
-
|
44
|
-
unless @local
|
45
|
-
bucket = YAML::load(Base64.decode64(bucket))
|
46
|
-
end
|
47
|
-
|
48
|
-
return bucket
|
35
|
+
@local ? bucket : YAML::load(Base64.decode64(bucket))
|
49
36
|
end
|
50
37
|
end
|
51
38
|
|
@@ -107,17 +107,7 @@ class Puppet::Network::Format
|
|
107
107
|
|
108
108
|
method = send(name)
|
109
109
|
|
110
|
-
if type == :class
|
111
|
-
|
112
|
-
message = "has not implemented method '%s'" % method
|
113
|
-
else
|
114
|
-
has_method = klass.instance_methods.include?(method)
|
115
|
-
message = "has not implemented instance method '%s'" % method
|
116
|
-
end
|
117
|
-
|
118
|
-
return true if has_method
|
119
|
-
|
120
|
-
Puppet.debug "Format %s not supported for %s; %s" % [self.name, klass, message]
|
121
|
-
return false
|
110
|
+
return klass.respond_to?(method) if type == :class
|
111
|
+
return klass.instance_methods.include?(method)
|
122
112
|
end
|
123
113
|
end
|
@@ -119,16 +119,30 @@ module Puppet::Network::FormatHandler
|
|
119
119
|
format_handler.format(b).weight <=> format_handler.format(a).weight
|
120
120
|
end
|
121
121
|
|
122
|
-
put_preferred_format_first(result)
|
122
|
+
result = put_preferred_format_first(result)
|
123
|
+
|
124
|
+
Puppet.debug "#{friendly_name} supports formats: #{result.map{ |f| f.to_s }.sort.join(' ')}; using #{result.first}"
|
125
|
+
|
126
|
+
result
|
123
127
|
end
|
124
128
|
|
125
129
|
private
|
126
130
|
|
131
|
+
def friendly_name
|
132
|
+
if self.respond_to? :indirection
|
133
|
+
indirection.name
|
134
|
+
else
|
135
|
+
self
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
127
139
|
def put_preferred_format_first(list)
|
128
140
|
preferred_format = Puppet.settings[:preferred_serialization_format].to_sym
|
129
141
|
if list.include?(preferred_format)
|
130
142
|
list.delete(preferred_format)
|
131
143
|
list.unshift(preferred_format)
|
144
|
+
else
|
145
|
+
Puppet.warning "Value of 'preferred_serialization_format' (#{preferred_format}) is invalid for #{friendly_name}, using default (#{list.first})"
|
132
146
|
end
|
133
147
|
list
|
134
148
|
end
|
@@ -44,7 +44,18 @@ end
|
|
44
44
|
# This format combines a yaml serialization, then zlib compression and base64 encoding.
|
45
45
|
Puppet::Network::FormatHandler.create(:b64_zlib_yaml, :mime => "text/b64_zlib_yaml") do
|
46
46
|
require 'base64'
|
47
|
-
|
47
|
+
|
48
|
+
def use_zlib?
|
49
|
+
Puppet.features.zlib? && Puppet[:zlib]
|
50
|
+
end
|
51
|
+
|
52
|
+
def requiring_zlib
|
53
|
+
if use_zlib?
|
54
|
+
yield
|
55
|
+
else
|
56
|
+
raise Puppet::Error, "the zlib library is not installed or is disabled."
|
57
|
+
end
|
58
|
+
end
|
48
59
|
|
49
60
|
def intern(klass, text)
|
50
61
|
decode(text)
|
@@ -70,7 +81,7 @@ Puppet::Network::FormatHandler.create(:b64_zlib_yaml, :mime => "text/b64_zlib_ya
|
|
70
81
|
|
71
82
|
# Because of yaml issue in ruby 1.8.1...
|
72
83
|
def supported?(klass)
|
73
|
-
RUBY_VERSION != '1.8.1'
|
84
|
+
RUBY_VERSION != '1.8.1' and use_zlib?
|
74
85
|
end
|
75
86
|
|
76
87
|
# fixup invalid yaml as per:
|
@@ -81,11 +92,15 @@ Puppet::Network::FormatHandler.create(:b64_zlib_yaml, :mime => "text/b64_zlib_ya
|
|
81
92
|
end
|
82
93
|
|
83
94
|
def encode(text)
|
84
|
-
|
95
|
+
requiring_zlib do
|
96
|
+
Base64.encode64(Zlib::Deflate.deflate(text, Zlib::BEST_COMPRESSION))
|
97
|
+
end
|
85
98
|
end
|
86
99
|
|
87
100
|
def decode(yaml)
|
88
|
-
|
101
|
+
requiring_zlib do
|
102
|
+
YAML.load(Zlib::Inflate.inflate(Base64.decode64(yaml)))
|
103
|
+
end
|
89
104
|
end
|
90
105
|
end
|
91
106
|
|
@@ -310,6 +310,7 @@ class Puppet::Network::Handler
|
|
310
310
|
mount.info "allowing %s access" % val
|
311
311
|
mount.allow(val)
|
312
312
|
rescue AuthStoreError => detail
|
313
|
+
puts detail.backtrace if Puppet[:trace]
|
313
314
|
raise FileServerError.new(detail.to_s,
|
314
315
|
count, @configuration.file)
|
315
316
|
end
|
@@ -97,6 +97,7 @@ module Puppet::Network::HTTP::Handler
|
|
97
97
|
# Execute our find.
|
98
98
|
def do_find(indirection_request, request, response)
|
99
99
|
unless result = indirection_request.model.find(indirection_request.key, indirection_request.to_hash)
|
100
|
+
Puppet.info("Could not find %s for '%s'" % [indirection_request.indirection_name, indirection_request.key])
|
100
101
|
return do_exception(response, "Could not find %s %s" % [indirection_request.indirection_name, indirection_request.key], 404)
|
101
102
|
end
|
102
103
|
|
@@ -12,23 +12,5 @@ class Puppet::Network::HTTP::RackHttpHandler
|
|
12
12
|
raise NotImplementedError, "Your RackHttpHandler subclass is supposed to override service(request)"
|
13
13
|
end
|
14
14
|
|
15
|
-
def ssl_client_header(request)
|
16
|
-
env_or_request_env(Puppet[:ssl_client_header], request)
|
17
|
-
end
|
18
|
-
|
19
|
-
def ssl_client_verify_header(request)
|
20
|
-
env_or_request_env(Puppet[:ssl_client_verify_header], request)
|
21
|
-
end
|
22
|
-
|
23
|
-
# Older Passenger versions passed all Environment vars in app(env),
|
24
|
-
# but since 2.2.3 they (some?) are really in ENV.
|
25
|
-
# Mongrel, etc. may also still use request.env.
|
26
|
-
def env_or_request_env(var, request)
|
27
|
-
if ENV.include?(var)
|
28
|
-
ENV[var]
|
29
|
-
else
|
30
|
-
request.env[var]
|
31
|
-
end
|
32
|
-
end
|
33
15
|
end
|
34
16
|
|
@@ -63,11 +63,11 @@ class Puppet::Network::HTTP::RackREST < Puppet::Network::HTTP::RackHttpHandler
|
|
63
63
|
result[:ip] = request.ip
|
64
64
|
|
65
65
|
# if we find SSL info in the headers, use them to get a hostname.
|
66
|
-
# try this with :ssl_client_header
|
67
|
-
#
|
68
|
-
if dn = ssl_client_header
|
66
|
+
# try this with :ssl_client_header, which defaults should work for
|
67
|
+
# Apache with StdEnvVars.
|
68
|
+
if dn = request.env[Puppet[:ssl_client_header]] and dn_matchdata = dn.match(/^.*?CN\s*=\s*(.*)/)
|
69
69
|
result[:node] = dn_matchdata[1].to_str
|
70
|
-
result[:authenticated] = (ssl_client_verify_header
|
70
|
+
result[:authenticated] = (request.env[Puppet[:ssl_client_verify_header]] == 'SUCCESS')
|
71
71
|
else
|
72
72
|
result[:node] = resolve_node(result)
|
73
73
|
result[:authenticated] = false
|
@@ -43,11 +43,11 @@ class Puppet::Network::HTTP::RackXMLRPC < Puppet::Network::HTTP::RackHttpHandler
|
|
43
43
|
ip = request.ip
|
44
44
|
|
45
45
|
# if we find SSL info in the headers, use them to get a hostname.
|
46
|
-
# try this with :ssl_client_header
|
47
|
-
#
|
48
|
-
if dn = ssl_client_header
|
46
|
+
# try this with :ssl_client_header, which defaults should work for
|
47
|
+
# Apache with StdEnvVars.
|
48
|
+
if dn = request.env[Puppet[:ssl_client_header]] and dn_matchdata = dn.match(/^.*?CN\s*=\s*(.*)/)
|
49
49
|
node = dn_matchdata[1].to_str
|
50
|
-
authenticated = (ssl_client_verify_header
|
50
|
+
authenticated = (request.env[Puppet[:ssl_client_verify_header]] == 'SUCCESS')
|
51
51
|
else
|
52
52
|
begin
|
53
53
|
node = Resolv.getname(ip)
|
@@ -22,7 +22,7 @@ class Puppet::Network::Server
|
|
22
22
|
$stderr.reopen $stdout
|
23
23
|
Puppet::Util::Log.reopen
|
24
24
|
rescue => detail
|
25
|
-
|
25
|
+
Puppet::Util.secure_open("/tmp/daemonout", "w") { |f|
|
26
26
|
f.puts "Could not start %s: %s" % [Puppet[:name], detail]
|
27
27
|
}
|
28
28
|
raise "Could not start %s: %s" % [Puppet[:name], detail]
|
@@ -55,15 +55,7 @@ class Puppet::Node::Environment
|
|
55
55
|
if ENV["PUPPETLIB"]
|
56
56
|
dirs = ENV["PUPPETLIB"].split(File::PATH_SEPARATOR) + dirs
|
57
57
|
end
|
58
|
-
dirs
|
59
|
-
if dir !~ /^#{File::SEPARATOR}/
|
60
|
-
File.join(Dir.getwd, dir)
|
61
|
-
else
|
62
|
-
dir
|
63
|
-
end
|
64
|
-
end.find_all do |p|
|
65
|
-
p =~ /^#{File::SEPARATOR}/ && FileTest.directory?(p)
|
66
|
-
end
|
58
|
+
validate_dirs(dirs)
|
67
59
|
end
|
68
60
|
|
69
61
|
# Return all modules from this environment.
|
@@ -73,7 +65,26 @@ class Puppet::Node::Environment
|
|
73
65
|
module_names.collect { |path| Puppet::Module.new(path, self) rescue nil }.compact
|
74
66
|
end
|
75
67
|
|
68
|
+
# Cache the manifestdir, so that we aren't searching through
|
69
|
+
# all known directories all the time.
|
70
|
+
cached_attr(:manifestdir, :ttl => Puppet[:filetimeout]) do
|
71
|
+
validate_dirs(self[:manifestdir].split(File::PATH_SEPARATOR))
|
72
|
+
end
|
73
|
+
|
76
74
|
def to_s
|
77
75
|
name.to_s
|
78
76
|
end
|
77
|
+
|
78
|
+
def validate_dirs(dirs)
|
79
|
+
dirs.collect do |dir|
|
80
|
+
if dir !~ /^#{File::SEPARATOR}/
|
81
|
+
File.join(Dir.getwd, dir)
|
82
|
+
else
|
83
|
+
dir
|
84
|
+
end
|
85
|
+
end.find_all do |p|
|
86
|
+
p =~ /^#{File::SEPARATOR}/ && FileTest.directory?(p)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
79
90
|
end
|
data/lib/puppet/parameter.rb
CHANGED
@@ -293,6 +293,13 @@ class Puppet::Parameter
|
|
293
293
|
define_method(:unmunge, &block)
|
294
294
|
end
|
295
295
|
|
296
|
+
# Optionaly convert the value to a canonical form so that it will
|
297
|
+
# be found in hashes, etc. Mostly useful for namevars.
|
298
|
+
def to_canonicalize(&block)
|
299
|
+
metaclass = (class << self; self; end)
|
300
|
+
metaclass.send(:define_method,:canonicalize,&block)
|
301
|
+
end
|
302
|
+
|
296
303
|
# Mark whether we're the namevar.
|
297
304
|
def isnamevar
|
298
305
|
@isnamevar = true
|
@@ -464,10 +471,19 @@ class Puppet::Parameter
|
|
464
471
|
value
|
465
472
|
end
|
466
473
|
|
474
|
+
# Assume the value is already in canonical form by default
|
475
|
+
def self.canonicalize(value)
|
476
|
+
value
|
477
|
+
end
|
478
|
+
|
479
|
+
def canonicalize(value)
|
480
|
+
self.class.canonicalize(value)
|
481
|
+
end
|
482
|
+
|
467
483
|
# A wrapper around our munging that makes sure we raise useful exceptions.
|
468
484
|
def munge(value)
|
469
485
|
begin
|
470
|
-
ret = unsafe_munge(value)
|
486
|
+
ret = unsafe_munge(canonicalize(value))
|
471
487
|
rescue Puppet::Error => detail
|
472
488
|
Puppet.debug "Reraising %s" % detail
|
473
489
|
raise
|
@@ -20,14 +20,14 @@ class Puppet::Parser::AST
|
|
20
20
|
# return result
|
21
21
|
# lazy evaluate right operand
|
22
22
|
case @operator
|
23
|
-
when "and"
|
23
|
+
when "and"
|
24
24
|
if Puppet::Parser::Scope.true?(lval)
|
25
25
|
rval = @rval.safeevaluate(scope)
|
26
26
|
Puppet::Parser::Scope.true?(rval)
|
27
27
|
else # false and false == false
|
28
28
|
false
|
29
29
|
end
|
30
|
-
when "or"
|
30
|
+
when "or"
|
31
31
|
if Puppet::Parser::Scope.true?(lval)
|
32
32
|
true
|
33
33
|
else
|
@@ -101,7 +101,7 @@ class Puppet::Parser::AST
|
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
104
|
-
def to_classname
|
104
|
+
def to_classname(dummy_argument=:work_arround_for_ruby_GC_bug)
|
105
105
|
to_s.downcase.gsub(/[^-\w:.]/,'').sub(/^\.+/,'')
|
106
106
|
end
|
107
107
|
|
@@ -150,6 +150,10 @@ class Puppet::Parser::AST
|
|
150
150
|
return scope.lookupvar(@value)
|
151
151
|
end
|
152
152
|
end
|
153
|
+
|
154
|
+
def to_s
|
155
|
+
"\$#{value}"
|
156
|
+
end
|
153
157
|
end
|
154
158
|
|
155
159
|
class Regex < AST::Leaf
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Runs an external command and returns the results
|
2
2
|
Puppet::Parser::Functions::newfunction(:generate, :type => :rvalue,
|
3
|
-
:doc => "Calls an external command
|
4
|
-
command. Any arguments are passed to the external command as
|
3
|
+
:doc => "Calls an external command on the Puppet master and returns
|
4
|
+
the results of the command. Any arguments are passed to the external command as
|
5
5
|
arguments. If the generator does not exit with return code of 0,
|
6
6
|
the generator is considered to have failed and a parse error is
|
7
7
|
thrown. Generators can only have file separators, alphanumerics, dashes,
|
@@ -10,7 +10,7 @@ module Puppet::Parser::Functions
|
|
10
10
|
with spaces. If an argument is an array, the elements of that
|
11
11
|
array is interpolated within the rest of the arguments; this makes
|
12
12
|
it possible to have an array of arguments and pass that array to
|
13
|
-
shellquote() instead of having to specify
|
13
|
+
shellquote() instead of having to specify each argument
|
14
14
|
individually in the call.
|
15
15
|
") \
|
16
16
|
do |args|
|
data/lib/puppet/property.rb
CHANGED
@@ -355,20 +355,12 @@ class Puppet::Property < Puppet::Parameter
|
|
355
355
|
end
|
356
356
|
|
357
357
|
def should_to_s(newvalue)
|
358
|
-
|
359
|
-
if defined? newvalue
|
360
|
-
newvalue.join(" ")
|
361
|
-
else
|
362
|
-
return nil
|
363
|
-
end
|
358
|
+
[newvalue].flatten.join(" ")
|
364
359
|
end
|
365
360
|
|
366
361
|
def sync
|
367
|
-
|
368
|
-
|
369
|
-
else
|
370
|
-
self.devfail "Got a nil value for should"
|
371
|
-
end
|
362
|
+
devfail "Got a nil value for should" unless should
|
363
|
+
set(should)
|
372
364
|
end
|
373
365
|
|
374
366
|
def to_s
|
@@ -17,8 +17,8 @@ Puppet::Type.type(:host).provide(:parsed,
|
|
17
17
|
text_line :comment, :match => /^#/
|
18
18
|
text_line :blank, :match => /^\s*$/
|
19
19
|
|
20
|
-
record_line :parsed, :fields => %w{ip name
|
21
|
-
:optional => %w{
|
20
|
+
record_line :parsed, :fields => %w{ip name host_aliases},
|
21
|
+
:optional => %w{host_aliases},
|
22
22
|
:rts => true do |line|
|
23
23
|
hash = {}
|
24
24
|
if line.sub!(/^(\S+)\s+(\S+)\s*/, '')
|
@@ -30,7 +30,7 @@ Puppet::Type.type(:host).provide(:parsed,
|
|
30
30
|
line.sub!(/^([^#]+)\s*/) do |value|
|
31
31
|
aliases = $1
|
32
32
|
unless aliases =~ /^\s*$/
|
33
|
-
hash[:
|
33
|
+
hash[:host_aliases] = aliases.split(/\s+/)
|
34
34
|
end
|
35
35
|
|
36
36
|
""
|
@@ -40,8 +40,8 @@ Puppet::Type.type(:host).provide(:parsed,
|
|
40
40
|
raise Puppet::Error, "Could not match '%s'" % line
|
41
41
|
end
|
42
42
|
|
43
|
-
if hash[:
|
44
|
-
hash.delete(:
|
43
|
+
if hash[:host_aliases] == ""
|
44
|
+
hash.delete(:host_aliases)
|
45
45
|
end
|
46
46
|
|
47
47
|
return hash
|
@@ -58,11 +58,11 @@ Puppet::Type.type(:host).provide(:parsed,
|
|
58
58
|
|
59
59
|
str = "%s\t%s" % [hash[:ip], hash[:name]]
|
60
60
|
|
61
|
-
if hash.include? :
|
62
|
-
if hash[:
|
63
|
-
str += "\t%s" % hash[:
|
61
|
+
if hash.include? :host_aliases
|
62
|
+
if hash[:host_aliases].is_a? Array
|
63
|
+
str += "\t%s" % hash[:host_aliases].join("\t")
|
64
64
|
else
|
65
|
-
raise ArgumentError, "
|
65
|
+
raise ArgumentError, "Host aliases must be specified as an array"
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|