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
data/lib/puppet/type/file.rb
CHANGED
@@ -6,17 +6,20 @@ require 'fileutils'
|
|
6
6
|
require 'puppet/network/handler'
|
7
7
|
require 'puppet/util/diff'
|
8
8
|
require 'puppet/util/checksums'
|
9
|
+
require 'puppet/network/client'
|
10
|
+
require 'puppet/util/backups'
|
9
11
|
|
10
12
|
module Puppet
|
11
13
|
newtype(:file) do
|
12
14
|
include Puppet::Util::MethodHelper
|
13
15
|
include Puppet::Util::Checksums
|
16
|
+
include Puppet::Util::Backups
|
14
17
|
@doc = "Manages local files, including setting ownership and
|
15
18
|
permissions, creation of both files and directories, and
|
16
19
|
retrieving entire files from remote servers. As Puppet matures, it
|
17
20
|
expected that the ``file`` resource will be used less and less to
|
18
21
|
manage content, and instead native resources will be used to do so.
|
19
|
-
|
22
|
+
|
20
23
|
If you find that you are often copying files in from a central
|
21
24
|
location, rather than using native resources, please contact
|
22
25
|
Reductive Labs and we can hopefully work with you to develop a
|
@@ -28,9 +31,21 @@ module Puppet
|
|
28
31
|
|
29
32
|
validate do |value|
|
30
33
|
unless value =~ /^#{File::SEPARATOR}/
|
31
|
-
raise Puppet::Error, "File paths must be fully qualified"
|
34
|
+
raise Puppet::Error, "File paths must be fully qualified, not '%s'" % value
|
32
35
|
end
|
33
36
|
end
|
37
|
+
|
38
|
+
# convert the current path in an index into the collection and the last
|
39
|
+
# path name. The aim is to use less storage for all common paths in a hierarchy
|
40
|
+
munge do |value|
|
41
|
+
path, name = File.split(value)
|
42
|
+
{ :index => Puppet::FileCollection.collection.index(path), :name => name }
|
43
|
+
end
|
44
|
+
|
45
|
+
# and the reverse
|
46
|
+
unmunge do |value|
|
47
|
+
File.join( Puppet::FileCollection.collection.path(value[:index]), value[:name] )
|
48
|
+
end
|
34
49
|
end
|
35
50
|
|
36
51
|
newparam(:backup) do
|
@@ -45,11 +60,11 @@ module Puppet
|
|
45
60
|
the same directory with that value as the extension of the
|
46
61
|
backup. Setting ``backup => false`` disables all backups of the
|
47
62
|
file in question.
|
48
|
-
|
63
|
+
|
49
64
|
Puppet automatically creates a local filebucket named ``puppet`` and
|
50
65
|
defaults to backing up there. To use a server-based filebucket,
|
51
66
|
you must specify one in your configuration::
|
52
|
-
|
67
|
+
|
53
68
|
filebucket { main:
|
54
69
|
server => puppet
|
55
70
|
}
|
@@ -74,39 +89,21 @@ module Puppet
|
|
74
89
|
filebucketed files.
|
75
90
|
"
|
76
91
|
|
77
|
-
defaultto
|
78
|
-
|
92
|
+
defaultto "puppet"
|
93
|
+
|
79
94
|
munge do |value|
|
80
95
|
# I don't really know how this is happening.
|
81
|
-
if value.is_a?(Array)
|
82
|
-
|
83
|
-
end
|
96
|
+
value = value.shift if value.is_a?(Array)
|
97
|
+
|
84
98
|
case value
|
85
|
-
when false, "false", :false
|
99
|
+
when false, "false", :false
|
86
100
|
false
|
87
|
-
when true, "true", ".puppet-bak", :true
|
101
|
+
when true, "true", ".puppet-bak", :true
|
88
102
|
".puppet-bak"
|
89
|
-
when
|
103
|
+
when String
|
90
104
|
value
|
91
|
-
when String:
|
92
|
-
# We can't depend on looking this up right now,
|
93
|
-
# we have to do it after all of the objects
|
94
|
-
# have been instantiated.
|
95
|
-
if bucketobj = Puppet::Type.type(:filebucket)[value]
|
96
|
-
@resource.bucket = bucketobj.bucket
|
97
|
-
bucketobj.title
|
98
|
-
else
|
99
|
-
# Set it to the string; finish() turns it into a
|
100
|
-
# filebucket.
|
101
|
-
@resource.bucket = value
|
102
|
-
value
|
103
|
-
end
|
104
|
-
when Puppet::Network::Client.client(:Dipper):
|
105
|
-
@resource.bucket = value
|
106
|
-
value.name
|
107
105
|
else
|
108
|
-
self.fail "Invalid backup type %s" %
|
109
|
-
value.inspect
|
106
|
+
self.fail "Invalid backup type %s" % value.inspect
|
110
107
|
end
|
111
108
|
end
|
112
109
|
end
|
@@ -115,7 +112,7 @@ module Puppet
|
|
115
112
|
desc "Whether and how deeply to do recursive
|
116
113
|
management."
|
117
114
|
|
118
|
-
newvalues(:true, :false, :inf, /^[0-9]+$/)
|
115
|
+
newvalues(:true, :false, :inf, :remote, /^[0-9]+$/)
|
119
116
|
|
120
117
|
# Replace the validation so that we allow numbers in
|
121
118
|
# addition to string representations of them.
|
@@ -125,10 +122,42 @@ module Puppet
|
|
125
122
|
case newval
|
126
123
|
when :true, :inf: true
|
127
124
|
when :false: false
|
125
|
+
when :remote: :remote
|
126
|
+
when Integer, Fixnum, Bignum:
|
127
|
+
self.warning "Setting recursion depth with the recurse parameter is now deprecated, please use recurselimit"
|
128
|
+
|
129
|
+
# recurse == 0 means no recursion
|
130
|
+
return false if value == 0
|
131
|
+
|
132
|
+
resource[:recurselimit] = value
|
133
|
+
true
|
134
|
+
when /^\d+$/:
|
135
|
+
self.warning "Setting recursion depth with the recurse parameter is now deprecated, please use recurselimit"
|
136
|
+
value = Integer(value)
|
137
|
+
|
138
|
+
# recurse == 0 means no recursion
|
139
|
+
return false if value == 0
|
140
|
+
|
141
|
+
resource[:recurselimit] = value
|
142
|
+
true
|
143
|
+
else
|
144
|
+
raise ArgumentError, "Invalid recurse value %s" % value.inspect
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
newparam(:recurselimit) do
|
150
|
+
desc "How deeply to do recursive management."
|
151
|
+
|
152
|
+
newvalues(/^[0-9]+$/)
|
153
|
+
|
154
|
+
munge do |value|
|
155
|
+
newval = super(value)
|
156
|
+
case newval
|
128
157
|
when Integer, Fixnum, Bignum: value
|
129
158
|
when /^\d+$/: Integer(value)
|
130
159
|
else
|
131
|
-
raise ArgumentError, "Invalid
|
160
|
+
raise ArgumentError, "Invalid recurselimit value %s" % value.inspect
|
132
161
|
end
|
133
162
|
end
|
134
163
|
end
|
@@ -156,8 +185,6 @@ module Puppet
|
|
156
185
|
engine, so shell metacharacters are fully supported, e.g. ``[a-z]*``.
|
157
186
|
Matches that would descend into the directory structure are ignored,
|
158
187
|
e.g., ``*/*``."
|
159
|
-
|
160
|
-
defaultto false
|
161
188
|
|
162
189
|
validate do |value|
|
163
190
|
unless value.is_a?(Array) or value.is_a?(String) or value == false
|
@@ -186,7 +213,7 @@ module Puppet
|
|
186
213
|
this will destroy data. Only use this option for generated
|
187
214
|
files unless you really know what you are doing. This option only
|
188
215
|
makes sense when recursively managing directories.
|
189
|
-
|
216
|
+
|
190
217
|
Note that when using ``purge`` with ``source``, Puppet will purge any files
|
191
218
|
that are not on the remote system."
|
192
219
|
|
@@ -207,15 +234,13 @@ module Puppet
|
|
207
234
|
|
208
235
|
newvalues(:first, :all)
|
209
236
|
end
|
210
|
-
|
211
|
-
attr_accessor :bucket
|
212
237
|
|
213
238
|
# Autorequire any parent directories.
|
214
239
|
autorequire(:file) do
|
215
|
-
|
216
|
-
|
240
|
+
basedir = File.dirname(self[:path])
|
241
|
+
if basedir != self[:path]
|
242
|
+
basedir
|
217
243
|
else
|
218
|
-
Puppet.err "no path for %s, somehow; cannot setup autorequires" % self.ref
|
219
244
|
nil
|
220
245
|
end
|
221
246
|
end
|
@@ -235,7 +260,7 @@ module Puppet
|
|
235
260
|
end
|
236
261
|
end
|
237
262
|
end
|
238
|
-
|
263
|
+
|
239
264
|
CREATORS = [:content, :source, :target]
|
240
265
|
|
241
266
|
validate do
|
@@ -243,11 +268,22 @@ module Puppet
|
|
243
268
|
CREATORS.each do |param|
|
244
269
|
count += 1 if self.should(param)
|
245
270
|
end
|
271
|
+
if @parameters.include?(:source)
|
272
|
+
count += 1
|
273
|
+
end
|
246
274
|
if count > 1
|
247
275
|
self.fail "You cannot specify more than one of %s" % CREATORS.collect { |p| p.to_s}.join(", ")
|
248
276
|
end
|
277
|
+
|
278
|
+
if !self[:source] and self[:recurse] == :remote
|
279
|
+
self.fail "You cannot specify a remote recursion without a source"
|
280
|
+
end
|
281
|
+
|
282
|
+
if !self[:recurse] and self[:recurselimit]
|
283
|
+
self.warning "Possible error: recurselimit is set but not recurse, no recursion will happen"
|
284
|
+
end
|
249
285
|
end
|
250
|
-
|
286
|
+
|
251
287
|
def self.[](path)
|
252
288
|
return nil unless path
|
253
289
|
super(path.gsub(/\/+/, '/').sub(/\/$/, ''))
|
@@ -268,7 +304,7 @@ module Puppet
|
|
268
304
|
obj[:check] = :all
|
269
305
|
files << obj
|
270
306
|
else
|
271
|
-
files << self.
|
307
|
+
files << self.new(
|
272
308
|
:name => path, :check => :all
|
273
309
|
)
|
274
310
|
end
|
@@ -278,11 +314,6 @@ module Puppet
|
|
278
314
|
|
279
315
|
@depthfirst = false
|
280
316
|
|
281
|
-
|
282
|
-
def argument?(arg)
|
283
|
-
@arghash.include?(arg)
|
284
|
-
end
|
285
|
-
|
286
317
|
# Determine the user to write files as.
|
287
318
|
def asuser
|
288
319
|
if self.should(:owner) and ! self.should(:owner).is_a?(Symbol)
|
@@ -301,159 +332,68 @@ module Puppet
|
|
301
332
|
return asuser
|
302
333
|
end
|
303
334
|
|
335
|
+
def bucket
|
336
|
+
return @bucket if defined?(@bucket) and @bucket
|
337
|
+
|
338
|
+
backup = self[:backup]
|
339
|
+
return nil unless backup
|
340
|
+
return nil if backup =~ /^\./
|
341
|
+
|
342
|
+
unless catalog or backup == "puppet"
|
343
|
+
fail "Can not find filebucket for backups without a catalog"
|
344
|
+
end
|
345
|
+
|
346
|
+
unless catalog and filebucket = catalog.resource(:filebucket, backup) or backup == "puppet"
|
347
|
+
fail "Could not find filebucket %s specified in backup" % backup
|
348
|
+
end
|
349
|
+
|
350
|
+
return default_bucket unless filebucket
|
351
|
+
|
352
|
+
@bucket = filebucket.bucket
|
353
|
+
|
354
|
+
return @bucket
|
355
|
+
end
|
356
|
+
|
357
|
+
def default_bucket
|
358
|
+
Puppet::Type.type(:filebucket).mkdefaultbucket.bucket
|
359
|
+
end
|
360
|
+
|
361
|
+
# Does the file currently exist? Just checks for whether
|
362
|
+
# we have a stat
|
363
|
+
def exist?
|
364
|
+
stat ? true : false
|
365
|
+
end
|
366
|
+
|
304
367
|
# We have to do some extra finishing, to retrieve our bucket if
|
305
368
|
# there is one.
|
306
369
|
def finish
|
307
|
-
# Let's cache these values, since there should really only be
|
308
|
-
# a couple of these buckets
|
309
|
-
@@filebuckets ||= {}
|
310
|
-
|
311
370
|
# Look up our bucket, if there is one
|
312
|
-
|
313
|
-
case bucket
|
314
|
-
when String:
|
315
|
-
if obj = @@filebuckets[bucket]
|
316
|
-
# This sets the @value on :backup, too
|
317
|
-
self.bucket = obj
|
318
|
-
elsif bucket == "puppet"
|
319
|
-
obj = Puppet::Network::Client.client(:Dipper).new(
|
320
|
-
:Path => Puppet[:clientbucketdir]
|
321
|
-
)
|
322
|
-
self.bucket = obj
|
323
|
-
@@filebuckets[bucket] = obj
|
324
|
-
elsif obj = Puppet::Type.type(:filebucket).bucket(bucket)
|
325
|
-
@@filebuckets[bucket] = obj
|
326
|
-
self.bucket = obj
|
327
|
-
else
|
328
|
-
self.fail "Could not find filebucket %s" % bucket
|
329
|
-
end
|
330
|
-
when Puppet::Network::Client.client(:Dipper): # things are hunky-dorey
|
331
|
-
else
|
332
|
-
self.fail "Invalid bucket type %s" % bucket.class
|
333
|
-
end
|
334
|
-
end
|
371
|
+
bucket()
|
335
372
|
super
|
336
373
|
end
|
337
|
-
|
374
|
+
|
338
375
|
# Create any children via recursion or whatever.
|
339
376
|
def eval_generate
|
340
|
-
recurse
|
341
|
-
end
|
377
|
+
return [] unless self.recurse?
|
342
378
|
|
343
|
-
|
344
|
-
|
345
|
-
#
|
346
|
-
|
347
|
-
#
|
348
|
-
#
|
349
|
-
|
350
|
-
|
351
|
-
end
|
352
|
-
|
353
|
-
unless self[:backup]
|
354
|
-
return true
|
355
|
-
end
|
379
|
+
recurse
|
380
|
+
#recurse.reject do |resource|
|
381
|
+
# catalog.resource(:file, resource[:path])
|
382
|
+
#end.each do |child|
|
383
|
+
# catalog.add_resource child
|
384
|
+
# catalog.relationship_graph.add_edge self, child
|
385
|
+
#end
|
386
|
+
end
|
356
387
|
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
return true
|
362
|
-
else
|
363
|
-
backup = self.bucket || self[:backup]
|
364
|
-
case backup
|
365
|
-
when Puppet::Network::Client.client(:Dipper):
|
366
|
-
notice "Recursively backing up to filebucket"
|
367
|
-
require 'find'
|
368
|
-
Find.find(self[:path]) do |f|
|
369
|
-
if File.file?(f)
|
370
|
-
sum = backup.backup(f)
|
371
|
-
self.notice "Filebucketed %s to %s with sum %s" %
|
372
|
-
[f, backup.name, sum]
|
373
|
-
end
|
374
|
-
end
|
375
|
-
|
376
|
-
return true
|
377
|
-
when String:
|
378
|
-
newfile = file + backup
|
379
|
-
# Just move it, since it's a directory.
|
380
|
-
if FileTest.exists?(newfile)
|
381
|
-
remove_backup(newfile)
|
382
|
-
end
|
383
|
-
begin
|
384
|
-
bfile = file + backup
|
385
|
-
|
386
|
-
# Ruby 1.8.1 requires the 'preserve' addition, but
|
387
|
-
# later versions do not appear to require it.
|
388
|
-
FileUtils.cp_r(file, bfile, :preserve => true)
|
389
|
-
return true
|
390
|
-
rescue => detail
|
391
|
-
# since they said they want a backup, let's error out
|
392
|
-
# if we couldn't make one
|
393
|
-
self.fail "Could not back %s up: %s" %
|
394
|
-
[file, detail.message]
|
395
|
-
end
|
396
|
-
else
|
397
|
-
self.err "Invalid backup type %s" % backup.inspect
|
398
|
-
return false
|
399
|
-
end
|
400
|
-
end
|
401
|
-
when "file":
|
402
|
-
backup = self.bucket || self[:backup]
|
403
|
-
case backup
|
404
|
-
when Puppet::Network::Client.client(:Dipper):
|
405
|
-
sum = backup.backup(file)
|
406
|
-
self.notice "Filebucketed to %s with sum %s" %
|
407
|
-
[backup.name, sum]
|
408
|
-
return true
|
409
|
-
when String:
|
410
|
-
newfile = file + backup
|
411
|
-
if FileTest.exists?(newfile)
|
412
|
-
remove_backup(newfile)
|
413
|
-
end
|
414
|
-
begin
|
415
|
-
# FIXME Shouldn't this just use a Puppet object with
|
416
|
-
# 'source' specified?
|
417
|
-
bfile = file + backup
|
418
|
-
|
419
|
-
# Ruby 1.8.1 requires the 'preserve' addition, but
|
420
|
-
# later versions do not appear to require it.
|
421
|
-
FileUtils.cp(file, bfile, :preserve => true)
|
422
|
-
return true
|
423
|
-
rescue => detail
|
424
|
-
# since they said they want a backup, let's error out
|
425
|
-
# if we couldn't make one
|
426
|
-
self.fail "Could not back %s up: %s" %
|
427
|
-
[file, detail.message]
|
428
|
-
end
|
429
|
-
else
|
430
|
-
self.err "Invalid backup type %s" % backup.inspect
|
431
|
-
return false
|
432
|
-
end
|
433
|
-
when "link": return true
|
434
|
-
else
|
435
|
-
self.notice "Cannot backup files of type %s" %
|
436
|
-
File.stat(file).ftype
|
437
|
-
return false
|
388
|
+
def flush
|
389
|
+
# We want to make sure we retrieve metadata anew on each transaction.
|
390
|
+
@parameters.each do |name, param|
|
391
|
+
param.flush if param.respond_to?(:flush)
|
438
392
|
end
|
393
|
+
@stat = nil
|
439
394
|
end
|
440
|
-
|
441
|
-
def handleignore(children)
|
442
|
-
return children unless self[:ignore]
|
443
|
-
self[:ignore].each { |ignore|
|
444
|
-
ignored = []
|
445
|
-
Dir.glob(File.join(self[:path],ignore), File::FNM_DOTMATCH) {
|
446
|
-
|match| ignored.push(File.basename(match))
|
447
|
-
}
|
448
|
-
children = children - ignored
|
449
|
-
}
|
450
|
-
return children
|
451
|
-
end
|
452
|
-
|
453
|
-
def initialize(hash)
|
454
|
-
# Store a copy of the arguments for later.
|
455
|
-
tmphash = hash.to_hash
|
456
395
|
|
396
|
+
def initialize(hash)
|
457
397
|
# Used for caching clients
|
458
398
|
@clients = {}
|
459
399
|
|
@@ -461,197 +401,42 @@ module Puppet
|
|
461
401
|
|
462
402
|
# Get rid of any duplicate slashes, and remove any trailing slashes.
|
463
403
|
@title = @title.gsub(/\/+/, "/")
|
464
|
-
|
465
|
-
@title.sub!(/\/$/, "") unless @title == "/"
|
466
|
-
|
467
|
-
# Clean out as many references to any file paths as possible.
|
468
|
-
# This was the source of many, many bugs.
|
469
|
-
@arghash = tmphash
|
470
|
-
@arghash.delete(self.class.namevar)
|
471
404
|
|
472
|
-
|
473
|
-
if @arghash.include?(param)
|
474
|
-
@arghash.delete(param)
|
475
|
-
end
|
476
|
-
end
|
405
|
+
@title.sub!(/\/$/, "") unless @title == "/"
|
477
406
|
|
478
407
|
@stat = nil
|
479
408
|
end
|
480
409
|
|
481
|
-
#
|
482
|
-
def
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
if self[:links] == :follow
|
487
|
-
method = :stat
|
488
|
-
end
|
489
|
-
|
490
|
-
targetstat = nil
|
491
|
-
unless FileTest.exist?(target)
|
492
|
-
return
|
493
|
-
end
|
494
|
-
# Now stat our target
|
495
|
-
targetstat = File.send(method, target)
|
496
|
-
unless targetstat.ftype == "directory"
|
497
|
-
return
|
498
|
-
end
|
499
|
-
|
500
|
-
# Now that we know our corresponding target is a directory,
|
501
|
-
# change our type
|
502
|
-
self[:ensure] = :directory
|
503
|
-
|
504
|
-
unless FileTest.readable? target
|
505
|
-
self.notice "Cannot manage %s: permission denied" % self.name
|
506
|
-
return
|
507
|
-
end
|
508
|
-
|
509
|
-
children = Dir.entries(target).reject { |d| d =~ /^\.+$/ }
|
510
|
-
|
511
|
-
# Get rid of ignored children
|
512
|
-
if @parameters.include?(:ignore)
|
513
|
-
children = handleignore(children)
|
514
|
-
end
|
515
|
-
|
516
|
-
added = []
|
517
|
-
children.each do |file|
|
518
|
-
Dir.chdir(target) do
|
519
|
-
longname = File.join(target, file)
|
520
|
-
|
521
|
-
# Files know to create directories when recursion
|
522
|
-
# is enabled and we're making links
|
523
|
-
args = {
|
524
|
-
:recurse => recurse,
|
525
|
-
:ensure => longname
|
526
|
-
}
|
527
|
-
|
528
|
-
if child = self.newchild(file, true, args)
|
529
|
-
added << child
|
530
|
-
end
|
531
|
-
end
|
410
|
+
# Configure discovered resources to be purged.
|
411
|
+
def mark_children_for_purging(children)
|
412
|
+
children.each do |name, child|
|
413
|
+
next if child[:source]
|
414
|
+
child[:ensure] = :absent
|
532
415
|
end
|
533
|
-
|
534
|
-
added
|
535
416
|
end
|
536
417
|
|
537
|
-
# Build up a recursive map of what's around right now
|
538
|
-
def localrecurse(recurse)
|
539
|
-
unless FileTest.exist?(self[:path]) and self.stat.directory?
|
540
|
-
#self.info "%s is not a directory; not recursing" %
|
541
|
-
# self[:path]
|
542
|
-
return
|
543
|
-
end
|
544
|
-
|
545
|
-
unless FileTest.readable? self[:path]
|
546
|
-
self.notice "Cannot manage %s: permission denied" % self.name
|
547
|
-
return
|
548
|
-
end
|
549
|
-
|
550
|
-
children = Dir.entries(self[:path])
|
551
|
-
|
552
|
-
#Get rid of ignored children
|
553
|
-
if @parameters.include?(:ignore)
|
554
|
-
children = handleignore(children)
|
555
|
-
end
|
556
|
-
|
557
|
-
added = []
|
558
|
-
children.each { |file|
|
559
|
-
file = File.basename(file)
|
560
|
-
next if file =~ /^\.\.?$/ # skip . and ..
|
561
|
-
options = {:recurse => recurse}
|
562
|
-
|
563
|
-
if child = self.newchild(file, true, options)
|
564
|
-
added << child
|
565
|
-
end
|
566
|
-
}
|
567
|
-
|
568
|
-
added
|
569
|
-
end
|
570
|
-
|
571
418
|
# Create a new file or directory object as a child to the current
|
572
419
|
# object.
|
573
|
-
def newchild(path
|
574
|
-
|
420
|
+
def newchild(path)
|
421
|
+
full_path = File.join(self[:path], path)
|
575
422
|
|
576
|
-
#
|
577
|
-
|
423
|
+
# Add some new values to our original arguments -- these are the ones
|
424
|
+
# set at initialization. We specifically want to exclude any param
|
425
|
+
# values set by the :source property or any default values.
|
426
|
+
# LAK:NOTE This is kind of silly, because the whole point here is that
|
427
|
+
# the values set at initialization should live as long as the resource
|
428
|
+
# but values set by default or by :source should only live for the transaction
|
429
|
+
# or so. Unfortunately, we don't have a straightforward way to manage
|
430
|
+
# the different lifetimes of this data, so we kludge it like this.
|
431
|
+
# The right-side hash wins in the merge.
|
432
|
+
options = @original_parameters.merge(:path => full_path).reject { |param, value| value.nil? }
|
578
433
|
|
579
|
-
#
|
580
|
-
|
581
|
-
|
582
|
-
v = symbolize(v)
|
583
|
-
args.delete(:ensure)
|
434
|
+
# These should never be passed to our children.
|
435
|
+
[:parent, :ensure, :recurse, :recurselimit, :target, :alias, :source].each do |param|
|
436
|
+
options.delete(param) if options.include?(param)
|
584
437
|
end
|
585
438
|
|
586
|
-
|
587
|
-
self.devfail(
|
588
|
-
"Must pass relative paths to PFile#newchild()"
|
589
|
-
)
|
590
|
-
else
|
591
|
-
path = File.join(self[:path], path)
|
592
|
-
end
|
593
|
-
|
594
|
-
args[:path] = path
|
595
|
-
|
596
|
-
unless hash.include?(:recurse)
|
597
|
-
if args.include?(:recurse)
|
598
|
-
if args[:recurse].is_a?(Integer)
|
599
|
-
args[:recurse] -= 1 # reduce the level of recursion
|
600
|
-
end
|
601
|
-
end
|
602
|
-
|
603
|
-
end
|
604
|
-
|
605
|
-
hash.each { |key,value|
|
606
|
-
args[key] = value
|
607
|
-
}
|
608
|
-
|
609
|
-
child = nil
|
610
|
-
|
611
|
-
# The child might already exist because 'localrecurse' runs
|
612
|
-
# before 'sourcerecurse'. I could push the override stuff into
|
613
|
-
# a separate method or something, but the work is the same other
|
614
|
-
# than this last bit, so it doesn't really make sense.
|
615
|
-
if child = catalog.resource(:file, path)
|
616
|
-
unless child.parent.object_id == self.object_id
|
617
|
-
self.debug "Not managing more explicit file %s" %
|
618
|
-
path
|
619
|
-
return nil
|
620
|
-
end
|
621
|
-
|
622
|
-
# This is only necessary for sourcerecurse, because we might have
|
623
|
-
# created the object with different 'should' values than are
|
624
|
-
# set remotely.
|
625
|
-
unless local
|
626
|
-
args.each { |var,value|
|
627
|
-
next if var == :path
|
628
|
-
next if var == :name
|
629
|
-
|
630
|
-
# behave idempotently
|
631
|
-
unless child.should(var) == value
|
632
|
-
child[var] = value
|
633
|
-
end
|
634
|
-
}
|
635
|
-
end
|
636
|
-
return nil
|
637
|
-
else # create it anew
|
638
|
-
#notice "Creating new file with args %s" % args.inspect
|
639
|
-
args[:parent] = self
|
640
|
-
begin
|
641
|
-
# This method is used by subclasses of :file, so use the class name rather than hard-coding
|
642
|
-
# :file.
|
643
|
-
return nil unless child = catalog.create_implicit_resource(self.class.name, args)
|
644
|
-
rescue => detail
|
645
|
-
self.notice "Cannot manage: %s" % [detail]
|
646
|
-
return nil
|
647
|
-
end
|
648
|
-
end
|
649
|
-
|
650
|
-
# LAK:FIXME This shouldn't be necessary, but as long as we're
|
651
|
-
# modeling the relationship graph specifically, it is.
|
652
|
-
catalog.relationship_graph.add_edge self, child
|
653
|
-
|
654
|
-
return child
|
439
|
+
return self.class.new(options)
|
655
440
|
end
|
656
441
|
|
657
442
|
# Files handle paths specially, because they just lengthen their
|
@@ -675,63 +460,60 @@ module Puppet
|
|
675
460
|
return [self.ref]
|
676
461
|
end
|
677
462
|
end
|
678
|
-
|
463
|
+
|
679
464
|
# Should we be purging?
|
680
465
|
def purge?
|
681
466
|
@parameters.include?(:purge) and (self[:purge] == :true or self[:purge] == "true")
|
682
467
|
end
|
683
468
|
|
684
|
-
#
|
685
|
-
#
|
686
|
-
#
|
469
|
+
# Recursively generate a list of file resources, which will
|
470
|
+
# be used to copy remote files, manage local files, and/or make links
|
471
|
+
# to map to another directory.
|
687
472
|
def recurse
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
recurse = self[:recurse]
|
692
|
-
# we might have a string, rather than a number
|
693
|
-
if recurse.is_a?(String)
|
694
|
-
if recurse =~ /^[0-9]+$/
|
695
|
-
recurse = Integer(recurse)
|
696
|
-
else # anything else is infinite recursion
|
697
|
-
recurse = true
|
698
|
-
end
|
473
|
+
children = {}
|
474
|
+
if self[:recurse] != :remote
|
475
|
+
children = recurse_local
|
699
476
|
end
|
700
477
|
|
701
|
-
if
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
children = []
|
706
|
-
|
707
|
-
# We want to do link-recursing before normal recursion so that all
|
708
|
-
# of the target stuff gets copied over correctly.
|
709
|
-
if @parameters.include? :target and ret = self.linkrecurse(recurse)
|
710
|
-
children += ret
|
711
|
-
end
|
712
|
-
if ret = self.localrecurse(recurse)
|
713
|
-
children += ret
|
478
|
+
if self[:target]
|
479
|
+
recurse_link(children)
|
480
|
+
elsif self[:source]
|
481
|
+
recurse_remote(children)
|
714
482
|
end
|
715
483
|
|
716
|
-
#
|
717
|
-
|
718
|
-
if
|
719
|
-
ret, sourced = self.sourcerecurse(recurse)
|
720
|
-
if ret
|
721
|
-
children += ret
|
722
|
-
end
|
723
|
-
end
|
484
|
+
# If we're purging resources, then delete any resource that isn't on the
|
485
|
+
# remote system.
|
486
|
+
mark_children_for_purging(children) if self.purge?
|
724
487
|
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
488
|
+
result = children.values.sort { |a, b| a[:path] <=> b[:path] }
|
489
|
+
remove_less_specific_files(result)
|
490
|
+
end
|
491
|
+
|
492
|
+
# This is to fix bug #2296, where two files recurse over the same
|
493
|
+
# set of files. It's a rare case, and when it does happen you're
|
494
|
+
# not likely to have many actual conflicts, which is good, because
|
495
|
+
# this is a pretty inefficient implementation.
|
496
|
+
def remove_less_specific_files(files)
|
497
|
+
# We sort the paths so we can short-circuit some tests.
|
498
|
+
mypath = self[:path]
|
499
|
+
other_paths = catalog.vertices.find_all do |r|
|
500
|
+
r.is_a?(self.class) and r[:path][0..(mypath.length - 1)] == mypath
|
501
|
+
end.collect { |r| r[:path] }.sort { |a, b| a.length <=> b.length } - [self[:path]]
|
502
|
+
|
503
|
+
return files if other_paths.empty?
|
504
|
+
|
505
|
+
remove = []
|
506
|
+
files.each do |file|
|
507
|
+
path = file[:path]
|
508
|
+
other_paths.each do |p|
|
509
|
+
if path[0..(p.length - 1)] == p
|
510
|
+
remove << file
|
511
|
+
break
|
730
512
|
end
|
731
513
|
end
|
732
514
|
end
|
733
|
-
|
734
|
-
|
515
|
+
|
516
|
+
files - remove
|
735
517
|
end
|
736
518
|
|
737
519
|
# A simple method for determining whether we should be recursing.
|
@@ -740,174 +522,120 @@ module Puppet
|
|
740
522
|
|
741
523
|
val = @parameters[:recurse].value
|
742
524
|
|
743
|
-
if val and (val == true or val
|
525
|
+
if val and (val == true or val == :remote)
|
744
526
|
return true
|
745
527
|
else
|
746
528
|
return false
|
747
529
|
end
|
748
530
|
end
|
749
531
|
|
750
|
-
#
|
751
|
-
def
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
532
|
+
# Recurse the target of the link.
|
533
|
+
def recurse_link(children)
|
534
|
+
perform_recursion(self[:target]).each do |meta|
|
535
|
+
if meta.relative_path == "."
|
536
|
+
self[:ensure] = :directory
|
537
|
+
next
|
538
|
+
end
|
539
|
+
|
540
|
+
children[meta.relative_path] ||= newchild(meta.relative_path)
|
541
|
+
if meta.ftype == "directory"
|
542
|
+
children[meta.relative_path][:ensure] = :directory
|
543
|
+
else
|
544
|
+
children[meta.relative_path][:ensure] = :link
|
545
|
+
children[meta.relative_path][:target] = meta.full_path
|
546
|
+
end
|
756
547
|
end
|
757
|
-
|
548
|
+
children
|
549
|
+
end
|
758
550
|
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
551
|
+
# Recurse the file itself, returning a Metadata instance for every found file.
|
552
|
+
def recurse_local
|
553
|
+
result = perform_recursion(self[:path])
|
554
|
+
return {} unless result
|
555
|
+
result.inject({}) do |hash, meta|
|
556
|
+
next hash if meta.relative_path == "."
|
557
|
+
|
558
|
+
hash[meta.relative_path] = newchild(meta.relative_path)
|
559
|
+
hash
|
763
560
|
end
|
561
|
+
end
|
764
562
|
|
765
|
-
|
766
|
-
|
563
|
+
# Recurse against our remote file.
|
564
|
+
def recurse_remote(children)
|
565
|
+
sourceselect = self[:sourceselect]
|
767
566
|
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
567
|
+
total = self[:source].collect do |source|
|
568
|
+
next unless result = perform_recursion(source)
|
569
|
+
return if top = result.find { |r| r.relative_path == "." } and top.ftype != "directory"
|
570
|
+
result.each { |data| data.source = "%s/%s" % [source, data.relative_path] }
|
571
|
+
break result if result and ! result.empty? and sourceselect == :first
|
572
|
+
result
|
573
|
+
end.flatten
|
574
|
+
|
575
|
+
# This only happens if we have sourceselect == :all
|
576
|
+
unless sourceselect == :first
|
577
|
+
found = []
|
578
|
+
total.reject! do |data|
|
579
|
+
result = found.include?(data.relative_path)
|
580
|
+
found << data.relative_path unless found.include?(data.relative_path)
|
581
|
+
result
|
582
|
+
end
|
583
|
+
end
|
584
|
+
|
585
|
+
total.each do |meta|
|
586
|
+
if meta.relative_path == "."
|
587
|
+
parameter(:source).metadata = meta
|
588
|
+
next
|
589
|
+
end
|
590
|
+
children[meta.relative_path] ||= newchild(meta.relative_path)
|
591
|
+
children[meta.relative_path][:source] = meta.source
|
592
|
+
children[meta.relative_path][:checksum] = :md5 if meta.ftype == "file"
|
593
|
+
|
594
|
+
children[meta.relative_path].parameter(:source).metadata = meta
|
774
595
|
end
|
596
|
+
|
597
|
+
children
|
598
|
+
end
|
599
|
+
|
600
|
+
def perform_recursion(path)
|
601
|
+
Puppet::FileServing::Metadata.search(path, :links => self[:links], :recurse => (self[:recurse] == :remote ? true : self[:recurse]), :recurselimit => self[:recurselimit], :ignore => self[:ignore])
|
775
602
|
end
|
776
603
|
|
777
604
|
# Remove any existing data. This is only used when dealing with
|
778
605
|
# links or directories.
|
779
606
|
def remove_existing(should)
|
780
|
-
return unless s = stat
|
607
|
+
return unless s = stat
|
781
608
|
|
782
|
-
self.fail "Could not back up; will not replace" unless
|
609
|
+
self.fail "Could not back up; will not replace" unless perform_backup
|
783
610
|
|
784
611
|
unless should.to_s == "link"
|
785
|
-
return if s.ftype.to_s == should.to_s
|
612
|
+
return if s.ftype.to_s == should.to_s
|
786
613
|
end
|
787
614
|
|
788
615
|
case s.ftype
|
789
|
-
when "directory"
|
616
|
+
when "directory"
|
790
617
|
if self[:force] == :true
|
791
618
|
debug "Removing existing directory for replacement with %s" % should
|
792
619
|
FileUtils.rmtree(self[:path])
|
793
620
|
else
|
794
621
|
notice "Not removing directory; use 'force' to override"
|
795
622
|
end
|
796
|
-
when "link", "file"
|
623
|
+
when "link", "file"
|
797
624
|
debug "Removing existing %s for replacement with %s" %
|
798
625
|
[s.ftype, should]
|
799
626
|
File.unlink(self[:path])
|
800
627
|
else
|
801
628
|
self.fail "Could not back up files of type %s" % s.ftype
|
802
629
|
end
|
630
|
+
expire
|
803
631
|
end
|
804
632
|
|
805
633
|
# a wrapper method to make sure the file exists before doing anything
|
806
634
|
def retrieve
|
807
|
-
|
808
|
-
|
809
|
-
# If the file doesn't exist but we have a source, then call
|
810
|
-
# retrieve on that property
|
811
|
-
|
812
|
-
propertyvalues = properties().inject({}) { |hash, property|
|
813
|
-
hash[property] = :absent
|
814
|
-
hash
|
815
|
-
}
|
816
|
-
|
817
|
-
if @parameters.include?(:source)
|
818
|
-
propertyvalues[:source] = @parameters[:source].retrieve
|
819
|
-
end
|
820
|
-
return propertyvalues
|
821
|
-
end
|
822
|
-
|
823
|
-
return currentpropvalues()
|
824
|
-
end
|
825
|
-
|
826
|
-
# This recurses against the remote source and makes sure the local
|
827
|
-
# and remote structures match. It's run after 'localrecurse'. This
|
828
|
-
# method only does anything when its corresponding remote entry is
|
829
|
-
# a directory; in that case, this method creates file objects that
|
830
|
-
# correspond to any contained remote files.
|
831
|
-
def sourcerecurse(recurse)
|
832
|
-
# we'll set this manually as necessary
|
833
|
-
if @arghash.include?(:ensure)
|
834
|
-
@arghash.delete(:ensure)
|
835
|
-
end
|
836
|
-
|
837
|
-
r = false
|
838
|
-
if recurse
|
839
|
-
unless recurse == 0
|
840
|
-
r = 1
|
841
|
-
end
|
635
|
+
if source = parameter(:source)
|
636
|
+
source.copy_source_values
|
842
637
|
end
|
843
|
-
|
844
|
-
ignore = self[:ignore]
|
845
|
-
|
846
|
-
result = []
|
847
|
-
found = []
|
848
|
-
|
849
|
-
# Keep track of all the files we found in the source, so we can purge
|
850
|
-
# appropriately.
|
851
|
-
sourced = []
|
852
|
-
|
853
|
-
success = false
|
854
|
-
|
855
|
-
@parameters[:source].should.each do |source|
|
856
|
-
sourceobj, path = uri2obj(source)
|
857
|
-
|
858
|
-
# okay, we've got our source object; now we need to
|
859
|
-
# build up a local file structure to match the remote
|
860
|
-
# one
|
861
|
-
|
862
|
-
server = sourceobj.server
|
863
|
-
|
864
|
-
desc = server.list(path, self[:links], r, ignore)
|
865
|
-
if desc == ""
|
866
|
-
next
|
867
|
-
end
|
868
|
-
|
869
|
-
success = true
|
870
|
-
|
871
|
-
# Now create a new child for every file returned in the list.
|
872
|
-
result += desc.split("\n").collect { |line|
|
873
|
-
file, type = line.split("\t")
|
874
|
-
next if file == "/" # skip the listing object
|
875
|
-
name = file.sub(/^\//, '')
|
876
|
-
|
877
|
-
# This makes sure that the first source *always* wins
|
878
|
-
# for conflicting files.
|
879
|
-
next if found.include?(name)
|
880
|
-
|
881
|
-
# For directories, keep all of the sources, so that
|
882
|
-
# sourceselect still works as planned.
|
883
|
-
if type == "directory"
|
884
|
-
newsource = @parameters[:source].should.collect do |tmpsource|
|
885
|
-
tmpsource + file
|
886
|
-
end
|
887
|
-
else
|
888
|
-
newsource = source + file
|
889
|
-
end
|
890
|
-
args = {:source => newsource}
|
891
|
-
if type == file
|
892
|
-
args[:recurse] = nil
|
893
|
-
end
|
894
|
-
|
895
|
-
found << name
|
896
|
-
sourced << File.join(self[:path], name)
|
897
|
-
|
898
|
-
self.newchild(name, false, args)
|
899
|
-
}.reject {|c| c.nil? }
|
900
|
-
|
901
|
-
if self[:sourceselect] == :first
|
902
|
-
return [result, sourced]
|
903
|
-
end
|
904
|
-
end
|
905
|
-
|
906
|
-
unless success
|
907
|
-
raise Puppet::Error, "None of the provided sources exist"
|
908
|
-
end
|
909
|
-
|
910
|
-
return [result, sourced]
|
638
|
+
super
|
911
639
|
end
|
912
640
|
|
913
641
|
# Set the checksum, from another property. There are multiple
|
@@ -926,11 +654,33 @@ module Puppet
|
|
926
654
|
end
|
927
655
|
end
|
928
656
|
|
657
|
+
# Should this thing be a normal file? This is a relatively complex
|
658
|
+
# way of determining whether we're trying to create a normal file,
|
659
|
+
# and it's here so that the logic isn't visible in the content property.
|
660
|
+
def should_be_file?
|
661
|
+
return true if self[:ensure] == :file
|
662
|
+
|
663
|
+
# I.e., it's set to something like "directory"
|
664
|
+
return false if e = self[:ensure] and e != :present
|
665
|
+
|
666
|
+
# The user doesn't really care, apparently
|
667
|
+
if self[:ensure] == :present
|
668
|
+
return true unless s = stat
|
669
|
+
return true if s.ftype == "file"
|
670
|
+
return false
|
671
|
+
end
|
672
|
+
|
673
|
+
# If we've gotten here, then :ensure isn't set
|
674
|
+
return true if self[:content]
|
675
|
+
return true if stat and stat.ftype == "file"
|
676
|
+
return false
|
677
|
+
end
|
678
|
+
|
929
679
|
# Stat our file. Depending on the value of the 'links' attribute, we
|
930
680
|
# use either 'stat' or 'lstat', and we expect the properties to use the
|
931
681
|
# resulting stat object accordingly (mostly by testing the 'ftype'
|
932
682
|
# value).
|
933
|
-
|
683
|
+
cached_attr(:stat) do
|
934
684
|
method = :stat
|
935
685
|
|
936
686
|
# Files are the only types that support links
|
@@ -938,23 +688,15 @@ module Puppet
|
|
938
688
|
method = :lstat
|
939
689
|
end
|
940
690
|
path = self[:path]
|
941
|
-
# Just skip them when they don't exist at all.
|
942
|
-
unless FileTest.exists?(path) or FileTest.symlink?(path)
|
943
|
-
@stat = nil
|
944
|
-
return @stat
|
945
|
-
end
|
946
|
-
if @stat.nil? or refresh == true
|
947
|
-
begin
|
948
|
-
@stat = File.send(method, self[:path])
|
949
|
-
rescue Errno::ENOENT => error
|
950
|
-
@stat = nil
|
951
|
-
rescue Errno::EACCES => error
|
952
|
-
self.warning "Could not stat; permission denied"
|
953
|
-
@stat = nil
|
954
|
-
end
|
955
|
-
end
|
956
691
|
|
957
|
-
|
692
|
+
begin
|
693
|
+
File.send(method, self[:path])
|
694
|
+
rescue Errno::ENOENT => error
|
695
|
+
return nil
|
696
|
+
rescue Errno::EACCES => error
|
697
|
+
warning "Could not stat; permission denied"
|
698
|
+
return nil
|
699
|
+
end
|
958
700
|
end
|
959
701
|
|
960
702
|
# We have to hack this just a little bit, because otherwise we'll get
|
@@ -968,75 +710,6 @@ module Puppet
|
|
968
710
|
obj
|
969
711
|
end
|
970
712
|
|
971
|
-
def localfileserver
|
972
|
-
unless defined? @@localfileserver
|
973
|
-
args = {
|
974
|
-
:Local => true,
|
975
|
-
:Mount => { "/" => "localhost" },
|
976
|
-
:Config => false
|
977
|
-
}
|
978
|
-
@@localfileserver = Puppet::Network::Handler.handler(:fileserver).new(args)
|
979
|
-
end
|
980
|
-
@@localfileserver
|
981
|
-
end
|
982
|
-
|
983
|
-
def uri2obj(source)
|
984
|
-
sourceobj = Puppet::Type::File::FileSource.new
|
985
|
-
path = nil
|
986
|
-
unless source
|
987
|
-
devfail "Got a nil source"
|
988
|
-
end
|
989
|
-
if source =~ /^\//
|
990
|
-
source = "file://localhost/%s" % URI.escape(source)
|
991
|
-
sourceobj.mount = "localhost"
|
992
|
-
sourceobj.local = true
|
993
|
-
end
|
994
|
-
begin
|
995
|
-
uri = URI.parse(URI.escape(source))
|
996
|
-
rescue => detail
|
997
|
-
self.fail "Could not understand source %s: %s" %
|
998
|
-
[source, detail.to_s]
|
999
|
-
end
|
1000
|
-
|
1001
|
-
case uri.scheme
|
1002
|
-
when "file":
|
1003
|
-
sourceobj.server = localfileserver
|
1004
|
-
path = "/localhost" + uri.path
|
1005
|
-
when "puppet":
|
1006
|
-
# FIXME: We should cache clients by uri.host + uri.port
|
1007
|
-
# not by the full source path
|
1008
|
-
unless @clients.include?(source)
|
1009
|
-
host = uri.host
|
1010
|
-
host ||= Puppet[:server] unless Puppet[:name] == "puppet"
|
1011
|
-
if host.nil?
|
1012
|
-
server = localfileserver
|
1013
|
-
else
|
1014
|
-
args = { :Server => host }
|
1015
|
-
if uri.port
|
1016
|
-
args[:Port] = uri.port
|
1017
|
-
end
|
1018
|
-
server = Puppet::Network::Client.file.new(args)
|
1019
|
-
end
|
1020
|
-
@clients[source] = server
|
1021
|
-
end
|
1022
|
-
sourceobj.server = @clients[source]
|
1023
|
-
|
1024
|
-
tmp = uri.path
|
1025
|
-
if tmp =~ %r{^/(\w+)}
|
1026
|
-
sourceobj.mount = $1
|
1027
|
-
path = tmp
|
1028
|
-
#path = tmp.sub(%r{^/\w+},'') || "/"
|
1029
|
-
else
|
1030
|
-
self.fail "Invalid source path %s" % tmp
|
1031
|
-
end
|
1032
|
-
else
|
1033
|
-
self.fail "Got other URL type '%s' from %s" %
|
1034
|
-
[uri.scheme, source]
|
1035
|
-
end
|
1036
|
-
|
1037
|
-
return [sourceobj, path.sub(/\/\//, '/')]
|
1038
|
-
end
|
1039
|
-
|
1040
713
|
# Write out the file. Requires the content to be written,
|
1041
714
|
# the property name for logging, and the checksum for validation.
|
1042
715
|
def write(content, property, checksum = nil)
|
@@ -1049,8 +722,14 @@ module Puppet
|
|
1049
722
|
remove_existing(:file)
|
1050
723
|
|
1051
724
|
use_temporary_file = (content.length != 0)
|
1052
|
-
|
1053
|
-
|
725
|
+
if use_temporary_file
|
726
|
+
path = "#{self[:path]}.puppettmp_#{rand(10000)}"
|
727
|
+
while File.exists?(path) or File.symlink?(path)
|
728
|
+
path = "#{self[:path]}.puppettmp_#{rand(10000)}"
|
729
|
+
end
|
730
|
+
else
|
731
|
+
path = self[:path]
|
732
|
+
end
|
1054
733
|
|
1055
734
|
mode = self.should(:mode) # might be nil
|
1056
735
|
umask = mode ? 000 : 022
|
@@ -1065,7 +744,7 @@ module Puppet
|
|
1065
744
|
fail_if_checksum_is_wrong(path, checksum) if validate
|
1066
745
|
File.rename(path, self[:path])
|
1067
746
|
rescue => detail
|
1068
|
-
|
747
|
+
fail "Could not rename temporary file %s to %s : %s" % [path, self[:path], detail]
|
1069
748
|
ensure
|
1070
749
|
# Make sure the created file gets removed
|
1071
750
|
File.unlink(path) if FileTest.exists?(path)
|
@@ -1130,20 +809,14 @@ module Puppet
|
|
1130
809
|
next unless [:mode, :owner, :group, :seluser, :selrole, :seltype, :selrange].include?(thing.name)
|
1131
810
|
|
1132
811
|
# Make sure we get a new stat objct
|
1133
|
-
|
812
|
+
expire
|
1134
813
|
currentvalue = thing.retrieve
|
1135
814
|
unless thing.insync?(currentvalue)
|
1136
815
|
thing.sync
|
1137
816
|
end
|
1138
817
|
end
|
1139
818
|
end
|
1140
|
-
end # Puppet.type(:pfile)
|
1141
|
-
|
1142
|
-
# the filesource class can't include the path, because the path
|
1143
|
-
# changes for every file instance
|
1144
|
-
class ::Puppet::Type::File::FileSource
|
1145
|
-
attr_accessor :mount, :root, :server, :local
|
1146
|
-
end
|
819
|
+
end # Puppet::Type.type(:pfile)
|
1147
820
|
|
1148
821
|
# We put all of the properties in separate files, because there are so many
|
1149
822
|
# of them. The order these are loaded is important, because it determines
|