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,3 +1,5 @@
|
|
1
|
+
require 'puppet/network/http'
|
2
|
+
|
1
3
|
class Puppet::Network::Server
|
2
4
|
attr_reader :server_type, :protocols, :address, :port
|
3
5
|
|
@@ -8,44 +10,44 @@ class Puppet::Network::Server
|
|
8
10
|
raise(ArgumentError, "Must specify :address or configure Puppet :bindaddress.")
|
9
11
|
@port = args[:port] || Puppet[:masterport] ||
|
10
12
|
raise(ArgumentError, "Must specify :port or configure Puppet :masterport")
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
13
|
+
@protocols = [ :rest ]
|
14
|
+
@listening = false
|
15
|
+
@routes = {}
|
16
|
+
self.register(args[:handlers]) if args[:handlers]
|
15
17
|
end
|
16
18
|
|
17
19
|
def register(*indirections)
|
18
|
-
|
19
|
-
|
20
|
+
raise ArgumentError, "Indirection names are required." if indirections.empty?
|
21
|
+
indirections.flatten.each { |i| @routes[i.to_sym] = true }
|
20
22
|
end
|
21
23
|
|
22
24
|
def unregister(*indirections)
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
25
|
+
raise "Cannot unregister indirections while server is listening." if listening?
|
26
|
+
indirections = @routes.keys if indirections.empty?
|
27
|
+
|
28
|
+
indirections.flatten.each do |i|
|
29
|
+
raise(ArgumentError, "Indirection [%s] is unknown." % i) unless @routes[i.to_sym]
|
30
|
+
end
|
29
31
|
|
30
|
-
|
31
|
-
|
32
|
-
|
32
|
+
indirections.flatten.each do |i|
|
33
|
+
@routes.delete(i.to_sym)
|
34
|
+
end
|
33
35
|
end
|
34
36
|
|
35
37
|
def listening?
|
36
|
-
|
38
|
+
@listening
|
37
39
|
end
|
38
40
|
|
39
41
|
def listen
|
40
|
-
|
41
|
-
|
42
|
-
|
42
|
+
raise "Cannot listen -- already listening." if listening?
|
43
|
+
@listening = true
|
44
|
+
http_server.listen(:address => address, :port => port, :handlers => @routes.keys, :protocols => protocols)
|
43
45
|
end
|
44
46
|
|
45
47
|
def unlisten
|
46
|
-
|
47
|
-
|
48
|
-
|
48
|
+
raise "Cannot unlisten -- not currently listening." unless listening?
|
49
|
+
http_server.unlisten
|
50
|
+
@listening = false
|
49
51
|
end
|
50
52
|
|
51
53
|
def http_server_class
|
@@ -49,6 +49,11 @@ module Puppet::Network
|
|
49
49
|
self.recycle_connection
|
50
50
|
retry
|
51
51
|
end
|
52
|
+
["certificate verify failed", "hostname was not match", "hostname not match"].each do |str|
|
53
|
+
if detail.message.include?(str)
|
54
|
+
Puppet.warning "Certificate validation failed; considering using the certname configuration option"
|
55
|
+
end
|
56
|
+
end
|
52
57
|
raise XMLRPCClientError,
|
53
58
|
"Certificates were not trusted: %s" % detail
|
54
59
|
rescue ::XMLRPC::FaultException => detail
|
@@ -118,7 +123,7 @@ module Puppet::Network
|
|
118
123
|
nil, # user
|
119
124
|
nil, # password
|
120
125
|
true, # use_ssl
|
121
|
-
|
126
|
+
Puppet[:configtimeout] # use configured timeout (#1176)
|
122
127
|
)
|
123
128
|
@http = Puppet::Network::HttpPool.http_instance(@host, @port)
|
124
129
|
end
|
data/lib/puppet/node.rb
CHANGED
@@ -13,85 +13,7 @@ class Puppet::Node
|
|
13
13
|
indirects :node, :terminus_setting => :node_terminus, :doc => "Where to find node information.
|
14
14
|
A node is composed of its name, its facts, and its environment."
|
15
15
|
|
16
|
-
|
17
|
-
# thrown in for kicks.
|
18
|
-
def self.find_by_any_name(key)
|
19
|
-
return nil unless key
|
20
|
-
|
21
|
-
facts = node_facts(key)
|
22
|
-
node = nil
|
23
|
-
names = node_names(key, facts)
|
24
|
-
names.each do |name|
|
25
|
-
name = name.to_s if name.is_a?(Symbol)
|
26
|
-
break if node = find(name)
|
27
|
-
end
|
28
|
-
|
29
|
-
# If they made it this far, we haven't found anything, so look for a
|
30
|
-
# default node.
|
31
|
-
unless node or names.include?("default")
|
32
|
-
if node = find("default")
|
33
|
-
Puppet.notice "Using default node for %s" % key
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
if node
|
38
|
-
node.names = names
|
39
|
-
|
40
|
-
return node
|
41
|
-
else
|
42
|
-
return nil
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
private
|
47
|
-
|
48
|
-
# Look up the node facts so we can generate the node names to use.
|
49
|
-
def self.node_facts(key)
|
50
|
-
if facts = Puppet::Node::Facts.find(key)
|
51
|
-
facts.values
|
52
|
-
else
|
53
|
-
{}
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
# Calculate the list of node names we should use for looking
|
58
|
-
# up our node.
|
59
|
-
def self.node_names(key, facts = nil)
|
60
|
-
facts ||= node_facts(key)
|
61
|
-
names = []
|
62
|
-
|
63
|
-
if hostname = facts["hostname"]
|
64
|
-
unless hostname == key
|
65
|
-
names << hostname
|
66
|
-
end
|
67
|
-
else
|
68
|
-
hostname = key
|
69
|
-
end
|
70
|
-
|
71
|
-
if fqdn = facts["fqdn"]
|
72
|
-
hostname = fqdn
|
73
|
-
names << fqdn
|
74
|
-
end
|
75
|
-
|
76
|
-
# Make sure both the fqdn and the short name of the
|
77
|
-
# host can be used in the manifest
|
78
|
-
if hostname =~ /\./
|
79
|
-
names << hostname.sub(/\..+/,'')
|
80
|
-
elsif domain = facts['domain']
|
81
|
-
names << hostname + "." + domain
|
82
|
-
end
|
83
|
-
|
84
|
-
# Sort the names inversely by name length.
|
85
|
-
names.sort! { |a,b| b.length <=> a.length }
|
86
|
-
|
87
|
-
# And make sure the key is first, since that's the most
|
88
|
-
# likely usage.
|
89
|
-
([key] + names).uniq
|
90
|
-
end
|
91
|
-
|
92
|
-
public
|
93
|
-
|
94
|
-
attr_accessor :name, :classes, :parameters, :source, :ipaddress, :names
|
16
|
+
attr_accessor :name, :classes, :parameters, :source, :ipaddress
|
95
17
|
attr_reader :time
|
96
18
|
|
97
19
|
# Set the environment, making sure that it's valid.
|
@@ -153,6 +75,8 @@ class Puppet::Node
|
|
153
75
|
def fact_merge
|
154
76
|
if facts = Puppet::Node::Facts.find(name)
|
155
77
|
merge(facts.values)
|
78
|
+
else
|
79
|
+
Puppet.warning "Could not find facts for %s; you probably have a discrepancy between the node and fact names" % name
|
156
80
|
end
|
157
81
|
end
|
158
82
|
|
@@ -162,4 +86,39 @@ class Puppet::Node
|
|
162
86
|
@parameters[name] = value unless @parameters.include?(name)
|
163
87
|
end
|
164
88
|
end
|
89
|
+
|
90
|
+
# Calculate the list of names we might use for looking
|
91
|
+
# up our node. This is only used for AST nodes.
|
92
|
+
def names
|
93
|
+
names = []
|
94
|
+
|
95
|
+
# First, get the fqdn
|
96
|
+
unless fqdn = parameters["fqdn"]
|
97
|
+
if domain = parameters["domain"]
|
98
|
+
fqdn = parameters["hostname"] + "." + parameters["domain"]
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
# Now that we (might) have the fqdn, add each piece to the name
|
103
|
+
# list to search, in order of longest to shortest.
|
104
|
+
if fqdn
|
105
|
+
list = fqdn.split(".")
|
106
|
+
tmp = []
|
107
|
+
list.each_with_index do |short, i|
|
108
|
+
tmp << list[0..i].join(".")
|
109
|
+
end
|
110
|
+
names += tmp.reverse
|
111
|
+
end
|
112
|
+
|
113
|
+
# And make sure the node name is first, since that's the most
|
114
|
+
# likely usage.
|
115
|
+
# The name is usually the Certificate CN, but it can be
|
116
|
+
# set to the 'facter' hostname instead.
|
117
|
+
if Puppet[:node_name] == 'cert'
|
118
|
+
names.unshift name
|
119
|
+
else
|
120
|
+
names.unshift parameters["hostname"]
|
121
|
+
end
|
122
|
+
names.uniq
|
123
|
+
end
|
165
124
|
end
|
data/lib/puppet/node/catalog.rb
CHANGED
@@ -88,6 +88,12 @@ class Puppet::Node::Catalog < Puppet::PGraph
|
|
88
88
|
resource.ref =~ /^(.+)\[/
|
89
89
|
|
90
90
|
newref = "%s[%s]" % [$1 || resource.class.name, name]
|
91
|
+
|
92
|
+
# LAK:NOTE It's important that we directly compare the references,
|
93
|
+
# because sometimes an alias is created before the resource is
|
94
|
+
# added to the catalog, so comparing inside the below if block
|
95
|
+
# isn't sufficient.
|
96
|
+
return if newref == resource.ref
|
91
97
|
if existing = @resource_table[newref]
|
92
98
|
return if existing == resource
|
93
99
|
raise(ArgumentError, "Cannot alias %s to %s; resource %s already exists" % [resource.ref, name, newref])
|
@@ -483,6 +489,9 @@ class Puppet::Node::Catalog < Puppet::PGraph
|
|
483
489
|
if resource.is_a?(Puppet::TransObject)
|
484
490
|
resource = resource.dup
|
485
491
|
resource.catalog = result
|
492
|
+
elsif resource.is_a?(Puppet::Parser::Resource)
|
493
|
+
resource = resource.to_transobject
|
494
|
+
resource.catalog = result
|
486
495
|
end
|
487
496
|
|
488
497
|
newres = resource.send(convert)
|
data/lib/puppet/node/facts.rb
CHANGED
@@ -8,8 +8,16 @@ class Puppet::Node::Facts
|
|
8
8
|
# the node sources.
|
9
9
|
extend Puppet::Indirector
|
10
10
|
|
11
|
+
# We want to expire any cached nodes if the facts are saved.
|
12
|
+
module NodeExpirer
|
13
|
+
def save(instance, *args)
|
14
|
+
Puppet::Node.expire(instance.name)
|
15
|
+
super
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
11
19
|
# Use the node source as the indirection terminus.
|
12
|
-
indirects :facts, :terminus_class => :facter
|
20
|
+
indirects :facts, :terminus_class => :facter, :extend => NodeExpirer
|
13
21
|
|
14
22
|
attr_accessor :name, :values
|
15
23
|
|
@@ -6,6 +6,12 @@ class Puppet::Parser::Collector
|
|
6
6
|
# Call the collection method, mark all of the returned objects as non-virtual,
|
7
7
|
# and then delete this object from the list of collections to evaluate.
|
8
8
|
def evaluate
|
9
|
+
# Shortcut if we're not using storeconfigs and they're trying to collect
|
10
|
+
# exported resources.
|
11
|
+
if form == :exported and Puppet[:storeconfigs] != true
|
12
|
+
Puppet.warning "Not collecting exported resources without storeconfigs"
|
13
|
+
return false
|
14
|
+
end
|
9
15
|
if self.resources
|
10
16
|
if objects = collect_resources and ! objects.empty?
|
11
17
|
return objects
|
@@ -332,7 +332,7 @@ class Puppet::Parser::Compiler
|
|
332
332
|
|
333
333
|
unless remaining.empty?
|
334
334
|
fail Puppet::ParseError,
|
335
|
-
"Could not find
|
335
|
+
"Could not find resource(s) %s for overriding" % remaining.collect { |o|
|
336
336
|
o.ref
|
337
337
|
}.join(", ")
|
338
338
|
end
|
@@ -165,7 +165,7 @@ module Functions
|
|
165
165
|
type is defined, either as a native type or a defined type, or whether a class is defined.
|
166
166
|
This is useful for checking whether a class is defined and only including it if it is.
|
167
167
|
This function can also test whether a resource has been defined, using resource references
|
168
|
-
(e.g., ``if defined(File['/tmp/myfile'] { ... }``). This function is unfortunately
|
168
|
+
(e.g., ``if defined(File['/tmp/myfile']) { ... }``). This function is unfortunately
|
169
169
|
dependent on the parse order of the configuration when testing whether a resource is defined.") do |vals|
|
170
170
|
result = false
|
171
171
|
vals.each do |val|
|
@@ -188,6 +188,22 @@ module Functions
|
|
188
188
|
result
|
189
189
|
end
|
190
190
|
|
191
|
+
newfunction(:fqdn_rand, :type => :rvalue, :doc => "Generates random
|
192
|
+
numbers based on the node's fqdn. The first argument sets the range.
|
193
|
+
The second argument specifies a number to add to the seed and is
|
194
|
+
optional.") do |args|
|
195
|
+
require 'md5'
|
196
|
+
max = args[0]
|
197
|
+
if args[1] then
|
198
|
+
seed = args[1]
|
199
|
+
else
|
200
|
+
seed = 1
|
201
|
+
end
|
202
|
+
fqdn_seed = MD5.new(lookupvar('fqdn')).to_s.hex
|
203
|
+
srand(seed+fqdn_seed)
|
204
|
+
rand(max).to_s
|
205
|
+
end
|
206
|
+
|
191
207
|
newfunction(:fail, :doc => "Fail with a parse error.") do |vals|
|
192
208
|
vals = vals.collect { |s| s.to_s }.join(" ") if vals.is_a? Array
|
193
209
|
raise Puppet::ParseError, vals.to_s
|
@@ -301,6 +317,14 @@ module Functions
|
|
301
317
|
end
|
302
318
|
output
|
303
319
|
end
|
320
|
+
|
321
|
+
newfunction(:sha1, :type => :rvalue,
|
322
|
+
:doc => "Returns a SHA1 hash value from a provided string.") do |args|
|
323
|
+
require 'sha1'
|
324
|
+
|
325
|
+
Digest::SHA1.hexdigest(args[0])
|
326
|
+
end
|
327
|
+
|
304
328
|
end
|
305
329
|
end
|
306
330
|
|
@@ -50,23 +50,8 @@ class Puppet::Parser::Interpreter
|
|
50
50
|
# Return the parser for a specific environment.
|
51
51
|
def parser(environment)
|
52
52
|
if ! @parsers[environment] or @parsers[environment].reparse?
|
53
|
-
# This will throw an exception if it does not succeed.
|
54
|
-
|
55
|
-
# one.
|
56
|
-
begin
|
57
|
-
tmp = create_parser(environment)
|
58
|
-
@parsers[environment].clear if @parsers[environment]
|
59
|
-
@parsers[environment] = tmp
|
60
|
-
rescue => detail
|
61
|
-
# If a parser already exists, than assume that we logged the
|
62
|
-
# exception elsewhere and reuse the parser. If one doesn't
|
63
|
-
# exist, then reraise.
|
64
|
-
if @parsers[environment]
|
65
|
-
Puppet.err detail
|
66
|
-
else
|
67
|
-
raise detail
|
68
|
-
end
|
69
|
-
end
|
53
|
+
# This will throw an exception if it does not succeed.
|
54
|
+
@parsers[environment] = create_parser(environment)
|
70
55
|
end
|
71
56
|
@parsers[environment]
|
72
57
|
end
|
data/lib/puppet/parser/parser.rb
CHANGED
@@ -29,7 +29,7 @@ module Puppet
|
|
29
29
|
|
30
30
|
class Parser < Racc::Parser
|
31
31
|
|
32
|
-
module_eval <<'..end grammar.ra modeval..
|
32
|
+
module_eval <<'..end grammar.ra modeval..id9145566289', 'grammar.ra', 638
|
33
33
|
|
34
34
|
# It got too annoying having code in a file that needs to be compiled.
|
35
35
|
require 'puppet/parser/parser_support'
|
@@ -41,7 +41,7 @@ require 'puppet/parser/parser_support'
|
|
41
41
|
|
42
42
|
# $Id$
|
43
43
|
|
44
|
-
..end grammar.ra modeval..
|
44
|
+
..end grammar.ra modeval..id9145566289
|
45
45
|
|
46
46
|
##### racc 1.4.5 generates ###
|
47
47
|
|
@@ -958,7 +958,7 @@ module_eval <<'.,.,', 'grammar.ra', 174
|
|
958
958
|
type = val[0]
|
959
959
|
|
960
960
|
if (type == :exported and ! Puppet[:storeconfigs]) and ! Puppet[:parseonly]
|
961
|
-
|
961
|
+
Puppet.warning addcontext("You cannot collect without storeconfigs being set")
|
962
962
|
end
|
963
963
|
|
964
964
|
if val[1].is_a? AST::ResourceDefaults
|
@@ -1011,7 +1011,7 @@ module_eval <<'.,.,', 'grammar.ra', 199
|
|
1011
1011
|
args[:form] = val[1]
|
1012
1012
|
end
|
1013
1013
|
if args[:form] == :exported and ! Puppet[:storeconfigs] and ! Puppet[:parseonly]
|
1014
|
-
|
1014
|
+
Puppet.warning addcontext("You cannot collect exported resources without storeconfigs being set; the collection will be ignored")
|
1015
1015
|
end
|
1016
1016
|
result = ast AST::Collection, args
|
1017
1017
|
result
|
@@ -237,7 +237,9 @@ class Puppet::Parser::Parser
|
|
237
237
|
end
|
238
238
|
end
|
239
239
|
|
240
|
-
|
240
|
+
# We don't know whether we're looking for a class or definition, so we have
|
241
|
+
# to test for both.
|
242
|
+
return true if classes.include?(classname) || definitions.include?(classname)
|
241
243
|
|
242
244
|
unless @loaded.include?(filename)
|
243
245
|
@loaded << filename
|
@@ -249,7 +251,9 @@ class Puppet::Parser::Parser
|
|
249
251
|
# We couldn't load the file
|
250
252
|
end
|
251
253
|
end
|
252
|
-
|
254
|
+
# We don't know whether we're looking for a class or definition, so we have
|
255
|
+
# to test for both.
|
256
|
+
return classes.include?(classname) || definitions.include?(classname)
|
253
257
|
end
|
254
258
|
|
255
259
|
# Split an fq name into a namespace and name
|
@@ -303,6 +303,12 @@ class Puppet::Parser::Resource
|
|
303
303
|
return bucket
|
304
304
|
end
|
305
305
|
|
306
|
+
# Convert this resource to a RAL resource. We hackishly go via the
|
307
|
+
# transportable stuff.
|
308
|
+
def to_type
|
309
|
+
to_trans.to_type
|
310
|
+
end
|
311
|
+
|
306
312
|
def to_transobject
|
307
313
|
# Now convert to a transobject
|
308
314
|
obj = Puppet::TransObject.new(@ref.title, @ref.type)
|