puppet 0.24.5 → 0.24.6
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 +206 -0
- data/Rakefile +53 -0
- data/bin/filebucket +0 -0
- data/bin/puppet +32 -11
- data/bin/puppetca +1 -0
- data/bin/puppetd +0 -0
- data/bin/puppetdoc +0 -0
- data/bin/puppetmasterd +0 -0
- data/bin/puppetrun +16 -8
- data/bin/ralsh +0 -0
- data/conf/debian/rules +0 -0
- data/conf/gentoo/init.d/puppetmaster +0 -0
- data/conf/osx/PackageInfo.plist +36 -0
- data/conf/osx/createpackage.sh +167 -0
- data/conf/osx/preflight +12 -0
- data/conf/redhat/client.init +1 -1
- data/conf/redhat/puppet.spec +34 -6
- data/conf/redhat/server.init +42 -7
- data/conf/redhat/server.sysconfig +22 -0
- data/conf/solaris/smf/svc-puppetd +0 -0
- data/conf/solaris/smf/svc-puppetmasterd +0 -0
- data/examples/etc/init.d/sleeper +0 -0
- data/examples/mac_dscl.pp +0 -0
- data/examples/mac_dscl_revert.pp +0 -0
- data/examples/mac_netinfo.pp +0 -0
- data/examples/mac_pkgdmg.pp +0 -0
- data/ext/bin/sleeper +0 -0
- data/ext/module_puppet +0 -0
- data/ext/nagios/check_puppet.rb +0 -0
- data/ext/passenger/README +63 -0
- data/ext/passenger/apache2.conf +29 -0
- data/ext/passenger/config.ru +40 -0
- data/ext/puppet-test +0 -0
- data/ext/puppetlast +6 -31
- data/ext/puppetstoredconfigclean.rb +87 -0
- data/install.rb +75 -20
- data/lib/puppet.rb +1 -1
- data/lib/puppet/daemon.rb +0 -0
- data/lib/puppet/defaults.rb +3 -7
- data/lib/puppet/external/base64.rb +0 -0
- data/lib/puppet/external/nagios.rb +0 -0
- data/lib/puppet/external/nagios/base.rb +0 -0
- data/lib/puppet/file_serving/fileset.rb +2 -2
- data/lib/puppet/file_serving/metadata.rb +3 -3
- data/lib/puppet/indirector/facts/facter.rb +3 -2
- data/lib/puppet/indirector/yaml.rb +10 -1
- data/lib/puppet/module.rb +36 -12
- data/lib/puppet/network/authstore.rb +0 -0
- data/lib/puppet/network/client/master.rb +12 -11
- data/lib/puppet/network/handler/filebucket.rb +0 -0
- data/lib/puppet/network/handler/fileserver.rb +38 -46
- data/lib/puppet/network/handler/master.rb +1 -1
- data/lib/puppet/network/handler/report.rb +0 -0
- data/lib/puppet/network/handler/resource.rb +0 -0
- data/lib/puppet/network/handler/runner.rb +0 -0
- data/lib/puppet/network/http_server/rack.rb +148 -0
- data/lib/puppet/network/rights.rb +0 -0
- data/lib/puppet/network/xmlrpc/client.rb +5 -5
- data/lib/puppet/node.rb +5 -9
- data/lib/puppet/node/environment.rb +1 -17
- data/lib/puppet/node/facts.rb +0 -0
- data/lib/puppet/parameter.rb +1 -28
- data/lib/puppet/parser/ast.rb +6 -0
- data/lib/puppet/parser/ast/arithmetic_operator.rb +41 -0
- data/lib/puppet/parser/ast/boolean_operator.rb +48 -0
- data/lib/puppet/parser/ast/collexpr.rb +6 -1
- data/lib/puppet/parser/ast/comparison_operator.rb +37 -0
- data/lib/puppet/parser/ast/minus.rb +23 -0
- data/lib/puppet/parser/ast/nop.rb +11 -0
- data/lib/puppet/parser/ast/not.rb +19 -0
- data/lib/puppet/parser/ast/resource_override.rb +23 -16
- data/lib/puppet/parser/ast/resource_reference.rb +10 -6
- data/lib/puppet/parser/ast/vardef.rb +2 -2
- data/lib/puppet/parser/collector.rb +2 -1
- data/lib/puppet/parser/functions.rb +7 -217
- data/lib/puppet/parser/functions/defined.rb +27 -0
- data/lib/puppet/parser/functions/fail.rb +4 -0
- data/lib/puppet/parser/functions/file.rb +21 -0
- data/lib/puppet/parser/functions/fqdn_rand.rb +15 -0
- data/lib/puppet/parser/functions/generate.rb +35 -0
- data/lib/puppet/parser/functions/include.rb +26 -0
- data/lib/puppet/parser/functions/realize.rb +14 -0
- data/lib/puppet/parser/functions/search.rb +7 -0
- data/lib/puppet/parser/functions/sha1.rb +6 -0
- data/lib/puppet/parser/functions/tag.rb +6 -0
- data/lib/puppet/parser/functions/tagged.rb +18 -0
- data/lib/puppet/parser/functions/template.rb +22 -0
- data/lib/puppet/parser/lexer.rb +15 -5
- data/lib/puppet/parser/parser.rb +1073 -715
- data/lib/puppet/parser/parser_support.rb +18 -13
- data/lib/puppet/parser/resource.rb +1 -1
- data/lib/puppet/parser/resource/param.rb +10 -2
- data/lib/puppet/parser/scope.rb +63 -5
- data/lib/puppet/parser/templatewrapper.rb +61 -15
- data/lib/puppet/property.rb +7 -1
- data/lib/puppet/property/keyvalue.rb +96 -0
- data/lib/puppet/property/list.rb +78 -0
- data/lib/puppet/provider/confine.rb +1 -1
- data/lib/puppet/provider/confine/variable.rb +10 -1
- data/lib/puppet/provider/cron/crontab.rb +0 -0
- data/lib/puppet/provider/mailalias/aliases.rb +0 -0
- data/lib/puppet/provider/maillist/mailman.rb +0 -0
- data/lib/puppet/provider/mount/parsed.rb +0 -0
- data/lib/puppet/provider/nameservice.rb +24 -39
- data/lib/puppet/provider/nameservice/directoryservice.rb +12 -3
- data/lib/puppet/provider/nameservice/netinfo.rb +12 -2
- data/lib/puppet/provider/nameservice/objectadd.rb +1 -10
- data/lib/puppet/provider/package/appdmg.rb +1 -1
- data/lib/puppet/provider/package/apple.rb +0 -0
- data/lib/puppet/provider/package/apt.rb +14 -21
- data/lib/puppet/provider/package/aptitude.rb +0 -0
- data/lib/puppet/provider/package/blastwave.rb +2 -0
- data/lib/puppet/provider/package/darwinport.rb +0 -0
- data/lib/puppet/provider/package/dpkg.rb +33 -51
- data/lib/puppet/provider/package/fink.rb +1 -1
- data/lib/puppet/provider/package/freebsd.rb +0 -0
- data/lib/puppet/provider/package/gem.rb +0 -0
- data/lib/puppet/provider/package/hpux.rb +46 -0
- data/lib/puppet/provider/package/openbsd.rb +0 -0
- data/lib/puppet/provider/package/pkgdmg.rb +1 -1
- data/lib/puppet/provider/package/portage.rb +3 -1
- data/lib/puppet/provider/package/ports.rb +3 -3
- data/lib/puppet/provider/package/rpm.rb +8 -1
- data/lib/puppet/provider/package/rug.rb +2 -2
- data/lib/puppet/provider/package/sun.rb +2 -0
- data/lib/puppet/provider/package/sunfreeware.rb +3 -0
- data/lib/puppet/provider/package/yum.rb +24 -17
- data/lib/puppet/provider/package/yumhelper.py +92 -11
- data/lib/puppet/provider/parsedfile.rb +0 -0
- data/lib/puppet/provider/port/parsed.rb +0 -0
- data/lib/puppet/provider/selboolean/getsetsebool.rb +47 -0
- data/lib/puppet/provider/selmodule/semodule.rb +143 -0
- data/lib/puppet/provider/service/base.rb +0 -0
- data/lib/puppet/provider/service/daemontools.rb +154 -0
- data/lib/puppet/provider/service/debian.rb +1 -1
- data/lib/puppet/provider/service/freebsd.rb +2 -0
- data/lib/puppet/provider/service/gentoo.rb +2 -0
- data/lib/puppet/provider/service/init.rb +0 -0
- data/lib/puppet/provider/service/redhat.rb +1 -1
- data/lib/puppet/provider/service/runit.rb +93 -0
- data/lib/puppet/provider/service/smf.rb +2 -0
- data/lib/puppet/provider/ssh_authorized_key/parsed.rb +7 -1
- data/lib/puppet/provider/sshkey/parsed.rb +0 -0
- data/lib/puppet/provider/user/hpux.rb +30 -0
- data/lib/puppet/provider/user/user_role_add.rb +156 -0
- data/lib/puppet/provider/user/useradd.rb +23 -14
- data/lib/puppet/rails/database/002_remove_duplicated_index_on_all_tables.rb +17 -0
- data/lib/puppet/rails/database/schema.rb +0 -8
- data/lib/puppet/rails/resource.rb +6 -6
- data/lib/puppet/reference/configuration.rb +0 -7
- data/lib/puppet/reports.rb +0 -0
- data/lib/puppet/reports/rrdgraph.rb +3 -2
- data/lib/puppet/sslcertificates.rb +0 -0
- data/lib/puppet/sslcertificates/inventory.rb +3 -2
- data/lib/puppet/sslcertificates/support.rb +3 -0
- data/lib/puppet/transaction/report.rb +1 -7
- data/lib/puppet/transportable.rb +10 -7
- data/lib/puppet/type.rb +2110 -14
- data/lib/puppet/type/cron.rb +0 -0
- data/lib/puppet/type/exec.rb +0 -0
- data/lib/puppet/type/file.rb +12 -2
- data/lib/puppet/type/file/checksum.rb +4 -0
- data/lib/puppet/type/file/content.rb +0 -0
- data/lib/puppet/type/file/ensure.rb +0 -0
- data/lib/puppet/type/file/group.rb +30 -43
- data/lib/puppet/type/file/mode.rb +0 -0
- data/lib/puppet/type/file/owner.rb +0 -0
- data/lib/puppet/type/file/selcontext.rb +104 -0
- data/lib/puppet/type/file/source.rb +0 -0
- data/lib/puppet/type/file/type.rb +0 -0
- data/lib/puppet/type/filebucket.rb +0 -0
- data/lib/puppet/type/group.rb +0 -8
- data/lib/puppet/type/host.rb +0 -0
- data/lib/puppet/type/mailalias.rb +0 -0
- data/lib/puppet/type/maillist.rb +0 -0
- data/lib/puppet/type/mount.rb +0 -0
- data/lib/puppet/type/package.rb +2 -2
- data/lib/puppet/type/port.rb +0 -0
- data/lib/puppet/type/schedule.rb +0 -0
- data/lib/puppet/type/selboolean.rb +31 -0
- data/lib/puppet/type/selmodule.rb +54 -0
- data/lib/puppet/type/ssh_authorized_key.rb +3 -3
- data/lib/puppet/type/sshkey.rb +0 -0
- data/lib/puppet/type/tidy.rb +0 -0
- data/lib/puppet/type/user.rb +153 -137
- data/lib/puppet/type/yumrepo.rb +18 -2
- data/lib/puppet/type/zone.rb +5 -1
- data/lib/puppet/util.rb +7 -7
- data/lib/puppet/util/filetype.rb +7 -0
- data/lib/puppet/util/instance_loader.rb +0 -0
- data/lib/puppet/util/ldap/connection.rb +11 -1
- data/lib/puppet/util/ldap/manager.rb +1 -1
- data/lib/puppet/util/loadedfile.rb +0 -0
- data/lib/puppet/util/log.rb +42 -43
- data/lib/puppet/util/metric.rb +23 -9
- data/lib/puppet/util/posix.rb +69 -18
- data/lib/puppet/util/selinux.rb +139 -0
- data/lib/puppet/util/settings.rb +5 -7
- data/lib/puppet/util/user_attr.rb +21 -0
- data/test/certmgr/ca.rb +0 -0
- data/test/certmgr/certmgr.rb +0 -0
- data/test/certmgr/inventory.rb +0 -0
- data/test/certmgr/support.rb +0 -0
- data/test/data/providers/ssh_authorized_key/parsed/authorized_keys1 +3 -0
- data/test/data/snippets/append.pp +11 -0
- data/test/data/snippets/arithmetic_expression.pp +8 -0
- data/test/data/snippets/arraytrailingcomma.pp +3 -0
- data/test/data/snippets/emptyifelse.pp +9 -0
- data/test/data/snippets/funccomma.pp +5 -0
- data/test/data/snippets/ifexpression.rb +6 -0
- data/test/data/snippets/subclass_name_duplication.pp +0 -0
- data/test/executables/filebucket.rb +0 -0
- data/test/executables/puppetbin.rb +0 -0
- data/test/executables/puppetca.rb +0 -0
- data/test/executables/puppetd.rb +0 -0
- data/test/executables/puppetmasterd.rb +0 -0
- data/test/executables/puppetmodule.rb +0 -0
- data/test/language/ast.rb +0 -0
- data/test/language/ast/casestatement.rb +0 -0
- data/test/language/ast/resource.rb +0 -0
- data/test/language/ast/resource_reference.rb +0 -28
- data/test/language/ast/selector.rb +0 -0
- data/test/language/ast/variable.rb +0 -0
- data/test/language/functions.rb +91 -12
- data/test/language/parser.rb +21 -0
- data/test/language/resource.rb +0 -0
- data/test/language/scope.rb +28 -0
- data/test/language/snippets.rb +14 -0
- data/test/language/transportable.rb +0 -0
- data/test/lib/puppettest.rb +0 -0
- data/test/lib/puppettest/reporttesting.rb +0 -2
- data/test/lib/puppettest/runnable_test.rb +2 -0
- data/test/lib/puppettest/support/resources.rb +0 -0
- data/test/network/authconfig.rb +0 -0
- data/test/network/authorization.rb +0 -0
- data/test/network/authstore.rb +0 -0
- data/test/network/client/ca.rb +0 -0
- data/test/network/client/client.rb +0 -0
- data/test/network/client/dipper.rb +0 -0
- data/test/network/client/master.rb +2 -6
- data/test/network/client/resource.rb +0 -0
- data/test/network/client_request.rb +0 -0
- data/test/network/daemon.rb +0 -0
- data/test/network/handler/bucket.rb +0 -0
- data/test/network/handler/ca.rb +0 -0
- data/test/network/handler/fileserver.rb +8 -0
- data/test/network/handler/handler.rb +0 -0
- data/test/network/handler/master.rb +3 -1
- data/test/network/handler/report.rb +0 -0
- data/test/network/handler/resource.rb +0 -0
- data/test/network/handler/runner.rb +0 -0
- data/test/network/rights.rb +0 -0
- data/test/network/server/mongrel_test.rb +0 -0
- data/test/network/server/webrick.rb +0 -0
- data/test/network/xmlrpc/client.rb +0 -0
- data/test/network/xmlrpc/processor.rb +0 -0
- data/test/network/xmlrpc/server.rb +0 -0
- data/test/network/xmlrpc/webrick_servlet.rb +0 -0
- data/test/other/dsl.rb +0 -0
- data/test/other/events.rb +0 -0
- data/test/other/overrides.rb +0 -0
- data/test/other/provider.rb +0 -0
- data/test/other/puppet.rb +0 -0
- data/test/other/relationships.rb +0 -0
- data/test/other/report.rb +2 -4
- data/test/other/transactions.rb +1 -1
- data/test/puppet/conffiles.rb +0 -0
- data/test/puppet/defaults.rb +0 -0
- data/test/puppet/errortest.rb +0 -0
- data/test/puppet/tc_suidmanager.rb +0 -0
- data/test/rails/ast.rb +0 -0
- data/test/rails/configuration.rb +0 -0
- data/test/rails/host.rb +0 -0
- data/test/rails/rails.rb +0 -0
- data/test/rails/railsparameter.rb +0 -0
- data/test/rails/railsresource.rb +0 -0
- data/test/ral/manager/attributes.rb +0 -0
- data/test/ral/manager/instances.rb +0 -0
- data/test/ral/manager/manager.rb +0 -0
- data/test/ral/manager/provider.rb +0 -0
- data/test/ral/manager/type.rb +0 -0
- data/test/ral/providers/cron/crontab.rb +0 -0
- data/test/ral/providers/group.rb +14 -13
- data/test/ral/providers/host/netinfo.rb +0 -0
- data/test/ral/providers/host/parsed.rb +0 -0
- data/test/ral/providers/mailalias/aliases.rb +0 -0
- data/test/ral/providers/mount/netinfo.rb +0 -0
- data/test/ral/providers/nameservice.rb +0 -0
- data/test/ral/providers/package.rb +0 -31
- data/test/ral/providers/package/aptitude.rb +1 -2
- data/test/ral/providers/package/aptrpm.rb +2 -2
- data/test/ral/providers/parsedfile.rb +0 -0
- data/test/ral/providers/port/parsed.rb +0 -0
- data/test/ral/providers/provider.rb +0 -0
- data/test/ral/providers/service/base.rb +0 -0
- data/test/ral/providers/service/debian.rb +0 -0
- data/test/ral/providers/sshkey/parsed.rb +0 -0
- data/test/ral/providers/user.rb +8 -8
- data/test/ral/providers/user/useradd.rb +0 -0
- data/test/ral/type/basic.rb +0 -0
- data/test/ral/type/cron.rb +0 -0
- data/test/ral/type/exec.rb +0 -0
- data/test/ral/type/file.rb +0 -0
- data/test/ral/type/file/target.rb +0 -0
- data/test/ral/type/filebucket.rb +0 -0
- data/test/ral/type/fileignoresource.rb +0 -0
- data/test/ral/type/filesources.rb +1 -3
- data/test/ral/type/group.rb +0 -0
- data/test/ral/type/host.rb +0 -0
- data/test/ral/type/mailalias.rb +1 -2
- data/test/ral/type/parameter.rb +0 -0
- data/test/ral/type/port.rb +0 -0
- data/test/ral/type/property.rb +0 -0
- data/test/ral/type/resources.rb +0 -0
- data/test/ral/type/service.rb +0 -0
- data/test/ral/type/sshkey.rb +0 -0
- data/test/ral/type/tidy.rb +0 -0
- data/test/ral/type/user.rb +0 -50
- data/test/ral/type/yumrepo.rb +7 -1
- data/test/ral/type/zone.rb +0 -0
- data/test/test +0 -0
- data/test/util/autoload.rb +0 -0
- data/test/util/classgen.rb +0 -0
- data/test/util/execution.rb +0 -0
- data/test/util/features.rb +0 -0
- data/test/util/fileparsing.rb +0 -0
- data/test/util/filetype.rb +0 -0
- data/test/util/inifile.rb +0 -0
- data/test/util/instance_loader.rb +0 -0
- data/test/util/log.rb +0 -59
- data/test/util/metrics.rb +0 -0
- data/test/util/package.rb +0 -0
- data/test/util/pidlock.rb +0 -0
- data/test/util/settings.rb +0 -0
- data/test/util/storage.rb +0 -0
- data/test/util/subclass_loader.rb +0 -0
- data/test/util/utiltest.rb +0 -0
- metadata +54 -19
- data/lib/puppet/metatype/attributes.rb +0 -685
- data/lib/puppet/metatype/closure.rb +0 -49
- data/lib/puppet/metatype/container.rb +0 -50
- data/lib/puppet/metatype/evaluation.rb +0 -163
- data/lib/puppet/metatype/instances.rb +0 -305
- data/lib/puppet/metatype/metaparams.rb +0 -423
- data/lib/puppet/metatype/providers.rb +0 -247
- data/lib/puppet/metatype/relationships.rb +0 -115
- data/lib/puppet/metatype/schedules.rb +0 -33
- data/lib/puppet/metatype/tags.rb +0 -38
- data/lib/puppet/util/plist.rb +0 -23
- data/lib/puppet/util/plist/generator.rb +0 -225
- data/lib/puppet/util/plist/parser.rb +0 -226
- data/test/ral/providers/package/apt.rb +0 -169
- data/test/ral/providers/package/dpkg.rb +0 -64
- data/test/util/posixtest.rb +0 -169
@@ -1,423 +0,0 @@
|
|
1
|
-
require 'puppet'
|
2
|
-
require 'puppet/type'
|
3
|
-
|
4
|
-
class Puppet::Type
|
5
|
-
# Add all of the meta parameters.
|
6
|
-
#newmetaparam(:onerror) do
|
7
|
-
# desc "How to handle errors -- roll back innermost
|
8
|
-
# transaction, roll back entire transaction, ignore, etc. Currently
|
9
|
-
# non-functional."
|
10
|
-
#end
|
11
|
-
|
12
|
-
newmetaparam(:noop) do
|
13
|
-
desc "Boolean flag indicating whether work should actually
|
14
|
-
be done."
|
15
|
-
|
16
|
-
newvalues(:true, :false)
|
17
|
-
munge do |value|
|
18
|
-
case value
|
19
|
-
when true, :true, "true": @resource.noop = true
|
20
|
-
when false, :false, "false": @resource.noop = false
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
newmetaparam(:schedule) do
|
26
|
-
desc "On what schedule the object should be managed. You must create a
|
27
|
-
schedule object, and then reference the name of that object to use
|
28
|
-
that for your schedule::
|
29
|
-
|
30
|
-
schedule { daily:
|
31
|
-
period => daily,
|
32
|
-
range => \"2-4\"
|
33
|
-
}
|
34
|
-
|
35
|
-
exec { \"/usr/bin/apt-get update\":
|
36
|
-
schedule => daily
|
37
|
-
}
|
38
|
-
|
39
|
-
The creation of the schedule object does not need to appear in the
|
40
|
-
configuration before objects that use it."
|
41
|
-
end
|
42
|
-
|
43
|
-
newmetaparam(:check) do
|
44
|
-
desc "Propertys which should have their values retrieved
|
45
|
-
but which should not actually be modified. This is currently used
|
46
|
-
internally, but will eventually be used for querying, so that you
|
47
|
-
could specify that you wanted to check the install state of all
|
48
|
-
packages, and then query the Puppet client daemon to get reports
|
49
|
-
on all packages."
|
50
|
-
|
51
|
-
munge do |args|
|
52
|
-
# If they've specified all, collect all known properties
|
53
|
-
if args == :all
|
54
|
-
args = @resource.class.properties.find_all do |property|
|
55
|
-
# Only get properties supported by our provider
|
56
|
-
if @resource.provider
|
57
|
-
@resource.provider.class.supports_parameter?(property)
|
58
|
-
else
|
59
|
-
true
|
60
|
-
end
|
61
|
-
end.collect do |property|
|
62
|
-
property.name
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
unless args.is_a?(Array)
|
67
|
-
args = [args]
|
68
|
-
end
|
69
|
-
|
70
|
-
unless defined? @resource
|
71
|
-
self.devfail "No parent for %s, %s?" %
|
72
|
-
[self.class, self.name]
|
73
|
-
end
|
74
|
-
|
75
|
-
args.each { |property|
|
76
|
-
unless property.is_a?(Symbol)
|
77
|
-
property = property.intern
|
78
|
-
end
|
79
|
-
next if @resource.propertydefined?(property)
|
80
|
-
|
81
|
-
unless propertyklass = @resource.class.validproperty?(property)
|
82
|
-
if @resource.class.validattr?(property)
|
83
|
-
next
|
84
|
-
else
|
85
|
-
raise Puppet::Error, "%s is not a valid attribute for %s" %
|
86
|
-
[property, self.class.name]
|
87
|
-
end
|
88
|
-
end
|
89
|
-
next unless propertyklass.checkable?
|
90
|
-
@resource.newattr(property)
|
91
|
-
}
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
# We've got four relationship metaparameters, so this method is used
|
96
|
-
# to reduce code duplication between them.
|
97
|
-
def munge_relationship(param, values)
|
98
|
-
# We need to support values passed in as an array or as a
|
99
|
-
# resource reference.
|
100
|
-
result = []
|
101
|
-
|
102
|
-
# 'values' could be an array or a reference. If it's an array,
|
103
|
-
# it could be an array of references or an array of arrays.
|
104
|
-
if values.is_a?(Puppet::Type)
|
105
|
-
result << [values.class.name, values.title]
|
106
|
-
else
|
107
|
-
unless values.is_a?(Array)
|
108
|
-
devfail "Relationships must be resource references"
|
109
|
-
end
|
110
|
-
if values[0].is_a?(String) or values[0].is_a?(Symbol)
|
111
|
-
# we're a type/title array reference
|
112
|
-
values[0] = symbolize(values[0])
|
113
|
-
result << values
|
114
|
-
else
|
115
|
-
# we're an array of stuff
|
116
|
-
values.each do |value|
|
117
|
-
if value.is_a?(Puppet::Type)
|
118
|
-
result << [value.class.name, value.title]
|
119
|
-
elsif value.is_a?(Array)
|
120
|
-
value[0] = symbolize(value[0])
|
121
|
-
result << value
|
122
|
-
else
|
123
|
-
devfail "Invalid relationship %s" % value.inspect
|
124
|
-
end
|
125
|
-
end
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
if existing = self[param]
|
130
|
-
result = existing + result
|
131
|
-
end
|
132
|
-
|
133
|
-
result
|
134
|
-
end
|
135
|
-
|
136
|
-
newmetaparam(:loglevel) do
|
137
|
-
desc "Sets the level that information will be logged.
|
138
|
-
The log levels have the biggest impact when logs are sent to
|
139
|
-
syslog (which is currently the default)."
|
140
|
-
defaultto :notice
|
141
|
-
|
142
|
-
newvalues(*Puppet::Util::Log.levels)
|
143
|
-
newvalues(:verbose)
|
144
|
-
|
145
|
-
munge do |loglevel|
|
146
|
-
val = super(loglevel)
|
147
|
-
if val == :verbose
|
148
|
-
val = :info
|
149
|
-
end
|
150
|
-
val
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
newmetaparam(:alias) do
|
155
|
-
desc "Creates an alias for the object. Puppet uses this internally when you
|
156
|
-
provide a symbolic name::
|
157
|
-
|
158
|
-
file { sshdconfig:
|
159
|
-
path => $operatingsystem ? {
|
160
|
-
solaris => \"/usr/local/etc/ssh/sshd_config\",
|
161
|
-
default => \"/etc/ssh/sshd_config\"
|
162
|
-
},
|
163
|
-
source => \"...\"
|
164
|
-
}
|
165
|
-
|
166
|
-
service { sshd:
|
167
|
-
subscribe => file[sshdconfig]
|
168
|
-
}
|
169
|
-
|
170
|
-
When you use this feature, the parser sets ``sshdconfig`` as the name,
|
171
|
-
and the library sets that as an alias for the file so the dependency
|
172
|
-
lookup for ``sshd`` works. You can use this parameter yourself,
|
173
|
-
but note that only the library can use these aliases; for instance,
|
174
|
-
the following code will not work::
|
175
|
-
|
176
|
-
file { \"/etc/ssh/sshd_config\":
|
177
|
-
owner => root,
|
178
|
-
group => root,
|
179
|
-
alias => sshdconfig
|
180
|
-
}
|
181
|
-
|
182
|
-
file { sshdconfig:
|
183
|
-
mode => 644
|
184
|
-
}
|
185
|
-
|
186
|
-
There's no way here for the Puppet parser to know that these two stanzas
|
187
|
-
should be affecting the same file.
|
188
|
-
|
189
|
-
See the `LanguageTutorial language tutorial`:trac: for more information.
|
190
|
-
|
191
|
-
"
|
192
|
-
|
193
|
-
munge do |aliases|
|
194
|
-
unless aliases.is_a?(Array)
|
195
|
-
aliases = [aliases]
|
196
|
-
end
|
197
|
-
|
198
|
-
raise(ArgumentError, "Cannot add aliases without a catalog") unless @resource.catalog
|
199
|
-
|
200
|
-
@resource.info "Adding aliases %s" % aliases.collect { |a| a.inspect }.join(", ")
|
201
|
-
|
202
|
-
aliases.each do |other|
|
203
|
-
if obj = @resource.catalog.resource(@resource.class.name, other)
|
204
|
-
unless obj.object_id == @resource.object_id
|
205
|
-
self.fail("%s can not create alias %s: object already exists" % [@resource.title, other])
|
206
|
-
end
|
207
|
-
next
|
208
|
-
end
|
209
|
-
|
210
|
-
# LAK:FIXME Old-school, add the alias to the class.
|
211
|
-
@resource.class.alias(other, @resource)
|
212
|
-
|
213
|
-
# Newschool, add it to the catalog.
|
214
|
-
@resource.catalog.alias(@resource, other)
|
215
|
-
end
|
216
|
-
end
|
217
|
-
end
|
218
|
-
|
219
|
-
newmetaparam(:tag) do
|
220
|
-
desc "Add the specified tags to the associated resource. While all resources
|
221
|
-
are automatically tagged with as much information as possible
|
222
|
-
(e.g., each class and definition containing the resource), it can
|
223
|
-
be useful to add your own tags to a given resource.
|
224
|
-
|
225
|
-
Tags are currently useful for things like applying a subset of a
|
226
|
-
host's configuration::
|
227
|
-
|
228
|
-
puppetd --test --tags mytag
|
229
|
-
|
230
|
-
This way, when you're testing a configuration you can run just the
|
231
|
-
portion you're testing."
|
232
|
-
|
233
|
-
munge do |tags|
|
234
|
-
tags = [tags] unless tags.is_a? Array
|
235
|
-
|
236
|
-
tags.each do |tag|
|
237
|
-
@resource.tag(tag)
|
238
|
-
end
|
239
|
-
end
|
240
|
-
end
|
241
|
-
|
242
|
-
class RelationshipMetaparam < Puppet::Parameter
|
243
|
-
class << self
|
244
|
-
attr_accessor :direction, :events, :callback, :subclasses
|
245
|
-
end
|
246
|
-
|
247
|
-
@subclasses = []
|
248
|
-
|
249
|
-
def self.inherited(sub)
|
250
|
-
@subclasses << sub
|
251
|
-
end
|
252
|
-
|
253
|
-
def munge(rels)
|
254
|
-
@resource.munge_relationship(self.class.name, rels)
|
255
|
-
end
|
256
|
-
|
257
|
-
def validate_relationship
|
258
|
-
@value.each do |value|
|
259
|
-
unless @resource.catalog.resource(*value)
|
260
|
-
description = self.class.direction == :in ? "dependency" : "dependent"
|
261
|
-
fail Puppet::Error, "Could not find #{description} %s[%s] for %s" % [value[0].to_s.capitalize, value[1], resource.ref]
|
262
|
-
end
|
263
|
-
end
|
264
|
-
end
|
265
|
-
|
266
|
-
# Create edges from each of our relationships. :in
|
267
|
-
# relationships are specified by the event-receivers, and :out
|
268
|
-
# relationships are specified by the event generator. This
|
269
|
-
# way 'source' and 'target' are consistent terms in both edges
|
270
|
-
# and events -- that is, an event targets edges whose source matches
|
271
|
-
# the event's source. The direction of the relationship determines
|
272
|
-
# which resource is applied first and which resource is considered
|
273
|
-
# to be the event generator.
|
274
|
-
def to_edges
|
275
|
-
@value.collect do |value|
|
276
|
-
# we just have a name and a type, and we need to convert it
|
277
|
-
# to an object...
|
278
|
-
tname, name = value
|
279
|
-
reference = Puppet::ResourceReference.new(tname, name)
|
280
|
-
|
281
|
-
# Either of the two retrieval attempts could have returned
|
282
|
-
# nil.
|
283
|
-
unless object = reference.resolve
|
284
|
-
self.fail "Could not retrieve dependency '%s' of %s" % [reference, @resource.ref]
|
285
|
-
end
|
286
|
-
|
287
|
-
# Are we requiring them, or vice versa? See the method docs
|
288
|
-
# for futher info on this.
|
289
|
-
if self.class.direction == :in
|
290
|
-
source = object
|
291
|
-
target = @resource
|
292
|
-
else
|
293
|
-
source = @resource
|
294
|
-
target = object
|
295
|
-
end
|
296
|
-
|
297
|
-
if method = self.class.callback
|
298
|
-
subargs = {
|
299
|
-
:event => self.class.events,
|
300
|
-
:callback => method
|
301
|
-
}
|
302
|
-
self.debug("subscribes to %s" % [object.ref])
|
303
|
-
else
|
304
|
-
# If there's no callback, there's no point in even adding
|
305
|
-
# a label.
|
306
|
-
subargs = nil
|
307
|
-
self.debug("requires %s" % [object.ref])
|
308
|
-
end
|
309
|
-
|
310
|
-
rel = Puppet::Relationship.new(source, target, subargs)
|
311
|
-
end
|
312
|
-
end
|
313
|
-
end
|
314
|
-
|
315
|
-
def self.relationship_params
|
316
|
-
RelationshipMetaparam.subclasses
|
317
|
-
end
|
318
|
-
|
319
|
-
|
320
|
-
# Note that the order in which the relationships params is defined
|
321
|
-
# matters. The labelled params (notify and subcribe) must be later,
|
322
|
-
# so that if both params are used, those ones win. It's a hackish
|
323
|
-
# solution, but it works.
|
324
|
-
|
325
|
-
newmetaparam(:require, :parent => RelationshipMetaparam, :attributes => {:direction => :in, :events => :NONE}) do
|
326
|
-
desc "One or more objects that this object depends on.
|
327
|
-
This is used purely for guaranteeing that changes to required objects
|
328
|
-
happen before the dependent object. For instance::
|
329
|
-
|
330
|
-
# Create the destination directory before you copy things down
|
331
|
-
file { \"/usr/local/scripts\":
|
332
|
-
ensure => directory
|
333
|
-
}
|
334
|
-
|
335
|
-
file { \"/usr/local/scripts/myscript\":
|
336
|
-
source => \"puppet://server/module/myscript\",
|
337
|
-
mode => 755,
|
338
|
-
require => File[\"/usr/local/scripts\"]
|
339
|
-
}
|
340
|
-
|
341
|
-
Multiple dependencies can be specified by providing a comma-seperated list
|
342
|
-
of resources, enclosed in square brackets::
|
343
|
-
|
344
|
-
require => [ File[\"/usr/local\"], File[\"/usr/local/scripts\"] ]
|
345
|
-
|
346
|
-
Note that Puppet will autorequire everything that it can, and
|
347
|
-
there are hooks in place so that it's easy for resources to add new
|
348
|
-
ways to autorequire objects, so if you think Puppet could be
|
349
|
-
smarter here, let us know.
|
350
|
-
|
351
|
-
In fact, the above code was redundant -- Puppet will autorequire
|
352
|
-
any parent directories that are being managed; it will
|
353
|
-
automatically realize that the parent directory should be created
|
354
|
-
before the script is pulled down.
|
355
|
-
|
356
|
-
Currently, exec resources will autorequire their CWD (if it is
|
357
|
-
specified) plus any fully qualified paths that appear in the
|
358
|
-
command. For instance, if you had an ``exec`` command that ran
|
359
|
-
the ``myscript`` mentioned above, the above code that pulls the
|
360
|
-
file down would be automatically listed as a requirement to the
|
361
|
-
``exec`` code, so that you would always be running againts the
|
362
|
-
most recent version.
|
363
|
-
"
|
364
|
-
end
|
365
|
-
|
366
|
-
newmetaparam(:subscribe, :parent => RelationshipMetaparam, :attributes => {:direction => :in, :events => :ALL_EVENTS, :callback => :refresh}) do
|
367
|
-
desc "One or more objects that this object depends on. Changes in the
|
368
|
-
subscribed to objects result in the dependent objects being
|
369
|
-
refreshed (e.g., a service will get restarted). For instance::
|
370
|
-
|
371
|
-
class nagios {
|
372
|
-
file { \"/etc/nagios/nagios.conf\":
|
373
|
-
source => \"puppet://server/module/nagios.conf\",
|
374
|
-
alias => nagconf # just to make things easier for me
|
375
|
-
}
|
376
|
-
service { nagios:
|
377
|
-
running => true,
|
378
|
-
subscribe => File[nagconf]
|
379
|
-
}
|
380
|
-
}
|
381
|
-
|
382
|
-
Currently the ``exec``, ``mount`` and ``service`` type support
|
383
|
-
refreshing.
|
384
|
-
"
|
385
|
-
end
|
386
|
-
|
387
|
-
newmetaparam(:before, :parent => RelationshipMetaparam, :attributes => {:direction => :out, :events => :NONE}) do
|
388
|
-
desc %{This parameter is the opposite of **require** -- it guarantees
|
389
|
-
that the specified object is applied later than the specifying
|
390
|
-
object::
|
391
|
-
|
392
|
-
file { "/var/nagios/configuration":
|
393
|
-
source => "...",
|
394
|
-
recurse => true,
|
395
|
-
before => Exec["nagios-rebuid"]
|
396
|
-
}
|
397
|
-
|
398
|
-
exec { "nagios-rebuild":
|
399
|
-
command => "/usr/bin/make",
|
400
|
-
cwd => "/var/nagios/configuration"
|
401
|
-
}
|
402
|
-
|
403
|
-
This will make sure all of the files are up to date before the
|
404
|
-
make command is run.}
|
405
|
-
end
|
406
|
-
|
407
|
-
newmetaparam(:notify, :parent => RelationshipMetaparam, :attributes => {:direction => :out, :events => :ALL_EVENTS, :callback => :refresh}) do
|
408
|
-
desc %{This parameter is the opposite of **subscribe** -- it sends events
|
409
|
-
to the specified object::
|
410
|
-
|
411
|
-
file { "/etc/sshd_config":
|
412
|
-
source => "....",
|
413
|
-
notify => Service[sshd]
|
414
|
-
}
|
415
|
-
|
416
|
-
service { sshd:
|
417
|
-
ensure => running
|
418
|
-
}
|
419
|
-
|
420
|
-
This will restart the sshd service if the sshd config file changes.}
|
421
|
-
end
|
422
|
-
end # Puppet::Type
|
423
|
-
|
@@ -1,247 +0,0 @@
|
|
1
|
-
require 'puppet/provider'
|
2
|
-
require 'puppet/util/provider_features'
|
3
|
-
class Puppet::Type
|
4
|
-
# Add the feature handling module.
|
5
|
-
extend Puppet::Util::ProviderFeatures
|
6
|
-
|
7
|
-
attr_reader :provider
|
8
|
-
|
9
|
-
# the Type class attribute accessors
|
10
|
-
class << self
|
11
|
-
attr_accessor :providerloader
|
12
|
-
attr_writer :defaultprovider
|
13
|
-
end
|
14
|
-
|
15
|
-
# Find the default provider.
|
16
|
-
def self.defaultprovider
|
17
|
-
unless defined? @defaultprovider and @defaultprovider
|
18
|
-
suitable = suitableprovider()
|
19
|
-
|
20
|
-
# Find which providers are a default for this system.
|
21
|
-
defaults = suitable.find_all { |provider| provider.default? }
|
22
|
-
|
23
|
-
# If we don't have any default we use suitable providers
|
24
|
-
defaults = suitable if defaults.empty?
|
25
|
-
max = defaults.collect { |provider| provider.defaultnum }.max
|
26
|
-
defaults = defaults.find_all { |provider| provider.defaultnum == max }
|
27
|
-
|
28
|
-
retval = nil
|
29
|
-
if defaults.length > 1
|
30
|
-
Puppet.warning(
|
31
|
-
"Found multiple default providers for %s: %s; using %s" %
|
32
|
-
[self.name, defaults.collect { |i| i.name.to_s }.join(", "),
|
33
|
-
defaults[0].name]
|
34
|
-
)
|
35
|
-
retval = defaults.shift
|
36
|
-
elsif defaults.length == 1
|
37
|
-
retval = defaults.shift
|
38
|
-
else
|
39
|
-
raise Puppet::DevError, "Could not find a default provider for %s" %
|
40
|
-
self.name
|
41
|
-
end
|
42
|
-
|
43
|
-
@defaultprovider = retval
|
44
|
-
end
|
45
|
-
|
46
|
-
return @defaultprovider
|
47
|
-
end
|
48
|
-
|
49
|
-
# Convert a hash, as provided by, um, a provider, into an instance of self.
|
50
|
-
def self.hash2obj(hash)
|
51
|
-
obj = nil
|
52
|
-
|
53
|
-
namevar = self.namevar
|
54
|
-
unless hash.include?(namevar) and hash[namevar]
|
55
|
-
raise Puppet::DevError, "Hash was not passed with namevar"
|
56
|
-
end
|
57
|
-
|
58
|
-
# if the obj already exists with that name...
|
59
|
-
if obj = self[hash[namevar]]
|
60
|
-
# We're assuming here that objects with the same name
|
61
|
-
# are the same object, which *should* be the case, assuming
|
62
|
-
# we've set up our naming stuff correctly everywhere.
|
63
|
-
|
64
|
-
# Mark found objects as present
|
65
|
-
hash.each { |param, value|
|
66
|
-
if property = obj.property(param)
|
67
|
-
elsif val = obj[param]
|
68
|
-
obj[param] = val
|
69
|
-
else
|
70
|
-
# There is a value on disk, but it should go away
|
71
|
-
obj[param] = :absent
|
72
|
-
end
|
73
|
-
}
|
74
|
-
else
|
75
|
-
# create a new obj, since no existing one seems to
|
76
|
-
# match
|
77
|
-
obj = self.create(namevar => hash[namevar])
|
78
|
-
|
79
|
-
# We can't just pass the hash in at object creation time,
|
80
|
-
# because it sets the should value, not the is value.
|
81
|
-
hash.delete(namevar)
|
82
|
-
hash.each { |param, value|
|
83
|
-
obj[param] = value unless obj.add_property_parameter(param)
|
84
|
-
}
|
85
|
-
end
|
86
|
-
|
87
|
-
return obj
|
88
|
-
end
|
89
|
-
|
90
|
-
# Retrieve a provider by name.
|
91
|
-
def self.provider(name)
|
92
|
-
name = Puppet::Util.symbolize(name)
|
93
|
-
|
94
|
-
# If we don't have it yet, try loading it.
|
95
|
-
unless @providers.has_key?(name)
|
96
|
-
@providerloader.load(name)
|
97
|
-
end
|
98
|
-
return @providers[name]
|
99
|
-
end
|
100
|
-
|
101
|
-
# Just list all of the providers.
|
102
|
-
def self.providers
|
103
|
-
@providers.keys
|
104
|
-
end
|
105
|
-
|
106
|
-
def self.validprovider?(name)
|
107
|
-
name = Puppet::Util.symbolize(name)
|
108
|
-
|
109
|
-
return (@providers.has_key?(name) && @providers[name].suitable?)
|
110
|
-
end
|
111
|
-
|
112
|
-
# Create a new provider of a type. This method must be called
|
113
|
-
# directly on the type that it's implementing.
|
114
|
-
def self.provide(name, options = {}, &block)
|
115
|
-
name = Puppet::Util.symbolize(name)
|
116
|
-
|
117
|
-
if obj = @providers[name]
|
118
|
-
Puppet.debug "Reloading %s %s provider" % [name, self.name]
|
119
|
-
unprovide(name)
|
120
|
-
end
|
121
|
-
|
122
|
-
parent = if pname = options[:parent]
|
123
|
-
options.delete(:parent)
|
124
|
-
if pname.is_a? Class
|
125
|
-
pname
|
126
|
-
else
|
127
|
-
if provider = self.provider(pname)
|
128
|
-
provider
|
129
|
-
else
|
130
|
-
raise Puppet::DevError,
|
131
|
-
"Could not find parent provider %s of %s" %
|
132
|
-
[pname, name]
|
133
|
-
end
|
134
|
-
end
|
135
|
-
else
|
136
|
-
Puppet::Provider
|
137
|
-
end
|
138
|
-
|
139
|
-
options[:resource_type] ||= self
|
140
|
-
|
141
|
-
self.providify
|
142
|
-
|
143
|
-
provider = genclass(name,
|
144
|
-
:parent => parent,
|
145
|
-
:hash => @providers,
|
146
|
-
:prefix => "Provider",
|
147
|
-
:block => block,
|
148
|
-
:include => feature_module,
|
149
|
-
:extend => feature_module,
|
150
|
-
:attributes => options
|
151
|
-
)
|
152
|
-
|
153
|
-
return provider
|
154
|
-
end
|
155
|
-
|
156
|
-
# Make sure we have a :provider parameter defined. Only gets called if there
|
157
|
-
# are providers.
|
158
|
-
def self.providify
|
159
|
-
return if @paramhash.has_key? :provider
|
160
|
-
|
161
|
-
newparam(:provider) do
|
162
|
-
desc "The specific backend for #{self.name.to_s} to use. You will
|
163
|
-
seldom need to specify this -- Puppet will usually discover the
|
164
|
-
appropriate provider for your platform."
|
165
|
-
|
166
|
-
# This is so we can refer back to the type to get a list of
|
167
|
-
# providers for documentation.
|
168
|
-
class << self
|
169
|
-
attr_accessor :parenttype
|
170
|
-
end
|
171
|
-
|
172
|
-
# We need to add documentation for each provider.
|
173
|
-
def self.doc
|
174
|
-
@doc + " Available providers are:\n\n" + parenttype().providers.sort { |a,b|
|
175
|
-
a.to_s <=> b.to_s
|
176
|
-
}.collect { |i|
|
177
|
-
"* **%s**: %s" % [i, parenttype().provider(i).doc]
|
178
|
-
}.join("\n")
|
179
|
-
end
|
180
|
-
|
181
|
-
defaultto {
|
182
|
-
@resource.class.defaultprovider.name
|
183
|
-
}
|
184
|
-
|
185
|
-
validate do |provider_class|
|
186
|
-
provider_class = provider_class[0] if provider_class.is_a? Array
|
187
|
-
if provider_class.is_a?(Puppet::Provider)
|
188
|
-
provider_class = provider_class.class.name
|
189
|
-
end
|
190
|
-
|
191
|
-
unless provider = @resource.class.provider(provider_class)
|
192
|
-
raise ArgumentError, "Invalid %s provider '%s'" % [@resource.class.name, provider_class]
|
193
|
-
end
|
194
|
-
end
|
195
|
-
|
196
|
-
munge do |provider|
|
197
|
-
provider = provider[0] if provider.is_a? Array
|
198
|
-
if provider.is_a? String
|
199
|
-
provider = provider.intern
|
200
|
-
end
|
201
|
-
@resource.provider = provider
|
202
|
-
|
203
|
-
if provider.is_a?(Puppet::Provider)
|
204
|
-
provider.class.name
|
205
|
-
else
|
206
|
-
provider
|
207
|
-
end
|
208
|
-
end
|
209
|
-
end.parenttype = self
|
210
|
-
end
|
211
|
-
|
212
|
-
def self.unprovide(name)
|
213
|
-
if @providers.has_key? name
|
214
|
-
rmclass(name,
|
215
|
-
:hash => @providers,
|
216
|
-
:prefix => "Provider"
|
217
|
-
)
|
218
|
-
if @defaultprovider and @defaultprovider.name == name
|
219
|
-
@defaultprovider = nil
|
220
|
-
end
|
221
|
-
end
|
222
|
-
end
|
223
|
-
|
224
|
-
# Return an array of all of the suitable providers.
|
225
|
-
def self.suitableprovider
|
226
|
-
if @providers.empty?
|
227
|
-
providerloader.loadall
|
228
|
-
end
|
229
|
-
@providers.find_all { |name, provider|
|
230
|
-
provider.suitable?
|
231
|
-
}.collect { |name, provider|
|
232
|
-
provider
|
233
|
-
}.reject { |p| p.name == :fake } # For testing
|
234
|
-
end
|
235
|
-
|
236
|
-
def provider=(name)
|
237
|
-
if name.is_a?(Puppet::Provider)
|
238
|
-
@provider = name
|
239
|
-
@provider.resource = self
|
240
|
-
elsif klass = self.class.provider(name)
|
241
|
-
@provider = klass.new(self)
|
242
|
-
else
|
243
|
-
raise ArgumentError, "Could not find %s provider of %s" %
|
244
|
-
[name, self.class.name]
|
245
|
-
end
|
246
|
-
end
|
247
|
-
end
|