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
@@ -1,108 +1,118 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
module Puppet::Network::HTTP::Handler
|
2
|
+
|
3
|
+
def initialize_for_puppet(args = {})
|
3
4
|
raise ArgumentError unless @server = args[:server]
|
4
5
|
raise ArgumentError unless @handler = args[:handler]
|
5
6
|
@model = find_model_for_handler(@handler)
|
6
|
-
register_handler
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
# handle an HTTP request
|
10
10
|
def process(request, response)
|
11
11
|
return do_find(request, response) if get?(request) and singular?(request)
|
12
12
|
return do_search(request, response) if get?(request) and plural?(request)
|
13
13
|
return do_destroy(request, response) if delete?(request) and singular?(request)
|
14
|
-
return do_save(request, response) if put?(request)
|
14
|
+
return do_save(request, response) if put?(request) and singular?(request)
|
15
15
|
raise ArgumentError, "Did not understand HTTP #{http_method(request)} request for '#{path(request)}'"
|
16
16
|
rescue Exception => e
|
17
17
|
return do_exception(request, response, e)
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
private
|
21
|
-
|
21
|
+
|
22
|
+
def model
|
23
|
+
@model
|
24
|
+
end
|
25
|
+
|
22
26
|
def do_find(request, response)
|
23
|
-
key = request_key(request) || raise(ArgumentError, "Could not locate lookup key in request path [#{path}]")
|
27
|
+
key = request_key(request) || raise(ArgumentError, "Could not locate lookup key in request path [#{path(request)}]")
|
24
28
|
args = params(request)
|
25
|
-
result =
|
29
|
+
result = model.find(key, args).to_yaml
|
26
30
|
encode_result(request, response, result)
|
27
31
|
end
|
28
32
|
|
29
33
|
def do_search(request, response)
|
30
34
|
args = params(request)
|
31
|
-
result =
|
35
|
+
result = model.search(args).collect {|result| result.to_yaml }.to_yaml
|
32
36
|
encode_result(request, response, result)
|
33
37
|
end
|
34
38
|
|
35
39
|
def do_destroy(request, response)
|
36
|
-
key = request_key(request) || raise(ArgumentError, "Could not locate lookup key in request path [#{path}]")
|
40
|
+
key = request_key(request) || raise(ArgumentError, "Could not locate lookup key in request path [#{path(request)}]")
|
37
41
|
args = params(request)
|
38
|
-
result =
|
42
|
+
result = model.destroy(key, args)
|
39
43
|
encode_result(request, response, YAML.dump(result))
|
40
44
|
end
|
41
45
|
|
42
46
|
def do_save(request, response)
|
43
|
-
data = body(request)
|
47
|
+
data = body(request).to_s
|
44
48
|
raise ArgumentError, "No data to save" if !data or data.empty?
|
45
49
|
args = params(request)
|
46
|
-
obj =
|
47
|
-
result = obj
|
50
|
+
obj = model.from_yaml(data)
|
51
|
+
result = save_object(obj, args).to_yaml
|
48
52
|
encode_result(request, response, result)
|
49
53
|
end
|
50
|
-
|
54
|
+
|
55
|
+
# LAK:NOTE This has to be here for testing; it's a stub-point so
|
56
|
+
# we keep infinite recursion from happening.
|
57
|
+
def save_object(object, args)
|
58
|
+
object.save(args)
|
59
|
+
end
|
60
|
+
|
51
61
|
def do_exception(request, response, exception, status=404)
|
52
|
-
encode_result(request, response, exception.
|
62
|
+
encode_result(request, response, exception.to_yaml, status)
|
53
63
|
end
|
54
|
-
|
64
|
+
|
55
65
|
def find_model_for_handler(handler)
|
56
66
|
Puppet::Indirector::Indirection.model(handler) ||
|
57
67
|
raise(ArgumentError, "Cannot locate indirection [#{handler}].")
|
58
68
|
end
|
59
|
-
|
69
|
+
|
60
70
|
def get?(request)
|
61
71
|
http_method(request) == 'GET'
|
62
72
|
end
|
63
|
-
|
73
|
+
|
64
74
|
def put?(request)
|
65
75
|
http_method(request) == 'PUT'
|
66
76
|
end
|
67
|
-
|
77
|
+
|
68
78
|
def delete?(request)
|
69
79
|
http_method(request) == 'DELETE'
|
70
80
|
end
|
71
|
-
|
81
|
+
|
72
82
|
def singular?(request)
|
73
83
|
%r{/#{@handler.to_s}$}.match(path(request))
|
74
84
|
end
|
75
|
-
|
85
|
+
|
76
86
|
def plural?(request)
|
77
87
|
%r{/#{@handler.to_s}s$}.match(path(request))
|
78
88
|
end
|
79
|
-
|
80
|
-
|
81
|
-
|
89
|
+
|
90
|
+
# methods to be overridden by the including web server class
|
91
|
+
|
82
92
|
def register_handler
|
83
93
|
raise NotImplementedError
|
84
94
|
end
|
85
|
-
|
95
|
+
|
86
96
|
def http_method(request)
|
87
97
|
raise NotImplementedError
|
88
98
|
end
|
89
|
-
|
99
|
+
|
90
100
|
def path(request)
|
91
101
|
raise NotImplementedError
|
92
102
|
end
|
93
|
-
|
103
|
+
|
94
104
|
def request_key(request)
|
95
105
|
raise NotImplementedError
|
96
106
|
end
|
97
|
-
|
107
|
+
|
98
108
|
def body(request)
|
99
109
|
raise NotImplementedError
|
100
110
|
end
|
101
|
-
|
111
|
+
|
102
112
|
def params(request)
|
103
113
|
raise NotImplementedError
|
104
114
|
end
|
105
|
-
|
115
|
+
|
106
116
|
def encode_result(request, response, result, status = 200)
|
107
117
|
raise NotImplementedError
|
108
118
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'mongrel' if Puppet.features.mongrel?
|
2
2
|
|
3
3
|
require 'puppet/network/http/mongrel/rest'
|
4
|
-
require 'puppet/network/http/mongrel/xmlrpc'
|
5
4
|
|
6
5
|
class Puppet::Network::HTTP::Mongrel
|
7
6
|
def initialize(args = {})
|
@@ -14,20 +13,20 @@ class Puppet::Network::HTTP::Mongrel
|
|
14
13
|
raise ArgumentError, ":address must be specified." unless args[:address]
|
15
14
|
raise ArgumentError, ":port must be specified." unless args[:port]
|
16
15
|
raise "Mongrel server is already listening" if listening?
|
17
|
-
|
16
|
+
|
18
17
|
@protocols = args[:protocols]
|
19
18
|
@handlers = args[:handlers]
|
20
|
-
@server = Mongrel::HttpServer.new(args[:address], args[:port])
|
21
|
-
|
19
|
+
@server = Mongrel::HttpServer.new(args[:address], args[:port])
|
22
20
|
setup_handlers
|
23
21
|
|
24
|
-
@server.run
|
25
22
|
@listening = true
|
23
|
+
@server.run
|
26
24
|
end
|
27
25
|
|
28
26
|
def unlisten
|
29
27
|
raise "Mongrel server is not listening" unless listening?
|
30
|
-
@server.
|
28
|
+
@server.stop
|
29
|
+
@server = nil
|
31
30
|
@listening = false
|
32
31
|
end
|
33
32
|
|
@@ -39,16 +38,16 @@ class Puppet::Network::HTTP::Mongrel
|
|
39
38
|
|
40
39
|
def setup_handlers
|
41
40
|
@protocols.each do |protocol|
|
41
|
+
klass = class_for_protocol(protocol)
|
42
42
|
@handlers.each do |handler|
|
43
|
-
|
43
|
+
@server.register('/' + handler.to_s, klass.new(:server => @server, :handler => handler))
|
44
|
+
@server.register('/' + handler.to_s + 's', klass.new(:server => @server, :handler => handler))
|
44
45
|
end
|
45
46
|
end
|
46
47
|
end
|
47
48
|
|
48
|
-
# TODO/FIXME: need a spec which forces delegation to the real class
|
49
49
|
def class_for_protocol(protocol)
|
50
50
|
return Puppet::Network::HTTP::MongrelREST if protocol.to_sym == :rest
|
51
|
-
return Puppet::Network::HTTP::MongrelXMLRPC if protocol.to_sym == :xmlrpc
|
52
51
|
raise ArgumentError, "Unknown protocol [#{protocol}]."
|
53
52
|
end
|
54
53
|
end
|
@@ -1,39 +1,66 @@
|
|
1
1
|
require 'puppet/network/http/handler'
|
2
2
|
|
3
|
-
class Puppet::Network::HTTP::MongrelREST <
|
3
|
+
class Puppet::Network::HTTP::MongrelREST < Mongrel::HttpHandler
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
def
|
8
|
-
|
9
|
-
|
5
|
+
include Puppet::Network::HTTP::Handler
|
6
|
+
|
7
|
+
def initialize(args={})
|
8
|
+
super()
|
9
|
+
initialize_for_puppet(args)
|
10
|
+
end
|
11
|
+
|
12
|
+
# Return the query params for this request. We had to expose this method for
|
13
|
+
# testing purposes.
|
14
|
+
def params(request)
|
15
|
+
Mongrel::HttpRequest.query_parse(request.params["QUERY_STRING"]).merge(client_info(request))
|
10
16
|
end
|
11
|
-
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
# which HTTP verb was used in this request
|
12
21
|
def http_method(request)
|
13
22
|
request.params[Mongrel::Const::REQUEST_METHOD]
|
14
23
|
end
|
15
|
-
|
24
|
+
|
25
|
+
# what path was requested?
|
16
26
|
def path(request)
|
17
27
|
# LAK:NOTE See http://snurl.com/21zf8 [groups_google_com]
|
18
28
|
x = '/' + request.params[Mongrel::Const::REQUEST_PATH].split('/')[1]
|
19
29
|
end
|
20
|
-
|
30
|
+
|
31
|
+
# return the key included in the request path
|
21
32
|
def request_key(request)
|
22
33
|
# LAK:NOTE See http://snurl.com/21zf8 [groups_google_com]
|
23
34
|
x = request.params[Mongrel::Const::REQUEST_PATH].split('/')[2]
|
24
35
|
end
|
25
|
-
|
36
|
+
|
37
|
+
# return the request body
|
26
38
|
def body(request)
|
27
39
|
request.body
|
28
40
|
end
|
29
|
-
|
30
|
-
|
31
|
-
Mongrel::HttpRequest.query_parse(request.params["QUERY_STRING"])
|
32
|
-
end
|
33
|
-
|
41
|
+
|
42
|
+
# produce the body of the response
|
34
43
|
def encode_result(request, response, result, status = 200)
|
35
44
|
response.start(status) do |head, body|
|
36
45
|
body.write(result)
|
37
46
|
end
|
38
47
|
end
|
48
|
+
|
49
|
+
def client_info(request)
|
50
|
+
result = {}
|
51
|
+
params = request.params
|
52
|
+
result[:ip] = params["REMOTE_ADDR"]
|
53
|
+
|
54
|
+
# JJM #906 The following dn.match regular expression is forgiving
|
55
|
+
# enough to match the two Distinguished Name string contents
|
56
|
+
# coming from Apache, Pound or other reverse SSL proxies.
|
57
|
+
if dn = params[Puppet[:ssl_client_header]] and dn_matchdata = dn.match(/^.*?CN\s*=\s*(.*)/)
|
58
|
+
result[:node] = dn_matchdata[1].to_str
|
59
|
+
result[:authenticated] = (params[Puppet[:ssl_client_verify_header]] == 'SUCCESS')
|
60
|
+
else
|
61
|
+
result[:authenticated] = false
|
62
|
+
end
|
63
|
+
|
64
|
+
return result
|
65
|
+
end
|
39
66
|
end
|
@@ -1,11 +1,17 @@
|
|
1
1
|
require 'webrick'
|
2
2
|
require 'webrick/https'
|
3
3
|
require 'puppet/network/http/webrick/rest'
|
4
|
-
require '
|
4
|
+
require 'thread'
|
5
5
|
|
6
6
|
class Puppet::Network::HTTP::WEBrick
|
7
7
|
def initialize(args = {})
|
8
8
|
@listening = false
|
9
|
+
@mutex = Mutex.new
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.class_for_protocol(protocol)
|
13
|
+
return Puppet::Network::HTTP::WEBrickREST if protocol.to_sym == :rest
|
14
|
+
raise "Unknown protocol [#{protocol}]."
|
9
15
|
end
|
10
16
|
|
11
17
|
def listen(args = {})
|
@@ -13,39 +19,44 @@ class Puppet::Network::HTTP::WEBrick
|
|
13
19
|
raise ArgumentError, ":protocols must be specified." if !args[:protocols] or args[:protocols].empty?
|
14
20
|
raise ArgumentError, ":address must be specified." unless args[:address]
|
15
21
|
raise ArgumentError, ":port must be specified." unless args[:port]
|
16
|
-
raise "WEBrick server is already listening" if listening?
|
17
22
|
|
18
23
|
@protocols = args[:protocols]
|
19
24
|
@handlers = args[:handlers]
|
20
25
|
@server = WEBrick::HTTPServer.new(:BindAddress => args[:address], :Port => args[:port])
|
21
26
|
setup_handlers
|
22
|
-
|
23
|
-
@
|
27
|
+
|
28
|
+
@mutex.synchronize do
|
29
|
+
raise "WEBrick server is already listening" if @listening
|
30
|
+
@listening = true
|
31
|
+
@thread = Thread.new { @server.start }
|
32
|
+
end
|
24
33
|
end
|
25
34
|
|
26
35
|
def unlisten
|
27
|
-
|
28
|
-
|
29
|
-
|
36
|
+
@mutex.synchronize do
|
37
|
+
raise "WEBrick server is not listening" unless @listening
|
38
|
+
@server.shutdown
|
39
|
+
@thread.join
|
40
|
+
@server = nil
|
41
|
+
@listening = false
|
42
|
+
end
|
30
43
|
end
|
31
44
|
|
32
45
|
def listening?
|
33
|
-
@
|
46
|
+
@mutex.synchronize do
|
47
|
+
@listening
|
48
|
+
end
|
34
49
|
end
|
35
|
-
|
50
|
+
|
36
51
|
private
|
37
52
|
|
38
53
|
def setup_handlers
|
39
54
|
@protocols.each do |protocol|
|
55
|
+
klass = self.class.class_for_protocol(protocol)
|
40
56
|
@handlers.each do |handler|
|
41
|
-
|
57
|
+
@server.mount('/' + handler.to_s, klass, handler)
|
58
|
+
@server.mount('/' + handler.to_s + 's', klass, handler)
|
42
59
|
end
|
43
60
|
end
|
44
61
|
end
|
45
|
-
|
46
|
-
def class_for_protocol(protocol)
|
47
|
-
return Puppet::Network::HTTP::WEBrickREST if protocol.to_sym == :rest
|
48
|
-
return Puppet::Network::HTTP::WEBrickXMLRPC if protocol.to_sym == :xmlrpc
|
49
|
-
raise ArgumentError, "Unknown protocol [#{protocol}]."
|
50
|
-
end
|
51
62
|
end
|
@@ -1,6 +1,20 @@
|
|
1
1
|
require 'puppet/network/http/handler'
|
2
2
|
|
3
|
-
class Puppet::Network::HTTP::WEBrickREST <
|
3
|
+
class Puppet::Network::HTTP::WEBrickREST < WEBrick::HTTPServlet::AbstractServlet
|
4
|
+
|
5
|
+
include Puppet::Network::HTTP::Handler
|
6
|
+
|
7
|
+
def initialize(server, handler)
|
8
|
+
raise ArgumentError, "server is required" unless server
|
9
|
+
super(server)
|
10
|
+
initialize_for_puppet(:server => server, :handler => handler)
|
11
|
+
end
|
12
|
+
|
13
|
+
# We had to expose this method for testing purposes.
|
14
|
+
def params(request)
|
15
|
+
result = request.query
|
16
|
+
result.merge(client_information(request))
|
17
|
+
end
|
4
18
|
|
5
19
|
# WEBrick uses a service() method to respond to requests. Simply delegate to the handler response() method.
|
6
20
|
def service(request, response)
|
@@ -8,36 +22,46 @@ class Puppet::Network::HTTP::WEBrickREST < Puppet::Network::HTTP::Handler
|
|
8
22
|
end
|
9
23
|
|
10
24
|
private
|
11
|
-
|
12
|
-
def register_handler
|
13
|
-
@server.mount('/' + @handler.to_s, self)
|
14
|
-
@server.mount('/' + @handler.to_s + 's', self)
|
15
|
-
end
|
16
25
|
|
17
26
|
def http_method(request)
|
18
27
|
request.request_method
|
19
28
|
end
|
20
|
-
|
29
|
+
|
21
30
|
def path(request)
|
22
31
|
# LAK:NOTE See http://snurl.com/21zf8 [groups_google_com]
|
23
32
|
x = '/' + request.path.split('/')[1]
|
24
33
|
end
|
25
|
-
|
34
|
+
|
26
35
|
def request_key(request)
|
27
36
|
# LAK:NOTE See http://snurl.com/21zf8 [groups_google_com]
|
28
37
|
x = request.path.split('/')[2]
|
29
38
|
end
|
30
|
-
|
39
|
+
|
31
40
|
def body(request)
|
32
41
|
request.body
|
33
42
|
end
|
34
|
-
|
35
|
-
def params(request)
|
36
|
-
request.query
|
37
|
-
end
|
38
|
-
|
43
|
+
|
39
44
|
def encode_result(request, response, result, status = 200)
|
40
45
|
response.status = status
|
41
46
|
response.body = result
|
42
47
|
end
|
48
|
+
|
49
|
+
# Retrieve node/cert/ip information from the request object.
|
50
|
+
def client_information(request)
|
51
|
+
result = {}
|
52
|
+
if peer = request.peeraddr and ip = peer[3]
|
53
|
+
result[:ip] = ip
|
54
|
+
end
|
55
|
+
|
56
|
+
# If they have a certificate (which will almost always be true)
|
57
|
+
# then we get the hostname from the cert, instead of via IP
|
58
|
+
# info
|
59
|
+
result[:authenticated] = false
|
60
|
+
if cert = request.client_cert and nameary = cert.subject.to_a.find { |ary| ary[0] == "CN" }
|
61
|
+
result[:node] = nameary[1]
|
62
|
+
result[:authenticated] = true
|
63
|
+
end
|
64
|
+
|
65
|
+
result
|
66
|
+
end
|
43
67
|
end
|
@@ -88,8 +88,9 @@ module Puppet::Network::HttpPool
|
|
88
88
|
class << http; attr_accessor :ca_file; end
|
89
89
|
|
90
90
|
http.use_ssl = true
|
91
|
-
|
92
|
-
http.
|
91
|
+
# Use configured timeout (#1176)
|
92
|
+
http.read_timeout = Puppet[:configtimeout]
|
93
|
+
http.open_timeout = Puppet[:configtimeout]
|
93
94
|
# JJM Configurable fix for #896.
|
94
95
|
if Puppet[:http_enable_post_connection_check]
|
95
96
|
http.enable_post_connection_check = true
|