puppet 0.24.1 → 0.24.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 +94 -0
- data/Rakefile +0 -4
- data/bin/puppet +18 -10
- data/bin/puppetd +1 -1
- data/bin/puppetdoc +14 -4
- data/bin/puppetmasterd +1 -1
- data/bin/puppetrun +3 -8
- data/bin/ralsh +12 -11
- data/conf/freebsd/puppetd +1 -1
- data/conf/freebsd/puppetmasterd +1 -1
- data/conf/gentoo/puppet/puppet.conf +29 -0
- data/conf/namespaceauth.conf +20 -0
- data/conf/redhat/puppet.spec +4 -1
- data/conf/solaris/smf/puppetd.xml +1 -1
- data/conf/solaris/smf/puppetmasterd.xml +1 -1
- data/conf/suse/puppet.spec +10 -8
- data/examples/root/etc/puppet/{puppetmasterd.conf → puppet.conf} +6 -3
- data/ext/logcheck/puppet +7 -0
- data/ext/puppet-test +28 -5
- data/lib/puppet.rb +2 -1
- data/lib/puppet/defaults.rb +12 -5
- data/lib/puppet/dsl.rb +43 -45
- data/lib/puppet/external/{gratr/rdot.rb → dot.rb} +0 -0
- data/lib/puppet/external/nagios.rb +50 -0
- data/lib/puppet/external/nagios/base.rb +421 -0
- data/lib/puppet/external/nagios/parser.rb +816 -0
- data/lib/puppet/file_serving/file_base.rb +16 -3
- data/lib/puppet/file_serving/metadata.rb +29 -11
- data/lib/puppet/indirector/terminus.rb +1 -0
- data/lib/puppet/metatype/closure.rb +4 -0
- data/lib/puppet/metatype/evaluation.rb +2 -17
- data/lib/puppet/metatype/metaparams.rb +1 -1
- data/lib/puppet/network.rb +3 -0
- data/lib/puppet/network/client.rb +4 -5
- data/lib/puppet/network/client/master.rb +10 -7
- data/lib/puppet/network/handler/fileserver.rb +22 -45
- data/lib/puppet/network/http_pool.rb +3 -0
- data/lib/puppet/network/http_server/mongrel.rb +7 -1
- data/lib/puppet/network/http_server/webrick.rb +4 -3
- data/lib/puppet/network/xmlrpc/client.rb +12 -1
- data/lib/puppet/node/catalog.rb +51 -40
- data/lib/puppet/parser/ast.rb +27 -49
- data/lib/puppet/parser/ast/astarray.rb +5 -24
- data/lib/puppet/parser/ast/caseopt.rb +4 -4
- data/lib/puppet/parser/ast/casestatement.rb +4 -5
- data/lib/puppet/parser/ast/collection.rb +3 -5
- data/lib/puppet/parser/ast/collexpr.rb +3 -5
- data/lib/puppet/parser/ast/definition.rb +148 -159
- data/lib/puppet/parser/ast/else.rb +2 -3
- data/lib/puppet/parser/ast/function.rb +3 -10
- data/lib/puppet/parser/ast/hostclass.rb +66 -59
- data/lib/puppet/parser/ast/ifstatement.rb +4 -5
- data/lib/puppet/parser/ast/leaf.rb +6 -6
- data/lib/puppet/parser/ast/node.rb +26 -58
- data/lib/puppet/parser/ast/resource.rb +5 -7
- data/lib/puppet/parser/ast/resource_defaults.rb +2 -4
- data/lib/puppet/parser/ast/resource_override.rb +4 -6
- data/lib/puppet/parser/ast/resource_reference.rb +2 -4
- data/lib/puppet/parser/ast/resourceparam.rb +2 -4
- data/lib/puppet/parser/ast/selector.rb +5 -6
- data/lib/puppet/parser/ast/tag.rb +2 -4
- data/lib/puppet/parser/ast/vardef.rb +3 -4
- data/lib/puppet/parser/collector.rb +5 -5
- data/lib/puppet/parser/{compile.rb → compiler.rb} +69 -107
- data/lib/puppet/parser/functions.rb +3 -3
- data/lib/puppet/parser/interpreter.rb +32 -23
- data/lib/puppet/parser/lexer.rb +391 -282
- data/lib/puppet/parser/parser.rb +5 -4
- data/lib/puppet/parser/parser_support.rb +3 -6
- data/lib/puppet/parser/resource.rb +24 -36
- data/lib/puppet/parser/resource/param.rb +1 -1
- data/lib/puppet/parser/resource/reference.rb +7 -3
- data/lib/puppet/parser/scope.rb +12 -7
- data/lib/puppet/parser/templatewrapper.rb +1 -1
- data/lib/puppet/pgraph.rb +9 -98
- data/lib/puppet/provider/interface/redhat.rb +65 -65
- data/lib/puppet/provider/mount/parsed.rb +1 -1
- data/lib/puppet/provider/naginator.rb +55 -0
- data/lib/puppet/provider/nameservice/directoryservice.rb +6 -7
- data/lib/puppet/provider/package/fink.rb +0 -2
- data/lib/puppet/provider/package/gem.rb +9 -5
- data/lib/puppet/provider/package/openbsd.rb +1 -1
- data/lib/puppet/provider/package/pkgdmg.rb +3 -8
- data/lib/puppet/provider/package/portage.rb +4 -4
- data/lib/puppet/provider/package/yumhelper.py +8 -6
- data/lib/puppet/provider/parsedfile.rb +7 -1
- data/lib/puppet/provider/service/debian.rb +2 -0
- data/lib/puppet/provider/service/gentoo.rb +4 -0
- data/lib/puppet/provider/service/init.rb +1 -1
- data/lib/puppet/provider/sshkey/parsed.rb +2 -0
- data/lib/puppet/provider/user/useradd.rb +1 -1
- data/lib/puppet/rails.rb +4 -0
- data/lib/puppet/rails/database/001_add_created_at_to_all_tables.rb +17 -0
- data/lib/puppet/rails/fact_value.rb +4 -0
- data/lib/puppet/rails/host.rb +1 -2
- data/lib/puppet/rails/param_value.rb +4 -0
- data/lib/puppet/rails/resource_tag.rb +4 -0
- data/lib/puppet/rails/source_file.rb +4 -1
- data/lib/puppet/relationship.rb +5 -1
- data/lib/puppet/reports/tagmail.rb +12 -1
- data/lib/puppet/resource_reference.rb +1 -1
- data/lib/puppet/simple_graph.rb +78 -11
- data/lib/puppet/sslcertificates.rb +1 -1
- data/lib/puppet/sslcertificates/ca.rb +3 -3
- data/lib/puppet/transaction.rb +7 -4
- data/lib/puppet/transportable.rb +1 -1
- data/lib/puppet/type.rb +3 -10
- data/lib/puppet/type/cron.rb +18 -0
- data/lib/puppet/type/exec.rb +18 -12
- data/lib/puppet/type/{pfile.rb → file.rb} +66 -84
- data/lib/puppet/type/file/checksum.rb +271 -0
- data/lib/puppet/type/{pfile → file}/content.rb +10 -15
- data/lib/puppet/type/{pfile → file}/ensure.rb +15 -8
- data/lib/puppet/type/{pfile → file}/group.rb +0 -0
- data/lib/puppet/type/{pfile → file}/mode.rb +0 -0
- data/lib/puppet/type/{pfile → file}/owner.rb +0 -0
- data/lib/puppet/type/{pfile → file}/source.rb +34 -48
- data/lib/puppet/type/{pfile → file}/target.rb +0 -0
- data/lib/puppet/type/{pfile → file}/type.rb +0 -0
- data/lib/puppet/type/{pfilebucket.rb → filebucket.rb} +0 -0
- data/lib/puppet/type/host.rb +13 -0
- data/lib/puppet/type/mailalias.rb +1 -1
- data/lib/puppet/type/nagios_command.rb +3 -0
- data/lib/puppet/type/nagios_contact.rb +3 -0
- data/lib/puppet/type/nagios_contactgroup.rb +3 -0
- data/lib/puppet/type/nagios_host.rb +3 -0
- data/lib/puppet/type/nagios_hostextinfo.rb +3 -0
- data/lib/puppet/type/nagios_hostgroup.rb +3 -0
- data/lib/puppet/type/nagios_hostgroupescalation.rb +3 -0
- data/lib/puppet/type/nagios_service.rb +3 -0
- data/lib/puppet/type/nagios_servicedependency.rb +3 -0
- data/lib/puppet/type/nagios_serviceescalation.rb +3 -0
- data/lib/puppet/type/nagios_serviceextinfo.rb +3 -0
- data/lib/puppet/type/nagios_timeperiod.rb +3 -0
- data/lib/puppet/type/package.rb +4 -12
- data/lib/puppet/type/service.rb +9 -0
- data/lib/puppet/type/sshkey.rb +3 -3
- data/lib/puppet/util/autoload.rb +5 -5
- data/lib/puppet/util/checksums.rb +51 -13
- data/lib/puppet/util/constant_inflector.rb +14 -0
- data/lib/puppet/util/filetype.rb +1 -1
- data/lib/puppet/util/graph.rb +3 -9
- data/lib/puppet/util/nagios_maker.rb +57 -0
- data/lib/puppet/util/settings.rb +19 -16
- data/lib/puppet/util/tagging.rb +39 -0
- data/test/executables/puppetbin.rb +17 -0
- data/test/language/ast.rb +8 -58
- data/test/language/ast/casestatement.rb +3 -3
- data/test/language/ast/resource.rb +6 -7
- data/test/language/ast/resource_reference.rb +12 -12
- data/test/language/ast/selector.rb +2 -2
- data/test/language/ast/variable.rb +2 -2
- data/test/language/functions.rb +24 -24
- data/test/language/parser.rb +20 -8
- data/test/language/resource.rb +5 -42
- data/test/language/scope.rb +21 -37
- data/test/language/snippets.rb +7 -0
- data/test/lib/puppettest.rb +28 -14
- data/test/lib/puppettest/parsertesting.rb +10 -10
- data/test/lib/puppettest/support/resources.rb +1 -1
- data/test/network/client/master.rb +10 -0
- data/test/network/handler/fileserver.rb +51 -49
- data/test/network/server/webrick.rb +1 -1
- data/test/other/dsl.rb +3 -4
- data/test/other/transactions.rb +6 -4
- data/test/rails/ast.rb +2 -2
- data/test/rails/configuration.rb +1 -1
- data/test/rails/railsparameter.rb +2 -0
- data/test/rails/railsresource.rb +1 -0
- data/test/ral/manager/type.rb +4 -4
- data/test/ral/providers/cron/crontab.rb +3 -1
- data/test/ral/providers/package.rb +1 -1
- data/test/ral/{types → type}/basic.rb +2 -2
- data/test/ral/{types → type}/cron.rb +0 -0
- data/test/ral/{types → type}/exec.rb +42 -2
- data/test/ral/{types → type}/file.rb +34 -79
- data/test/ral/{types → type}/file/target.rb +0 -0
- data/test/ral/{types → type}/filebucket.rb +0 -0
- data/test/ral/{types → type}/fileignoresource.rb +0 -0
- data/test/ral/{types → type}/filesources.rb +8 -27
- data/test/ral/{types → type}/group.rb +0 -0
- data/test/ral/{types → type}/host.rb +16 -0
- data/test/ral/{types → type}/mailalias.rb +0 -0
- data/test/ral/{types → type}/parameter.rb +0 -0
- data/test/ral/{types → type}/port.rb +0 -0
- data/test/ral/{types → type}/property.rb +0 -0
- data/test/ral/{types → type}/resources.rb +0 -0
- data/test/ral/{types → type}/service.rb +0 -0
- data/test/ral/{types → type}/sshkey.rb +0 -0
- data/test/ral/{types → type}/tidy.rb +1 -0
- data/test/ral/{types → type}/user.rb +0 -0
- data/test/ral/{types → type}/yumrepo.rb +0 -0
- data/test/ral/{types → type}/zone.rb +0 -0
- data/test/util/autoload.rb +24 -5
- metadata +60 -107
- data/conf/gentoo/puppet/puppetca.conf +0 -29
- data/conf/gentoo/puppet/puppetd.conf +0 -29
- data/conf/gentoo/puppet/puppetmasterd.conf +0 -29
- data/examples/root/etc/puppet/puppetd.conf +0 -4
- data/lib/puppet/external/gratr.rb +0 -33
- data/lib/puppet/external/gratr/adjacency_graph.rb +0 -257
- data/lib/puppet/external/gratr/base.rb +0 -34
- data/lib/puppet/external/gratr/biconnected.rb +0 -116
- data/lib/puppet/external/gratr/chinese_postman.rb +0 -123
- data/lib/puppet/external/gratr/common.rb +0 -73
- data/lib/puppet/external/gratr/comparability.rb +0 -92
- data/lib/puppet/external/gratr/digraph.rb +0 -116
- data/lib/puppet/external/gratr/digraph_distance.rb +0 -185
- data/lib/puppet/external/gratr/dot.rb +0 -90
- data/lib/puppet/external/gratr/edge.rb +0 -145
- data/lib/puppet/external/gratr/graph.rb +0 -303
- data/lib/puppet/external/gratr/graph_api.rb +0 -83
- data/lib/puppet/external/gratr/import.rb +0 -44
- data/lib/puppet/external/gratr/labels.rb +0 -90
- data/lib/puppet/external/gratr/maximum_flow.rb +0 -64
- data/lib/puppet/external/gratr/search.rb +0 -409
- data/lib/puppet/external/gratr/strong_components.rb +0 -127
- data/lib/puppet/external/gratr/undirected_graph.rb +0 -153
- data/lib/puppet/rails/external/tagging/acts_as_taggable.rb +0 -62
- data/lib/puppet/rails/external/tagging/init.rb +0 -5
- data/lib/puppet/rails/external/tagging/tag.rb +0 -50
- data/lib/puppet/rails/external/tagging/tagging.rb +0 -12
- data/lib/puppet/rails/puppet_class.rb +0 -6
- data/lib/puppet/reference/node_source.rb +0 -9
- data/lib/puppet/reference/report.rb +0 -21
- data/lib/puppet/type/pfile/checksum.rb +0 -326
- data/test/language/ast/definition.rb +0 -166
- data/test/language/ast/hostclass.rb +0 -184
- data/test/language/compile.rb +0 -569
- data/test/language/lexer.rb +0 -276
- data/test/lib/mocha.rb +0 -19
- data/test/lib/mocha/any_instance_method.rb +0 -35
- data/test/lib/mocha/auto_verify.rb +0 -113
- data/test/lib/mocha/central.rb +0 -35
- data/test/lib/mocha/class_method.rb +0 -62
- data/test/lib/mocha/deprecation.rb +0 -22
- data/test/lib/mocha/exception_raiser.rb +0 -17
- data/test/lib/mocha/expectation.rb +0 -378
- data/test/lib/mocha/expectation_error.rb +0 -6
- data/test/lib/mocha/infinite_range.rb +0 -25
- data/test/lib/mocha/inspect.rb +0 -39
- data/test/lib/mocha/instance_method.rb +0 -8
- data/test/lib/mocha/is_a.rb +0 -9
- data/test/lib/mocha/metaclass.rb +0 -7
- data/test/lib/mocha/missing_expectation.rb +0 -27
- data/test/lib/mocha/mock.rb +0 -207
- data/test/lib/mocha/multiple_yields.rb +0 -20
- data/test/lib/mocha/no_yields.rb +0 -11
- data/test/lib/mocha/object.rb +0 -110
- data/test/lib/mocha/parameter_matchers.rb +0 -9
- data/test/lib/mocha/parameter_matchers/all_of.rb +0 -39
- data/test/lib/mocha/parameter_matchers/any_of.rb +0 -44
- data/test/lib/mocha/parameter_matchers/anything.rb +0 -30
- data/test/lib/mocha/parameter_matchers/has_entry.rb +0 -39
- data/test/lib/mocha/parameter_matchers/has_key.rb +0 -39
- data/test/lib/mocha/parameter_matchers/has_value.rb +0 -39
- data/test/lib/mocha/parameter_matchers/includes.rb +0 -37
- data/test/lib/mocha/pretty_parameters.rb +0 -28
- data/test/lib/mocha/return_values.rb +0 -31
- data/test/lib/mocha/setup_and_teardown.rb +0 -23
- data/test/lib/mocha/single_return_value.rb +0 -24
- data/test/lib/mocha/single_yield.rb +0 -18
- data/test/lib/mocha/standalone.rb +0 -32
- data/test/lib/mocha/stub.rb +0 -18
- data/test/lib/mocha/test_case_adapter.rb +0 -49
- data/test/lib/mocha/yield_parameters.rb +0 -31
data/lib/puppet/type/sshkey.rb
CHANGED
@@ -53,14 +53,14 @@ module Puppet
|
|
53
53
|
end
|
54
54
|
|
55
55
|
newparam(:name) do
|
56
|
-
desc "The host name."
|
56
|
+
desc "The host name that the key is associated with."
|
57
57
|
|
58
58
|
isnamevar
|
59
59
|
end
|
60
60
|
|
61
61
|
newproperty(:target) do
|
62
|
-
desc "The file in which to store the
|
63
|
-
|
62
|
+
desc "The file in which to store the ssh key. Only used by
|
63
|
+
the ``parsed`` provider."
|
64
64
|
|
65
65
|
defaultto { if @resource.class.defaultprovider.ancestors.include?(Puppet::Provider::ParsedFile)
|
66
66
|
@resource.class.defaultprovider.default_target
|
data/lib/puppet/util/autoload.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
|
+
require 'puppet/util/warnings'
|
2
|
+
|
1
3
|
# Autoload paths, either based on names or all at once.
|
2
4
|
class Puppet::Util::Autoload
|
3
5
|
include Puppet::Util
|
6
|
+
include Puppet::Util::Warnings
|
4
7
|
|
5
8
|
@autoloaders = {}
|
6
9
|
@loaded = []
|
@@ -109,9 +112,8 @@ class Puppet::Util::Autoload
|
|
109
112
|
Dir.glob("#{dir}/*.rb").each do |file|
|
110
113
|
name = File.basename(file).sub(".rb", '').intern
|
111
114
|
next if loaded?(name)
|
112
|
-
rubypath = File.join(@path, name.to_s)
|
113
115
|
begin
|
114
|
-
Kernel.require
|
116
|
+
Kernel.require file
|
115
117
|
loaded(name, file)
|
116
118
|
rescue => detail
|
117
119
|
if Puppet[:trace]
|
@@ -123,8 +125,6 @@ class Puppet::Util::Autoload
|
|
123
125
|
end
|
124
126
|
end
|
125
127
|
|
126
|
-
private
|
127
|
-
|
128
128
|
# Yield each subdir in turn.
|
129
129
|
def eachdir
|
130
130
|
searchpath.each do |dir|
|
@@ -137,7 +137,7 @@ class Puppet::Util::Autoload
|
|
137
137
|
def searchpath
|
138
138
|
# JJM: Search for optional lib directories in each module bundle.
|
139
139
|
module_lib_dirs = Puppet[:modulepath].split(":").collect do |d|
|
140
|
-
Dir.glob("%s/*/lib" % d).select do |f|
|
140
|
+
Dir.glob("%s/*/{plugins,lib}" % d).select do |f|
|
141
141
|
FileTest.directory?(f)
|
142
142
|
end
|
143
143
|
end.flatten
|
@@ -1,37 +1,75 @@
|
|
1
|
+
# A stand-alone module for calculating checksums
|
2
|
+
# in a generic way.
|
1
3
|
module Puppet::Util::Checksums
|
4
|
+
# Calculate a checksum using Digest::MD5.
|
2
5
|
def md5(content)
|
3
6
|
require 'digest/md5'
|
4
7
|
Digest::MD5.hexdigest(content)
|
5
8
|
end
|
6
9
|
|
7
|
-
|
10
|
+
# Calculate a checksum of the first 500 chars of the content using Digest::MD5.
|
11
|
+
def md5lite(content)
|
12
|
+
md5(content[0..511])
|
13
|
+
end
|
14
|
+
|
15
|
+
# Calculate a checksum of a file's content using Digest::MD5.
|
16
|
+
def md5_file(filename, lite = false)
|
8
17
|
require 'digest/md5'
|
9
18
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
19
|
+
digest = Digest::MD5.new()
|
20
|
+
return checksum_file(digest, filename, lite)
|
21
|
+
end
|
22
|
+
|
23
|
+
# Calculate a checksum of the first 500 chars of a file's content using Digest::MD5.
|
24
|
+
def md5lite_file(filename)
|
25
|
+
md5_file(filename, true)
|
26
|
+
end
|
16
27
|
|
17
|
-
|
28
|
+
# Return the :mtime timestamp of a file.
|
29
|
+
def mtime_file(filename)
|
30
|
+
File.stat(filename).send(:mtime)
|
18
31
|
end
|
19
32
|
|
33
|
+
# Calculate a checksum using Digest::SHA1.
|
20
34
|
def sha1(content)
|
21
35
|
require 'digest/sha1'
|
22
36
|
Digest::SHA1.hexdigest(content)
|
23
37
|
end
|
24
38
|
|
25
|
-
|
39
|
+
# Calculate a checksum of the first 500 chars of the content using Digest::SHA1.
|
40
|
+
def sha1lite(content)
|
41
|
+
sha1(content[0..511])
|
42
|
+
end
|
43
|
+
|
44
|
+
# Calculate a checksum of a file's content using Digest::SHA1.
|
45
|
+
def sha1_file(filename, lite = false)
|
26
46
|
require 'digest/sha1'
|
27
47
|
|
28
|
-
|
48
|
+
digest = Digest::SHA1.new()
|
49
|
+
return checksum_file(digest, filename, lite)
|
50
|
+
end
|
51
|
+
|
52
|
+
# Calculate a checksum of the first 500 chars of a file's content using Digest::SHA1.
|
53
|
+
def sha1lite_file(filename)
|
54
|
+
sha1_file(filename, true)
|
55
|
+
end
|
56
|
+
|
57
|
+
# Return the :ctime of a file.
|
58
|
+
def ctime_file(filename)
|
59
|
+
File.stat(filename).send(:ctime)
|
60
|
+
end
|
61
|
+
|
62
|
+
private
|
63
|
+
|
64
|
+
# Perform an incremental checksum on a file.
|
65
|
+
def checksum_file(digest, filename, lite = false)
|
29
66
|
File.open(filename, 'r') do |file|
|
30
|
-
file.
|
31
|
-
|
67
|
+
while content = file.read(512)
|
68
|
+
digest << content
|
69
|
+
break if lite
|
32
70
|
end
|
33
71
|
end
|
34
72
|
|
35
|
-
return
|
73
|
+
return digest.hexdigest
|
36
74
|
end
|
37
75
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# Created on 2008-02-12
|
2
|
+
# Copyright Luke Kanies
|
3
|
+
|
4
|
+
# A common module for converting between constants and
|
5
|
+
# file names.
|
6
|
+
module Puppet::Util::ConstantInflector
|
7
|
+
def file2constant(file)
|
8
|
+
file.split("/").collect { |name| name.capitalize }.join("::").gsub(/_+(.)/) { |term| $1.capitalize }
|
9
|
+
end
|
10
|
+
|
11
|
+
def constant2file(constant)
|
12
|
+
constant.to_s.gsub(/([a-z])([A-Z])/) { |term| $1 + "_" + $2 }.gsub("::", "/").downcase
|
13
|
+
end
|
14
|
+
end
|
data/lib/puppet/util/filetype.rb
CHANGED
@@ -165,7 +165,7 @@ class Puppet::Util::FileType
|
|
165
165
|
|
166
166
|
# Remove a specific @path's cron tab.
|
167
167
|
def remove
|
168
|
-
if Facter.value("operatingsystem")
|
168
|
+
if %w{Darwin FreeBSD}.include?(Facter.value("operatingsystem"))
|
169
169
|
%x{/bin/echo yes | #{cmdbase()} -r 2>/dev/null}
|
170
170
|
else
|
171
171
|
%x{#{cmdbase()} -r 2>/dev/null}
|
data/lib/puppet/util/graph.rb
CHANGED
@@ -16,21 +16,15 @@ module Puppet::Util::Graph
|
|
16
16
|
|
17
17
|
self.each do |child|
|
18
18
|
unless block_given? and ! yield(child)
|
19
|
-
graph.add_edge
|
20
|
-
|
21
|
-
if graph.cyclic?
|
22
|
-
raise Puppet::Error, "%s created a cyclic graph" % self
|
23
|
-
end
|
19
|
+
graph.add_edge(self, child)
|
24
20
|
|
25
21
|
if child.respond_to?(:to_graph)
|
26
22
|
child.to_graph(graph, &block)
|
27
23
|
end
|
28
24
|
end
|
29
25
|
end
|
30
|
-
|
31
|
-
if graph.
|
32
|
-
raise Puppet::Error, "%s created a cyclic graph" % self
|
33
|
-
end
|
26
|
+
|
27
|
+
# Do a topsort, which will throw an exception if the graph is cyclic.
|
34
28
|
|
35
29
|
graph
|
36
30
|
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'puppet/external/nagios'
|
2
|
+
require 'puppet/external/nagios/base'
|
3
|
+
require 'puppet/provider/naginator'
|
4
|
+
|
5
|
+
module Puppet::Util::NagiosMaker
|
6
|
+
# Create a new nagios type, using all of the parameters
|
7
|
+
# from the parser.
|
8
|
+
def self.create_nagios_type(name)
|
9
|
+
name = name.to_sym
|
10
|
+
full_name = ("nagios_" + name.to_s).to_sym
|
11
|
+
|
12
|
+
raise(Puppet::DevError, "No nagios type for %s" % name) unless nagtype = Nagios::Base.type(name)
|
13
|
+
|
14
|
+
type = Puppet::Type.newtype(full_name) {}
|
15
|
+
|
16
|
+
type.ensurable
|
17
|
+
|
18
|
+
type.newparam(nagtype.namevar, :namevar => true) do
|
19
|
+
desc "The name parameter for Nagios type %s" % nagtype.name
|
20
|
+
end
|
21
|
+
|
22
|
+
# We deduplicate the parameters because it makes sense to allow Naginator to have dupes.
|
23
|
+
nagtype.parameters.uniq.each do |param|
|
24
|
+
next if param == nagtype.namevar
|
25
|
+
|
26
|
+
# We can't turn these parameter names into constants, so at least for now they aren't
|
27
|
+
# supported.
|
28
|
+
next if param.to_s =~ /^[0-9]/
|
29
|
+
|
30
|
+
type.newproperty(param) do
|
31
|
+
desc "Nagios configuration file parameter."
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
type.newproperty(:target) do
|
36
|
+
desc 'target'
|
37
|
+
|
38
|
+
defaultto do
|
39
|
+
resource.class.defaultprovider.default_target
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
target = "/etc/nagios/#{full_name.to_s}.cfg"
|
44
|
+
provider = type.provide(:naginator, :parent => Puppet::Provider::Naginator, :default_target => target) {}
|
45
|
+
|
46
|
+
type.desc "The Nagios type #{name.to_s}. This resource type is autogenerated using the
|
47
|
+
model developed in Naginator_, and all of the Nagios types are generated using the
|
48
|
+
same code and the same library.
|
49
|
+
|
50
|
+
This type generates Nagios configuration statements in Nagios-parseable configuration
|
51
|
+
files. By default, the statements will be added to ``#{target}``, but
|
52
|
+
you can send them to a different file by setting their ``target`` attribute.
|
53
|
+
|
54
|
+
.. _naginator: http://reductivelabs.com/trac/naginator
|
55
|
+
"
|
56
|
+
end
|
57
|
+
end
|
data/lib/puppet/util/settings.rb
CHANGED
@@ -509,19 +509,19 @@ class Puppet::Util::Settings
|
|
509
509
|
objects += add_user_resources(section, obj, done)
|
510
510
|
end
|
511
511
|
|
512
|
+
value = obj.value
|
513
|
+
|
512
514
|
# Only files are convertable to transportable resources.
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
done[:file][trans.name] = trans
|
524
|
-
end
|
515
|
+
next unless obj.respond_to? :to_transportable and transobjects = obj.to_transportable
|
516
|
+
|
517
|
+
transobjects = [transobjects] unless transobjects.is_a? Array
|
518
|
+
transobjects.each do |trans|
|
519
|
+
# transportable could return nil
|
520
|
+
next unless trans
|
521
|
+
unless done[:file].include? trans.name
|
522
|
+
@created << trans.name
|
523
|
+
objects << trans
|
524
|
+
done[:file][trans.name] = trans
|
525
525
|
end
|
526
526
|
end
|
527
527
|
end
|
@@ -1124,7 +1124,7 @@ Generated on #{Time.now}.
|
|
1124
1124
|
# the variable 'dir', or adding a slash at the end.
|
1125
1125
|
def munge(value)
|
1126
1126
|
# If it's not a fully qualified path...
|
1127
|
-
if value.is_a?(String) and value !~ /^\$/ and value !~ /^\//
|
1127
|
+
if value.is_a?(String) and value !~ /^\$/ and value !~ /^\// and value != 'false'
|
1128
1128
|
# Make it one
|
1129
1129
|
value = File.join(Dir.getwd, value)
|
1130
1130
|
end
|
@@ -1153,12 +1153,15 @@ Generated on #{Time.now}.
|
|
1153
1153
|
def to_transportable
|
1154
1154
|
type = self.type
|
1155
1155
|
return nil unless type
|
1156
|
-
path = @parent.value(self.name).split(File::SEPARATOR)
|
1157
|
-
path.shift # remove the leading nil
|
1158
1156
|
|
1159
|
-
objects = []
|
1160
1157
|
path = self.value
|
1161
1158
|
|
1159
|
+
return nil unless path.is_a?(String)
|
1160
|
+
return nil if path =~ /^\/dev/
|
1161
|
+
return nil if Puppet::Type.type(:file)[path] # skip files that are in our global resource list.
|
1162
|
+
|
1163
|
+
objects = []
|
1164
|
+
|
1162
1165
|
# Skip plain files that don't exist, since we won't be managing them anyway.
|
1163
1166
|
return nil unless self.name.to_s =~ /dir$/ or File.exist?(path) or self.create
|
1164
1167
|
obj = Puppet::TransObject.new(path, "file")
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# Created on 2008-01-19
|
2
|
+
# Copyright Luke Kanies
|
3
|
+
|
4
|
+
# A common module to handle tagging.
|
5
|
+
module Puppet::Util::Tagging
|
6
|
+
# Add a tag to our current list. These tags will be added to all
|
7
|
+
# of the objects contained in this scope.
|
8
|
+
def tag(*ary)
|
9
|
+
@tags ||= []
|
10
|
+
|
11
|
+
qualified = []
|
12
|
+
|
13
|
+
ary.collect { |tag| tag.to_s.downcase }.each do |tag|
|
14
|
+
fail(Puppet::ParseError, "Invalid tag %s" % tag.inspect) unless valid_tag?(tag)
|
15
|
+
qualified << tag if tag.include?("::")
|
16
|
+
@tags << tag unless @tags.include?(tag)
|
17
|
+
end
|
18
|
+
|
19
|
+
qualified.collect { |name| name.split("::") }.flatten.each { |tag| @tags << tag unless @tags.include?(tag) }
|
20
|
+
end
|
21
|
+
|
22
|
+
# Are we tagged with the provided tag?
|
23
|
+
def tagged?(tag)
|
24
|
+
defined?(@tags) and @tags.include?(tag.to_s)
|
25
|
+
end
|
26
|
+
|
27
|
+
# Return a copy of the tag list, so someone can't ask for our tags
|
28
|
+
# and then modify them.
|
29
|
+
def tags
|
30
|
+
@tags ||= []
|
31
|
+
@tags.dup
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def valid_tag?(tag)
|
37
|
+
tag =~ /^\w[-\w:.]*$/
|
38
|
+
end
|
39
|
+
end
|
@@ -83,5 +83,22 @@ class TestPuppetBin < Test::Unit::TestCase
|
|
83
83
|
|
84
84
|
assert(FileTest.exists?(path), "Failed to create config'ed file")
|
85
85
|
end
|
86
|
+
|
87
|
+
def test_parseonly
|
88
|
+
path = tempfile()
|
89
|
+
manifest = tempfile()
|
90
|
+
puppet = %x{which puppet}.chomp
|
91
|
+
if puppet == ""
|
92
|
+
Puppet.info "cannot find puppet; cannot test parseonly"
|
93
|
+
return
|
94
|
+
end
|
95
|
+
code = 'File <<| |>>
|
96
|
+
include nosuchclass'
|
97
|
+
|
98
|
+
assert_nothing_raised {
|
99
|
+
IO.popen("#{puppet} --parseonly", 'w') { |p| p.puts code }
|
100
|
+
}
|
101
|
+
assert($? == 0, "parseonly test exited with code %s" % $?.to_i)
|
102
|
+
end
|
86
103
|
end
|
87
104
|
|
data/test/language/ast.rb
CHANGED
@@ -35,14 +35,14 @@ class TestAST < Test::Unit::TestCase
|
|
35
35
|
# We initialized it to true, so we should get that first
|
36
36
|
ret = nil
|
37
37
|
assert_nothing_raised {
|
38
|
-
ret = astif.evaluate(
|
38
|
+
ret = astif.evaluate("yay")
|
39
39
|
}
|
40
40
|
assert_equal(:if, ret)
|
41
41
|
|
42
42
|
# Now set it to false and check that
|
43
43
|
faketest.evaluate = false
|
44
44
|
assert_nothing_raised {
|
45
|
-
ret = astif.evaluate(
|
45
|
+
ret = astif.evaluate("yay")
|
46
46
|
}
|
47
47
|
assert_equal(:else, ret)
|
48
48
|
end
|
@@ -57,10 +57,10 @@ class TestAST < Test::Unit::TestCase
|
|
57
57
|
end
|
58
58
|
|
59
59
|
Puppet::Parser::Resource.expects(:new).with { |o| o.is_a?(Hash) }.returns(:override)
|
60
|
-
scope.
|
60
|
+
scope.compiler.expects(:add_override).with(:override)
|
61
61
|
ret = nil
|
62
62
|
assert_nothing_raised do
|
63
|
-
ret = ref.evaluate
|
63
|
+
ret = ref.evaluate scope
|
64
64
|
end
|
65
65
|
|
66
66
|
assert_equal(:override, ret, "Did not return override")
|
@@ -74,7 +74,7 @@ class TestAST < Test::Unit::TestCase
|
|
74
74
|
args = {:source => "/yay/ness", :group => "yayness"}
|
75
75
|
assert_nothing_raised do
|
76
76
|
obj = defaultobj "file", args
|
77
|
-
obj.evaluate
|
77
|
+
obj.evaluate scope
|
78
78
|
end
|
79
79
|
|
80
80
|
hash = nil
|
@@ -93,56 +93,6 @@ class TestAST < Test::Unit::TestCase
|
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
96
|
-
def test_node
|
97
|
-
scope = mkscope
|
98
|
-
parser = scope.compile.parser
|
99
|
-
|
100
|
-
# Define a base node
|
101
|
-
basenode = parser.newnode "basenode", :code => AST::ASTArray.new(:children => [
|
102
|
-
resourcedef("file", "/tmp/base", "owner" => "root")
|
103
|
-
])
|
104
|
-
|
105
|
-
# Now define a subnode
|
106
|
-
nodes = parser.newnode ["mynode", "othernode"],
|
107
|
-
:code => AST::ASTArray.new(:children => [
|
108
|
-
resourcedef("file", "/tmp/mynode", "owner" => "root"),
|
109
|
-
resourcedef("file", "/tmp/basenode", "owner" => "daemon")
|
110
|
-
])
|
111
|
-
|
112
|
-
assert_instance_of(Array, nodes)
|
113
|
-
|
114
|
-
# Make sure we can find them all.
|
115
|
-
%w{mynode othernode}.each do |node|
|
116
|
-
assert(parser.nodes[node], "Could not find %s" % node)
|
117
|
-
end
|
118
|
-
mynode = parser.nodes["mynode"]
|
119
|
-
|
120
|
-
# Now try evaluating the node
|
121
|
-
assert_nothing_raised do
|
122
|
-
mynode.evaluate :scope => scope, :resource => scope.resource
|
123
|
-
end
|
124
|
-
|
125
|
-
# Make sure that we can find each of the files
|
126
|
-
myfile = scope.findresource "File[/tmp/mynode]"
|
127
|
-
assert(myfile, "Could not find file from node")
|
128
|
-
assert_equal("root", myfile[:owner])
|
129
|
-
|
130
|
-
basefile = scope.findresource "File[/tmp/basenode]"
|
131
|
-
assert(basefile, "Could not find file from base node")
|
132
|
-
assert_equal("daemon", basefile[:owner])
|
133
|
-
|
134
|
-
# Now make sure we can evaluate nodes with parents
|
135
|
-
child = parser.newnode(%w{child}, :parent => "basenode").shift
|
136
|
-
|
137
|
-
newscope = mkscope :parser => parser
|
138
|
-
assert_nothing_raised do
|
139
|
-
child.evaluate :scope => newscope, :resource => scope.resource
|
140
|
-
end
|
141
|
-
|
142
|
-
assert(newscope.findresource("File[/tmp/base]"),
|
143
|
-
"Could not find base resource")
|
144
|
-
end
|
145
|
-
|
146
96
|
def test_collection
|
147
97
|
scope = mkscope
|
148
98
|
|
@@ -155,13 +105,13 @@ class TestAST < Test::Unit::TestCase
|
|
155
105
|
|
156
106
|
ret = nil
|
157
107
|
assert_nothing_raised do
|
158
|
-
ret = coll.evaluate
|
108
|
+
ret = coll.evaluate scope
|
159
109
|
end
|
160
110
|
|
161
111
|
assert_instance_of(Puppet::Parser::Collector, ret)
|
162
112
|
|
163
113
|
# Now make sure we get it back from the scope
|
164
|
-
colls = scope.
|
114
|
+
colls = scope.compiler.instance_variable_get("@collections")
|
165
115
|
assert_equal([ret], colls, "Did not store collector in config's collection list")
|
166
116
|
end
|
167
117
|
|
@@ -175,7 +125,7 @@ class TestAST < Test::Unit::TestCase
|
|
175
125
|
run_collection_queries(:virtual) do |string, result, query|
|
176
126
|
code = nil
|
177
127
|
assert_nothing_raised do
|
178
|
-
str, code = query.evaluate
|
128
|
+
str, code = query.evaluate scope
|
179
129
|
end
|
180
130
|
|
181
131
|
assert_instance_of(Proc, code)
|