puppet 0.24.9 → 0.25.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 +18680 -1241
- data/CHANGELOG.old +1705 -0
- data/LICENSE +2 -2
- data/README +1 -1
- data/README.queueing +126 -0
- data/README.rst +4 -4
- data/Rakefile +62 -216
- data/bin/filebucket +6 -117
- data/bin/pi +50 -0
- data/bin/puppet +7 -188
- data/bin/puppetdoc +7 -198
- data/bin/ralsh +4 -191
- data/conf/auth.conf +94 -0
- data/conf/gentoo/init.d/puppetmaster +30 -30
- data/conf/osx/PackageInfo.plist +30 -30
- data/conf/osx/createpackage.sh +23 -18
- data/conf/osx/preflight +8 -0
- data/conf/puppet-queue.conf +10 -0
- data/conf/redhat/client.init +52 -41
- data/conf/redhat/logrotate +1 -0
- data/conf/redhat/puppet.spec +74 -36
- data/conf/redhat/rundir-perms.patch +28 -0
- data/conf/redhat/server.init +48 -43
- data/conf/redhat/server.sysconfig +4 -4
- data/conf/solaris/smf/puppetd.xml +53 -53
- data/conf/solaris/smf/puppetmasterd.xml +53 -53
- data/conf/solaris/smf/svc-puppetd +4 -4
- data/conf/solaris/smf/svc-puppetmasterd +3 -3
- data/conf/suse/client.init +4 -4
- data/conf/suse/puppet.spec +14 -14
- data/conf/suse/server.init +17 -17
- data/examples/etc/init.d/sleeper +8 -8
- data/examples/mac_dscl.pp +2 -2
- data/examples/mac_dscl_revert.pp +1 -1
- data/examples/mcx_dock_default.pp +108 -108
- data/examples/mcx_dock_full.pp +108 -108
- data/examples/mcx_nogroup.pp +108 -108
- data/examples/modules/sample-module/lib/puppet/parser/functions/hostname_to_dn.rb +5 -5
- data/examples/modules/sample-module/manifests/init.pp +2 -2
- data/examples/relationships +1 -1
- data/ext/autotest/config +6 -6
- data/ext/bin/sleeper +12 -12
- data/ext/dbfix.sql +21 -21
- data/ext/emacs/puppet-mode.el +42 -41
- data/ext/extlookup.rb +183 -0
- data/ext/ldap/puppet.schema +2 -1
- data/ext/logcheck/puppet +1 -1
- data/ext/module_puppet +7 -7
- data/ext/nagios/check_puppet.rb +83 -83
- data/ext/nagios/naggen +302 -0
- data/ext/puppet-test +61 -18
- data/ext/puppetlisten/puppetlisten.rb +76 -0
- data/ext/puppetlisten/puppetrun.rb +39 -0
- data/ext/puppetstoredconfigclean.rb +29 -29
- data/ext/rack/README +73 -0
- data/ext/rack/files/apache2.conf +38 -0
- data/ext/rack/files/config.ru +18 -0
- data/ext/rack/manifest.pp +59 -0
- data/ext/vim/syntax/puppet.vim +54 -35
- data/install.rb +37 -26
- data/lib/puppet.rb +15 -227
- data/lib/puppet/agent.rb +134 -0
- data/lib/puppet/agent/locker.rb +42 -0
- data/lib/puppet/agent/runner.rb +65 -0
- data/lib/puppet/application.rb +313 -0
- data/lib/puppet/application/filebucket.rb +87 -0
- data/lib/puppet/application/pi.rb +214 -0
- data/lib/puppet/application/puppet.rb +177 -0
- data/lib/puppet/application/puppetca.rb +71 -0
- data/lib/puppet/application/puppetd.rb +256 -0
- data/lib/puppet/application/puppetdoc.rb +222 -0
- data/lib/puppet/application/puppetmasterd.rb +168 -0
- data/lib/puppet/application/puppetqd.rb +96 -0
- data/lib/puppet/application/puppetrun.rb +219 -0
- data/lib/puppet/application/ralsh.rb +168 -0
- data/lib/puppet/configurer.rb +177 -0
- data/lib/puppet/configurer/downloader.rb +79 -0
- data/lib/puppet/configurer/fact_handler.rb +68 -0
- data/lib/puppet/configurer/plugin_handler.rb +26 -0
- data/lib/puppet/daemon.rb +78 -28
- data/lib/puppet/defaults.rb +239 -166
- data/lib/puppet/dsl.rb +7 -7
- data/lib/puppet/external/dot.rb +271 -271
- data/lib/puppet/external/event-loop/better-definers.rb +298 -298
- data/lib/puppet/external/event-loop/event-loop.rb +274 -274
- data/lib/puppet/external/event-loop/signal-system.rb +163 -163
- data/lib/puppet/external/lock.rb +1 -1
- data/lib/puppet/external/nagios.rb +20 -20
- data/lib/puppet/external/nagios/base.rb +3 -3
- data/lib/puppet/external/nagios/grammar.ry +185 -0
- data/lib/puppet/external/nagios/makefile +9 -0
- data/lib/puppet/external/nagios/parser.rb +1 -1
- data/lib/puppet/feature/json.rb +2 -0
- data/lib/puppet/feature/rack.rb +24 -0
- data/lib/puppet/feature/rails.rb +23 -33
- data/lib/puppet/feature/rubygems.rb +6 -0
- data/lib/puppet/feature/stomp.rb +6 -0
- data/lib/puppet/file_serving/{file_base.rb → base.rb} +10 -9
- data/lib/puppet/file_serving/configuration.rb +61 -61
- data/lib/puppet/file_serving/configuration/parser.rb +24 -29
- data/lib/puppet/file_serving/content.rb +26 -11
- data/lib/puppet/file_serving/fileset.rb +54 -19
- data/lib/puppet/file_serving/indirection_hooks.rb +12 -24
- data/lib/puppet/file_serving/metadata.rb +8 -8
- data/lib/puppet/file_serving/mount.rb +9 -151
- data/lib/puppet/file_serving/mount/file.rb +126 -0
- data/lib/puppet/file_serving/mount/modules.rb +25 -0
- data/lib/puppet/file_serving/mount/plugins.rb +27 -0
- data/lib/puppet/file_serving/terminus_helper.rb +9 -4
- data/lib/puppet/indirector.rb +6 -4
- data/lib/puppet/indirector/active_record.rb +28 -0
- data/lib/puppet/indirector/catalog/active_record.rb +36 -0
- data/lib/puppet/indirector/catalog/compiler.rb +50 -24
- data/lib/puppet/indirector/catalog/queue.rb +5 -0
- data/lib/puppet/indirector/catalog/rest.rb +6 -0
- data/lib/puppet/indirector/catalog/yaml.rb +2 -4
- data/lib/puppet/indirector/certificate/ca.rb +9 -0
- data/lib/puppet/indirector/certificate/file.rb +9 -0
- data/lib/puppet/indirector/certificate/rest.rb +9 -0
- data/lib/puppet/indirector/certificate_request/ca.rb +14 -0
- data/lib/puppet/indirector/certificate_request/file.rb +8 -0
- data/lib/puppet/indirector/certificate_request/rest.rb +9 -0
- data/lib/puppet/indirector/certificate_revocation_list/ca.rb +8 -0
- data/lib/puppet/indirector/certificate_revocation_list/file.rb +8 -0
- data/lib/puppet/indirector/certificate_revocation_list/rest.rb +9 -0
- data/lib/puppet/indirector/direct_file_server.rb +4 -8
- data/lib/puppet/indirector/exec.rb +2 -6
- data/lib/puppet/indirector/facts/active_record.rb +36 -0
- data/lib/puppet/indirector/facts/facter.rb +30 -22
- data/lib/puppet/indirector/facts/rest.rb +6 -0
- data/lib/puppet/indirector/file.rb +1 -0
- data/lib/puppet/indirector/file_content/rest.rb +0 -1
- data/lib/puppet/indirector/file_metadata/file.rb +2 -2
- data/lib/puppet/indirector/file_metadata/rest.rb +0 -1
- data/lib/puppet/indirector/file_server.rb +31 -18
- data/lib/puppet/indirector/indirection.rb +46 -33
- data/lib/puppet/indirector/key/ca.rb +12 -0
- data/lib/puppet/indirector/key/file.rb +42 -0
- data/lib/puppet/indirector/node/active_record.rb +13 -0
- data/lib/puppet/indirector/node/ldap.rb +1 -1
- data/lib/puppet/indirector/queue.rb +83 -0
- data/lib/puppet/indirector/report/processor.rb +1 -1
- data/lib/puppet/indirector/report/rest.rb +7 -0
- data/lib/puppet/indirector/request.rb +158 -15
- data/lib/puppet/indirector/rest.rb +74 -36
- data/lib/puppet/indirector/runner/rest.rb +7 -0
- data/lib/puppet/indirector/ssl_file.rb +174 -0
- data/lib/puppet/indirector/terminus.rb +4 -4
- data/lib/puppet/indirector/yaml.rb +1 -1
- data/lib/puppet/metatype/manager.rb +3 -3
- data/lib/puppet/module.rb +99 -124
- data/lib/puppet/network/authconfig.rb +57 -42
- data/lib/puppet/network/authstore.rb +58 -10
- data/lib/puppet/network/client.rb +0 -2
- data/lib/puppet/network/client/ca.rb +1 -1
- data/lib/puppet/network/client/dipper.rb +7 -2
- data/lib/puppet/network/format.rb +123 -0
- data/lib/puppet/network/format_handler.rb +156 -0
- data/lib/puppet/network/formats.rb +123 -0
- data/lib/puppet/network/handler/filebucket.rb +1 -1
- data/lib/puppet/network/handler/fileserver.rb +43 -35
- data/lib/puppet/network/handler/master.rb +4 -4
- data/lib/puppet/network/handler/report.rb +1 -1
- data/lib/puppet/network/handler/resource.rb +16 -20
- data/lib/puppet/network/handler/runner.rb +9 -42
- data/lib/puppet/network/http.rb +4 -4
- data/lib/puppet/network/http/api.rb +4 -0
- data/lib/puppet/network/http/api/v1.rb +65 -0
- data/lib/puppet/network/http/handler.rb +163 -56
- data/lib/puppet/network/http/mongrel.rb +19 -15
- data/lib/puppet/network/http/mongrel/rest.rb +35 -17
- data/lib/puppet/network/http/rack.rb +62 -0
- data/lib/puppet/network/http/rack/httphandler.rb +34 -0
- data/lib/puppet/network/http/rack/rest.rb +79 -0
- data/lib/puppet/network/http/rack/xmlrpc.rb +65 -0
- data/lib/puppet/network/http/webrick.rb +89 -16
- data/lib/puppet/network/http/webrick/rest.rb +24 -11
- data/lib/puppet/network/http_pool.rb +28 -29
- data/lib/puppet/network/http_server/mongrel.rb +8 -10
- data/lib/puppet/network/http_server/webrick.rb +1 -3
- data/lib/puppet/network/rest_authconfig.rb +89 -0
- data/lib/puppet/network/rest_authorization.rb +25 -0
- data/lib/puppet/network/rights.rb +230 -27
- data/lib/puppet/network/server.rb +133 -31
- data/lib/puppet/network/xmlrpc/client.rb +5 -5
- data/lib/puppet/network/xmlrpc/webrick_servlet.rb +6 -6
- data/lib/puppet/node.rb +28 -21
- data/lib/puppet/node/environment.rb +48 -0
- data/lib/puppet/node/facts.rb +21 -0
- data/lib/puppet/parameter.rb +291 -219
- data/lib/puppet/parser/ast.rb +1 -0
- data/lib/puppet/parser/ast/astarray.rb +5 -1
- data/lib/puppet/parser/ast/boolean_operator.rb +3 -3
- data/lib/puppet/parser/ast/caseopt.rb +10 -0
- data/lib/puppet/parser/ast/casestatement.rb +12 -27
- data/lib/puppet/parser/ast/collection.rb +31 -0
- data/lib/puppet/parser/ast/collexpr.rb +18 -11
- data/lib/puppet/parser/ast/comparison_operator.rb +1 -1
- data/lib/puppet/parser/ast/definition.rb +6 -2
- data/lib/puppet/parser/ast/function.rb +7 -2
- data/lib/puppet/parser/ast/ifstatement.rb +11 -6
- data/lib/puppet/parser/ast/leaf.rb +106 -3
- data/lib/puppet/parser/ast/match_operator.rb +31 -0
- data/lib/puppet/parser/ast/node.rb +10 -6
- data/lib/puppet/parser/ast/resource_defaults.rb +2 -2
- data/lib/puppet/parser/ast/resource_override.rb +1 -1
- data/lib/puppet/parser/ast/resource_reference.rb +11 -3
- data/lib/puppet/parser/ast/selector.rb +14 -32
- data/lib/puppet/parser/ast/vardef.rb +1 -1
- data/lib/puppet/parser/collector.rb +67 -15
- data/lib/puppet/parser/compiler.rb +21 -53
- data/lib/puppet/parser/files.rb +92 -0
- data/lib/puppet/parser/functions.rb +3 -3
- data/lib/puppet/parser/functions/defined.rb +3 -3
- data/lib/puppet/parser/functions/fqdn_rand.rb +3 -3
- data/lib/puppet/parser/functions/inline_template.rb +4 -4
- data/lib/puppet/parser/functions/regsubst.rb +37 -35
- data/lib/puppet/parser/functions/require.rb +34 -0
- data/lib/puppet/parser/functions/shellquote.rb +41 -0
- data/lib/puppet/parser/functions/split.rb +29 -0
- data/lib/puppet/parser/functions/sprintf.rb +6 -6
- data/lib/puppet/parser/functions/template.rb +4 -4
- data/lib/puppet/parser/functions/versioncmp.rb +22 -1
- data/lib/puppet/parser/grammar.ra +812 -0
- data/lib/puppet/parser/interpreter.rb +4 -4
- data/lib/puppet/parser/lexer.rb +44 -15
- data/lib/puppet/parser/loaded_code.rb +115 -0
- data/lib/puppet/parser/makefile +8 -0
- data/lib/puppet/parser/parser.rb +1080 -928
- data/lib/puppet/parser/parser_support.rb +118 -96
- data/lib/puppet/parser/resource.rb +56 -126
- data/lib/puppet/parser/resource/param.rb +2 -76
- data/lib/puppet/parser/resource/reference.rb +15 -8
- data/lib/puppet/parser/scope.rb +68 -35
- data/lib/puppet/parser/templatewrapper.rb +8 -8
- data/lib/puppet/parser/yaml_trimmer.rb +11 -0
- data/lib/puppet/property.rb +69 -124
- data/lib/puppet/property/list.rb +3 -3
- data/lib/puppet/provider.rb +5 -5
- data/lib/puppet/provider/augeas/augeas.rb +119 -118
- data/lib/puppet/provider/computer/computer.rb +3 -3
- data/lib/puppet/provider/confine/variable.rb +1 -1
- data/lib/puppet/provider/cron/crontab.rb +8 -7
- data/lib/puppet/provider/group/directoryservice.rb +2 -2
- data/lib/puppet/provider/group/groupadd.rb +1 -1
- data/lib/puppet/provider/group/ldap.rb +3 -3
- data/lib/puppet/provider/group/pw.rb +1 -1
- data/lib/puppet/provider/host/parsed.rb +3 -3
- data/lib/puppet/provider/ldap.rb +1 -3
- data/lib/puppet/provider/macauthorization/macauthorization.rb +62 -55
- data/lib/puppet/provider/mailalias/aliases.rb +9 -1
- data/lib/puppet/provider/maillist/mailman.rb +8 -4
- data/lib/puppet/provider/mcx/mcxcontent.rb +11 -11
- data/lib/puppet/provider/mount/parsed.rb +2 -2
- data/lib/puppet/provider/nameservice.rb +6 -6
- data/lib/puppet/provider/nameservice/directoryservice.rb +83 -87
- data/lib/puppet/provider/package/appdmg.rb +10 -9
- data/lib/puppet/provider/package/apple.rb +1 -3
- data/lib/puppet/provider/package/apt.rb +5 -5
- data/lib/puppet/provider/package/aptitude.rb +1 -1
- data/lib/puppet/provider/package/aptrpm.rb +1 -1
- data/lib/puppet/provider/package/darwinport.rb +1 -1
- data/lib/puppet/provider/package/dpkg.rb +2 -2
- data/lib/puppet/provider/package/fink.rb +6 -6
- data/lib/puppet/provider/package/freebsd.rb +1 -1
- data/lib/puppet/provider/package/gem.rb +2 -2
- data/lib/puppet/provider/package/hpux.rb +5 -5
- data/lib/puppet/provider/package/pkgdmg.rb +30 -22
- data/lib/puppet/provider/package/portage.rb +1 -1
- data/lib/puppet/provider/package/ports.rb +1 -1
- data/lib/puppet/provider/package/rpm.rb +5 -5
- data/lib/puppet/provider/package/rug.rb +1 -1
- data/lib/puppet/provider/package/sun.rb +7 -7
- data/lib/puppet/provider/package/up2date.rb +1 -1
- data/lib/puppet/provider/package/yum.rb +2 -2
- data/lib/puppet/provider/package/yumhelper.py +2 -2
- data/lib/puppet/provider/port/parsed.rb +1 -1
- data/lib/puppet/provider/selmodule/semodule.rb +3 -3
- data/lib/puppet/provider/service/base.rb +21 -12
- data/lib/puppet/provider/service/daemontools.rb +86 -49
- data/lib/puppet/provider/service/debian.rb +20 -12
- data/lib/puppet/provider/service/freebsd.rb +5 -5
- data/lib/puppet/provider/service/gentoo.rb +2 -2
- data/lib/puppet/provider/service/init.rb +21 -33
- data/lib/puppet/provider/service/launchd.rb +120 -48
- data/lib/puppet/provider/service/redhat.rb +12 -21
- data/lib/puppet/provider/service/runit.rb +19 -9
- data/lib/puppet/provider/service/smf.rb +49 -34
- data/lib/puppet/provider/ssh_authorized_key/parsed.rb +34 -0
- data/lib/puppet/provider/sshkey/parsed.rb +2 -2
- data/lib/puppet/provider/user/directoryservice.rb +12 -29
- data/lib/puppet/provider/user/hpux.rb +3 -3
- data/lib/puppet/provider/user/ldap.rb +2 -2
- data/lib/puppet/provider/zfs/solaris.rb +1 -1
- data/lib/puppet/provider/zone/solaris.rb +4 -4
- data/lib/puppet/provider/zpool/solaris.rb +3 -3
- data/lib/puppet/rails.rb +9 -9
- data/lib/puppet/rails/benchmark.rb +69 -0
- data/lib/puppet/rails/database/001_add_created_at_to_all_tables.rb +5 -5
- data/lib/puppet/rails/database/002_remove_duplicated_index_on_all_tables.rb +2 -2
- data/lib/puppet/rails/database/003_add_environment_to_host.rb +1 -1
- data/lib/puppet/rails/database/schema.rb +8 -8
- data/lib/puppet/rails/fact_value.rb +1 -1
- data/lib/puppet/rails/host.rb +211 -93
- data/lib/puppet/rails/param_name.rb +5 -1
- data/lib/puppet/rails/param_value.rb +29 -2
- data/lib/puppet/rails/puppet_tag.rb +5 -0
- data/lib/puppet/rails/resource.rb +120 -20
- data/lib/puppet/rails/resource_tag.rb +1 -1
- data/lib/puppet/rails/source_file.rb +1 -1
- data/lib/puppet/reference/configuration.rb +14 -14
- data/lib/puppet/reference/function.rb +1 -1
- data/lib/puppet/reference/metaparameter.rb +48 -0
- data/lib/puppet/reference/providers.rb +6 -6
- data/lib/puppet/reference/type.rb +1 -37
- data/lib/puppet/relationship.rb +57 -30
- data/lib/puppet/reports/rrdgraph.rb +4 -4
- data/lib/puppet/reports/store.rb +3 -3
- data/lib/puppet/reports/tagmail.rb +15 -15
- data/lib/puppet/resource.rb +265 -0
- data/lib/puppet/{node → resource}/catalog.rb +188 -112
- data/lib/puppet/{resource_reference.rb → resource/reference.rb} +46 -24
- data/lib/puppet/simple_graph.rb +165 -27
- data/lib/puppet/ssl.rb +7 -0
- data/lib/puppet/ssl/base.rb +62 -0
- data/lib/puppet/ssl/certificate.rb +34 -0
- data/lib/puppet/ssl/certificate_authority.rb +298 -0
- data/lib/puppet/ssl/certificate_authority/interface.rb +118 -0
- data/lib/puppet/ssl/certificate_factory.rb +145 -0
- data/lib/puppet/ssl/certificate_request.rb +51 -0
- data/lib/puppet/ssl/certificate_revocation_list.rb +86 -0
- data/lib/puppet/ssl/host.rb +271 -0
- data/lib/puppet/ssl/inventory.rb +52 -0
- data/lib/puppet/ssl/key.rb +56 -0
- data/lib/puppet/sslcertificates.rb +6 -6
- data/lib/puppet/sslcertificates/ca.rb +15 -15
- data/lib/puppet/sslcertificates/certificate.rb +4 -4
- data/lib/puppet/sslcertificates/inventory.rb +3 -3
- data/lib/puppet/transaction.rb +113 -139
- data/lib/puppet/transaction/change.rb +6 -6
- data/lib/puppet/transaction/event.rb +1 -1
- data/lib/puppet/transaction/report.rb +7 -1
- data/lib/puppet/transportable.rb +28 -28
- data/lib/puppet/type.rb +263 -688
- data/lib/puppet/type/augeas.rb +3 -2
- data/lib/puppet/type/component.rb +28 -95
- data/lib/puppet/type/computer.rb +10 -10
- data/lib/puppet/type/cron.rb +19 -14
- data/lib/puppet/type/exec.rb +21 -20
- data/lib/puppet/type/file.rb +306 -633
- data/lib/puppet/type/file/checksum.rb +10 -11
- data/lib/puppet/type/file/content.rb +83 -22
- data/lib/puppet/type/file/ensure.rb +15 -9
- data/lib/puppet/type/file/group.rb +7 -1
- data/lib/puppet/type/file/mode.rb +1 -1
- data/lib/puppet/type/file/owner.rb +9 -3
- data/lib/puppet/type/file/selcontext.rb +4 -4
- data/lib/puppet/type/file/source.rb +78 -179
- data/lib/puppet/type/file/target.rb +3 -3
- data/lib/puppet/type/file/type.rb +2 -2
- data/lib/puppet/type/filebucket.rb +33 -54
- data/lib/puppet/type/group.rb +8 -8
- data/lib/puppet/type/host.rb +7 -7
- data/lib/puppet/type/k5login.rb +2 -2
- data/lib/puppet/type/macauthorization.rb +77 -52
- data/lib/puppet/type/mailalias.rb +2 -2
- data/lib/puppet/type/maillist.rb +2 -2
- data/lib/puppet/type/mcx.rb +3 -3
- data/lib/puppet/type/mount.rb +16 -11
- data/lib/puppet/type/notify.rb +4 -4
- data/lib/puppet/type/package.rb +6 -28
- data/lib/puppet/type/port.rb +1 -1
- data/lib/puppet/type/resources.rb +19 -19
- data/lib/puppet/type/schedule.rb +18 -20
- data/lib/puppet/type/selmodule.rb +1 -1
- data/lib/puppet/type/service.rb +11 -7
- data/lib/puppet/type/ssh_authorized_key.rb +26 -9
- data/lib/puppet/type/sshkey.rb +2 -2
- data/lib/puppet/type/tidy.rb +285 -289
- data/lib/puppet/type/user.rb +9 -7
- data/lib/puppet/type/yumrepo.rb +17 -16
- data/lib/puppet/type/zone.rb +8 -7
- data/lib/puppet/util.rb +11 -36
- data/lib/puppet/util/autoload.rb +31 -19
- data/lib/puppet/util/autoload/file_cache.rb +115 -0
- data/lib/puppet/util/backups.rb +86 -0
- data/lib/puppet/util/cacher.rb +135 -0
- data/lib/puppet/util/checksums.rb +11 -1
- data/lib/puppet/util/classgen.rb +1 -1
- data/lib/puppet/util/config_store.rb +2 -2
- data/lib/puppet/util/constant_inflector.rb +1 -1
- data/lib/puppet/util/diff.rb +2 -2
- data/lib/puppet/util/docs.rb +9 -3
- data/lib/puppet/util/execution.rb +1 -1
- data/lib/puppet/util/feature.rb +27 -20
- data/lib/puppet/util/fileparsing.rb +3 -3
- data/lib/puppet/util/filetype.rb +8 -6
- data/lib/puppet/util/graph.rb +5 -5
- data/lib/puppet/util/inifile.rb +5 -5
- data/lib/puppet/util/json.rb +13 -0
- data/lib/puppet/util/ldap/connection.rb +2 -2
- data/lib/puppet/util/log.rb +48 -31
- data/lib/puppet/util/metric.rb +4 -4
- data/lib/puppet/util/monkey_patches.rb +43 -0
- data/lib/puppet/util/nagios_maker.rb +1 -1
- data/lib/puppet/util/package.rb +4 -4
- data/lib/puppet/util/pidlock.rb +59 -59
- data/lib/puppet/util/posix.rb +13 -52
- data/lib/puppet/util/provider_features.rb +3 -3
- data/lib/puppet/util/queue.rb +96 -0
- data/lib/puppet/util/queue/stomp.rb +47 -0
- data/lib/puppet/util/rails/cache_accumulator.rb +65 -0
- data/lib/puppet/util/rails/collection_merger.rb +0 -39
- data/lib/puppet/util/rails/reference_serializer.rb +17 -3
- data/lib/puppet/util/rdoc.rb +1 -0
- data/lib/puppet/util/rdoc/code_objects.rb +5 -1
- data/lib/puppet/util/rdoc/generators/puppet_generator.rb +5 -5
- data/lib/puppet/util/rdoc/generators/template/puppet/puppet.rb +13 -13
- data/lib/puppet/util/rdoc/parser.rb +28 -32
- data/lib/puppet/util/reference.rb +29 -8
- data/lib/puppet/util/resource_template.rb +1 -1
- data/lib/puppet/util/selinux.rb +12 -6
- data/lib/puppet/util/settings.rb +203 -578
- data/lib/puppet/util/settings/boolean_setting.rb +33 -0
- data/lib/puppet/util/settings/file_setting.rb +119 -0
- data/lib/puppet/util/settings/setting.rb +110 -0
- data/lib/puppet/util/subclass_loader.rb +1 -1
- data/lib/puppet/util/suidmanager.rb +2 -2
- data/lib/puppet/util/tagging.rb +1 -1
- data/lib/puppet/util/warnings.rb +17 -9
- data/man/man8/filebucket.8 +2 -2
- data/man/man8/pi.8 +2 -2
- data/man/man8/puppet.8 +3 -4
- data/man/man8/puppet.conf.8 +63 -63
- data/man/man8/puppetca.8 +2 -2
- data/man/man8/puppetd.8 +2 -2
- data/man/man8/puppetdoc.8 +2 -2
- data/man/man8/puppetmasterd.8 +2 -2
- data/man/man8/puppetrun.8 +2 -2
- data/man/man8/ralsh.8 +3 -3
- data/sbin/puppetca +102 -0
- data/sbin/puppetd +159 -0
- data/sbin/puppetmasterd +66 -0
- data/sbin/puppetqd +53 -0
- data/sbin/puppetrun +130 -0
- data/spec/Rakefile +2 -2
- data/spec/integration/application/puppet.rb +33 -0
- data/spec/integration/bin/puppetmasterd.rb +110 -0
- data/spec/integration/configurer.rb +18 -0
- data/spec/integration/defaults.rb +158 -7
- data/spec/integration/file_serving/content.rb +2 -0
- data/spec/integration/file_serving/fileset.rb +14 -0
- data/spec/integration/file_serving/metadata.rb +2 -0
- data/spec/integration/file_serving/terminus_helper.rb +22 -0
- data/spec/integration/indirector/catalog/compiler.rb +67 -0
- data/spec/integration/indirector/catalog/queue.rb +61 -0
- data/spec/integration/indirector/certificate/rest.rb +69 -0
- data/spec/integration/indirector/certificate_request/rest.rb +89 -0
- data/spec/integration/indirector/certificate_revocation_list/rest.rb +77 -0
- data/spec/integration/indirector/direct_file_server.rb +16 -23
- data/spec/integration/indirector/file_content/file_server.rb +75 -0
- data/spec/integration/indirector/report/rest.rb +95 -0
- data/spec/integration/indirector/rest.rb +207 -147
- data/spec/integration/network/client.rb +19 -0
- data/spec/integration/network/formats.rb +110 -0
- data/spec/integration/network/handler.rb +25 -0
- data/spec/integration/network/server/mongrel.rb +26 -8
- data/spec/integration/network/server/webrick.rb +49 -11
- data/spec/integration/node/environment.rb +58 -0
- data/spec/integration/node/facts.rb +4 -2
- data/spec/integration/parser/compiler.rb +29 -0
- data/spec/integration/parser/functions/require.rb +67 -0
- data/spec/integration/provider/mailalias/aliases.rb +25 -0
- data/spec/integration/{node → resource}/catalog.rb +17 -10
- data/spec/integration/ssl/certificate_authority.rb +135 -0
- data/spec/integration/ssl/certificate_request.rb +59 -0
- data/spec/integration/ssl/certificate_revocation_list.rb +42 -0
- data/spec/integration/ssl/host.rb +90 -0
- data/spec/integration/transaction.rb +66 -0
- data/spec/integration/transaction/report.rb +2 -5
- data/spec/integration/type.rb +22 -0
- data/spec/integration/type/file.rb +458 -0
- data/spec/integration/type/package.rb +1 -1
- data/spec/integration/type/tidy.rb +27 -0
- data/spec/integration/util/autoload.rb +114 -0
- data/spec/integration/util/feature.rb +54 -0
- data/spec/integration/util/file_locking.rb +2 -1
- data/spec/integration/util/settings.rb +27 -0
- data/spec/lib/puppet_spec/files.rb +9 -0
- data/spec/monkey_patches/add_confine_and_runnable_to_rspec_dsl.rb +1 -0
- data/spec/monkey_patches/alias_should_to_must.rb +1 -0
- data/spec/shared_behaviours/file_server_terminus.rb +14 -11
- data/spec/shared_behaviours/file_serving.rb +13 -17
- data/spec/spec_helper.rb +22 -5
- data/spec/unit/agent.rb +259 -0
- data/spec/unit/agent/locker.rb +100 -0
- data/spec/unit/agent/runner.rb +118 -0
- data/spec/unit/application.rb +420 -0
- data/spec/unit/application/filebucket.rb +220 -0
- data/spec/unit/application/pi.rb +84 -0
- data/spec/unit/application/puppet.rb +404 -0
- data/spec/unit/application/puppetca.rb +142 -0
- data/spec/unit/application/puppetd.rb +502 -0
- data/spec/unit/application/puppetdoc.rb +345 -0
- data/spec/unit/application/puppetmasterd.rb +456 -0
- data/spec/unit/application/puppetqd.rb +186 -0
- data/spec/unit/application/puppetrun.rb +279 -0
- data/spec/unit/application/ralsh.rb +237 -0
- data/spec/unit/configurer.rb +232 -0
- data/spec/unit/configurer/downloader.rb +188 -0
- data/spec/unit/configurer/fact_handler.rb +150 -0
- data/spec/unit/configurer/plugin_handler.rb +112 -0
- data/spec/unit/daemon.rb +287 -0
- data/spec/unit/file_serving/{file_base.rb → base.rb} +39 -31
- data/spec/unit/file_serving/configuration.rb +104 -93
- data/spec/unit/file_serving/configuration/parser.rb +64 -18
- data/spec/unit/file_serving/content.rb +65 -26
- data/spec/unit/file_serving/fileset.rb +116 -14
- data/spec/unit/file_serving/indirection_hooks.rb +34 -95
- data/spec/unit/file_serving/metadata.rb +27 -40
- data/spec/unit/file_serving/mount.rb +7 -118
- data/spec/unit/file_serving/mount/file.rb +188 -0
- data/spec/unit/file_serving/mount/modules.rb +63 -0
- data/spec/unit/file_serving/mount/plugins.rb +61 -0
- data/spec/unit/file_serving/terminus_helper.rb +39 -27
- data/spec/unit/indirector.rb +6 -1
- data/spec/unit/indirector/active_record.rb +76 -0
- data/spec/unit/indirector/catalog/active_record.rb +122 -0
- data/spec/unit/indirector/catalog/compiler.rb +222 -118
- data/spec/unit/indirector/catalog/queue.rb +20 -0
- data/spec/unit/indirector/catalog/rest.rb +11 -0
- data/spec/unit/indirector/catalog/yaml.rb +6 -6
- data/spec/unit/indirector/certificate/ca.rb +28 -0
- data/spec/unit/indirector/certificate/file.rb +28 -0
- data/spec/unit/indirector/certificate/rest.rb +23 -0
- data/spec/unit/indirector/certificate_request/ca.rb +19 -0
- data/spec/unit/indirector/certificate_request/file.rb +19 -0
- data/spec/unit/indirector/certificate_request/rest.rb +23 -0
- data/spec/unit/indirector/certificate_revocation_list/ca.rb +21 -0
- data/spec/unit/indirector/certificate_revocation_list/file.rb +20 -0
- data/spec/unit/indirector/certificate_revocation_list/rest.rb +23 -0
- data/spec/unit/indirector/direct_file_server.rb +3 -8
- data/spec/unit/indirector/exec.rb +6 -1
- data/spec/unit/indirector/facts/active_record.rb +104 -0
- data/spec/unit/indirector/facts/facter.rb +53 -12
- data/spec/unit/indirector/facts/rest.rb +11 -0
- data/spec/unit/indirector/file.rb +8 -1
- data/spec/unit/indirector/file_metadata/file.rb +5 -5
- data/spec/unit/indirector/file_server.rb +181 -98
- data/spec/unit/indirector/indirection.rb +102 -38
- data/spec/unit/indirector/key/ca.rb +28 -0
- data/spec/unit/indirector/key/file.rb +104 -0
- data/spec/unit/indirector/node/active_record.rb +34 -0
- data/spec/unit/indirector/node/ldap.rb +1 -1
- data/spec/unit/indirector/node/rest.rb +2 -2
- data/spec/unit/indirector/queue.rb +123 -0
- data/spec/unit/indirector/report/rest.rb +28 -0
- data/spec/unit/indirector/request.rb +221 -0
- data/spec/unit/indirector/rest.rb +343 -334
- data/spec/unit/indirector/runner/rest.rb +11 -0
- data/spec/unit/indirector/ssl_file.rb +280 -0
- data/spec/unit/module.rb +180 -180
- data/spec/unit/network/authconfig.rb +292 -0
- data/spec/unit/network/authstore.rb +94 -0
- data/spec/unit/network/client.rb +2 -2
- data/spec/unit/network/client/dipper.rb +16 -0
- data/spec/unit/network/format.rb +191 -0
- data/spec/unit/network/format_handler.rb +306 -0
- data/spec/unit/network/formats.rb +249 -0
- data/spec/unit/network/handler/fileserver.rb +2 -5
- data/spec/unit/network/http.rb +3 -3
- data/spec/unit/network/http/api/v1.rb +122 -0
- data/spec/unit/network/http/handler.rb +448 -0
- data/spec/unit/network/http/mongrel.rb +46 -32
- data/spec/unit/network/http/mongrel/rest.rb +174 -319
- data/spec/unit/network/http/rack.rb +102 -0
- data/spec/unit/network/http/rack/rest.rb +199 -0
- data/spec/unit/network/http/rack/xmlrpc.rb +157 -0
- data/spec/unit/network/http/webrick.rb +249 -37
- data/spec/unit/network/http/webrick/rest.rb +113 -279
- data/spec/unit/network/http_pool.rb +86 -110
- data/spec/unit/network/rest_authconfig.rb +146 -0
- data/spec/unit/network/rest_authorization.rb +43 -0
- data/spec/unit/network/rights.rb +519 -0
- data/spec/unit/network/server.rb +475 -257
- data/spec/unit/node.rb +43 -10
- data/spec/unit/node/environment.rb +143 -9
- data/spec/unit/node/facts.rb +77 -24
- data/spec/unit/other/selinux.rb +85 -0
- data/spec/unit/other/transbucket.rb +29 -13
- data/spec/unit/other/transobject.rb +35 -15
- data/spec/unit/parameter.rb +378 -5
- data/spec/unit/parser/ast.rb +1 -1
- data/spec/unit/parser/ast/arithmetic_operator.rb +17 -17
- data/spec/unit/parser/ast/astarray.rb +16 -10
- data/spec/unit/parser/ast/boolean_operator.rb +2 -2
- data/spec/unit/parser/ast/casestatement.rb +143 -0
- data/spec/unit/parser/ast/collection.rb +63 -0
- data/spec/unit/parser/ast/collexpr.rb +31 -8
- data/spec/unit/parser/ast/comparison_operator.rb +9 -9
- data/spec/unit/parser/ast/definition.rb +18 -0
- data/spec/unit/parser/ast/function.rb +6 -0
- data/spec/unit/parser/ast/ifstatement.rb +75 -0
- data/spec/unit/parser/ast/leaf.rb +261 -0
- data/spec/unit/parser/ast/match_operator.rb +50 -0
- data/spec/unit/parser/ast/minus.rb +1 -1
- data/spec/unit/parser/ast/node.rb +20 -0
- data/spec/unit/parser/ast/not.rb +1 -1
- data/spec/unit/parser/ast/resource_override.rb +5 -5
- data/spec/unit/parser/ast/resource_reference.rb +11 -5
- data/spec/unit/parser/ast/selector.rb +156 -0
- data/spec/unit/parser/ast/vardef.rb +11 -11
- data/spec/unit/parser/collector.rb +167 -48
- data/spec/unit/parser/compiler.rb +128 -104
- data/spec/unit/parser/files.rb +190 -0
- data/spec/unit/parser/functions/inline_template.rb +0 -0
- data/spec/unit/parser/functions/regsubst.rb +42 -42
- data/spec/unit/parser/functions/require.rb +36 -0
- data/spec/unit/parser/functions/shellquote.rb +92 -0
- data/spec/unit/parser/functions/split.rb +51 -0
- data/spec/unit/parser/functions/sprintf.rb +11 -11
- data/spec/unit/parser/functions/template.rb +0 -0
- data/spec/unit/parser/functions/versioncmp.rb +2 -2
- data/spec/unit/parser/interpreter.rb +16 -7
- data/spec/unit/parser/lexer.rb +72 -12
- data/spec/unit/parser/loaded_code.rb +198 -0
- data/spec/unit/parser/parser.rb +215 -28
- data/spec/unit/parser/resource.rb +131 -22
- data/spec/unit/parser/scope.rb +207 -12
- data/spec/unit/parser/templatewrapper.rb +8 -3
- data/spec/unit/property.rb +270 -16
- data/spec/unit/property/list.rb +12 -6
- data/spec/unit/provider.rb +31 -0
- data/spec/unit/provider/augeas/augeas.rb +61 -33
- data/spec/unit/provider/macauthorization.rb +29 -29
- data/spec/unit/provider/mcx/mcxcontent.rb +4 -4
- data/spec/unit/provider/mount/parsed.rb +5 -8
- data/spec/unit/provider/naginator.rb +0 -0
- data/spec/unit/provider/package/apt.rb +6 -6
- data/spec/unit/provider/package/pkgdmg.rb +73 -0
- data/spec/unit/provider/selboolean.rb +1 -1
- data/spec/unit/provider/selmodule.rb +2 -2
- data/spec/unit/provider/service/daemontools.rb +40 -15
- data/spec/unit/provider/service/debian.rb +89 -0
- data/spec/unit/provider/service/init.rb +106 -0
- data/spec/unit/provider/service/launchd.rb +71 -13
- data/spec/unit/provider/service/redhat.rb +94 -0
- data/spec/unit/provider/service/runit.rb +14 -2
- data/spec/unit/provider/ssh_authorized_key/parsed.rb +66 -2
- data/spec/unit/provider/user/ldap.rb +1 -1
- data/spec/unit/provider/user/user_role_add.rb +1 -1
- data/spec/unit/provider/zfs/solaris.rb +18 -6
- data/spec/unit/provider/zone/solaris.rb +1 -1
- data/spec/unit/rails.rb +16 -22
- data/spec/unit/rails/host.rb +163 -0
- data/spec/unit/rails/param_value.rb +49 -0
- data/spec/unit/rails/resource.rb +87 -0
- data/spec/unit/relationship.rb +141 -29
- data/spec/unit/resource.rb +504 -0
- data/spec/unit/resource/catalog.rb +1061 -0
- data/spec/unit/resource/reference.rb +111 -0
- data/spec/unit/simple_graph.rb +448 -191
- data/spec/unit/ssl/certificate.rb +124 -0
- data/spec/unit/ssl/certificate_authority.rb +741 -0
- data/spec/unit/ssl/certificate_authority/interface.rb +269 -0
- data/spec/unit/ssl/certificate_factory.rb +107 -0
- data/spec/unit/ssl/certificate_request.rb +193 -0
- data/spec/unit/ssl/certificate_revocation_list.rb +180 -0
- data/spec/unit/ssl/host.rb +704 -0
- data/spec/unit/ssl/inventory.rb +180 -0
- data/spec/unit/ssl/key.rb +198 -0
- data/spec/unit/transaction.rb +65 -2
- data/spec/unit/transaction/change.rb +1 -1
- data/spec/unit/transaction/report.rb +1 -1
- data/spec/unit/type.rb +361 -8
- data/spec/unit/type/augeas.rb +30 -37
- data/spec/unit/type/component.rb +63 -0
- data/spec/unit/type/computer.rb +17 -21
- data/spec/unit/type/exec.rb +27 -2
- data/spec/unit/type/file.rb +704 -83
- data/spec/unit/type/file/content.rb +253 -15
- data/spec/unit/type/file/ensure.rb +65 -2
- data/spec/unit/type/file/group.rb +5 -0
- data/spec/unit/type/file/owner.rb +5 -0
- data/spec/unit/type/file/selinux.rb +12 -16
- data/spec/unit/type/file/source.rb +264 -0
- data/spec/unit/type/filebucket.rb +74 -0
- data/spec/unit/type/group.rb +1 -5
- data/spec/unit/type/macauthorization.rb +59 -26
- data/spec/unit/type/mcx.rb +8 -16
- data/spec/unit/type/mount.rb +8 -16
- data/spec/unit/type/noop_metaparam.rb +0 -2
- data/spec/unit/type/package.rb +13 -23
- data/spec/unit/type/resources.rb +4 -7
- data/spec/unit/type/schedule.rb +1 -7
- data/spec/unit/type/selboolean.rb +4 -6
- data/spec/unit/type/service.rb +23 -33
- data/spec/unit/type/ssh_authorized_key.rb +25 -14
- data/spec/unit/type/tidy.rb +329 -21
- data/spec/unit/type/user.rb +18 -10
- data/spec/unit/type/zfs.rb +6 -6
- data/spec/unit/util/autoload.rb +94 -3
- data/spec/unit/util/autoload/file_cache.rb +183 -0
- data/spec/unit/util/backups.rb +159 -0
- data/spec/unit/util/cache_accumulator.rb +69 -0
- data/spec/unit/util/cacher.rb +185 -0
- data/spec/unit/util/checksums.rb +9 -1
- data/spec/unit/util/feature.rb +72 -0
- data/spec/unit/util/filetype.rb +1 -11
- data/spec/unit/util/json.rb +21 -0
- data/spec/unit/util/log.rb +45 -0
- data/spec/unit/util/package.rb +2 -2
- data/spec/unit/util/queue.rb +88 -0
- data/spec/unit/util/queue/stomp.rb +140 -0
- data/spec/unit/util/reference_serializer.rb +52 -0
- data/spec/unit/util/selinux.rb +5 -3
- data/spec/unit/util/settings.rb +413 -264
- data/spec/unit/util/settings/file_setting.rb +223 -0
- data/spec/unit/util/storage.rb +11 -11
- data/spec/unit/util/warnings.rb +21 -17
- data/test/Rakefile +6 -5
- data/test/certmgr/ca.rb +5 -5
- data/test/certmgr/certmgr.rb +4 -4
- data/test/data/providers/cron/crontab.allthree +2 -2
- data/test/data/providers/cron/crontab.envNcomment +1 -1
- data/test/data/providers/cron/crontab.envNname +1 -1
- data/test/data/providers/cron/crontab.multirecords +1 -1
- data/test/data/providers/cron/crontab_collections.yaml +14 -14
- data/test/data/providers/cron/crontab_multiple_with_env.yaml +6 -6
- data/test/data/providers/cron/crontab_sample_records.yaml +102 -102
- data/test/data/providers/mailalias/aliases/test1 +28 -0
- data/test/data/providers/package/testpackages.yaml +6 -6
- data/test/data/reports/1.yaml +17 -17
- data/test/data/reports/tagmail_passers.conf +2 -2
- data/test/data/snippets/append.pp +5 -5
- data/test/data/snippets/casestatement.pp +9 -2
- data/test/data/snippets/classincludes.pp +1 -1
- data/test/data/snippets/collection_override.pp +8 -0
- data/test/data/snippets/fqparents.pp +2 -2
- data/test/data/snippets/ifexpression.pp +12 -0
- data/test/data/snippets/multilinecomments.pp +5 -1
- data/test/data/snippets/selectorvalues.pp +7 -0
- data/test/data/types/hosts/1 +1 -1
- data/test/data/types/hosts/2 +3 -3
- data/test/data/types/hosts/solaris +2 -2
- data/test/data/types/mount/freebsd.fstab +7 -7
- data/test/data/types/mount/solaris.fstab +10 -10
- data/test/data/types/port/1 +472 -472
- data/test/data/types/port/darwin +4347 -4347
- data/test/language/ast.rb +3 -2
- data/test/language/ast/casestatement.rb +12 -12
- data/test/language/ast/resource.rb +4 -4
- data/test/language/ast/resource_reference.rb +5 -5
- data/test/language/ast/selector.rb +11 -11
- data/test/language/ast/variable.rb +4 -4
- data/test/language/functions.rb +16 -16
- data/test/language/parser.rb +89 -111
- data/test/language/resource.rb +3 -88
- data/test/language/scope.rb +14 -55
- data/test/language/snippets.rb +31 -31
- data/test/lib/puppettest.rb +12 -12
- data/test/lib/puppettest/certificates.rb +2 -2
- data/test/lib/puppettest/exetest.rb +0 -1
- data/test/lib/puppettest/fakes.rb +1 -1
- data/test/lib/puppettest/parsertesting.rb +9 -4
- data/test/lib/puppettest/railstesting.rb +3 -3
- data/test/lib/puppettest/servertest.rb +1 -1
- data/test/lib/puppettest/support/assertions.rb +2 -2
- data/test/lib/puppettest/support/collection.rb +1 -1
- data/test/lib/puppettest/support/resources.rb +7 -7
- data/test/lib/puppettest/support/utils.rb +10 -16
- data/test/lib/puppettest/testcase.rb +2 -1
- data/test/network/authconfig.rb +1 -1
- data/test/network/authorization.rb +1 -1
- data/test/network/authstore.rb +57 -14
- data/test/network/client/ca.rb +1 -0
- data/test/network/client/resource.rb +12 -50
- data/test/network/client_request.rb +1 -1
- data/test/network/handler/bucket.rb +2 -2
- data/test/network/handler/fileserver.rb +17 -21
- data/test/network/handler/master.rb +5 -5
- data/test/network/handler/report.rb +3 -3
- data/test/network/handler/resource.rb +29 -75
- data/test/network/handler/runner.rb +8 -58
- data/test/network/rights.rb +1 -1
- data/test/network/server/mongrel_test.rb +15 -1
- data/test/network/server/webrick.rb +0 -36
- data/test/network/xmlrpc/webrick_servlet.rb +5 -5
- data/test/other/dsl.rb +3 -3
- data/test/other/events.rb +15 -15
- data/test/other/puppet.rb +2 -32
- data/test/other/relationships.rb +21 -148
- data/test/other/report.rb +20 -23
- data/test/other/transactions.rb +110 -298
- data/test/puppet/defaults.rb +1 -1
- data/test/puppet/tc_suidmanager.rb +1 -1
- data/test/rails/railsparameter.rb +4 -4
- data/test/ral/manager/attributes.rb +12 -68
- data/test/ral/manager/instances.rb +3 -19
- data/test/ral/manager/manager.rb +7 -7
- data/test/ral/manager/provider.rb +7 -7
- data/test/ral/manager/type.rb +54 -349
- data/test/ral/providers/cron/crontab.rb +14 -14
- data/test/ral/providers/group.rb +5 -6
- data/test/ral/providers/host/parsed.rb +3 -3
- data/test/ral/providers/mailalias/aliases.rb +4 -4
- data/test/ral/providers/package.rb +3 -3
- data/test/ral/providers/package/aptitude.rb +55 -55
- data/test/ral/providers/package/aptrpm.rb +7 -7
- data/test/ral/providers/parsedfile.rb +10 -14
- data/test/ral/providers/port/parsed.rb +6 -6
- data/test/ral/providers/provider.rb +10 -10
- data/test/ral/providers/service/base.rb +32 -32
- data/test/ral/providers/sshkey/parsed.rb +14 -14
- data/test/ral/providers/user.rb +16 -17
- data/test/ral/providers/user/useradd.rb +19 -22
- data/test/ral/type/cron.rb +21 -28
- data/test/ral/type/exec.rb +57 -60
- data/test/ral/type/file.rb +88 -862
- data/test/ral/type/file/target.rb +21 -70
- data/test/ral/type/fileignoresource.rb +37 -44
- data/test/ral/type/filesources.rb +43 -473
- data/test/ral/type/group.rb +6 -7
- data/test/ral/type/host.rb +14 -30
- data/test/ral/type/mailalias.rb +3 -3
- data/test/ral/type/port.rb +5 -5
- data/test/ral/type/resources.rb +37 -37
- data/test/ral/type/service.rb +3 -3
- data/test/ral/type/sshkey.rb +34 -39
- data/test/ral/type/user.rb +15 -14
- data/test/ral/type/yumrepo.rb +18 -17
- data/test/ral/type/zone.rb +4 -6
- data/test/test +9 -9
- data/test/util/fileparsing.rb +10 -10
- data/test/util/inifile.rb +6 -6
- data/test/util/instance_loader.rb +1 -1
- data/test/util/log.rb +2 -2
- data/test/util/metrics.rb +1 -6
- data/test/util/package.rb +1 -1
- data/test/util/pidlock.rb +116 -116
- data/test/util/settings.rb +40 -429
- data/test/util/storage.rb +5 -5
- data/test/util/subclass_loader.rb +0 -7
- data/test/util/utiltest.rb +10 -29
- metadata +1369 -941
- data/bin/puppetca +0 -363
- data/bin/puppetd +0 -439
- data/bin/puppetmasterd +0 -289
- data/bin/puppetrun +0 -369
- data/conf/redhat/lsb-config.patch +0 -51
- data/conf/redhat/no-chuser-0.15.1.patch +0 -38
- data/conf/redhat/no-lockdir.patch +0 -13
- data/examples/mac_netinfo.pp +0 -5
- data/ext/passenger/README +0 -63
- data/ext/passenger/apache2.conf +0 -29
- data/ext/passenger/config.ru +0 -40
- data/lib/puppet/config_stores/rest.rb +0 -60
- data/lib/puppet/executables/client/certhandler.rb +0 -82
- data/lib/puppet/indirector/file_content/modules.rb +0 -11
- data/lib/puppet/indirector/file_metadata/modules.rb +0 -17
- data/lib/puppet/indirector/module_files.rb +0 -82
- data/lib/puppet/indirector/ssl_rsa.rb +0 -5
- data/lib/puppet/indirector/ssl_rsa/file.rb +0 -33
- data/lib/puppet/network/client/master.rb +0 -524
- data/lib/puppet/network/http_server/rack.rb +0 -148
- data/lib/puppet/pgraph.rb +0 -121
- data/lib/puppet/provider/group/netinfo.rb +0 -15
- data/lib/puppet/provider/host/netinfo.rb +0 -19
- data/lib/puppet/provider/mount/netinfo.rb +0 -37
- data/lib/puppet/provider/nameservice/netinfo.rb +0 -224
- data/lib/puppet/provider/user/netinfo.rb +0 -111
- data/lib/puppet/util/fact_store.rb +0 -59
- data/lib/puppet/util/uri_helper.rb +0 -22
- data/spec/integration/file_serving/configuration.rb +0 -43
- data/spec/integration/indirector/module_files.rb +0 -57
- data/spec/unit/executables/client/certhandler.rb +0 -135
- data/spec/unit/indirector/file_content/modules.rb +0 -18
- data/spec/unit/indirector/file_metadata/modules.rb +0 -42
- data/spec/unit/indirector/module_files.rb +0 -259
- data/spec/unit/indirector/ssl_rsa/file.rb +0 -121
- data/spec/unit/network/client/master.rb +0 -442
- data/spec/unit/node/catalog.rb +0 -865
- data/spec/unit/other/pgraph.rb +0 -210
- data/spec/unit/resource_reference.rb +0 -73
- data/spec/unit/util/uri_helper.rb +0 -41
- data/test/data/snippets/ifexpression.rb +0 -6
- data/test/executables/filebucket.rb +0 -51
- data/test/executables/puppetbin.rb +0 -104
- data/test/executables/puppetca.rb +0 -115
- data/test/executables/puppetd.rb +0 -55
- data/test/executables/puppetmasterd.rb +0 -147
- data/test/network/client/client.rb +0 -195
- data/test/network/client/master.rb +0 -490
- data/test/network/daemon.rb +0 -70
- data/test/network/handler/handler.rb +0 -63
- data/test/other/overrides.rb +0 -107
- data/test/puppet/conffiles.rb +0 -107
- data/test/rails/ast.rb +0 -73
- data/test/rails/configuration.rb +0 -71
- data/test/rails/host.rb +0 -154
- data/test/rails/railsresource.rb +0 -251
- data/test/ral/providers/host/netinfo.rb +0 -56
- data/test/ral/providers/mount/netinfo.rb +0 -79
- data/test/ral/type/basic.rb +0 -85
- data/test/ral/type/filebucket.rb +0 -157
- data/test/ral/type/parameter.rb +0 -174
- data/test/ral/type/property.rb +0 -388
- data/test/ral/type/tidy.rb +0 -291
- data/test/util/autoload.rb +0 -145
- data/test/util/features.rb +0 -95
@@ -239,11 +239,11 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
|
|
239
239
|
|
240
240
|
|
241
241
|
#####################################################################
|
242
|
-
### H E A D E R T E M P L A T E
|
242
|
+
### H E A D E R T E M P L A T E
|
243
243
|
#####################################################################
|
244
244
|
|
245
245
|
XHTML_PREAMBLE = %{<?xml version="1.0" encoding="%charset%"?>
|
246
|
-
<!DOCTYPE html
|
246
|
+
<!DOCTYPE html
|
247
247
|
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
248
248
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
249
249
|
}
|
@@ -271,7 +271,7 @@ HEADER = XHTML_PREAMBLE + %{
|
|
271
271
|
return false;
|
272
272
|
|
273
273
|
elemStyle = elem.style;
|
274
|
-
|
274
|
+
|
275
275
|
if ( elemStyle.display != "block" ) {
|
276
276
|
elemStyle.display = "block"
|
277
277
|
} else {
|
@@ -280,10 +280,10 @@ HEADER = XHTML_PREAMBLE + %{
|
|
280
280
|
|
281
281
|
return true;
|
282
282
|
}
|
283
|
-
|
283
|
+
|
284
284
|
// Make codeblocks hidden by default
|
285
285
|
document.writeln( "<style type=\\"text/css\\">div.method-source-code { display: none }</style>" )
|
286
|
-
|
286
|
+
|
287
287
|
// ]]>
|
288
288
|
</script>
|
289
289
|
|
@@ -516,7 +516,7 @@ IF:sectitle
|
|
516
516
|
IF:seccomment
|
517
517
|
<div class="section-comment">
|
518
518
|
%seccomment%
|
519
|
-
</div>
|
519
|
+
</div>
|
520
520
|
ENDIF:seccomment
|
521
521
|
ENDIF:sectitle
|
522
522
|
END:sections
|
@@ -608,7 +608,7 @@ IF:sectitle
|
|
608
608
|
IF:seccomment
|
609
609
|
<div class="section-comment">
|
610
610
|
%seccomment%
|
611
|
-
</div>
|
611
|
+
</div>
|
612
612
|
ENDIF:seccomment
|
613
613
|
ENDIF:sectitle
|
614
614
|
|
@@ -720,7 +720,7 @@ END:attributes
|
|
720
720
|
</div>
|
721
721
|
</div>
|
722
722
|
ENDIF:attributes
|
723
|
-
|
723
|
+
|
724
724
|
|
725
725
|
|
726
726
|
<!-- if method_list -->
|
@@ -755,7 +755,7 @@ IF:sourcecode
|
|
755
755
|
</a>
|
756
756
|
ENDIF:sourcecode
|
757
757
|
</div>
|
758
|
-
|
758
|
+
|
759
759
|
<div class="method-description">
|
760
760
|
IF:m_desc
|
761
761
|
%m_desc%
|
@@ -797,7 +797,7 @@ START:params
|
|
797
797
|
END:params
|
798
798
|
ENDIF:params
|
799
799
|
</div>
|
800
|
-
|
800
|
+
|
801
801
|
<div class="method-description">
|
802
802
|
IF:m_desc
|
803
803
|
%m_desc%
|
@@ -935,7 +935,7 @@ METHOD_INDEX = FILE_INDEX
|
|
935
935
|
COMBO_INDEX = XHTML_PREAMBLE + %{
|
936
936
|
<!--
|
937
937
|
|
938
|
-
%classes_title% & %defines_title%
|
938
|
+
%classes_title% & %defines_title%
|
939
939
|
|
940
940
|
-->
|
941
941
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
@@ -950,7 +950,7 @@ COMBO_INDEX = XHTML_PREAMBLE + %{
|
|
950
950
|
parent.docwin.location.href = url;
|
951
951
|
}
|
952
952
|
//--></SCRIPT>
|
953
|
-
|
953
|
+
|
954
954
|
</head>
|
955
955
|
<body>
|
956
956
|
<div id="index">
|
@@ -1019,7 +1019,7 @@ ENDIF:plugins
|
|
1019
1019
|
}
|
1020
1020
|
|
1021
1021
|
INDEX = %{<?xml version="1.0" encoding="%charset%"?>
|
1022
|
-
<!DOCTYPE html
|
1022
|
+
<!DOCTYPE html
|
1023
1023
|
PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
|
1024
1024
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
|
1025
1025
|
|
@@ -41,6 +41,18 @@ class Parser
|
|
41
41
|
|
42
42
|
private
|
43
43
|
|
44
|
+
# Due to a bug in RDoc, we need to roll our own find_module_named
|
45
|
+
# The issue is that RDoc tries harder by asking the parent for a class/module
|
46
|
+
# of the name. But by doing so, it can mistakenly use a module of same name
|
47
|
+
# but from which we are not descendant.
|
48
|
+
def find_object_named(container, name)
|
49
|
+
return container if container.name == name
|
50
|
+
container.each_classmodule do |m|
|
51
|
+
return m if m.name == name
|
52
|
+
end
|
53
|
+
nil
|
54
|
+
end
|
55
|
+
|
44
56
|
# walk down the namespace and lookup/create container as needed
|
45
57
|
def get_class_or_module(container, name)
|
46
58
|
|
@@ -54,9 +66,9 @@ class Parser
|
|
54
66
|
final_name = names.pop
|
55
67
|
names.each do |name|
|
56
68
|
prev_container = container
|
57
|
-
container = container
|
69
|
+
container = find_object_named(container, name)
|
58
70
|
unless container
|
59
|
-
container = prev_container.
|
71
|
+
container = prev_container.add_class(PuppetClass, name, nil)
|
60
72
|
end
|
61
73
|
end
|
62
74
|
return [container, final_name]
|
@@ -155,8 +167,8 @@ class Parser
|
|
155
167
|
scan_for_vardef(container,stmt.children) if stmt.is_a?(Puppet::Parser::AST::ASTArray)
|
156
168
|
|
157
169
|
if stmt.is_a?(Puppet::Parser::AST::VarDef)
|
158
|
-
Puppet.debug "rdoc: found constant: %s = %s" % [stmt.name.to_s,
|
159
|
-
container.add_constant(Constant.new(stmt.name.to_s,
|
170
|
+
Puppet.debug "rdoc: found constant: %s = %s" % [stmt.name.to_s, stmt.value.to_s]
|
171
|
+
container.add_constant(Constant.new(stmt.name.to_s, stmt.value.to_s, stmt.doc))
|
160
172
|
end
|
161
173
|
end
|
162
174
|
end
|
@@ -169,20 +181,15 @@ class Parser
|
|
169
181
|
|
170
182
|
if stmt.is_a?(Puppet::Parser::AST::Resource) and !stmt.type.nil?
|
171
183
|
type = stmt.type.split("::").collect { |s| s.capitalize }.join("::")
|
172
|
-
title =
|
184
|
+
title = stmt.title.is_a?(Puppet::Parser::AST::ASTArray) ? stmt.title.to_s.gsub(/\[(.*)\]/,'\1') : stmt.title.to_s
|
173
185
|
Puppet.debug "rdoc: found resource: %s[%s]" % [type,title]
|
174
186
|
|
175
187
|
param = []
|
176
188
|
stmt.params.children.each do |p|
|
177
189
|
res = {}
|
178
190
|
res["name"] = p.param
|
179
|
-
|
180
|
-
|
181
|
-
res["value"] = "'#{p.value}'"
|
182
|
-
else
|
183
|
-
res["value"] = "[%s]" % p.value.children.collect { |v| "'#{v}'" }.join(", ")
|
184
|
-
end
|
185
|
-
end
|
191
|
+
res["value"] = "#{p.value.to_s}" unless p.value.nil?
|
192
|
+
|
186
193
|
param << res
|
187
194
|
end
|
188
195
|
|
@@ -203,6 +210,10 @@ class Parser
|
|
203
210
|
comment = klass.doc
|
204
211
|
look_for_directives_in(container, comment) unless comment.empty?
|
205
212
|
cls = container.add_class(PuppetClass, name, superclass)
|
213
|
+
# it is possible we already encountered this class, while parsing some namespaces
|
214
|
+
# from other classes of other files. But at that time we couldn't know this class superclass
|
215
|
+
# so, now we know it and force it.
|
216
|
+
cls.superclass = superclass
|
206
217
|
cls.record_location(@top_level)
|
207
218
|
|
208
219
|
# scan class code for include
|
@@ -248,8 +259,6 @@ class Parser
|
|
248
259
|
# split define name by :: to find the complete module hierarchy
|
249
260
|
container, name = get_class_or_module(container,name)
|
250
261
|
|
251
|
-
return if container.find_local_symbol(name)
|
252
|
-
|
253
262
|
# build up declaration
|
254
263
|
declaration = ""
|
255
264
|
define.arguments.each do |arg,value|
|
@@ -281,7 +290,8 @@ class Parser
|
|
281
290
|
# that contains the documentation
|
282
291
|
def parse_elements(container)
|
283
292
|
Puppet.debug "rdoc: scanning manifest"
|
284
|
-
@ast
|
293
|
+
@ast.hostclasses.values.sort { |a,b| a.classname <=> b.classname }.each do |klass|
|
294
|
+
name = klass.classname
|
285
295
|
if klass.file == @input_file_name
|
286
296
|
unless name.empty?
|
287
297
|
document_class(name,klass,container)
|
@@ -293,15 +303,15 @@ class Parser
|
|
293
303
|
end
|
294
304
|
end
|
295
305
|
|
296
|
-
@ast
|
306
|
+
@ast.definitions.each do |name, define|
|
297
307
|
if define.file == @input_file_name
|
298
308
|
document_define(name,define,container)
|
299
309
|
end
|
300
310
|
end
|
301
311
|
|
302
|
-
@ast
|
312
|
+
@ast.nodes.each do |name, node|
|
303
313
|
if node.file == @input_file_name
|
304
|
-
document_node(name,node,container)
|
314
|
+
document_node(name.to_s,node,container)
|
305
315
|
end
|
306
316
|
end
|
307
317
|
end
|
@@ -419,19 +429,5 @@ class Parser
|
|
419
429
|
comment.gsub!(/^#--.*?^#\+\+/m, '')
|
420
430
|
comment.sub!(/^#--.*/m, '')
|
421
431
|
end
|
422
|
-
|
423
|
-
# convert an AST value to a string
|
424
|
-
def value_to_s(value)
|
425
|
-
value = value.children if value.is_a?(Puppet::Parser::AST::ASTArray)
|
426
|
-
if value.is_a?(Array)
|
427
|
-
"['#{value.join(", ")}']"
|
428
|
-
elsif [:true, true, "true"].include?(value)
|
429
|
-
"true"
|
430
|
-
elsif [:false, false, "false"].include?(value)
|
431
|
-
"false"
|
432
|
-
else
|
433
|
-
value.to_s
|
434
|
-
end
|
435
|
-
end
|
436
432
|
end
|
437
433
|
end
|
@@ -14,7 +14,7 @@ class Puppet::Util::Reference
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def self.modes
|
17
|
-
%w{pdf trac text}
|
17
|
+
%w{pdf trac text markdown}
|
18
18
|
end
|
19
19
|
|
20
20
|
def self.newreference(name, options = {}, &block)
|
@@ -36,7 +36,7 @@ class Puppet::Util::Reference
|
|
36
36
|
|
37
37
|
def self.pdf(text)
|
38
38
|
puts "creating pdf"
|
39
|
-
|
39
|
+
File.open("/tmp/puppetdoc.txt", "w") do |f|
|
40
40
|
f.puts text
|
41
41
|
end
|
42
42
|
rst2latex = %x{which rst2latex}
|
@@ -48,7 +48,6 @@ class Puppet::Util::Reference
|
|
48
48
|
end
|
49
49
|
rst2latex.chomp!
|
50
50
|
cmd = %{#{rst2latex} /tmp/puppetdoc.txt > /tmp/puppetdoc.tex}
|
51
|
-
Puppet::Util.secure_open('/tmp/puppetdoc.tex','w') {}
|
52
51
|
output = %x{#{cmd}}
|
53
52
|
unless $? == 0
|
54
53
|
$stderr.puts "rst2latex failed"
|
@@ -58,14 +57,36 @@ class Puppet::Util::Reference
|
|
58
57
|
$stderr.puts output
|
59
58
|
|
60
59
|
# Now convert to pdf
|
61
|
-
puts "handling pdf"
|
62
60
|
Dir.chdir("/tmp") do
|
63
61
|
%x{texi2pdf puppetdoc.tex >/dev/null 2>/dev/null}
|
64
62
|
end
|
65
63
|
|
66
|
-
|
67
|
-
|
68
|
-
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.markdown(name, text)
|
67
|
+
puts "Creating markdown for #{name} reference."
|
68
|
+
dir = "/tmp/" + Puppet::PUPPETVERSION
|
69
|
+
FileUtils.mkdir(dir) unless File.directory?(dir)
|
70
|
+
File.open(dir + "/" + "#{name}.rst", "w") do |f|
|
71
|
+
f.puts text
|
72
|
+
end
|
73
|
+
pandoc = %x{which pandoc}
|
74
|
+
if $? != 0 or pandoc =~ /no /
|
75
|
+
pandoc = %x{which pandoc}
|
76
|
+
end
|
77
|
+
if $? != 0 or pandoc =~ /no /
|
78
|
+
raise "Could not find pandoc"
|
79
|
+
end
|
80
|
+
pandoc.chomp!
|
81
|
+
cmd = %{#{pandoc} -s -r rst -w markdown #{dir}/#{name}.rst -o #{dir}/#{name}.mdwn}
|
82
|
+
output = %x{#{cmd}}
|
83
|
+
unless $? == 0
|
84
|
+
$stderr.puts "Pandoc failed to create #{name} reference."
|
85
|
+
$stderr.puts output
|
86
|
+
exit(1)
|
87
|
+
end
|
88
|
+
|
89
|
+
File.unlink(dir + "/" + "#{name}.rst")
|
69
90
|
end
|
70
91
|
|
71
92
|
def self.references
|
@@ -169,7 +190,7 @@ class Puppet::Util::Reference
|
|
169
190
|
end
|
170
191
|
|
171
192
|
def trac
|
172
|
-
|
193
|
+
File.open("/tmp/puppetdoc.txt", "w") do |f|
|
173
194
|
f.puts self.to_trac
|
174
195
|
end
|
175
196
|
|
@@ -18,7 +18,7 @@ require 'erb'
|
|
18
18
|
# def generate
|
19
19
|
# template = Puppet::Util::ResourceTemplate.new("/path/to/template", self)
|
20
20
|
#
|
21
|
-
# return Puppet::Type.type(:file).
|
21
|
+
# return Puppet::Type.type(:file).new :path => "/my/file",
|
22
22
|
# :content => template.evaluate
|
23
23
|
# end
|
24
24
|
#
|
data/lib/puppet/util/selinux.rb
CHANGED
@@ -122,7 +122,7 @@ module Puppet::Util::SELinux
|
|
122
122
|
else
|
123
123
|
context = value
|
124
124
|
end
|
125
|
-
|
125
|
+
|
126
126
|
retval = Selinux.lsetfilecon(file, context)
|
127
127
|
if retval == 0
|
128
128
|
return true
|
@@ -152,9 +152,15 @@ module Puppet::Util::SELinux
|
|
152
152
|
|
153
153
|
# Internal helper function to read and parse /proc/mounts
|
154
154
|
def read_mounts
|
155
|
+
mounts = ""
|
155
156
|
begin
|
156
|
-
mountfh = File.open("/proc/mounts"
|
157
|
-
|
157
|
+
mountfh = File.open("/proc/mounts")
|
158
|
+
# We use read_nonblock() in a loop rather than read() to work-around
|
159
|
+
# a linux kernel bug. See ticket #1963 for details.
|
160
|
+
while true
|
161
|
+
mounts += mountfh.read_nonblock(1024)
|
162
|
+
end
|
163
|
+
rescue EOFError
|
158
164
|
mountfh.close
|
159
165
|
rescue
|
160
166
|
return nil
|
@@ -179,12 +185,12 @@ module Puppet::Util::SELinux
|
|
179
185
|
unless mnts = read_mounts()
|
180
186
|
return nil
|
181
187
|
end
|
182
|
-
|
188
|
+
|
183
189
|
# For a given file:
|
184
|
-
# Check if the filename is in the data structure;
|
190
|
+
# Check if the filename is in the data structure;
|
185
191
|
# return the fstype if it is.
|
186
192
|
# Just in case: return something if you're down to "/" or ""
|
187
|
-
# Remove the last slash and everything after it,
|
193
|
+
# Remove the last slash and everything after it,
|
188
194
|
# and repeat with that as the file for the next loop through.
|
189
195
|
ary = file.split('/')
|
190
196
|
while not ary.empty? do
|
data/lib/puppet/util/settings.rb
CHANGED
@@ -3,11 +3,18 @@ require 'sync'
|
|
3
3
|
require 'puppet/transportable'
|
4
4
|
require 'getoptlong'
|
5
5
|
|
6
|
+
require 'puppet/external/event-loop'
|
7
|
+
require 'puppet/util/cacher'
|
8
|
+
require 'puppet/util/loadedfile'
|
6
9
|
|
7
10
|
# The class for handling configuration files.
|
8
11
|
class Puppet::Util::Settings
|
9
12
|
include Enumerable
|
10
|
-
include Puppet::Util
|
13
|
+
include Puppet::Util::Cacher
|
14
|
+
|
15
|
+
require 'puppet/util/settings/setting'
|
16
|
+
require 'puppet/util/settings/file_setting'
|
17
|
+
require 'puppet/util/settings/boolean_setting'
|
11
18
|
|
12
19
|
attr_accessor :file
|
13
20
|
attr_reader :timer
|
@@ -19,62 +26,35 @@ class Puppet::Util::Settings
|
|
19
26
|
|
20
27
|
# Set a config value. This doesn't set the defaults, it sets the value itself.
|
21
28
|
def []=(param, value)
|
22
|
-
param
|
23
|
-
unless element = @config[param]
|
24
|
-
raise ArgumentError,
|
25
|
-
"Attempt to assign a value to unknown configuration parameter %s" % param.inspect
|
26
|
-
end
|
27
|
-
if element.respond_to?(:munge)
|
28
|
-
value = element.munge(value)
|
29
|
-
end
|
30
|
-
if element.respond_to?(:handle)
|
31
|
-
element.handle(value)
|
32
|
-
end
|
33
|
-
# Reset the name, so it's looked up again.
|
34
|
-
if param == :name
|
35
|
-
@name = nil
|
36
|
-
end
|
37
|
-
@sync.synchronize do # yay, thread-safe
|
38
|
-
@values[:memory][param] = value
|
39
|
-
@cache.clear
|
40
|
-
end
|
41
|
-
|
42
|
-
return value
|
29
|
+
set_value(param, value, :memory)
|
43
30
|
end
|
44
31
|
|
45
32
|
# Generate the list of valid arguments, in a format that GetoptLong can
|
46
33
|
# understand, and add them to the passed option list.
|
47
34
|
def addargs(options)
|
48
|
-
# Hackish, but acceptable. Copy the current ARGV for restarting.
|
49
|
-
Puppet.args = ARGV.dup
|
50
|
-
|
51
35
|
# Add all of the config parameters as valid options.
|
52
|
-
self.each { |name,
|
53
|
-
|
36
|
+
self.each { |name, setting|
|
37
|
+
setting.getopt_args.each { |args| options << args }
|
54
38
|
}
|
55
39
|
|
56
40
|
return options
|
57
41
|
end
|
58
42
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
puts detail.backtrace
|
69
|
-
end
|
70
|
-
Puppet.err "Could not configure myself: %s" % detail
|
71
|
-
end
|
43
|
+
# Generate the list of valid arguments, in a format that OptionParser can
|
44
|
+
# understand, and add them to the passed option list.
|
45
|
+
def optparse_addargs(options)
|
46
|
+
# Add all of the config parameters as valid options.
|
47
|
+
self.each { |name, setting|
|
48
|
+
options << setting.optparse_args
|
49
|
+
}
|
50
|
+
|
51
|
+
return options
|
72
52
|
end
|
73
53
|
|
74
54
|
# Is our parameter a boolean parameter?
|
75
55
|
def boolean?(param)
|
76
|
-
param =
|
77
|
-
if @config.include?(param) and @config[param].kind_of?
|
56
|
+
param = param.to_sym
|
57
|
+
if @config.include?(param) and @config[param].kind_of? BooleanSetting
|
78
58
|
return true
|
79
59
|
else
|
80
60
|
return false
|
@@ -126,7 +106,7 @@ class Puppet::Util::Settings
|
|
126
106
|
|
127
107
|
# Return a value's description.
|
128
108
|
def description(name)
|
129
|
-
if obj = @config[
|
109
|
+
if obj = @config[name.to_sym]
|
130
110
|
obj.desc
|
131
111
|
else
|
132
112
|
nil
|
@@ -152,8 +132,8 @@ class Puppet::Util::Settings
|
|
152
132
|
end
|
153
133
|
|
154
134
|
# Return an object by name.
|
155
|
-
def
|
156
|
-
param =
|
135
|
+
def setting(param)
|
136
|
+
param = param.to_sym
|
157
137
|
@config[param]
|
158
138
|
end
|
159
139
|
|
@@ -169,17 +149,12 @@ class Puppet::Util::Settings
|
|
169
149
|
bool = false
|
170
150
|
end
|
171
151
|
str = str.intern
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
@values[:cli][str] = bool
|
176
|
-
else
|
177
|
-
@values[:cli][str] = value
|
178
|
-
end
|
179
|
-
end
|
180
|
-
else
|
181
|
-
raise ArgumentError, "Invalid argument %s" % opt
|
152
|
+
|
153
|
+
if value == "" or value.nil?
|
154
|
+
value = bool
|
182
155
|
end
|
156
|
+
|
157
|
+
set_value(str, value, :cli)
|
183
158
|
end
|
184
159
|
|
185
160
|
def include?(name)
|
@@ -197,7 +172,7 @@ class Puppet::Util::Settings
|
|
197
172
|
def initialize
|
198
173
|
@config = {}
|
199
174
|
@shortnames = {}
|
200
|
-
|
175
|
+
|
201
176
|
@created = []
|
202
177
|
@searchpath = nil
|
203
178
|
|
@@ -222,8 +197,8 @@ class Puppet::Util::Settings
|
|
222
197
|
# They probably deserve their own class, but I don't want to do that until I can refactor environments
|
223
198
|
# its a little better than where they were
|
224
199
|
|
225
|
-
# Prints the contents of a config file with the available config
|
226
|
-
# prints a single value of a config
|
200
|
+
# Prints the contents of a config file with the available config settings, or it
|
201
|
+
# prints a single value of a config setting.
|
227
202
|
def print_config_options
|
228
203
|
env = value(:environment)
|
229
204
|
val = value(:configprint)
|
@@ -277,7 +252,7 @@ class Puppet::Util::Settings
|
|
277
252
|
|
278
253
|
# Return a given object's file metadata.
|
279
254
|
def metadata(param)
|
280
|
-
if obj = @config[
|
255
|
+
if obj = @config[param.to_sym] and obj.is_a?(FileSetting)
|
281
256
|
return [:owner, :group, :mode].inject({}) do |meta, p|
|
282
257
|
if v = obj.send(p)
|
283
258
|
meta[p] = v
|
@@ -335,7 +310,18 @@ class Puppet::Util::Settings
|
|
335
310
|
|
336
311
|
# Parse the configuration file. Just provides
|
337
312
|
# thread safety.
|
338
|
-
def parse
|
313
|
+
def parse
|
314
|
+
raise "No :config setting defined; cannot parse unknown config file" unless self[:config]
|
315
|
+
|
316
|
+
# Create a timer so that this file will get checked automatically
|
317
|
+
# and reparsed if necessary.
|
318
|
+
set_filetimeout_timer()
|
319
|
+
|
320
|
+
# Retrieve the value now, so that we don't lose it in the 'clear' call.
|
321
|
+
file = self[:config]
|
322
|
+
|
323
|
+
return unless FileTest.exist?(file)
|
324
|
+
|
339
325
|
# We have to clear outside of the sync, because it's
|
340
326
|
# also using synchronize().
|
341
327
|
clear(true)
|
@@ -350,7 +336,7 @@ class Puppet::Util::Settings
|
|
350
336
|
parse_file(file).each do |area, values|
|
351
337
|
@values[area] = values
|
352
338
|
end
|
353
|
-
|
339
|
+
|
354
340
|
# Determine our environment, if we have one.
|
355
341
|
if @config[:environment]
|
356
342
|
env = self.value(:environment).to_sym
|
@@ -383,128 +369,43 @@ class Puppet::Util::Settings
|
|
383
369
|
end
|
384
370
|
end
|
385
371
|
|
386
|
-
|
387
|
-
|
388
|
-
#
|
389
|
-
|
390
|
-
def old_parse(file)
|
391
|
-
text = nil
|
392
|
-
|
393
|
-
if file.is_a? Puppet::Util::LoadedFile
|
394
|
-
@file = file
|
395
|
-
else
|
396
|
-
@file = Puppet::Util::LoadedFile.new(file)
|
397
|
-
end
|
398
|
-
|
399
|
-
# Don't create a timer for the old style parsing.
|
400
|
-
# settimer()
|
401
|
-
|
402
|
-
begin
|
403
|
-
text = File.read(@file.file)
|
404
|
-
rescue Errno::ENOENT
|
405
|
-
raise Puppet::Error, "No such file %s" % file
|
406
|
-
rescue Errno::EACCES
|
407
|
-
raise Puppet::Error, "Permission denied to file %s" % file
|
408
|
-
end
|
409
|
-
|
410
|
-
@sync.synchronize do
|
411
|
-
@values = Hash.new { |names, name|
|
412
|
-
names[name] = {}
|
413
|
-
}
|
414
|
-
end
|
415
|
-
|
416
|
-
# Get rid of the values set by the file, keeping cli values.
|
417
|
-
self.clear(true)
|
418
|
-
|
419
|
-
section = "puppet"
|
420
|
-
metas = %w{owner group mode}
|
421
|
-
values = Hash.new { |hash, key| hash[key] = {} }
|
422
|
-
@sync.synchronize do
|
423
|
-
text.split(/\n/).each { |line|
|
424
|
-
case line
|
425
|
-
when /^\[(\w+)\]$/: section = $1 # Section names
|
426
|
-
when /^\s*#/: next # Skip comments
|
427
|
-
when /^\s*$/: next # Skip blanks
|
428
|
-
when /^\s*(\w+)\s*=\s*(.+)$/: # settings
|
429
|
-
var = $1.intern
|
430
|
-
if var == :mode
|
431
|
-
value = $2
|
432
|
-
else
|
433
|
-
value = munge_value($2)
|
434
|
-
end
|
435
|
-
|
436
|
-
# Only warn if we don't know what this config var is. This
|
437
|
-
# prevents exceptions later on.
|
438
|
-
unless @config.include?(var) or metas.include?(var.to_s)
|
439
|
-
Puppet.warning "Discarded unknown configuration parameter %s" % var.inspect
|
440
|
-
next # Skip this line.
|
441
|
-
end
|
442
|
-
|
443
|
-
# Mmm, "special" attributes
|
444
|
-
if metas.include?(var.to_s)
|
445
|
-
unless values.include?(section)
|
446
|
-
values[section] = {}
|
447
|
-
end
|
448
|
-
values[section][var.to_s] = value
|
449
|
-
|
450
|
-
# If the parameter is valid, then set it.
|
451
|
-
if section == Puppet[:name] and @config.include?(var)
|
452
|
-
#@config[var].value = value
|
453
|
-
@values[:main][var] = value
|
454
|
-
end
|
455
|
-
next
|
456
|
-
end
|
457
|
-
|
458
|
-
# Don't override set parameters, since the file is parsed
|
459
|
-
# after cli arguments are handled.
|
460
|
-
unless @config.include?(var) and @config[var].setbycli
|
461
|
-
Puppet.debug "%s: Setting %s to '%s'" % [section, var, value]
|
462
|
-
@values[:main][var] = value
|
463
|
-
end
|
464
|
-
@config[var].section = symbolize(section)
|
465
|
-
|
466
|
-
metas.each { |meta|
|
467
|
-
if values[section][meta]
|
468
|
-
if @config[var].respond_to?(meta + "=")
|
469
|
-
@config[var].send(meta + "=", values[section][meta])
|
470
|
-
end
|
471
|
-
end
|
472
|
-
}
|
473
|
-
else
|
474
|
-
raise Puppet::Error, "Could not match line %s" % line
|
475
|
-
end
|
476
|
-
}
|
477
|
-
end
|
478
|
-
end
|
479
|
-
|
480
|
-
# Create a new config option.
|
481
|
-
def newelement(hash)
|
372
|
+
# Create a new setting. The value is passed in because it's used to determine
|
373
|
+
# what kind of setting we're creating, but the value itself might be either
|
374
|
+
# a default or a value, so we can't actually assign it.
|
375
|
+
def newsetting(hash)
|
482
376
|
klass = nil
|
483
377
|
if hash[:section]
|
484
|
-
hash[:section] =
|
378
|
+
hash[:section] = hash[:section].to_sym
|
485
379
|
end
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
when String, Integer, Float: # nothing
|
492
|
-
klass = CElement
|
380
|
+
if type = hash[:type]
|
381
|
+
unless klass = {:setting => Setting, :file => FileSetting, :boolean => BooleanSetting}[type]
|
382
|
+
raise ArgumentError, "Invalid setting type '%s'" % type
|
383
|
+
end
|
384
|
+
hash.delete(:type)
|
493
385
|
else
|
494
|
-
|
386
|
+
case hash[:default]
|
387
|
+
when true, false, "true", "false"
|
388
|
+
klass = BooleanSetting
|
389
|
+
when /^\$\w+\//, /^\//
|
390
|
+
klass = FileSetting
|
391
|
+
when String, Integer, Float # nothing
|
392
|
+
klass = Setting
|
393
|
+
else
|
394
|
+
raise Puppet::Error, "Invalid value '%s' for %s" % [value.inspect, hash[:name]]
|
395
|
+
end
|
495
396
|
end
|
496
397
|
hash[:settings] = self
|
497
|
-
|
398
|
+
setting = klass.new(hash)
|
498
399
|
|
499
|
-
return
|
400
|
+
return setting
|
500
401
|
end
|
501
402
|
|
502
|
-
# This has to be private, because it doesn't add the
|
503
|
-
private :
|
403
|
+
# This has to be private, because it doesn't add the settings to @config
|
404
|
+
private :newsetting
|
504
405
|
|
505
406
|
# Iterate across all of the objects in a given section.
|
506
407
|
def persection(section)
|
507
|
-
section =
|
408
|
+
section = section.to_sym
|
508
409
|
self.each { |name, obj|
|
509
410
|
if obj.section == section
|
510
411
|
yield obj
|
@@ -512,12 +413,20 @@ class Puppet::Util::Settings
|
|
512
413
|
}
|
513
414
|
end
|
514
415
|
|
416
|
+
# Cache this in an easily clearable way, since we were
|
417
|
+
# having trouble cleaning it up after tests.
|
418
|
+
cached_attr(:file) do
|
419
|
+
if path = self[:config] and FileTest.exist?(path)
|
420
|
+
Puppet::Util::LoadedFile.new(path)
|
421
|
+
end
|
422
|
+
end
|
423
|
+
|
515
424
|
# Reparse our config file, if necessary.
|
516
425
|
def reparse
|
517
|
-
if
|
518
|
-
Puppet.notice "Reparsing %s" %
|
426
|
+
if file and file.changed?
|
427
|
+
Puppet.notice "Reparsing %s" % file.file
|
519
428
|
@sync.synchronize do
|
520
|
-
parse
|
429
|
+
parse
|
521
430
|
end
|
522
431
|
reuse()
|
523
432
|
end
|
@@ -526,10 +435,9 @@ class Puppet::Util::Settings
|
|
526
435
|
def reuse
|
527
436
|
return unless defined? @used
|
528
437
|
@sync.synchronize do # yay, thread-safe
|
529
|
-
@used
|
530
|
-
|
531
|
-
|
532
|
-
end
|
438
|
+
new = @used
|
439
|
+
@used = []
|
440
|
+
self.use(*new)
|
533
441
|
end
|
534
442
|
end
|
535
443
|
|
@@ -557,45 +465,55 @@ class Puppet::Util::Settings
|
|
557
465
|
return sectionlist, sections
|
558
466
|
end
|
559
467
|
|
560
|
-
|
561
|
-
|
562
|
-
done ||= Hash.new { |hash, key| hash[key] = {} }
|
563
|
-
objects = []
|
564
|
-
persection(section) do |obj|
|
565
|
-
if @config[:mkusers] and value(:mkusers)
|
566
|
-
objects += add_user_resources(section, obj, done)
|
567
|
-
end
|
468
|
+
def service_user_available?
|
469
|
+
return @service_user_available if defined?(@service_user_available)
|
568
470
|
|
569
|
-
|
471
|
+
return @service_user_available = false unless user_name = self[:user]
|
570
472
|
|
571
|
-
|
572
|
-
next unless obj.respond_to? :to_transportable and transobjects = obj.to_transportable
|
473
|
+
user = Puppet::Type.type(:user).new :name => self[:user], :check => :ensure
|
573
474
|
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
475
|
+
return @service_user_available = user.exists?
|
476
|
+
end
|
477
|
+
|
478
|
+
def set_value(param, value, type)
|
479
|
+
param = param.to_sym
|
480
|
+
unless setting = @config[param]
|
481
|
+
raise ArgumentError,
|
482
|
+
"Attempt to assign a value to unknown configuration parameter %s" % param.inspect
|
483
|
+
end
|
484
|
+
if setting.respond_to?(:munge)
|
485
|
+
value = setting.munge(value)
|
584
486
|
end
|
487
|
+
if setting.respond_to?(:handle)
|
488
|
+
setting.handle(value)
|
489
|
+
end
|
490
|
+
# Reset the name, so it's looked up again.
|
491
|
+
if param == :name
|
492
|
+
@name = nil
|
493
|
+
end
|
494
|
+
@sync.synchronize do # yay, thread-safe
|
495
|
+
@values[type][param] = value
|
496
|
+
@cache.clear
|
585
497
|
|
586
|
-
|
587
|
-
bucket.type = "Settings"
|
588
|
-
bucket.name = section
|
589
|
-
bucket.push(*objects)
|
590
|
-
bucket.keyword = "class"
|
498
|
+
clearused
|
591
499
|
|
592
|
-
|
500
|
+
# Clear the list of environments, because they cache, at least, the module path.
|
501
|
+
# We *could* preferentially just clear them if the modulepath is changed,
|
502
|
+
# but we don't really know if, say, the vardir is changed and the modulepath
|
503
|
+
# is defined relative to it. We need the defined? stuff because of loading
|
504
|
+
# order issues.
|
505
|
+
Puppet::Node::Environment.clear if defined?(Puppet::Node) and defined?(Puppet::Node::Environment)
|
506
|
+
end
|
507
|
+
|
508
|
+
return value
|
593
509
|
end
|
594
510
|
|
511
|
+
private :set_value
|
512
|
+
|
595
513
|
# Set a bunch of defaults in a given section. The sections are actually pretty
|
596
514
|
# pointless, but they help break things up a bit, anyway.
|
597
515
|
def setdefaults(section, defs)
|
598
|
-
section =
|
516
|
+
section = section.to_sym
|
599
517
|
call = []
|
600
518
|
defs.each { |name, hash|
|
601
519
|
if hash.is_a? Array
|
@@ -606,13 +524,13 @@ class Puppet::Util::Settings
|
|
606
524
|
hash = {}
|
607
525
|
[:default, :desc].zip(tmp).each { |p,v| hash[p] = v }
|
608
526
|
end
|
609
|
-
name =
|
527
|
+
name = name.to_sym
|
610
528
|
hash[:name] = name
|
611
529
|
hash[:section] = section
|
612
530
|
if @config.include?(name)
|
613
531
|
raise ArgumentError, "Parameter %s is already defined" % name
|
614
532
|
end
|
615
|
-
tryconfig =
|
533
|
+
tryconfig = newsetting(hash)
|
616
534
|
if short = tryconfig.short
|
617
535
|
if other = @shortnames[short]
|
618
536
|
raise ArgumentError, "Parameter %s is already using short name '%s'" % [other.name, short]
|
@@ -631,25 +549,33 @@ class Puppet::Util::Settings
|
|
631
549
|
end
|
632
550
|
|
633
551
|
# Create a timer to check whether the file should be reparsed.
|
634
|
-
def
|
635
|
-
|
636
|
-
|
637
|
-
:interval => Puppet[:filetimeout],
|
638
|
-
:tolerance => 1,
|
639
|
-
:start? => true
|
640
|
-
) do
|
641
|
-
self.reparse()
|
642
|
-
end
|
643
|
-
end
|
552
|
+
def set_filetimeout_timer
|
553
|
+
return unless timeout = self[:filetimeout] and timeout = Integer(timeout) and timeout > 0
|
554
|
+
timer = EventLoop::Timer.new(:interval => timeout, :tolerance => 1, :start? => true) { self.reparse() }
|
644
555
|
end
|
645
556
|
|
646
|
-
# Convert
|
647
|
-
|
648
|
-
|
649
|
-
|
557
|
+
# Convert the settings we manage into a catalog full of resources that model those settings.
|
558
|
+
# We currently have to go through Trans{Object,Bucket} instances,
|
559
|
+
# because this hasn't been ported yet.
|
560
|
+
def to_catalog(*sections)
|
561
|
+
sections = nil if sections.empty?
|
562
|
+
|
563
|
+
catalog = Puppet::Resource::Catalog.new("Settings")
|
564
|
+
|
565
|
+
@config.values.find_all { |value| value.is_a?(FileSetting) }.each do |file|
|
566
|
+
next unless (sections.nil? or sections.include?(file.section))
|
567
|
+
next unless resource = file.to_resource
|
568
|
+
next if catalog.resource(resource.ref)
|
569
|
+
|
570
|
+
catalog.add_resource(resource)
|
571
|
+
end
|
572
|
+
|
573
|
+
add_user_resources(catalog, sections)
|
574
|
+
|
575
|
+
catalog
|
650
576
|
end
|
651
577
|
|
652
|
-
# Convert our list of config
|
578
|
+
# Convert our list of config settings into a configuration file.
|
653
579
|
def to_config
|
654
580
|
str = %{The configuration file for #{Puppet[:name]}. Note that this file
|
655
581
|
is likely to have unused configuration parameters in it; any parameter that's
|
@@ -677,62 +603,29 @@ Generated on #{Time.now}.
|
|
677
603
|
return str
|
678
604
|
end
|
679
605
|
|
680
|
-
# Convert our configuration into a list of transportable objects.
|
681
|
-
def to_transportable(*sections)
|
682
|
-
done = Hash.new { |hash, key|
|
683
|
-
hash[key] = {}
|
684
|
-
}
|
685
|
-
|
686
|
-
topbucket = Puppet::TransBucket.new
|
687
|
-
if defined? @file.file and @file.file
|
688
|
-
topbucket.name = @file.file
|
689
|
-
else
|
690
|
-
topbucket.name = "top"
|
691
|
-
end
|
692
|
-
topbucket.type = "Settings"
|
693
|
-
topbucket.top = true
|
694
|
-
|
695
|
-
# Now iterate over each section
|
696
|
-
if sections.empty?
|
697
|
-
eachsection do |section|
|
698
|
-
sections << section
|
699
|
-
end
|
700
|
-
end
|
701
|
-
sections.each do |section|
|
702
|
-
obj = section_to_transportable(section, done)
|
703
|
-
topbucket.push obj
|
704
|
-
end
|
705
|
-
|
706
|
-
topbucket
|
707
|
-
end
|
708
|
-
|
709
606
|
# Convert to a parseable manifest
|
710
607
|
def to_manifest
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
}
|
717
|
-
|
718
|
-
return manifest
|
608
|
+
catalog = to_catalog
|
609
|
+
# The resource list is a list of references, not actual instances.
|
610
|
+
catalog.resources.collect do |ref|
|
611
|
+
catalog.resource(ref).to_manifest
|
612
|
+
end.join("\n\n")
|
719
613
|
end
|
720
614
|
|
721
615
|
# Create the necessary objects to use a section. This is idempotent;
|
722
616
|
# you can 'use' a section as many times as you want.
|
723
617
|
def use(*sections)
|
618
|
+
sections = sections.collect { |s| s.to_sym }
|
724
619
|
@sync.synchronize do # yay, thread-safe
|
725
|
-
sections = sections.reject { |s| @used.include?(s
|
620
|
+
sections = sections.reject { |s| @used.include?(s) }
|
726
621
|
|
727
622
|
return if sections.empty?
|
728
623
|
|
729
|
-
bucket = to_transportable(*sections)
|
730
|
-
|
731
624
|
begin
|
732
|
-
catalog =
|
625
|
+
catalog = to_catalog(*sections).to_ral
|
733
626
|
rescue => detail
|
734
627
|
puts detail.backtrace if Puppet[:trace]
|
735
|
-
Puppet.err "Could not create resources for managing Puppet's files and directories: %s" % detail
|
628
|
+
Puppet.err "Could not create resources for managing Puppet's files and directories in sections %s: %s" % [sections.inspect, detail]
|
736
629
|
|
737
630
|
# We need some way to get rid of any resources created during the catalog creation
|
738
631
|
# but not cleaned up.
|
@@ -745,11 +638,9 @@ Generated on #{Time.now}.
|
|
745
638
|
if transaction.any_failed?
|
746
639
|
report = transaction.report
|
747
640
|
failures = report.logs.find_all { |log| log.level == :err }
|
748
|
-
raise "Got %s failure(s) while initializing: %s" % [failures.length, failures.collect { |l| l.to_s }.join("; ")]
|
641
|
+
raise "Got %s failure(s) while initializing: %s" % [failures.length, failures.collect { |l| l.to_s }.join("; ")]
|
749
642
|
end
|
750
643
|
end
|
751
|
-
ensure
|
752
|
-
catalog.clear
|
753
644
|
end
|
754
645
|
|
755
646
|
sections.each { |s| @used << s }
|
@@ -758,21 +649,21 @@ Generated on #{Time.now}.
|
|
758
649
|
end
|
759
650
|
|
760
651
|
def valid?(param)
|
761
|
-
param =
|
652
|
+
param = param.to_sym
|
762
653
|
@config.has_key?(param)
|
763
654
|
end
|
764
655
|
|
765
656
|
# Find the correct value using our search path. Optionally accept an environment
|
766
657
|
# in which to search before the other configuration sections.
|
767
658
|
def value(param, environment = nil)
|
768
|
-
param =
|
769
|
-
environment =
|
659
|
+
param = param.to_sym
|
660
|
+
environment = environment.to_sym if environment
|
770
661
|
|
771
662
|
# Short circuit to nil for undefined parameters.
|
772
663
|
return nil unless @config.include?(param)
|
773
664
|
|
774
665
|
# Yay, recursion.
|
775
|
-
self.reparse() unless
|
666
|
+
#self.reparse() unless [:config, :filetimeout].include?(param)
|
776
667
|
|
777
668
|
# Check the cache first. It needs to be a per-environment
|
778
669
|
# cache so that we don't spread values from one env
|
@@ -794,7 +685,7 @@ Generated on #{Time.now}.
|
|
794
685
|
end
|
795
686
|
throw :foundval, nil
|
796
687
|
end
|
797
|
-
|
688
|
+
|
798
689
|
# If we didn't get a value, use the default
|
799
690
|
val = @config[param].default if val.nil?
|
800
691
|
|
@@ -850,20 +741,26 @@ Generated on #{Time.now}.
|
|
850
741
|
end
|
851
742
|
|
852
743
|
sync.synchronize(Sync::EX) do
|
853
|
-
File.open(file,
|
744
|
+
File.open(file, ::File::CREAT|::File::RDWR, 0600) do |rf|
|
854
745
|
rf.lock_exclusive do
|
855
746
|
if File.exist?(tmpfile)
|
856
747
|
raise Puppet::Error, ".tmp file already exists for %s; Aborting locked write. Check the .tmp file and delete if appropriate" %
|
857
748
|
[file]
|
858
749
|
end
|
859
750
|
|
860
|
-
|
751
|
+
# If there's a failure, remove our tmpfile
|
752
|
+
begin
|
753
|
+
writesub(default, tmpfile, *args, &bloc)
|
754
|
+
rescue
|
755
|
+
File.unlink(tmpfile) if FileTest.exist?(tmpfile)
|
756
|
+
raise
|
757
|
+
end
|
861
758
|
|
862
759
|
begin
|
863
760
|
File.rename(tmpfile, file)
|
864
761
|
rescue => detail
|
865
|
-
Puppet.err "Could not rename %s to %s: %s" %
|
866
|
-
|
762
|
+
Puppet.err "Could not rename %s to %s: %s" % [file, tmpfile, detail]
|
763
|
+
File.unlink(tmpfile) if FileTest.exist?(tmpfile)
|
867
764
|
end
|
868
765
|
end
|
869
766
|
end
|
@@ -878,53 +775,33 @@ Generated on #{Time.now}.
|
|
878
775
|
raise ArgumentError, "Unknown default %s" % default
|
879
776
|
end
|
880
777
|
|
881
|
-
unless obj.is_a?
|
778
|
+
unless obj.is_a? FileSetting
|
882
779
|
raise ArgumentError, "Default %s is not a file" % default
|
883
780
|
end
|
884
781
|
|
885
782
|
return obj
|
886
783
|
end
|
887
|
-
|
784
|
+
|
888
785
|
# Create the transportable objects for users and groups.
|
889
|
-
def add_user_resources(
|
890
|
-
|
891
|
-
[:
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
# Skip root or wheel
|
902
|
-
next if %w{root wheel}.include?(name.to_s)
|
903
|
-
|
904
|
-
# Skip owners and groups we've already done, but tag
|
905
|
-
# them with our section if necessary
|
906
|
-
if done[type].include?(name)
|
907
|
-
tags = done[type][name].tags
|
908
|
-
unless tags.include?(section)
|
909
|
-
done[type][name].tags = tags << section
|
910
|
-
end
|
911
|
-
else
|
912
|
-
newobj = Puppet::TransObject.new(name, type.to_s)
|
913
|
-
newobj.tags = ["puppet", "configuration", section]
|
914
|
-
newobj[:ensure] = :present
|
915
|
-
if type == :user
|
916
|
-
newobj[:comment] ||= "%s user" % name
|
917
|
-
end
|
918
|
-
# Set the group appropriately for the user
|
919
|
-
if type == :user
|
920
|
-
newobj[:gid] = Puppet[:group]
|
921
|
-
end
|
922
|
-
done[type][name] = newobj
|
923
|
-
resources << newobj
|
786
|
+
def add_user_resources(catalog, sections)
|
787
|
+
return unless Puppet.features.root?
|
788
|
+
return unless self[:mkusers]
|
789
|
+
|
790
|
+
@config.each do |name, setting|
|
791
|
+
next unless setting.respond_to?(:owner)
|
792
|
+
next unless sections.nil? or sections.include?(setting.section)
|
793
|
+
|
794
|
+
if user = setting.owner and user != "root" and catalog.resource(:user, user).nil?
|
795
|
+
resource = Puppet::Resource.new(:user, user, :ensure => :present)
|
796
|
+
if self[:group]
|
797
|
+
resource[:gid] = self[:group]
|
924
798
|
end
|
799
|
+
catalog.add_resource resource
|
800
|
+
end
|
801
|
+
if group = setting.group and ! %w{root wheel}.include?(group) and catalog.resource(:group, group).nil?
|
802
|
+
catalog.add_resource Puppet::Resource.new(:group, group, :ensure => :present)
|
925
803
|
end
|
926
804
|
end
|
927
|
-
resources
|
928
805
|
end
|
929
806
|
|
930
807
|
# Yield each search source in turn.
|
@@ -936,7 +813,7 @@ Generated on #{Time.now}.
|
|
936
813
|
end
|
937
814
|
end
|
938
815
|
|
939
|
-
# Return all
|
816
|
+
# Return all settings that have associated hooks; this is so
|
940
817
|
# we can call them after parsing the configuration file.
|
941
818
|
def settings_with_hooks
|
942
819
|
@config.values.find_all { |setting| setting.respond_to?(:handle) }
|
@@ -966,17 +843,17 @@ Generated on #{Time.now}.
|
|
966
843
|
end
|
967
844
|
result[:value] = value.sub(/\s*$/, '')
|
968
845
|
return result
|
969
|
-
|
970
|
-
return nil
|
971
846
|
end
|
972
847
|
|
973
848
|
# Convert arguments into booleans, integers, or whatever.
|
974
849
|
def munge_value(value)
|
975
850
|
# Handle different data types correctly
|
976
851
|
return case value
|
977
|
-
when /^false$/i
|
978
|
-
when /^true$/i
|
979
|
-
when /^\d+$/i
|
852
|
+
when /^false$/i; false
|
853
|
+
when /^true$/i; true
|
854
|
+
when /^\d+$/i; Integer(value)
|
855
|
+
when true; true
|
856
|
+
when false; false
|
980
857
|
else
|
981
858
|
value.gsub(/^["']|["']$/,'').sub(/\s+$/, '')
|
982
859
|
end
|
@@ -989,10 +866,6 @@ Generated on #{Time.now}.
|
|
989
866
|
def parse_file(file)
|
990
867
|
text = read_file(file)
|
991
868
|
|
992
|
-
# Create a timer so that this file will get checked automatically
|
993
|
-
# and reparsed if necessary.
|
994
|
-
settimer()
|
995
|
-
|
996
869
|
result = Hash.new { |names, name|
|
997
870
|
names[name] = {}
|
998
871
|
}
|
@@ -1005,13 +878,13 @@ Generated on #{Time.now}.
|
|
1005
878
|
text.split(/\n/).each { |line|
|
1006
879
|
count += 1
|
1007
880
|
case line
|
1008
|
-
when /^\s*\[(\w+)\]
|
881
|
+
when /^\s*\[(\w+)\]$/
|
1009
882
|
section = $1.intern # Section names
|
1010
883
|
# Add a meta section
|
1011
884
|
result[section][:_meta] ||= {}
|
1012
|
-
when /^\s
|
1013
|
-
when /^\s
|
1014
|
-
when /^\s*(\w+)\s*=\s*(.*)
|
885
|
+
when /^\s*#/; next # Skip comments
|
886
|
+
when /^\s*$/; next # Skip blanks
|
887
|
+
when /^\s*(\w+)\s*=\s*(.*)$/ # settings
|
1015
888
|
var = $1.intern
|
1016
889
|
|
1017
890
|
# We don't want to munge modes, because they're specified in octal, so we'll
|
@@ -1048,14 +921,8 @@ Generated on #{Time.now}.
|
|
1048
921
|
|
1049
922
|
# Read the file in.
|
1050
923
|
def read_file(file)
|
1051
|
-
if file.is_a? Puppet::Util::LoadedFile
|
1052
|
-
@file = file
|
1053
|
-
else
|
1054
|
-
@file = Puppet::Util::LoadedFile.new(file)
|
1055
|
-
end
|
1056
|
-
|
1057
924
|
begin
|
1058
|
-
return File.read(
|
925
|
+
return File.read(file)
|
1059
926
|
rescue Errno::ENOENT
|
1060
927
|
raise ArgumentError, "No such file %s" % file
|
1061
928
|
rescue Errno::EACCES
|
@@ -1071,246 +938,4 @@ Generated on #{Time.now}.
|
|
1071
938
|
end
|
1072
939
|
end
|
1073
940
|
end
|
1074
|
-
|
1075
|
-
# The base element type.
|
1076
|
-
class CElement
|
1077
|
-
attr_accessor :name, :section, :default, :setbycli, :call_on_define
|
1078
|
-
attr_reader :desc, :short
|
1079
|
-
|
1080
|
-
def desc=(value)
|
1081
|
-
@desc = value.gsub(/^\s*/, '')
|
1082
|
-
end
|
1083
|
-
|
1084
|
-
# get the arguments in getopt format
|
1085
|
-
def getopt_args
|
1086
|
-
if short
|
1087
|
-
[["--#{name}", "-#{short}", GetoptLong::REQUIRED_ARGUMENT]]
|
1088
|
-
else
|
1089
|
-
[["--#{name}", GetoptLong::REQUIRED_ARGUMENT]]
|
1090
|
-
end
|
1091
|
-
end
|
1092
|
-
|
1093
|
-
def hook=(block)
|
1094
|
-
meta_def :handle, &block
|
1095
|
-
end
|
1096
|
-
|
1097
|
-
# Create the new element. Pretty much just sets the name.
|
1098
|
-
def initialize(args = {})
|
1099
|
-
@settings = args.delete(:settings)
|
1100
|
-
raise ArgumentError.new("You must refer to a settings object") if @settings.nil? or !@settings.is_a?(Puppet::Util::Settings)
|
1101
|
-
|
1102
|
-
args.each do |param, value|
|
1103
|
-
method = param.to_s + "="
|
1104
|
-
unless self.respond_to? method
|
1105
|
-
raise ArgumentError, "%s does not accept %s" % [self.class, param]
|
1106
|
-
end
|
1107
|
-
|
1108
|
-
self.send(method, value)
|
1109
|
-
end
|
1110
|
-
|
1111
|
-
unless self.desc
|
1112
|
-
raise ArgumentError, "You must provide a description for the %s config option" % self.name
|
1113
|
-
end
|
1114
|
-
end
|
1115
|
-
|
1116
|
-
def iscreated
|
1117
|
-
@iscreated = true
|
1118
|
-
end
|
1119
|
-
|
1120
|
-
def iscreated?
|
1121
|
-
if defined? @iscreated
|
1122
|
-
return @iscreated
|
1123
|
-
else
|
1124
|
-
return false
|
1125
|
-
end
|
1126
|
-
end
|
1127
|
-
|
1128
|
-
def set?
|
1129
|
-
if defined? @value and ! @value.nil?
|
1130
|
-
return true
|
1131
|
-
else
|
1132
|
-
return false
|
1133
|
-
end
|
1134
|
-
end
|
1135
|
-
|
1136
|
-
# short name for the celement
|
1137
|
-
def short=(value)
|
1138
|
-
if value.to_s.length != 1
|
1139
|
-
raise ArgumentError, "Short names can only be one character."
|
1140
|
-
end
|
1141
|
-
@short = value.to_s
|
1142
|
-
end
|
1143
|
-
|
1144
|
-
# Convert the object to a config statement.
|
1145
|
-
def to_config
|
1146
|
-
str = @desc.gsub(/^/, "# ") + "\n"
|
1147
|
-
|
1148
|
-
# Add in a statement about the default.
|
1149
|
-
if defined? @default and @default
|
1150
|
-
str += "# The default value is '%s'.\n" % @default
|
1151
|
-
end
|
1152
|
-
|
1153
|
-
# If the value has not been overridden, then print it out commented
|
1154
|
-
# and unconverted, so it's clear that that's the default and how it
|
1155
|
-
# works.
|
1156
|
-
value = @settings.value(self.name)
|
1157
|
-
|
1158
|
-
if value != @default
|
1159
|
-
line = "%s = %s" % [@name, value]
|
1160
|
-
else
|
1161
|
-
line = "# %s = %s" % [@name, @default]
|
1162
|
-
end
|
1163
|
-
|
1164
|
-
str += line + "\n"
|
1165
|
-
|
1166
|
-
str.gsub(/^/, " ")
|
1167
|
-
end
|
1168
|
-
|
1169
|
-
# Retrieves the value, or if it's not set, retrieves the default.
|
1170
|
-
def value
|
1171
|
-
@settings.value(self.name)
|
1172
|
-
end
|
1173
|
-
end
|
1174
|
-
|
1175
|
-
# A file.
|
1176
|
-
class CFile < CElement
|
1177
|
-
attr_writer :owner, :group
|
1178
|
-
attr_accessor :mode, :create
|
1179
|
-
|
1180
|
-
def group
|
1181
|
-
if defined? @group
|
1182
|
-
return @settings.convert(@group)
|
1183
|
-
else
|
1184
|
-
return nil
|
1185
|
-
end
|
1186
|
-
end
|
1187
|
-
|
1188
|
-
def owner
|
1189
|
-
if defined? @owner
|
1190
|
-
return @settings.convert(@owner)
|
1191
|
-
else
|
1192
|
-
return nil
|
1193
|
-
end
|
1194
|
-
end
|
1195
|
-
|
1196
|
-
# Set the type appropriately. Yep, a hack. This supports either naming
|
1197
|
-
# the variable 'dir', or adding a slash at the end.
|
1198
|
-
def munge(value)
|
1199
|
-
# If it's not a fully qualified path...
|
1200
|
-
if value.is_a?(String) and value !~ /^\$/ and value !~ /^\// and value != 'false'
|
1201
|
-
# Make it one
|
1202
|
-
value = File.join(Dir.getwd, value)
|
1203
|
-
end
|
1204
|
-
if value.to_s =~ /\/$/
|
1205
|
-
@type = :directory
|
1206
|
-
return value.sub(/\/$/, '')
|
1207
|
-
end
|
1208
|
-
return value
|
1209
|
-
end
|
1210
|
-
|
1211
|
-
# Return the appropriate type.
|
1212
|
-
def type
|
1213
|
-
value = @settings.value(self.name)
|
1214
|
-
if @name.to_s =~ /dir/
|
1215
|
-
return :directory
|
1216
|
-
elsif value.to_s =~ /\/$/
|
1217
|
-
return :directory
|
1218
|
-
elsif value.is_a? String
|
1219
|
-
return :file
|
1220
|
-
else
|
1221
|
-
return nil
|
1222
|
-
end
|
1223
|
-
end
|
1224
|
-
|
1225
|
-
# Convert the object to a TransObject instance.
|
1226
|
-
def to_transportable
|
1227
|
-
type = self.type
|
1228
|
-
return nil unless type
|
1229
|
-
|
1230
|
-
path = self.value
|
1231
|
-
|
1232
|
-
return nil unless path.is_a?(String)
|
1233
|
-
return nil if path =~ /^\/dev/
|
1234
|
-
return nil if Puppet::Type.type(:file)[path] # skip files that are in our global resource list.
|
1235
|
-
|
1236
|
-
objects = []
|
1237
|
-
|
1238
|
-
# Skip plain files that don't exist, since we won't be managing them anyway.
|
1239
|
-
return nil unless self.name.to_s =~ /dir$/ or File.exist?(path) or self.create
|
1240
|
-
obj = Puppet::TransObject.new(path, "file")
|
1241
|
-
|
1242
|
-
# Only create directories, or files that are specifically marked to
|
1243
|
-
# create.
|
1244
|
-
if type == :directory or self.create
|
1245
|
-
obj[:ensure] = type
|
1246
|
-
end
|
1247
|
-
[:mode].each { |var|
|
1248
|
-
if value = self.send(var)
|
1249
|
-
# Don't bother converting the mode, since the file type
|
1250
|
-
# can handle it any old way.
|
1251
|
-
obj[var] = value
|
1252
|
-
end
|
1253
|
-
}
|
1254
|
-
|
1255
|
-
# Only chown or chgrp when root
|
1256
|
-
if Puppet.features.root?
|
1257
|
-
[:group, :owner].each { |var|
|
1258
|
-
if value = self.send(var)
|
1259
|
-
obj[var] = value
|
1260
|
-
end
|
1261
|
-
}
|
1262
|
-
end
|
1263
|
-
|
1264
|
-
# And set the loglevel to debug for everything
|
1265
|
-
obj[:loglevel] = "debug"
|
1266
|
-
|
1267
|
-
# We're not actually modifying any files here, and if we allow a
|
1268
|
-
# filebucket to get used here we get into an infinite recursion
|
1269
|
-
# trying to set the filebucket up.
|
1270
|
-
obj[:backup] = false
|
1271
|
-
|
1272
|
-
if self.section
|
1273
|
-
obj.tags += ["puppet", "configuration", self.section, self.name]
|
1274
|
-
end
|
1275
|
-
objects << obj
|
1276
|
-
objects
|
1277
|
-
end
|
1278
|
-
|
1279
|
-
# Make sure any provided variables look up to something.
|
1280
|
-
def validate(value)
|
1281
|
-
return true unless value.is_a? String
|
1282
|
-
value.scan(/\$(\w+)/) { |name|
|
1283
|
-
name = $1
|
1284
|
-
unless @settings.include?(name)
|
1285
|
-
raise ArgumentError,
|
1286
|
-
"Settings parameter '%s' is undefined" %
|
1287
|
-
name
|
1288
|
-
end
|
1289
|
-
}
|
1290
|
-
end
|
1291
|
-
end
|
1292
|
-
|
1293
|
-
# A simple boolean.
|
1294
|
-
class CBoolean < CElement
|
1295
|
-
# get the arguments in getopt format
|
1296
|
-
def getopt_args
|
1297
|
-
if short
|
1298
|
-
[["--#{name}", "-#{short}", GetoptLong::NO_ARGUMENT],
|
1299
|
-
["--no-#{name}", GetoptLong::NO_ARGUMENT]]
|
1300
|
-
else
|
1301
|
-
[["--#{name}", GetoptLong::NO_ARGUMENT],
|
1302
|
-
["--no-#{name}", GetoptLong::NO_ARGUMENT]]
|
1303
|
-
end
|
1304
|
-
end
|
1305
|
-
|
1306
|
-
def munge(value)
|
1307
|
-
case value
|
1308
|
-
when true, "true": return true
|
1309
|
-
when false, "false": return false
|
1310
|
-
else
|
1311
|
-
raise ArgumentError, "Invalid value '%s' for %s" %
|
1312
|
-
[value.inspect, @name]
|
1313
|
-
end
|
1314
|
-
end
|
1315
|
-
end
|
1316
941
|
end
|