puppet 0.24.4 → 0.24.5
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 +170 -0
- data/Rakefile +6 -4
- data/bin/filebucket +3 -2
- data/bin/puppet +7 -4
- data/bin/puppetca +32 -14
- data/bin/puppetd +12 -34
- data/bin/puppetmasterd +3 -2
- data/bin/puppetrun +5 -43
- data/bin/ralsh +2 -2
- data/conf/debian/README.source +2 -0
- data/conf/debian/TODO.Debian +1 -0
- data/conf/debian/changelog +257 -0
- data/conf/debian/compat +1 -0
- data/conf/debian/control +45 -0
- data/conf/debian/copyright +17 -0
- data/conf/debian/docs +1 -0
- data/conf/debian/fileserver.conf +12 -0
- data/conf/debian/puppet.NEWS +63 -0
- data/conf/debian/puppet.conf +8 -0
- data/conf/debian/puppet.dirs +7 -0
- data/conf/debian/puppet.files +6 -0
- data/conf/debian/puppet.init +64 -0
- data/conf/debian/puppet.logrotate +11 -0
- data/conf/debian/puppet.postinst +9 -0
- data/conf/debian/puppet.postrm +21 -0
- data/conf/debian/puppet.preinst +25 -0
- data/conf/debian/puppetmaster.files +4 -0
- data/conf/debian/puppetmaster.init +58 -0
- data/conf/debian/rules +115 -0
- data/conf/debian/watch +2 -0
- data/conf/gentoo/init.d/puppet +1 -1
- data/conf/gentoo/init.d/puppetmaster +32 -31
- data/conf/redhat/client.init +10 -2
- data/conf/redhat/puppet.spec +4 -1
- data/conf/redhat/server.init +9 -1
- data/examples/{code/allatonce → allatonce} +0 -0
- data/examples/{code/assignments → assignments} +0 -0
- data/examples/{code/components → components} +0 -0
- data/examples/{root/etc → etc}/init.d/sleeper +0 -0
- data/examples/{root/etc → etc}/otherfile +0 -0
- data/examples/{root/etc → etc}/puppet/fileserver.conf +0 -0
- data/examples/{root/etc → etc}/puppet/namespaceauth.conf +0 -0
- data/examples/{root/etc → etc}/puppet/puppet.conf +0 -0
- data/examples/{root/etc → etc}/puppet/tagmail.conf +0 -0
- data/examples/{code/execs → execs} +0 -0
- data/examples/{code/file.bl → file.bl} +0 -0
- data/examples/{code/filedefaults → filedefaults} +0 -0
- data/examples/{code/fileparsing → fileparsing} +0 -0
- data/examples/{code/filerecursion → filerecursion} +0 -0
- data/examples/{code/functions → functions} +0 -0
- data/examples/{code/groups → groups} +0 -0
- data/examples/{code/head → head} +0 -0
- data/examples/{code/importing → importing} +0 -0
- data/examples/{code/mac_automount.pp → mac_automount.pp} +0 -0
- data/examples/{code/mac_dscl.pp → mac_dscl.pp} +0 -0
- data/examples/{code/mac_dscl_revert.pp → mac_dscl_revert.pp} +0 -0
- data/examples/{code/mac_netinfo.pp → mac_netinfo.pp} +0 -0
- data/examples/{code/mac_pkgdmg.pp → mac_pkgdmg.pp} +0 -0
- data/examples/{code/modules → modules}/sample-module.pp +0 -0
- data/examples/{code/modules → modules}/sample-module/README.txt +0 -0
- data/examples/{code/modules → modules}/sample-module/lib/puppet/parser/functions/hostname_to_dn.rb +0 -0
- data/examples/{code/modules → modules}/sample-module/manifests/init.pp +0 -0
- data/examples/{code/modules → modules}/sample-module/templates/sample.erb +0 -0
- data/examples/{code/nodes → nodes} +0 -0
- data/examples/{code/one → one} +0 -0
- data/examples/{code/relationships → relationships} +0 -0
- data/examples/{code/selectors → selectors} +0 -0
- data/examples/{code/simpletests → simpletests} +0 -0
- data/examples/{code/svncommit → svncommit} +0 -0
- data/ext/autotest/Rakefile +8 -0
- data/ext/autotest/config +43 -0
- data/ext/autotest/readme.rst +16 -0
- data/{examples/root → ext}/bin/sleeper +1 -1
- data/ext/emacs/puppet-mode.el +246 -184
- data/ext/ldap/puppet.schema +7 -2
- data/ext/module_puppet +4 -3
- data/ext/nagios/check_puppet.rb +117 -0
- data/ext/puppetlast +40 -0
- data/install.rb +12 -3
- data/lib/puppet.rb +1 -44
- data/lib/puppet/defaults.rb +23 -10
- data/lib/puppet/dsl.rb +2 -2
- data/lib/puppet/executables/client/certhandler.rb +77 -0
- data/lib/puppet/external/nagios.rb +1 -1
- data/lib/puppet/external/nagios/base.rb +60 -46
- data/lib/puppet/file_serving/indirection_hooks.rb +4 -2
- data/lib/puppet/file_serving/metadata.rb +0 -9
- data/lib/puppet/file_serving/terminus_helper.rb +4 -4
- data/lib/puppet/indirector.rb +26 -28
- data/lib/puppet/indirector/catalog/compiler.rb +6 -28
- data/lib/puppet/indirector/checksum/file.rb +2 -2
- data/lib/puppet/indirector/direct_file_server.rb +7 -7
- data/lib/puppet/indirector/envelope.rb +13 -0
- data/lib/puppet/indirector/exec.rb +2 -2
- data/lib/puppet/indirector/facts/facter.rb +2 -2
- data/lib/puppet/indirector/file.rb +17 -14
- data/lib/puppet/indirector/file_metadata/file.rb +2 -2
- data/lib/puppet/indirector/file_server.rb +14 -14
- data/lib/puppet/indirector/indirection.rb +113 -48
- data/lib/puppet/indirector/ldap.rb +13 -25
- data/lib/puppet/indirector/memory.rb +7 -7
- data/lib/puppet/indirector/module_files.rb +14 -14
- data/lib/puppet/indirector/node/exec.rb +3 -10
- data/lib/puppet/indirector/node/ldap.rb +138 -41
- data/lib/puppet/indirector/node/plain.rb +1 -8
- data/lib/puppet/indirector/node/rest.rb +1 -1
- data/lib/puppet/indirector/plain.rb +2 -2
- data/lib/puppet/indirector/report/processor.rb +2 -2
- data/lib/puppet/indirector/request.rb +42 -0
- data/lib/puppet/indirector/rest.rb +51 -3
- data/lib/puppet/indirector/terminus.rb +0 -27
- data/lib/puppet/indirector/yaml.rb +12 -17
- data/lib/puppet/metatype/attributes.rb +3 -7
- data/lib/puppet/metatype/evaluation.rb +2 -2
- data/lib/puppet/module.rb +6 -2
- data/lib/puppet/network/client/master.rb +29 -81
- data/lib/puppet/network/handler/master.rb +12 -43
- data/lib/puppet/network/http.rb +8 -6
- data/lib/puppet/network/http/handler.rb +42 -32
- data/lib/puppet/network/http/mongrel.rb +8 -9
- data/lib/puppet/network/http/mongrel/rest.rb +42 -15
- data/lib/puppet/network/http/webrick.rb +27 -16
- data/lib/puppet/network/http/webrick/rest.rb +38 -14
- data/lib/puppet/network/http_pool.rb +3 -2
- data/lib/puppet/network/server.rb +24 -22
- data/lib/puppet/network/xmlrpc/client.rb +6 -1
- data/lib/puppet/node.rb +38 -79
- data/lib/puppet/node/catalog.rb +9 -0
- data/lib/puppet/node/facts.rb +9 -1
- data/lib/puppet/parser/ast/function.rb +1 -1
- data/lib/puppet/parser/collector.rb +6 -0
- data/lib/puppet/parser/compiler.rb +1 -1
- data/lib/puppet/parser/functions.rb +25 -1
- data/lib/puppet/parser/interpreter.rb +2 -17
- data/lib/puppet/parser/parser.rb +4 -4
- data/lib/puppet/parser/parser_support.rb +6 -2
- data/lib/puppet/parser/resource.rb +6 -0
- data/lib/puppet/parser/templatewrapper.rb +9 -0
- data/lib/puppet/pgraph.rb +1 -1
- data/lib/puppet/property.rb +0 -1
- data/lib/puppet/provider.rb +9 -95
- data/lib/puppet/provider/confine.rb +77 -0
- data/lib/puppet/provider/confine/exists.rb +22 -0
- data/lib/puppet/provider/confine/false.rb +19 -0
- data/lib/puppet/provider/confine/feature.rb +17 -0
- data/lib/puppet/provider/confine/true.rb +20 -0
- data/lib/puppet/provider/confine/variable.rb +42 -0
- data/lib/puppet/provider/confine_collection.rb +47 -0
- data/lib/puppet/provider/confiner.rb +20 -0
- data/lib/puppet/provider/cron/crontab.rb +6 -2
- data/lib/puppet/provider/group/groupadd.rb +1 -1
- data/lib/puppet/provider/group/ldap.rb +48 -0
- data/lib/puppet/provider/ldap.rb +137 -0
- data/lib/puppet/provider/nameservice.rb +1 -2
- data/lib/puppet/provider/nameservice/objectadd.rb +2 -5
- data/lib/puppet/provider/package/dpkg.rb +16 -1
- data/lib/puppet/provider/package/freebsd.rb +15 -4
- data/lib/puppet/provider/package/gem.rb +33 -12
- data/lib/puppet/provider/package/pkgdmg.rb +1 -60
- data/lib/puppet/provider/package/ports.rb +6 -1
- data/lib/puppet/provider/package/rpm.rb +14 -13
- data/lib/puppet/provider/package/urpmi.rb +3 -3
- data/lib/puppet/provider/service/base.rb +4 -4
- data/lib/puppet/provider/service/debian.rb +1 -1
- data/lib/puppet/provider/service/init.rb +5 -3
- data/lib/puppet/provider/service/redhat.rb +35 -7
- data/lib/puppet/provider/ssh_authorized_key/parsed.rb +69 -0
- data/lib/puppet/provider/user/ldap.rb +133 -0
- data/lib/puppet/provider/user/useradd.rb +1 -1
- data/lib/puppet/rails/database/001_add_created_at_to_all_tables.rb +14 -14
- data/lib/puppet/rails/database/schema.rb +9 -0
- data/lib/puppet/rails/resource.rb +1 -0
- data/lib/puppet/reference/providers.rb +8 -2
- data/lib/puppet/reference/report.rb +23 -0
- data/lib/puppet/reports/rrdgraph.rb +4 -2
- data/lib/puppet/sslcertificates/ca.rb +9 -4
- data/lib/puppet/sslcertificates/support.rb +26 -2
- data/lib/puppet/transaction.rb +11 -16
- data/lib/puppet/transaction/change.rb +94 -0
- data/lib/puppet/transaction/event.rb +21 -0
- data/lib/puppet/transaction/report.rb +4 -0
- data/lib/puppet/type.rb +0 -2
- data/lib/puppet/type/file/ensure.rb +0 -5
- data/lib/puppet/type/file/group.rb +13 -7
- data/lib/puppet/type/file/source.rb +8 -15
- data/lib/puppet/type/file/target.rb +2 -0
- data/lib/puppet/type/group.rb +1 -1
- data/lib/puppet/type/mount.rb +4 -2
- data/lib/puppet/type/nagios_hostescalation.rb +3 -0
- data/lib/puppet/type/nagios_servicegroup.rb +3 -0
- data/lib/puppet/type/ssh_authorized_key.rb +56 -0
- data/lib/puppet/type/user.rb +3 -0
- data/lib/puppet/type/yumrepo.rb +0 -1
- data/lib/puppet/util.rb +1 -1
- data/lib/puppet/util/ldap.rb +5 -0
- data/lib/puppet/util/ldap/connection.rb +69 -0
- data/lib/puppet/util/ldap/generator.rb +45 -0
- data/lib/puppet/util/ldap/manager.rb +281 -0
- data/lib/puppet/util/posix.rb +2 -2
- data/lib/puppet/util/resource_template.rb +61 -0
- data/lib/puppet/util/settings.rb +63 -3
- data/lib/puppet/util/storage.rb +4 -0
- data/lib/puppet/util/warnings.rb +7 -0
- data/man/man8/filebucket.8 +116 -0
- data/man/man8/pi.8 +34 -0
- data/man/man8/puppet.8 +78 -0
- data/man/man8/puppet.conf.8 +1747 -0
- data/man/man8/puppetca.8 +118 -0
- data/man/man8/puppetd.8 +184 -0
- data/man/man8/puppetdoc.8 +62 -0
- data/man/man8/puppetmasterd.8 +87 -0
- data/man/man8/puppetrun.8 +151 -0
- data/man/man8/ralsh.8 +135 -0
- data/test/README +24 -0
- data/test/certmgr/support.rb +28 -1
- data/test/data/failers/badclassnoparam +10 -0
- data/test/data/failers/badclassparam +10 -0
- data/test/data/failers/badcompnoparam +9 -0
- data/test/data/failers/badcompparam +9 -0
- data/test/data/failers/badtypeparam +3 -0
- data/test/data/failers/noobjectrvalue +1 -0
- data/test/data/providers/cron/crontab.allthree +17 -0
- data/test/data/providers/cron/crontab.envNcomment +12 -0
- data/test/data/providers/cron/crontab.envNname +11 -0
- data/test/data/providers/cron/crontab.multirecords +12 -0
- data/test/data/providers/cron/crontab_collections.yaml +44 -0
- data/test/data/providers/cron/crontab_multiple_with_env.yaml +54 -0
- data/test/data/providers/cron/crontab_sample_records.yaml +272 -0
- data/test/data/providers/cron/examples/freebsd +2 -0
- data/test/data/providers/cron/examples/one +14 -0
- data/test/data/providers/cron/examples/openbsd +20 -0
- data/test/data/providers/package/testpackages.yaml +65 -0
- data/test/data/providers/ssh_authorized_key/parsed/authorized_keys +5 -0
- data/test/data/reports/1.yaml +108 -0
- data/test/data/reports/2.yaml +108 -0
- data/test/data/reports/tagmail_failers.conf +3 -0
- data/test/data/reports/tagmail_passers.conf +30 -0
- data/test/data/snippets/aliastest.pp +16 -0
- data/test/data/snippets/argumentdefaults +14 -0
- data/test/data/snippets/casestatement.pp +58 -0
- data/test/data/snippets/classheirarchy.pp +15 -0
- data/test/data/snippets/classincludes.pp +17 -0
- data/test/data/snippets/classpathtest +11 -0
- data/test/data/snippets/collection.pp +10 -0
- data/test/data/snippets/collection_within_virtual_definitions.pp +20 -0
- data/test/data/snippets/componentmetaparams.pp +11 -0
- data/test/data/snippets/componentrequire.pp +8 -0
- data/test/data/snippets/deepclassheirarchy.pp +23 -0
- data/test/data/snippets/defineoverrides.pp +17 -0
- data/test/data/snippets/emptyclass.pp +9 -0
- data/test/data/snippets/emptyexec.pp +3 -0
- data/test/data/snippets/falsevalues.pp +3 -0
- data/test/data/snippets/filecreate +11 -0
- data/test/data/snippets/fqdefinition.pp +5 -0
- data/test/data/snippets/fqparents.pp +11 -0
- data/test/data/snippets/implicititeration +15 -0
- data/test/data/snippets/multipleinstances +7 -0
- data/test/data/snippets/multisubs.pp +13 -0
- data/test/data/snippets/namevartest +9 -0
- data/test/data/snippets/scopetest +13 -0
- data/test/data/snippets/selectorvalues.pp +42 -0
- data/test/data/snippets/simpledefaults +5 -0
- data/test/data/snippets/simpleselector +38 -0
- data/test/data/snippets/singleary.pp +19 -0
- data/test/data/snippets/singlequote.pp +11 -0
- data/test/data/snippets/singleselector.pp +22 -0
- data/test/data/snippets/subclass_name_duplication.pp +11 -0
- data/test/data/snippets/tag.pp +9 -0
- data/test/data/snippets/tagged.pp +35 -0
- data/test/data/snippets/virtualresources.pp +14 -0
- data/test/data/types/hosts/1 +3 -0
- data/test/data/types/hosts/2 +13 -0
- data/test/data/types/hosts/solaris +5 -0
- data/test/data/types/mailalias/file1 +183 -0
- data/test/data/types/mount/freebsd.fstab +7 -0
- data/test/data/types/mount/linux.fstab +11 -0
- data/test/data/types/mount/solaris.fstab +11 -0
- data/test/data/types/port/1 +533 -0
- data/test/data/types/port/darwin +11866 -0
- data/test/data/types/ssh_authorized_key/1 +2 -0
- data/test/data/types/sshkey/1 +21 -0
- data/test/data/types/yumrepos/fedora-devel.repo +26 -0
- data/test/data/types/yumrepos/fedora.repo +9 -0
- data/test/language/parser.rb +8 -1
- data/test/lib/puppettest/runnable_test.rb +3 -0
- data/test/lib/puppettest/support/utils.rb +1 -1
- data/test/lib/rake/puppet_testtask.rb +3 -0
- data/test/lib/stubba.rb +1 -1
- data/test/network/client/ca.rb +1 -0
- data/test/network/client/master.rb +13 -127
- data/test/network/handler/master.rb +61 -80
- data/test/other/provider.rb +0 -45
- data/test/other/transactions.rb +53 -15
- data/test/rails/host.rb +0 -37
- data/test/ral/providers/cron/crontab.rb +32 -3
- data/test/ral/providers/provider.rb +28 -7
- data/test/ral/type/filesources.rb +2 -18
- data/test/ral/type/sshkey.rb +0 -1
- data/test/ral/type/user.rb +6 -0
- data/test/test +241 -0
- metadata +289 -113
- data/examples/root/etc/configfile +0 -0
- data/examples/root/etc/debian-passwd +0 -29
- data/examples/root/etc/debian-syslog.conf +0 -71
- data/lib/puppet/event.rb +0 -28
- data/lib/puppet/network/handler/configuration.rb +0 -184
- data/lib/puppet/network/http/mongrel/xmlrpc.rb +0 -4
- data/lib/puppet/network/http/webrick/xmlrpc.rb +0 -4
- data/lib/puppet/propertychange.rb +0 -141
- data/lib/puppet/provider/interface/redhat.rb +0 -250
- data/lib/puppet/provider/interface/sunos.rb +0 -133
- data/lib/puppet/type/interface.rb +0 -60
- data/lib/puppet/util/variables.rb +0 -38
- data/test/network/handler/configuration.rb +0 -160
- data/test/other/propertychange.rb +0 -140
- data/test/util/loadedfile.rb +0 -121
@@ -20,6 +20,15 @@ class Puppet::Parser::TemplateWrapper
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
+
# Should return true if a variable is defined, false if it is not
|
24
|
+
def has_variable?(name)
|
25
|
+
if @scope.lookupvar(name.to_s, false) != :undefined
|
26
|
+
true
|
27
|
+
else
|
28
|
+
false
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
23
32
|
# Ruby treats variables like methods, so we can cheat here and
|
24
33
|
# trap missing vars like they were missing methods.
|
25
34
|
def method_missing(name, *args)
|
data/lib/puppet/pgraph.rb
CHANGED
@@ -58,7 +58,7 @@ class Puppet::PGraph < Puppet::SimpleGraph
|
|
58
58
|
# to, which is the same thing as saying all edges directly below
|
59
59
|
# This vertex in the graph.
|
60
60
|
adjacent(source, :direction => :out, :type => :edges).find_all do |edge|
|
61
|
-
edge.match?(event.
|
61
|
+
edge.match?(event.name)
|
62
62
|
end
|
63
63
|
end.compact.flatten
|
64
64
|
end
|
data/lib/puppet/property.rb
CHANGED
data/lib/puppet/provider.rb
CHANGED
@@ -5,6 +5,10 @@ class Puppet::Provider
|
|
5
5
|
include Puppet::Util::Warnings
|
6
6
|
extend Puppet::Util::Warnings
|
7
7
|
|
8
|
+
require 'puppet/provider/confiner'
|
9
|
+
|
10
|
+
extend Puppet::Provider::Confiner
|
11
|
+
|
8
12
|
Puppet::Util.logmethods(self, true)
|
9
13
|
|
10
14
|
class << self
|
@@ -40,27 +44,13 @@ class Puppet::Provider
|
|
40
44
|
[name, self.name]
|
41
45
|
end
|
42
46
|
|
43
|
-
|
44
|
-
return nil
|
45
|
-
end
|
46
|
-
|
47
|
-
command
|
47
|
+
return binary(command)
|
48
48
|
end
|
49
49
|
|
50
50
|
# Define commands that are not optional.
|
51
51
|
def self.commands(hash)
|
52
52
|
optional_commands(hash) do |name, path|
|
53
|
-
confine :exists => path
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
def self.confine(hash)
|
58
|
-
hash.each do |p,v|
|
59
|
-
if v.is_a? Array
|
60
|
-
@confines[p] += v
|
61
|
-
else
|
62
|
-
@confines[p] << v
|
63
|
-
end
|
53
|
+
confine :exists => path, :for_binary => true
|
64
54
|
end
|
65
55
|
end
|
66
56
|
|
@@ -108,10 +98,6 @@ class Puppet::Provider
|
|
108
98
|
def self.initvars
|
109
99
|
@defaults = {}
|
110
100
|
@commands = {}
|
111
|
-
@origcommands = {}
|
112
|
-
@confines = Hash.new do |hash, key|
|
113
|
-
hash[key] = []
|
114
|
-
end
|
115
101
|
end
|
116
102
|
|
117
103
|
# The method for returning a list of provider instances. Note that it returns providers, preferably with values already
|
@@ -180,16 +166,7 @@ class Puppet::Provider
|
|
180
166
|
def self.optional_commands(hash)
|
181
167
|
hash.each do |name, path|
|
182
168
|
name = symbolize(name)
|
183
|
-
@
|
184
|
-
|
185
|
-
# Try to find the full path (or verify already-full paths); otherwise
|
186
|
-
# store that the command is missing so we know it's defined but absent.
|
187
|
-
if tmp = binary(path)
|
188
|
-
path = tmp
|
189
|
-
@commands[name] = path
|
190
|
-
else
|
191
|
-
@commands[name] = :missing
|
192
|
-
end
|
169
|
+
@commands[name] = path
|
193
170
|
|
194
171
|
if block_given?
|
195
172
|
yield(name, path)
|
@@ -208,69 +185,6 @@ class Puppet::Provider
|
|
208
185
|
@source
|
209
186
|
end
|
210
187
|
|
211
|
-
# Check whether this implementation is suitable for our platform.
|
212
|
-
def self.suitable?(short = true)
|
213
|
-
# A single false result is sufficient to turn the whole thing down.
|
214
|
-
# We don't return 'true' until the very end, though, so that every
|
215
|
-
# confine is tested.
|
216
|
-
missing = {}
|
217
|
-
@confines.each do |check, values|
|
218
|
-
case check
|
219
|
-
when :exists:
|
220
|
-
values.each do |value|
|
221
|
-
unless value and FileTest.exists? value
|
222
|
-
debug "Not suitable: missing %s" % value
|
223
|
-
return false if short
|
224
|
-
missing[:exists] ||= []
|
225
|
-
missing[:exists] << value
|
226
|
-
end
|
227
|
-
end
|
228
|
-
when :true:
|
229
|
-
values.each do |v|
|
230
|
-
debug "Not suitable: false value"
|
231
|
-
unless v
|
232
|
-
return false if short
|
233
|
-
missing[:true] ||= 0
|
234
|
-
missing[:true] += 1
|
235
|
-
end
|
236
|
-
end
|
237
|
-
when :false:
|
238
|
-
values.each do |v|
|
239
|
-
debug "Not suitable: true value"
|
240
|
-
if v and short
|
241
|
-
return false if short
|
242
|
-
missing[:false] ||= 0
|
243
|
-
missing[:false] += 1
|
244
|
-
end
|
245
|
-
end
|
246
|
-
else # Just delegate everything else to facter
|
247
|
-
if result = Facter.value(check)
|
248
|
-
result = result.to_s.downcase.intern
|
249
|
-
|
250
|
-
found = values.find do |v|
|
251
|
-
result == v.to_s.downcase.intern
|
252
|
-
end
|
253
|
-
unless found
|
254
|
-
debug "Not suitable: %s not in %s" % [check, values]
|
255
|
-
return false if short
|
256
|
-
missing[:facter] ||= {}
|
257
|
-
missing[:facter][check] = values
|
258
|
-
end
|
259
|
-
else
|
260
|
-
return false if short
|
261
|
-
missing[:facter] ||= {}
|
262
|
-
missing[:facter][check] = values
|
263
|
-
end
|
264
|
-
end
|
265
|
-
end
|
266
|
-
|
267
|
-
if short
|
268
|
-
return true
|
269
|
-
else
|
270
|
-
return missing
|
271
|
-
end
|
272
|
-
end
|
273
|
-
|
274
188
|
# Does this provider support the specified parameter?
|
275
189
|
def self.supports_parameter?(param)
|
276
190
|
if param.is_a?(Class)
|
@@ -309,8 +223,8 @@ class Puppet::Provider
|
|
309
223
|
end
|
310
224
|
|
311
225
|
dochook(:commands) do
|
312
|
-
if @
|
313
|
-
return " Required binaries: " + @
|
226
|
+
if @commands.length > 0
|
227
|
+
return " Required binaries: " + @commands.collect do |n, c|
|
314
228
|
"``#{c}``"
|
315
229
|
end.join(", ") + "."
|
316
230
|
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# The class that handles testing whether our providers
|
2
|
+
# actually work or not.
|
3
|
+
require 'puppet/util'
|
4
|
+
|
5
|
+
class Puppet::Provider::Confine
|
6
|
+
include Puppet::Util
|
7
|
+
|
8
|
+
@tests = {}
|
9
|
+
|
10
|
+
class << self
|
11
|
+
attr_accessor :name
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.inherited(klass)
|
15
|
+
name = klass.to_s.split("::").pop.downcase.to_sym
|
16
|
+
raise "Test %s is already defined" % name if @tests.include?(name)
|
17
|
+
|
18
|
+
klass.name = name
|
19
|
+
|
20
|
+
@tests[name] = klass
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.test(name)
|
24
|
+
unless @tests[name]
|
25
|
+
begin
|
26
|
+
require "puppet/provider/confine/%s" % name
|
27
|
+
rescue LoadError => detail
|
28
|
+
unless detail.to_s.include?("no such file")
|
29
|
+
warn "Could not load confine test '%s': %s" % [name, detail]
|
30
|
+
end
|
31
|
+
# Could not find file
|
32
|
+
end
|
33
|
+
end
|
34
|
+
return @tests[name]
|
35
|
+
end
|
36
|
+
|
37
|
+
attr_reader :values
|
38
|
+
|
39
|
+
# Mark that this confine is used for testing binary existence.
|
40
|
+
attr_accessor :for_binary
|
41
|
+
def for_binary?
|
42
|
+
for_binary
|
43
|
+
end
|
44
|
+
|
45
|
+
def initialize(values)
|
46
|
+
values = [values] unless values.is_a?(Array)
|
47
|
+
@values = values
|
48
|
+
end
|
49
|
+
|
50
|
+
# Provide a hook for the message when there's a failure.
|
51
|
+
def message(value)
|
52
|
+
""
|
53
|
+
end
|
54
|
+
|
55
|
+
# Collect the results of all of them.
|
56
|
+
def result
|
57
|
+
values.collect { |value| pass?(value) }
|
58
|
+
end
|
59
|
+
|
60
|
+
# Test whether our confine matches.
|
61
|
+
def valid?
|
62
|
+
values.each do |value|
|
63
|
+
unless pass?(value)
|
64
|
+
Puppet.debug message(value)
|
65
|
+
return false
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
return true
|
70
|
+
ensure
|
71
|
+
reset
|
72
|
+
end
|
73
|
+
|
74
|
+
# Provide a hook for subclasses.
|
75
|
+
def reset
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'puppet/provider/confine'
|
2
|
+
|
3
|
+
class Puppet::Provider::Confine::Exists < Puppet::Provider::Confine
|
4
|
+
def self.summarize(confines)
|
5
|
+
confines.inject([]) { |total, confine| total + confine.summary }
|
6
|
+
end
|
7
|
+
|
8
|
+
def pass?(value)
|
9
|
+
if for_binary?
|
10
|
+
return false unless value = binary(value)
|
11
|
+
end
|
12
|
+
value and FileTest.exist?(value)
|
13
|
+
end
|
14
|
+
|
15
|
+
def message(value)
|
16
|
+
"file %s does not exist" % value
|
17
|
+
end
|
18
|
+
|
19
|
+
def summary
|
20
|
+
result.zip(values).inject([]) { |array, args| val, f = args; array << f unless val; array }
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'puppet/provider/confine'
|
2
|
+
|
3
|
+
class Puppet::Provider::Confine::False < Puppet::Provider::Confine
|
4
|
+
def self.summarize(confines)
|
5
|
+
confines.inject(0) { |count, confine| count + confine.summary }
|
6
|
+
end
|
7
|
+
|
8
|
+
def pass?(value)
|
9
|
+
! value
|
10
|
+
end
|
11
|
+
|
12
|
+
def message(value)
|
13
|
+
"true value when expecting false"
|
14
|
+
end
|
15
|
+
|
16
|
+
def summary
|
17
|
+
result.find_all { |v| v == false }.length
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'puppet/provider/confine'
|
2
|
+
|
3
|
+
class Puppet::Provider::Confine::Feature < Puppet::Provider::Confine
|
4
|
+
def self.summarize(confines)
|
5
|
+
confines.collect { |c| c.values }.flatten.uniq.find_all { |value| ! confines[0].pass?(value) }
|
6
|
+
end
|
7
|
+
|
8
|
+
# Is the named feature available?
|
9
|
+
def pass?(value)
|
10
|
+
Puppet.features.send(value.to_s + "?")
|
11
|
+
end
|
12
|
+
|
13
|
+
def message(value)
|
14
|
+
"feature %s is missing" % value
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'puppet/provider/confine'
|
2
|
+
|
3
|
+
class Puppet::Provider::Confine::True < Puppet::Provider::Confine
|
4
|
+
def self.summarize(confines)
|
5
|
+
confines.inject(0) { |count, confine| count + confine.summary }
|
6
|
+
end
|
7
|
+
|
8
|
+
def pass?(value)
|
9
|
+
# Double negate, so we only get true or false.
|
10
|
+
! ! value
|
11
|
+
end
|
12
|
+
|
13
|
+
def message(value)
|
14
|
+
"false value when expecting true"
|
15
|
+
end
|
16
|
+
|
17
|
+
def summary
|
18
|
+
result.find_all { |v| v == true }.length
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'puppet/provider/confine'
|
2
|
+
|
3
|
+
class Puppet::Provider::Confine::Variable < Puppet::Provider::Confine
|
4
|
+
def self.summarize(confines)
|
5
|
+
result = Hash.new { |hash, key| hash[key] = [] }
|
6
|
+
confines.inject(result) { |total, confine| total[confine.fact] += confine.values unless confine.valid?; total }
|
7
|
+
end
|
8
|
+
|
9
|
+
attr_accessor :name
|
10
|
+
|
11
|
+
# Retrieve the value from facter
|
12
|
+
def facter_value
|
13
|
+
unless defined?(@facter_value) and @facter_value
|
14
|
+
@facter_value = ::Facter.value(name).to_s.downcase
|
15
|
+
end
|
16
|
+
@facter_value
|
17
|
+
end
|
18
|
+
|
19
|
+
def message(value)
|
20
|
+
"facter value '%s' for '%s' not in required list '%s'" % [value, self.name, values.join(",")]
|
21
|
+
end
|
22
|
+
|
23
|
+
def pass?(value)
|
24
|
+
test_value.downcase.to_s == value.to_s.downcase
|
25
|
+
end
|
26
|
+
|
27
|
+
def reset
|
28
|
+
# Reset the cache. We want to cache it during a given
|
29
|
+
# run, but across runs.
|
30
|
+
@facter_value = nil
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def setting?
|
36
|
+
Puppet.settings.valid?(name)
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_value
|
40
|
+
setting? ? Puppet.settings[name] : facter_value
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# Manage a collection of confines, returning a boolean or
|
2
|
+
# helpful information.
|
3
|
+
require 'puppet/provider/confine'
|
4
|
+
|
5
|
+
class Puppet::Provider::ConfineCollection
|
6
|
+
def confine(hash)
|
7
|
+
if hash.include?(:for_binary)
|
8
|
+
for_binary = true
|
9
|
+
hash.delete(:for_binary)
|
10
|
+
else
|
11
|
+
for_binary = false
|
12
|
+
end
|
13
|
+
hash.each do |test, values|
|
14
|
+
if klass = Puppet::Provider::Confine.test(test)
|
15
|
+
@confines << klass.new(values)
|
16
|
+
@confines[-1].for_binary = true if for_binary
|
17
|
+
else
|
18
|
+
confine = Puppet::Provider::Confine.test(:variable).new(values)
|
19
|
+
confine.name = test
|
20
|
+
@confines << confine
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def initialize
|
26
|
+
@confines = []
|
27
|
+
end
|
28
|
+
|
29
|
+
# Return a hash of the whole confine set, used for the Provider
|
30
|
+
# reference.
|
31
|
+
def summary
|
32
|
+
confines = Hash.new { |hash, key| hash[key] = [] }
|
33
|
+
@confines.each { |confine| confines[confine.class] << confine }
|
34
|
+
result = {}
|
35
|
+
confines.each do |klass, list|
|
36
|
+
value = klass.summarize(list)
|
37
|
+
next if (value.respond_to?(:length) and value.length == 0) or (value == 0)
|
38
|
+
result[klass.name] = value
|
39
|
+
|
40
|
+
end
|
41
|
+
result
|
42
|
+
end
|
43
|
+
|
44
|
+
def valid?
|
45
|
+
! @confines.detect { |c| ! c.valid? }
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'puppet/provider/confine_collection'
|
2
|
+
|
3
|
+
module Puppet::Provider::Confiner
|
4
|
+
def confine(hash)
|
5
|
+
confine_collection.confine(hash)
|
6
|
+
end
|
7
|
+
|
8
|
+
def confine_collection
|
9
|
+
unless defined?(@confine_collection)
|
10
|
+
@confine_collection = Puppet::Provider::ConfineCollection.new
|
11
|
+
end
|
12
|
+
@confine_collection
|
13
|
+
end
|
14
|
+
|
15
|
+
# Check whether this implementation is suitable for our platform.
|
16
|
+
def suitable?(short = true)
|
17
|
+
return confine_collection.valid? if short
|
18
|
+
return confine_collection.summary
|
19
|
+
end
|
20
|
+
end
|