puppet 0.23.2 → 0.24.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 +112 -1
- data/README +1 -1
- data/Rakefile +1 -2
- data/bin/filebucket +2 -3
- data/bin/puppet +55 -39
- data/bin/puppetca +20 -11
- data/bin/puppetd +30 -31
- data/bin/puppetdoc +27 -28
- data/bin/puppetmasterd +24 -42
- data/bin/puppetrun +3 -4
- data/bin/ralsh +5 -7
- data/conf/redhat/puppet.spec +4 -1
- data/conf/solaris/smf/svc-puppetd +1 -1
- data/conf/solaris/smf/svc-puppetmasterd +1 -1
- data/examples/code/allatonce +1 -1
- data/examples/code/assignments +1 -1
- data/examples/code/components +1 -1
- data/examples/code/file.bl +1 -1
- data/examples/code/filedefaults +1 -1
- data/examples/code/fileparsing +1 -1
- data/examples/code/filerecursion +1 -1
- data/examples/code/functions +1 -1
- data/examples/code/groups +1 -1
- data/examples/code/head +1 -1
- data/examples/code/importing +1 -1
- data/examples/code/modules/sample-module.pp +10 -0
- data/examples/code/modules/sample-module/README.txt +17 -0
- data/examples/code/modules/sample-module/lib/puppet/parser/functions/hostname_to_dn.rb +36 -0
- data/examples/code/modules/sample-module/manifests/init.pp +12 -0
- data/examples/code/modules/sample-module/templates/sample.erb +5 -0
- data/examples/code/nodes +1 -1
- data/examples/code/one +1 -1
- data/examples/code/relationships +1 -1
- data/examples/code/selectors +1 -1
- data/examples/code/simpletests +1 -1
- data/examples/root/etc/init.d/sleeper +1 -1
- data/examples/root/etc/puppet/fileserver.conf +1 -1
- data/ext/ldap/puppet.schema +1 -1
- data/ext/module_puppet +30 -21
- data/ext/puppet-test +3 -3
- data/ext/vim/filetype.vim +1 -1
- data/install.rb +1 -2
- data/lib/puppet.rb +20 -19
- data/lib/puppet/checksum.rb +57 -0
- data/lib/puppet/config_stores/rest.rb +1 -1
- data/lib/puppet/daemon.rb +0 -1
- data/lib/puppet/{configuration.rb → defaults.rb} +56 -23
- data/lib/puppet/dsl.rb +22 -116
- data/lib/puppet/error.rb +0 -9
- data/lib/puppet/event.rb +0 -1
- data/lib/puppet/external/gratr/rdot.rb +0 -1
- data/lib/puppet/external/lock.rb +0 -1
- data/lib/puppet/feature/base.rb +3 -2
- data/lib/puppet/feature/rails.rb +0 -1
- data/lib/puppet/file_serving.rb +7 -0
- data/lib/puppet/file_serving/configuration.rb +129 -0
- data/lib/puppet/file_serving/configuration/parser.rb +124 -0
- data/lib/puppet/file_serving/content.rb +34 -0
- data/lib/puppet/file_serving/file_base.rb +63 -0
- data/lib/puppet/file_serving/fileset.rb +138 -0
- data/lib/puppet/file_serving/indirection_hooks.rb +44 -0
- data/lib/puppet/file_serving/metadata.rb +69 -0
- data/lib/puppet/file_serving/mount.rb +186 -0
- data/lib/puppet/file_serving/terminus_helper.rb +19 -0
- data/lib/puppet/indirector.rb +68 -0
- data/lib/puppet/indirector/catalog/compiler.rb +173 -0
- data/lib/puppet/indirector/catalog/yaml.rb +24 -0
- data/lib/puppet/indirector/checksum/file.rb +33 -0
- data/lib/puppet/indirector/code.rb +6 -0
- data/lib/puppet/indirector/direct_file_server.rb +27 -0
- data/lib/puppet/indirector/exec.rb +57 -0
- data/lib/puppet/indirector/facts/facter.rb +65 -0
- data/lib/puppet/indirector/facts/memory.rb +9 -0
- data/lib/puppet/indirector/facts/yaml.rb +7 -0
- data/lib/puppet/indirector/file.rb +54 -0
- data/lib/puppet/indirector/file_content.rb +5 -0
- data/lib/puppet/indirector/file_content/file.rb +11 -0
- data/lib/puppet/indirector/file_content/file_server.rb +11 -0
- data/lib/puppet/indirector/file_content/modules.rb +11 -0
- data/lib/puppet/indirector/file_content/rest.rb +12 -0
- data/lib/puppet/indirector/file_metadata.rb +5 -0
- data/lib/puppet/indirector/file_metadata/file.rb +26 -0
- data/lib/puppet/indirector/file_metadata/file_server.rb +11 -0
- data/lib/puppet/indirector/file_metadata/modules.rb +17 -0
- data/lib/puppet/indirector/file_metadata/rest.rb +12 -0
- data/lib/puppet/indirector/file_server.rb +56 -0
- data/lib/puppet/indirector/indirection.rb +237 -0
- data/lib/puppet/indirector/ldap.rb +90 -0
- data/lib/puppet/indirector/memory.rb +21 -0
- data/lib/puppet/indirector/module_files.rb +82 -0
- data/lib/puppet/indirector/node/exec.rb +52 -0
- data/lib/puppet/indirector/node/ldap.rb +120 -0
- data/lib/puppet/indirector/node/memory.rb +10 -0
- data/lib/puppet/indirector/node/plain.rb +19 -0
- data/lib/puppet/indirector/node/rest.rb +7 -0
- data/lib/puppet/indirector/node/yaml.rb +7 -0
- data/lib/puppet/indirector/plain.rb +9 -0
- data/lib/puppet/indirector/report/processor.rb +50 -0
- data/lib/puppet/indirector/rest.rb +8 -0
- data/lib/puppet/indirector/ssl_rsa.rb +5 -0
- data/lib/puppet/indirector/ssl_rsa/file.rb +33 -0
- data/lib/puppet/indirector/terminus.rb +178 -0
- data/lib/puppet/indirector/yaml.rb +57 -0
- data/lib/puppet/metatype/attributes.rb +3 -3
- data/lib/puppet/metatype/closure.rb +0 -66
- data/lib/puppet/metatype/container.rb +0 -9
- data/lib/puppet/metatype/evaluation.rb +10 -2
- data/lib/puppet/metatype/instances.rb +16 -30
- data/lib/puppet/metatype/manager.rb +1 -2
- data/lib/puppet/metatype/metaparams.rb +27 -21
- data/lib/puppet/metatype/providers.rb +3 -2
- data/lib/puppet/metatype/relationships.rb +1 -2
- data/lib/puppet/metatype/schedules.rb +0 -1
- data/lib/puppet/metatype/tags.rb +0 -1
- data/lib/puppet/module.rb +60 -32
- data/lib/puppet/network/authconfig.rb +0 -1
- data/lib/puppet/network/authorization.rb +0 -1
- data/lib/puppet/network/authstore.rb +0 -1
- data/lib/puppet/network/client.rb +13 -4
- data/lib/puppet/network/client/ca.rb +4 -5
- data/lib/puppet/network/client/dipper.rb +0 -1
- data/lib/puppet/network/client/file.rb +0 -1
- data/lib/puppet/network/client/master.rb +127 -235
- data/lib/puppet/network/client/proxy.rb +0 -1
- data/lib/puppet/network/client/report.rb +0 -1
- data/lib/puppet/network/client/resource.rb +0 -1
- data/lib/puppet/network/client/runner.rb +0 -1
- data/lib/puppet/network/client/status.rb +0 -1
- data/lib/puppet/network/client_request.rb +0 -1
- data/lib/puppet/network/handler.rb +5 -2
- data/lib/puppet/network/handler/ca.rb +1 -2
- data/lib/puppet/network/handler/configuration.rb +184 -0
- data/lib/puppet/network/handler/filebucket.rb +1 -2
- data/lib/puppet/network/handler/fileserver.rb +279 -107
- data/lib/puppet/network/handler/master.rb +57 -152
- data/lib/puppet/network/handler/report.rb +6 -65
- data/lib/puppet/network/handler/resource.rb +5 -13
- data/lib/puppet/network/handler/runner.rb +3 -4
- data/lib/puppet/network/handler/status.rb +0 -1
- data/lib/puppet/network/http.rb +13 -0
- data/lib/puppet/network/http/handler.rb +109 -0
- data/lib/puppet/network/http/mongrel.rb +54 -0
- data/lib/puppet/network/http/mongrel/rest.rb +37 -0
- data/lib/puppet/network/http/mongrel/xmlrpc.rb +4 -0
- data/lib/puppet/network/http/webrick.rb +51 -0
- data/lib/puppet/network/http/webrick/rest.rb +41 -0
- data/lib/puppet/network/http/webrick/xmlrpc.rb +4 -0
- data/lib/puppet/network/http_server.rb +3 -0
- data/lib/puppet/network/{server → http_server}/mongrel.rb +11 -5
- data/lib/puppet/network/{server → http_server}/webrick.rb +9 -5
- data/lib/puppet/network/rest_controller.rb +2 -0
- data/lib/puppet/network/rights.rb +0 -1
- data/lib/puppet/network/server.rb +63 -3
- data/lib/puppet/network/xmlrpc/client.rb +90 -23
- data/lib/puppet/network/xmlrpc/processor.rb +0 -1
- data/lib/puppet/network/xmlrpc/server.rb +0 -1
- data/lib/puppet/network/xmlrpc/webrick_servlet.rb +0 -1
- data/lib/puppet/node.rb +165 -0
- data/lib/puppet/node/catalog.rb +480 -0
- data/lib/puppet/node/environment.rb +46 -0
- data/lib/puppet/node/facts.rb +36 -0
- data/lib/puppet/parameter.rb +34 -28
- data/lib/puppet/parser/ast.rb +0 -1
- data/lib/puppet/parser/ast/astarray.rb +30 -53
- data/lib/puppet/parser/ast/branch.rb +0 -10
- data/lib/puppet/parser/ast/caseopt.rb +0 -11
- data/lib/puppet/parser/ast/casestatement.rb +0 -12
- data/lib/puppet/parser/ast/collection.rb +1 -3
- data/lib/puppet/parser/ast/collexpr.rb +0 -2
- data/lib/puppet/parser/ast/{component.rb → definition.rb} +58 -72
- data/lib/puppet/parser/ast/else.rb +0 -10
- data/lib/puppet/parser/ast/function.rb +0 -2
- data/lib/puppet/parser/ast/hostclass.rb +21 -19
- data/lib/puppet/parser/ast/ifstatement.rb +0 -13
- data/lib/puppet/parser/ast/leaf.rb +0 -8
- data/lib/puppet/parser/ast/node.rb +13 -10
- data/lib/puppet/parser/ast/resource.rb +75 -0
- data/lib/puppet/parser/ast/{resourcedefaults.rb → resource_defaults.rb} +4 -20
- data/lib/puppet/parser/ast/{resourceoverride.rb → resource_override.rb} +3 -5
- data/lib/puppet/parser/ast/resource_reference.rb +66 -0
- data/lib/puppet/parser/ast/resourceparam.rb +0 -14
- data/lib/puppet/parser/ast/selector.rb +0 -10
- data/lib/puppet/parser/ast/tag.rb +0 -2
- data/lib/puppet/parser/ast/vardef.rb +0 -14
- data/lib/puppet/parser/collector.rb +83 -101
- data/lib/puppet/parser/compile.rb +509 -0
- data/lib/puppet/parser/functions.rb +10 -10
- data/lib/puppet/parser/interpreter.rb +44 -662
- data/lib/puppet/parser/lexer.rb +1 -3
- data/lib/puppet/parser/parser.rb +674 -701
- data/lib/puppet/parser/parser_support.rb +33 -24
- data/lib/puppet/parser/resource.rb +219 -162
- data/lib/puppet/parser/resource/param.rb +1 -2
- data/lib/puppet/parser/resource/reference.rb +24 -16
- data/lib/puppet/parser/scope.rb +48 -459
- data/lib/puppet/parser/templatewrapper.rb +4 -5
- data/lib/puppet/pgraph.rb +10 -13
- data/lib/puppet/property.rb +25 -41
- data/lib/puppet/propertychange.rb +0 -2
- data/lib/puppet/provider.rb +15 -11
- data/lib/puppet/provider/cron/crontab.rb +6 -7
- data/lib/puppet/provider/group/groupadd.rb +0 -1
- data/lib/puppet/provider/group/netinfo.rb +0 -1
- data/lib/puppet/provider/group/pw.rb +0 -1
- data/lib/puppet/provider/host/netinfo.rb +0 -1
- data/lib/puppet/provider/host/parsed.rb +0 -1
- data/lib/puppet/provider/interface/redhat.rb +90 -91
- data/lib/puppet/provider/interface/sunos.rb +98 -81
- data/lib/puppet/provider/mailalias/aliases.rb +0 -1
- data/lib/puppet/provider/maillist/mailman.rb +2 -3
- data/lib/puppet/provider/mount.rb +10 -9
- data/lib/puppet/provider/mount/netinfo.rb +0 -1
- data/lib/puppet/provider/mount/parsed.rb +0 -1
- data/lib/puppet/provider/nameservice.rb +0 -1
- data/lib/puppet/provider/nameservice/netinfo.rb +0 -1
- data/lib/puppet/provider/nameservice/objectadd.rb +0 -1
- data/lib/puppet/provider/nameservice/pw.rb +0 -1
- data/lib/puppet/provider/package.rb +0 -2
- data/lib/puppet/provider/package/appdmg.rb +0 -1
- data/lib/puppet/provider/package/apple.rb +0 -1
- data/lib/puppet/provider/package/apt.rb +0 -1
- data/lib/puppet/provider/package/aptitude.rb +0 -1
- data/lib/puppet/provider/package/aptrpm.rb +0 -1
- data/lib/puppet/provider/package/blastwave.rb +0 -1
- data/lib/puppet/provider/package/darwinport.rb +0 -1
- data/lib/puppet/provider/package/dpkg.rb +9 -1
- data/lib/puppet/provider/package/fink.rb +0 -1
- data/lib/puppet/provider/package/freebsd.rb +0 -1
- data/lib/puppet/provider/package/gem.rb +0 -1
- data/lib/puppet/provider/package/openbsd.rb +1 -2
- data/lib/puppet/provider/package/pkgdmg.rb +14 -15
- data/lib/puppet/provider/package/portage.rb +6 -7
- data/lib/puppet/provider/package/ports.rb +1 -4
- data/lib/puppet/provider/package/rpm.rb +31 -45
- data/lib/puppet/provider/package/sun.rb +0 -3
- data/lib/puppet/provider/package/sunfreeware.rb +0 -1
- data/lib/puppet/provider/package/up2date.rb +0 -1
- data/lib/puppet/provider/package/urpmi.rb +0 -1
- data/lib/puppet/provider/package/yum.rb +45 -14
- data/lib/puppet/provider/package/yumhelper.py +37 -0
- data/lib/puppet/provider/parsedfile.rb +2 -3
- data/lib/puppet/provider/port/parsed.rb +0 -1
- data/lib/puppet/provider/service/base.rb +4 -1
- data/lib/puppet/provider/service/debian.rb +5 -2
- data/lib/puppet/provider/service/freebsd.rb +51 -0
- data/lib/puppet/provider/service/init.rb +16 -40
- data/lib/puppet/provider/service/redhat.rb +1 -6
- data/lib/puppet/provider/service/smf.rb +0 -1
- data/lib/puppet/provider/sshkey/parsed.rb +0 -1
- data/lib/puppet/provider/user/netinfo.rb +0 -1
- data/lib/puppet/provider/user/pw.rb +0 -1
- data/lib/puppet/provider/user/useradd.rb +0 -1
- data/lib/puppet/provider/zone/solaris.rb +0 -1
- data/lib/puppet/rails.rb +35 -30
- data/lib/puppet/rails/database/schema.rb +0 -1
- data/lib/puppet/rails/host.rb +6 -15
- data/lib/puppet/rails/param_name.rb +1 -2
- data/lib/puppet/rails/param_value.rb +0 -1
- data/lib/puppet/rails/puppet_class.rb +0 -1
- data/lib/puppet/rails/resource.rb +3 -5
- data/lib/puppet/reference/configuration.rb +12 -6
- data/lib/puppet/reference/indirection.rb +34 -0
- data/lib/puppet/reference/node_source.rb +9 -0
- data/lib/puppet/relationship.rb +10 -8
- data/lib/puppet/reports.rb +51 -0
- data/lib/puppet/reports/log.rb +2 -3
- data/lib/puppet/reports/rrdgraph.rb +2 -5
- data/lib/puppet/reports/store.rb +6 -7
- data/lib/puppet/reports/tagmail.rb +2 -3
- data/lib/puppet/resource_reference.rb +79 -0
- data/lib/puppet/simple_graph.rb +251 -0
- data/lib/puppet/sslcertificates.rb +19 -15
- data/lib/puppet/sslcertificates/ca.rb +56 -15
- data/lib/puppet/sslcertificates/certificate.rb +0 -1
- data/lib/puppet/sslcertificates/inventory.rb +2 -6
- data/lib/puppet/sslcertificates/monkey_patch.rb +6 -0
- data/lib/puppet/sslcertificates/support.rb +4 -5
- data/lib/puppet/transaction.rb +93 -96
- data/lib/puppet/transaction/report.rb +5 -1
- data/lib/puppet/transportable.rb +79 -125
- data/lib/puppet/type.rb +44 -10
- data/lib/puppet/type/component.rb +25 -110
- data/lib/puppet/type/cron.rb +1 -2
- data/lib/puppet/type/exec.rb +19 -13
- data/lib/puppet/type/group.rb +0 -1
- data/lib/puppet/type/host.rb +0 -1
- data/lib/puppet/type/interface.rb +6 -3
- data/lib/puppet/type/k5login.rb +87 -0
- data/lib/puppet/type/mailalias.rb +0 -1
- data/lib/puppet/type/maillist.rb +0 -1
- data/lib/puppet/type/mount.rb +7 -13
- data/lib/puppet/type/notify.rb +0 -1
- data/lib/puppet/type/package.rb +7 -63
- data/lib/puppet/type/pfile.rb +25 -32
- data/lib/puppet/type/pfile/checksum.rb +0 -1
- data/lib/puppet/type/pfile/content.rb +18 -3
- data/lib/puppet/type/pfile/ensure.rb +5 -6
- data/lib/puppet/type/pfile/group.rb +4 -1
- data/lib/puppet/type/pfile/mode.rb +0 -1
- data/lib/puppet/type/pfile/owner.rb +6 -9
- data/lib/puppet/type/pfile/source.rb +28 -11
- data/lib/puppet/type/pfile/target.rb +2 -1
- data/lib/puppet/type/pfile/type.rb +0 -1
- data/lib/puppet/type/pfilebucket.rb +0 -1
- data/lib/puppet/type/port.rb +0 -1
- data/lib/puppet/type/resources.rb +0 -1
- data/lib/puppet/type/schedule.rb +17 -15
- data/lib/puppet/type/service.rb +23 -159
- data/lib/puppet/type/sshkey.rb +0 -1
- data/lib/puppet/type/tidy.rb +15 -7
- data/lib/puppet/type/user.rb +0 -1
- data/lib/puppet/type/zone.rb +0 -1
- data/lib/puppet/util.rb +1 -2
- data/lib/puppet/util/autoload.rb +21 -23
- data/lib/puppet/util/checksums.rb +37 -0
- data/lib/puppet/util/classgen.rb +0 -1
- data/lib/puppet/util/diff.rb +71 -0
- data/lib/puppet/util/docs.rb +8 -2
- data/lib/puppet/util/errors.rb +0 -1
- data/lib/puppet/util/execution.rb +0 -1
- data/lib/puppet/util/fact_store.rb +0 -1
- data/lib/puppet/util/feature.rb +31 -22
- data/lib/puppet/util/fileparsing.rb +3 -2
- data/lib/puppet/util/filetype.rb +30 -12
- data/lib/puppet/util/graph.rb +0 -1
- data/lib/puppet/util/inifile.rb +0 -1
- data/lib/puppet/util/instance_loader.rb +11 -4
- data/lib/puppet/util/loadedfile.rb +0 -1
- data/lib/puppet/util/log.rb +0 -1
- data/lib/puppet/util/log_paths.rb +0 -1
- data/lib/puppet/util/logging.rb +0 -1
- data/lib/puppet/util/metaid.rb +0 -1
- data/lib/puppet/util/methodhelper.rb +0 -2
- data/lib/puppet/util/metric.rb +1 -2
- data/lib/puppet/util/plist.rb +0 -1
- data/lib/puppet/util/plist/generator.rb +0 -1
- data/lib/puppet/util/plist/parser.rb +0 -1
- data/lib/puppet/util/posix.rb +7 -1
- data/lib/puppet/util/provider_features.rb +11 -12
- data/lib/puppet/util/rails/collection_merger.rb +0 -1
- data/lib/puppet/util/reference.rb +2 -3
- data/lib/puppet/util/{config.rb → settings.rb} +424 -300
- data/lib/puppet/util/storage.rb +1 -3
- data/lib/puppet/util/subclass_loader.rb +0 -1
- data/lib/puppet/util/suidmanager.rb +25 -42
- data/lib/puppet/util/uri_helper.rb +22 -0
- data/lib/puppet/util/variables.rb +0 -1
- data/lib/puppet/util/warnings.rb +0 -1
- data/test/Rakefile +1 -1
- data/test/certmgr/ca.rb +8 -2
- data/test/certmgr/certmgr.rb +14 -6
- data/test/certmgr/inventory.rb +18 -30
- data/test/certmgr/support.rb +3 -2
- data/test/executables/filebucket.rb +1 -2
- data/test/executables/puppetbin.rb +1 -2
- data/test/executables/puppetca.rb +7 -2
- data/test/executables/puppetd.rb +23 -29
- data/test/executables/puppetmasterd.rb +1 -2
- data/test/executables/puppetmodule.rb +1 -2
- data/test/language/ast.rb +24 -29
- data/test/language/ast/casestatement.rb +1 -2
- data/test/language/ast/definition.rb +166 -0
- data/test/language/ast/hostclass.rb +50 -29
- data/test/language/ast/resource.rb +59 -0
- data/test/language/ast/{resourceref.rb → resource_reference.rb} +30 -20
- data/test/language/ast/selector.rb +1 -2
- data/test/language/ast/variable.rb +1 -2
- data/test/language/compile.rb +569 -0
- data/test/language/functions.rb +57 -76
- data/test/language/lexer.rb +20 -3
- data/test/language/parser.rb +45 -33
- data/test/language/resource.rb +275 -308
- data/test/language/scope.rb +135 -410
- data/test/language/snippets.rb +19 -41
- data/test/language/transportable.rb +8 -29
- data/test/lib/mocha/auto_verify.rb +6 -6
- data/test/lib/mocha/deprecation.rb +22 -0
- data/test/lib/mocha/exception_raiser.rb +17 -0
- data/test/lib/mocha/expectation.rb +167 -84
- data/test/lib/mocha/infinite_range.rb +4 -6
- data/test/lib/mocha/inspect.rb +3 -1
- data/test/lib/mocha/is_a.rb +9 -0
- data/test/lib/mocha/missing_expectation.rb +27 -0
- data/test/lib/mocha/mock.rb +192 -5
- data/test/lib/mocha/multiple_yields.rb +20 -0
- data/test/lib/mocha/no_yields.rb +11 -0
- data/test/lib/mocha/object.rb +11 -1
- data/test/lib/mocha/parameter_matchers.rb +9 -0
- data/test/lib/mocha/parameter_matchers/all_of.rb +39 -0
- data/test/lib/mocha/parameter_matchers/any_of.rb +44 -0
- data/test/lib/mocha/parameter_matchers/anything.rb +30 -0
- data/test/lib/mocha/parameter_matchers/has_entry.rb +39 -0
- data/test/lib/mocha/parameter_matchers/has_key.rb +39 -0
- data/test/lib/mocha/parameter_matchers/has_value.rb +39 -0
- data/test/lib/mocha/parameter_matchers/includes.rb +37 -0
- data/test/lib/mocha/return_values.rb +31 -0
- data/test/lib/mocha/single_return_value.rb +24 -0
- data/test/lib/mocha/single_yield.rb +18 -0
- data/test/lib/mocha/standalone.rb +2 -0
- data/test/lib/mocha/stub.rb +18 -0
- data/test/lib/mocha/test_case_adapter.rb +3 -3
- data/test/lib/mocha/yield_parameters.rb +31 -0
- data/test/lib/puppettest.rb +38 -20
- data/test/lib/puppettest/certificates.rb +0 -1
- data/test/lib/puppettest/exetest.rb +0 -1
- data/test/lib/puppettest/fakes.rb +0 -1
- data/test/lib/puppettest/fileparsing.rb +8 -15
- data/test/lib/puppettest/filetesting.rb +0 -1
- data/test/lib/puppettest/parsertesting.rb +37 -23
- data/test/lib/puppettest/railstesting.rb +3 -6
- data/test/lib/puppettest/reporttesting.rb +0 -1
- data/test/lib/puppettest/resourcetesting.rb +6 -34
- data/test/lib/puppettest/runnable_test.rb +30 -0
- data/test/lib/puppettest/servertest.rb +2 -3
- data/test/lib/puppettest/support/assertions.rb +13 -41
- data/test/lib/puppettest/support/collection.rb +0 -1
- data/test/lib/puppettest/support/helpers.rb +0 -1
- data/test/lib/puppettest/support/resources.rb +17 -17
- data/test/lib/puppettest/support/utils.rb +45 -27
- data/test/lib/puppettest/testcase.rb +2 -21
- data/test/lib/rake/puppet_test_loader.rb +0 -1
- data/test/lib/rake/puppet_testtask.rb +0 -1
- data/test/network/authconfig.rb +1 -2
- data/test/network/authorization.rb +1 -2
- data/test/network/authstore.rb +1 -2
- data/test/network/client/ca.rb +12 -7
- data/test/network/client/client.rb +17 -22
- data/test/network/client/dipper.rb +1 -2
- data/test/network/client/master.rb +70 -184
- data/test/network/client/resource.rb +9 -2
- data/test/network/client_request.rb +1 -2
- data/test/network/daemon.rb +1 -2
- data/test/network/handler/bucket.rb +2 -31
- data/test/network/handler/ca.rb +9 -3
- data/test/network/handler/configuration.rb +160 -0
- data/test/network/handler/fileserver.rb +24 -5
- data/test/network/handler/handler.rb +1 -2
- data/test/network/handler/master.rb +38 -243
- data/test/network/handler/report.rb +2 -104
- data/test/network/handler/resource.rb +5 -3
- data/test/network/handler/runner.rb +22 -60
- data/test/network/rights.rb +1 -2
- data/test/network/server/mongrel_test.rb +2 -3
- data/test/network/server/webrick.rb +17 -11
- data/test/network/xmlrpc/client.rb +27 -12
- data/test/network/xmlrpc/processor.rb +3 -4
- data/test/network/xmlrpc/server.rb +1 -2
- data/test/network/xmlrpc/webrick_servlet.rb +8 -2
- data/test/other/dsl.rb +2 -4
- data/test/other/events.rb +14 -56
- data/test/other/overrides.rb +3 -6
- data/test/other/propertychange.rb +1 -2
- data/test/other/provider.rb +1 -2
- data/test/other/puppet.rb +1 -2
- data/test/other/relationships.rb +15 -17
- data/test/other/report.rb +14 -20
- data/test/other/transactions.rb +109 -192
- data/test/puppet/conffiles.rb +3 -5
- data/test/puppet/defaults.rb +1 -28
- data/test/puppet/errortest.rb +1 -2
- data/test/puppet/tc_suidmanager.rb +77 -63
- data/test/rails/ast.rb +4 -4
- data/test/rails/configuration.rb +71 -0
- data/test/rails/host.rb +19 -30
- data/test/rails/rails.rb +1 -2
- data/test/rails/railsparameter.rb +3 -4
- data/test/rails/railsresource.rb +6 -5
- data/test/ral/manager/attributes.rb +1 -2
- data/test/ral/manager/instances.rb +3 -3
- data/test/ral/manager/manager.rb +1 -2
- data/test/ral/manager/provider.rb +1 -2
- data/test/ral/manager/type.rb +89 -93
- data/test/ral/providers/cron/crontab.rb +9 -11
- data/test/ral/providers/group.rb +1 -2
- data/test/ral/providers/host/netinfo.rb +1 -2
- data/test/ral/providers/host/parsed.rb +1 -2
- data/test/ral/providers/mailalias/aliases.rb +1 -2
- data/test/ral/providers/mount/netinfo.rb +1 -2
- data/test/ral/providers/nameservice.rb +1 -2
- data/test/ral/providers/package.rb +5 -4
- data/test/ral/providers/package/apt.rb +0 -1
- data/test/ral/providers/package/aptrpm.rb +0 -1
- data/test/ral/providers/parsedfile.rb +1 -2
- data/test/ral/providers/port/parsed.rb +1 -2
- data/test/ral/providers/provider.rb +10 -5
- data/test/ral/providers/service/base.rb +1 -2
- data/test/ral/providers/service/debian.rb +58 -0
- data/test/ral/providers/sshkey/parsed.rb +1 -2
- data/test/ral/providers/user.rb +3 -2
- data/test/ral/providers/user/useradd.rb +0 -1
- data/test/ral/types/basic.rb +4 -9
- data/test/ral/types/cron.rb +6 -12
- data/test/ral/types/exec.rb +6 -7
- data/test/ral/types/file.rb +35 -14
- data/test/ral/types/file/target.rb +6 -5
- data/test/ral/types/filebucket.rb +3 -2
- data/test/ral/types/fileignoresource.rb +10 -42
- data/test/ral/types/filesources.rb +21 -60
- data/test/ral/types/group.rb +3 -3
- data/test/ral/types/host.rb +6 -3
- data/test/ral/types/mailalias.rb +1 -2
- data/test/ral/types/parameter.rb +5 -3
- data/test/ral/types/port.rb +1 -2
- data/test/ral/types/property.rb +3 -3
- data/test/ral/types/resources.rb +1 -2
- data/test/ral/types/service.rb +5 -3
- data/test/ral/types/sshkey.rb +5 -3
- data/test/ral/types/tidy.rb +63 -3
- data/test/ral/types/user.rb +10 -11
- data/test/ral/types/yumrepo.rb +1 -1
- data/test/ral/types/zone.rb +1 -2
- data/test/util/autoload.rb +23 -27
- data/test/util/classgen.rb +1 -2
- data/test/util/execution.rb +1 -2
- data/test/util/features.rb +1 -3
- data/test/util/fileparsing.rb +11 -3
- data/test/util/filetype.rb +1 -2
- data/test/util/inifile.rb +1 -1
- data/test/util/instance_loader.rb +5 -6
- data/test/util/loadedfile.rb +1 -2
- data/test/util/log.rb +1 -2
- data/test/util/metrics.rb +1 -2
- data/test/util/package.rb +1 -2
- data/test/util/posixtest.rb +1 -2
- data/test/util/{config.rb → settings.rb} +123 -265
- data/test/util/storage.rb +1 -2
- data/test/util/subclass_loader.rb +1 -2
- data/test/util/utiltest.rb +1 -111
- metadata +130 -112
- data/ext/tools/passwd2puppet +0 -45
- data/lib/puppet/fact_stores/yaml.rb +0 -42
- data/lib/puppet/network/handler/facts.rb +0 -70
- data/lib/puppet/parser/ast/resourcedef.rb +0 -222
- data/lib/puppet/parser/ast/resourceref.rb +0 -58
- data/test/language/ast/component.rb +0 -142
- data/test/language/collector.rb +0 -179
- data/test/language/interpreter.rb +0 -804
- data/test/language/node.rb +0 -126
- data/test/lib/mocha/mock_methods.rb +0 -122
- data/test/lib/puppettest/graph.rb +0 -41
- data/test/lib/spec.rb +0 -8
- data/test/lib/spec/callback.rb +0 -11
- data/test/lib/spec/callback/callback_container.rb +0 -60
- data/test/lib/spec/callback/extensions/module.rb +0 -24
- data/test/lib/spec/callback/extensions/object.rb +0 -37
- data/test/lib/spec/deprecated.rb +0 -3
- data/test/lib/spec/expectations.rb +0 -59
- data/test/lib/spec/expectations/differs/default.rb +0 -62
- data/test/lib/spec/expectations/errors.rb +0 -6
- data/test/lib/spec/expectations/extensions.rb +0 -3
- data/test/lib/spec/expectations/extensions/object.rb +0 -109
- data/test/lib/spec/expectations/extensions/proc.rb +0 -57
- data/test/lib/spec/expectations/extensions/string_and_symbol.rb +0 -17
- data/test/lib/spec/expectations/handler.rb +0 -47
- data/test/lib/spec/expectations/should.rb +0 -5
- data/test/lib/spec/expectations/should/base.rb +0 -64
- data/test/lib/spec/expectations/should/change.rb +0 -69
- data/test/lib/spec/expectations/should/have.rb +0 -128
- data/test/lib/spec/expectations/should/not.rb +0 -74
- data/test/lib/spec/expectations/should/should.rb +0 -81
- data/test/lib/spec/expectations/sugar.rb +0 -47
- data/test/lib/spec/matchers.rb +0 -160
- data/test/lib/spec/matchers/be.rb +0 -161
- data/test/lib/spec/matchers/be_close.rb +0 -37
- data/test/lib/spec/matchers/change.rb +0 -120
- data/test/lib/spec/matchers/eql.rb +0 -43
- data/test/lib/spec/matchers/equal.rb +0 -43
- data/test/lib/spec/matchers/has.rb +0 -44
- data/test/lib/spec/matchers/have.rb +0 -140
- data/test/lib/spec/matchers/include.rb +0 -50
- data/test/lib/spec/matchers/match.rb +0 -41
- data/test/lib/spec/matchers/raise_error.rb +0 -100
- data/test/lib/spec/matchers/respond_to.rb +0 -35
- data/test/lib/spec/matchers/satisfy.rb +0 -47
- data/test/lib/spec/matchers/throw_symbol.rb +0 -75
- data/test/lib/spec/mocks.rb +0 -232
- data/test/lib/spec/mocks/argument_expectation.rb +0 -132
- data/test/lib/spec/mocks/error_generator.rb +0 -85
- data/test/lib/spec/mocks/errors.rb +0 -10
- data/test/lib/spec/mocks/extensions/object.rb +0 -3
- data/test/lib/spec/mocks/message_expectation.rb +0 -231
- data/test/lib/spec/mocks/methods.rb +0 -40
- data/test/lib/spec/mocks/mock.rb +0 -26
- data/test/lib/spec/mocks/mock_handler.rb +0 -166
- data/test/lib/spec/mocks/order_group.rb +0 -29
- data/test/lib/spec/rake/spectask.rb +0 -173
- data/test/lib/spec/rake/verify_rcov.rb +0 -47
- data/test/lib/spec/runner.rb +0 -132
- data/test/lib/spec/runner/backtrace_tweaker.rb +0 -55
- data/test/lib/spec/runner/command_line.rb +0 -34
- data/test/lib/spec/runner/context.rb +0 -154
- data/test/lib/spec/runner/context_eval.rb +0 -142
- data/test/lib/spec/runner/context_runner.rb +0 -55
- data/test/lib/spec/runner/drb_command_line.rb +0 -21
- data/test/lib/spec/runner/execution_context.rb +0 -17
- data/test/lib/spec/runner/extensions/kernel.rb +0 -17
- data/test/lib/spec/runner/extensions/object.rb +0 -32
- data/test/lib/spec/runner/formatter.rb +0 -5
- data/test/lib/spec/runner/formatter/base_text_formatter.rb +0 -118
- data/test/lib/spec/runner/formatter/html_formatter.rb +0 -219
- data/test/lib/spec/runner/formatter/progress_bar_formatter.rb +0 -27
- data/test/lib/spec/runner/formatter/rdoc_formatter.rb +0 -22
- data/test/lib/spec/runner/formatter/specdoc_formatter.rb +0 -23
- data/test/lib/spec/runner/heckle_runner.rb +0 -71
- data/test/lib/spec/runner/heckle_runner_win.rb +0 -10
- data/test/lib/spec/runner/option_parser.rb +0 -224
- data/test/lib/spec/runner/reporter.rb +0 -105
- data/test/lib/spec/runner/spec_matcher.rb +0 -25
- data/test/lib/spec/runner/spec_parser.rb +0 -41
- data/test/lib/spec/runner/spec_should_raise_handler.rb +0 -74
- data/test/lib/spec/runner/specification.rb +0 -114
- data/test/lib/spec/translator.rb +0 -87
- data/test/lib/spec/version.rb +0 -30
- data/test/network/handler/facts.rb +0 -112
- data/test/other/pgraph.rb +0 -290
- data/test/other/relationship.rb +0 -74
- data/test/puppet/modules.rb +0 -59
- data/test/rails/collection.rb +0 -247
- data/test/rails/interpreter.rb +0 -91
- data/test/ral/providers/mount/parsed.rb +0 -251
- data/test/ral/providers/service.rb +0 -235
- data/test/ral/types/component.rb +0 -113
- data/test/ral/types/interface.rb +0 -40
- data/test/ral/types/mount.rb +0 -362
- data/test/ral/types/package.rb +0 -154
- data/test/ral/types/schedule.rb +0 -357
- data/test/tagging/tagging.rb +0 -170
- data/test/util/fact_store.rb +0 -67
- data/test/util/graph.rb +0 -108
data/lib/puppet/util/graph.rb
CHANGED
data/lib/puppet/util/inifile.rb
CHANGED
@@ -5,8 +5,14 @@ require 'puppet/util'
|
|
5
5
|
# of Puppet::Util::Autoload
|
6
6
|
module Puppet::Util::InstanceLoader
|
7
7
|
include Puppet::Util
|
8
|
+
|
9
|
+
# Are we instance-loading this type?
|
10
|
+
def instance_loading?(type)
|
11
|
+
defined?(@autoloaders) and @autoloaders.include?(symbolize(type))
|
12
|
+
end
|
13
|
+
|
8
14
|
# Define a new type of autoloading.
|
9
|
-
def
|
15
|
+
def instance_load(type, path, options = {})
|
10
16
|
@autoloaders ||= {}
|
11
17
|
@instances ||= {}
|
12
18
|
type = symbolize(type)
|
@@ -30,6 +36,9 @@ module Puppet::Util::InstanceLoader
|
|
30
36
|
def instance_docs(type)
|
31
37
|
docs = ""
|
32
38
|
|
39
|
+
# Load all instances.
|
40
|
+
instance_loader(type).loadall
|
41
|
+
|
33
42
|
# Use this method so they all get loaded
|
34
43
|
loaded_instances(type).sort { |a,b| a.to_s <=> b.to_s }.each do |name|
|
35
44
|
mod = self.loaded_instance(name)
|
@@ -54,7 +63,7 @@ module Puppet::Util::InstanceLoader
|
|
54
63
|
# Retrieve an alread-loaded instance, or attempt to load our instance.
|
55
64
|
def loaded_instance(type, name)
|
56
65
|
name = symbolize(name)
|
57
|
-
instances = instance_hash(type)
|
66
|
+
return nil unless instances = instance_hash(type)
|
58
67
|
unless instances.include? name
|
59
68
|
if instance_loader(type).load(name)
|
60
69
|
unless instances.include? name
|
@@ -70,5 +79,3 @@ module Puppet::Util::InstanceLoader
|
|
70
79
|
instances[name]
|
71
80
|
end
|
72
81
|
end
|
73
|
-
|
74
|
-
# $Id: instance_loader.rb 2476 2007-05-07 18:59:40Z luke $
|
data/lib/puppet/util/log.rb
CHANGED
data/lib/puppet/util/logging.rb
CHANGED
data/lib/puppet/util/metaid.rb
CHANGED
data/lib/puppet/util/metric.rb
CHANGED
@@ -21,7 +21,7 @@ class Puppet::Util::Metric
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def create(start = nil)
|
24
|
-
Puppet.
|
24
|
+
Puppet.settings.use(:main, :metrics)
|
25
25
|
|
26
26
|
start ||= Time.now.to_i - 5
|
27
27
|
|
@@ -149,4 +149,3 @@ end
|
|
149
149
|
|
150
150
|
Puppet::Metric = Puppet::Util::Metric
|
151
151
|
|
152
|
-
# $Id: metric.rb 2584 2007-06-14 14:23:58Z luke $
|
data/lib/puppet/util/plist.rb
CHANGED
data/lib/puppet/util/posix.rb
CHANGED
@@ -53,6 +53,13 @@ module Puppet::Util::POSIX
|
|
53
53
|
return object.send(field)
|
54
54
|
end
|
55
55
|
end
|
56
|
+
|
57
|
+
# Apparently the group/passwd methods need to get reset; if we skip
|
58
|
+
# this call, then new users aren't found.
|
59
|
+
case type
|
60
|
+
when :passwd: Etc.send(:endpwent)
|
61
|
+
when :group: Etc.send(:endgrent)
|
62
|
+
end
|
56
63
|
return nil
|
57
64
|
end
|
58
65
|
|
@@ -116,4 +123,3 @@ module Puppet::Util::POSIX
|
|
116
123
|
end
|
117
124
|
end
|
118
125
|
|
119
|
-
# $Id: posix.rb 2598 2007-06-17 23:11:14Z luke $
|
@@ -55,9 +55,7 @@ module Puppet::Util::ProviderFeatures
|
|
55
55
|
# required to determine if the feature is present.
|
56
56
|
def feature(name, docs, hash = {})
|
57
57
|
@features ||= {}
|
58
|
-
if @features.include?(name)
|
59
|
-
raise Puppet::DevError, "Feature %s is already defined" % name
|
60
|
-
end
|
58
|
+
raise(Puppet::DevError, "Feature %s is already defined" % name) if @features.include?(name)
|
61
59
|
begin
|
62
60
|
obj = ProviderFeature.new(name, docs, hash)
|
63
61
|
@features[obj.name] = obj
|
@@ -133,7 +131,8 @@ module Puppet::Util::ProviderFeatures
|
|
133
131
|
}
|
134
132
|
end
|
135
133
|
|
136
|
-
# Create a method that will
|
134
|
+
# Create a method that will determine if a provided list of
|
135
|
+
# features are satisfied by the curred provider.
|
137
136
|
@feature_module.send(:define_method, :satisfies?) do |*needed|
|
138
137
|
ret = true
|
139
138
|
needed.flatten.each do |feature|
|
@@ -150,13 +149,7 @@ module Puppet::Util::ProviderFeatures
|
|
150
149
|
@features.each do |name, feature|
|
151
150
|
method = name.to_s + "?"
|
152
151
|
@feature_module.send(:define_method, method) do
|
153
|
-
|
154
|
-
true
|
155
|
-
elsif feature.available?(self)
|
156
|
-
true
|
157
|
-
else
|
158
|
-
false
|
159
|
-
end
|
152
|
+
(is_a?(Class) ? declared_feature?(name) : self.class.declared_feature?(name)) or feature.available?(self)
|
160
153
|
end
|
161
154
|
end
|
162
155
|
|
@@ -173,6 +166,12 @@ module Puppet::Util::ProviderFeatures
|
|
173
166
|
end
|
174
167
|
@feature_module
|
175
168
|
end
|
169
|
+
|
170
|
+
# Return the actual provider feature instance. Really only used for testing.
|
171
|
+
def provider_feature(name)
|
172
|
+
return nil unless defined?(@features)
|
173
|
+
|
174
|
+
@features[name]
|
175
|
+
end
|
176
176
|
end
|
177
177
|
|
178
|
-
# $Id: provider_features.rb 2542 2007-05-30 20:36:29Z mpalmer $
|
@@ -7,7 +7,7 @@ class Puppet::Util::Reference
|
|
7
7
|
|
8
8
|
extend Puppet::Util::InstanceLoader
|
9
9
|
|
10
|
-
|
10
|
+
instance_load(:reference, 'puppet/reference')
|
11
11
|
|
12
12
|
def self.footer
|
13
13
|
"\n\n----------------\n\n*This page autogenerated on %s*\n" % Time.now
|
@@ -143,7 +143,7 @@ class Puppet::Util::Reference
|
|
143
143
|
def to_rest(withcontents = true)
|
144
144
|
# First the header
|
145
145
|
text = h(@title, 1)
|
146
|
-
text += "\n\n**This page is autogenerated; any changes will get overwritten
|
146
|
+
text += "\n\n**This page is autogenerated; any changes will get overwritten** *(last generated on #{Time.now.to_s})*\n\n"
|
147
147
|
if withcontents
|
148
148
|
text += ".. contents:: :depth: %s\n\n" % @depth
|
149
149
|
end
|
@@ -186,4 +186,3 @@ class Puppet::Util::Reference
|
|
186
186
|
end
|
187
187
|
end
|
188
188
|
|
189
|
-
# $Id: reference.rb 2636 2007-06-19 23:52:34Z luke $
|
@@ -1,98 +1,84 @@
|
|
1
1
|
require 'puppet'
|
2
2
|
require 'sync'
|
3
3
|
require 'puppet/transportable'
|
4
|
+
require 'getoptlong'
|
5
|
+
|
4
6
|
|
5
7
|
# The class for handling configuration files.
|
6
|
-
class Puppet::Util::
|
8
|
+
class Puppet::Util::Settings
|
7
9
|
include Enumerable
|
8
10
|
include Puppet::Util
|
9
11
|
|
10
12
|
@@sync = Sync.new
|
11
13
|
|
12
|
-
|
14
|
+
attr_accessor :file
|
15
|
+
attr_reader :timer
|
13
16
|
|
14
17
|
# Retrieve a config value
|
15
18
|
def [](param)
|
16
|
-
|
17
|
-
|
18
|
-
# Yay, recursion.
|
19
|
-
self.reparse() unless param == :filetimeout
|
20
|
-
|
21
|
-
# Cache the returned values; this method was taking close to
|
22
|
-
# 10% of the compile time.
|
23
|
-
unless @returned[param]
|
24
|
-
if @config.include?(param)
|
25
|
-
if @config[param]
|
26
|
-
@returned[param] = @config[param].value
|
27
|
-
end
|
28
|
-
else
|
29
|
-
raise ArgumentError, "Undefined configuration parameter '%s'" % param
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
return @returned[param]
|
19
|
+
value(param)
|
34
20
|
end
|
35
21
|
|
36
22
|
# Set a config value. This doesn't set the defaults, it sets the value itself.
|
37
23
|
def []=(param, value)
|
38
24
|
@@sync.synchronize do # yay, thread-safe
|
39
25
|
param = symbolize(param)
|
40
|
-
unless @config
|
41
|
-
raise
|
26
|
+
unless element = @config[param]
|
27
|
+
raise ArgumentError,
|
42
28
|
"Attempt to assign a value to unknown configuration parameter %s" % param.inspect
|
43
29
|
end
|
44
|
-
|
45
|
-
|
30
|
+
if element.respond_to?(:munge)
|
31
|
+
value = element.munge(value)
|
32
|
+
end
|
33
|
+
if element.respond_to?(:handle)
|
34
|
+
element.handle(value)
|
46
35
|
end
|
47
|
-
|
48
|
-
if
|
49
|
-
@
|
36
|
+
# Reset the name, so it's looked up again.
|
37
|
+
if param == :name
|
38
|
+
@name = nil
|
50
39
|
end
|
40
|
+
@values[:memory][param] = value
|
41
|
+
@cache.clear
|
51
42
|
end
|
52
43
|
|
53
44
|
return value
|
54
45
|
end
|
55
46
|
|
56
47
|
# A simplified equality operator.
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
48
|
+
# LAK: For some reason, this causes mocha to not be able to mock
|
49
|
+
# the 'value' method, and it's not used anywhere.
|
50
|
+
# def ==(other)
|
51
|
+
# self.each { |myname, myobj|
|
52
|
+
# unless other[myname] == value(myname)
|
53
|
+
# return false
|
54
|
+
# end
|
55
|
+
# }
|
56
|
+
#
|
57
|
+
# return true
|
58
|
+
# end
|
66
59
|
|
67
60
|
# Generate the list of valid arguments, in a format that GetoptLong can
|
68
61
|
# understand, and add them to the passed option list.
|
69
62
|
def addargs(options)
|
70
|
-
require 'getoptlong'
|
71
|
-
|
72
63
|
# Hackish, but acceptable. Copy the current ARGV for restarting.
|
73
64
|
Puppet.args = ARGV.dup
|
74
65
|
|
75
66
|
# Add all of the config parameters as valid options.
|
76
|
-
self.each { |
|
77
|
-
|
78
|
-
options << ["--#{param}", GetoptLong::NO_ARGUMENT]
|
79
|
-
options << ["--no-#{param}", GetoptLong::NO_ARGUMENT]
|
80
|
-
else
|
81
|
-
options << ["--#{param}", GetoptLong::REQUIRED_ARGUMENT]
|
82
|
-
end
|
67
|
+
self.each { |name, element|
|
68
|
+
element.getopt_args.each { |args| options << args }
|
83
69
|
}
|
84
70
|
|
85
71
|
return options
|
86
72
|
end
|
87
73
|
|
88
|
-
# Turn the config into a
|
74
|
+
# Turn the config into a Puppet configuration and apply it
|
89
75
|
def apply
|
90
76
|
trans = self.to_transportable
|
91
77
|
begin
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
78
|
+
config = trans.to_catalog
|
79
|
+
config.store_state = false
|
80
|
+
config.apply
|
81
|
+
config.clear
|
96
82
|
rescue => detail
|
97
83
|
if Puppet[:trace]
|
98
84
|
puts detail.backtrace
|
@@ -118,45 +104,69 @@ class Puppet::Util::Config
|
|
118
104
|
obj.clear
|
119
105
|
end
|
120
106
|
}
|
121
|
-
@
|
107
|
+
@values.each do |name, values|
|
108
|
+
next if name == :cli and exceptcli
|
109
|
+
@values.delete(name)
|
110
|
+
end
|
122
111
|
|
123
112
|
# Don't clear the 'used' in this case, since it's a config file reparse,
|
124
113
|
# and we want to retain this info.
|
125
114
|
unless exceptcli
|
126
115
|
@used = []
|
127
116
|
end
|
117
|
+
|
118
|
+
@cache.clear
|
119
|
+
|
120
|
+
@name = nil
|
128
121
|
end
|
129
122
|
|
130
123
|
# This is mostly just used for testing.
|
131
124
|
def clearused
|
132
|
-
@
|
125
|
+
@cache.clear
|
133
126
|
@used = []
|
134
127
|
end
|
135
128
|
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
129
|
+
# Do variable interpolation on the value.
|
130
|
+
def convert(value)
|
131
|
+
return value unless value
|
132
|
+
return value unless value.is_a? String
|
133
|
+
newval = value.gsub(/\$(\w+)|\$\{(\w+)\}/) do |value|
|
134
|
+
varname = $2 || $1
|
135
|
+
if pval = self.value(varname)
|
136
|
+
pval
|
140
137
|
else
|
141
|
-
raise Puppet::DevError, "
|
138
|
+
raise Puppet::DevError, "Could not find value for %s" % parent
|
142
139
|
end
|
140
|
+
end
|
141
|
+
|
142
|
+
return newval
|
143
|
+
end
|
144
|
+
|
145
|
+
# Return a value's description.
|
146
|
+
def description(name)
|
147
|
+
if obj = @config[symbolize(name)]
|
148
|
+
obj.desc
|
149
|
+
else
|
150
|
+
nil
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
def each
|
155
|
+
@config.each { |name, object|
|
156
|
+
yield name, object
|
143
157
|
}
|
144
158
|
end
|
145
159
|
|
146
160
|
# Iterate over each section name.
|
147
161
|
def eachsection
|
148
162
|
yielded = []
|
149
|
-
@
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
yielded << section
|
155
|
-
end
|
156
|
-
else
|
157
|
-
raise Puppet::DevError, "%s is in the order but does not exist" % name
|
163
|
+
@config.each do |name, object|
|
164
|
+
section = object.section
|
165
|
+
unless yielded.include? section
|
166
|
+
yield section
|
167
|
+
yielded << section
|
158
168
|
end
|
159
|
-
|
169
|
+
end
|
160
170
|
end
|
161
171
|
|
162
172
|
# Return an object by name.
|
@@ -167,6 +177,7 @@ class Puppet::Util::Config
|
|
167
177
|
|
168
178
|
# Handle a command-line argument.
|
169
179
|
def handlearg(opt, value = nil)
|
180
|
+
@cache.clear
|
170
181
|
value = munge_value(value) if value
|
171
182
|
str = opt.sub(/^--/,'')
|
172
183
|
bool = true
|
@@ -175,16 +186,13 @@ class Puppet::Util::Config
|
|
175
186
|
str = newstr
|
176
187
|
bool = false
|
177
188
|
end
|
189
|
+
str = str.intern
|
178
190
|
if self.valid?(str)
|
179
191
|
if self.boolean?(str)
|
180
|
-
|
192
|
+
@values[:cli][str] = bool
|
181
193
|
else
|
182
|
-
|
194
|
+
@values[:cli][str] = value
|
183
195
|
end
|
184
|
-
|
185
|
-
# Mark that this was set on the cli, so it's not overridden if the
|
186
|
-
# config gets reread.
|
187
|
-
@config[str.intern].setbycli = true
|
188
196
|
else
|
189
197
|
raise ArgumentError, "Invalid argument %s" % opt
|
190
198
|
end
|
@@ -195,13 +203,42 @@ class Puppet::Util::Config
|
|
195
203
|
@config.include?(name)
|
196
204
|
end
|
197
205
|
|
206
|
+
# check to see if a short name is already defined
|
207
|
+
def shortinclude?(short)
|
208
|
+
short = short.intern if name.is_a? String
|
209
|
+
@shortnames.include?(short)
|
210
|
+
end
|
211
|
+
|
198
212
|
# Create a new config object
|
199
213
|
def initialize
|
200
|
-
@order = []
|
201
214
|
@config = {}
|
215
|
+
@shortnames = {}
|
202
216
|
|
203
217
|
@created = []
|
204
|
-
@
|
218
|
+
@searchpath = nil
|
219
|
+
|
220
|
+
# Keep track of set values.
|
221
|
+
@values = Hash.new { |hash, key| hash[key] = {} }
|
222
|
+
|
223
|
+
# And keep a per-environment cache
|
224
|
+
@cache = Hash.new { |hash, key| hash[key] = {} }
|
225
|
+
|
226
|
+
# A central concept of a name.
|
227
|
+
@name = nil
|
228
|
+
end
|
229
|
+
|
230
|
+
# Return a given object's file metadata.
|
231
|
+
def metadata(param)
|
232
|
+
if obj = @config[symbolize(param)] and obj.is_a?(CFile)
|
233
|
+
return [:owner, :group, :mode].inject({}) do |meta, p|
|
234
|
+
if v = obj.send(p)
|
235
|
+
meta[p] = v
|
236
|
+
end
|
237
|
+
meta
|
238
|
+
end
|
239
|
+
else
|
240
|
+
nil
|
241
|
+
end
|
205
242
|
end
|
206
243
|
|
207
244
|
# Make a directory with the appropriate user, group, and mode
|
@@ -221,28 +258,74 @@ class Puppet::Util::Config
|
|
221
258
|
end
|
222
259
|
end
|
223
260
|
|
261
|
+
# Figure out our name.
|
262
|
+
def name
|
263
|
+
unless @name
|
264
|
+
unless @config[:name]
|
265
|
+
return nil
|
266
|
+
end
|
267
|
+
searchpath.each do |source|
|
268
|
+
next if source == :name
|
269
|
+
break if @name = @values[source][:name]
|
270
|
+
end
|
271
|
+
unless @name
|
272
|
+
@name = convert(@config[:name].default).intern
|
273
|
+
end
|
274
|
+
end
|
275
|
+
@name
|
276
|
+
end
|
277
|
+
|
224
278
|
# Return all of the parameters associated with a given section.
|
225
|
-
def params(section)
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
name
|
231
|
-
|
279
|
+
def params(section = nil)
|
280
|
+
if section
|
281
|
+
section = section.intern if section.is_a? String
|
282
|
+
@config.find_all { |name, obj|
|
283
|
+
obj.section == section
|
284
|
+
}.collect { |name, obj|
|
285
|
+
name
|
286
|
+
}
|
287
|
+
else
|
288
|
+
@config.keys
|
289
|
+
end
|
232
290
|
end
|
233
291
|
|
234
292
|
# Parse the configuration file.
|
235
293
|
def parse(file)
|
236
|
-
|
294
|
+
clear(true)
|
237
295
|
|
238
|
-
|
239
|
-
|
240
|
-
set_parameter_hash(main)
|
296
|
+
parse_file(file).each do |area, values|
|
297
|
+
@values[area] = values
|
241
298
|
end
|
242
299
|
|
243
|
-
#
|
244
|
-
if @config
|
245
|
-
|
300
|
+
# Determine our environment, if we have one.
|
301
|
+
if @config[:environment]
|
302
|
+
env = self.value(:environment).to_sym
|
303
|
+
else
|
304
|
+
env = "none"
|
305
|
+
end
|
306
|
+
|
307
|
+
# Call any hooks we should be calling.
|
308
|
+
settings_with_hooks.each do |setting|
|
309
|
+
each_source(env) do |source|
|
310
|
+
if value = @values[source][setting.name]
|
311
|
+
# We still have to use value() to retrieve the value, since
|
312
|
+
# we want the fully interpolated value, not $vardir/lib or whatever.
|
313
|
+
# This results in extra work, but so few of the settings
|
314
|
+
# will have associated hooks that it ends up being less work this
|
315
|
+
# way overall.
|
316
|
+
setting.handle(self.value(setting.name, env))
|
317
|
+
break
|
318
|
+
end
|
319
|
+
end
|
320
|
+
end
|
321
|
+
|
322
|
+
# We have to do it in the reverse of the search path,
|
323
|
+
# because multiple sections could set the same value
|
324
|
+
# and I'm too lazy to only set the metadata once.
|
325
|
+
searchpath.reverse.each do |source|
|
326
|
+
if meta = @values[source][:_meta]
|
327
|
+
set_metadata(meta)
|
328
|
+
end
|
246
329
|
end
|
247
330
|
end
|
248
331
|
|
@@ -307,7 +390,8 @@ class Puppet::Util::Config
|
|
307
390
|
|
308
391
|
# If the parameter is valid, then set it.
|
309
392
|
if section == Puppet[:name] and @config.include?(var)
|
310
|
-
|
393
|
+
#@config[var].value = value
|
394
|
+
@values[:main][var] = value
|
311
395
|
end
|
312
396
|
next
|
313
397
|
end
|
@@ -316,7 +400,7 @@ class Puppet::Util::Config
|
|
316
400
|
# after cli arguments are handled.
|
317
401
|
unless @config.include?(var) and @config[var].setbycli
|
318
402
|
Puppet.debug "%s: Setting %s to '%s'" % [section, var, value]
|
319
|
-
|
403
|
+
@values[:main][var] = value
|
320
404
|
end
|
321
405
|
@config[var].section = symbolize(section)
|
322
406
|
|
@@ -355,11 +439,12 @@ class Puppet::Util::Config
|
|
355
439
|
hash[:parent] = self
|
356
440
|
element = klass.new(hash)
|
357
441
|
|
358
|
-
@order << element.name
|
359
|
-
|
360
442
|
return element
|
361
443
|
end
|
362
444
|
|
445
|
+
# This has to be private, because it doesn't add the elements to @config
|
446
|
+
private :newelement
|
447
|
+
|
363
448
|
# Iterate across all of the objects in a given section.
|
364
449
|
def persection(section)
|
365
450
|
section = symbolize(section)
|
@@ -391,6 +476,15 @@ class Puppet::Util::Config
|
|
391
476
|
end
|
392
477
|
end
|
393
478
|
|
479
|
+
# The order in which to search for values.
|
480
|
+
def searchpath(environment = nil)
|
481
|
+
if environment
|
482
|
+
[:cli, :memory, environment, :name, :main]
|
483
|
+
else
|
484
|
+
[:cli, :memory, :name, :main]
|
485
|
+
end
|
486
|
+
end
|
487
|
+
|
394
488
|
# Get a list of objects per section
|
395
489
|
def sectionlist
|
396
490
|
sectionlist = []
|
@@ -407,59 +501,17 @@ class Puppet::Util::Config
|
|
407
501
|
end
|
408
502
|
|
409
503
|
# Convert a single section into transportable objects.
|
410
|
-
def section_to_transportable(section, done = nil
|
504
|
+
def section_to_transportable(section, done = nil)
|
411
505
|
done ||= Hash.new { |hash, key| hash[key] = {} }
|
412
506
|
objects = []
|
413
507
|
persection(section) do |obj|
|
414
|
-
if @config[:mkusers] and
|
415
|
-
|
416
|
-
type = nil
|
417
|
-
if attr == :owner
|
418
|
-
type = :user
|
419
|
-
else
|
420
|
-
type = attr
|
421
|
-
end
|
422
|
-
# If a user and/or group is set, then make sure we're
|
423
|
-
# managing that object
|
424
|
-
if obj.respond_to? attr and name = obj.send(attr)
|
425
|
-
# Skip root or wheel
|
426
|
-
next if %w{root wheel}.include?(name.to_s)
|
427
|
-
|
428
|
-
# Skip owners and groups we've already done, but tag
|
429
|
-
# them with our section if necessary
|
430
|
-
if done[type].include?(name)
|
431
|
-
tags = done[type][name].tags
|
432
|
-
unless tags.include?(section)
|
433
|
-
done[type][name].tags = tags << section
|
434
|
-
end
|
435
|
-
elsif newobj = Puppet::Type.type(type)[name]
|
436
|
-
unless newobj.property(:ensure)
|
437
|
-
newobj[:ensure] = "present"
|
438
|
-
end
|
439
|
-
newobj.tag(section)
|
440
|
-
if type == :user
|
441
|
-
newobj[:comment] ||= "%s user" % name
|
442
|
-
end
|
443
|
-
else
|
444
|
-
newobj = Puppet::TransObject.new(name, type.to_s)
|
445
|
-
newobj.tags = ["puppet", "configuration", section]
|
446
|
-
newobj[:ensure] = "present"
|
447
|
-
if type == :user
|
448
|
-
newobj[:comment] ||= "%s user" % name
|
449
|
-
end
|
450
|
-
# Set the group appropriately for the user
|
451
|
-
if type == :user
|
452
|
-
newobj[:gid] = Puppet[:group]
|
453
|
-
end
|
454
|
-
done[type][name] = newobj
|
455
|
-
objects << newobj
|
456
|
-
end
|
457
|
-
end
|
458
|
-
end
|
508
|
+
if @config[:mkusers] and value(:mkusers)
|
509
|
+
objects += add_user_resources(section, obj, done)
|
459
510
|
end
|
460
511
|
|
512
|
+
# Only files are convertable to transportable resources.
|
461
513
|
if obj.respond_to? :to_transportable
|
462
|
-
next if obj.
|
514
|
+
next if value(obj.name) =~ /^\/dev/
|
463
515
|
transobjects = obj.to_transportable
|
464
516
|
transobjects = [transobjects] unless transobjects.is_a? Array
|
465
517
|
transobjects.each do |trans|
|
@@ -475,7 +527,8 @@ class Puppet::Util::Config
|
|
475
527
|
end
|
476
528
|
|
477
529
|
bucket = Puppet::TransBucket.new
|
478
|
-
bucket.type =
|
530
|
+
bucket.type = "Settings"
|
531
|
+
bucket.name = section
|
479
532
|
bucket.push(*objects)
|
480
533
|
bucket.keyword = "class"
|
481
534
|
|
@@ -486,8 +539,12 @@ class Puppet::Util::Config
|
|
486
539
|
# pointless, but they help break things up a bit, anyway.
|
487
540
|
def setdefaults(section, defs)
|
488
541
|
section = symbolize(section)
|
542
|
+
call = []
|
489
543
|
defs.each { |name, hash|
|
490
544
|
if hash.is_a? Array
|
545
|
+
unless hash.length == 2
|
546
|
+
raise ArgumentError, "Defaults specified as an array must contain only the default value and the decription"
|
547
|
+
end
|
491
548
|
tmp = hash
|
492
549
|
hash = {}
|
493
550
|
[:default, :desc].zip(tmp).each { |p,v| hash[p] = v }
|
@@ -497,10 +554,24 @@ class Puppet::Util::Config
|
|
497
554
|
hash[:section] = section
|
498
555
|
name = hash[:name]
|
499
556
|
if @config.include?(name)
|
500
|
-
raise
|
557
|
+
raise ArgumentError, "Parameter %s is already defined" % name
|
501
558
|
end
|
502
|
-
|
559
|
+
tryconfig = newelement(hash)
|
560
|
+
if short = tryconfig.short
|
561
|
+
if other = @shortnames[short]
|
562
|
+
raise ArgumentError, "Parameter %s is already using short name '%s'" % [other.name, short]
|
563
|
+
end
|
564
|
+
@shortnames[short] = tryconfig
|
565
|
+
end
|
566
|
+
@config[name] = tryconfig
|
567
|
+
|
568
|
+
# Collect the settings that need to have their hooks called immediately.
|
569
|
+
# We have to collect them so that we can be sure we're fully initialized before
|
570
|
+
# the hook is called.
|
571
|
+
call << tryconfig if tryconfig.call_on_define
|
503
572
|
}
|
573
|
+
|
574
|
+
call.each { |setting| setting.handle(self.value(setting.name)) }
|
504
575
|
end
|
505
576
|
|
506
577
|
# Create a timer to check whether the file should be reparsed.
|
@@ -517,12 +588,12 @@ class Puppet::Util::Config
|
|
517
588
|
end
|
518
589
|
|
519
590
|
# Convert our list of objects into a component that can be applied.
|
520
|
-
def
|
591
|
+
def to_configuration
|
521
592
|
transport = self.to_transportable
|
522
|
-
return transport.
|
593
|
+
return transport.to_catalog
|
523
594
|
end
|
524
595
|
|
525
|
-
# Convert our list of
|
596
|
+
# Convert our list of config elements into a configuration file.
|
526
597
|
def to_config
|
527
598
|
str = %{The configuration file for #{Puppet[:name]}. Note that this file
|
528
599
|
is likely to have unused configuration parameters in it; any parameter that's
|
@@ -555,7 +626,7 @@ Generated on #{Time.now}.
|
|
555
626
|
end
|
556
627
|
|
557
628
|
# Convert our configuration into a list of transportable objects.
|
558
|
-
def to_transportable
|
629
|
+
def to_transportable(*sections)
|
559
630
|
done = Hash.new { |hash, key|
|
560
631
|
hash[key] = {}
|
561
632
|
}
|
@@ -564,14 +635,20 @@ Generated on #{Time.now}.
|
|
564
635
|
if defined? @file.file and @file.file
|
565
636
|
topbucket.name = @file.file
|
566
637
|
else
|
567
|
-
topbucket.name = "
|
638
|
+
topbucket.name = "top"
|
568
639
|
end
|
569
|
-
topbucket.type = "
|
640
|
+
topbucket.type = "Settings"
|
570
641
|
topbucket.top = true
|
571
642
|
|
572
643
|
# Now iterate over each section
|
573
|
-
|
574
|
-
|
644
|
+
if sections.empty?
|
645
|
+
eachsection do |section|
|
646
|
+
sections << section
|
647
|
+
end
|
648
|
+
end
|
649
|
+
sections.each do |section|
|
650
|
+
obj = section_to_transportable(section, done)
|
651
|
+
topbucket.push obj
|
575
652
|
end
|
576
653
|
|
577
654
|
topbucket
|
@@ -597,46 +674,19 @@ Generated on #{Time.now}.
|
|
597
674
|
@used = []
|
598
675
|
end
|
599
676
|
|
600
|
-
|
601
|
-
symbolize(s)
|
602
|
-
}.find_all { |s|
|
603
|
-
! @used.include? s
|
604
|
-
}
|
605
|
-
return if runners.empty?
|
606
|
-
|
607
|
-
bucket = Puppet::TransBucket.new
|
608
|
-
bucket.type = "puppetconfig"
|
609
|
-
bucket.top = true
|
610
|
-
|
611
|
-
# Create a hash to keep track of what we've done so far.
|
612
|
-
@done = Hash.new { |hash, key| hash[key] = {} }
|
613
|
-
runners.each do |section|
|
614
|
-
bucket.push section_to_transportable(section, @done, false)
|
615
|
-
end
|
616
|
-
|
617
|
-
objects = bucket.to_type
|
677
|
+
bucket = to_transportable(*sections)
|
618
678
|
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
trans = objects.evaluate
|
626
|
-
trans.ignoretags = true
|
627
|
-
trans.configurator = true
|
628
|
-
trans.evaluate
|
629
|
-
if tags
|
630
|
-
Puppet[:tags] = tags
|
679
|
+
config = bucket.to_catalog
|
680
|
+
config.host_config = false
|
681
|
+
config.apply do |transaction|
|
682
|
+
if failures = transaction.any_failed?
|
683
|
+
raise "Could not configure for running; got %s failure(s)" % failures
|
684
|
+
end
|
631
685
|
end
|
686
|
+
config.clear
|
632
687
|
|
633
|
-
|
634
|
-
|
635
|
-
objects.remove(true)
|
636
|
-
|
637
|
-
objects = nil
|
638
|
-
|
639
|
-
runners.each { |s| @used << s }
|
688
|
+
sections.each { |s| @used << s }
|
689
|
+
@used.uniq
|
640
690
|
end
|
641
691
|
end
|
642
692
|
|
@@ -645,6 +695,47 @@ Generated on #{Time.now}.
|
|
645
695
|
@config.has_key?(param)
|
646
696
|
end
|
647
697
|
|
698
|
+
# Find the correct value using our search path. Optionally accept an environment
|
699
|
+
# in which to search before the other configuration sections.
|
700
|
+
def value(param, environment = nil)
|
701
|
+
param = symbolize(param)
|
702
|
+
environment = symbolize(environment) if environment
|
703
|
+
|
704
|
+
# Short circuit to nil for undefined parameters.
|
705
|
+
return nil unless @config.include?(param)
|
706
|
+
|
707
|
+
# Yay, recursion.
|
708
|
+
self.reparse() unless param == :filetimeout
|
709
|
+
|
710
|
+
# Check the cache first. It needs to be a per-environment
|
711
|
+
# cache so that we don't spread values from one env
|
712
|
+
# to another.
|
713
|
+
if cached = @cache[environment||"none"][param]
|
714
|
+
return cached
|
715
|
+
end
|
716
|
+
|
717
|
+
# See if we can find it within our searchable list of values
|
718
|
+
val = nil
|
719
|
+
each_source(environment) do |source|
|
720
|
+
# Look for the value. We have to test the hash for whether
|
721
|
+
# it exists, because the value might be false.
|
722
|
+
if @values[source].include?(param)
|
723
|
+
val = @values[source][param]
|
724
|
+
break
|
725
|
+
end
|
726
|
+
end
|
727
|
+
|
728
|
+
# If we didn't get a value, use the default
|
729
|
+
val = @config[param].default if val.nil?
|
730
|
+
|
731
|
+
# Convert it if necessary
|
732
|
+
val = convert(val)
|
733
|
+
|
734
|
+
# And cache it
|
735
|
+
@cache[environment||"none"][param] = val
|
736
|
+
return val
|
737
|
+
end
|
738
|
+
|
648
739
|
# Open a file with the appropriate user, group, and mode
|
649
740
|
def write(default, *args)
|
650
741
|
obj = nil
|
@@ -671,7 +762,7 @@ Generated on #{Time.now}.
|
|
671
762
|
|
672
763
|
args << mode
|
673
764
|
|
674
|
-
File.open(obj.
|
765
|
+
File.open(value(obj.name), *args) do |file|
|
675
766
|
yield file
|
676
767
|
end
|
677
768
|
end
|
@@ -715,30 +806,87 @@ Generated on #{Time.now}.
|
|
715
806
|
|
716
807
|
private
|
717
808
|
|
718
|
-
#
|
809
|
+
# Create the transportable objects for users and groups.
|
810
|
+
def add_user_resources(section, obj, done)
|
811
|
+
resources = []
|
812
|
+
[:owner, :group].each do |attr|
|
813
|
+
type = nil
|
814
|
+
if attr == :owner
|
815
|
+
type = :user
|
816
|
+
else
|
817
|
+
type = attr
|
818
|
+
end
|
819
|
+
# If a user and/or group is set, then make sure we're
|
820
|
+
# managing that object
|
821
|
+
if obj.respond_to? attr and name = obj.send(attr)
|
822
|
+
# Skip root or wheel
|
823
|
+
next if %w{root wheel}.include?(name.to_s)
|
824
|
+
|
825
|
+
# Skip owners and groups we've already done, but tag
|
826
|
+
# them with our section if necessary
|
827
|
+
if done[type].include?(name)
|
828
|
+
tags = done[type][name].tags
|
829
|
+
unless tags.include?(section)
|
830
|
+
done[type][name].tags = tags << section
|
831
|
+
end
|
832
|
+
else
|
833
|
+
newobj = Puppet::TransObject.new(name, type.to_s)
|
834
|
+
newobj.tags = ["puppet", "configuration", section]
|
835
|
+
newobj[:ensure] = :present
|
836
|
+
if type == :user
|
837
|
+
newobj[:comment] ||= "%s user" % name
|
838
|
+
end
|
839
|
+
# Set the group appropriately for the user
|
840
|
+
if type == :user
|
841
|
+
newobj[:gid] = Puppet[:group]
|
842
|
+
end
|
843
|
+
done[type][name] = newobj
|
844
|
+
resources << newobj
|
845
|
+
end
|
846
|
+
end
|
847
|
+
end
|
848
|
+
resources
|
849
|
+
end
|
850
|
+
|
851
|
+
# Yield each search source in turn.
|
852
|
+
def each_source(environment)
|
853
|
+
searchpath(environment).each do |source|
|
854
|
+
# Modify the source as necessary.
|
855
|
+
source = self.name if source == :name
|
856
|
+
yield source
|
857
|
+
end
|
858
|
+
end
|
859
|
+
|
860
|
+
# Return all elements that have associated hooks; this is so
|
861
|
+
# we can call them after parsing the configuration file.
|
862
|
+
def settings_with_hooks
|
863
|
+
@config.values.find_all { |setting| setting.respond_to?(:handle) }
|
864
|
+
end
|
865
|
+
|
866
|
+
# Extract extra setting information for files.
|
719
867
|
def extract_fileinfo(string)
|
720
|
-
paramregex = %r{(\w+)\s*=\s*([\w\d]+)}
|
721
868
|
result = {}
|
722
|
-
string.
|
869
|
+
value = string.sub(/\{\s*([^}]+)\s*\}/) do
|
723
870
|
params = $1
|
724
871
|
params.split(/\s*,\s*/).each do |str|
|
725
|
-
if str =~ /^\s*(\w+)\s*=\s*([\w\
|
872
|
+
if str =~ /^\s*(\w+)\s*=\s*([\w\d]+)\s*$/
|
726
873
|
param, value = $1.intern, $2
|
727
874
|
result[param] = value
|
728
875
|
unless [:owner, :mode, :group].include?(param)
|
729
|
-
raise
|
876
|
+
raise ArgumentError, "Invalid file option '%s'" % param
|
730
877
|
end
|
731
878
|
|
732
879
|
if param == :mode and value !~ /^\d+$/
|
733
|
-
raise
|
880
|
+
raise ArgumentError, "File modes must be numbers"
|
734
881
|
end
|
735
882
|
else
|
736
|
-
raise
|
883
|
+
raise ArgumentError, "Could not parse '%s'" % string
|
737
884
|
end
|
738
885
|
end
|
739
|
-
|
740
|
-
return result
|
886
|
+
''
|
741
887
|
end
|
888
|
+
result[:value] = value.sub(/\s*$/, '')
|
889
|
+
return result
|
742
890
|
|
743
891
|
return nil
|
744
892
|
end
|
@@ -760,26 +908,12 @@ Generated on #{Time.now}.
|
|
760
908
|
# support parsing old files with any section, or new files with just two
|
761
909
|
# valid sections.
|
762
910
|
def parse_file(file)
|
763
|
-
text =
|
764
|
-
|
765
|
-
if file.is_a? Puppet::Util::LoadedFile
|
766
|
-
@file = file
|
767
|
-
else
|
768
|
-
@file = Puppet::Util::LoadedFile.new(file)
|
769
|
-
end
|
911
|
+
text = read_file(file)
|
770
912
|
|
771
913
|
# Create a timer so that this file will get checked automatically
|
772
914
|
# and reparsed if necessary.
|
773
915
|
settimer()
|
774
916
|
|
775
|
-
begin
|
776
|
-
text = File.read(@file.file)
|
777
|
-
rescue Errno::ENOENT
|
778
|
-
raise Puppet::Error, "No such file %s" % file
|
779
|
-
rescue Errno::EACCES
|
780
|
-
raise Puppet::Error, "Permission denied to file %s" % file
|
781
|
-
end
|
782
|
-
|
783
917
|
result = Hash.new { |names, name|
|
784
918
|
names[name] = {}
|
785
919
|
}
|
@@ -792,13 +926,13 @@ Generated on #{Time.now}.
|
|
792
926
|
text.split(/\n/).each { |line|
|
793
927
|
count += 1
|
794
928
|
case line
|
795
|
-
when /^\[(\w+)\]$/:
|
929
|
+
when /^\s*\[(\w+)\]$/:
|
796
930
|
section = $1.intern # Section names
|
797
931
|
# Add a meta section
|
798
932
|
result[section][:_meta] ||= {}
|
799
933
|
when /^\s*#/: next # Skip comments
|
800
934
|
when /^\s*$/: next # Skip blanks
|
801
|
-
when /^\s*(\w+)\s*=\s*(
|
935
|
+
when /^\s*(\w+)\s*=\s*(.*)$/: # settings
|
802
936
|
var = $1.intern
|
803
937
|
|
804
938
|
# We don't want to munge modes, because they're specified in octal, so we'll
|
@@ -812,6 +946,8 @@ Generated on #{Time.now}.
|
|
812
946
|
# Check to see if this is a file argument and it has extra options
|
813
947
|
begin
|
814
948
|
if value.is_a?(String) and options = extract_fileinfo(value)
|
949
|
+
value = options[:value]
|
950
|
+
options.delete(:value)
|
815
951
|
result[section][:_meta][var] = options
|
816
952
|
end
|
817
953
|
result[section][var] = value
|
@@ -831,60 +967,55 @@ Generated on #{Time.now}.
|
|
831
967
|
return result
|
832
968
|
end
|
833
969
|
|
834
|
-
#
|
835
|
-
def
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
next
|
841
|
-
end
|
842
|
-
if @config[param].setbycli
|
843
|
-
Puppet.debug "Ignoring %s set by config file; overridden by cli" % param
|
844
|
-
else
|
845
|
-
self[param] = value
|
846
|
-
end
|
970
|
+
# Read the file in.
|
971
|
+
def read_file(file)
|
972
|
+
if file.is_a? Puppet::Util::LoadedFile
|
973
|
+
@file = file
|
974
|
+
else
|
975
|
+
@file = Puppet::Util::LoadedFile.new(file)
|
847
976
|
end
|
848
977
|
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
978
|
+
begin
|
979
|
+
return File.read(@file.file)
|
980
|
+
rescue Errno::ENOENT
|
981
|
+
raise ArgumentError, "No such file %s" % file
|
982
|
+
rescue Errno::EACCES
|
983
|
+
raise ArgumentError, "Permission denied to file %s" % file
|
984
|
+
end
|
985
|
+
end
|
986
|
+
|
987
|
+
# Set file metadata.
|
988
|
+
def set_metadata(meta)
|
989
|
+
meta.each do |var, values|
|
990
|
+
values.each do |param, value|
|
991
|
+
@config[var].send(param.to_s + "=", value)
|
854
992
|
end
|
855
993
|
end
|
856
994
|
end
|
857
995
|
|
858
996
|
# The base element type.
|
859
997
|
class CElement
|
860
|
-
attr_accessor :name, :section, :default, :parent, :setbycli
|
861
|
-
attr_reader :desc
|
998
|
+
attr_accessor :name, :section, :default, :parent, :setbycli, :call_on_define
|
999
|
+
attr_reader :desc, :short
|
862
1000
|
|
863
1001
|
# Unset any set value.
|
864
1002
|
def clear
|
865
1003
|
@value = nil
|
866
1004
|
end
|
867
1005
|
|
868
|
-
# Do variable interpolation on the value.
|
869
|
-
def convert(value)
|
870
|
-
return value unless value
|
871
|
-
return value unless value.is_a? String
|
872
|
-
newval = value.gsub(/\$(\w+)|\$\{(\w+)\}/) do |value|
|
873
|
-
varname = $2 || $1
|
874
|
-
if pval = @parent[varname]
|
875
|
-
pval
|
876
|
-
else
|
877
|
-
raise Puppet::DevError, "Could not find value for %s" % parent
|
878
|
-
end
|
879
|
-
end
|
880
|
-
|
881
|
-
return newval
|
882
|
-
end
|
883
|
-
|
884
1006
|
def desc=(value)
|
885
1007
|
@desc = value.gsub(/^\s*/, '')
|
886
1008
|
end
|
887
1009
|
|
1010
|
+
# get the arguments in getopt format
|
1011
|
+
def getopt_args
|
1012
|
+
if short
|
1013
|
+
[["--#{name}", "-#{short}", GetoptLong::REQUIRED_ARGUMENT]]
|
1014
|
+
else
|
1015
|
+
[["--#{name}", GetoptLong::REQUIRED_ARGUMENT]]
|
1016
|
+
end
|
1017
|
+
end
|
1018
|
+
|
888
1019
|
def hook=(block)
|
889
1020
|
meta_def :handle, &block
|
890
1021
|
end
|
@@ -929,6 +1060,14 @@ Generated on #{Time.now}.
|
|
929
1060
|
end
|
930
1061
|
end
|
931
1062
|
|
1063
|
+
# short name for the celement
|
1064
|
+
def short=(value)
|
1065
|
+
if value.to_s.length != 1
|
1066
|
+
raise ArgumentError, "Short names can only be one character."
|
1067
|
+
end
|
1068
|
+
@short = value.to_s
|
1069
|
+
end
|
1070
|
+
|
932
1071
|
# Convert the object to a config statement.
|
933
1072
|
def to_config
|
934
1073
|
str = @desc.gsub(/^/, "# ") + "\n"
|
@@ -938,13 +1077,13 @@ Generated on #{Time.now}.
|
|
938
1077
|
str += "# The default value is '%s'.\n" % @default
|
939
1078
|
end
|
940
1079
|
|
941
|
-
line = "%s = %s" % [@name, self.value]
|
942
|
-
|
943
1080
|
# If the value has not been overridden, then print it out commented
|
944
1081
|
# and unconverted, so it's clear that that's the default and how it
|
945
1082
|
# works.
|
946
|
-
|
947
|
-
|
1083
|
+
value = @parent.value(self.name)
|
1084
|
+
|
1085
|
+
if value != @default
|
1086
|
+
line = "%s = %s" % [@name, value]
|
948
1087
|
else
|
949
1088
|
line = "# %s = %s" % [@name, @default]
|
950
1089
|
end
|
@@ -956,37 +1095,7 @@ Generated on #{Time.now}.
|
|
956
1095
|
|
957
1096
|
# Retrieves the value, or if it's not set, retrieves the default.
|
958
1097
|
def value
|
959
|
-
|
960
|
-
if defined? @value and ! @value.nil?
|
961
|
-
retval = @value
|
962
|
-
elsif defined? @default
|
963
|
-
retval = @default
|
964
|
-
else
|
965
|
-
return nil
|
966
|
-
end
|
967
|
-
|
968
|
-
if retval.is_a? String
|
969
|
-
return convert(retval)
|
970
|
-
else
|
971
|
-
return retval
|
972
|
-
end
|
973
|
-
end
|
974
|
-
|
975
|
-
# Set the value.
|
976
|
-
def value=(value)
|
977
|
-
if respond_to?(:validate)
|
978
|
-
validate(value)
|
979
|
-
end
|
980
|
-
|
981
|
-
if respond_to?(:munge)
|
982
|
-
@value = munge(value)
|
983
|
-
else
|
984
|
-
@value = value
|
985
|
-
end
|
986
|
-
|
987
|
-
if respond_to?(:handle)
|
988
|
-
handle(@value)
|
989
|
-
end
|
1098
|
+
@parent.value(self.name)
|
990
1099
|
end
|
991
1100
|
end
|
992
1101
|
|
@@ -997,7 +1106,7 @@ Generated on #{Time.now}.
|
|
997
1106
|
|
998
1107
|
def group
|
999
1108
|
if defined? @group
|
1000
|
-
return convert(@group)
|
1109
|
+
return @parent.convert(@group)
|
1001
1110
|
else
|
1002
1111
|
return nil
|
1003
1112
|
end
|
@@ -1005,7 +1114,7 @@ Generated on #{Time.now}.
|
|
1005
1114
|
|
1006
1115
|
def owner
|
1007
1116
|
if defined? @owner
|
1008
|
-
return convert(@owner)
|
1117
|
+
return @parent.convert(@owner)
|
1009
1118
|
else
|
1010
1119
|
return nil
|
1011
1120
|
end
|
@@ -1014,6 +1123,11 @@ Generated on #{Time.now}.
|
|
1014
1123
|
# Set the type appropriately. Yep, a hack. This supports either naming
|
1015
1124
|
# the variable 'dir', or adding a slash at the end.
|
1016
1125
|
def munge(value)
|
1126
|
+
# If it's not a fully qualified path...
|
1127
|
+
if value.is_a?(String) and value !~ /^\$/ and value !~ /^\//
|
1128
|
+
# Make it one
|
1129
|
+
value = File.join(Dir.getwd, value)
|
1130
|
+
end
|
1017
1131
|
if value.to_s =~ /\/$/
|
1018
1132
|
@type = :directory
|
1019
1133
|
return value.sub(/\/$/, '')
|
@@ -1023,7 +1137,7 @@ Generated on #{Time.now}.
|
|
1023
1137
|
|
1024
1138
|
# Return the appropriate type.
|
1025
1139
|
def type
|
1026
|
-
value = self.
|
1140
|
+
value = @parent.value(self.name)
|
1027
1141
|
if @name.to_s =~ /dir/
|
1028
1142
|
return :directory
|
1029
1143
|
elsif value.to_s =~ /\/$/
|
@@ -1036,17 +1150,18 @@ Generated on #{Time.now}.
|
|
1036
1150
|
end
|
1037
1151
|
|
1038
1152
|
# Convert the object to a TransObject instance.
|
1039
|
-
# FIXME There's no dependency system in place right now; if you use
|
1040
|
-
# a section that requires another section, there's nothing done to
|
1041
|
-
# correct that for you, at the moment.
|
1042
1153
|
def to_transportable
|
1043
1154
|
type = self.type
|
1044
1155
|
return nil unless type
|
1045
|
-
path =
|
1156
|
+
path = @parent.value(self.name).split(File::SEPARATOR)
|
1046
1157
|
path.shift # remove the leading nil
|
1047
1158
|
|
1048
1159
|
objects = []
|
1049
|
-
|
1160
|
+
path = self.value
|
1161
|
+
|
1162
|
+
# Skip plain files that don't exist, since we won't be managing them anyway.
|
1163
|
+
return nil unless self.name.to_s =~ /dir$/ or File.exist?(path) or self.create
|
1164
|
+
obj = Puppet::TransObject.new(path, "file")
|
1050
1165
|
|
1051
1166
|
# Only create directories, or files that are specifically marked to
|
1052
1167
|
# create.
|
@@ -1055,14 +1170,14 @@ Generated on #{Time.now}.
|
|
1055
1170
|
end
|
1056
1171
|
[:mode].each { |var|
|
1057
1172
|
if value = self.send(var)
|
1058
|
-
# Don't
|
1173
|
+
# Don't bother converting the mode, since the file type
|
1059
1174
|
# can handle it any old way.
|
1060
1175
|
obj[var] = value
|
1061
1176
|
end
|
1062
1177
|
}
|
1063
1178
|
|
1064
1179
|
# Only chown or chgrp when root
|
1065
|
-
if Puppet
|
1180
|
+
if Puppet.features.root?
|
1066
1181
|
[:group, :owner].each { |var|
|
1067
1182
|
if value = self.send(var)
|
1068
1183
|
obj[var] = value
|
@@ -1092,7 +1207,7 @@ Generated on #{Time.now}.
|
|
1092
1207
|
name = $1
|
1093
1208
|
unless @parent.include?(name)
|
1094
1209
|
raise ArgumentError,
|
1095
|
-
"
|
1210
|
+
"Settings parameter '%s' is undefined" %
|
1096
1211
|
name
|
1097
1212
|
end
|
1098
1213
|
}
|
@@ -1101,16 +1216,25 @@ Generated on #{Time.now}.
|
|
1101
1216
|
|
1102
1217
|
# A simple boolean.
|
1103
1218
|
class CBoolean < CElement
|
1219
|
+
# get the arguments in getopt format
|
1220
|
+
def getopt_args
|
1221
|
+
if short
|
1222
|
+
[["--#{name}", "-#{short}", GetoptLong::NO_ARGUMENT],
|
1223
|
+
["--no-#{name}", GetoptLong::NO_ARGUMENT]]
|
1224
|
+
else
|
1225
|
+
[["--#{name}", GetoptLong::NO_ARGUMENT],
|
1226
|
+
["--no-#{name}", GetoptLong::NO_ARGUMENT]]
|
1227
|
+
end
|
1228
|
+
end
|
1229
|
+
|
1104
1230
|
def munge(value)
|
1105
1231
|
case value
|
1106
1232
|
when true, "true": return true
|
1107
1233
|
when false, "false": return false
|
1108
1234
|
else
|
1109
|
-
raise
|
1235
|
+
raise ArgumentError, "Invalid value '%s' for %s" %
|
1110
1236
|
[value.inspect, @name]
|
1111
1237
|
end
|
1112
1238
|
end
|
1113
1239
|
end
|
1114
1240
|
end
|
1115
|
-
|
1116
|
-
# $Id: config.rb 2743 2007-08-04 00:36:47Z luke $
|