puppet 0.25.5 → 2.6.0
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 +667 -0
- data/LICENSE +2 -2
- data/README +5 -1
- data/README.queueing +1 -1
- data/README.rst +7 -4
- data/Rakefile +6 -18
- data/bin/filebucket +0 -94
- data/bin/pi +2 -47
- data/bin/puppet +2 -69
- data/bin/puppetca +2 -100
- data/bin/puppetd +2 -158
- data/bin/puppetdoc +2 -63
- data/bin/puppetmasterd +2 -64
- data/bin/puppetqd +2 -51
- data/bin/puppetrun +2 -127
- data/bin/ralsh +2 -87
- data/conf/epm.list +2 -2
- data/conf/osx/PackageInfo.plist +1 -1
- data/conf/redhat/client.init +11 -8
- data/conf/redhat/puppet.conf +1 -1
- data/conf/redhat/puppet.spec +1 -1
- data/conf/redhat/rundir-perms.patch +13 -13
- data/conf/redhat/server.init +11 -5
- data/conf/solaris/pkginfo +2 -2
- data/conf/solaris/smf/puppetd.xml +3 -3
- data/conf/solaris/smf/puppetmasterd.xml +3 -3
- data/conf/suse/client.init +3 -2
- data/conf/suse/puppet.spec +22 -18
- data/conf/suse/server.init +12 -11
- data/examples/modules/sample-module/README.txt +3 -3
- data/examples/modules/sample-module/lib/puppet/parser/functions/hostname_to_dn.rb +4 -4
- data/ext/extlookup.rb +94 -96
- data/ext/nagios/check_puppet.rb +94 -88
- data/ext/nagios/naggen +3 -3
- data/ext/puppet-test +27 -3
- data/ext/puppetlisten/puppetlisten.rb +39 -39
- data/ext/puppetlisten/puppetrun.rb +6 -6
- data/ext/puppetstoredconfigclean.rb +49 -43
- data/ext/pure_ruby_dsl/dsl_test.rb +7 -0
- data/ext/regexp_nodes/regexp_nodes.rb +133 -133
- data/ext/yaml_nodes.rb +99 -0
- data/install.rb +109 -118
- data/lib/puppet.rb +118 -131
- data/lib/puppet/agent.rb +86 -119
- data/lib/puppet/agent/locker.rb +28 -30
- data/lib/puppet/application.rb +276 -184
- data/lib/puppet/application/agent.rb +266 -0
- data/lib/puppet/application/apply.rb +165 -0
- data/lib/puppet/application/cert.rb +85 -0
- data/lib/puppet/application/describe.rb +203 -0
- data/lib/puppet/application/doc.rb +215 -0
- data/lib/puppet/application/filebucket.rb +73 -73
- data/lib/puppet/application/kick.rb +212 -0
- data/lib/puppet/application/master.rb +156 -0
- data/lib/puppet/application/queue.rb +91 -0
- data/lib/puppet/application/resource.rb +118 -0
- data/lib/puppet/configurer.rb +214 -197
- data/lib/puppet/configurer/downloader.rb +63 -63
- data/lib/puppet/configurer/fact_handler.rb +51 -51
- data/lib/puppet/configurer/plugin_handler.rb +19 -19
- data/lib/puppet/daemon.rb +100 -103
- data/lib/puppet/defaults.rb +793 -796
- data/lib/puppet/dsl.rb +5 -269
- data/lib/puppet/dsl/resource_api.rb +120 -0
- data/lib/puppet/dsl/resource_type_api.rb +40 -0
- data/lib/puppet/error.rb +34 -36
- data/lib/puppet/external/base64.rb +8 -8
- data/lib/puppet/external/dot.rb +262 -262
- data/lib/puppet/external/event-loop/better-definers.rb +297 -297
- data/lib/puppet/external/event-loop/event-loop.rb +264 -272
- data/lib/puppet/external/event-loop/signal-system.rb +161 -163
- data/lib/puppet/external/lock.rb +41 -41
- data/lib/puppet/external/nagios.rb +32 -32
- data/lib/puppet/external/nagios/base.rb +453 -458
- data/lib/puppet/external/nagios/parser.rb +264 -287
- data/lib/puppet/external/pson/common.rb +8 -5
- data/lib/puppet/external/pson/pure/generator.rb +26 -26
- data/lib/puppet/external/pson/pure/parser.rb +43 -48
- data/lib/puppet/feature/base.rb +21 -1
- data/lib/puppet/feature/pson.rb +4 -4
- data/lib/puppet/feature/rack.rb +14 -14
- data/lib/puppet/feature/rails.rb +23 -25
- data/lib/puppet/file_bucket.rb +4 -0
- data/lib/puppet/file_bucket/dipper.rb +99 -0
- data/lib/puppet/file_bucket/file.rb +136 -0
- data/lib/puppet/file_bucket/file/indirection_hooks.rb +9 -0
- data/lib/puppet/file_collection.rb +20 -20
- data/lib/puppet/file_collection/lookup.rb +11 -11
- data/lib/puppet/file_serving/base.rb +67 -71
- data/lib/puppet/file_serving/configuration.rb +84 -86
- data/lib/puppet/file_serving/configuration/parser.rb +103 -102
- data/lib/puppet/file_serving/content.rb +34 -33
- data/lib/puppet/file_serving/fileset.rb +131 -133
- data/lib/puppet/file_serving/indirection_hooks.rb +17 -17
- data/lib/puppet/file_serving/metadata.rb +98 -95
- data/lib/puppet/file_serving/mount.rb +22 -22
- data/lib/puppet/file_serving/mount/file.rb +101 -106
- data/lib/puppet/file_serving/mount/modules.rb +15 -15
- data/lib/puppet/file_serving/mount/plugins.rb +15 -16
- data/lib/puppet/file_serving/terminus_helper.rb +13 -13
- data/lib/puppet/indirector.rb +48 -49
- data/lib/puppet/indirector/active_record.rb +19 -19
- data/lib/puppet/indirector/catalog/active_record.rb +25 -25
- data/lib/puppet/indirector/catalog/compiler.rb +134 -145
- data/lib/puppet/indirector/catalog/rest.rb +1 -1
- data/lib/puppet/indirector/catalog/yaml.rb +13 -13
- data/lib/puppet/indirector/certificate/ca.rb +3 -3
- data/lib/puppet/indirector/certificate/file.rb +3 -3
- data/lib/puppet/indirector/certificate/rest.rb +8 -8
- data/lib/puppet/indirector/certificate_request/ca.rb +7 -7
- data/lib/puppet/indirector/certificate_request/file.rb +2 -2
- data/lib/puppet/indirector/certificate_request/rest.rb +3 -3
- data/lib/puppet/indirector/certificate_revocation_list/ca.rb +2 -2
- data/lib/puppet/indirector/certificate_revocation_list/file.rb +2 -2
- data/lib/puppet/indirector/certificate_revocation_list/rest.rb +3 -3
- data/lib/puppet/indirector/couch.rb +76 -0
- data/lib/puppet/indirector/direct_file_server.rb +11 -11
- data/lib/puppet/indirector/envelope.rb +4 -4
- data/lib/puppet/indirector/exec.rb +38 -42
- data/lib/puppet/indirector/facts/active_record.rb +24 -24
- data/lib/puppet/indirector/facts/couch.rb +31 -0
- data/lib/puppet/indirector/facts/facter.rb +63 -61
- data/lib/puppet/indirector/facts/memory.rb +4 -4
- data/lib/puppet/indirector/facts/rest.rb +1 -1
- data/lib/puppet/indirector/facts/yaml.rb +2 -2
- data/lib/puppet/indirector/file.rb +67 -46
- data/lib/puppet/indirector/file_bucket_file/file.rb +146 -0
- data/lib/puppet/indirector/file_bucket_file/rest.rb +8 -0
- data/lib/puppet/indirector/file_content/file.rb +1 -1
- data/lib/puppet/indirector/file_content/file_server.rb +1 -1
- data/lib/puppet/indirector/file_content/rest.rb +1 -1
- data/lib/puppet/indirector/file_metadata/file.rb +11 -11
- data/lib/puppet/indirector/file_metadata/file_server.rb +1 -1
- data/lib/puppet/indirector/file_metadata/rest.rb +1 -1
- data/lib/puppet/indirector/file_server.rb +44 -44
- data/lib/puppet/indirector/indirection.rb +249 -260
- data/lib/puppet/indirector/key/ca.rb +5 -5
- data/lib/puppet/indirector/key/file.rb +29 -29
- data/lib/puppet/indirector/ldap.rb +62 -64
- data/lib/puppet/indirector/memory.rb +13 -13
- data/lib/puppet/indirector/node/active_record.rb +6 -6
- data/lib/puppet/indirector/node/exec.rb +40 -44
- data/lib/puppet/indirector/node/ldap.rb +246 -212
- data/lib/puppet/indirector/node/memory.rb +5 -5
- data/lib/puppet/indirector/node/plain.rb +12 -12
- data/lib/puppet/indirector/node/rest.rb +2 -2
- data/lib/puppet/indirector/node/yaml.rb +2 -2
- data/lib/puppet/indirector/plain.rb +4 -4
- data/lib/puppet/indirector/queue.rb +49 -51
- data/lib/puppet/indirector/report/processor.rb +34 -37
- data/lib/puppet/indirector/report/rest.rb +3 -3
- data/lib/puppet/indirector/request.rb +171 -157
- data/lib/puppet/indirector/resource/ral.rb +48 -0
- data/lib/puppet/indirector/resource/rest.rb +5 -0
- data/lib/puppet/indirector/resource_type.rb +5 -0
- data/lib/puppet/indirector/resource_type/parser.rb +27 -0
- data/lib/puppet/indirector/resource_type/rest.rb +7 -0
- data/lib/puppet/indirector/rest.rb +83 -79
- data/lib/puppet/indirector/run/local.rb +8 -0
- data/lib/puppet/indirector/run/rest.rb +6 -0
- data/lib/puppet/indirector/ssl_file.rb +165 -165
- data/lib/puppet/indirector/status.rb +3 -0
- data/lib/puppet/indirector/status/local.rb +7 -0
- data/lib/puppet/indirector/status/rest.rb +5 -0
- data/lib/puppet/indirector/terminus.rb +129 -133
- data/lib/puppet/indirector/yaml.rb +47 -49
- data/lib/puppet/metatype/manager.rb +120 -114
- data/lib/puppet/module.rb +182 -124
- data/lib/puppet/network/authconfig.rb +146 -156
- data/lib/puppet/network/authorization.rb +63 -70
- data/lib/puppet/network/authstore.rb +226 -232
- data/lib/puppet/network/client.rb +141 -152
- data/lib/puppet/network/client/ca.rb +47 -49
- data/lib/puppet/network/client/file.rb +3 -3
- data/lib/puppet/network/client/proxy.rb +19 -19
- data/lib/puppet/network/client/report.rb +17 -21
- data/lib/puppet/network/client/runner.rb +5 -7
- data/lib/puppet/network/client/status.rb +1 -1
- data/lib/puppet/network/client_request.rb +20 -22
- data/lib/puppet/network/format.rb +79 -81
- data/lib/puppet/network/format_handler.rb +135 -130
- data/lib/puppet/network/formats.rb +128 -154
- data/lib/puppet/network/handler.rb +43 -46
- data/lib/puppet/network/handler/ca.rb +129 -135
- data/lib/puppet/network/handler/filebucket.rb +39 -170
- data/lib/puppet/network/handler/fileserver.rb +624 -656
- data/lib/puppet/network/handler/master.rb +62 -75
- data/lib/puppet/network/handler/report.rb +60 -67
- data/lib/puppet/network/handler/runner.rb +20 -20
- data/lib/puppet/network/handler/status.rb +9 -9
- data/lib/puppet/network/http.rb +12 -12
- data/lib/puppet/network/http/api/v1.rb +49 -44
- data/lib/puppet/network/http/compression.rb +111 -0
- data/lib/puppet/network/http/handler.rb +183 -183
- data/lib/puppet/network/http/mongrel.rb +46 -48
- data/lib/puppet/network/http/mongrel/rest.rb +73 -66
- data/lib/puppet/network/http/rack.rb +45 -45
- data/lib/puppet/network/http/rack/httphandler.rb +7 -7
- data/lib/puppet/network/http/rack/rest.rb +84 -61
- data/lib/puppet/network/http/rack/xmlrpc.rb +49 -49
- data/lib/puppet/network/http/webrick.rb +108 -112
- data/lib/puppet/network/http/webrick/rest.rb +60 -57
- data/lib/puppet/network/http_pool.rb +95 -83
- data/lib/puppet/network/http_server/mongrel.rb +90 -90
- data/lib/puppet/network/http_server/webrick.rb +139 -148
- data/lib/puppet/network/rest_authconfig.rb +76 -71
- data/lib/puppet/network/rest_authorization.rb +11 -13
- data/lib/puppet/network/rights.rb +217 -226
- data/lib/puppet/network/server.rb +147 -151
- data/lib/puppet/network/xmlrpc/client.rb +197 -205
- data/lib/puppet/network/xmlrpc/processor.rb +68 -72
- data/lib/puppet/network/xmlrpc/server.rb +10 -10
- data/lib/puppet/network/xmlrpc/webrick_servlet.rb +94 -100
- data/lib/puppet/node.rb +99 -107
- data/lib/puppet/node/environment.rb +109 -62
- data/lib/puppet/node/facts.rb +48 -43
- data/lib/puppet/parameter.rb +246 -498
- data/lib/puppet/parameter/value.rb +63 -0
- data/lib/puppet/parameter/value_collection.rb +143 -0
- data/lib/puppet/parser.rb +4 -0
- data/lib/puppet/parser/ast.rb +81 -67
- data/lib/puppet/parser/ast/arithmetic_operator.rb +27 -29
- data/lib/puppet/parser/ast/astarray.rb +50 -50
- data/lib/puppet/parser/ast/asthash.rb +37 -0
- data/lib/puppet/parser/ast/boolean_operator.rb +33 -35
- data/lib/puppet/parser/ast/branch.rb +29 -31
- data/lib/puppet/parser/ast/caseopt.rb +50 -56
- data/lib/puppet/parser/ast/casestatement.rb +30 -30
- data/lib/puppet/parser/ast/collection.rb +43 -37
- data/lib/puppet/parser/ast/collexpr.rb +66 -69
- data/lib/puppet/parser/ast/comparison_operator.rb +32 -35
- data/lib/puppet/parser/ast/else.rb +13 -13
- data/lib/puppet/parser/ast/function.rb +34 -43
- data/lib/puppet/parser/ast/ifstatement.rb +23 -27
- data/lib/puppet/parser/ast/in_operator.rb +24 -0
- data/lib/puppet/parser/ast/leaf.rb +173 -156
- data/lib/puppet/parser/ast/match_operator.rb +16 -19
- data/lib/puppet/parser/ast/minus.rb +13 -13
- data/lib/puppet/parser/ast/nop.rb +6 -6
- data/lib/puppet/parser/ast/not.rb +9 -9
- data/lib/puppet/parser/ast/relationship.rb +60 -0
- data/lib/puppet/parser/ast/resource.rb +58 -57
- data/lib/puppet/parser/ast/resource_defaults.rb +16 -16
- data/lib/puppet/parser/ast/resource_override.rb +51 -51
- data/lib/puppet/parser/ast/resource_reference.rb +17 -72
- data/lib/puppet/parser/ast/resourceparam.rb +20 -17
- data/lib/puppet/parser/ast/selector.rb +30 -34
- data/lib/puppet/parser/ast/tag.rb +16 -16
- data/lib/puppet/parser/ast/vardef.rb +20 -16
- data/lib/puppet/parser/collector.rb +181 -189
- data/lib/puppet/parser/compiler.rb +395 -364
- data/lib/puppet/parser/files.rb +65 -69
- data/lib/puppet/parser/functions.rb +85 -97
- data/lib/puppet/parser/functions/defined.rb +23 -23
- data/lib/puppet/parser/functions/fail.rb +2 -2
- data/lib/puppet/parser/functions/file.rb +21 -19
- data/lib/puppet/parser/functions/fqdn_rand.rb +7 -7
- data/lib/puppet/parser/functions/generate.rb +24 -26
- data/lib/puppet/parser/functions/include.rb +16 -18
- data/lib/puppet/parser/functions/inline_template.rb +16 -17
- data/lib/puppet/parser/functions/realize.rb +8 -8
- data/lib/puppet/parser/functions/regsubst.rb +74 -59
- data/lib/puppet/parser/functions/require.rb +35 -33
- data/lib/puppet/parser/functions/search.rb +5 -5
- data/lib/puppet/parser/functions/sha1.rb +3 -4
- data/lib/puppet/parser/functions/shellquote.rb +31 -33
- data/lib/puppet/parser/functions/split.rb +8 -8
- data/lib/puppet/parser/functions/sprintf.rb +10 -9
- data/lib/puppet/parser/functions/tag.rb +3 -3
- data/lib/puppet/parser/functions/tagged.rb +13 -13
- data/lib/puppet/parser/functions/template.rb +18 -19
- data/lib/puppet/parser/functions/versioncmp.rb +17 -14
- data/lib/puppet/parser/grammar.ra +485 -422
- data/lib/puppet/parser/lexer.rb +500 -442
- data/lib/puppet/parser/parser.rb +1438 -1084
- data/lib/puppet/parser/parser_support.rb +227 -502
- data/lib/puppet/parser/relationship.rb +43 -0
- data/lib/puppet/parser/resource.rb +280 -375
- data/lib/puppet/parser/resource/param.rb +18 -18
- data/lib/puppet/parser/scope.rb +450 -447
- data/lib/puppet/parser/templatewrapper.rb +92 -94
- data/lib/puppet/parser/type_loader.rb +146 -0
- data/lib/puppet/parser/yaml_trimmer.rb +6 -8
- data/lib/puppet/property.rb +290 -453
- data/lib/puppet/property/ensure.rb +92 -0
- data/lib/puppet/property/keyvalue.rb +74 -82
- data/lib/puppet/property/list.rb +71 -81
- data/lib/puppet/property/ordered_list.rb +15 -15
- data/lib/puppet/provider.rb +229 -241
- data/lib/puppet/provider/augeas/augeas.rb +318 -320
- data/lib/puppet/provider/computer/computer.rb +13 -13
- data/lib/puppet/provider/confine.rb +63 -63
- data/lib/puppet/provider/confine/exists.rb +14 -14
- data/lib/puppet/provider/confine/false.rb +12 -12
- data/lib/puppet/provider/confine/feature.rb +10 -10
- data/lib/puppet/provider/confine/true.rb +13 -13
- data/lib/puppet/provider/confine/variable.rb +51 -54
- data/lib/puppet/provider/confine_collection.rb +38 -38
- data/lib/puppet/provider/confiner.rb +10 -14
- data/lib/puppet/provider/cron/crontab.rb +172 -173
- data/lib/puppet/provider/file/posix.rb +99 -0
- data/lib/puppet/provider/file/win32.rb +74 -0
- data/lib/puppet/provider/group/directoryservice.rb +6 -6
- data/lib/puppet/provider/group/groupadd.rb +18 -20
- data/lib/puppet/provider/group/ldap.rb +40 -43
- data/lib/puppet/provider/group/pw.rb +23 -23
- data/lib/puppet/provider/host/parsed.rb +51 -50
- data/lib/puppet/provider/ldap.rb +121 -123
- data/lib/puppet/provider/macauthorization/macauthorization.rb +263 -272
- data/lib/puppet/provider/mailalias/aliases.rb +34 -31
- data/lib/puppet/provider/maillist/mailman.rb +87 -93
- data/lib/puppet/provider/mcx/mcxcontent.rb +155 -151
- data/lib/puppet/provider/mount.rb +36 -40
- data/lib/puppet/provider/mount/parsed.rb +28 -26
- data/lib/puppet/provider/naginator.rb +46 -48
- data/lib/puppet/provider/nameservice.rb +215 -257
- data/lib/puppet/provider/nameservice/directoryservice.rb +455 -471
- data/lib/puppet/provider/nameservice/objectadd.rb +21 -21
- data/lib/puppet/provider/nameservice/pw.rb +13 -13
- data/lib/puppet/provider/package.rb +18 -20
- data/lib/puppet/provider/package/aix.rb +128 -0
- data/lib/puppet/provider/package/appdmg.rb +78 -82
- data/lib/puppet/provider/package/apple.rb +39 -40
- data/lib/puppet/provider/package/apt.rb +95 -104
- data/lib/puppet/provider/package/aptitude.rb +19 -21
- data/lib/puppet/provider/package/aptrpm.rb +70 -72
- data/lib/puppet/provider/package/blastwave.rb +88 -94
- data/lib/puppet/provider/package/darwinport.rb +67 -69
- data/lib/puppet/provider/package/dpkg.rb +123 -97
- data/lib/puppet/provider/package/fink.rb +66 -68
- data/lib/puppet/provider/package/freebsd.rb +38 -40
- data/lib/puppet/provider/package/gem.rb +98 -102
- data/lib/puppet/provider/package/hpux.rb +37 -39
- data/lib/puppet/provider/package/nim.rb +35 -0
- data/lib/puppet/provider/package/openbsd.rb +100 -75
- data/lib/puppet/provider/package/pkg.rb +108 -0
- data/lib/puppet/provider/package/pkgdmg.rb +95 -87
- data/lib/puppet/provider/package/portage.rb +101 -104
- data/lib/puppet/provider/package/ports.rb +71 -73
- data/lib/puppet/provider/package/portupgrade.rb +251 -0
- data/lib/puppet/provider/package/rpm.rb +113 -115
- data/lib/puppet/provider/package/rug.rb +46 -46
- data/lib/puppet/provider/package/sun.rb +135 -151
- data/lib/puppet/provider/package/sunfreeware.rb +5 -5
- data/lib/puppet/provider/package/up2date.rb +31 -31
- data/lib/puppet/provider/package/urpmi.rb +51 -51
- data/lib/puppet/provider/package/yum.rb +90 -98
- data/lib/puppet/provider/package/zypper.rb +52 -0
- data/lib/puppet/provider/parsedfile.rb +306 -329
- data/lib/puppet/provider/port/parsed.rb +5 -5
- data/lib/puppet/provider/selboolean/getsetsebool.rb +34 -34
- data/lib/puppet/provider/selmodule/semodule.rb +103 -111
- data/lib/puppet/provider/service/base.rb +134 -139
- data/lib/puppet/provider/service/bsd.rb +48 -0
- data/lib/puppet/provider/service/daemontools.rb +158 -162
- data/lib/puppet/provider/service/debian.rb +36 -36
- data/lib/puppet/provider/service/freebsd.rb +118 -38
- data/lib/puppet/provider/service/gentoo.rb +33 -39
- data/lib/puppet/provider/service/init.rb +125 -125
- data/lib/puppet/provider/service/launchd.rb +234 -254
- data/lib/puppet/provider/service/redhat.rb +58 -58
- data/lib/puppet/provider/service/runit.rb +74 -74
- data/lib/puppet/provider/service/smf.rb +81 -85
- data/lib/puppet/provider/service/src.rb +87 -0
- data/lib/puppet/provider/ssh_authorized_key/parsed.rb +73 -81
- data/lib/puppet/provider/sshkey/parsed.rb +24 -21
- data/lib/puppet/provider/user/directoryservice.rb +71 -71
- data/lib/puppet/provider/user/hpux.rb +20 -20
- data/lib/puppet/provider/user/ldap.rb +106 -110
- data/lib/puppet/provider/user/pw.rb +33 -37
- data/lib/puppet/provider/user/user_role_add.rb +168 -183
- data/lib/puppet/provider/user/useradd.rb +50 -51
- data/lib/puppet/provider/zfs/solaris.rb +35 -35
- data/lib/puppet/provider/zone/solaris.rb +206 -205
- data/lib/puppet/provider/zpool/solaris.rb +95 -97
- data/lib/puppet/rails.rb +115 -122
- data/lib/puppet/rails/benchmark.rb +43 -49
- data/lib/puppet/rails/database/001_add_created_at_to_all_tables.rb +8 -12
- data/lib/puppet/rails/database/002_remove_duplicated_index_on_all_tables.rb +8 -12
- data/lib/puppet/rails/database/003_add_environment_to_host.rb +6 -10
- data/lib/puppet/rails/database/schema.rb +100 -97
- data/lib/puppet/rails/fact_name.rb +1 -1
- data/lib/puppet/rails/fact_value.rb +5 -5
- data/lib/puppet/rails/host.rb +252 -249
- data/lib/puppet/rails/param_name.rb +15 -15
- data/lib/puppet/rails/param_value.rb +55 -55
- data/lib/puppet/rails/puppet_tag.rb +4 -4
- data/lib/puppet/rails/resource.rb +189 -203
- data/lib/puppet/rails/resource_tag.rb +19 -19
- data/lib/puppet/rails/source_file.rb +5 -5
- data/lib/puppet/reference/configuration.rb +53 -56
- data/lib/puppet/reference/function.rb +1 -1
- data/lib/puppet/reference/indirection.rb +13 -13
- data/lib/puppet/reference/metaparameter.rb +40 -40
- data/lib/puppet/reference/network.rb +16 -16
- data/lib/puppet/reference/providers.rb +97 -98
- data/lib/puppet/reference/report.rb +1 -1
- data/lib/puppet/reference/type.rb +67 -70
- data/lib/puppet/relationship.rb +65 -67
- data/lib/puppet/reports.rb +32 -34
- data/lib/puppet/reports/http.rb +22 -0
- data/lib/puppet/reports/log.rb +7 -6
- data/lib/puppet/reports/rrdgraph.rb +105 -114
- data/lib/puppet/reports/store.rb +53 -56
- data/lib/puppet/reports/tagmail.rb +149 -157
- data/lib/puppet/resource.rb +428 -194
- data/lib/puppet/resource/catalog.rb +496 -512
- data/lib/puppet/resource/status.rb +58 -0
- data/lib/puppet/resource/type.rb +311 -0
- data/lib/puppet/resource/type_collection.rb +217 -0
- data/lib/puppet/resource/type_collection_helper.rb +7 -0
- data/lib/puppet/run.rb +77 -0
- data/lib/puppet/simple_graph.rb +381 -413
- data/lib/puppet/ssl.rb +2 -1
- data/lib/puppet/ssl/base.rb +60 -43
- data/lib/puppet/ssl/certificate.rb +21 -21
- data/lib/puppet/ssl/certificate_authority.rb +215 -229
- data/lib/puppet/ssl/certificate_authority/interface.rb +84 -68
- data/lib/puppet/ssl/certificate_factory.rb +119 -119
- data/lib/puppet/ssl/certificate_request.rb +52 -45
- data/lib/puppet/ssl/certificate_revocation_list.rb +78 -78
- data/lib/puppet/ssl/host.rb +230 -228
- data/lib/puppet/ssl/inventory.rb +33 -33
- data/lib/puppet/ssl/key.rb +37 -37
- data/lib/puppet/sslcertificates.rb +124 -123
- data/lib/puppet/sslcertificates/ca.rb +327 -344
- data/lib/puppet/sslcertificates/certificate.rb +197 -224
- data/lib/puppet/sslcertificates/inventory.rb +27 -29
- data/lib/puppet/sslcertificates/support.rb +113 -119
- data/lib/puppet/status.rb +28 -0
- data/lib/puppet/transaction.rb +349 -696
- data/lib/puppet/transaction/change.rb +80 -85
- data/lib/puppet/transaction/event.rb +54 -14
- data/lib/puppet/transaction/event_manager.rb +99 -0
- data/lib/puppet/transaction/report.rb +121 -59
- data/lib/puppet/transaction/resource_harness.rb +150 -0
- data/lib/puppet/transportable.rb +215 -226
- data/lib/puppet/type.rb +1644 -1849
- data/lib/puppet/type/augeas.rb +153 -134
- data/lib/puppet/type/component.rb +63 -65
- data/lib/puppet/type/computer.rb +44 -44
- data/lib/puppet/type/cron.rb +364 -384
- data/lib/puppet/type/exec.rb +583 -521
- data/lib/puppet/type/file.rb +786 -823
- data/lib/puppet/type/file/checksum.rb +23 -240
- data/lib/puppet/type/file/content.rb +193 -129
- data/lib/puppet/type/file/ensure.rb +149 -153
- data/lib/puppet/type/file/group.rb +94 -104
- data/lib/puppet/type/file/mode.rb +109 -122
- data/lib/puppet/type/file/owner.rb +39 -131
- data/lib/puppet/type/file/selcontext.rb +69 -73
- data/lib/puppet/type/file/source.rb +165 -153
- data/lib/puppet/type/file/target.rb +56 -60
- data/lib/puppet/type/file/type.rb +18 -18
- data/lib/puppet/type/filebucket.rb +91 -92
- data/lib/puppet/type/group.rb +77 -82
- data/lib/puppet/type/host.rb +85 -85
- data/lib/puppet/type/k5login.rb +65 -65
- data/lib/puppet/type/macauthorization.rb +141 -143
- data/lib/puppet/type/mailalias.rb +37 -37
- data/lib/puppet/type/maillist.rb +51 -51
- data/lib/puppet/type/mcx.rb +62 -62
- data/lib/puppet/type/mount.rb +199 -193
- data/lib/puppet/type/notify.rb +33 -33
- data/lib/puppet/type/package.rb +301 -298
- data/lib/puppet/type/port.rb +4 -4
- data/lib/puppet/type/resources.rb +107 -123
- data/lib/puppet/type/schedule.rb +317 -326
- data/lib/puppet/type/selboolean.rb +19 -19
- data/lib/puppet/type/selmodule.rb +34 -34
- data/lib/puppet/type/service.rb +152 -152
- data/lib/puppet/type/ssh_authorized_key.rb +74 -78
- data/lib/puppet/type/sshkey.rb +52 -56
- data/lib/puppet/type/stage.rb +18 -0
- data/lib/puppet/type/tidy.rb +289 -300
- data/lib/puppet/type/user.rb +300 -312
- data/lib/puppet/type/yumrepo.rb +300 -335
- data/lib/puppet/type/zfs.rb +36 -36
- data/lib/puppet/type/zone.rb +376 -347
- data/lib/puppet/type/zpool.rb +71 -77
- data/lib/puppet/util.rb +383 -387
- data/lib/puppet/util/autoload.rb +125 -143
- data/lib/puppet/util/autoload/file_cache.rb +78 -101
- data/lib/puppet/util/backups.rb +66 -66
- data/lib/puppet/util/cacher.rb +112 -120
- data/lib/puppet/util/checksums.rb +119 -84
- data/lib/puppet/util/classgen.rb +157 -167
- data/lib/puppet/util/command_line.rb +95 -0
- data/lib/puppet/util/command_line/filebucket +97 -0
- data/lib/puppet/util/command_line/pi +48 -0
- data/lib/puppet/util/command_line/puppet +69 -0
- data/lib/puppet/util/command_line/puppetca +110 -0
- data/lib/puppet/util/command_line/puppetd +186 -0
- data/lib/puppet/util/command_line/puppetdoc +67 -0
- data/lib/puppet/util/command_line/puppetmasterd +65 -0
- data/lib/puppet/util/command_line/puppetqd +53 -0
- data/lib/puppet/util/command_line/puppetrun +128 -0
- data/lib/puppet/util/command_line/ralsh +89 -0
- data/lib/puppet/util/constant_inflector.rb +7 -7
- data/lib/puppet/util/diff.rb +59 -56
- data/lib/puppet/util/docs.rb +97 -99
- data/lib/puppet/util/errors.rb +53 -44
- data/lib/puppet/util/execution.rb +15 -15
- data/lib/puppet/util/feature.rb +62 -72
- data/lib/puppet/util/file_locking.rb +33 -33
- data/lib/puppet/util/fileparsing.rb +292 -318
- data/lib/puppet/util/filetype.rb +246 -263
- data/lib/puppet/util/graph.rb +16 -18
- data/lib/puppet/util/inifile.rb +170 -184
- data/lib/puppet/util/inline_docs.rb +26 -0
- data/lib/puppet/util/instance_loader.rb +58 -58
- data/lib/puppet/util/ldap/connection.rb +57 -59
- data/lib/puppet/util/ldap/generator.rb +31 -31
- data/lib/puppet/util/ldap/manager.rb +233 -235
- data/lib/puppet/util/loadedfile.rb +49 -51
- data/lib/puppet/util/log.rb +210 -494
- data/lib/puppet/util/log/destination.rb +49 -0
- data/lib/puppet/util/log/destinations.rb +217 -0
- data/lib/puppet/util/log_paths.rb +15 -17
- data/lib/puppet/util/logging.rb +34 -13
- data/lib/puppet/util/metaid.rb +15 -15
- data/lib/puppet/util/methodhelper.rb +24 -26
- data/lib/puppet/util/metric.rb +123 -125
- data/lib/puppet/util/monkey_patches.rb +21 -20
- data/lib/puppet/util/nagios_maker.rb +41 -41
- data/lib/puppet/util/package.rb +24 -26
- data/lib/puppet/util/pidlock.rb +49 -49
- data/lib/puppet/util/posix.rb +115 -115
- data/lib/puppet/util/provider_features.rb +147 -155
- data/lib/puppet/util/pson.rb +5 -5
- data/lib/puppet/util/queue.rb +55 -55
- data/lib/puppet/util/queue/stomp.rb +27 -27
- data/lib/puppet/util/rails/cache_accumulator.rb +49 -49
- data/lib/puppet/util/rails/collection_merger.rb +13 -13
- data/lib/puppet/util/rails/reference_serializer.rb +26 -26
- data/lib/puppet/util/rdoc.rb +77 -74
- data/lib/puppet/util/rdoc/code_objects.rb +235 -217
- data/lib/puppet/util/rdoc/generators/puppet_generator.rb +732 -676
- data/lib/puppet/util/rdoc/generators/template/puppet/puppet.rb +38 -12
- data/lib/puppet/util/rdoc/parser.rb +418 -392
- data/lib/puppet/util/reference.rb +168 -174
- data/lib/puppet/util/resource_template.rb +17 -17
- data/lib/puppet/util/run_mode.rb +81 -0
- data/lib/puppet/util/selinux.rb +184 -200
- data/lib/puppet/util/settings.rb +886 -919
- data/lib/puppet/util/settings/boolean_setting.rb +20 -23
- data/lib/puppet/util/settings/file_setting.rb +98 -99
- data/lib/puppet/util/settings/setting.rb +71 -87
- data/lib/puppet/util/storage.rb +73 -84
- data/lib/puppet/util/subclass_loader.rb +59 -66
- data/lib/puppet/util/suidmanager.rb +87 -84
- data/lib/puppet/util/tagging.rb +37 -39
- data/lib/puppet/util/user_attr.rb +14 -14
- data/lib/puppet/util/warnings.rb +20 -20
- data/lib/puppet/util/zaml.rb +242 -241
- data/man/man5/puppet.conf.5 +148 -76
- data/man/man8/filebucket.8 +6 -6
- data/man/man8/pi.8 +5 -5
- data/man/man8/puppet.8 +2 -73
- data/man/man8/puppetca.8 +47 -32
- data/man/man8/puppetd.8 +118 -76
- data/man/man8/puppetdoc.8 +16 -12
- data/man/man8/puppetmasterd.8 +4 -4
- data/man/man8/puppetqd.8 +4 -4
- data/man/man8/puppetrun.8 +23 -22
- data/man/man8/ralsh.8 +16 -17
- data/spec/fixtures/yaml/test.local.yaml +16 -0
- data/spec/integration/application/apply_spec.rb +33 -0
- data/spec/integration/configurer_spec.rb +35 -0
- data/spec/integration/defaults_spec.rb +258 -0
- data/spec/integration/file_serving/content_spec.rb +20 -0
- data/spec/integration/file_serving/fileset_spec.rb +14 -0
- data/spec/integration/file_serving/metadata_spec.rb +21 -0
- data/spec/integration/file_serving/terminus_helper_spec.rb +22 -0
- data/spec/integration/indirector/bucket_file/rest_spec.rb +68 -0
- data/spec/integration/indirector/catalog/compiler_spec.rb +68 -0
- data/spec/integration/indirector/catalog/queue_spec.rb +61 -0
- data/spec/integration/indirector/certificate/rest_spec.rb +68 -0
- data/spec/integration/indirector/certificate_request/rest_spec.rb +88 -0
- data/spec/integration/indirector/certificate_revocation_list/rest_spec.rb +76 -0
- data/spec/integration/indirector/direct_file_server_spec.rb +73 -0
- data/spec/integration/indirector/file_content/file_server_spec.rb +94 -0
- data/spec/integration/indirector/file_metadata/file_server_spec.rb +18 -0
- data/spec/integration/indirector/node/ldap_spec.rb +15 -0
- data/spec/integration/indirector/report/rest_spec.rb +96 -0
- data/spec/integration/indirector/rest_spec.rb +524 -0
- data/spec/integration/network/client_spec.rb +19 -0
- data/spec/integration/network/formats_spec.rb +110 -0
- data/spec/integration/network/handler_spec.rb +25 -0
- data/spec/integration/network/server/mongrel_spec.rb +66 -0
- data/spec/integration/network/server/webrick_spec.rb +85 -0
- data/spec/integration/node/environment_spec.rb +58 -0
- data/spec/integration/node/facts_spec.rb +47 -0
- data/spec/integration/node_spec.rb +93 -0
- data/spec/integration/parser/collector_spec.rb +38 -0
- data/spec/integration/parser/compiler_spec.rb +29 -0
- data/spec/integration/parser/functions/require_spec.rb +44 -0
- data/spec/integration/parser/parser_spec.rb +113 -0
- data/spec/integration/provider/mailalias/aliases_spec.rb +25 -0
- data/spec/integration/provider/package_spec.rb +26 -0
- data/spec/integration/provider/service/init_spec.rb +32 -0
- data/spec/integration/reference/providers_spec.rb +17 -0
- data/spec/integration/reports_spec.rb +18 -0
- data/spec/integration/resource/catalog_spec.rb +61 -0
- data/spec/integration/resource/type_collection_spec.rb +96 -0
- data/spec/integration/ssl/certificate_authority_spec.rb +135 -0
- data/spec/integration/ssl/certificate_request_spec.rb +61 -0
- data/spec/integration/ssl/certificate_revocation_list_spec.rb +42 -0
- data/spec/integration/ssl/host_spec.rb +90 -0
- data/spec/integration/transaction/report_spec.rb +29 -0
- data/spec/integration/transaction_spec.rb +284 -0
- data/spec/integration/type/file_spec.rb +506 -0
- data/spec/integration/type/package_spec.rb +25 -0
- data/spec/integration/type/tidy_spec.rb +32 -0
- data/spec/integration/type_spec.rb +22 -0
- data/spec/integration/util/autoload_spec.rb +114 -0
- data/spec/integration/util/feature_spec.rb +54 -0
- data/spec/integration/util/file_locking_spec.rb +37 -0
- data/spec/integration/util/rdoc/parser_spec.rb +59 -0
- data/spec/integration/util/settings_spec.rb +30 -0
- data/spec/lib/puppet_spec/files.rb +16 -6
- data/spec/monkey_patches/add_confine_and_runnable_to_rspec_dsl.rb +27 -27
- data/spec/monkey_patches/alias_should_to_must.rb +4 -4
- data/spec/shared_behaviours/file_server_terminus.rb +28 -28
- data/spec/shared_behaviours/file_serving.rb +53 -53
- data/spec/shared_behaviours/memory_terminus.rb +22 -22
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +61 -18
- data/spec/spec_specs/runnable_spec.rb +95 -0
- data/spec/unit/agent/locker_spec.rb +100 -0
- data/spec/unit/agent_spec.rb +281 -0
- data/spec/unit/application/agent_spec.rb +588 -0
- data/spec/unit/application/apply_spec.rb +387 -0
- data/spec/unit/application/cert_spec.rb +194 -0
- data/spec/unit/application/describe_spec.rb +84 -0
- data/spec/unit/application/doc_spec.rb +368 -0
- data/spec/unit/application/filebucket_spec.rb +223 -0
- data/spec/unit/application/kick_spec.rb +313 -0
- data/spec/unit/application/master_spec.rb +453 -0
- data/spec/unit/application/queue_spec.rb +186 -0
- data/spec/unit/application/resource_spec.rb +233 -0
- data/spec/unit/application_spec.rb +531 -0
- data/spec/unit/configurer/downloader_spec.rb +188 -0
- data/spec/unit/configurer/fact_handler_spec.rb +164 -0
- data/spec/unit/configurer/plugin_handler_spec.rb +112 -0
- data/spec/unit/configurer_spec.rb +494 -0
- data/spec/unit/daemon_spec.rb +306 -0
- data/spec/unit/dsl/resource_api_spec.rb +181 -0
- data/spec/unit/dsl/resource_type_api_spec.rb +46 -0
- data/spec/unit/file_bucket/dipper_spec.rb +122 -0
- data/spec/unit/file_bucket/file_spec.rb +230 -0
- data/spec/unit/file_collection/lookup_spec.rb +46 -0
- data/spec/unit/file_collection_spec.rb +53 -0
- data/spec/unit/file_serving/base_spec.rb +132 -0
- data/spec/unit/file_serving/configuration/parser_spec.rb +181 -0
- data/spec/unit/file_serving/configuration_spec.rb +249 -0
- data/spec/unit/file_serving/content_spec.rb +118 -0
- data/spec/unit/file_serving/fileset_spec.rb +347 -0
- data/spec/unit/file_serving/indirection_hooks_spec.rb +63 -0
- data/spec/unit/file_serving/metadata_spec.rb +286 -0
- data/spec/unit/file_serving/mount/file_spec.rb +196 -0
- data/spec/unit/file_serving/mount/modules_spec.rb +63 -0
- data/spec/unit/file_serving/mount/plugins_spec.rb +61 -0
- data/spec/unit/file_serving/mount_spec.rb +32 -0
- data/spec/unit/file_serving/terminus_helper_spec.rb +98 -0
- data/spec/unit/indirector/active_record_spec.rb +76 -0
- data/spec/unit/indirector/catalog/active_record_spec.rb +141 -0
- data/spec/unit/indirector/catalog/compiler_spec.rb +275 -0
- data/spec/unit/indirector/catalog/queue_spec.rb +20 -0
- data/spec/unit/indirector/catalog/rest_spec.rb +11 -0
- data/spec/unit/indirector/catalog/yaml_spec.rb +25 -0
- data/spec/unit/indirector/certificate/ca_spec.rb +28 -0
- data/spec/unit/indirector/certificate/file_spec.rb +28 -0
- data/spec/unit/indirector/certificate/rest_spec.rb +58 -0
- data/spec/unit/indirector/certificate_request/ca_spec.rb +19 -0
- data/spec/unit/indirector/certificate_request/file_spec.rb +19 -0
- data/spec/unit/indirector/certificate_request/rest_spec.rb +23 -0
- data/spec/unit/indirector/certificate_revocation_list/ca_spec.rb +21 -0
- data/spec/unit/indirector/certificate_revocation_list/file_spec.rb +20 -0
- data/spec/unit/indirector/certificate_revocation_list/rest_spec.rb +23 -0
- data/spec/unit/indirector/code_spec.rb +33 -0
- data/spec/unit/indirector/direct_file_server_spec.rb +84 -0
- data/spec/unit/indirector/envelope_spec.rb +47 -0
- data/spec/unit/indirector/exec_spec.rb +56 -0
- data/spec/unit/indirector/facts/active_record_spec.rb +104 -0
- data/spec/unit/indirector/facts/couch_spec.rb +98 -0
- data/spec/unit/indirector/facts/facter_spec.rb +143 -0
- data/spec/unit/indirector/facts/rest_spec.rb +11 -0
- data/spec/unit/indirector/facts/yaml_spec.rb +26 -0
- data/spec/unit/indirector/file_bucket_file/file_spec.rb +290 -0
- data/spec/unit/indirector/file_bucket_file/rest_spec.rb +11 -0
- data/spec/unit/indirector/file_content/file_server_spec.rb +18 -0
- data/spec/unit/indirector/file_content/file_spec.rb +18 -0
- data/spec/unit/indirector/file_content/rest_spec.rb +11 -0
- data/spec/unit/indirector/file_metadata/file_server_spec.rb +18 -0
- data/spec/unit/indirector/file_metadata/file_spec.rb +52 -0
- data/spec/unit/indirector/file_metadata/rest_spec.rb +9 -0
- data/spec/unit/indirector/file_server_spec.rb +267 -0
- data/spec/unit/indirector/file_spec.rb +181 -0
- data/spec/unit/indirector/indirection_spec.rb +795 -0
- data/spec/unit/indirector/key/ca_spec.rb +28 -0
- data/spec/unit/indirector/key/file_spec.rb +104 -0
- data/spec/unit/indirector/ldap_spec.rb +143 -0
- data/spec/unit/indirector/memory_spec.rb +29 -0
- data/spec/unit/indirector/node/active_record_spec.rb +41 -0
- data/spec/unit/indirector/node/exec_spec.rb +70 -0
- data/spec/unit/indirector/node/ldap_spec.rb +456 -0
- data/spec/unit/indirector/node/memory_spec.rb +19 -0
- data/spec/unit/indirector/node/plain_spec.rb +19 -0
- data/spec/unit/indirector/node/rest_spec.rb +13 -0
- data/spec/unit/indirector/node/yaml_spec.rb +25 -0
- data/spec/unit/indirector/plain_spec.rb +29 -0
- data/spec/unit/indirector/queue_spec.rb +123 -0
- data/spec/unit/indirector/report/processor_spec.rb +81 -0
- data/spec/unit/indirector/report/rest_spec.rb +28 -0
- data/spec/unit/indirector/request_spec.rb +304 -0
- data/spec/unit/indirector/resource/ral_spec.rb +129 -0
- data/spec/unit/indirector/resource/rest_spec.rb +11 -0
- data/spec/unit/indirector/resource_type/parser_spec.rb +75 -0
- data/spec/unit/indirector/resource_type/rest_spec.rb +15 -0
- data/spec/unit/indirector/rest_spec.rb +455 -0
- data/spec/unit/indirector/run/local_spec.rb +20 -0
- data/spec/unit/indirector/run/rest_spec.rb +11 -0
- data/spec/unit/indirector/ssl_file_spec.rb +281 -0
- data/spec/unit/indirector/status/rest_spec.rb +11 -0
- data/spec/unit/indirector/terminus_spec.rb +245 -0
- data/spec/unit/indirector/yaml_spec.rb +146 -0
- data/spec/unit/indirector_spec.rb +157 -0
- data/spec/unit/module_spec.rb +547 -0
- data/spec/unit/network/authconfig_spec.rb +292 -0
- data/spec/unit/network/authstore_spec.rb +370 -0
- data/spec/unit/network/client_spec.rb +45 -0
- data/spec/unit/network/format_handler_spec.rb +336 -0
- data/spec/unit/network/format_spec.rb +198 -0
- data/spec/unit/network/formats_spec.rb +337 -0
- data/spec/unit/network/handler/fileserver_spec.rb +172 -0
- data/spec/unit/network/http/api/v1_spec.rb +122 -0
- data/spec/unit/network/http/compression_spec.rb +199 -0
- data/spec/unit/network/http/handler_spec.rb +455 -0
- data/spec/unit/network/http/mongrel/rest_spec.rb +249 -0
- data/spec/unit/network/http/mongrel/{xmlrpc.rb → xmlrpc_spec.rb} +0 -0
- data/spec/unit/network/http/mongrel_spec.rb +131 -0
- data/spec/unit/network/http/rack/rest_spec.rb +249 -0
- data/spec/unit/network/http/rack/xmlrpc_spec.rb +157 -0
- data/spec/unit/network/http/rack_spec.rb +102 -0
- data/spec/unit/network/http/webrick/rest_spec.rb +180 -0
- data/spec/unit/network/http/webrick/{xmlrpc.rb → xmlrpc_spec.rb} +0 -0
- data/spec/unit/network/http/webrick_spec.rb +339 -0
- data/spec/unit/network/http_pool_spec.rb +206 -0
- data/spec/unit/network/http_spec.rb +35 -0
- data/spec/unit/network/rest_authconfig_spec.rb +148 -0
- data/spec/unit/network/rest_authorization_spec.rb +43 -0
- data/spec/unit/network/rights_spec.rb +519 -0
- data/spec/unit/network/server_spec.rb +534 -0
- data/spec/unit/network/xmlrpc/client_spec.rb +171 -0
- data/spec/unit/node/environment_spec.rb +248 -0
- data/spec/unit/node/facts_spec.rb +102 -0
- data/spec/unit/node_spec.rb +210 -0
- data/spec/unit/other/selinux_spec.rb +94 -0
- data/spec/unit/other/transbucket_spec.rb +188 -0
- data/spec/unit/other/transobject_spec.rb +112 -0
- data/spec/unit/parameter/value_collection_spec.rb +167 -0
- data/spec/unit/parameter/value_spec.rb +88 -0
- data/spec/unit/parameter_spec.rb +172 -0
- data/spec/unit/parser/ast/arithmetic_operator_spec.rb +73 -0
- data/spec/unit/parser/ast/astarray_spec.rb +72 -0
- data/spec/unit/parser/ast/asthash_spec.rb +98 -0
- data/spec/unit/parser/ast/boolean_operator_spec.rb +53 -0
- data/spec/unit/parser/ast/casestatement_spec.rb +161 -0
- data/spec/unit/parser/ast/collection_spec.rb +63 -0
- data/spec/unit/parser/ast/collexpr_spec.rb +115 -0
- data/spec/unit/parser/ast/comparison_operator_spec.rb +116 -0
- data/spec/unit/parser/ast/function_spec.rb +83 -0
- data/spec/unit/parser/ast/ifstatement_spec.rb +76 -0
- data/spec/unit/parser/ast/in_operator_spec.rb +60 -0
- data/spec/unit/parser/ast/leaf_spec.rb +362 -0
- data/spec/unit/parser/ast/match_operator_spec.rb +50 -0
- data/spec/unit/parser/ast/minus_spec.rb +36 -0
- data/spec/unit/parser/ast/nop_spec.rb +20 -0
- data/spec/unit/parser/ast/not_spec.rb +30 -0
- data/spec/unit/parser/ast/relationship_spec.rb +88 -0
- data/spec/unit/parser/ast/resource_defaults_spec.rb +22 -0
- data/spec/unit/parser/ast/resource_override_spec.rb +51 -0
- data/spec/unit/parser/ast/resource_reference_spec.rb +46 -0
- data/spec/unit/parser/ast/resource_spec.rb +120 -0
- data/spec/unit/parser/ast/selector_spec.rb +139 -0
- data/spec/unit/parser/ast/vardef_spec.rb +60 -0
- data/spec/unit/parser/ast_spec.rb +111 -0
- data/spec/unit/parser/collector_spec.rb +559 -0
- data/spec/unit/parser/compiler_spec.rb +754 -0
- data/spec/unit/parser/files_spec.rb +201 -0
- data/spec/unit/parser/functions/defined_spec.rb +50 -0
- data/spec/unit/parser/functions/fqdn_rand_spec.rb +62 -0
- data/spec/unit/parser/functions/generate_spec.rb +41 -0
- data/spec/unit/parser/functions/inline_template_spec.rb +59 -0
- data/spec/unit/parser/functions/realize_spec.rb +51 -0
- data/spec/unit/parser/functions/regsubst_spec.rb +192 -0
- data/spec/unit/parser/functions/require_spec.rb +74 -0
- data/spec/unit/parser/functions/shellquote_spec.rb +81 -0
- data/spec/unit/parser/functions/split_spec.rb +49 -0
- data/spec/unit/parser/functions/sprintf_spec.rb +41 -0
- data/spec/unit/parser/functions/tag_spec.rb +24 -0
- data/spec/unit/parser/functions/template_spec.rb +62 -0
- data/spec/unit/parser/functions/versioncmp_spec.rb +29 -0
- data/spec/unit/parser/functions_spec.rb +102 -0
- data/spec/unit/parser/lexer_spec.rb +646 -0
- data/spec/unit/parser/parser_spec.rb +412 -0
- data/spec/unit/parser/relationship_spec.rb +70 -0
- data/spec/unit/parser/resource_spec.rb +564 -0
- data/spec/unit/parser/scope_spec.rb +629 -0
- data/spec/unit/parser/templatewrapper_spec.rb +144 -0
- data/spec/unit/parser/type_loader_spec.rb +201 -0
- data/spec/unit/property/ensure_spec.rb +13 -0
- data/spec/unit/property/keyvalue_spec.rb +168 -0
- data/spec/unit/property/list_spec.rb +166 -0
- data/spec/unit/property/ordered_list_spec.rb +64 -0
- data/spec/unit/property_spec.rb +410 -0
- data/spec/unit/provider/augeas/augeas_spec.rb +413 -0
- data/spec/unit/provider/confine/exists_spec.rb +81 -0
- data/spec/unit/provider/confine/false_spec.rb +53 -0
- data/spec/unit/provider/confine/feature_spec.rb +60 -0
- data/spec/unit/provider/confine/true_spec.rb +53 -0
- data/spec/unit/provider/confine/variable_spec.rb +107 -0
- data/spec/unit/provider/confine_collection_spec.rb +134 -0
- data/spec/unit/provider/confine_spec.rb +78 -0
- data/spec/unit/provider/confiner_spec.rb +63 -0
- data/spec/unit/provider/group/groupadd_spec.rb +31 -0
- data/spec/unit/provider/group/ldap_spec.rb +105 -0
- data/spec/unit/provider/ldap_spec.rb +248 -0
- data/spec/unit/provider/macauthorization_spec.rb +147 -0
- data/spec/unit/provider/mcx/mcxcontent_spec.rb +175 -0
- data/spec/unit/provider/mount/parsed_spec.rb +193 -0
- data/spec/unit/provider/mount_spec.rb +130 -0
- data/spec/unit/provider/naginator_spec.rb +58 -0
- data/spec/unit/provider/package/aix_spec.rb +66 -0
- data/spec/unit/provider/package/apt_spec.rb +145 -0
- data/spec/unit/provider/package/dpkg_spec.rb +225 -0
- data/spec/unit/provider/package/gem_spec.rb +87 -0
- data/spec/unit/provider/package/hpux_spec.rb +52 -0
- data/spec/unit/provider/package/nim_spec.rb +42 -0
- data/spec/unit/provider/package/pkg_spec.rb +63 -0
- data/spec/unit/provider/package/pkgdmg_spec.rb +84 -0
- data/spec/unit/provider/package/zypper_spec.rb +81 -0
- data/spec/unit/provider/parsedfile_spec.rb +95 -0
- data/spec/unit/provider/selboolean_spec.rb +37 -0
- data/spec/unit/provider/selmodule_spec.rb +66 -0
- data/spec/unit/provider/service/daemontools_spec.rb +166 -0
- data/spec/unit/provider/service/debian_spec.rb +89 -0
- data/spec/unit/provider/service/init_spec.rb +168 -0
- data/spec/unit/provider/service/launchd_spec.rb +200 -0
- data/spec/unit/provider/service/redhat_spec.rb +121 -0
- data/spec/unit/provider/service/runit_spec.rb +140 -0
- data/spec/unit/provider/service/src_spec.rb +97 -0
- data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +228 -0
- data/spec/unit/provider/sshkey/parsed_spec.rb +38 -0
- data/spec/unit/provider/user/hpux_spec.rb +25 -0
- data/spec/unit/provider/user/ldap_spec.rb +279 -0
- data/spec/unit/provider/user/user_role_add_spec.rb +249 -0
- data/spec/unit/provider/user/useradd_spec.rb +115 -0
- data/spec/unit/provider/zfs/solaris_spec.rb +99 -0
- data/spec/unit/provider/zone/solaris_spec.rb +55 -0
- data/spec/unit/provider/zpool/solaris_spec.rb +179 -0
- data/spec/unit/provider_spec.rb +31 -0
- data/spec/unit/puppet_spec.rb +12 -0
- data/spec/unit/rails/host_spec.rb +163 -0
- data/spec/unit/rails/param_value_spec.rb +49 -0
- data/spec/unit/rails/resource_spec.rb +123 -0
- data/spec/unit/rails_spec.rb +258 -0
- data/spec/unit/relationship_spec.rb +236 -0
- data/spec/unit/reports/http_spec.rb +56 -0
- data/spec/unit/reports/tagmail_spec.rb +94 -0
- data/spec/unit/reports_spec.rb +61 -0
- data/spec/unit/resource/catalog_spec.rb +1078 -0
- data/spec/unit/resource/status_spec.rb +103 -0
- data/spec/unit/resource/type_collection_helper_spec.rb +25 -0
- data/spec/unit/resource/type_collection_spec.rb +432 -0
- data/spec/unit/resource/type_spec.rb +722 -0
- data/spec/unit/resource_spec.rb +818 -0
- data/spec/unit/run_spec.rb +137 -0
- data/spec/unit/simple_graph_spec.rb +544 -0
- data/spec/unit/ssl/base_spec.rb +43 -0
- data/spec/unit/ssl/certificate_authority/interface_spec.rb +333 -0
- data/spec/unit/ssl/certificate_authority_spec.rb +772 -0
- data/spec/unit/ssl/certificate_factory_spec.rb +107 -0
- data/spec/unit/ssl/certificate_request_spec.rb +220 -0
- data/spec/unit/ssl/certificate_revocation_list_spec.rb +168 -0
- data/spec/unit/ssl/certificate_spec.rb +124 -0
- data/spec/unit/ssl/host_spec.rb +707 -0
- data/spec/unit/ssl/inventory_spec.rb +180 -0
- data/spec/unit/ssl/key_spec.rb +198 -0
- data/spec/unit/status_spec.rb +31 -0
- data/spec/unit/transaction/change_spec.rb +193 -0
- data/spec/unit/transaction/event_manager_spec.rb +260 -0
- data/spec/unit/transaction/event_spec.rb +108 -0
- data/spec/unit/transaction/report_spec.rb +234 -0
- data/spec/unit/transaction/resource_harness_spec.rb +401 -0
- data/spec/unit/transaction_spec.rb +452 -0
- data/spec/unit/transportable_spec.rb +0 -0
- data/spec/unit/type/augeas_spec.rb +122 -0
- data/spec/unit/type/component_spec.rb +63 -0
- data/spec/unit/type/computer_spec.rb +81 -0
- data/spec/unit/type/cron_spec.rb +33 -0
- data/spec/unit/type/exec_spec.rb +162 -0
- data/spec/unit/type/file/checksum_spec.rb +73 -0
- data/spec/unit/type/file/content_spec.rb +460 -0
- data/spec/unit/type/file/ensure_spec.rb +84 -0
- data/spec/unit/type/file/group_spec.rb +123 -0
- data/spec/unit/type/file/owner_spec.rb +150 -0
- data/spec/unit/type/file/selinux_spec.rb +83 -0
- data/spec/unit/type/file/source_spec.rb +272 -0
- data/spec/unit/type/file_spec.rb +1070 -0
- data/spec/unit/type/filebucket_spec.rb +74 -0
- data/spec/unit/type/group_spec.rb +57 -0
- data/spec/unit/type/macauthorization_spec.rb +111 -0
- data/spec/unit/type/maillist_spec.rb +42 -0
- data/spec/unit/type/mcx_spec.rb +100 -0
- data/spec/unit/type/mount_spec.rb +261 -0
- data/spec/unit/type/nagios_spec.rb +63 -0
- data/spec/unit/type/noop_metaparam_spec.rb +37 -0
- data/spec/unit/type/package_spec.rb +240 -0
- data/spec/unit/type/resources_spec.rb +102 -0
- data/spec/unit/type/schedule_spec.rb +333 -0
- data/spec/unit/type/selboolean_spec.rb +45 -0
- data/spec/unit/type/selmodule_spec.rb +18 -0
- data/spec/unit/type/service_spec.rb +222 -0
- data/spec/unit/type/ssh_authorized_key_spec.rb +152 -0
- data/spec/unit/type/stage_spec.rb +9 -0
- data/spec/unit/type/tidy_spec.rb +424 -0
- data/spec/unit/type/user_spec.rb +281 -0
- data/spec/unit/type/zfs_spec.rb +45 -0
- data/spec/unit/type/zone_spec.rb +60 -0
- data/spec/unit/type/zpool_spec.rb +110 -0
- data/spec/unit/type_spec.rb +566 -0
- data/spec/unit/util/autoload/file_cache_spec.rb +159 -0
- data/spec/unit/util/autoload_spec.rb +120 -0
- data/spec/unit/util/backups_spec.rb +159 -0
- data/spec/unit/util/cache_accumulator_spec.rb +75 -0
- data/spec/unit/util/cacher_spec.rb +185 -0
- data/spec/unit/util/checksums_spec.rb +153 -0
- data/spec/unit/util/command_line_spec.rb +108 -0
- data/spec/unit/util/constant_inflector_spec.rb +70 -0
- data/spec/unit/util/errors_spec.rb +38 -0
- data/spec/unit/util/feature_spec.rb +72 -0
- data/spec/unit/util/file_locking_spec.rb +156 -0
- data/spec/unit/util/filetype_spec.rb +100 -0
- data/spec/unit/util/inline_docs_spec.rb +32 -0
- data/spec/unit/util/json_spec.rb +21 -0
- data/spec/unit/util/ldap/connection_spec.rb +169 -0
- data/spec/unit/util/ldap/generator_spec.rb +54 -0
- data/spec/unit/util/ldap/manager_spec.rb +654 -0
- data/spec/unit/util/loadedfile_spec.rb +65 -0
- data/spec/unit/util/log/destinations_spec.rb +24 -0
- data/spec/unit/util/log_spec.rb +215 -0
- data/spec/unit/util/logging_spec.rb +95 -0
- data/spec/unit/util/metric_spec.rb +95 -0
- data/spec/unit/util/monkey_patches_spec.rb +7 -0
- data/spec/unit/util/nagios_maker_spec.rb +126 -0
- data/spec/unit/util/package_spec.rb +21 -0
- data/spec/unit/util/posix_spec.rb +256 -0
- data/spec/unit/util/queue/stomp_spec.rb +140 -0
- data/spec/unit/util/queue_spec.rb +96 -0
- data/spec/unit/util/rdoc/parser_spec.rb +540 -0
- data/spec/unit/util/rdoc_spec.rb +165 -0
- data/spec/unit/util/reference_serializer_spec.rb +52 -0
- data/spec/unit/util/resource_template_spec.rb +58 -0
- data/spec/unit/util/run_mode_spec.rb +51 -0
- data/spec/unit/util/selinux_spec.rb +278 -0
- data/spec/unit/util/settings/file_setting_spec.rb +256 -0
- data/spec/unit/util/settings_spec.rb +1099 -0
- data/spec/unit/util/storage_spec.rb +235 -0
- data/spec/unit/util/tagging_spec.rb +102 -0
- data/spec/unit/util/user_attr_spec.rb +47 -0
- data/spec/unit/util/warnings_spec.rb +39 -0
- data/spec/unit/util/zaml_spec.rb +38 -0
- data/tasks/rake/git_workflow.rake +1 -1
- data/tasks/rake/sign.rake +2 -2
- data/test/certmgr/ca.rb +61 -61
- data/test/certmgr/certmgr.rb +292 -283
- data/test/certmgr/inventory.rb +44 -42
- data/test/certmgr/support.rb +78 -77
- data/test/data/providers/ssh_authorized_key/parsed/authorized_keys +1 -1
- data/test/data/snippets/hash.pp +33 -0
- data/test/language/ast.rb +68 -117
- data/test/language/ast/variable.rb +14 -15
- data/test/language/functions.rb +404 -463
- data/test/language/parser.rb +670 -1135
- data/test/language/scope.rb +198 -402
- data/test/language/snippets.rb +439 -447
- data/test/language/transportable.rb +67 -66
- data/test/lib/puppettest.rb +260 -268
- data/test/lib/puppettest/certificates.rb +51 -53
- data/test/lib/puppettest/exetest.rb +107 -111
- data/test/lib/puppettest/fakes.rb +153 -158
- data/test/lib/puppettest/fileparsing.rb +17 -17
- data/test/lib/puppettest/filetesting.rb +204 -213
- data/test/lib/puppettest/parsertesting.rb +382 -365
- data/test/lib/puppettest/railstesting.rb +49 -50
- data/test/lib/puppettest/reporttesting.rb +10 -10
- data/test/lib/puppettest/resourcetesting.rb +45 -36
- data/test/lib/puppettest/runnable_test.rb +36 -28
- data/test/lib/puppettest/servertest.rb +54 -51
- data/test/lib/puppettest/support/assertions.rb +48 -55
- data/test/lib/puppettest/support/helpers.rb +12 -16
- data/test/lib/puppettest/support/resources.rb +23 -25
- data/test/lib/puppettest/support/utils.rb +138 -148
- data/test/lib/puppettest/testcase.rb +15 -17
- data/test/lib/rake/puppet_test_loader.rb +1 -3
- data/test/lib/rake/puppet_testtask.rb +10 -10
- data/test/network/authconfig.rb +48 -50
- data/test/network/authorization.rb +114 -113
- data/test/network/authstore.rb +454 -406
- data/test/network/client/ca.rb +46 -48
- data/test/network/client/dipper.rb +22 -22
- data/test/network/client_request.rb +20 -20
- data/test/network/handler/ca.rb +251 -252
- data/test/network/handler/fileserver.rb +1071 -1001
- data/test/network/handler/master.rb +58 -58
- data/test/network/handler/report.rb +64 -64
- data/test/network/handler/runner.rb +8 -8
- data/test/network/rights.rb +22 -19
- data/test/network/server/mongrel_test.rb +87 -87
- data/test/network/server/webrick.rb +99 -87
- data/test/network/xmlrpc/client.rb +30 -30
- data/test/network/xmlrpc/processor.rb +52 -53
- data/test/network/xmlrpc/server.rb +10 -11
- data/test/network/xmlrpc/webrick_servlet.rb +21 -18
- data/test/other/provider.rb +69 -84
- data/test/other/puppet.rb +61 -76
- data/test/other/relationships.rb +73 -65
- data/test/other/report.rb +88 -187
- data/test/other/transactions.rb +363 -885
- data/test/puppet/defaults.rb +51 -54
- data/test/puppet/errortest.rb +8 -8
- data/test/puppet/tc_suidmanager.rb +106 -103
- data/test/rails/rails.rb +8 -9
- data/test/rails/railsparameter.rb +60 -54
- data/test/ral/manager/attributes.rb +262 -260
- data/test/ral/manager/instances.rb +77 -78
- data/test/ral/manager/manager.rb +36 -36
- data/test/ral/manager/provider.rb +56 -79
- data/test/ral/manager/type.rb +308 -449
- data/test/ral/providers/cron/crontab.rb +561 -545
- data/test/ral/providers/group.rb +203 -212
- data/test/ral/providers/host/parsed.rb +189 -180
- data/test/ral/providers/mailalias/aliases.rb +40 -40
- data/test/ral/providers/nameservice.rb +21 -21
- data/test/ral/providers/package.rb +207 -214
- data/test/ral/providers/package/aptitude.rb +75 -63
- data/test/ral/providers/package/aptrpm.rb +84 -72
- data/test/ral/providers/parsedfile.rb +510 -509
- data/test/ral/providers/port/parsed.rb +5 -5
- data/test/ral/providers/provider.rb +421 -421
- data/test/ral/providers/service/base.rb +59 -53
- data/test/ral/providers/sshkey/parsed.rb +86 -83
- data/test/ral/providers/user.rb +471 -451
- data/test/ral/providers/user/useradd.rb +168 -177
- data/test/ral/type/cron.rb +406 -393
- data/test/ral/type/exec.rb +721 -641
- data/test/ral/type/file.rb +827 -896
- data/test/ral/type/file/target.rb +295 -251
- data/test/ral/type/fileignoresource.rb +232 -205
- data/test/ral/type/filesources.rb +446 -485
- data/test/ral/type/host.rb +124 -153
- data/test/ral/type/mailalias.rb +28 -31
- data/test/ral/type/port.rb +7 -7
- data/test/ral/type/resources.rb +88 -93
- data/test/ral/type/service.rb +19 -19
- data/test/ral/type/sshkey.rb +120 -160
- data/test/ral/type/user.rb +132 -414
- data/test/ral/type/yumrepo.rb +95 -92
- data/test/ral/type/zone.rb +316 -287
- data/test/test +1 -1
- data/test/util/classgen.rb +182 -167
- data/test/util/execution.rb +18 -18
- data/test/util/fileparsing.rb +580 -540
- data/test/util/inifile.rb +117 -106
- data/test/util/instance_loader.rb +29 -29
- data/test/util/log.rb +202 -198
- data/test/util/metrics.rb +51 -51
- data/test/util/package.rb +11 -12
- data/test/util/pidlock.rb +115 -115
- data/test/util/settings.rb +613 -557
- data/test/util/storage.rb +71 -88
- data/test/util/subclass_loader.rb +69 -72
- data/test/util/utiltest.rb +204 -203
- metadata +493 -395
- data/lib/puppet/agent/runner.rb +0 -65
- data/lib/puppet/application/pi.rb +0 -214
- data/lib/puppet/application/puppet.rb +0 -181
- data/lib/puppet/application/puppetca.rb +0 -71
- data/lib/puppet/application/puppetd.rb +0 -250
- data/lib/puppet/application/puppetdoc.rb +0 -224
- data/lib/puppet/application/puppetmasterd.rb +0 -168
- data/lib/puppet/application/puppetqd.rb +0 -96
- data/lib/puppet/application/puppetrun.rb +0 -210
- data/lib/puppet/application/ralsh.rb +0 -152
- data/lib/puppet/checksum.rb +0 -57
- data/lib/puppet/indirector/checksum/file.rb +0 -33
- data/lib/puppet/indirector/runner/rest.rb +0 -7
- data/lib/puppet/network/client/dipper.rb +0 -85
- data/lib/puppet/network/client/resource.rb +0 -38
- data/lib/puppet/network/handler/resource.rb +0 -190
- data/lib/puppet/parser/ast/definition.rb +0 -207
- data/lib/puppet/parser/ast/hostclass.rb +0 -95
- data/lib/puppet/parser/ast/node.rb +0 -42
- data/lib/puppet/parser/interpreter.rb +0 -84
- data/lib/puppet/parser/loaded_code.rb +0 -119
- data/lib/puppet/parser/resource/reference.rb +0 -99
- data/lib/puppet/resource/reference.rb +0 -90
- data/lib/puppet/util/config_store.rb +0 -61
- data/spec/integration/application/puppet.rb +0 -33
- data/spec/integration/bin/puppetmasterd.rb +0 -122
- data/spec/integration/checksum.rb +0 -48
- data/spec/integration/configurer.rb +0 -18
- data/spec/integration/defaults.rb +0 -230
- data/spec/integration/file_serving/content.rb +0 -20
- data/spec/integration/file_serving/fileset.rb +0 -14
- data/spec/integration/file_serving/metadata.rb +0 -21
- data/spec/integration/file_serving/terminus_helper.rb +0 -22
- data/spec/integration/indirector/catalog/compiler.rb +0 -67
- data/spec/integration/indirector/catalog/queue.rb +0 -61
- data/spec/integration/indirector/certificate/rest.rb +0 -70
- data/spec/integration/indirector/certificate_request/rest.rb +0 -88
- data/spec/integration/indirector/certificate_revocation_list/rest.rb +0 -76
- data/spec/integration/indirector/direct_file_server.rb +0 -73
- data/spec/integration/indirector/file_content/file_server.rb +0 -94
- data/spec/integration/indirector/file_metadata/file_server.rb +0 -18
- data/spec/integration/indirector/node/ldap.rb +0 -15
- data/spec/integration/indirector/report/rest.rb +0 -94
- data/spec/integration/indirector/rest.rb +0 -523
- data/spec/integration/network/client.rb +0 -19
- data/spec/integration/network/formats.rb +0 -110
- data/spec/integration/network/handler.rb +0 -25
- data/spec/integration/network/server/mongrel.rb +0 -66
- data/spec/integration/network/server/webrick.rb +0 -86
- data/spec/integration/node.rb +0 -93
- data/spec/integration/node/environment.rb +0 -58
- data/spec/integration/node/facts.rb +0 -47
- data/spec/integration/parser/compiler.rb +0 -29
- data/spec/integration/parser/functions/require.rb +0 -86
- data/spec/integration/provider/mailalias/aliases.rb +0 -25
- data/spec/integration/provider/package.rb +0 -26
- data/spec/integration/provider/service/init.rb +0 -32
- data/spec/integration/reference/providers.rb +0 -17
- data/spec/integration/reports.rb +0 -18
- data/spec/integration/resource/catalog.rb +0 -61
- data/spec/integration/ssl/certificate_authority.rb +0 -135
- data/spec/integration/ssl/certificate_request.rb +0 -61
- data/spec/integration/ssl/certificate_revocation_list.rb +0 -42
- data/spec/integration/ssl/host.rb +0 -90
- data/spec/integration/transaction.rb +0 -66
- data/spec/integration/transaction/report.rb +0 -29
- data/spec/integration/type.rb +0 -22
- data/spec/integration/type/file.rb +0 -477
- data/spec/integration/type/package.rb +0 -25
- data/spec/integration/type/tidy.rb +0 -27
- data/spec/integration/util/autoload.rb +0 -114
- data/spec/integration/util/feature.rb +0 -54
- data/spec/integration/util/file_locking.rb +0 -37
- data/spec/integration/util/settings.rb +0 -27
- data/spec/unit/agent.rb +0 -259
- data/spec/unit/agent/locker.rb +0 -100
- data/spec/unit/agent/runner.rb +0 -118
- data/spec/unit/application.rb +0 -420
- data/spec/unit/application/filebucket.rb +0 -220
- data/spec/unit/application/pi.rb +0 -84
- data/spec/unit/application/puppet.rb +0 -399
- data/spec/unit/application/puppetca.rb +0 -142
- data/spec/unit/application/puppetd.rb +0 -502
- data/spec/unit/application/puppetdoc.rb +0 -360
- data/spec/unit/application/puppetmasterd.rb +0 -457
- data/spec/unit/application/puppetqd.rb +0 -186
- data/spec/unit/application/puppetrun.rb +0 -289
- data/spec/unit/application/ralsh.rb +0 -254
- data/spec/unit/configurer.rb +0 -339
- data/spec/unit/configurer/downloader.rb +0 -188
- data/spec/unit/configurer/fact_handler.rb +0 -164
- data/spec/unit/configurer/plugin_handler.rb +0 -112
- data/spec/unit/daemon.rb +0 -287
- data/spec/unit/file_collection.rb +0 -53
- data/spec/unit/file_collection/lookup.rb +0 -46
- data/spec/unit/file_serving/base.rb +0 -132
- data/spec/unit/file_serving/configuration.rb +0 -249
- data/spec/unit/file_serving/configuration/parser.rb +0 -181
- data/spec/unit/file_serving/content.rb +0 -110
- data/spec/unit/file_serving/fileset.rb +0 -347
- data/spec/unit/file_serving/indirection_hooks.rb +0 -63
- data/spec/unit/file_serving/metadata.rb +0 -286
- data/spec/unit/file_serving/mount.rb +0 -32
- data/spec/unit/file_serving/mount/file.rb +0 -196
- data/spec/unit/file_serving/mount/modules.rb +0 -63
- data/spec/unit/file_serving/mount/plugins.rb +0 -61
- data/spec/unit/file_serving/terminus_helper.rb +0 -98
- data/spec/unit/indirector.rb +0 -157
- data/spec/unit/indirector/active_record.rb +0 -76
- data/spec/unit/indirector/catalog/active_record.rb +0 -141
- data/spec/unit/indirector/catalog/compiler.rb +0 -261
- data/spec/unit/indirector/catalog/queue.rb +0 -20
- data/spec/unit/indirector/catalog/rest.rb +0 -11
- data/spec/unit/indirector/catalog/yaml.rb +0 -25
- data/spec/unit/indirector/certificate/ca.rb +0 -28
- data/spec/unit/indirector/certificate/file.rb +0 -28
- data/spec/unit/indirector/certificate/rest.rb +0 -57
- data/spec/unit/indirector/certificate_request/ca.rb +0 -19
- data/spec/unit/indirector/certificate_request/file.rb +0 -19
- data/spec/unit/indirector/certificate_request/rest.rb +0 -23
- data/spec/unit/indirector/certificate_revocation_list/ca.rb +0 -21
- data/spec/unit/indirector/certificate_revocation_list/file.rb +0 -20
- data/spec/unit/indirector/certificate_revocation_list/rest.rb +0 -23
- data/spec/unit/indirector/checksum/file.rb +0 -139
- data/spec/unit/indirector/code.rb +0 -33
- data/spec/unit/indirector/direct_file_server.rb +0 -84
- data/spec/unit/indirector/envelope.rb +0 -47
- data/spec/unit/indirector/exec.rb +0 -56
- data/spec/unit/indirector/facts/active_record.rb +0 -104
- data/spec/unit/indirector/facts/facter.rb +0 -142
- data/spec/unit/indirector/facts/rest.rb +0 -11
- data/spec/unit/indirector/facts/yaml.rb +0 -26
- data/spec/unit/indirector/file.rb +0 -161
- data/spec/unit/indirector/file_content/file.rb +0 -18
- data/spec/unit/indirector/file_content/file_server.rb +0 -18
- data/spec/unit/indirector/file_content/rest.rb +0 -11
- data/spec/unit/indirector/file_metadata/file.rb +0 -52
- data/spec/unit/indirector/file_metadata/file_server.rb +0 -18
- data/spec/unit/indirector/file_metadata/rest.rb +0 -9
- data/spec/unit/indirector/file_server.rb +0 -267
- data/spec/unit/indirector/indirection.rb +0 -795
- data/spec/unit/indirector/key/ca.rb +0 -28
- data/spec/unit/indirector/key/file.rb +0 -104
- data/spec/unit/indirector/ldap.rb +0 -143
- data/spec/unit/indirector/memory.rb +0 -29
- data/spec/unit/indirector/node/active_record.rb +0 -34
- data/spec/unit/indirector/node/exec.rb +0 -69
- data/spec/unit/indirector/node/ldap.rb +0 -458
- data/spec/unit/indirector/node/memory.rb +0 -19
- data/spec/unit/indirector/node/plain.rb +0 -19
- data/spec/unit/indirector/node/rest.rb +0 -13
- data/spec/unit/indirector/node/yaml.rb +0 -25
- data/spec/unit/indirector/plain.rb +0 -29
- data/spec/unit/indirector/queue.rb +0 -123
- data/spec/unit/indirector/report/processor.rb +0 -81
- data/spec/unit/indirector/report/rest.rb +0 -28
- data/spec/unit/indirector/request.rb +0 -308
- data/spec/unit/indirector/rest.rb +0 -403
- data/spec/unit/indirector/runner/rest.rb +0 -11
- data/spec/unit/indirector/ssl_file.rb +0 -280
- data/spec/unit/indirector/terminus.rb +0 -245
- data/spec/unit/indirector/yaml.rb +0 -145
- data/spec/unit/module.rb +0 -247
- data/spec/unit/network/authconfig.rb +0 -292
- data/spec/unit/network/authstore.rb +0 -370
- data/spec/unit/network/client.rb +0 -45
- data/spec/unit/network/client/dipper.rb +0 -16
- data/spec/unit/network/format.rb +0 -191
- data/spec/unit/network/format_handler.rb +0 -327
- data/spec/unit/network/formats.rb +0 -365
- data/spec/unit/network/handler/fileserver.rb +0 -176
- data/spec/unit/network/http.rb +0 -35
- data/spec/unit/network/http/api/v1.rb +0 -122
- data/spec/unit/network/http/handler.rb +0 -458
- data/spec/unit/network/http/mongrel.rb +0 -131
- data/spec/unit/network/http/mongrel/rest.rb +0 -232
- data/spec/unit/network/http/rack.rb +0 -102
- data/spec/unit/network/http/rack/rest.rb +0 -199
- data/spec/unit/network/http/rack/xmlrpc.rb +0 -157
- data/spec/unit/network/http/webrick.rb +0 -339
- data/spec/unit/network/http/webrick/rest.rb +0 -157
- data/spec/unit/network/http_pool.rb +0 -206
- data/spec/unit/network/rest_authconfig.rb +0 -146
- data/spec/unit/network/rest_authorization.rb +0 -43
- data/spec/unit/network/rights.rb +0 -519
- data/spec/unit/network/server.rb +0 -534
- data/spec/unit/network/xmlrpc/client.rb +0 -171
- data/spec/unit/node.rb +0 -200
- data/spec/unit/node/environment.rb +0 -187
- data/spec/unit/node/facts.rb +0 -97
- data/spec/unit/other/checksum.rb +0 -92
- data/spec/unit/other/selinux.rb +0 -85
- data/spec/unit/other/transbucket.rb +0 -188
- data/spec/unit/other/transobject.rb +0 -112
- data/spec/unit/parameter.rb +0 -405
- data/spec/unit/parser/ast.rb +0 -41
- data/spec/unit/parser/ast/arithmetic_operator.rb +0 -73
- data/spec/unit/parser/ast/astarray.rb +0 -72
- data/spec/unit/parser/ast/boolean_operator.rb +0 -53
- data/spec/unit/parser/ast/casestatement.rb +0 -135
- data/spec/unit/parser/ast/collection.rb +0 -63
- data/spec/unit/parser/ast/collexpr.rb +0 -115
- data/spec/unit/parser/ast/comparison_operator.rb +0 -92
- data/spec/unit/parser/ast/definition.rb +0 -213
- data/spec/unit/parser/ast/function.rb +0 -83
- data/spec/unit/parser/ast/hostclass.rb +0 -148
- data/spec/unit/parser/ast/ifstatement.rb +0 -76
- data/spec/unit/parser/ast/leaf.rb +0 -298
- data/spec/unit/parser/ast/match_operator.rb +0 -50
- data/spec/unit/parser/ast/minus.rb +0 -36
- data/spec/unit/parser/ast/node.rb +0 -145
- data/spec/unit/parser/ast/nop.rb +0 -20
- data/spec/unit/parser/ast/not.rb +0 -30
- data/spec/unit/parser/ast/resource.rb +0 -103
- data/spec/unit/parser/ast/resource_override.rb +0 -51
- data/spec/unit/parser/ast/resource_reference.rb +0 -69
- data/spec/unit/parser/ast/selector.rb +0 -155
- data/spec/unit/parser/ast/vardef.rb +0 -47
- data/spec/unit/parser/collector.rb +0 -556
- data/spec/unit/parser/compiler.rb +0 -604
- data/spec/unit/parser/files.rb +0 -190
- data/spec/unit/parser/functions.rb +0 -83
- data/spec/unit/parser/functions/fqdn_rand.rb +0 -62
- data/spec/unit/parser/functions/generate.rb +0 -41
- data/spec/unit/parser/functions/inline_template.rb +0 -59
- data/spec/unit/parser/functions/realize.rb +0 -51
- data/spec/unit/parser/functions/regsubst.rb +0 -168
- data/spec/unit/parser/functions/require.rb +0 -69
- data/spec/unit/parser/functions/shellquote.rb +0 -92
- data/spec/unit/parser/functions/split.rb +0 -51
- data/spec/unit/parser/functions/sprintf.rb +0 -42
- data/spec/unit/parser/functions/template.rb +0 -62
- data/spec/unit/parser/functions/versioncmp.rb +0 -29
- data/spec/unit/parser/interpreter.rb +0 -147
- data/spec/unit/parser/lexer.rb +0 -731
- data/spec/unit/parser/loaded_code.rb +0 -215
- data/spec/unit/parser/parser.rb +0 -423
- data/spec/unit/parser/resource.rb +0 -529
- data/spec/unit/parser/resource/reference.rb +0 -111
- data/spec/unit/parser/scope.rb +0 -387
- data/spec/unit/parser/templatewrapper.rb +0 -134
- data/spec/unit/property.rb +0 -305
- data/spec/unit/property/keyvalue.rb +0 -168
- data/spec/unit/property/list.rb +0 -166
- data/spec/unit/property/ordered_list.rb +0 -64
- data/spec/unit/provider.rb +0 -31
- data/spec/unit/provider/augeas/augeas.rb +0 -413
- data/spec/unit/provider/confine.rb +0 -78
- data/spec/unit/provider/confine/exists.rb +0 -81
- data/spec/unit/provider/confine/false.rb +0 -53
- data/spec/unit/provider/confine/feature.rb +0 -60
- data/spec/unit/provider/confine/true.rb +0 -53
- data/spec/unit/provider/confine/variable.rb +0 -107
- data/spec/unit/provider/confine_collection.rb +0 -134
- data/spec/unit/provider/confiner.rb +0 -63
- data/spec/unit/provider/group/groupadd.rb +0 -31
- data/spec/unit/provider/group/ldap.rb +0 -105
- data/spec/unit/provider/ldap.rb +0 -248
- data/spec/unit/provider/macauthorization.rb +0 -147
- data/spec/unit/provider/mcx/mcxcontent.rb +0 -175
- data/spec/unit/provider/mount.rb +0 -130
- data/spec/unit/provider/mount/parsed.rb +0 -194
- data/spec/unit/provider/naginator.rb +0 -58
- data/spec/unit/provider/package/apt.rb +0 -138
- data/spec/unit/provider/package/dpkg.rb +0 -170
- data/spec/unit/provider/package/gem.rb +0 -87
- data/spec/unit/provider/package/hpux.rb +0 -52
- data/spec/unit/provider/package/pkgdmg.rb +0 -73
- data/spec/unit/provider/parsedfile.rb +0 -95
- data/spec/unit/provider/selboolean.rb +0 -37
- data/spec/unit/provider/selmodule.rb +0 -66
- data/spec/unit/provider/service/daemontools.rb +0 -166
- data/spec/unit/provider/service/debian.rb +0 -89
- data/spec/unit/provider/service/init.rb +0 -121
- data/spec/unit/provider/service/launchd.rb +0 -200
- data/spec/unit/provider/service/redhat.rb +0 -96
- data/spec/unit/provider/service/runit.rb +0 -140
- data/spec/unit/provider/ssh_authorized_key/parsed.rb +0 -206
- data/spec/unit/provider/sshkey/parsed.rb +0 -38
- data/spec/unit/provider/user/hpux.rb +0 -25
- data/spec/unit/provider/user/ldap.rb +0 -279
- data/spec/unit/provider/user/user_role_add.rb +0 -249
- data/spec/unit/provider/user/useradd.rb +0 -115
- data/spec/unit/provider/zfs/solaris.rb +0 -99
- data/spec/unit/provider/zone/solaris.rb +0 -42
- data/spec/unit/provider/zpool/solaris.rb +0 -179
- data/spec/unit/rails.rb +0 -133
- data/spec/unit/rails/host.rb +0 -163
- data/spec/unit/rails/param_value.rb +0 -49
- data/spec/unit/rails/resource.rb +0 -107
- data/spec/unit/relationship.rb +0 -236
- data/spec/unit/reports.rb +0 -61
- data/spec/unit/resource.rb +0 -495
- data/spec/unit/resource/catalog.rb +0 -1053
- data/spec/unit/resource/reference.rb +0 -111
- data/spec/unit/simple_graph.rb +0 -551
- data/spec/unit/ssl/certificate.rb +0 -124
- data/spec/unit/ssl/certificate_authority.rb +0 -741
- data/spec/unit/ssl/certificate_authority/interface.rb +0 -269
- data/spec/unit/ssl/certificate_factory.rb +0 -107
- data/spec/unit/ssl/certificate_request.rb +0 -193
- data/spec/unit/ssl/certificate_revocation_list.rb +0 -168
- data/spec/unit/ssl/host.rb +0 -704
- data/spec/unit/ssl/inventory.rb +0 -180
- data/spec/unit/ssl/key.rb +0 -198
- data/spec/unit/transaction.rb +0 -146
- data/spec/unit/transaction/change.rb +0 -187
- data/spec/unit/transaction/event.rb +0 -25
- data/spec/unit/transaction/report.rb +0 -40
- data/spec/unit/type.rb +0 -426
- data/spec/unit/type/augeas.rb +0 -106
- data/spec/unit/type/component.rb +0 -63
- data/spec/unit/type/computer.rb +0 -78
- data/spec/unit/type/cron.rb +0 -33
- data/spec/unit/type/exec.rb +0 -116
- data/spec/unit/type/file.rb +0 -810
- data/spec/unit/type/file/checksum.rb +0 -28
- data/spec/unit/type/file/content.rb +0 -297
- data/spec/unit/type/file/ensure.rb +0 -84
- data/spec/unit/type/file/group.rb +0 -123
- data/spec/unit/type/file/owner.rb +0 -143
- data/spec/unit/type/file/selinux.rb +0 -84
- data/spec/unit/type/file/source.rb +0 -264
- data/spec/unit/type/filebucket.rb +0 -74
- data/spec/unit/type/group.rb +0 -39
- data/spec/unit/type/macauthorization.rb +0 -111
- data/spec/unit/type/maillist.rb +0 -42
- data/spec/unit/type/mcx.rb +0 -100
- data/spec/unit/type/mount.rb +0 -211
- data/spec/unit/type/nagios.rb +0 -63
- data/spec/unit/type/noop_metaparam.rb +0 -37
- data/spec/unit/type/package.rb +0 -236
- data/spec/unit/type/resources.rb +0 -89
- data/spec/unit/type/schedule.rb +0 -333
- data/spec/unit/type/selboolean.rb +0 -45
- data/spec/unit/type/selmodule.rb +0 -18
- data/spec/unit/type/service.rb +0 -230
- data/spec/unit/type/ssh_authorized_key.rb +0 -140
- data/spec/unit/type/tidy.rb +0 -422
- data/spec/unit/type/user.rb +0 -285
- data/spec/unit/type/zfs.rb +0 -45
- data/spec/unit/type/zone.rb +0 -20
- data/spec/unit/type/zpool.rb +0 -110
- data/spec/unit/util/autoload.rb +0 -133
- data/spec/unit/util/autoload/file_cache.rb +0 -183
- data/spec/unit/util/backups.rb +0 -159
- data/spec/unit/util/cache_accumulator.rb +0 -69
- data/spec/unit/util/cacher.rb +0 -185
- data/spec/unit/util/checksums.rb +0 -113
- data/spec/unit/util/constant_inflector.rb +0 -70
- data/spec/unit/util/feature.rb +0 -72
- data/spec/unit/util/file_locking.rb +0 -115
- data/spec/unit/util/filetype.rb +0 -100
- data/spec/unit/util/json.rb +0 -21
- data/spec/unit/util/ldap/connection.rb +0 -169
- data/spec/unit/util/ldap/generator.rb +0 -54
- data/spec/unit/util/ldap/manager.rb +0 -654
- data/spec/unit/util/loadedfile.rb +0 -65
- data/spec/unit/util/log.rb +0 -202
- data/spec/unit/util/metric.rb +0 -95
- data/spec/unit/util/monkey_patches.rb +0 -103
- data/spec/unit/util/nagios_maker.rb +0 -126
- data/spec/unit/util/package.rb +0 -21
- data/spec/unit/util/posix.rb +0 -256
- data/spec/unit/util/queue.rb +0 -96
- data/spec/unit/util/queue/stomp.rb +0 -140
- data/spec/unit/util/reference_serializer.rb +0 -52
- data/spec/unit/util/resource_template.rb +0 -58
- data/spec/unit/util/selinux.rb +0 -280
- data/spec/unit/util/settings.rb +0 -1058
- data/spec/unit/util/settings/file_setting.rb +0 -248
- data/spec/unit/util/storage.rb +0 -248
- data/spec/unit/util/tagging.rb +0 -102
- data/spec/unit/util/user_attr.rb +0 -47
- data/spec/unit/util/warnings.rb +0 -39
- data/spec/unit/util/zaml.rb +0 -38
- data/test/language/ast/casestatement.rb +0 -103
- data/test/language/ast/resource.rb +0 -58
- data/test/language/ast/resource_reference.rb +0 -77
- data/test/language/ast/selector.rb +0 -61
- data/test/language/resource.rb +0 -172
- data/test/lib/puppettest/support/collection.rb +0 -29
- data/test/network/client/resource.rb +0 -52
- data/test/network/handler/bucket.rb +0 -313
- data/test/network/handler/resource.rb +0 -250
- data/test/other/dsl.rb +0 -215
- data/test/other/events.rb +0 -124
- data/test/ral/type/group.rb +0 -170
data/lib/puppet/type.rb
CHANGED
@@ -9,7 +9,6 @@ require 'puppet/metatype/manager'
|
|
9
9
|
require 'puppet/util/errors'
|
10
10
|
require 'puppet/util/log_paths'
|
11
11
|
require 'puppet/util/logging'
|
12
|
-
require 'puppet/resource/reference'
|
13
12
|
require 'puppet/util/cacher'
|
14
13
|
require 'puppet/file_collection/lookup'
|
15
14
|
require 'puppet/util/tagging'
|
@@ -18,2074 +17,1870 @@ require 'puppet/util/tagging'
|
|
18
17
|
|
19
18
|
module Puppet
|
20
19
|
class Type
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
20
|
+
include Puppet::Util
|
21
|
+
include Puppet::Util::Errors
|
22
|
+
include Puppet::Util::LogPaths
|
23
|
+
include Puppet::Util::Logging
|
24
|
+
include Puppet::Util::Cacher
|
25
|
+
include Puppet::FileCollection::Lookup
|
26
|
+
include Puppet::Util::Tagging
|
27
|
+
|
28
|
+
###############################
|
29
|
+
# Code related to resource type attributes.
|
30
|
+
class << self
|
31
|
+
include Puppet::Util::ClassGen
|
32
|
+
include Puppet::Util::Warnings
|
33
|
+
attr_reader :properties
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.states
|
37
|
+
warnonce "The states method is deprecated; use properties"
|
38
|
+
properties
|
39
|
+
end
|
40
|
+
|
41
|
+
# All parameters, in the appropriate order. The key_attributes come first, then
|
42
|
+
# the provider, then the properties, and finally the params and metaparams
|
43
|
+
# in the order they were specified in the files.
|
44
|
+
def self.allattrs
|
45
|
+
key_attributes | (parameters & [:provider]) | properties.collect { |property| property.name } | parameters | metaparams
|
46
|
+
end
|
47
|
+
|
48
|
+
# Retrieve an attribute alias, if there is one.
|
49
|
+
def self.attr_alias(param)
|
50
|
+
@attr_aliases[symbolize(param)]
|
51
|
+
end
|
52
|
+
|
53
|
+
# Create an alias to an existing attribute. This will cause the aliased
|
54
|
+
# attribute to be valid when setting and retrieving values on the instance.
|
55
|
+
def self.set_attr_alias(hash)
|
56
|
+
hash.each do |new, old|
|
57
|
+
@attr_aliases[symbolize(new)] = symbolize(old)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
# Find the class associated with any given attribute.
|
62
|
+
def self.attrclass(name)
|
63
|
+
@attrclasses ||= {}
|
64
|
+
|
65
|
+
# We cache the value, since this method gets called such a huge number
|
66
|
+
# of times (as in, hundreds of thousands in a given run).
|
67
|
+
unless @attrclasses.include?(name)
|
68
|
+
@attrclasses[name] = case self.attrtype(name)
|
69
|
+
when :property; @validproperties[name]
|
70
|
+
when :meta; @@metaparamhash[name]
|
71
|
+
when :param; @paramhash[name]
|
72
|
+
end
|
73
|
+
end
|
74
|
+
@attrclasses[name]
|
75
|
+
end
|
76
|
+
|
77
|
+
# What type of parameter are we dealing with? Cache the results, because
|
78
|
+
# this method gets called so many times.
|
79
|
+
def self.attrtype(attr)
|
80
|
+
@attrtypes ||= {}
|
81
|
+
unless @attrtypes.include?(attr)
|
82
|
+
@attrtypes[attr] = case
|
83
|
+
when @validproperties.include?(attr); :property
|
84
|
+
when @paramhash.include?(attr); :param
|
85
|
+
when @@metaparamhash.include?(attr); :meta
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
@attrtypes[attr]
|
90
|
+
end
|
91
|
+
|
92
|
+
def self.eachmetaparam
|
93
|
+
@@metaparams.each { |p| yield p.name }
|
94
|
+
end
|
95
|
+
|
96
|
+
# Create the 'ensure' class. This is a separate method so other types
|
97
|
+
# can easily call it and create their own 'ensure' values.
|
98
|
+
def self.ensurable(&block)
|
99
|
+
if block_given?
|
100
|
+
self.newproperty(:ensure, :parent => Puppet::Property::Ensure, &block)
|
101
|
+
else
|
102
|
+
self.newproperty(:ensure, :parent => Puppet::Property::Ensure) do
|
103
|
+
self.defaultvalues
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
# Should we add the 'ensure' property to this class?
|
109
|
+
def self.ensurable?
|
110
|
+
# If the class has all three of these methods defined, then it's
|
111
|
+
# ensurable.
|
112
|
+
ens = [:exists?, :create, :destroy].inject { |set, method|
|
113
|
+
set &&= self.public_method_defined?(method)
|
114
|
+
}
|
115
|
+
|
116
|
+
ens
|
117
|
+
end
|
118
|
+
|
119
|
+
# Deal with any options passed into parameters.
|
120
|
+
def self.handle_param_options(name, options)
|
121
|
+
# If it's a boolean parameter, create a method to test the value easily
|
122
|
+
if options[:boolean]
|
123
|
+
define_method(name.to_s + "?") do
|
124
|
+
val = self[name]
|
125
|
+
if val == :true or val == true
|
126
|
+
return true
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
# Is the parameter in question a meta-parameter?
|
133
|
+
def self.metaparam?(param)
|
134
|
+
@@metaparamhash.include?(symbolize(param))
|
135
|
+
end
|
136
|
+
|
137
|
+
# Find the metaparameter class associated with a given metaparameter name.
|
138
|
+
def self.metaparamclass(name)
|
139
|
+
@@metaparamhash[symbolize(name)]
|
140
|
+
end
|
141
|
+
|
142
|
+
def self.metaparams
|
143
|
+
@@metaparams.collect { |param| param.name }
|
144
|
+
end
|
145
|
+
|
146
|
+
def self.metaparamdoc(metaparam)
|
147
|
+
@@metaparamhash[metaparam].doc
|
148
|
+
end
|
149
|
+
|
150
|
+
# Create a new metaparam. Requires a block and a name, stores it in the
|
151
|
+
# @parameters array, and does some basic checking on it.
|
152
|
+
def self.newmetaparam(name, options = {}, &block)
|
153
|
+
@@metaparams ||= []
|
154
|
+
@@metaparamhash ||= {}
|
155
|
+
name = symbolize(name)
|
156
|
+
|
157
|
+
|
158
|
+
param = genclass(
|
159
|
+
name,
|
160
|
+
:parent => options[:parent] || Puppet::Parameter,
|
161
|
+
:prefix => "MetaParam",
|
162
|
+
:hash => @@metaparamhash,
|
163
|
+
:array => @@metaparams,
|
164
|
+
:attributes => options[:attributes],
|
165
|
+
|
166
|
+
&block
|
167
|
+
)
|
168
|
+
|
169
|
+
# Grr.
|
170
|
+
param.required_features = options[:required_features] if options[:required_features]
|
171
|
+
|
172
|
+
handle_param_options(name, options)
|
173
|
+
|
174
|
+
param.metaparam = true
|
175
|
+
|
176
|
+
param
|
177
|
+
end
|
178
|
+
|
179
|
+
def self.key_attribute_parameters
|
180
|
+
@key_attribute_parameters ||= (
|
181
|
+
params = @parameters.find_all { |param|
|
182
|
+
param.isnamevar? or param.name == :name
|
183
|
+
}
|
184
|
+
)
|
185
|
+
end
|
28
186
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
187
|
+
def self.key_attributes
|
188
|
+
key_attribute_parameters.collect { |p| p.name }
|
189
|
+
end
|
190
|
+
|
191
|
+
def self.title_patterns
|
192
|
+
case key_attributes.length
|
193
|
+
when 0; []
|
194
|
+
when 1;
|
195
|
+
identity = lambda {|x| x}
|
196
|
+
[ [ /(.*)/m, [ [key_attributes.first, identity ] ] ] ]
|
197
|
+
else
|
198
|
+
raise Puppet::DevError,"you must specify title patterns when there are two or more key attributes"
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
def uniqueness_key
|
203
|
+
to_resource.uniqueness_key
|
204
|
+
end
|
205
|
+
|
206
|
+
# Create a new parameter. Requires a block and a name, stores it in the
|
207
|
+
# @parameters array, and does some basic checking on it.
|
208
|
+
def self.newparam(name, options = {}, &block)
|
209
|
+
options[:attributes] ||= {}
|
210
|
+
|
211
|
+
param = genclass(
|
212
|
+
name,
|
213
|
+
:parent => options[:parent] || Puppet::Parameter,
|
214
|
+
:attributes => options[:attributes],
|
215
|
+
:block => block,
|
216
|
+
:prefix => "Parameter",
|
217
|
+
:array => @parameters,
|
36
218
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
219
|
+
:hash => @paramhash
|
220
|
+
)
|
221
|
+
|
222
|
+
handle_param_options(name, options)
|
41
223
|
|
42
|
-
#
|
43
|
-
|
44
|
-
# in the order they were specified in the files.
|
45
|
-
def self.allattrs
|
46
|
-
# Cache this, since it gets called multiple times
|
47
|
-
namevar = self.namevar
|
224
|
+
# Grr.
|
225
|
+
param.required_features = options[:required_features] if options[:required_features]
|
48
226
|
|
49
|
-
|
50
|
-
if self.parameters.include?(:provider)
|
51
|
-
order << :provider
|
52
|
-
end
|
53
|
-
order << [self.properties.collect { |property| property.name },
|
54
|
-
self.parameters - [:provider],
|
55
|
-
self.metaparams].flatten.reject { |param|
|
56
|
-
# we don't want our namevar in there multiple times
|
57
|
-
param == namevar
|
58
|
-
}
|
59
|
-
|
60
|
-
order.flatten!
|
61
|
-
|
62
|
-
return order
|
63
|
-
end
|
64
|
-
|
65
|
-
# Retrieve an attribute alias, if there is one.
|
66
|
-
def self.attr_alias(param)
|
67
|
-
@attr_aliases[symbolize(param)]
|
68
|
-
end
|
227
|
+
param.isnamevar if options[:namevar]
|
69
228
|
|
70
|
-
|
71
|
-
|
72
|
-
def self.set_attr_alias(hash)
|
73
|
-
hash.each do |new, old|
|
74
|
-
@attr_aliases[symbolize(new)] = symbolize(old)
|
75
|
-
end
|
76
|
-
end
|
229
|
+
param
|
230
|
+
end
|
77
231
|
|
78
|
-
|
79
|
-
|
80
|
-
|
232
|
+
def self.newstate(name, options = {}, &block)
|
233
|
+
Puppet.warning "newstate() has been deprecrated; use newproperty(#{name})"
|
234
|
+
newproperty(name, options, &block)
|
235
|
+
end
|
81
236
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
237
|
+
# Create a new property. The first parameter must be the name of the property;
|
238
|
+
# this is how users will refer to the property when creating new instances.
|
239
|
+
# The second parameter is a hash of options; the options are:
|
240
|
+
# * <tt>:parent</tt>: The parent class for the property. Defaults to Puppet::Property.
|
241
|
+
# * <tt>:retrieve</tt>: The method to call on the provider or @parent object (if
|
242
|
+
# the provider is not set) to retrieve the current value.
|
243
|
+
def self.newproperty(name, options = {}, &block)
|
244
|
+
name = symbolize(name)
|
245
|
+
|
246
|
+
# This is here for types that might still have the old method of defining
|
247
|
+
# a parent class.
|
248
|
+
unless options.is_a? Hash
|
249
|
+
raise Puppet::DevError,
|
250
|
+
"Options must be a hash, not #{options.inspect}"
|
251
|
+
end
|
252
|
+
|
253
|
+
raise Puppet::DevError, "Class #{self.name} already has a property named #{name}" if @validproperties.include?(name)
|
254
|
+
|
255
|
+
if parent = options[:parent]
|
256
|
+
options.delete(:parent)
|
257
|
+
else
|
258
|
+
parent = Puppet::Property
|
259
|
+
end
|
260
|
+
|
261
|
+
# We have to create our own, new block here because we want to define
|
262
|
+
# an initial :retrieve method, if told to, and then eval the passed
|
263
|
+
# block if available.
|
264
|
+
prop = genclass(name, :parent => parent, :hash => @validproperties, :attributes => options) do
|
265
|
+
# If they've passed a retrieve method, then override the retrieve
|
266
|
+
# method on the class.
|
267
|
+
if options[:retrieve]
|
268
|
+
define_method(:retrieve) do
|
269
|
+
provider.send(options[:retrieve])
|
270
|
+
end
|
271
|
+
end
|
272
|
+
|
273
|
+
class_eval(&block) if block
|
274
|
+
end
|
275
|
+
|
276
|
+
# If it's the 'ensure' property, always put it first.
|
277
|
+
if name == :ensure
|
278
|
+
@properties.unshift prop
|
279
|
+
else
|
280
|
+
@properties << prop
|
281
|
+
end
|
282
|
+
|
283
|
+
prop
|
284
|
+
end
|
285
|
+
|
286
|
+
def self.paramdoc(param)
|
287
|
+
@paramhash[param].doc
|
288
|
+
end
|
289
|
+
|
290
|
+
# Return the parameter names
|
291
|
+
def self.parameters
|
292
|
+
return [] unless defined?(@parameters)
|
293
|
+
@parameters.collect { |klass| klass.name }
|
294
|
+
end
|
295
|
+
|
296
|
+
# Find the parameter class associated with a given parameter name.
|
297
|
+
def self.paramclass(name)
|
298
|
+
@paramhash[name]
|
299
|
+
end
|
300
|
+
|
301
|
+
# Return the property class associated with a name
|
302
|
+
def self.propertybyname(name)
|
303
|
+
@validproperties[name]
|
304
|
+
end
|
305
|
+
|
306
|
+
def self.validattr?(name)
|
307
|
+
name = symbolize(name)
|
308
|
+
return true if name == :name
|
309
|
+
@validattrs ||= {}
|
105
310
|
|
106
|
-
|
311
|
+
unless @validattrs.include?(name)
|
312
|
+
@validattrs[name] = !!(self.validproperty?(name) or self.validparameter?(name) or self.metaparam?(name))
|
107
313
|
end
|
108
314
|
|
109
|
-
|
110
|
-
|
111
|
-
# of the File class.
|
112
|
-
def self.copyparam(klass, name)
|
113
|
-
param = klass.attrclass(name)
|
315
|
+
@validattrs[name]
|
316
|
+
end
|
114
317
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
318
|
+
# does the name reflect a valid property?
|
319
|
+
def self.validproperty?(name)
|
320
|
+
name = symbolize(name)
|
321
|
+
@validproperties.include?(name) && @validproperties[name]
|
322
|
+
end
|
120
323
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
324
|
+
# Return the list of validproperties
|
325
|
+
def self.validproperties
|
326
|
+
return {} unless defined?(@parameters)
|
327
|
+
|
328
|
+
@validproperties.keys
|
329
|
+
end
|
330
|
+
|
331
|
+
# does the name reflect a valid parameter?
|
332
|
+
def self.validparameter?(name)
|
333
|
+
raise Puppet::DevError, "Class #{self} has not defined parameters" unless defined?(@parameters)
|
334
|
+
!!(@paramhash.include?(name) or @@metaparamhash.include?(name))
|
335
|
+
end
|
336
|
+
|
337
|
+
# This is a forward-compatibility method - it's the validity interface we'll use in Puppet::Resource.
|
338
|
+
def self.valid_parameter?(name)
|
339
|
+
validattr?(name)
|
340
|
+
end
|
341
|
+
|
342
|
+
# Return either the attribute alias or the attribute.
|
343
|
+
def attr_alias(name)
|
344
|
+
name = symbolize(name)
|
345
|
+
if synonym = self.class.attr_alias(name)
|
346
|
+
return synonym
|
347
|
+
else
|
348
|
+
return name
|
349
|
+
end
|
350
|
+
end
|
351
|
+
|
352
|
+
# Are we deleting this resource?
|
353
|
+
def deleting?
|
354
|
+
obj = @parameters[:ensure] and obj.should == :absent
|
355
|
+
end
|
356
|
+
|
357
|
+
# Create a new property if it is valid but doesn't exist
|
358
|
+
# Returns: true if a new parameter was added, false otherwise
|
359
|
+
def add_property_parameter(prop_name)
|
360
|
+
if self.class.validproperty?(prop_name) && !@parameters[prop_name]
|
361
|
+
self.newattr(prop_name)
|
362
|
+
return true
|
363
|
+
end
|
364
|
+
false
|
365
|
+
end
|
366
|
+
|
367
|
+
#
|
368
|
+
# The name_var is the key_attribute in the case that there is only one.
|
369
|
+
#
|
370
|
+
def name_var
|
371
|
+
key_attributes = self.class.key_attributes
|
372
|
+
(key_attributes.length == 1) && key_attributes.first
|
373
|
+
end
|
374
|
+
|
375
|
+
# abstract accessing parameters and properties, and normalize
|
376
|
+
# access to always be symbols, not strings
|
377
|
+
# This returns a value, not an object. It returns the 'is'
|
378
|
+
# value, but you can also specifically return 'is' and 'should'
|
379
|
+
# values using 'object.is(:property)' or 'object.should(:property)'.
|
380
|
+
def [](name)
|
381
|
+
name = attr_alias(name)
|
382
|
+
|
383
|
+
fail("Invalid parameter #{name}(#{name.inspect})") unless self.class.validattr?(name)
|
384
|
+
|
385
|
+
if name == :name
|
386
|
+
name = name_var
|
387
|
+
end
|
388
|
+
|
389
|
+
if obj = @parameters[name]
|
390
|
+
# Note that if this is a property, then the value is the "should" value,
|
391
|
+
# not the current value.
|
392
|
+
obj.value
|
393
|
+
else
|
394
|
+
return nil
|
395
|
+
end
|
396
|
+
end
|
397
|
+
|
398
|
+
# Abstract setting parameters and properties, and normalize
|
399
|
+
# access to always be symbols, not strings. This sets the 'should'
|
400
|
+
# value on properties, and otherwise just sets the appropriate parameter.
|
401
|
+
def []=(name,value)
|
402
|
+
name = attr_alias(name)
|
403
|
+
|
404
|
+
fail("Invalid parameter #{name}") unless self.class.validattr?(name)
|
405
|
+
|
406
|
+
if name == :name
|
407
|
+
name = name_var
|
408
|
+
end
|
409
|
+
raise Puppet::Error.new("Got nil value for #{name}") if value.nil?
|
410
|
+
|
411
|
+
property = self.newattr(name)
|
412
|
+
|
413
|
+
begin
|
414
|
+
# make sure the parameter doesn't have any errors
|
415
|
+
property.value = value
|
416
|
+
rescue => detail
|
417
|
+
error = Puppet::Error.new("Parameter #{name} failed: #{detail}")
|
418
|
+
error.set_backtrace(detail.backtrace)
|
419
|
+
raise error
|
420
|
+
end
|
421
|
+
|
422
|
+
nil
|
423
|
+
end
|
424
|
+
|
425
|
+
# remove a property from the object; useful in testing or in cleanup
|
426
|
+
# when an error has been encountered
|
427
|
+
def delete(attr)
|
428
|
+
attr = symbolize(attr)
|
429
|
+
if @parameters.has_key?(attr)
|
430
|
+
@parameters.delete(attr)
|
431
|
+
else
|
432
|
+
raise Puppet::DevError.new("Undefined attribute '#{attr}' in #{self}")
|
433
|
+
end
|
434
|
+
end
|
435
|
+
|
436
|
+
# iterate across the existing properties
|
437
|
+
def eachproperty
|
438
|
+
# properties is a private method
|
439
|
+
properties.each { |property|
|
440
|
+
yield property
|
441
|
+
}
|
442
|
+
end
|
443
|
+
|
444
|
+
# Create a transaction event. Called by Transaction or by
|
445
|
+
# a property.
|
446
|
+
def event(options = {})
|
447
|
+
Puppet::Transaction::Event.new({:resource => self, :file => file, :line => line, :tags => tags, :version => version}.merge(options))
|
448
|
+
end
|
449
|
+
|
450
|
+
# Let the catalog determine whether a given cached value is
|
451
|
+
# still valid or has expired.
|
452
|
+
def expirer
|
453
|
+
catalog
|
454
|
+
end
|
455
|
+
|
456
|
+
# retrieve the 'should' value for a specified property
|
457
|
+
def should(name)
|
458
|
+
name = attr_alias(name)
|
459
|
+
(prop = @parameters[name] and prop.is_a?(Puppet::Property)) ? prop.should : nil
|
460
|
+
end
|
461
|
+
|
462
|
+
# Create the actual attribute instance. Requires either the attribute
|
463
|
+
# name or class as the first argument, then an optional hash of
|
464
|
+
# attributes to set during initialization.
|
465
|
+
def newattr(name)
|
466
|
+
if name.is_a?(Class)
|
467
|
+
klass = name
|
468
|
+
name = klass.name
|
469
|
+
end
|
470
|
+
|
471
|
+
unless klass = self.class.attrclass(name)
|
472
|
+
raise Puppet::Error, "Resource type #{self.class.name} does not support parameter #{name}"
|
473
|
+
end
|
474
|
+
|
475
|
+
return @parameters[name] if @parameters.include?(name)
|
476
|
+
|
477
|
+
@parameters[name] = klass.new(:resource => self)
|
478
|
+
end
|
479
|
+
|
480
|
+
# return the value of a parameter
|
481
|
+
def parameter(name)
|
482
|
+
@parameters[name.to_sym]
|
483
|
+
end
|
484
|
+
|
485
|
+
def parameters
|
486
|
+
@parameters.dup
|
487
|
+
end
|
488
|
+
|
489
|
+
# Is the named property defined?
|
490
|
+
def propertydefined?(name)
|
491
|
+
name = name.intern unless name.is_a? Symbol
|
492
|
+
@parameters.include?(name)
|
493
|
+
end
|
494
|
+
|
495
|
+
# Return an actual property instance by name; to return the value, use 'resource[param]'
|
496
|
+
# LAK:NOTE(20081028) Since the 'parameter' method is now a superset of this method,
|
497
|
+
# this one should probably go away at some point.
|
498
|
+
def property(name)
|
499
|
+
(obj = @parameters[symbolize(name)] and obj.is_a?(Puppet::Property)) ? obj : nil
|
500
|
+
end
|
501
|
+
|
502
|
+
# For any parameters or properties that have defaults and have not yet been
|
503
|
+
# set, set them now. This method can be handed a list of attributes,
|
504
|
+
# and if so it will only set defaults for those attributes.
|
505
|
+
def set_default(attr)
|
506
|
+
return unless klass = self.class.attrclass(attr)
|
507
|
+
return unless klass.method_defined?(:default)
|
508
|
+
return if @parameters.include?(klass.name)
|
509
|
+
|
510
|
+
return unless parameter = newattr(klass.name)
|
511
|
+
|
512
|
+
if value = parameter.default and ! value.nil?
|
513
|
+
parameter.value = value
|
514
|
+
else
|
515
|
+
@parameters.delete(parameter.name)
|
516
|
+
end
|
517
|
+
end
|
518
|
+
|
519
|
+
# Convert our object to a hash. This just includes properties.
|
520
|
+
def to_hash
|
521
|
+
rethash = {}
|
522
|
+
|
523
|
+
@parameters.each do |name, obj|
|
524
|
+
rethash[name] = obj.value
|
525
|
+
end
|
526
|
+
|
527
|
+
rethash
|
528
|
+
end
|
529
|
+
|
530
|
+
def type
|
531
|
+
self.class.name
|
532
|
+
end
|
533
|
+
|
534
|
+
# Return a specific value for an attribute.
|
535
|
+
def value(name)
|
536
|
+
name = attr_alias(name)
|
537
|
+
|
538
|
+
(obj = @parameters[name] and obj.respond_to?(:value)) ? obj.value : nil
|
539
|
+
end
|
540
|
+
|
541
|
+
def version
|
542
|
+
return 0 unless catalog
|
543
|
+
catalog.version
|
544
|
+
end
|
545
|
+
|
546
|
+
# Return all of the property objects, in the order specified in the
|
547
|
+
# class.
|
548
|
+
def properties
|
549
|
+
self.class.properties.collect { |prop| @parameters[prop.name] }.compact
|
550
|
+
end
|
551
|
+
|
552
|
+
# Is this type's name isomorphic with the object? That is, if the
|
553
|
+
# name conflicts, does it necessarily mean that the objects conflict?
|
554
|
+
# Defaults to true.
|
555
|
+
def self.isomorphic?
|
556
|
+
if defined?(@isomorphic)
|
557
|
+
return @isomorphic
|
558
|
+
else
|
559
|
+
return true
|
560
|
+
end
|
561
|
+
end
|
562
|
+
|
563
|
+
def isomorphic?
|
564
|
+
self.class.isomorphic?
|
565
|
+
end
|
566
|
+
|
567
|
+
# is the instance a managed instance? A 'yes' here means that
|
568
|
+
# the instance was created from the language, vs. being created
|
569
|
+
# in order resolve other questions, such as finding a package
|
570
|
+
# in a list
|
571
|
+
def managed?
|
572
|
+
# Once an object is managed, it always stays managed; but an object
|
573
|
+
# that is listed as unmanaged might become managed later in the process,
|
574
|
+
# so we have to check that every time
|
575
|
+
if @managed
|
576
|
+
return @managed
|
577
|
+
else
|
578
|
+
@managed = false
|
579
|
+
properties.each { |property|
|
580
|
+
s = property.should
|
581
|
+
if s and ! property.class.unmanaged
|
582
|
+
@managed = true
|
583
|
+
break
|
584
|
+
end
|
585
|
+
}
|
586
|
+
return @managed
|
587
|
+
end
|
588
|
+
end
|
589
|
+
|
590
|
+
###############################
|
591
|
+
# Code related to the container behaviour.
|
592
|
+
|
593
|
+
# this is a retarded hack method to get around the difference between
|
594
|
+
# component children and file children
|
595
|
+
def self.depthfirst?
|
596
|
+
@depthfirst
|
597
|
+
end
|
598
|
+
|
599
|
+
def depthfirst?
|
600
|
+
self.class.depthfirst?
|
601
|
+
end
|
602
|
+
|
603
|
+
# Remove an object. The argument determines whether the object's
|
604
|
+
# subscriptions get eliminated, too.
|
605
|
+
def remove(rmdeps = true)
|
606
|
+
# This is hackish (mmm, cut and paste), but it works for now, and it's
|
607
|
+
# better than warnings.
|
608
|
+
@parameters.each do |name, obj|
|
609
|
+
obj.remove
|
610
|
+
end
|
611
|
+
@parameters.clear
|
612
|
+
|
613
|
+
@parent = nil
|
614
|
+
|
615
|
+
# Remove the reference to the provider.
|
616
|
+
if self.provider
|
617
|
+
@provider.clear
|
618
|
+
@provider = nil
|
619
|
+
end
|
620
|
+
end
|
621
|
+
|
622
|
+
###############################
|
623
|
+
# Code related to evaluating the resources.
|
624
|
+
|
625
|
+
# Flush the provider, if it supports it. This is called by the
|
626
|
+
# transaction.
|
627
|
+
def flush
|
628
|
+
self.provider.flush if self.provider and self.provider.respond_to?(:flush)
|
629
|
+
end
|
630
|
+
|
631
|
+
# if all contained objects are in sync, then we're in sync
|
632
|
+
# FIXME I don't think this is used on the type instances any more,
|
633
|
+
# it's really only used for testing
|
634
|
+
def insync?(is)
|
635
|
+
insync = true
|
636
|
+
|
637
|
+
if property = @parameters[:ensure]
|
638
|
+
unless is.include? property
|
639
|
+
raise Puppet::DevError,
|
640
|
+
"The is value is not in the is array for '#{property.name}'"
|
641
|
+
end
|
642
|
+
ensureis = is[property]
|
643
|
+
if property.insync?(ensureis) and property.should == :absent
|
644
|
+
return true
|
645
|
+
end
|
646
|
+
end
|
647
|
+
|
648
|
+
properties.each { |property|
|
649
|
+
unless is.include? property
|
650
|
+
raise Puppet::DevError,
|
651
|
+
"The is value is not in the is array for '#{property.name}'"
|
652
|
+
end
|
653
|
+
|
654
|
+
propis = is[property]
|
655
|
+
unless property.insync?(propis)
|
656
|
+
property.debug("Not in sync: #{propis.inspect} vs #{property.should.inspect}")
|
657
|
+
insync = false
|
658
|
+
#else
|
659
|
+
# property.debug("In sync")
|
660
|
+
end
|
661
|
+
}
|
662
|
+
|
663
|
+
#self.debug("#{self} sync status is #{insync}")
|
664
|
+
insync
|
665
|
+
end
|
666
|
+
|
667
|
+
# retrieve the current value of all contained properties
|
668
|
+
def retrieve
|
669
|
+
fail "Provider #{provider.class.name} is not functional on this host" if self.provider.is_a?(Puppet::Provider) and ! provider.class.suitable?
|
670
|
+
|
671
|
+
result = Puppet::Resource.new(type, title)
|
672
|
+
|
673
|
+
# Provide the name, so we know we'll always refer to a real thing
|
674
|
+
result[:name] = self[:name] unless self[:name] == title
|
675
|
+
|
676
|
+
if ensure_prop = property(:ensure) or (self.class.validattr?(:ensure) and ensure_prop = newattr(:ensure))
|
677
|
+
result[:ensure] = ensure_state = ensure_prop.retrieve
|
678
|
+
else
|
679
|
+
ensure_state = nil
|
680
|
+
end
|
681
|
+
|
682
|
+
properties.each do |property|
|
683
|
+
next if property.name == :ensure
|
684
|
+
if ensure_state == :absent
|
685
|
+
result[property] = :absent
|
686
|
+
else
|
687
|
+
result[property] = property.retrieve
|
688
|
+
end
|
689
|
+
end
|
690
|
+
|
691
|
+
result
|
692
|
+
end
|
693
|
+
|
694
|
+
def retrieve_resource
|
695
|
+
resource = retrieve
|
696
|
+
resource = Resource.new(type, title, :parameters => resource) if resource.is_a? Hash
|
697
|
+
resource
|
698
|
+
end
|
699
|
+
|
700
|
+
# Get a hash of the current properties. Returns a hash with
|
701
|
+
# the actual property instance as the key and the current value
|
702
|
+
# as the, um, value.
|
703
|
+
def currentpropvalues
|
704
|
+
# It's important to use the 'properties' method here, as it follows the order
|
705
|
+
# in which they're defined in the class. It also guarantees that 'ensure'
|
706
|
+
# is the first property, which is important for skipping 'retrieve' on
|
707
|
+
# all the properties if the resource is absent.
|
708
|
+
ensure_state = false
|
709
|
+
return properties.inject({}) do | prophash, property|
|
710
|
+
if property.name == :ensure
|
711
|
+
ensure_state = property.retrieve
|
712
|
+
prophash[property] = ensure_state
|
713
|
+
else
|
714
|
+
if ensure_state == :absent
|
715
|
+
prophash[property] = :absent
|
135
716
|
else
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
end
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
end
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
717
|
+
prophash[property] = property.retrieve
|
718
|
+
end
|
719
|
+
end
|
720
|
+
prophash
|
721
|
+
end
|
722
|
+
end
|
723
|
+
|
724
|
+
# Are we running in noop mode?
|
725
|
+
def noop?
|
726
|
+
# If we're not a host_config, we're almost certainly part of
|
727
|
+
# Settings, and we want to ignore 'noop'
|
728
|
+
return false if catalog and ! catalog.host_config?
|
729
|
+
|
730
|
+
if defined?(@noop)
|
731
|
+
@noop
|
732
|
+
else
|
733
|
+
Puppet[:noop]
|
734
|
+
end
|
735
|
+
end
|
736
|
+
|
737
|
+
def noop
|
738
|
+
noop?
|
739
|
+
end
|
740
|
+
|
741
|
+
###############################
|
742
|
+
# Code related to managing resource instances.
|
743
|
+
require 'puppet/transportable'
|
744
|
+
|
745
|
+
# retrieve a named instance of the current type
|
746
|
+
def self.[](name)
|
747
|
+
raise "Global resource access is deprecated"
|
748
|
+
@objects[name] || @aliases[name]
|
749
|
+
end
|
750
|
+
|
751
|
+
# add an instance by name to the class list of instances
|
752
|
+
def self.[]=(name,object)
|
753
|
+
raise "Global resource storage is deprecated"
|
754
|
+
newobj = nil
|
755
|
+
if object.is_a?(Puppet::Type)
|
756
|
+
newobj = object
|
757
|
+
else
|
758
|
+
raise Puppet::DevError, "must pass a Puppet::Type object"
|
759
|
+
end
|
760
|
+
|
761
|
+
if exobj = @objects[name] and self.isomorphic?
|
762
|
+
msg = "Object '#{newobj.class.name}[#{name}]' already exists"
|
763
|
+
|
764
|
+
msg += ("in file #{object.file} at line #{object.line}") if exobj.file and exobj.line
|
765
|
+
msg += ("and cannot be redefined in file #{object.file} at line #{object.line}") if object.file and object.line
|
766
|
+
error = Puppet::Error.new(msg)
|
767
|
+
raise error
|
768
|
+
else
|
769
|
+
#Puppet.info("adding %s of type %s to class list" %
|
770
|
+
# [name,object.class])
|
771
|
+
@objects[name] = newobj
|
772
|
+
end
|
773
|
+
end
|
774
|
+
|
775
|
+
# Create an alias. We keep these in a separate hash so that we don't encounter
|
776
|
+
# the objects multiple times when iterating over them.
|
777
|
+
def self.alias(name, obj)
|
778
|
+
raise "Global resource aliasing is deprecated"
|
779
|
+
if @objects.include?(name)
|
780
|
+
unless @objects[name] == obj
|
781
|
+
raise Puppet::Error.new(
|
782
|
+
"Cannot create alias #{name}: object already exists"
|
198
783
|
)
|
199
|
-
|
200
|
-
# Grr.
|
201
|
-
if options[:required_features]
|
202
|
-
param.required_features = options[:required_features]
|
203
|
-
end
|
204
|
-
|
205
|
-
handle_param_options(name, options)
|
206
|
-
|
207
|
-
param.metaparam = true
|
208
|
-
|
209
|
-
return param
|
784
|
+
end
|
210
785
|
end
|
211
786
|
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
param.isnamevar? or param.name == :name
|
217
|
-
}
|
218
|
-
|
219
|
-
if params.length > 1
|
220
|
-
raise Puppet::DevError, "Found multiple namevars for %s" % self.name
|
221
|
-
elsif params.length == 1
|
222
|
-
params.first
|
223
|
-
else
|
224
|
-
raise Puppet::DevError, "No namevar for %s" % self.name
|
225
|
-
end
|
787
|
+
if @aliases.include?(name)
|
788
|
+
unless @aliases[name] == obj
|
789
|
+
raise Puppet::Error.new(
|
790
|
+
"Object #{@aliases[name].name} already has alias #{name}"
|
226
791
|
)
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
792
|
+
end
|
793
|
+
end
|
794
|
+
|
795
|
+
@aliases[name] = obj
|
796
|
+
end
|
797
|
+
|
798
|
+
# remove all of the instances of a single type
|
799
|
+
def self.clear
|
800
|
+
raise "Global resource removal is deprecated"
|
801
|
+
if defined?(@objects)
|
802
|
+
@objects.each do |name, obj|
|
803
|
+
obj.remove(true)
|
804
|
+
end
|
805
|
+
@objects.clear
|
806
|
+
end
|
807
|
+
@aliases.clear if defined?(@aliases)
|
808
|
+
end
|
809
|
+
|
810
|
+
# Force users to call this, so that we can merge objects if
|
811
|
+
# necessary.
|
812
|
+
def self.create(args)
|
813
|
+
# LAK:DEP Deprecation notice added 12/17/2008
|
814
|
+
Puppet.warning "Puppet::Type.create is deprecated; use Puppet::Type.new"
|
815
|
+
new(args)
|
816
|
+
end
|
817
|
+
|
818
|
+
# remove a specified object
|
819
|
+
def self.delete(resource)
|
820
|
+
raise "Global resource removal is deprecated"
|
821
|
+
return unless defined?(@objects)
|
822
|
+
@objects.delete(resource.title) if @objects.include?(resource.title)
|
823
|
+
@aliases.delete(resource.title) if @aliases.include?(resource.title)
|
824
|
+
if @aliases.has_value?(resource)
|
825
|
+
names = []
|
826
|
+
@aliases.each do |name, otherres|
|
827
|
+
if otherres == resource
|
828
|
+
names << name
|
829
|
+
end
|
830
|
+
end
|
831
|
+
names.each { |name| @aliases.delete(name) }
|
832
|
+
end
|
833
|
+
end
|
834
|
+
|
835
|
+
# iterate across each of the type's instances
|
836
|
+
def self.each
|
837
|
+
raise "Global resource iteration is deprecated"
|
838
|
+
return unless defined?(@objects)
|
839
|
+
@objects.each { |name,instance|
|
840
|
+
yield instance
|
841
|
+
}
|
842
|
+
end
|
843
|
+
|
844
|
+
# does the type have an object with the given name?
|
845
|
+
def self.has_key?(name)
|
846
|
+
raise "Global resource access is deprecated"
|
847
|
+
@objects.has_key?(name)
|
848
|
+
end
|
849
|
+
|
850
|
+
# Retrieve all known instances. Either requires providers or must be overridden.
|
851
|
+
def self.instances
|
852
|
+
raise Puppet::DevError, "#{self.name} has no providers and has not overridden 'instances'" if provider_hash.empty?
|
853
|
+
|
854
|
+
# Put the default provider first, then the rest of the suitable providers.
|
855
|
+
provider_instances = {}
|
856
|
+
providers_by_source.collect do |provider|
|
857
|
+
provider.instances.collect do |instance|
|
858
|
+
# We always want to use the "first" provider instance we find, unless the resource
|
859
|
+
# is already managed and has a different provider set
|
860
|
+
if other = provider_instances[instance.name]
|
861
|
+
Puppet.warning "%s %s found in both %s and %s; skipping the %s version" %
|
862
|
+
[self.name.to_s.capitalize, instance.name, other.class.name, instance.class.name, instance.class.name]
|
863
|
+
next
|
864
|
+
end
|
865
|
+
provider_instances[instance.name] = instance
|
866
|
+
|
867
|
+
new(:name => instance.name, :provider => instance, :audit => :all)
|
868
|
+
end
|
869
|
+
end.flatten.compact
|
870
|
+
end
|
871
|
+
|
872
|
+
# Return a list of one suitable provider per source, with the default provider first.
|
873
|
+
def self.providers_by_source
|
874
|
+
# Put the default provider first, then the rest of the suitable providers.
|
875
|
+
sources = []
|
876
|
+
[defaultprovider, suitableprovider].flatten.uniq.collect do |provider|
|
877
|
+
next if sources.include?(provider.source)
|
878
|
+
|
879
|
+
sources << provider.source
|
880
|
+
provider
|
881
|
+
end.compact
|
882
|
+
end
|
883
|
+
|
884
|
+
# Convert a simple hash into a Resource instance.
|
885
|
+
def self.hash2resource(hash)
|
886
|
+
hash = hash.inject({}) { |result, ary| result[ary[0].to_sym] = ary[1]; result }
|
887
|
+
|
888
|
+
title = hash.delete(:title)
|
889
|
+
title ||= hash[:name]
|
890
|
+
title ||= hash[key_attributes.first] if key_attributes.length == 1
|
891
|
+
|
892
|
+
raise Puppet::Error, "Title or name must be provided" unless title
|
893
|
+
|
894
|
+
# Now create our resource.
|
895
|
+
resource = Puppet::Resource.new(self.name, title)
|
896
|
+
[:catalog].each do |attribute|
|
897
|
+
if value = hash[attribute]
|
898
|
+
hash.delete(attribute)
|
899
|
+
resource.send(attribute.to_s + "=", value)
|
900
|
+
end
|
901
|
+
end
|
902
|
+
|
903
|
+
hash.each do |param, value|
|
904
|
+
resource[param] = value
|
905
|
+
end
|
906
|
+
resource
|
907
|
+
end
|
908
|
+
|
909
|
+
# Create the path for logging and such.
|
910
|
+
def pathbuilder
|
911
|
+
if p = parent
|
912
|
+
[p.pathbuilder, self.ref].flatten
|
913
|
+
else
|
914
|
+
[self.ref]
|
915
|
+
end
|
916
|
+
end
|
917
|
+
|
918
|
+
###############################
|
919
|
+
# Add all of the meta parameters.
|
920
|
+
newmetaparam(:noop) do
|
921
|
+
desc "Boolean flag indicating whether work should actually
|
922
|
+
be done."
|
923
|
+
|
924
|
+
newvalues(:true, :false)
|
925
|
+
munge do |value|
|
926
|
+
case value
|
927
|
+
when true, :true, "true"; @resource.noop = true
|
928
|
+
when false, :false, "false"; @resource.noop = false
|
929
|
+
end
|
930
|
+
end
|
931
|
+
end
|
932
|
+
|
933
|
+
newmetaparam(:schedule) do
|
934
|
+
desc "On what schedule the object should be managed. You must create a
|
935
|
+
schedule object, and then reference the name of that object to use
|
936
|
+
that for your schedule::
|
937
|
+
|
938
|
+
schedule { daily:
|
939
|
+
period => daily,
|
940
|
+
range => \"2-4\"
|
941
|
+
}
|
350
942
|
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
else
|
355
|
-
@validattrs[name] = false
|
356
|
-
end
|
357
|
-
end
|
943
|
+
exec { \"/usr/bin/apt-get update\":
|
944
|
+
schedule => daily
|
945
|
+
}
|
358
946
|
|
359
|
-
|
360
|
-
|
947
|
+
The creation of the schedule object does not need to appear in the
|
948
|
+
configuration before objects that use it."
|
949
|
+
end
|
361
950
|
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
return @validproperties[name]
|
367
|
-
else
|
368
|
-
return false
|
369
|
-
end
|
370
|
-
end
|
371
|
-
|
372
|
-
# Return the list of validproperties
|
373
|
-
def self.validproperties
|
374
|
-
return {} unless defined? @parameters
|
951
|
+
newmetaparam(:audit) do
|
952
|
+
desc "Audit specified attributes of resources over time, and report if any have changed.
|
953
|
+
This attribute can be used to track changes to any resource over time, and can
|
954
|
+
provide an audit trail of every change that happens on any given machine.
|
375
955
|
|
376
|
-
|
377
|
-
|
956
|
+
Note that you cannot both audit and manage an attribute - managing it guarantees
|
957
|
+
the value, and any changes already get logged."
|
378
958
|
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
return true
|
386
|
-
else
|
387
|
-
return false
|
959
|
+
validate do |list|
|
960
|
+
list = Array(list)
|
961
|
+
unless list == [:all]
|
962
|
+
list.each do |param|
|
963
|
+
next if @resource.class.validattr?(param)
|
964
|
+
fail "Cannot audit #{param}: not a valid attribute for #{resource}"
|
388
965
|
end
|
966
|
+
end
|
389
967
|
end
|
390
968
|
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
else
|
397
|
-
return name
|
398
|
-
end
|
969
|
+
munge do |args|
|
970
|
+
properties_to_audit(args).each do |param|
|
971
|
+
next unless resource.class.validproperty?(param)
|
972
|
+
resource.newattr(param)
|
973
|
+
end
|
399
974
|
end
|
400
975
|
|
401
|
-
|
402
|
-
|
403
|
-
|
976
|
+
def all_properties
|
977
|
+
resource.class.properties.find_all do |property|
|
978
|
+
resource.provider.nil? or resource.provider.class.supports_parameter?(property)
|
979
|
+
end.collect do |property|
|
980
|
+
property.name
|
981
|
+
end
|
404
982
|
end
|
405
983
|
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
end
|
413
|
-
return false
|
984
|
+
def properties_to_audit(list)
|
985
|
+
if list == :all
|
986
|
+
list = all_properties if list == :all
|
987
|
+
else
|
988
|
+
list = Array(list).collect { |p| p.to_sym }
|
989
|
+
end
|
414
990
|
end
|
991
|
+
end
|
415
992
|
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
# value, but you can also specifically return 'is' and 'should'
|
420
|
-
# values using 'object.is(:property)' or 'object.should(:property)'.
|
421
|
-
def [](name)
|
422
|
-
name = attr_alias(name)
|
993
|
+
newmetaparam(:check) do
|
994
|
+
desc "Audit specified attributes of resources over time, and report if any have changed.
|
995
|
+
This parameter has been deprecated in favor of 'audit'."
|
423
996
|
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
if name == :name
|
429
|
-
name = self.class.namevar
|
430
|
-
end
|
431
|
-
|
432
|
-
if obj = @parameters[name]
|
433
|
-
# Note that if this is a property, then the value is the "should" value,
|
434
|
-
# not the current value.
|
435
|
-
obj.value
|
436
|
-
else
|
437
|
-
return nil
|
438
|
-
end
|
997
|
+
munge do |args|
|
998
|
+
resource.warning "'check' attribute is deprecated; use 'audit' instead"
|
999
|
+
resource[:audit] = args
|
439
1000
|
end
|
1001
|
+
end
|
440
1002
|
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
unless self.class.validattr?(name)
|
448
|
-
fail("Invalid parameter %s" % [name])
|
449
|
-
end
|
450
|
-
|
451
|
-
if name == :name
|
452
|
-
name = self.class.namevar
|
453
|
-
end
|
454
|
-
if value.nil?
|
455
|
-
raise Puppet::Error.new("Got nil value for %s" % name)
|
456
|
-
end
|
1003
|
+
newmetaparam(:loglevel) do
|
1004
|
+
desc "Sets the level that information will be logged.
|
1005
|
+
The log levels have the biggest impact when logs are sent to
|
1006
|
+
syslog (which is currently the default)."
|
1007
|
+
defaultto :notice
|
457
1008
|
|
458
|
-
|
459
|
-
|
460
|
-
return nil
|
461
|
-
else
|
462
|
-
self.newattr(name, :value => value)
|
463
|
-
end
|
1009
|
+
newvalues(*Puppet::Util::Log.levels)
|
1010
|
+
newvalues(:verbose)
|
464
1011
|
|
465
|
-
|
1012
|
+
munge do |loglevel|
|
1013
|
+
val = super(loglevel)
|
1014
|
+
if val == :verbose
|
1015
|
+
val = :info
|
1016
|
+
end
|
1017
|
+
val
|
466
1018
|
end
|
1019
|
+
end
|
467
1020
|
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
attr = symbolize(attr)
|
472
|
-
if @parameters.has_key?(attr)
|
473
|
-
@parameters.delete(attr)
|
474
|
-
else
|
475
|
-
raise Puppet::DevError.new("Undefined attribute '#{attr}' in #{self}")
|
476
|
-
end
|
477
|
-
end
|
1021
|
+
newmetaparam(:alias) do
|
1022
|
+
desc "Creates an alias for the object. Puppet uses this internally when you
|
1023
|
+
provide a symbolic name::
|
478
1024
|
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
1025
|
+
file { sshdconfig:
|
1026
|
+
path => $operatingsystem ? {
|
1027
|
+
solaris => \"/usr/local/etc/ssh/sshd_config\",
|
1028
|
+
default => \"/etc/ssh/sshd_config\"
|
1029
|
+
},
|
1030
|
+
source => \"...\"
|
484
1031
|
}
|
485
|
-
end
|
486
|
-
|
487
|
-
# Let the catalog determine whether a given cached value is
|
488
|
-
# still valid or has expired.
|
489
|
-
def expirer
|
490
|
-
catalog
|
491
|
-
end
|
492
1032
|
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
if prop = @parameters[name] and prop.is_a?(Puppet::Property)
|
497
|
-
return prop.should
|
498
|
-
else
|
499
|
-
return nil
|
500
|
-
end
|
501
|
-
end
|
502
|
-
|
503
|
-
# Create the actual attribute instance. Requires either the attribute
|
504
|
-
# name or class as the first argument, then an optional hash of
|
505
|
-
# attributes to set during initialization.
|
506
|
-
def newattr(name, options = {})
|
507
|
-
if name.is_a?(Class)
|
508
|
-
klass = name
|
509
|
-
name = klass.name
|
510
|
-
end
|
511
|
-
|
512
|
-
unless klass = self.class.attrclass(name)
|
513
|
-
raise Puppet::Error, "Resource type %s does not support parameter %s" % [self.class.name, name]
|
514
|
-
end
|
515
|
-
|
516
|
-
if @parameters.include?(name)
|
517
|
-
raise Puppet::Error, "Parameter '%s' is already defined in %s" %
|
518
|
-
[name, self.ref]
|
519
|
-
end
|
520
|
-
|
521
|
-
if provider and ! provider.class.supports_parameter?(klass)
|
522
|
-
missing = klass.required_features.find_all { |f| ! provider.class.feature?(f) }
|
523
|
-
info "Provider %s does not support features %s; not managing attribute %s" % [provider.class.name, missing.join(", "), name]
|
524
|
-
return nil
|
525
|
-
end
|
1033
|
+
service { sshd:
|
1034
|
+
subscribe => file[sshdconfig]
|
1035
|
+
}
|
526
1036
|
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
return @parameters[name] = klass.new(options)
|
533
|
-
rescue => detail
|
534
|
-
error = Puppet::Error.new("Parameter %s failed: %s" %
|
535
|
-
[name, detail])
|
536
|
-
error.set_backtrace(detail.backtrace)
|
537
|
-
raise error
|
538
|
-
end
|
539
|
-
end
|
1037
|
+
When you use this feature, the parser sets ``sshdconfig`` as the name,
|
1038
|
+
and the library sets that as an alias for the file so the dependency
|
1039
|
+
lookup for ``sshd`` works. You can use this parameter yourself,
|
1040
|
+
but note that only the library can use these aliases; for instance,
|
1041
|
+
the following code will not work::
|
540
1042
|
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
1043
|
+
file { \"/etc/ssh/sshd_config\":
|
1044
|
+
owner => root,
|
1045
|
+
group => root,
|
1046
|
+
alias => sshdconfig
|
1047
|
+
}
|
545
1048
|
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
name = name.intern
|
550
|
-
end
|
551
|
-
return @parameters.include?(name)
|
552
|
-
end
|
1049
|
+
file { sshdconfig:
|
1050
|
+
mode => 644
|
1051
|
+
}
|
553
1052
|
|
554
|
-
|
555
|
-
|
556
|
-
# this one should probably go away at some point.
|
557
|
-
def property(name)
|
558
|
-
if obj = @parameters[symbolize(name)] and obj.is_a?(Puppet::Property)
|
559
|
-
return obj
|
560
|
-
else
|
561
|
-
return nil
|
562
|
-
end
|
563
|
-
end
|
1053
|
+
There's no way here for the Puppet parser to know that these two stanzas
|
1054
|
+
should be affecting the same file.
|
564
1055
|
|
565
|
-
|
566
|
-
# set, set them now. This method can be handed a list of attributes,
|
567
|
-
# and if so it will only set defaults for those attributes.
|
568
|
-
def set_default(attr)
|
569
|
-
return unless klass = self.class.attrclass(attr)
|
570
|
-
return unless klass.method_defined?(:default)
|
571
|
-
return if @parameters.include?(klass.name)
|
1056
|
+
See the `LanguageTutorial language tutorial`:trac: for more information.
|
572
1057
|
|
573
|
-
|
1058
|
+
"
|
574
1059
|
|
575
|
-
|
576
|
-
|
577
|
-
else
|
578
|
-
@parameters.delete(parameter.name)
|
579
|
-
end
|
580
|
-
end
|
1060
|
+
munge do |aliases|
|
1061
|
+
aliases = [aliases] unless aliases.is_a?(Array)
|
581
1062
|
|
582
|
-
|
583
|
-
def to_hash
|
584
|
-
rethash = {}
|
1063
|
+
raise(ArgumentError, "Cannot add aliases without a catalog") unless @resource.catalog
|
585
1064
|
|
586
|
-
|
587
|
-
|
1065
|
+
aliases.each do |other|
|
1066
|
+
if obj = @resource.catalog.resource(@resource.class.name, other)
|
1067
|
+
unless obj.object_id == @resource.object_id
|
1068
|
+
self.fail("#{@resource.title} can not create alias #{other}: object already exists")
|
1069
|
+
end
|
1070
|
+
next
|
588
1071
|
end
|
589
1072
|
|
590
|
-
|
1073
|
+
# Newschool, add it to the catalog.
|
1074
|
+
@resource.catalog.alias(@resource, other)
|
1075
|
+
end
|
591
1076
|
end
|
1077
|
+
end
|
592
1078
|
|
593
|
-
|
594
|
-
|
595
|
-
|
1079
|
+
newmetaparam(:tag) do
|
1080
|
+
desc "Add the specified tags to the associated resource. While all resources
|
1081
|
+
are automatically tagged with as much information as possible
|
1082
|
+
(e.g., each class and definition containing the resource), it can
|
1083
|
+
be useful to add your own tags to a given resource.
|
596
1084
|
|
597
|
-
|
598
|
-
|
599
|
-
else
|
600
|
-
return nil
|
601
|
-
end
|
602
|
-
end
|
1085
|
+
Tags are currently useful for things like applying a subset of a
|
1086
|
+
host's configuration::
|
603
1087
|
|
604
|
-
|
605
|
-
return 0 unless catalog
|
606
|
-
catalog.version
|
607
|
-
end
|
1088
|
+
puppet agent --test --tags mytag
|
608
1089
|
|
609
|
-
|
610
|
-
|
1090
|
+
This way, when you're testing a configuration you can run just the
|
1091
|
+
portion you're testing."
|
611
1092
|
|
612
|
-
|
1093
|
+
munge do |tags|
|
1094
|
+
tags = [tags] unless tags.is_a? Array
|
613
1095
|
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
#debug "%s has %s properties" % [self,@parameters.length]
|
618
|
-
props = self.class.properties.collect { |prop|
|
619
|
-
@parameters[prop.name]
|
620
|
-
}.find_all { |p|
|
621
|
-
! p.nil?
|
622
|
-
}.each do |prop|
|
623
|
-
unless prop.is_a?(Puppet::Property)
|
624
|
-
raise Puppet::DevError, "got a non-property %s(%s)" %
|
625
|
-
[prop.class, prop.class.name]
|
626
|
-
end
|
627
|
-
end
|
628
|
-
|
629
|
-
props
|
1096
|
+
tags.each do |tag|
|
1097
|
+
@resource.tag(tag)
|
1098
|
+
end
|
630
1099
|
end
|
1100
|
+
end
|
631
1101
|
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
# name conflicts, does it necessarily mean that the objects conflict?
|
636
|
-
# Defaults to true.
|
637
|
-
def self.isomorphic?
|
638
|
-
if defined? @isomorphic
|
639
|
-
return @isomorphic
|
640
|
-
else
|
641
|
-
return true
|
642
|
-
end
|
1102
|
+
class RelationshipMetaparam < Puppet::Parameter
|
1103
|
+
class << self
|
1104
|
+
attr_accessor :direction, :events, :callback, :subclasses
|
643
1105
|
end
|
644
1106
|
|
645
|
-
|
646
|
-
self.class.isomorphic?
|
647
|
-
end
|
1107
|
+
@subclasses = []
|
648
1108
|
|
649
|
-
|
650
|
-
|
651
|
-
# in order resolve other questions, such as finding a package
|
652
|
-
# in a list
|
653
|
-
def managed?
|
654
|
-
# Once an object is managed, it always stays managed; but an object
|
655
|
-
# that is listed as unmanaged might become managed later in the process,
|
656
|
-
# so we have to check that every time
|
657
|
-
if defined? @managed and @managed
|
658
|
-
return @managed
|
659
|
-
else
|
660
|
-
@managed = false
|
661
|
-
properties.each { |property|
|
662
|
-
s = property.should
|
663
|
-
if s and ! property.class.unmanaged
|
664
|
-
@managed = true
|
665
|
-
break
|
666
|
-
end
|
667
|
-
}
|
668
|
-
return @managed
|
669
|
-
end
|
1109
|
+
def self.inherited(sub)
|
1110
|
+
@subclasses << sub
|
670
1111
|
end
|
671
1112
|
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
def self.depthfirst?
|
678
|
-
if defined? @depthfirst
|
679
|
-
return @depthfirst
|
1113
|
+
def munge(references)
|
1114
|
+
references = [references] unless references.is_a?(Array)
|
1115
|
+
references.collect do |ref|
|
1116
|
+
if ref.is_a?(Puppet::Resource)
|
1117
|
+
ref
|
680
1118
|
else
|
681
|
-
|
1119
|
+
Puppet::Resource.new(ref)
|
682
1120
|
end
|
1121
|
+
end
|
683
1122
|
end
|
684
1123
|
|
685
|
-
def
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
# subscriptions get eliminated, too.
|
691
|
-
def remove(rmdeps = true)
|
692
|
-
# This is hackish (mmm, cut and paste), but it works for now, and it's
|
693
|
-
# better than warnings.
|
694
|
-
@parameters.each do |name, obj|
|
695
|
-
obj.remove
|
696
|
-
end
|
697
|
-
@parameters.clear
|
698
|
-
|
699
|
-
@parent = nil
|
700
|
-
|
701
|
-
# Remove the reference to the provider.
|
702
|
-
if self.provider
|
703
|
-
@provider.clear
|
704
|
-
@provider = nil
|
1124
|
+
def validate_relationship
|
1125
|
+
@value.each do |ref|
|
1126
|
+
unless @resource.catalog.resource(ref.to_s)
|
1127
|
+
description = self.class.direction == :in ? "dependency" : "dependent"
|
1128
|
+
fail "Could not find #{description} #{ref} for #{resource.ref}"
|
705
1129
|
end
|
1130
|
+
end
|
706
1131
|
end
|
707
1132
|
|
708
|
-
|
709
|
-
#
|
710
|
-
|
711
|
-
#
|
712
|
-
#
|
713
|
-
#
|
714
|
-
#
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
end
|
720
|
-
end
|
721
|
-
|
722
|
-
# this only operates on properties, not properties + children
|
723
|
-
# it's important that we call retrieve() on the type instance,
|
724
|
-
# not directly on the property, because it allows the type to override
|
725
|
-
# the method, like pfile does
|
726
|
-
currentvalues = self.retrieve
|
1133
|
+
# Create edges from each of our relationships. :in
|
1134
|
+
# relationships are specified by the event-receivers, and :out
|
1135
|
+
# relationships are specified by the event generator. This
|
1136
|
+
# way 'source' and 'target' are consistent terms in both edges
|
1137
|
+
# and events -- that is, an event targets edges whose source matches
|
1138
|
+
# the event's source. The direction of the relationship determines
|
1139
|
+
# which resource is applied first and which resource is considered
|
1140
|
+
# to be the event generator.
|
1141
|
+
def to_edges
|
1142
|
+
@value.collect do |reference|
|
1143
|
+
reference.catalog = resource.catalog
|
727
1144
|
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
self.debug "%s change(s)" %
|
733
|
-
[changes.length]
|
1145
|
+
# Either of the two retrieval attempts could have returned
|
1146
|
+
# nil.
|
1147
|
+
unless related_resource = reference.resolve
|
1148
|
+
self.fail "Could not retrieve dependency '#{reference}' of #{@resource.ref}"
|
734
1149
|
end
|
735
1150
|
|
736
|
-
#
|
737
|
-
#
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
noop = noop?
|
742
|
-
if ! noop or (noop && changes.length == 0)
|
743
|
-
self.cache(:checked, Time.now)
|
744
|
-
end
|
745
|
-
return changes.flatten
|
746
|
-
end
|
747
|
-
|
748
|
-
# Flush the provider, if it supports it. This is called by the
|
749
|
-
# transaction.
|
750
|
-
def flush
|
751
|
-
if self.provider and self.provider.respond_to?(:flush)
|
752
|
-
self.provider.flush
|
753
|
-
end
|
754
|
-
end
|
755
|
-
|
756
|
-
# if all contained objects are in sync, then we're in sync
|
757
|
-
# FIXME I don't think this is used on the type instances any more,
|
758
|
-
# it's really only used for testing
|
759
|
-
def insync?(is)
|
760
|
-
insync = true
|
761
|
-
|
762
|
-
if property = @parameters[:ensure]
|
763
|
-
unless is.include? property
|
764
|
-
raise Puppet::DevError,
|
765
|
-
"The is value is not in the is array for '%s'" %
|
766
|
-
[property.name]
|
767
|
-
end
|
768
|
-
ensureis = is[property]
|
769
|
-
if property.insync?(ensureis) and property.should == :absent
|
770
|
-
return true
|
771
|
-
end
|
772
|
-
end
|
773
|
-
|
774
|
-
properties.each { |property|
|
775
|
-
unless is.include? property
|
776
|
-
raise Puppet::DevError,
|
777
|
-
"The is value is not in the is array for '%s'" %
|
778
|
-
[property.name]
|
779
|
-
end
|
780
|
-
|
781
|
-
propis = is[property]
|
782
|
-
unless property.insync?(propis)
|
783
|
-
property.debug("Not in sync: %s vs %s" %
|
784
|
-
[propis.inspect, property.should.inspect])
|
785
|
-
insync = false
|
786
|
-
#else
|
787
|
-
# property.debug("In sync")
|
788
|
-
end
|
789
|
-
}
|
790
|
-
|
791
|
-
#self.debug("%s sync status is %s" % [self,insync])
|
792
|
-
return insync
|
793
|
-
end
|
794
|
-
|
795
|
-
# retrieve the current value of all contained properties
|
796
|
-
def retrieve
|
797
|
-
return currentpropvalues
|
798
|
-
end
|
799
|
-
|
800
|
-
# Get a hash of the current properties. Returns a hash with
|
801
|
-
# the actual property instance as the key and the current value
|
802
|
-
# as the, um, value.
|
803
|
-
def currentpropvalues
|
804
|
-
# It's important to use the 'properties' method here, as it follows the order
|
805
|
-
# in which they're defined in the class. It also guarantees that 'ensure'
|
806
|
-
# is the first property, which is important for skipping 'retrieve' on
|
807
|
-
# all the properties if the resource is absent.
|
808
|
-
ensure_state = false
|
809
|
-
return properties().inject({}) do | prophash, property|
|
810
|
-
if property.name == :ensure
|
811
|
-
ensure_state = property.retrieve
|
812
|
-
prophash[property] = ensure_state
|
813
|
-
else
|
814
|
-
if ensure_state == :absent
|
815
|
-
prophash[property] = :absent
|
816
|
-
else
|
817
|
-
prophash[property] = property.retrieve
|
818
|
-
end
|
819
|
-
end
|
820
|
-
prophash
|
821
|
-
end
|
822
|
-
end
|
823
|
-
|
824
|
-
# Are we running in noop mode?
|
825
|
-
def noop?
|
826
|
-
if defined?(@noop)
|
827
|
-
@noop
|
1151
|
+
# Are we requiring them, or vice versa? See the method docs
|
1152
|
+
# for futher info on this.
|
1153
|
+
if self.class.direction == :in
|
1154
|
+
source = related_resource
|
1155
|
+
target = @resource
|
828
1156
|
else
|
829
|
-
|
830
|
-
|
831
|
-
end
|
832
|
-
|
833
|
-
def noop
|
834
|
-
noop?
|
835
|
-
end
|
836
|
-
|
837
|
-
# Retrieve the changes associated with all of the properties.
|
838
|
-
def propertychanges(currentvalues)
|
839
|
-
# If we are changing the existence of the object, then none of
|
840
|
-
# the other properties matter.
|
841
|
-
changes = []
|
842
|
-
ensureparam = @parameters[:ensure]
|
843
|
-
|
844
|
-
# This allows resource types to have 'ensure' be a parameter, which allows them to
|
845
|
-
# just pass the parameter on to other generated resources.
|
846
|
-
ensureparam = nil unless ensureparam.is_a?(Puppet::Property)
|
847
|
-
if ensureparam && !currentvalues.include?(ensureparam)
|
848
|
-
raise Puppet::DevError, "Parameter ensure defined but missing from current values"
|
1157
|
+
source = @resource
|
1158
|
+
target = related_resource
|
849
1159
|
end
|
850
1160
|
|
851
|
-
if
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
1161
|
+
if method = self.class.callback
|
1162
|
+
subargs = {
|
1163
|
+
:event => self.class.events,
|
1164
|
+
:callback => method
|
1165
|
+
}
|
1166
|
+
self.debug("subscribes to #{related_resource.ref}")
|
857
1167
|
else
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
Puppet::Transaction::Change.new(property, currentvalues[property])
|
863
|
-
}
|
864
|
-
end
|
865
|
-
|
866
|
-
if Puppet[:debug] and changes.length > 0
|
867
|
-
self.debug("Changing " + changes.collect { |ch| ch.property.name }.join(","))
|
1168
|
+
# If there's no callback, there's no point in even adding
|
1169
|
+
# a label.
|
1170
|
+
subargs = nil
|
1171
|
+
self.debug("requires #{related_resource.ref}")
|
868
1172
|
end
|
869
1173
|
|
870
|
-
|
1174
|
+
rel = Puppet::Relationship.new(source, target, subargs)
|
1175
|
+
end
|
871
1176
|
end
|
1177
|
+
end
|
872
1178
|
|
873
|
-
|
874
|
-
|
875
|
-
|
1179
|
+
def self.relationship_params
|
1180
|
+
RelationshipMetaparam.subclasses
|
1181
|
+
end
|
876
1182
|
|
877
|
-
# retrieve a named instance of the current type
|
878
|
-
def self.[](name)
|
879
|
-
raise "Global resource access is deprecated"
|
880
|
-
@objects[name] || @aliases[name]
|
881
|
-
end
|
882
1183
|
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
if object.is_a?(Puppet::Type)
|
888
|
-
newobj = object
|
889
|
-
else
|
890
|
-
raise Puppet::DevError, "must pass a Puppet::Type object"
|
891
|
-
end
|
892
|
-
|
893
|
-
if exobj = @objects[name] and self.isomorphic?
|
894
|
-
msg = "Object '%s[%s]' already exists" %
|
895
|
-
[newobj.class.name, name]
|
896
|
-
|
897
|
-
if exobj.file and exobj.line
|
898
|
-
msg += ("in file %s at line %s" %
|
899
|
-
[object.file, object.line])
|
900
|
-
end
|
901
|
-
if object.file and object.line
|
902
|
-
msg += ("and cannot be redefined in file %s at line %s" %
|
903
|
-
[object.file, object.line])
|
904
|
-
end
|
905
|
-
error = Puppet::Error.new(msg)
|
906
|
-
raise error
|
907
|
-
else
|
908
|
-
#Puppet.info("adding %s of type %s to class list" %
|
909
|
-
# [name,object.class])
|
910
|
-
@objects[name] = newobj
|
911
|
-
end
|
912
|
-
end
|
1184
|
+
# Note that the order in which the relationships params is defined
|
1185
|
+
# matters. The labelled params (notify and subcribe) must be later,
|
1186
|
+
# so that if both params are used, those ones win. It's a hackish
|
1187
|
+
# solution, but it works.
|
913
1188
|
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
if @objects.include?(name)
|
919
|
-
unless @objects[name] == obj
|
920
|
-
raise Puppet::Error.new(
|
921
|
-
"Cannot create alias %s: object already exists" %
|
922
|
-
[name]
|
923
|
-
)
|
924
|
-
end
|
925
|
-
end
|
1189
|
+
newmetaparam(:require, :parent => RelationshipMetaparam, :attributes => {:direction => :in, :events => :NONE}) do
|
1190
|
+
desc "One or more objects that this object depends on.
|
1191
|
+
This is used purely for guaranteeing that changes to required objects
|
1192
|
+
happen before the dependent object. For instance::
|
926
1193
|
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
[@aliases[name].name, name]
|
932
|
-
)
|
933
|
-
end
|
934
|
-
end
|
1194
|
+
# Create the destination directory before you copy things down
|
1195
|
+
file { \"/usr/local/scripts\":
|
1196
|
+
ensure => directory
|
1197
|
+
}
|
935
1198
|
|
936
|
-
|
937
|
-
|
1199
|
+
file { \"/usr/local/scripts/myscript\":
|
1200
|
+
source => \"puppet://server/module/myscript\",
|
1201
|
+
mode => 755,
|
1202
|
+
require => File[\"/usr/local/scripts\"]
|
1203
|
+
}
|
938
1204
|
|
939
|
-
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
|
949
|
-
|
950
|
-
|
951
|
-
|
1205
|
+
Multiple dependencies can be specified by providing a comma-seperated list
|
1206
|
+
of resources, enclosed in square brackets::
|
1207
|
+
|
1208
|
+
require => [ File[\"/usr/local\"], File[\"/usr/local/scripts\"] ]
|
1209
|
+
|
1210
|
+
Note that Puppet will autorequire everything that it can, and
|
1211
|
+
there are hooks in place so that it's easy for resources to add new
|
1212
|
+
ways to autorequire objects, so if you think Puppet could be
|
1213
|
+
smarter here, let us know.
|
1214
|
+
|
1215
|
+
In fact, the above code was redundant -- Puppet will autorequire
|
1216
|
+
any parent directories that are being managed; it will
|
1217
|
+
automatically realize that the parent directory should be created
|
1218
|
+
before the script is pulled down.
|
1219
|
+
|
1220
|
+
Currently, exec resources will autorequire their CWD (if it is
|
1221
|
+
specified) plus any fully qualified paths that appear in the
|
1222
|
+
command. For instance, if you had an ``exec`` command that ran
|
1223
|
+
the ``myscript`` mentioned above, the above code that pulls the
|
1224
|
+
file down would be automatically listed as a requirement to the
|
1225
|
+
``exec`` code, so that you would always be running againts the
|
1226
|
+
most recent version.
|
1227
|
+
"
|
1228
|
+
end
|
1229
|
+
|
1230
|
+
newmetaparam(:subscribe, :parent => RelationshipMetaparam, :attributes => {:direction => :in, :events => :ALL_EVENTS, :callback => :refresh}) do
|
1231
|
+
desc "One or more objects that this object depends on. Changes in the
|
1232
|
+
subscribed to objects result in the dependent objects being
|
1233
|
+
refreshed (e.g., a service will get restarted). For instance::
|
1234
|
+
|
1235
|
+
class nagios {
|
1236
|
+
file { \"/etc/nagios/nagios.conf\":
|
1237
|
+
source => \"puppet://server/module/nagios.conf\",
|
1238
|
+
alias => nagconf # just to make things easier for me
|
1239
|
+
}
|
1240
|
+
service { nagios:
|
1241
|
+
ensure => running,
|
1242
|
+
subscribe => File[nagconf]
|
1243
|
+
}
|
1244
|
+
}
|
952
1245
|
|
953
|
-
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
Puppet.warning "Puppet::Type.create is deprecated; use Puppet::Type.new"
|
958
|
-
new(args)
|
959
|
-
end
|
1246
|
+
Currently the ``exec``, ``mount`` and ``service`` type support
|
1247
|
+
refreshing.
|
1248
|
+
"
|
1249
|
+
end
|
960
1250
|
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
|
965
|
-
if @objects.include?(resource.title)
|
966
|
-
@objects.delete(resource.title)
|
967
|
-
end
|
968
|
-
if @aliases.include?(resource.title)
|
969
|
-
@aliases.delete(resource.title)
|
970
|
-
end
|
971
|
-
if @aliases.has_value?(resource)
|
972
|
-
names = []
|
973
|
-
@aliases.each do |name, otherres|
|
974
|
-
if otherres == resource
|
975
|
-
names << name
|
976
|
-
end
|
977
|
-
end
|
978
|
-
names.each { |name| @aliases.delete(name) }
|
979
|
-
end
|
980
|
-
end
|
1251
|
+
newmetaparam(:before, :parent => RelationshipMetaparam, :attributes => {:direction => :out, :events => :NONE}) do
|
1252
|
+
desc %{This parameter is the opposite of **require** -- it guarantees
|
1253
|
+
that the specified object is applied later than the specifying
|
1254
|
+
object::
|
981
1255
|
|
982
|
-
|
983
|
-
|
984
|
-
|
985
|
-
|
986
|
-
@objects.each { |name,instance|
|
987
|
-
yield instance
|
1256
|
+
file { "/var/nagios/configuration":
|
1257
|
+
source => "...",
|
1258
|
+
recurse => true,
|
1259
|
+
before => Exec["nagios-rebuid"]
|
988
1260
|
}
|
989
|
-
end
|
990
1261
|
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
end
|
1262
|
+
exec { "nagios-rebuild":
|
1263
|
+
command => "/usr/bin/make",
|
1264
|
+
cwd => "/var/nagios/configuration"
|
1265
|
+
}
|
996
1266
|
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
raise Puppet::DevError, "%s has no providers and has not overridden 'instances'" % self.name
|
1001
|
-
end
|
1267
|
+
This will make sure all of the files are up to date before the
|
1268
|
+
make command is run.}
|
1269
|
+
end
|
1002
1270
|
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
provider.instances.collect do |instance|
|
1007
|
-
# We always want to use the "first" provider instance we find, unless the resource
|
1008
|
-
# is already managed and has a different provider set
|
1009
|
-
if other = provider_instances[instance.name]
|
1010
|
-
Puppet.warning "%s %s found in both %s and %s; skipping the %s version" %
|
1011
|
-
[self.name.to_s.capitalize, instance.name, other.class.name, instance.class.name, instance.class.name]
|
1012
|
-
next
|
1013
|
-
end
|
1014
|
-
provider_instances[instance.name] = instance
|
1015
|
-
|
1016
|
-
new(:name => instance.name, :provider => instance, :check => :all)
|
1017
|
-
end
|
1018
|
-
end.flatten.compact
|
1019
|
-
end
|
1020
|
-
|
1021
|
-
# Return a list of one suitable provider per source, with the default provider first.
|
1022
|
-
def self.providers_by_source
|
1023
|
-
# Put the default provider first, then the rest of the suitable providers.
|
1024
|
-
sources = []
|
1025
|
-
[defaultprovider, suitableprovider].flatten.uniq.collect do |provider|
|
1026
|
-
next if sources.include?(provider.source)
|
1027
|
-
|
1028
|
-
sources << provider.source
|
1029
|
-
provider
|
1030
|
-
end.compact
|
1031
|
-
end
|
1032
|
-
|
1033
|
-
# Convert a simple hash into a Resource instance. This is a convenience method,
|
1034
|
-
# so people can create RAL resources with a hash and get the same behaviour
|
1035
|
-
# as we get internally when we use Resource instances.
|
1036
|
-
# This should only be used directly from Ruby -- it's not used when going through
|
1037
|
-
# normal Puppet usage.
|
1038
|
-
def self.hash2resource(hash)
|
1039
|
-
hash = hash.inject({}) { |result, ary| result[ary[0].to_sym] = ary[1]; result }
|
1040
|
-
|
1041
|
-
if title = hash[:title]
|
1042
|
-
hash.delete(:title)
|
1043
|
-
else
|
1044
|
-
if self.namevar != :name
|
1045
|
-
if hash.include?(:name) and hash.include?(self.namevar)
|
1046
|
-
raise Puppet::Error, "Cannot provide both name and %s to resources of type %s" % [self.namevar, self.name]
|
1047
|
-
end
|
1048
|
-
if title = hash[self.namevar]
|
1049
|
-
hash.delete(self.namevar)
|
1050
|
-
end
|
1051
|
-
end
|
1052
|
-
|
1053
|
-
unless title ||= hash[:name]
|
1054
|
-
raise Puppet::Error, "You must specify a name or title for resources"
|
1055
|
-
end
|
1056
|
-
end
|
1271
|
+
newmetaparam(:notify, :parent => RelationshipMetaparam, :attributes => {:direction => :out, :events => :ALL_EVENTS, :callback => :refresh}) do
|
1272
|
+
desc %{This parameter is the opposite of **subscribe** -- it sends events
|
1273
|
+
to the specified object::
|
1057
1274
|
|
1275
|
+
file { "/etc/sshd_config":
|
1276
|
+
source => "....",
|
1277
|
+
notify => Service[sshd]
|
1278
|
+
}
|
1058
1279
|
|
1059
|
-
|
1060
|
-
|
1061
|
-
|
1062
|
-
if value = hash[attribute]
|
1063
|
-
hash.delete(attribute)
|
1064
|
-
resource.send(attribute.to_s + "=", value)
|
1065
|
-
end
|
1066
|
-
end
|
1280
|
+
service { sshd:
|
1281
|
+
ensure => running
|
1282
|
+
}
|
1067
1283
|
|
1068
|
-
|
1069
|
-
|
1070
|
-
end
|
1071
|
-
return resource
|
1072
|
-
end
|
1284
|
+
This will restart the sshd service if the sshd config file changes.}
|
1285
|
+
end
|
1073
1286
|
|
1074
|
-
|
1075
|
-
|
1076
|
-
|
1077
|
-
|
1078
|
-
|
1079
|
-
[self.ref]
|
1080
|
-
end
|
1081
|
-
end
|
1287
|
+
newmetaparam(:stage) do
|
1288
|
+
desc %{Which run stage a given resource should reside in. This just creates
|
1289
|
+
a dependency on or from the named milestone. For instance, saying that
|
1290
|
+
this is in the 'bootstrap' stage creates a dependency on the 'bootstrap'
|
1291
|
+
milestone.
|
1082
1292
|
|
1083
|
-
|
1084
|
-
|
1085
|
-
newmetaparam(:noop) do
|
1086
|
-
desc "Boolean flag indicating whether work should actually
|
1087
|
-
be done."
|
1293
|
+
By default, all classes get directly added to the
|
1294
|
+
'main' stage. You can create new stages as resources:
|
1088
1295
|
|
1089
|
-
|
1090
|
-
munge do |value|
|
1091
|
-
case value
|
1092
|
-
when true, :true, "true"; @resource.noop = true
|
1093
|
-
when false, :false, "false"; @resource.noop = false
|
1094
|
-
end
|
1095
|
-
end
|
1096
|
-
end
|
1296
|
+
stage { [pre, post]: }
|
1097
1297
|
|
1098
|
-
|
1099
|
-
desc "On what schedule the object should be managed. You must create a
|
1100
|
-
schedule object, and then reference the name of that object to use
|
1101
|
-
that for your schedule::
|
1102
|
-
|
1103
|
-
schedule { daily:
|
1104
|
-
period => daily,
|
1105
|
-
range => \"2-4\"
|
1106
|
-
}
|
1107
|
-
|
1108
|
-
exec { \"/usr/bin/apt-get update\":
|
1109
|
-
schedule => daily
|
1110
|
-
}
|
1111
|
-
|
1112
|
-
The creation of the schedule object does not need to appear in the
|
1113
|
-
configuration before objects that use it."
|
1114
|
-
end
|
1115
|
-
|
1116
|
-
newmetaparam(:check) do
|
1117
|
-
desc "Propertys which should have their values retrieved
|
1118
|
-
but which should not actually be modified. This is currently used
|
1119
|
-
internally, but will eventually be used for querying, so that you
|
1120
|
-
could specify that you wanted to check the install state of all
|
1121
|
-
packages, and then query the Puppet client daemon to get reports
|
1122
|
-
on all packages."
|
1123
|
-
|
1124
|
-
munge do |args|
|
1125
|
-
# If they've specified all, collect all known properties
|
1126
|
-
if args == :all
|
1127
|
-
args = @resource.class.properties.find_all do |property|
|
1128
|
-
# Only get properties supported by our provider
|
1129
|
-
if @resource.provider
|
1130
|
-
@resource.provider.class.supports_parameter?(property)
|
1131
|
-
else
|
1132
|
-
true
|
1133
|
-
end
|
1134
|
-
end.collect do |property|
|
1135
|
-
property.name
|
1136
|
-
end
|
1137
|
-
end
|
1138
|
-
|
1139
|
-
unless args.is_a?(Array)
|
1140
|
-
args = [args]
|
1141
|
-
end
|
1142
|
-
|
1143
|
-
unless defined? @resource
|
1144
|
-
self.devfail "No parent for %s, %s?" %
|
1145
|
-
[self.class, self.name]
|
1146
|
-
end
|
1147
|
-
|
1148
|
-
args.each { |property|
|
1149
|
-
unless property.is_a?(Symbol)
|
1150
|
-
property = property.intern
|
1151
|
-
end
|
1152
|
-
next if @resource.propertydefined?(property)
|
1153
|
-
|
1154
|
-
unless propertyklass = @resource.class.validproperty?(property)
|
1155
|
-
if @resource.class.validattr?(property)
|
1156
|
-
next
|
1157
|
-
else
|
1158
|
-
raise Puppet::Error, "%s is not a valid attribute for %s" %
|
1159
|
-
[property, self.class.name]
|
1160
|
-
end
|
1161
|
-
end
|
1162
|
-
next unless propertyklass.checkable?
|
1163
|
-
@resource.newattr(property)
|
1164
|
-
}
|
1165
|
-
end
|
1166
|
-
end
|
1298
|
+
To order stages, use standard relationships:
|
1167
1299
|
|
1168
|
-
|
1169
|
-
desc "Sets the level that information will be logged.
|
1170
|
-
The log levels have the biggest impact when logs are sent to
|
1171
|
-
syslog (which is currently the default)."
|
1172
|
-
defaultto :notice
|
1300
|
+
stage { pre: before => Stage[main] }
|
1173
1301
|
|
1174
|
-
|
1175
|
-
newvalues(:verbose)
|
1302
|
+
Or use the new relationship syntax:
|
1176
1303
|
|
1177
|
-
|
1178
|
-
val = super(loglevel)
|
1179
|
-
if val == :verbose
|
1180
|
-
val = :info
|
1181
|
-
end
|
1182
|
-
val
|
1183
|
-
end
|
1184
|
-
end
|
1304
|
+
Stage[pre] -> Stage[main] -> Stage[post]
|
1185
1305
|
|
1186
|
-
|
1187
|
-
desc "Creates an alias for the object. Puppet uses this internally when you
|
1188
|
-
provide a symbolic name::
|
1306
|
+
Then use the new class parameters to specify a stage:
|
1189
1307
|
|
1190
|
-
|
1191
|
-
path => $operatingsystem ? {
|
1192
|
-
solaris => \"/usr/local/etc/ssh/sshd_config\",
|
1193
|
-
default => \"/etc/ssh/sshd_config\"
|
1194
|
-
},
|
1195
|
-
source => \"...\"
|
1196
|
-
}
|
1308
|
+
class { foo: stage => pre }
|
1197
1309
|
|
1198
|
-
|
1199
|
-
|
1200
|
-
}
|
1310
|
+
Stages can only be set on classes, not individual resources. This will
|
1311
|
+
fail::
|
1201
1312
|
|
1202
|
-
|
1203
|
-
|
1204
|
-
|
1205
|
-
but note that only the library can use these aliases; for instance,
|
1206
|
-
the following code will not work::
|
1313
|
+
file { '/foo': stage => pre, ensure => file }
|
1314
|
+
}
|
1315
|
+
end
|
1207
1316
|
|
1208
|
-
|
1209
|
-
|
1210
|
-
|
1211
|
-
|
1212
|
-
}
|
1317
|
+
###############################
|
1318
|
+
# All of the provider plumbing for the resource types.
|
1319
|
+
require 'puppet/provider'
|
1320
|
+
require 'puppet/util/provider_features'
|
1213
1321
|
|
1214
|
-
|
1215
|
-
|
1216
|
-
}
|
1322
|
+
# Add the feature handling module.
|
1323
|
+
extend Puppet::Util::ProviderFeatures
|
1217
1324
|
|
1218
|
-
|
1219
|
-
should be affecting the same file.
|
1325
|
+
attr_reader :provider
|
1220
1326
|
|
1221
|
-
|
1327
|
+
# the Type class attribute accessors
|
1328
|
+
class << self
|
1329
|
+
attr_accessor :providerloader
|
1330
|
+
attr_writer :defaultprovider
|
1331
|
+
end
|
1222
1332
|
|
1223
|
-
|
1333
|
+
# Find the default provider.
|
1334
|
+
def self.defaultprovider
|
1335
|
+
unless @defaultprovider
|
1336
|
+
suitable = suitableprovider
|
1224
1337
|
|
1225
|
-
|
1226
|
-
|
1227
|
-
aliases = [aliases]
|
1228
|
-
end
|
1338
|
+
# Find which providers are a default for this system.
|
1339
|
+
defaults = suitable.find_all { |provider| provider.default? }
|
1229
1340
|
|
1230
|
-
|
1341
|
+
# If we don't have any default we use suitable providers
|
1342
|
+
defaults = suitable if defaults.empty?
|
1343
|
+
max = defaults.collect { |provider| provider.specificity }.max
|
1344
|
+
defaults = defaults.find_all { |provider| provider.specificity == max }
|
1231
1345
|
|
1232
|
-
|
1233
|
-
|
1234
|
-
|
1235
|
-
|
1236
|
-
|
1237
|
-
|
1238
|
-
|
1346
|
+
retval = nil
|
1347
|
+
if defaults.length > 1
|
1348
|
+
Puppet.warning(
|
1349
|
+
"Found multiple default providers for #{self.name}: #{defaults.collect { |i| i.name.to_s }.join(", ")}; using #{defaults[0].name}"
|
1350
|
+
)
|
1351
|
+
retval = defaults.shift
|
1352
|
+
elsif defaults.length == 1
|
1353
|
+
retval = defaults.shift
|
1354
|
+
else
|
1355
|
+
raise Puppet::DevError, "Could not find a default provider for #{self.name}"
|
1356
|
+
end
|
1239
1357
|
|
1240
|
-
|
1241
|
-
@resource.catalog.alias(@resource, other)
|
1242
|
-
end
|
1243
|
-
end
|
1358
|
+
@defaultprovider = retval
|
1244
1359
|
end
|
1245
1360
|
|
1246
|
-
|
1247
|
-
|
1248
|
-
are automatically tagged with as much information as possible
|
1249
|
-
(e.g., each class and definition containing the resource), it can
|
1250
|
-
be useful to add your own tags to a given resource.
|
1361
|
+
@defaultprovider
|
1362
|
+
end
|
1251
1363
|
|
1252
|
-
|
1253
|
-
|
1364
|
+
def self.provider_hash_by_type(type)
|
1365
|
+
@provider_hashes ||= {}
|
1366
|
+
@provider_hashes[type] ||= {}
|
1367
|
+
end
|
1254
1368
|
|
1255
|
-
|
1369
|
+
def self.provider_hash
|
1370
|
+
Puppet::Type.provider_hash_by_type(self.name)
|
1371
|
+
end
|
1256
1372
|
|
1257
|
-
|
1258
|
-
|
1373
|
+
# Retrieve a provider by name.
|
1374
|
+
def self.provider(name)
|
1375
|
+
name = Puppet::Util.symbolize(name)
|
1259
1376
|
|
1260
|
-
|
1261
|
-
|
1377
|
+
# If we don't have it yet, try loading it.
|
1378
|
+
@providerloader.load(name) unless provider_hash.has_key?(name)
|
1379
|
+
provider_hash[name]
|
1380
|
+
end
|
1262
1381
|
|
1263
|
-
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1267
|
-
end
|
1382
|
+
# Just list all of the providers.
|
1383
|
+
def self.providers
|
1384
|
+
provider_hash.keys
|
1385
|
+
end
|
1268
1386
|
|
1269
|
-
|
1270
|
-
|
1271
|
-
attr_accessor :direction, :events, :callback, :subclasses
|
1272
|
-
end
|
1387
|
+
def self.validprovider?(name)
|
1388
|
+
name = Puppet::Util.symbolize(name)
|
1273
1389
|
|
1274
|
-
|
1390
|
+
(provider_hash.has_key?(name) && provider_hash[name].suitable?)
|
1391
|
+
end
|
1275
1392
|
|
1276
|
-
|
1277
|
-
|
1278
|
-
|
1279
|
-
|
1280
|
-
def munge(references)
|
1281
|
-
references = [references] unless references.is_a?(Array)
|
1282
|
-
references.collect do |ref|
|
1283
|
-
if ref.is_a?(Puppet::Resource::Reference)
|
1284
|
-
ref
|
1285
|
-
else
|
1286
|
-
Puppet::Resource::Reference.new(ref)
|
1287
|
-
end
|
1288
|
-
end
|
1289
|
-
end
|
1393
|
+
# Create a new provider of a type. This method must be called
|
1394
|
+
# directly on the type that it's implementing.
|
1395
|
+
def self.provide(name, options = {}, &block)
|
1396
|
+
name = Puppet::Util.symbolize(name)
|
1290
1397
|
|
1291
|
-
|
1292
|
-
|
1293
|
-
|
1294
|
-
description = self.class.direction == :in ? "dependency" : "dependent"
|
1295
|
-
fail "Could not find %s %s for %s" % [description, ref.to_s, resource.ref]
|
1296
|
-
end
|
1297
|
-
end
|
1298
|
-
end
|
1299
|
-
|
1300
|
-
# Create edges from each of our relationships. :in
|
1301
|
-
# relationships are specified by the event-receivers, and :out
|
1302
|
-
# relationships are specified by the event generator. This
|
1303
|
-
# way 'source' and 'target' are consistent terms in both edges
|
1304
|
-
# and events -- that is, an event targets edges whose source matches
|
1305
|
-
# the event's source. The direction of the relationship determines
|
1306
|
-
# which resource is applied first and which resource is considered
|
1307
|
-
# to be the event generator.
|
1308
|
-
def to_edges
|
1309
|
-
@value.collect do |reference|
|
1310
|
-
reference.catalog = resource.catalog
|
1311
|
-
|
1312
|
-
# Either of the two retrieval attempts could have returned
|
1313
|
-
# nil.
|
1314
|
-
unless related_resource = reference.resolve
|
1315
|
-
self.fail "Could not retrieve dependency '%s' of %s" % [reference, @resource.ref]
|
1316
|
-
end
|
1317
|
-
|
1318
|
-
# Are we requiring them, or vice versa? See the method docs
|
1319
|
-
# for futher info on this.
|
1320
|
-
if self.class.direction == :in
|
1321
|
-
source = related_resource
|
1322
|
-
target = @resource
|
1323
|
-
else
|
1324
|
-
source = @resource
|
1325
|
-
target = related_resource
|
1326
|
-
end
|
1327
|
-
|
1328
|
-
if method = self.class.callback
|
1329
|
-
subargs = {
|
1330
|
-
:event => self.class.events,
|
1331
|
-
:callback => method
|
1332
|
-
}
|
1333
|
-
self.debug("subscribes to %s" % [related_resource.ref])
|
1334
|
-
else
|
1335
|
-
# If there's no callback, there's no point in even adding
|
1336
|
-
# a label.
|
1337
|
-
subargs = nil
|
1338
|
-
self.debug("requires %s" % [related_resource.ref])
|
1339
|
-
end
|
1340
|
-
|
1341
|
-
rel = Puppet::Relationship.new(source, target, subargs)
|
1342
|
-
end
|
1343
|
-
end
|
1398
|
+
if obj = provider_hash[name]
|
1399
|
+
Puppet.debug "Reloading #{name} #{self.name} provider"
|
1400
|
+
unprovide(name)
|
1344
1401
|
end
|
1345
1402
|
|
1346
|
-
|
1347
|
-
|
1348
|
-
|
1349
|
-
|
1350
|
-
|
1351
|
-
|
1352
|
-
|
1353
|
-
|
1354
|
-
|
1355
|
-
|
1356
|
-
|
1357
|
-
|
1358
|
-
|
1359
|
-
|
1360
|
-
|
1361
|
-
# Create the destination directory before you copy things down
|
1362
|
-
file { \"/usr/local/scripts\":
|
1363
|
-
ensure => directory
|
1364
|
-
}
|
1365
|
-
|
1366
|
-
file { \"/usr/local/scripts/myscript\":
|
1367
|
-
source => \"puppet://server/module/myscript\",
|
1368
|
-
mode => 755,
|
1369
|
-
require => File[\"/usr/local/scripts\"]
|
1370
|
-
}
|
1371
|
-
|
1372
|
-
Multiple dependencies can be specified by providing a comma-seperated list
|
1373
|
-
of resources, enclosed in square brackets::
|
1374
|
-
|
1375
|
-
require => [ File[\"/usr/local\"], File[\"/usr/local/scripts\"] ]
|
1376
|
-
|
1377
|
-
Note that Puppet will autorequire everything that it can, and
|
1378
|
-
there are hooks in place so that it's easy for resources to add new
|
1379
|
-
ways to autorequire objects, so if you think Puppet could be
|
1380
|
-
smarter here, let us know.
|
1381
|
-
|
1382
|
-
In fact, the above code was redundant -- Puppet will autorequire
|
1383
|
-
any parent directories that are being managed; it will
|
1384
|
-
automatically realize that the parent directory should be created
|
1385
|
-
before the script is pulled down.
|
1386
|
-
|
1387
|
-
Currently, exec resources will autorequire their CWD (if it is
|
1388
|
-
specified) plus any fully qualified paths that appear in the
|
1389
|
-
command. For instance, if you had an ``exec`` command that ran
|
1390
|
-
the ``myscript`` mentioned above, the above code that pulls the
|
1391
|
-
file down would be automatically listed as a requirement to the
|
1392
|
-
``exec`` code, so that you would always be running againts the
|
1393
|
-
most recent version.
|
1394
|
-
"
|
1403
|
+
parent = if pname = options[:parent]
|
1404
|
+
options.delete(:parent)
|
1405
|
+
if pname.is_a? Class
|
1406
|
+
pname
|
1407
|
+
else
|
1408
|
+
if provider = self.provider(pname)
|
1409
|
+
provider
|
1410
|
+
else
|
1411
|
+
raise Puppet::DevError,
|
1412
|
+
"Could not find parent provider #{pname} of #{name}"
|
1413
|
+
end
|
1414
|
+
end
|
1415
|
+
else
|
1416
|
+
Puppet::Provider
|
1395
1417
|
end
|
1396
1418
|
|
1397
|
-
|
1398
|
-
desc "One or more objects that this object depends on. Changes in the
|
1399
|
-
subscribed to objects result in the dependent objects being
|
1400
|
-
refreshed (e.g., a service will get restarted). For instance::
|
1419
|
+
options[:resource_type] ||= self
|
1401
1420
|
|
1402
|
-
|
1403
|
-
file { \"/etc/nagios/nagios.conf\":
|
1404
|
-
source => \"puppet://server/module/nagios.conf\",
|
1405
|
-
alias => nagconf # just to make things easier for me
|
1406
|
-
}
|
1407
|
-
service { nagios:
|
1408
|
-
running => true,
|
1409
|
-
subscribe => File[nagconf]
|
1410
|
-
}
|
1411
|
-
}
|
1421
|
+
self.providify
|
1412
1422
|
|
1413
|
-
Currently the ``exec``, ``mount`` and ``service`` type support
|
1414
|
-
refreshing.
|
1415
|
-
"
|
1416
|
-
end
|
1417
1423
|
|
1418
|
-
|
1419
|
-
|
1420
|
-
|
1421
|
-
|
1424
|
+
provider = genclass(
|
1425
|
+
name,
|
1426
|
+
:parent => parent,
|
1427
|
+
:hash => provider_hash,
|
1428
|
+
:prefix => "Provider",
|
1429
|
+
:block => block,
|
1430
|
+
:include => feature_module,
|
1431
|
+
:extend => feature_module,
|
1422
1432
|
|
1423
|
-
|
1424
|
-
|
1425
|
-
recurse => true,
|
1426
|
-
before => Exec["nagios-rebuid"]
|
1427
|
-
}
|
1433
|
+
:attributes => options
|
1434
|
+
)
|
1428
1435
|
|
1429
|
-
|
1430
|
-
|
1431
|
-
cwd => "/var/nagios/configuration"
|
1432
|
-
}
|
1436
|
+
provider
|
1437
|
+
end
|
1433
1438
|
|
1434
|
-
|
1435
|
-
|
1436
|
-
|
1439
|
+
# Make sure we have a :provider parameter defined. Only gets called if there
|
1440
|
+
# are providers.
|
1441
|
+
def self.providify
|
1442
|
+
return if @paramhash.has_key? :provider
|
1437
1443
|
|
1438
|
-
|
1439
|
-
|
1440
|
-
|
1444
|
+
newparam(:provider) do
|
1445
|
+
desc "The specific backend for #{self.name.to_s} to use. You will
|
1446
|
+
seldom need to specify this -- Puppet will usually discover the
|
1447
|
+
appropriate provider for your platform."
|
1441
1448
|
|
1442
|
-
|
1443
|
-
|
1444
|
-
|
1445
|
-
|
1449
|
+
# This is so we can refer back to the type to get a list of
|
1450
|
+
# providers for documentation.
|
1451
|
+
class << self
|
1452
|
+
attr_accessor :parenttype
|
1453
|
+
end
|
1446
1454
|
|
1447
|
-
|
1448
|
-
|
1449
|
-
|
1455
|
+
# We need to add documentation for each provider.
|
1456
|
+
def self.doc
|
1457
|
+
@doc + " Available providers are:\n\n" + parenttype.providers.sort { |a,b|
|
1458
|
+
a.to_s <=> b.to_s
|
1459
|
+
}.collect { |i|
|
1460
|
+
"* **#{i}**: #{parenttype().provider(i).doc}"
|
1461
|
+
}.join("\n")
|
1462
|
+
end
|
1450
1463
|
|
1451
|
-
|
1452
|
-
|
1453
|
-
|
1454
|
-
###############################
|
1455
|
-
# All of the provider plumbing for the resource types.
|
1456
|
-
require 'puppet/provider'
|
1457
|
-
require 'puppet/util/provider_features'
|
1464
|
+
defaultto {
|
1465
|
+
@resource.class.defaultprovider.name
|
1466
|
+
}
|
1458
1467
|
|
1459
|
-
|
1460
|
-
|
1461
|
-
|
1462
|
-
attr_reader :provider
|
1468
|
+
validate do |provider_class|
|
1469
|
+
provider_class = provider_class[0] if provider_class.is_a? Array
|
1470
|
+
provider_class = provider_class.class.name if provider_class.is_a?(Puppet::Provider)
|
1463
1471
|
|
1464
|
-
|
1465
|
-
|
1466
|
-
attr_accessor :providerloader
|
1467
|
-
attr_writer :defaultprovider
|
1468
|
-
end
|
1469
|
-
|
1470
|
-
# Find the default provider.
|
1471
|
-
def self.defaultprovider
|
1472
|
-
unless defined? @defaultprovider and @defaultprovider
|
1473
|
-
suitable = suitableprovider()
|
1474
|
-
|
1475
|
-
# Find which providers are a default for this system.
|
1476
|
-
defaults = suitable.find_all { |provider| provider.default? }
|
1477
|
-
|
1478
|
-
# If we don't have any default we use suitable providers
|
1479
|
-
defaults = suitable if defaults.empty?
|
1480
|
-
max = defaults.collect { |provider| provider.specificity }.max
|
1481
|
-
defaults = defaults.find_all { |provider| provider.specificity == max }
|
1482
|
-
|
1483
|
-
retval = nil
|
1484
|
-
if defaults.length > 1
|
1485
|
-
Puppet.warning(
|
1486
|
-
"Found multiple default providers for %s: %s; using %s" %
|
1487
|
-
[self.name, defaults.collect { |i| i.name.to_s }.join(", "),
|
1488
|
-
defaults[0].name]
|
1489
|
-
)
|
1490
|
-
retval = defaults.shift
|
1491
|
-
elsif defaults.length == 1
|
1492
|
-
retval = defaults.shift
|
1493
|
-
else
|
1494
|
-
raise Puppet::DevError, "Could not find a default provider for %s" %
|
1495
|
-
self.name
|
1496
|
-
end
|
1497
|
-
|
1498
|
-
@defaultprovider = retval
|
1472
|
+
unless provider = @resource.class.provider(provider_class)
|
1473
|
+
raise ArgumentError, "Invalid #{@resource.class.name} provider '#{provider_class}'"
|
1499
1474
|
end
|
1475
|
+
end
|
1500
1476
|
|
1501
|
-
|
1502
|
-
|
1477
|
+
munge do |provider|
|
1478
|
+
provider = provider[0] if provider.is_a? Array
|
1479
|
+
provider = provider.intern if provider.is_a? String
|
1480
|
+
@resource.provider = provider
|
1503
1481
|
|
1504
|
-
|
1505
|
-
|
1506
|
-
|
1507
|
-
|
1508
|
-
|
1509
|
-
|
1510
|
-
|
1511
|
-
|
1512
|
-
|
1513
|
-
|
1514
|
-
|
1515
|
-
|
1516
|
-
|
1517
|
-
|
1518
|
-
|
1519
|
-
|
1482
|
+
if provider.is_a?(Puppet::Provider)
|
1483
|
+
provider.class.name
|
1484
|
+
else
|
1485
|
+
provider
|
1486
|
+
end
|
1487
|
+
end
|
1488
|
+
end.parenttype = self
|
1489
|
+
end
|
1490
|
+
|
1491
|
+
def self.unprovide(name)
|
1492
|
+
if provider_hash.has_key? name
|
1493
|
+
|
1494
|
+
rmclass(
|
1495
|
+
name,
|
1496
|
+
:hash => provider_hash,
|
1497
|
+
|
1498
|
+
:prefix => "Provider"
|
1499
|
+
)
|
1500
|
+
if @defaultprovider and @defaultprovider.name == name
|
1501
|
+
@defaultprovider = nil
|
1502
|
+
end
|
1503
|
+
end
|
1504
|
+
end
|
1505
|
+
|
1506
|
+
# Return an array of all of the suitable providers.
|
1507
|
+
def self.suitableprovider
|
1508
|
+
providerloader.loadall if provider_hash.empty?
|
1509
|
+
provider_hash.find_all { |name, provider|
|
1510
|
+
provider.suitable?
|
1511
|
+
}.collect { |name, provider|
|
1512
|
+
provider
|
1513
|
+
}.reject { |p| p.name == :fake } # For testing
|
1514
|
+
end
|
1515
|
+
|
1516
|
+
def provider=(name)
|
1517
|
+
if name.is_a?(Puppet::Provider)
|
1518
|
+
@provider = name
|
1519
|
+
@provider.resource = self
|
1520
|
+
elsif klass = self.class.provider(name)
|
1521
|
+
@provider = klass.new(self)
|
1522
|
+
else
|
1523
|
+
raise ArgumentError, "Could not find #{name} provider of #{self.class.name}"
|
1524
|
+
end
|
1525
|
+
end
|
1526
|
+
|
1527
|
+
###############################
|
1528
|
+
# All of the relationship code.
|
1529
|
+
|
1530
|
+
# Specify a block for generating a list of objects to autorequire. This
|
1531
|
+
# makes it so that you don't have to manually specify things that you clearly
|
1532
|
+
# require.
|
1533
|
+
def self.autorequire(name, &block)
|
1534
|
+
@autorequires ||= {}
|
1535
|
+
@autorequires[name] = block
|
1536
|
+
end
|
1537
|
+
|
1538
|
+
# Yield each of those autorequires in turn, yo.
|
1539
|
+
def self.eachautorequire
|
1540
|
+
@autorequires ||= {}
|
1541
|
+
@autorequires.each { |type, block|
|
1542
|
+
yield(type, block)
|
1543
|
+
}
|
1544
|
+
end
|
1545
|
+
|
1546
|
+
# Figure out of there are any objects we can automatically add as
|
1547
|
+
# dependencies.
|
1548
|
+
def autorequire(rel_catalog = nil)
|
1549
|
+
rel_catalog ||= catalog
|
1550
|
+
raise(Puppet::DevError, "You cannot add relationships without a catalog") unless rel_catalog
|
1551
|
+
|
1552
|
+
reqs = []
|
1553
|
+
self.class.eachautorequire { |type, block|
|
1554
|
+
# Ignore any types we can't find, although that would be a bit odd.
|
1555
|
+
next unless typeobj = Puppet::Type.type(type)
|
1556
|
+
|
1557
|
+
# Retrieve the list of names from the block.
|
1558
|
+
next unless list = self.instance_eval(&block)
|
1559
|
+
list = [list] unless list.is_a?(Array)
|
1560
|
+
|
1561
|
+
# Collect the current prereqs
|
1562
|
+
list.each { |dep|
|
1563
|
+
obj = nil
|
1564
|
+
# Support them passing objects directly, to save some effort.
|
1565
|
+
unless dep.is_a? Puppet::Type
|
1566
|
+
# Skip autorequires that we aren't managing
|
1567
|
+
unless dep = rel_catalog.resource(type, dep)
|
1568
|
+
next
|
1569
|
+
end
|
1520
1570
|
end
|
1521
|
-
return provider_hash[name]
|
1522
|
-
end
|
1523
1571
|
|
1524
|
-
|
1525
|
-
|
1526
|
-
|
1527
|
-
end
|
1572
|
+
reqs << Puppet::Relationship.new(dep, self)
|
1573
|
+
}
|
1574
|
+
}
|
1528
1575
|
|
1529
|
-
|
1530
|
-
|
1576
|
+
reqs
|
1577
|
+
end
|
1531
1578
|
|
1532
|
-
|
1533
|
-
|
1579
|
+
# Build the dependencies associated with an individual object.
|
1580
|
+
def builddepends
|
1581
|
+
# Handle the requires
|
1582
|
+
self.class.relationship_params.collect do |klass|
|
1583
|
+
if param = @parameters[klass.name]
|
1584
|
+
param.to_edges
|
1585
|
+
end
|
1586
|
+
end.flatten.reject { |r| r.nil? }
|
1587
|
+
end
|
1534
1588
|
|
1535
|
-
|
1536
|
-
|
1537
|
-
|
1538
|
-
|
1589
|
+
# Define the initial list of tags.
|
1590
|
+
def tags=(list)
|
1591
|
+
tag(self.class.name)
|
1592
|
+
tag(*list)
|
1593
|
+
end
|
1539
1594
|
|
1540
|
-
|
1541
|
-
|
1542
|
-
|
1543
|
-
|
1595
|
+
# Types (which map to resources in the languages) are entirely composed of
|
1596
|
+
# attribute value pairs. Generally, Puppet calls any of these things an
|
1597
|
+
# 'attribute', but these attributes always take one of three specific
|
1598
|
+
# forms: parameters, metaparams, or properties.
|
1544
1599
|
|
1545
|
-
|
1546
|
-
|
1547
|
-
|
1548
|
-
|
1549
|
-
|
1550
|
-
if provider = self.provider(pname)
|
1551
|
-
provider
|
1552
|
-
else
|
1553
|
-
raise Puppet::DevError,
|
1554
|
-
"Could not find parent provider %s of %s" %
|
1555
|
-
[pname, name]
|
1556
|
-
end
|
1557
|
-
end
|
1558
|
-
else
|
1559
|
-
Puppet::Provider
|
1560
|
-
end
|
1600
|
+
# In naming methods, I have tried to consistently name the method so
|
1601
|
+
# that it is clear whether it operates on all attributes (thus has 'attr' in
|
1602
|
+
# the method name, or whether it operates on a specific type of attributes.
|
1603
|
+
attr_writer :title
|
1604
|
+
attr_writer :noop
|
1561
1605
|
|
1562
|
-
|
1606
|
+
include Enumerable
|
1563
1607
|
|
1564
|
-
|
1608
|
+
# class methods dealing with Type management
|
1565
1609
|
|
1566
|
-
|
1567
|
-
:parent => parent,
|
1568
|
-
:hash => provider_hash,
|
1569
|
-
:prefix => "Provider",
|
1570
|
-
:block => block,
|
1571
|
-
:include => feature_module,
|
1572
|
-
:extend => feature_module,
|
1573
|
-
:attributes => options
|
1574
|
-
)
|
1610
|
+
public
|
1575
1611
|
|
1576
|
-
|
1577
|
-
|
1578
|
-
|
1579
|
-
|
1580
|
-
|
1581
|
-
|
1582
|
-
return if @paramhash.has_key? :provider
|
1583
|
-
|
1584
|
-
newparam(:provider) do
|
1585
|
-
desc "The specific backend for #{self.name.to_s} to use. You will
|
1586
|
-
seldom need to specify this -- Puppet will usually discover the
|
1587
|
-
appropriate provider for your platform."
|
1588
|
-
|
1589
|
-
# This is so we can refer back to the type to get a list of
|
1590
|
-
# providers for documentation.
|
1591
|
-
class << self
|
1592
|
-
attr_accessor :parenttype
|
1593
|
-
end
|
1594
|
-
|
1595
|
-
# We need to add documentation for each provider.
|
1596
|
-
def self.doc
|
1597
|
-
@doc + " Available providers are:\n\n" + parenttype().providers.sort { |a,b|
|
1598
|
-
a.to_s <=> b.to_s
|
1599
|
-
}.collect { |i|
|
1600
|
-
"* **%s**: %s" % [i, parenttype().provider(i).doc]
|
1601
|
-
}.join("\n")
|
1602
|
-
end
|
1603
|
-
|
1604
|
-
defaultto {
|
1605
|
-
@resource.class.defaultprovider.name
|
1606
|
-
}
|
1607
|
-
|
1608
|
-
validate do |provider_class|
|
1609
|
-
provider_class = provider_class[0] if provider_class.is_a? Array
|
1610
|
-
if provider_class.is_a?(Puppet::Provider)
|
1611
|
-
provider_class = provider_class.class.name
|
1612
|
-
end
|
1613
|
-
|
1614
|
-
unless provider = @resource.class.provider(provider_class)
|
1615
|
-
raise ArgumentError, "Invalid %s provider '%s'" % [@resource.class.name, provider_class]
|
1616
|
-
end
|
1617
|
-
end
|
1618
|
-
|
1619
|
-
munge do |provider|
|
1620
|
-
provider = provider[0] if provider.is_a? Array
|
1621
|
-
if provider.is_a? String
|
1622
|
-
provider = provider.intern
|
1623
|
-
end
|
1624
|
-
@resource.provider = provider
|
1625
|
-
|
1626
|
-
if provider.is_a?(Puppet::Provider)
|
1627
|
-
provider.class.name
|
1628
|
-
else
|
1629
|
-
provider
|
1630
|
-
end
|
1631
|
-
end
|
1632
|
-
end.parenttype = self
|
1633
|
-
end
|
1634
|
-
|
1635
|
-
def self.unprovide(name)
|
1636
|
-
if provider_hash.has_key? name
|
1637
|
-
rmclass(name,
|
1638
|
-
:hash => provider_hash,
|
1639
|
-
:prefix => "Provider"
|
1640
|
-
)
|
1641
|
-
if @defaultprovider and @defaultprovider.name == name
|
1642
|
-
@defaultprovider = nil
|
1643
|
-
end
|
1644
|
-
end
|
1645
|
-
end
|
1612
|
+
# the Type class attribute accessors
|
1613
|
+
class << self
|
1614
|
+
attr_reader :name
|
1615
|
+
attr_accessor :self_refresh
|
1616
|
+
include Enumerable, Puppet::Util::ClassGen
|
1617
|
+
include Puppet::MetaType::Manager
|
1646
1618
|
|
1647
|
-
|
1648
|
-
|
1649
|
-
|
1650
|
-
providerloader.loadall
|
1651
|
-
end
|
1652
|
-
provider_hash.find_all { |name, provider|
|
1653
|
-
provider.suitable?
|
1654
|
-
}.collect { |name, provider|
|
1655
|
-
provider
|
1656
|
-
}.reject { |p| p.name == :fake } # For testing
|
1657
|
-
end
|
1658
|
-
|
1659
|
-
def provider=(name)
|
1660
|
-
if name.is_a?(Puppet::Provider)
|
1661
|
-
@provider = name
|
1662
|
-
@provider.resource = self
|
1663
|
-
elsif klass = self.class.provider(name)
|
1664
|
-
@provider = klass.new(self)
|
1665
|
-
else
|
1666
|
-
raise ArgumentError, "Could not find %s provider of %s" %
|
1667
|
-
[name, self.class.name]
|
1668
|
-
end
|
1669
|
-
end
|
1619
|
+
include Puppet::Util
|
1620
|
+
include Puppet::Util::Logging
|
1621
|
+
end
|
1670
1622
|
|
1671
|
-
|
1672
|
-
|
1623
|
+
# all of the variables that must be initialized for each subclass
|
1624
|
+
def self.initvars
|
1625
|
+
# all of the instances of this class
|
1626
|
+
@objects = Hash.new
|
1627
|
+
@aliases = Hash.new
|
1673
1628
|
|
1674
|
-
|
1675
|
-
# makes it so that you don't have to manually specify things that you clearly
|
1676
|
-
# require.
|
1677
|
-
def self.autorequire(name, &block)
|
1678
|
-
@autorequires ||= {}
|
1679
|
-
@autorequires[name] = block
|
1680
|
-
end
|
1629
|
+
@defaults = {}
|
1681
1630
|
|
1682
|
-
|
1683
|
-
def self.eachautorequire
|
1684
|
-
@autorequires ||= {}
|
1685
|
-
@autorequires.each { |type, block|
|
1686
|
-
yield(type, block)
|
1687
|
-
}
|
1688
|
-
end
|
1631
|
+
@parameters ||= []
|
1689
1632
|
|
1690
|
-
|
1691
|
-
|
1692
|
-
|
1693
|
-
|
1694
|
-
raise(Puppet::DevError, "You cannot add relationships without a catalog") unless rel_catalog
|
1695
|
-
|
1696
|
-
reqs = []
|
1697
|
-
self.class.eachautorequire { |type, block|
|
1698
|
-
# Ignore any types we can't find, although that would be a bit odd.
|
1699
|
-
next unless typeobj = Puppet::Type.type(type)
|
1700
|
-
|
1701
|
-
# Retrieve the list of names from the block.
|
1702
|
-
next unless list = self.instance_eval(&block)
|
1703
|
-
unless list.is_a?(Array)
|
1704
|
-
list = [list]
|
1705
|
-
end
|
1706
|
-
|
1707
|
-
# Collect the current prereqs
|
1708
|
-
list.each { |dep|
|
1709
|
-
obj = nil
|
1710
|
-
# Support them passing objects directly, to save some effort.
|
1711
|
-
unless dep.is_a? Puppet::Type
|
1712
|
-
# Skip autorequires that we aren't managing
|
1713
|
-
unless dep = rel_catalog.resource(type, dep)
|
1714
|
-
next
|
1715
|
-
end
|
1716
|
-
end
|
1717
|
-
|
1718
|
-
reqs << Puppet::Relationship.new(dep, self)
|
1719
|
-
}
|
1720
|
-
}
|
1633
|
+
@validproperties = {}
|
1634
|
+
@properties = []
|
1635
|
+
@parameters = []
|
1636
|
+
@paramhash = {}
|
1721
1637
|
|
1722
|
-
|
1723
|
-
end
|
1724
|
-
|
1725
|
-
# Build the dependencies associated with an individual object.
|
1726
|
-
def builddepends
|
1727
|
-
# Handle the requires
|
1728
|
-
self.class.relationship_params.collect do |klass|
|
1729
|
-
if param = @parameters[klass.name]
|
1730
|
-
param.to_edges
|
1731
|
-
end
|
1732
|
-
end.flatten.reject { |r| r.nil? }
|
1733
|
-
end
|
1734
|
-
|
1735
|
-
###############################
|
1736
|
-
# All of the scheduling code.
|
1737
|
-
|
1738
|
-
# Look up the schedule and set it appropriately. This is done after
|
1739
|
-
# the instantiation phase, so that the schedule can be anywhere in the
|
1740
|
-
# file.
|
1741
|
-
def schedule
|
1742
|
-
unless catalog
|
1743
|
-
warning "Cannot schedule without a schedule-containing catalog"
|
1744
|
-
return nil
|
1745
|
-
end
|
1746
|
-
|
1747
|
-
unless defined? @schedule
|
1748
|
-
if name = self[:schedule]
|
1749
|
-
if sched = catalog.resource(:schedule, name)
|
1750
|
-
@schedule = sched
|
1751
|
-
else
|
1752
|
-
self.fail "Could not find schedule %s" % name
|
1753
|
-
end
|
1754
|
-
else
|
1755
|
-
@schedule = nil
|
1756
|
-
end
|
1757
|
-
end
|
1758
|
-
@schedule
|
1759
|
-
end
|
1638
|
+
@attr_aliases = {}
|
1760
1639
|
|
1761
|
-
|
1762
|
-
|
1763
|
-
|
1764
|
-
|
1640
|
+
@paramdoc = Hash.new { |hash,key|
|
1641
|
+
key = key.intern if key.is_a?(String)
|
1642
|
+
if hash.include?(key)
|
1643
|
+
hash[key]
|
1644
|
+
else
|
1645
|
+
"Param Documentation for #{key} not found"
|
1646
|
+
end
|
1647
|
+
}
|
1765
1648
|
|
1766
|
-
|
1767
|
-
# end up checking most resources most times, because they will generally
|
1768
|
-
# have been synced a long time ago (e.g., a file only gets updated
|
1769
|
-
# once a month on the server and its schedule is daily; the last sync time
|
1770
|
-
# will have been a month ago, so we'd end up checking every run).
|
1771
|
-
return schedule.match?(self.cached(:checked).to_i)
|
1772
|
-
end
|
1649
|
+
@doc ||= ""
|
1773
1650
|
|
1774
|
-
|
1775
|
-
|
1776
|
-
|
1777
|
-
|
1651
|
+
end
|
1652
|
+
|
1653
|
+
def self.to_s
|
1654
|
+
if defined?(@name)
|
1655
|
+
"Puppet::Type::#{@name.to_s.capitalize}"
|
1656
|
+
else
|
1657
|
+
super
|
1778
1658
|
end
|
1659
|
+
end
|
1779
1660
|
|
1780
|
-
|
1781
|
-
|
1782
|
-
|
1783
|
-
|
1661
|
+
# Create a block to validate that our object is set up entirely. This will
|
1662
|
+
# be run before the object is operated on.
|
1663
|
+
def self.validate(&block)
|
1664
|
+
define_method(:validate, &block)
|
1665
|
+
#@validate = block
|
1666
|
+
end
|
1784
1667
|
|
1785
|
-
|
1786
|
-
|
1787
|
-
# the method name, or whether it operates on a specific type of attributes.
|
1788
|
-
attr_writer :title
|
1789
|
-
attr_writer :noop
|
1668
|
+
# The catalog that this resource is stored in.
|
1669
|
+
attr_accessor :catalog
|
1790
1670
|
|
1791
|
-
|
1671
|
+
# is the resource exported
|
1672
|
+
attr_accessor :exported
|
1792
1673
|
|
1793
|
-
|
1674
|
+
# is the resource virtual (it should not :-))
|
1675
|
+
attr_accessor :virtual
|
1794
1676
|
|
1795
|
-
|
1677
|
+
# create a log at specified level
|
1678
|
+
def log(msg)
|
1796
1679
|
|
1797
|
-
|
1798
|
-
class << self
|
1799
|
-
attr_reader :name
|
1800
|
-
attr_accessor :self_refresh
|
1801
|
-
include Enumerable, Puppet::Util::ClassGen
|
1802
|
-
include Puppet::MetaType::Manager
|
1680
|
+
Puppet::Util::Log.create(
|
1803
1681
|
|
1804
|
-
|
1805
|
-
|
1806
|
-
end
|
1682
|
+
:level => @parameters[:loglevel].value,
|
1683
|
+
:message => msg,
|
1807
1684
|
|
1808
|
-
|
1809
|
-
|
1810
|
-
|
1811
|
-
@objects = Hash.new
|
1812
|
-
@aliases = Hash.new
|
1685
|
+
:source => self
|
1686
|
+
)
|
1687
|
+
end
|
1813
1688
|
|
1814
|
-
@defaults = {}
|
1815
1689
|
|
1816
|
-
|
1817
|
-
|
1818
|
-
end
|
1690
|
+
# instance methods related to instance intrinsics
|
1691
|
+
# e.g., initialize and name
|
1819
1692
|
|
1820
|
-
|
1821
|
-
@properties = []
|
1822
|
-
@parameters = []
|
1823
|
-
@paramhash = {}
|
1693
|
+
public
|
1824
1694
|
|
1825
|
-
|
1695
|
+
attr_reader :original_parameters
|
1826
1696
|
|
1827
|
-
|
1828
|
-
|
1829
|
-
|
1830
|
-
|
1831
|
-
if hash.include?(key)
|
1832
|
-
hash[key]
|
1833
|
-
else
|
1834
|
-
"Param Documentation for %s not found" % key
|
1835
|
-
end
|
1836
|
-
}
|
1697
|
+
# initialize the type instance
|
1698
|
+
def initialize(resource)
|
1699
|
+
raise Puppet::DevError, "Got TransObject instead of Resource or hash" if resource.is_a?(Puppet::TransObject)
|
1700
|
+
resource = self.class.hash2resource(resource) unless resource.is_a?(Puppet::Resource)
|
1837
1701
|
|
1838
|
-
|
1839
|
-
|
1840
|
-
end
|
1841
|
-
|
1842
|
-
end
|
1702
|
+
# The list of parameter/property instances.
|
1703
|
+
@parameters = {}
|
1843
1704
|
|
1844
|
-
|
1845
|
-
|
1846
|
-
|
1847
|
-
|
1848
|
-
|
1849
|
-
|
1705
|
+
# Set the title first, so any failures print correctly.
|
1706
|
+
if resource.type.to_s.downcase.to_sym == self.class.name
|
1707
|
+
self.title = resource.title
|
1708
|
+
else
|
1709
|
+
# This should only ever happen for components
|
1710
|
+
self.title = resource.ref
|
1850
1711
|
end
|
1851
1712
|
|
1852
|
-
|
1853
|
-
|
1854
|
-
|
1855
|
-
|
1856
|
-
|
1713
|
+
[:file, :line, :catalog, :exported, :virtual].each do |getter|
|
1714
|
+
setter = getter.to_s + "="
|
1715
|
+
if val = resource.send(getter)
|
1716
|
+
self.send(setter, val)
|
1717
|
+
end
|
1857
1718
|
end
|
1858
1719
|
|
1859
|
-
|
1860
|
-
attr_accessor :catalog
|
1861
|
-
|
1862
|
-
# is the resource exported
|
1863
|
-
attr_accessor :exported
|
1720
|
+
@tags = resource.tags
|
1864
1721
|
|
1865
|
-
|
1866
|
-
attr_accessor :virtual
|
1867
|
-
|
1868
|
-
# create a log at specified level
|
1869
|
-
def log(msg)
|
1870
|
-
Puppet::Util::Log.create(
|
1871
|
-
:level => @parameters[:loglevel].value,
|
1872
|
-
:message => msg,
|
1873
|
-
:source => self
|
1874
|
-
)
|
1875
|
-
end
|
1722
|
+
@original_parameters = resource.to_hash
|
1876
1723
|
|
1724
|
+
set_name(@original_parameters)
|
1877
1725
|
|
1878
|
-
|
1879
|
-
# e.g., initialize() and name()
|
1726
|
+
set_default(:provider)
|
1880
1727
|
|
1881
|
-
|
1728
|
+
set_parameters(@original_parameters)
|
1882
1729
|
|
1883
|
-
|
1730
|
+
self.validate if self.respond_to?(:validate)
|
1731
|
+
end
|
1884
1732
|
|
1885
|
-
|
1886
|
-
def initialize(resource)
|
1887
|
-
raise Puppet::DevError, "Got TransObject instead of Resource or hash" if resource.is_a?(Puppet::TransObject)
|
1888
|
-
resource = self.class.hash2resource(resource) unless resource.is_a?(Puppet::Resource)
|
1733
|
+
private
|
1889
1734
|
|
1890
|
-
|
1891
|
-
|
1735
|
+
# Set our resource's name.
|
1736
|
+
def set_name(hash)
|
1737
|
+
self[name_var] = hash.delete(name_var) if name_var
|
1738
|
+
end
|
1892
1739
|
|
1893
|
-
|
1894
|
-
|
1895
|
-
|
1740
|
+
# Set all of the parameters from a hash, in the appropriate order.
|
1741
|
+
def set_parameters(hash)
|
1742
|
+
# Use the order provided by allattrs, but add in any
|
1743
|
+
# extra attributes from the resource so we get failures
|
1744
|
+
# on invalid attributes.
|
1745
|
+
no_values = []
|
1746
|
+
(self.class.allattrs + hash.keys).uniq.each do |attr|
|
1747
|
+
begin
|
1748
|
+
# Set any defaults immediately. This is mostly done so
|
1749
|
+
# that the default provider is available for any other
|
1750
|
+
# property validation.
|
1751
|
+
if hash.has_key?(attr)
|
1752
|
+
self[attr] = hash[attr]
|
1896
1753
|
else
|
1897
|
-
|
1898
|
-
|
1899
|
-
|
1900
|
-
|
1901
|
-
|
1902
|
-
|
1903
|
-
|
1904
|
-
|
1905
|
-
|
1906
|
-
|
1907
|
-
|
1908
|
-
|
1909
|
-
|
1910
|
-
|
1911
|
-
|
1912
|
-
|
1913
|
-
|
1914
|
-
|
1915
|
-
|
1916
|
-
|
1917
|
-
|
1918
|
-
|
1919
|
-
|
1920
|
-
|
1921
|
-
|
1922
|
-
|
1923
|
-
|
1924
|
-
|
1925
|
-
|
1926
|
-
|
1927
|
-
|
1754
|
+
no_values << attr
|
1755
|
+
end
|
1756
|
+
rescue ArgumentError, Puppet::Error, TypeError
|
1757
|
+
raise
|
1758
|
+
rescue => detail
|
1759
|
+
error = Puppet::DevError.new( "Could not set #{attr} on #{self.class.name}: #{detail}")
|
1760
|
+
error.set_backtrace(detail.backtrace)
|
1761
|
+
raise error
|
1762
|
+
end
|
1763
|
+
end
|
1764
|
+
no_values.each do |attr|
|
1765
|
+
set_default(attr)
|
1766
|
+
end
|
1767
|
+
end
|
1768
|
+
|
1769
|
+
public
|
1770
|
+
|
1771
|
+
# Set up all of our autorequires.
|
1772
|
+
def finish
|
1773
|
+
# Make sure all of our relationships are valid. Again, must be done
|
1774
|
+
# when the entire catalog is instantiated.
|
1775
|
+
self.class.relationship_params.collect do |klass|
|
1776
|
+
if param = @parameters[klass.name]
|
1777
|
+
param.validate_relationship
|
1778
|
+
end
|
1779
|
+
end.flatten.reject { |r| r.nil? }
|
1780
|
+
end
|
1781
|
+
|
1782
|
+
# For now, leave the 'name' method functioning like it used to. Once 'title'
|
1783
|
+
# works everywhere, I'll switch it.
|
1784
|
+
def name
|
1785
|
+
self[:name]
|
1786
|
+
end
|
1787
|
+
|
1788
|
+
# Look up our parent in the catalog, if we have one.
|
1789
|
+
def parent
|
1790
|
+
return nil unless catalog
|
1791
|
+
|
1792
|
+
unless defined?(@parent)
|
1793
|
+
if parents = catalog.adjacent(self, :direction => :in)
|
1794
|
+
# We should never have more than one parent, so let's just ignore
|
1795
|
+
# it if we happen to.
|
1796
|
+
@parent = parents.shift
|
1797
|
+
else
|
1798
|
+
@parent = nil
|
1799
|
+
end
|
1928
1800
|
end
|
1801
|
+
@parent
|
1802
|
+
end
|
1929
1803
|
|
1930
|
-
|
1931
|
-
|
1932
|
-
|
1933
|
-
|
1934
|
-
# on invalid attributes.
|
1935
|
-
no_values = []
|
1936
|
-
(self.class.allattrs + hash.keys).uniq.each do |attr|
|
1937
|
-
begin
|
1938
|
-
# Set any defaults immediately. This is mostly done so
|
1939
|
-
# that the default provider is available for any other
|
1940
|
-
# property validation.
|
1941
|
-
if hash.has_key?(attr)
|
1942
|
-
self[attr] = hash[attr]
|
1943
|
-
else
|
1944
|
-
no_values << attr
|
1945
|
-
end
|
1946
|
-
rescue ArgumentError, Puppet::Error, TypeError
|
1947
|
-
raise
|
1948
|
-
rescue => detail
|
1949
|
-
error = Puppet::DevError.new( "Could not set %s on %s: %s" % [attr, self.class.name, detail])
|
1950
|
-
error.set_backtrace(detail.backtrace)
|
1951
|
-
raise error
|
1952
|
-
end
|
1953
|
-
end
|
1954
|
-
no_values.each do |attr|
|
1955
|
-
set_default(attr)
|
1956
|
-
end
|
1957
|
-
end
|
1804
|
+
# Return the "type[name]" style reference.
|
1805
|
+
def ref
|
1806
|
+
"#{self.class.name.to_s.capitalize}[#{self.title}]"
|
1807
|
+
end
|
1958
1808
|
|
1959
|
-
|
1809
|
+
def self_refresh?
|
1810
|
+
self.class.self_refresh
|
1811
|
+
end
|
1960
1812
|
|
1961
|
-
|
1962
|
-
|
1963
|
-
|
1964
|
-
|
1965
|
-
self.schedule
|
1813
|
+
# Mark that we're purging.
|
1814
|
+
def purging
|
1815
|
+
@purging = true
|
1816
|
+
end
|
1966
1817
|
|
1967
|
-
|
1968
|
-
|
1969
|
-
|
1970
|
-
|
1971
|
-
|
1972
|
-
|
1973
|
-
|
1818
|
+
# Is this resource being purged? Used by transactions to forbid
|
1819
|
+
# deletion when there are dependencies.
|
1820
|
+
def purging?
|
1821
|
+
if defined?(@purging)
|
1822
|
+
@purging
|
1823
|
+
else
|
1824
|
+
false
|
1974
1825
|
end
|
1826
|
+
end
|
1975
1827
|
|
1976
|
-
|
1977
|
-
|
1978
|
-
|
1979
|
-
|
1828
|
+
# Retrieve the title of an object. If no title was set separately,
|
1829
|
+
# then use the object's name.
|
1830
|
+
def title
|
1831
|
+
unless @title
|
1832
|
+
if self.class.validparameter?(name_var)
|
1833
|
+
@title = self[:name]
|
1834
|
+
elsif self.class.validproperty?(name_var)
|
1835
|
+
@title = self.should(name_var)
|
1836
|
+
else
|
1837
|
+
self.devfail "Could not find namevar #{name_var} for #{self.class.name}"
|
1838
|
+
end
|
1980
1839
|
end
|
1981
1840
|
|
1982
|
-
|
1983
|
-
|
1984
|
-
Puppet::Util::Storage.cache(self)[name] = value
|
1985
|
-
#@cache[name] = value
|
1986
|
-
end
|
1841
|
+
@title
|
1842
|
+
end
|
1987
1843
|
|
1988
|
-
|
1989
|
-
|
1990
|
-
|
1991
|
-
|
1992
|
-
end
|
1844
|
+
# convert to a string
|
1845
|
+
def to_s
|
1846
|
+
self.ref
|
1847
|
+
end
|
1993
1848
|
|
1994
|
-
|
1995
|
-
|
1996
|
-
|
1849
|
+
# Convert to a transportable object
|
1850
|
+
def to_trans(ret = true)
|
1851
|
+
trans = TransObject.new(self.title, self.class.name)
|
1997
1852
|
|
1998
|
-
|
1999
|
-
|
2000
|
-
|
2001
|
-
|
2002
|
-
@parent = parents.shift
|
2003
|
-
else
|
2004
|
-
@parent = nil
|
2005
|
-
end
|
2006
|
-
end
|
2007
|
-
@parent
|
1853
|
+
values = retrieve_resource
|
1854
|
+
values.each do |name, value|
|
1855
|
+
name = name.name if name.respond_to? :name
|
1856
|
+
trans[name] = value
|
2008
1857
|
end
|
2009
1858
|
|
2010
|
-
|
2011
|
-
|
2012
|
-
|
2013
|
-
end
|
1859
|
+
@parameters.each do |name, param|
|
1860
|
+
# Avoid adding each instance name twice
|
1861
|
+
next if param.class.isnamevar? and param.value == self.title
|
2014
1862
|
|
2015
|
-
|
2016
|
-
|
1863
|
+
# We've already got property values
|
1864
|
+
next if param.is_a?(Puppet::Property)
|
1865
|
+
trans[name] = param.value
|
2017
1866
|
end
|
2018
1867
|
|
2019
|
-
|
2020
|
-
def purging
|
2021
|
-
@purging = true
|
2022
|
-
end
|
1868
|
+
trans.tags = self.tags
|
2023
1869
|
|
2024
|
-
#
|
2025
|
-
# deletion when there are dependencies.
|
2026
|
-
def purging?
|
2027
|
-
if defined? @purging
|
2028
|
-
@purging
|
2029
|
-
else
|
2030
|
-
false
|
2031
|
-
end
|
2032
|
-
end
|
1870
|
+
# FIXME I'm currently ignoring 'parent' and 'path'
|
2033
1871
|
|
2034
|
-
|
2035
|
-
|
2036
|
-
def title
|
2037
|
-
unless defined? @title and @title
|
2038
|
-
namevar = self.class.namevar
|
2039
|
-
if self.class.validparameter?(namevar)
|
2040
|
-
@title = self[:name]
|
2041
|
-
elsif self.class.validproperty?(namevar)
|
2042
|
-
@title = self.should(namevar)
|
2043
|
-
else
|
2044
|
-
self.devfail "Could not find namevar %s for %s" %
|
2045
|
-
[namevar, self.class.name]
|
2046
|
-
end
|
2047
|
-
end
|
2048
|
-
|
2049
|
-
return @title
|
2050
|
-
end
|
2051
|
-
|
2052
|
-
# convert to a string
|
2053
|
-
def to_s
|
2054
|
-
self.ref
|
2055
|
-
end
|
2056
|
-
|
2057
|
-
# Convert to a transportable object
|
2058
|
-
def to_trans(ret = true)
|
2059
|
-
trans = TransObject.new(self.title, self.class.name)
|
2060
|
-
|
2061
|
-
values = retrieve()
|
2062
|
-
values.each do |name, value|
|
2063
|
-
trans[name.name] = value
|
2064
|
-
end
|
1872
|
+
trans
|
1873
|
+
end
|
2065
1874
|
|
2066
|
-
|
2067
|
-
|
2068
|
-
|
1875
|
+
def to_resource
|
1876
|
+
# this 'type instance' versus 'resource' distinction seems artificial
|
1877
|
+
# I'd like to see it collapsed someday ~JW
|
1878
|
+
self.to_trans.to_resource
|
1879
|
+
end
|
2069
1880
|
|
2070
|
-
|
2071
|
-
|
2072
|
-
|
2073
|
-
end
|
2074
|
-
|
2075
|
-
trans.tags = self.tags
|
2076
|
-
|
2077
|
-
# FIXME I'm currently ignoring 'parent' and 'path'
|
2078
|
-
|
2079
|
-
return trans
|
2080
|
-
end
|
2081
|
-
|
2082
|
-
%w{exported virtual}.each do |m|
|
2083
|
-
define_method(m+"?") do
|
2084
|
-
self.send(m)
|
2085
|
-
end
|
2086
|
-
end
|
2087
|
-
|
2088
|
-
end # Puppet::Type
|
1881
|
+
def virtual?; !!@virtual; end
|
1882
|
+
def exported?; !!@exported; end
|
1883
|
+
end
|
2089
1884
|
end
|
2090
1885
|
|
2091
1886
|
require 'puppet/provider'
|