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
@@ -2,26 +2,28 @@ require 'puppet/indirector/terminus'
|
|
2
2
|
|
3
3
|
# An empty terminus type, meant to just return empty objects.
|
4
4
|
class Puppet::Indirector::File < Puppet::Indirector::Terminus
|
5
|
-
|
5
|
+
# Remove files on disk.
|
6
|
+
def destroy(request)
|
6
7
|
if respond_to?(:path)
|
7
|
-
path = path(
|
8
|
+
path = path(request.key)
|
8
9
|
else
|
9
|
-
path =
|
10
|
+
path = request.key
|
10
11
|
end
|
11
|
-
raise Puppet::Error.new("File %s does not exist; cannot destroy" % [
|
12
|
+
raise Puppet::Error.new("File %s does not exist; cannot destroy" % [request.key]) unless File.exist?(path)
|
12
13
|
|
13
14
|
begin
|
14
15
|
File.unlink(path)
|
15
16
|
rescue => detail
|
16
|
-
raise Puppet::Error, "Could not remove %s: %s" % [
|
17
|
+
raise Puppet::Error, "Could not remove %s: %s" % [request.key, detail]
|
17
18
|
end
|
18
19
|
end
|
19
20
|
|
20
|
-
|
21
|
+
# Return a model instance for a given file on disk.
|
22
|
+
def find(request)
|
21
23
|
if respond_to?(:path)
|
22
|
-
path = path(
|
24
|
+
path = path(request.key)
|
23
25
|
else
|
24
|
-
path =
|
26
|
+
path = request.key
|
25
27
|
end
|
26
28
|
|
27
29
|
return nil unless File.exist?(path)
|
@@ -35,20 +37,21 @@ class Puppet::Indirector::File < Puppet::Indirector::Terminus
|
|
35
37
|
return model.new(content)
|
36
38
|
end
|
37
39
|
|
38
|
-
|
40
|
+
# Save a new file to disk.
|
41
|
+
def save(request)
|
39
42
|
if respond_to?(:path)
|
40
|
-
path = path(
|
43
|
+
path = path(request.key)
|
41
44
|
else
|
42
|
-
path =
|
45
|
+
path = request.key
|
43
46
|
end
|
44
47
|
dir = File.dirname(path)
|
45
48
|
|
46
|
-
raise Puppet::Error.new("Cannot save %s; parent directory %s does not exist" % [
|
49
|
+
raise Puppet::Error.new("Cannot save %s; parent directory %s does not exist" % [request.key, dir]) unless File.directory?(dir)
|
47
50
|
|
48
51
|
begin
|
49
|
-
File.open(path, "w") { |f| f.print
|
52
|
+
File.open(path, "w") { |f| f.print request.instance.content }
|
50
53
|
rescue => detail
|
51
|
-
raise Puppet::Error, "Could not write %s: %s" % [
|
54
|
+
raise Puppet::Error, "Could not write %s: %s" % [request.key, detail]
|
52
55
|
end
|
53
56
|
end
|
54
57
|
end
|
@@ -9,14 +9,14 @@ require 'puppet/indirector/direct_file_server'
|
|
9
9
|
class Puppet::Indirector::FileMetadata::File < Puppet::Indirector::DirectFileServer
|
10
10
|
desc "Retrieve file metadata directly from the local filesystem."
|
11
11
|
|
12
|
-
def find(
|
12
|
+
def find(request)
|
13
13
|
return unless data = super
|
14
14
|
data.collect_attributes
|
15
15
|
|
16
16
|
return data
|
17
17
|
end
|
18
18
|
|
19
|
-
def search(
|
19
|
+
def search(request)
|
20
20
|
return unless result = super
|
21
21
|
|
22
22
|
result.each { |instance| instance.collect_attributes }
|
@@ -14,28 +14,28 @@ class Puppet::Indirector::FileServer < Puppet::Indirector::Terminus
|
|
14
14
|
include Puppet::FileServing::TerminusHelper
|
15
15
|
|
16
16
|
# Is the client authorized to perform this action?
|
17
|
-
def authorized?(
|
18
|
-
return false unless [:find, :search].include?(method)
|
17
|
+
def authorized?(request)
|
18
|
+
return false unless [:find, :search].include?(request.method)
|
19
19
|
|
20
|
-
uri = key2uri(key)
|
20
|
+
uri = key2uri(request.key)
|
21
21
|
|
22
|
-
configuration.authorized?(uri.path, :node =>
|
22
|
+
configuration.authorized?(uri.path, :node => request.node, :ipaddress => request.ip)
|
23
23
|
end
|
24
24
|
|
25
25
|
# Find our key using the fileserver.
|
26
|
-
def find(
|
27
|
-
return nil unless path = find_path(
|
28
|
-
result = model.new(key, :path => path)
|
29
|
-
result.links = options[:links] if options[:links]
|
26
|
+
def find(request)
|
27
|
+
return nil unless path = find_path(request)
|
28
|
+
result = model.new(request.key, :path => path)
|
29
|
+
result.links = request.options[:links] if request.options[:links]
|
30
30
|
return result
|
31
31
|
end
|
32
32
|
|
33
33
|
# Search for files. This returns an array rather than a single
|
34
34
|
# file.
|
35
|
-
def search(
|
36
|
-
return nil unless path = find_path(
|
35
|
+
def search(request)
|
36
|
+
return nil unless path = find_path(request)
|
37
37
|
|
38
|
-
path2instances(
|
38
|
+
path2instances(request, path)
|
39
39
|
end
|
40
40
|
|
41
41
|
private
|
@@ -46,10 +46,10 @@ class Puppet::Indirector::FileServer < Puppet::Indirector::Terminus
|
|
46
46
|
end
|
47
47
|
|
48
48
|
# Find our path; used by :find and :search.
|
49
|
-
def find_path(
|
50
|
-
uri = key2uri(key)
|
49
|
+
def find_path(request)
|
50
|
+
uri = key2uri(request.key)
|
51
51
|
|
52
|
-
return nil unless path = configuration.file_path(uri.path, :node =>
|
52
|
+
return nil unless path = configuration.file_path(uri.path, :node => request.node)
|
53
53
|
|
54
54
|
return path
|
55
55
|
end
|
@@ -1,4 +1,6 @@
|
|
1
1
|
require 'puppet/util/docs'
|
2
|
+
require 'puppet/indirector/envelope'
|
3
|
+
require 'puppet/indirector/request'
|
2
4
|
|
3
5
|
# The class that connects functional classes with their different collection
|
4
6
|
# back-ends. Each indirection has a set of associated terminus classes,
|
@@ -28,8 +30,7 @@ class Puppet::Indirector::Indirection
|
|
28
30
|
# Find an indirected model by name. This is provided so that Terminus classes
|
29
31
|
# can specifically hook up with the indirections they are associated with.
|
30
32
|
def self.model(name)
|
31
|
-
match = @@indirections.find { |i| i.name == name }
|
32
|
-
return nil unless match
|
33
|
+
return nil unless match = @@indirections.find { |i| i.name == name }
|
33
34
|
match.model
|
34
35
|
end
|
35
36
|
|
@@ -65,6 +66,25 @@ class Puppet::Indirector::Indirection
|
|
65
66
|
@@indirections.delete(self) if @@indirections.include?(self)
|
66
67
|
end
|
67
68
|
|
69
|
+
# Set the time-to-live for instances created through this indirection.
|
70
|
+
def ttl=(value)
|
71
|
+
raise ArgumentError, "Indirection TTL must be an integer" unless value.is_a?(Fixnum)
|
72
|
+
@ttl = value
|
73
|
+
end
|
74
|
+
|
75
|
+
# Default to the runinterval for the ttl.
|
76
|
+
def ttl
|
77
|
+
unless defined?(@ttl)
|
78
|
+
@ttl = Puppet[:runinterval].to_i
|
79
|
+
end
|
80
|
+
@ttl
|
81
|
+
end
|
82
|
+
|
83
|
+
# Calculate the expiration date for a returned instance.
|
84
|
+
def expiration
|
85
|
+
Time.now + ttl
|
86
|
+
end
|
87
|
+
|
68
88
|
# Generate the full doc string.
|
69
89
|
def doc
|
70
90
|
text = ""
|
@@ -106,6 +126,11 @@ class Puppet::Indirector::Indirection
|
|
106
126
|
end
|
107
127
|
end
|
108
128
|
|
129
|
+
# Set up our request object.
|
130
|
+
def request(method, key, arguments = nil)
|
131
|
+
Puppet::Indirector::Request.new(self.name, method, key, arguments)
|
132
|
+
end
|
133
|
+
|
109
134
|
# Return the singleton terminus for this indirection.
|
110
135
|
def terminus(terminus_name = nil)
|
111
136
|
# Get the name of the terminus.
|
@@ -147,83 +172,123 @@ class Puppet::Indirector::Indirection
|
|
147
172
|
end
|
148
173
|
end
|
149
174
|
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
end
|
175
|
+
# Expire a cached object, if one is cached. Note that we don't actually
|
176
|
+
# remove it, we expire it and write it back out to disk. This way people
|
177
|
+
# can still use the expired object if they want.
|
178
|
+
def expire(key, *args)
|
179
|
+
request = request(:expire, key, *args)
|
180
|
+
|
181
|
+
return nil unless cache?
|
182
|
+
|
183
|
+
return nil unless instance = cache.find(request(:find, key, *args))
|
160
184
|
|
161
|
-
|
185
|
+
Puppet.info "Expiring the %s cache of %s" % [self.name, instance.name]
|
186
|
+
|
187
|
+
# Set an expiration date in the past
|
188
|
+
instance.expiration = Time.now - 60
|
189
|
+
|
190
|
+
cache.save(request(:save, instance, *args))
|
191
|
+
end
|
192
|
+
|
193
|
+
# Search for an instance in the appropriate terminus, caching the
|
194
|
+
# results if caching is configured..
|
195
|
+
def find(key, *args)
|
196
|
+
request = request(:find, key, *args)
|
197
|
+
terminus = prepare(request)
|
162
198
|
|
163
199
|
# See if our instance is in the cache and up to date.
|
164
|
-
if cache? and cache.
|
165
|
-
|
166
|
-
|
200
|
+
if cache? and cached = cache.find(request)
|
201
|
+
if cached.expired?
|
202
|
+
Puppet.info "Not using expired %s for %s from cache; expired at %s" % [self.name, request.key, cached.expiration]
|
203
|
+
else
|
204
|
+
Puppet.debug "Using cached %s for %s" % [self.name, request.key]
|
205
|
+
return cached
|
206
|
+
end
|
167
207
|
end
|
168
208
|
|
169
209
|
# Otherwise, return the result from the terminus, caching if appropriate.
|
170
|
-
if result = terminus
|
171
|
-
result.
|
210
|
+
if result = terminus.find(request)
|
211
|
+
result.expiration ||= self.expiration
|
172
212
|
if cache?
|
173
|
-
Puppet.info "Caching %s %s" % [self.name, key]
|
174
|
-
cache.save(result, *args)
|
213
|
+
Puppet.info "Caching %s for %s" % [self.name, request.key]
|
214
|
+
cache.save request(:save, result, *args)
|
175
215
|
end
|
176
216
|
|
177
|
-
terminus(terminus_name).post_find(result) if terminus(terminus_name).respond_to?(:post_find)
|
178
|
-
|
179
217
|
return result
|
180
218
|
end
|
181
|
-
end
|
182
|
-
|
183
|
-
def destroy(*args)
|
184
|
-
check_authorization(:destroy, terminus_class, args)
|
185
219
|
|
186
|
-
|
220
|
+
return nil
|
187
221
|
end
|
188
222
|
|
189
|
-
|
190
|
-
|
223
|
+
# Remove something via the terminus.
|
224
|
+
def destroy(key, *args)
|
225
|
+
request = request(:destroy, key, *args)
|
226
|
+
terminus = prepare(request)
|
191
227
|
|
192
|
-
result = terminus.
|
228
|
+
result = terminus.destroy(request)
|
193
229
|
|
194
|
-
|
230
|
+
if cache? and cached = cache.find(request(:find, key, *args))
|
231
|
+
# Reuse the existing request, since it's equivalent.
|
232
|
+
cache.destroy(request)
|
233
|
+
end
|
195
234
|
|
196
235
|
result
|
197
236
|
end
|
198
237
|
|
199
|
-
#
|
200
|
-
def
|
201
|
-
|
238
|
+
# Search for more than one instance. Should always return an array.
|
239
|
+
def search(key, *args)
|
240
|
+
request = request(:search, key, *args)
|
241
|
+
terminus = prepare(request)
|
202
242
|
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
243
|
+
if result = terminus.search(request)
|
244
|
+
raise Puppet::DevError, "Search results from terminus %s are not an array" % terminus.name unless result.is_a?(Array)
|
245
|
+
result.each do |instance|
|
246
|
+
instance.expiration ||= self.expiration
|
247
|
+
end
|
248
|
+
return result
|
249
|
+
end
|
209
250
|
end
|
210
251
|
|
211
|
-
|
212
|
-
|
252
|
+
# Save the instance in the appropriate terminus. This method is
|
253
|
+
# normally an instance method on the indirected class.
|
254
|
+
def save(instance, *args)
|
255
|
+
request = request(:save, instance, *args)
|
256
|
+
terminus = prepare(request)
|
257
|
+
|
258
|
+
# If caching is enabled, save our document there
|
259
|
+
cache.save(request) if cache?
|
260
|
+
terminus.save(request)
|
213
261
|
end
|
214
262
|
|
215
263
|
private
|
216
264
|
|
217
265
|
# Check authorization if there's a hook available; fail if there is one
|
218
266
|
# and it returns false.
|
219
|
-
def check_authorization(
|
220
|
-
#
|
221
|
-
#
|
222
|
-
return unless
|
267
|
+
def check_authorization(request, terminus)
|
268
|
+
# At this point, we're assuming authorization makes no sense without
|
269
|
+
# client information.
|
270
|
+
return unless request.node
|
271
|
+
|
272
|
+
# This is only to authorize via a terminus-specific authorization hook.
|
273
|
+
return unless terminus.respond_to?(:authorized?)
|
274
|
+
|
275
|
+
unless terminus.authorized?(request)
|
276
|
+
raise ArgumentError, "Not authorized to call %s on %s with %s" % [request.method, request.key, request.options.inspect]
|
277
|
+
end
|
278
|
+
end
|
223
279
|
|
224
|
-
|
225
|
-
|
280
|
+
# Setup a request, pick the appropriate terminus, check the request's authorization, and return it.
|
281
|
+
def prepare(request)
|
282
|
+
# Pick our terminus.
|
283
|
+
if respond_to?(:select_terminus)
|
284
|
+
terminus_name = select_terminus(request)
|
285
|
+
else
|
286
|
+
terminus_name = terminus_class
|
226
287
|
end
|
288
|
+
|
289
|
+
check_authorization(request, terminus(terminus_name))
|
290
|
+
|
291
|
+
return terminus(terminus_name)
|
227
292
|
end
|
228
293
|
|
229
294
|
# Create a new terminus instance.
|
@@ -1,19 +1,15 @@
|
|
1
1
|
require 'puppet/indirector/terminus'
|
2
|
+
require 'puppet/util/ldap/connection'
|
2
3
|
|
3
4
|
class Puppet::Indirector::Ldap < Puppet::Indirector::Terminus
|
4
5
|
# Perform our ldap search and process the result.
|
5
|
-
def find(
|
6
|
-
|
7
|
-
# get destroyed outside the scope of the search, strangely.
|
8
|
-
ldapsearch(name) { |entry| return process(name, entry) }
|
9
|
-
|
10
|
-
# Return nil if we haven't found something.
|
11
|
-
return nil
|
6
|
+
def find(request)
|
7
|
+
return ldapsearch(search_filter(request.key)) { |entry| return process(entry) } || nil
|
12
8
|
end
|
13
9
|
|
14
10
|
# Process the found entry. We assume that we don't just want the
|
15
11
|
# ldap object.
|
16
|
-
def process(
|
12
|
+
def process(entry)
|
17
13
|
raise Puppet::DevError, "The 'process' method has not been overridden for the LDAP terminus for %s" % self.name
|
18
14
|
end
|
19
15
|
|
@@ -33,14 +29,14 @@ class Puppet::Indirector::Ldap < Puppet::Indirector::Terminus
|
|
33
29
|
|
34
30
|
# Find the ldap node, return the class list and parent node specially,
|
35
31
|
# and everything else in a parameter hash.
|
36
|
-
def ldapsearch(
|
32
|
+
def ldapsearch(filter)
|
37
33
|
raise ArgumentError.new("You must pass a block to ldapsearch") unless block_given?
|
38
34
|
|
39
35
|
found = false
|
40
36
|
count = 0
|
41
37
|
|
42
38
|
begin
|
43
|
-
connection.search(search_base, 2,
|
39
|
+
connection.search(search_base, 2, filter, search_attributes) do |entry|
|
44
40
|
found = true
|
45
41
|
yield entry
|
46
42
|
end
|
@@ -52,15 +48,15 @@ class Puppet::Indirector::Ldap < Puppet::Indirector::Terminus
|
|
52
48
|
Puppet.warning "Retrying LDAP connection"
|
53
49
|
retry
|
54
50
|
else
|
55
|
-
|
51
|
+
error = Puppet::Error.new("LDAP Search failed")
|
52
|
+
error.set_backtrace(detail.backtrace)
|
53
|
+
raise error
|
56
54
|
end
|
57
55
|
end
|
58
56
|
|
59
57
|
return found
|
60
58
|
end
|
61
59
|
|
62
|
-
private
|
63
|
-
|
64
60
|
# Create an ldap connection.
|
65
61
|
def connection
|
66
62
|
unless defined? @connection and @connection
|
@@ -68,19 +64,11 @@ class Puppet::Indirector::Ldap < Puppet::Indirector::Terminus
|
|
68
64
|
raise Puppet::Error, "Could not set up LDAP Connection: Missing ruby/ldap libraries"
|
69
65
|
end
|
70
66
|
begin
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
@connection = LDAP::SSLConn.new(
|
75
|
-
Puppet[:ldapserver], Puppet[:ldapport], true
|
76
|
-
)
|
77
|
-
else
|
78
|
-
@connection = LDAP::Conn.new(Puppet[:ldapserver], Puppet[:ldapport])
|
79
|
-
end
|
80
|
-
@connection.set_option(LDAP::LDAP_OPT_PROTOCOL_VERSION, 3)
|
81
|
-
@connection.set_option(LDAP::LDAP_OPT_REFERRALS, LDAP::LDAP_OPT_ON)
|
82
|
-
@connection.simple_bind(Puppet[:ldapuser], Puppet[:ldappassword])
|
67
|
+
conn = Puppet::Util::Ldap::Connection.instance
|
68
|
+
conn.start
|
69
|
+
@connection = conn.connection
|
83
70
|
rescue => detail
|
71
|
+
puts detail.backtrace if Puppet[:trace]
|
84
72
|
raise Puppet::Error, "Could not connect to LDAP: %s" % detail
|
85
73
|
end
|
86
74
|
end
|
@@ -6,16 +6,16 @@ class Puppet::Indirector::Memory < Puppet::Indirector::Terminus
|
|
6
6
|
@instances = {}
|
7
7
|
end
|
8
8
|
|
9
|
-
def destroy(
|
10
|
-
raise ArgumentError.new("Could not find %s to destroy" %
|
11
|
-
@instances.delete(
|
9
|
+
def destroy(request)
|
10
|
+
raise ArgumentError.new("Could not find %s to destroy" % request.key) unless @instances.include?(request.key)
|
11
|
+
@instances.delete(request.key)
|
12
12
|
end
|
13
13
|
|
14
|
-
def find(
|
15
|
-
@instances[
|
14
|
+
def find(request)
|
15
|
+
@instances[request.key]
|
16
16
|
end
|
17
17
|
|
18
|
-
def save(
|
19
|
-
@instances[
|
18
|
+
def save(request)
|
19
|
+
@instances[request.key] = request.instance
|
20
20
|
end
|
21
21
|
end
|