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
@@ -0,0 +1,63 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
4
|
+
|
5
|
+
component = Puppet::Type.type(:component)
|
6
|
+
|
7
|
+
describe component do
|
8
|
+
it "should have a :name attribute" do
|
9
|
+
component.attrclass(:name).should_not be_nil
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should use Class as its type when a normal string is provided as the title" do
|
13
|
+
component.new(:name => "bar").ref.should == "Class[bar]"
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should always produce a resource reference string as its title" do
|
17
|
+
component.new(:name => "bar").title.should == "Class[bar]"
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should have a reference string equivalent to its title" do
|
21
|
+
comp = component.new(:name => "Foo[bar]")
|
22
|
+
comp.title.should == comp.ref
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should alias itself to its reference if it has a catalog and the catalog does not already have a resource with the same reference" do
|
26
|
+
catalog = mock 'catalog'
|
27
|
+
catalog.expects(:resource).with("Foo[bar]").returns nil
|
28
|
+
|
29
|
+
catalog.expects(:alias).with { |resource, name| resource.is_a?(component) and name == "Foo[bar]" }
|
30
|
+
|
31
|
+
component.new(:name => "Foo[bar]", :catalog => catalog)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should not fail when provided an invalid value" do
|
35
|
+
comp = component.new(:name => "Foo[bar]")
|
36
|
+
lambda { comp[:yayness] = "ey" }.should_not raise_error
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should return previously provided invalid values" do
|
40
|
+
comp = component.new(:name => "Foo[bar]")
|
41
|
+
comp[:yayness] = "eh"
|
42
|
+
comp[:yayness].should == "eh"
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should correctly support metaparameters" do
|
46
|
+
comp = component.new(:name => "Foo[bar]", :require => "Foo[bar]")
|
47
|
+
comp.parameter(:require).should be_instance_of(component.attrclass(:require))
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "when building up the path" do
|
51
|
+
it "should produce the class name if the component models a class" do
|
52
|
+
component.new(:name => "Class[foo]").pathbuilder.must == ["foo"]
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should produce an empty string if the component models the 'main' class" do
|
56
|
+
component.new(:name => "Class[main]").pathbuilder.must == [""]
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should produce a resource reference if the component does not model a class" do
|
60
|
+
component.new(:name => "Foo[bar]").pathbuilder.must == ["Foo[bar]"]
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
data/spec/unit/type/computer.rb
CHANGED
@@ -1,34 +1,30 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
2
|
+
|
3
3
|
require File.dirname(__FILE__) + '/../../spec_helper'
|
4
4
|
|
5
5
|
computer = Puppet::Type.type(:computer)
|
6
6
|
|
7
|
-
describe Puppet.type(:computer), " when checking computer objects" do
|
7
|
+
describe Puppet::Type.type(:computer), " when checking computer objects" do
|
8
8
|
before do
|
9
9
|
provider_class = Puppet::Type::Computer.provider(Puppet::Type::Computer.providers[0])
|
10
10
|
Puppet::Type::Computer.expects(:defaultprovider).returns provider_class
|
11
|
-
@resource = Puppet::Type::Computer.
|
11
|
+
@resource = Puppet::Type::Computer.new(
|
12
12
|
:name => "puppetcomputertest",
|
13
13
|
:en_address => "aa:bb:cc:dd:ee:ff",
|
14
14
|
:ip_address => "1.2.3.4")
|
15
15
|
@properties = {}
|
16
16
|
@ensure = Puppet::Type::Computer.attrclass(:ensure).new(:resource => @resource)
|
17
17
|
end
|
18
|
-
|
19
|
-
after do
|
20
|
-
computer.clear
|
21
|
-
end
|
22
|
-
|
18
|
+
|
23
19
|
it "should be able to create a instance" do
|
24
20
|
provider_class = Puppet::Type::Computer.provider(Puppet::Type::Computer.providers[0])
|
25
21
|
Puppet::Type::Computer.expects(:defaultprovider).returns provider_class
|
26
|
-
computer.
|
22
|
+
computer.new(:name => "bar").should_not be_nil
|
27
23
|
end
|
28
|
-
|
24
|
+
|
29
25
|
properties = [:en_address, :ip_address]
|
30
26
|
params = [:name]
|
31
|
-
|
27
|
+
|
32
28
|
properties.each do |property|
|
33
29
|
it "should have a %s property" % property do
|
34
30
|
computer.attrclass(property).ancestors.should be_include(Puppet::Property)
|
@@ -37,14 +33,14 @@ describe Puppet.type(:computer), " when checking computer objects" do
|
|
37
33
|
it "should have documentation for its %s property" % property do
|
38
34
|
computer.attrclass(property).doc.should be_instance_of(String)
|
39
35
|
end
|
40
|
-
|
36
|
+
|
41
37
|
it "should accept :absent as a value" do
|
42
38
|
prop = computer.attrclass(property).new(:resource => @resource)
|
43
39
|
prop.should = :absent
|
44
40
|
prop.should.must == :absent
|
45
41
|
end
|
46
42
|
end
|
47
|
-
|
43
|
+
|
48
44
|
params.each do |param|
|
49
45
|
it "should have a %s parameter" % param do
|
50
46
|
computer.attrclass(param).ancestors.should be_include(Puppet::Parameter)
|
@@ -54,7 +50,7 @@ describe Puppet.type(:computer), " when checking computer objects" do
|
|
54
50
|
computer.attrclass(param).doc.should be_instance_of(String)
|
55
51
|
end
|
56
52
|
end
|
57
|
-
|
53
|
+
|
58
54
|
describe "default values" do
|
59
55
|
before do
|
60
56
|
provider_class = computer.provider(computer.providers[0])
|
@@ -62,21 +58,21 @@ describe Puppet.type(:computer), " when checking computer objects" do
|
|
62
58
|
end
|
63
59
|
|
64
60
|
it "should be nil for en_address" do
|
65
|
-
computer.
|
61
|
+
computer.new(:name => :en_address)[:en_address].should == nil
|
66
62
|
end
|
67
|
-
|
63
|
+
|
68
64
|
it "should be nil for ip_address" do
|
69
|
-
computer.
|
65
|
+
computer.new(:name => :ip_address)[:ip_address].should == nil
|
70
66
|
end
|
71
67
|
end
|
72
|
-
|
73
|
-
describe "when managing the ensure property" do
|
68
|
+
|
69
|
+
describe "when managing the ensure property" do
|
74
70
|
it "should support a :present value" do
|
75
71
|
lambda { @ensure.should = :present }.should_not raise_error
|
76
72
|
end
|
77
|
-
|
73
|
+
|
78
74
|
it "should support an :absent value" do
|
79
75
|
lambda { @ensure.should = :absent }.should_not raise_error
|
80
76
|
end
|
81
77
|
end
|
82
|
-
end
|
78
|
+
end
|
data/spec/unit/type/exec.rb
CHANGED
@@ -3,11 +3,11 @@
|
|
3
3
|
require File.dirname(__FILE__) + '/../../spec_helper'
|
4
4
|
|
5
5
|
module ExecModuleTesting
|
6
|
-
def create_resource(command, output, exitstatus)
|
6
|
+
def create_resource(command, output, exitstatus, returns = [0])
|
7
7
|
@user_name = 'some_user_name'
|
8
8
|
@group_name = 'some_group_name'
|
9
9
|
Puppet.features.stubs(:root?).returns(true)
|
10
|
-
@execer = Puppet::Type.type(:exec).
|
10
|
+
@execer = Puppet::Type.type(:exec).new(:name => command, :path => %w{/usr/bin /bin}, :user => @user_name, :group => @group_name, :returns => returns)
|
11
11
|
|
12
12
|
status = stub "process"
|
13
13
|
status.stubs(:exitstatus).returns(exitstatus)
|
@@ -44,6 +44,18 @@ describe Puppet::Type.type(:exec), " when execing" do
|
|
44
44
|
|
45
45
|
proc { @execer.refresh }.should raise_error(Puppet::Error)
|
46
46
|
end
|
47
|
+
|
48
|
+
it "should not report a failure if the exit status is specified in a returns array" do
|
49
|
+
command = "false"
|
50
|
+
create_resource(command, "", 1, [0,1])
|
51
|
+
proc { @execer.refresh }.should_not raise_error(Puppet::Error)
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should report a failure if the exit status is not specified in a returns array" do
|
55
|
+
command = "false"
|
56
|
+
create_resource(command, "", 1, [0,100])
|
57
|
+
proc { @execer.refresh }.should raise_error(Puppet::Error)
|
58
|
+
end
|
47
59
|
|
48
60
|
it "should log the output on success" do
|
49
61
|
#Puppet::Util::Log.newdestination :console
|
@@ -89,3 +101,16 @@ describe Puppet::Type.type(:exec), " when logoutput=>on_failure is set," do
|
|
89
101
|
@execer.refresh
|
90
102
|
end
|
91
103
|
end
|
104
|
+
|
105
|
+
describe Puppet::Type.type(:exec) do
|
106
|
+
it "should be able to autorequire files mentioned in the command" do
|
107
|
+
catalog = Puppet::Resource::Catalog.new
|
108
|
+
catalog.add_resource Puppet::Type.type(:file).new(:name => "/bin/true")
|
109
|
+
@execer = Puppet::Type.type(:exec).new(:name => "/bin/true")
|
110
|
+
catalog.add_resource @execer
|
111
|
+
|
112
|
+
rels = @execer.autorequire
|
113
|
+
rels[0].should be_instance_of(Puppet::Relationship)
|
114
|
+
rels[0].target.should equal(@execer)
|
115
|
+
end
|
116
|
+
end
|
data/spec/unit/type/file.rb
CHANGED
@@ -7,107 +7,103 @@ describe Puppet::Type.type(:file) do
|
|
7
7
|
Puppet.settings.stubs(:use)
|
8
8
|
|
9
9
|
@path = Tempfile.new("puppetspec")
|
10
|
+
pathname = @path.path
|
10
11
|
@path.close!()
|
11
|
-
@path =
|
12
|
-
@file = Puppet::Type::File.
|
13
|
-
end
|
14
|
-
|
15
|
-
describe "when used with content and replace=>false" do
|
16
|
-
before do
|
17
|
-
@file[:content] = "foo"
|
18
|
-
@file[:replace] = false
|
19
|
-
end
|
12
|
+
@path = pathname
|
13
|
+
@file = Puppet::Type::File.new(:name => @path)
|
20
14
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
end
|
25
|
-
|
26
|
-
it "should be insync if the file exists and the content is right" do
|
27
|
-
File.open(@path, "w") do |f| f.puts "foo" end
|
28
|
-
@file.property(:content).insync?("foo").should be_true
|
29
|
-
end
|
15
|
+
@catalog = Puppet::Resource::Catalog.new
|
16
|
+
@file.catalog = @catalog
|
17
|
+
end
|
30
18
|
|
31
|
-
|
32
|
-
|
33
|
-
end
|
19
|
+
it "should have a method for determining if the file is present" do
|
20
|
+
@file.must respond_to(:exist?)
|
34
21
|
end
|
35
22
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
23
|
+
it "should be considered existent if it can be stat'ed" do
|
24
|
+
@file.expects(:stat).returns mock('stat')
|
25
|
+
@file.must be_exist
|
26
|
+
end
|
40
27
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
28
|
+
it "should be considered nonexistent if it can not be stat'ed" do
|
29
|
+
@file.expects(:stat).returns nil
|
30
|
+
@file.must_not be_exist
|
31
|
+
end
|
45
32
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
@file[:checksum] = :mtime
|
50
|
-
@file.property(:checksum).checktype.should == :md5
|
51
|
-
@file.property(:checksum).retrieve.should == "{md5}d3b07384d113edec49eaa6238ad5ff00"
|
52
|
-
end
|
33
|
+
it "should have a method for determining if the file should be a normal file" do
|
34
|
+
@file.must respond_to(:should_be_file?)
|
35
|
+
end
|
53
36
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
@file.property(:checksum).checktype.should == :md5
|
59
|
-
@file.property(:checksum).retrieve.should == "{md5}d3b07384d113edec49eaa6238ad5ff00"
|
60
|
-
end
|
37
|
+
it "should be a file if :ensure is set to :file" do
|
38
|
+
@file[:ensure] = :file
|
39
|
+
@file.must be_should_be_file
|
40
|
+
end
|
61
41
|
|
42
|
+
it "should be a file if :ensure is set to :present and the file exists as a normal file" do
|
43
|
+
@file.stubs(:stat).returns(mock('stat', :ftype => "file"))
|
44
|
+
@file[:ensure] = :present
|
45
|
+
@file.must be_should_be_file
|
46
|
+
end
|
62
47
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
@file.property(:checksum).getsum(:mtime).should == "{md5}d3b07384d113edec49eaa6238ad5ff00"
|
68
|
-
end
|
48
|
+
it "should not be a file if :ensure is set to something other than :file" do
|
49
|
+
@file[:ensure] = :directory
|
50
|
+
@file.must_not be_should_be_file
|
51
|
+
end
|
69
52
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
@file.property(:checksum).retrieve.should == "{md5}d3b07384d113edec49eaa6238ad5ff00"
|
76
|
-
end
|
53
|
+
it "should not be a file if :ensure is set to :present and the file exists but is not a normal file" do
|
54
|
+
@file.stubs(:stat).returns(mock('stat', :ftype => "directory"))
|
55
|
+
@file[:ensure] = :present
|
56
|
+
@file.must_not be_should_be_file
|
57
|
+
end
|
77
58
|
|
59
|
+
it "should be a file if :ensure is not set and :content is" do
|
60
|
+
@file[:content] = "foo"
|
61
|
+
@file.must be_should_be_file
|
78
62
|
end
|
79
63
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
64
|
+
it "should be a file if neither :ensure nor :content is set but the file exists as a normal file" do
|
65
|
+
@file.stubs(:stat).returns(mock("stat", :ftype => "file"))
|
66
|
+
@file.must be_should_be_file
|
67
|
+
end
|
84
68
|
|
85
|
-
|
69
|
+
it "should not be a file if neither :ensure nor :content is set but the file exists but not as a normal file" do
|
70
|
+
@file.stubs(:stat).returns(mock("stat", :ftype => "directory"))
|
71
|
+
@file.must_not be_should_be_file
|
72
|
+
end
|
86
73
|
|
87
|
-
|
88
|
-
|
74
|
+
it "should autorequire its parent directory" do
|
75
|
+
catalog = Puppet::Resource::Catalog.new
|
76
|
+
file = Puppet::Type::File.new(:name => "/foo/bar")
|
77
|
+
dir = Puppet::Type::File.new(:name => "/foo")
|
78
|
+
catalog.add_resource file
|
79
|
+
catalog.add_resource dir
|
80
|
+
reqs = file.autorequire
|
81
|
+
reqs[0].source.must == dir
|
82
|
+
reqs[0].target.must == file
|
83
|
+
end
|
89
84
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
85
|
+
it "should not autorequire its parent dir if its parent dir is itself" do
|
86
|
+
catalog = Puppet::Resource::Catalog.new
|
87
|
+
file = Puppet::Type::File.new(:name => "/")
|
88
|
+
catalog.add_resource file
|
89
|
+
file.autorequire.should be_empty
|
90
|
+
end
|
95
91
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
92
|
+
describe "when validating attributes" do
|
93
|
+
%w{path backup recurse recurselimit source replace force ignore links purge sourceselect}.each do |attr|
|
94
|
+
it "should have a '#{attr}' parameter" do
|
95
|
+
Puppet::Type.type(:file).attrtype(attr.intern).should == :param
|
96
|
+
end
|
100
97
|
end
|
101
98
|
|
102
|
-
|
103
|
-
|
104
|
-
|
99
|
+
%w{checksum content target ensure owner group mode type}.each do |attr|
|
100
|
+
it "should have a '#{attr}' property" do
|
101
|
+
Puppet::Type.type(:file).attrtype(attr.intern).should == :property
|
102
|
+
end
|
105
103
|
end
|
106
104
|
|
107
|
-
it "should
|
108
|
-
|
109
|
-
|
110
|
-
lambda { file.eval_generate }.should raise_error(Puppet::Error)
|
105
|
+
it "should have its 'path' attribute set as its namevar" do
|
106
|
+
Puppet::Type.type(:file).namevar.should == :path
|
111
107
|
end
|
112
108
|
end
|
113
109
|
|
@@ -125,11 +121,10 @@ describe Puppet::Type.type(:file) do
|
|
125
121
|
File.open(@file, "w", 0644) { |f| f.puts "yayness"; f.flush }
|
126
122
|
File.symlink(@file, @link)
|
127
123
|
|
128
|
-
@resource = Puppet.type(:file).
|
124
|
+
@resource = Puppet::Type.type(:file).new(
|
129
125
|
:path => @link,
|
130
126
|
:mode => "755"
|
131
127
|
)
|
132
|
-
@catalog = Puppet::Node::Catalog.new
|
133
128
|
@catalog.add_resource @resource
|
134
129
|
end
|
135
130
|
|
@@ -151,7 +146,633 @@ describe Puppet::Type.type(:file) do
|
|
151
146
|
end
|
152
147
|
end
|
153
148
|
|
154
|
-
|
155
|
-
Puppet::Type
|
149
|
+
it "should be able to retrieve a stat instance for the file it is managing" do
|
150
|
+
Puppet::Type.type(:file).new(:path => "/foo/bar", :source => "/bar/foo").should respond_to(:stat)
|
151
|
+
end
|
152
|
+
|
153
|
+
describe "when stat'ing its file" do
|
154
|
+
before do
|
155
|
+
@resource = Puppet::Type.type(:file).new(:path => "/foo/bar")
|
156
|
+
@resource[:links] = :manage # so we always use :lstat
|
157
|
+
end
|
158
|
+
|
159
|
+
it "should use :stat if it is following links" do
|
160
|
+
@resource[:links] = :follow
|
161
|
+
File.expects(:stat)
|
162
|
+
|
163
|
+
@resource.stat
|
164
|
+
end
|
165
|
+
|
166
|
+
it "should use :lstat if is it not following links" do
|
167
|
+
@resource[:links] = :manage
|
168
|
+
File.expects(:lstat)
|
169
|
+
|
170
|
+
@resource.stat
|
171
|
+
end
|
172
|
+
|
173
|
+
it "should stat the path of the file" do
|
174
|
+
File.expects(:lstat).with("/foo/bar")
|
175
|
+
|
176
|
+
@resource.stat
|
177
|
+
end
|
178
|
+
|
179
|
+
# This only happens in testing.
|
180
|
+
it "should return nil if the stat does not exist" do
|
181
|
+
File.expects(:lstat).returns nil
|
182
|
+
|
183
|
+
@resource.stat.should be_nil
|
184
|
+
end
|
185
|
+
|
186
|
+
it "should return nil if the file does not exist" do
|
187
|
+
File.expects(:lstat).raises(Errno::ENOENT)
|
188
|
+
|
189
|
+
@resource.stat.should be_nil
|
190
|
+
end
|
191
|
+
|
192
|
+
it "should return nil if the file cannot be stat'ed" do
|
193
|
+
File.expects(:lstat).raises(Errno::EACCES)
|
194
|
+
|
195
|
+
@resource.stat.should be_nil
|
196
|
+
end
|
197
|
+
|
198
|
+
it "should return the stat instance" do
|
199
|
+
File.expects(:lstat).returns "mystat"
|
200
|
+
|
201
|
+
@resource.stat.should == "mystat"
|
202
|
+
end
|
203
|
+
|
204
|
+
it "should cache the stat instance if it has a catalog and is applying" do
|
205
|
+
stat = mock 'stat'
|
206
|
+
File.expects(:lstat).returns stat
|
207
|
+
|
208
|
+
catalog = Puppet::Resource::Catalog.new
|
209
|
+
@resource.catalog = catalog
|
210
|
+
|
211
|
+
catalog.stubs(:applying?).returns true
|
212
|
+
|
213
|
+
@resource.stat.should equal(@resource.stat)
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
describe "when flushing" do
|
218
|
+
it "should flush all properties that respond to :flush" do
|
219
|
+
@resource = Puppet::Type.type(:file).new(:path => "/foo/bar", :source => "/bar/foo")
|
220
|
+
@resource.parameter(:source).expects(:flush)
|
221
|
+
@resource.flush
|
222
|
+
end
|
223
|
+
|
224
|
+
it "should reset its stat reference" do
|
225
|
+
@resource = Puppet::Type.type(:file).new(:path => "/foo/bar")
|
226
|
+
File.expects(:lstat).times(2).returns("stat1").then.returns("stat2")
|
227
|
+
@resource.stat.should == "stat1"
|
228
|
+
@resource.flush
|
229
|
+
@resource.stat.should == "stat2"
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
it "should have a method for performing recursion" do
|
234
|
+
@file.must respond_to(:perform_recursion)
|
235
|
+
end
|
236
|
+
|
237
|
+
describe "when executing a recursive search" do
|
238
|
+
it "should use Metadata to do its recursion" do
|
239
|
+
Puppet::FileServing::Metadata.expects(:search)
|
240
|
+
@file.perform_recursion(@file[:path])
|
241
|
+
end
|
242
|
+
|
243
|
+
it "should use the provided path as the key to the search" do
|
244
|
+
Puppet::FileServing::Metadata.expects(:search).with { |key, options| key == "/foo" }
|
245
|
+
@file.perform_recursion("/foo")
|
246
|
+
end
|
247
|
+
|
248
|
+
it "should return the results of the metadata search" do
|
249
|
+
Puppet::FileServing::Metadata.expects(:search).returns "foobar"
|
250
|
+
@file.perform_recursion(@file[:path]).should == "foobar"
|
251
|
+
end
|
252
|
+
|
253
|
+
it "should pass its recursion value to the search" do
|
254
|
+
@file[:recurse] = true
|
255
|
+
Puppet::FileServing::Metadata.expects(:search).with { |key, options| options[:recurse] == true }
|
256
|
+
@file.perform_recursion(@file[:path])
|
257
|
+
end
|
258
|
+
|
259
|
+
it "should pass true if recursion is remote" do
|
260
|
+
@file[:recurse] = :remote
|
261
|
+
Puppet::FileServing::Metadata.expects(:search).with { |key, options| options[:recurse] == true }
|
262
|
+
@file.perform_recursion(@file[:path])
|
263
|
+
end
|
264
|
+
|
265
|
+
it "should pass its recursion limit value to the search" do
|
266
|
+
@file[:recurselimit] = 10
|
267
|
+
Puppet::FileServing::Metadata.expects(:search).with { |key, options| options[:recurselimit] == 10 }
|
268
|
+
@file.perform_recursion(@file[:path])
|
269
|
+
end
|
270
|
+
|
271
|
+
it "should configure the search to ignore or manage links" do
|
272
|
+
@file[:links] = :manage
|
273
|
+
Puppet::FileServing::Metadata.expects(:search).with { |key, options| options[:links] == :manage }
|
274
|
+
@file.perform_recursion(@file[:path])
|
275
|
+
end
|
276
|
+
|
277
|
+
it "should pass its 'ignore' setting to the search if it has one" do
|
278
|
+
@file[:ignore] = %w{.svn CVS}
|
279
|
+
Puppet::FileServing::Metadata.expects(:search).with { |key, options| options[:ignore] == %w{.svn CVS} }
|
280
|
+
@file.perform_recursion(@file[:path])
|
281
|
+
end
|
282
|
+
end
|
283
|
+
|
284
|
+
it "should have a method for performing local recursion" do
|
285
|
+
@file.must respond_to(:recurse_local)
|
286
|
+
end
|
287
|
+
|
288
|
+
describe "when doing local recursion" do
|
289
|
+
before do
|
290
|
+
@metadata = stub 'metadata', :relative_path => "my/file"
|
291
|
+
end
|
292
|
+
|
293
|
+
it "should pass its path to the :perform_recursion method" do
|
294
|
+
@file.expects(:perform_recursion).with(@file[:path]).returns [@metadata]
|
295
|
+
@file.stubs(:newchild)
|
296
|
+
@file.recurse_local
|
297
|
+
end
|
298
|
+
|
299
|
+
it "should return an empty hash if the recursion returns nothing" do
|
300
|
+
@file.expects(:perform_recursion).returns nil
|
301
|
+
@file.recurse_local.should == {}
|
302
|
+
end
|
303
|
+
|
304
|
+
it "should create a new child resource with each generated metadata instance's relative path" do
|
305
|
+
@file.expects(:perform_recursion).returns [@metadata]
|
306
|
+
@file.expects(:newchild).with(@metadata.relative_path).returns "fiebar"
|
307
|
+
@file.recurse_local
|
308
|
+
end
|
309
|
+
|
310
|
+
it "should not create a new child resource for the '.' directory" do
|
311
|
+
@metadata.stubs(:relative_path).returns "."
|
312
|
+
|
313
|
+
@file.expects(:perform_recursion).returns [@metadata]
|
314
|
+
@file.expects(:newchild).never
|
315
|
+
@file.recurse_local
|
316
|
+
end
|
317
|
+
|
318
|
+
it "should return a hash of the created resources with the relative paths as the hash keys" do
|
319
|
+
@file.expects(:perform_recursion).returns [@metadata]
|
320
|
+
@file.expects(:newchild).with("my/file").returns "fiebar"
|
321
|
+
@file.recurse_local.should == {"my/file" => "fiebar"}
|
322
|
+
end
|
323
|
+
end
|
324
|
+
|
325
|
+
it "should have a method for performing link recursion" do
|
326
|
+
@file.must respond_to(:recurse_link)
|
327
|
+
end
|
328
|
+
|
329
|
+
describe "when doing link recursion" do
|
330
|
+
before do
|
331
|
+
@first = stub 'first', :relative_path => "first", :full_path => "/my/first", :ftype => "directory"
|
332
|
+
@second = stub 'second', :relative_path => "second", :full_path => "/my/second", :ftype => "file"
|
333
|
+
|
334
|
+
@resource = stub 'file', :[]= => nil
|
335
|
+
end
|
336
|
+
|
337
|
+
it "should pass its target to the :perform_recursion method" do
|
338
|
+
@file[:target] = "mylinks"
|
339
|
+
@file.expects(:perform_recursion).with("mylinks").returns [@first]
|
340
|
+
@file.stubs(:newchild).returns @resource
|
341
|
+
@file.recurse_link({})
|
342
|
+
end
|
343
|
+
|
344
|
+
it "should ignore the recursively-found '.' file and configure the top-level file to create a directory" do
|
345
|
+
@first.stubs(:relative_path).returns "."
|
346
|
+
@file[:target] = "mylinks"
|
347
|
+
@file.expects(:perform_recursion).with("mylinks").returns [@first]
|
348
|
+
@file.stubs(:newchild).never
|
349
|
+
@file.expects(:[]=).with(:ensure, :directory)
|
350
|
+
@file.recurse_link({})
|
351
|
+
end
|
352
|
+
|
353
|
+
it "should create a new child resource for each generated metadata instance's relative path that doesn't already exist in the children hash" do
|
354
|
+
@file.expects(:perform_recursion).returns [@first, @second]
|
355
|
+
@file.expects(:newchild).with(@first.relative_path).returns @resource
|
356
|
+
@file.recurse_link("second" => @resource)
|
357
|
+
end
|
358
|
+
|
359
|
+
it "should not create a new child resource for paths that already exist in the children hash" do
|
360
|
+
@file.expects(:perform_recursion).returns [@first]
|
361
|
+
@file.expects(:newchild).never
|
362
|
+
@file.recurse_link("first" => @resource)
|
363
|
+
end
|
364
|
+
|
365
|
+
it "should set the target to the full path of discovered file and set :ensure to :link if the file is not a directory" do
|
366
|
+
file = stub 'file'
|
367
|
+
file.expects(:[]=).with(:target, "/my/second")
|
368
|
+
file.expects(:[]=).with(:ensure, :link)
|
369
|
+
|
370
|
+
@file.stubs(:perform_recursion).returns [@first, @second]
|
371
|
+
@file.recurse_link("first" => @resource, "second" => file)
|
372
|
+
end
|
373
|
+
|
374
|
+
it "should :ensure to :directory if the file is a directory" do
|
375
|
+
file = stub 'file'
|
376
|
+
file.expects(:[]=).with(:ensure, :directory)
|
377
|
+
|
378
|
+
@file.stubs(:perform_recursion).returns [@first, @second]
|
379
|
+
@file.recurse_link("first" => file, "second" => @resource)
|
380
|
+
end
|
381
|
+
|
382
|
+
it "should return a hash with both created and existing resources with the relative paths as the hash keys" do
|
383
|
+
file = stub 'file', :[]= => nil
|
384
|
+
|
385
|
+
@file.expects(:perform_recursion).returns [@first, @second]
|
386
|
+
@file.stubs(:newchild).returns file
|
387
|
+
@file.recurse_link("second" => @resource).should == {"second" => @resource, "first" => file}
|
388
|
+
end
|
389
|
+
end
|
390
|
+
|
391
|
+
it "should have a method for performing remote recursion" do
|
392
|
+
@file.must respond_to(:recurse_remote)
|
393
|
+
end
|
394
|
+
|
395
|
+
describe "when doing remote recursion" do
|
396
|
+
before do
|
397
|
+
@file[:source] = "puppet://foo/bar"
|
398
|
+
|
399
|
+
@first = Puppet::FileServing::Metadata.new("/my", :relative_path => "first")
|
400
|
+
@second = Puppet::FileServing::Metadata.new("/my", :relative_path => "second")
|
401
|
+
@first.stubs(:ftype).returns "directory"
|
402
|
+
@second.stubs(:ftype).returns "directory"
|
403
|
+
|
404
|
+
@parameter = stub 'property', :metadata= => nil
|
405
|
+
@resource = stub 'file', :[]= => nil, :parameter => @parameter
|
406
|
+
end
|
407
|
+
|
408
|
+
it "should pass its source to the :perform_recursion method" do
|
409
|
+
data = Puppet::FileServing::Metadata.new("/whatever", :relative_path => "foobar")
|
410
|
+
@file.expects(:perform_recursion).with("puppet://foo/bar").returns [data]
|
411
|
+
@file.stubs(:newchild).returns @resource
|
412
|
+
@file.recurse_remote({})
|
413
|
+
end
|
414
|
+
|
415
|
+
it "should not recurse when the remote file is not a directory" do
|
416
|
+
data = Puppet::FileServing::Metadata.new("/whatever", :relative_path => ".")
|
417
|
+
data.stubs(:ftype).returns "file"
|
418
|
+
@file.expects(:perform_recursion).with("puppet://foo/bar").returns [data]
|
419
|
+
@file.expects(:newchild).never
|
420
|
+
@file.recurse_remote({})
|
421
|
+
end
|
422
|
+
|
423
|
+
it "should set the source of each returned file to the searched-for URI plus the found relative path" do
|
424
|
+
@first.expects(:source=).with File.join("puppet://foo/bar", @first.relative_path)
|
425
|
+
@file.expects(:perform_recursion).returns [@first]
|
426
|
+
@file.stubs(:newchild).returns @resource
|
427
|
+
@file.recurse_remote({})
|
428
|
+
end
|
429
|
+
|
430
|
+
it "should create a new resource for any relative file paths that do not already have a resource" do
|
431
|
+
@file.stubs(:perform_recursion).returns [@first]
|
432
|
+
@file.expects(:newchild).with("first").returns @resource
|
433
|
+
@file.recurse_remote({}).should == {"first" => @resource}
|
434
|
+
end
|
435
|
+
|
436
|
+
it "should not create a new resource for any relative file paths that do already have a resource" do
|
437
|
+
@file.stubs(:perform_recursion).returns [@first]
|
438
|
+
@file.expects(:newchild).never
|
439
|
+
@file.recurse_remote("first" => @resource)
|
440
|
+
end
|
441
|
+
|
442
|
+
it "should set the source of each resource to the source of the metadata" do
|
443
|
+
@file.stubs(:perform_recursion).returns [@first]
|
444
|
+
@resource.stubs(:[]=)
|
445
|
+
@resource.expects(:[]=).with(:source, File.join("puppet://foo/bar", @first.relative_path))
|
446
|
+
@file.recurse_remote("first" => @resource)
|
447
|
+
end
|
448
|
+
|
449
|
+
# LAK:FIXME This is a bug, but I can't think of a fix for it. Fortunately it's already
|
450
|
+
# filed, and when it's fixed, we'll just fix the whole flow.
|
451
|
+
it "should set the checksum type to :md5 if the remote file is a file" do
|
452
|
+
@first.stubs(:ftype).returns "file"
|
453
|
+
@file.stubs(:perform_recursion).returns [@first]
|
454
|
+
@resource.stubs(:[]=)
|
455
|
+
@resource.expects(:[]=).with(:checksum, :md5)
|
456
|
+
@file.recurse_remote("first" => @resource)
|
457
|
+
end
|
458
|
+
|
459
|
+
it "should store the metadata in the source property for each resource so the source does not have to requery the metadata" do
|
460
|
+
@file.stubs(:perform_recursion).returns [@first]
|
461
|
+
@resource.expects(:parameter).with(:source).returns @parameter
|
462
|
+
|
463
|
+
@parameter.expects(:metadata=).with(@first)
|
464
|
+
|
465
|
+
@file.recurse_remote("first" => @resource)
|
466
|
+
end
|
467
|
+
|
468
|
+
it "should not create a new resource for the '.' file" do
|
469
|
+
@first.stubs(:relative_path).returns "."
|
470
|
+
@file.stubs(:perform_recursion).returns [@first]
|
471
|
+
|
472
|
+
@file.expects(:newchild).never
|
473
|
+
|
474
|
+
@file.recurse_remote({})
|
475
|
+
end
|
476
|
+
|
477
|
+
it "should store the metadata in the main file's source property if the relative path is '.'" do
|
478
|
+
@first.stubs(:relative_path).returns "."
|
479
|
+
@file.stubs(:perform_recursion).returns [@first]
|
480
|
+
|
481
|
+
@file.parameter(:source).expects(:metadata=).with @first
|
482
|
+
|
483
|
+
@file.recurse_remote("first" => @resource)
|
484
|
+
end
|
485
|
+
|
486
|
+
describe "and multiple sources are provided" do
|
487
|
+
describe "and :sourceselect is set to :first" do
|
488
|
+
it "should create file instances for the results for the first source to return any values" do
|
489
|
+
data = Puppet::FileServing::Metadata.new("/whatever", :relative_path => "foobar")
|
490
|
+
@file[:source] = %w{/one /two /three /four}
|
491
|
+
@file.expects(:perform_recursion).with("/one").returns nil
|
492
|
+
@file.expects(:perform_recursion).with("/two").returns []
|
493
|
+
@file.expects(:perform_recursion).with("/three").returns [data]
|
494
|
+
@file.expects(:perform_recursion).with("/four").never
|
495
|
+
@file.expects(:newchild).with("foobar").returns @resource
|
496
|
+
@file.recurse_remote({})
|
497
|
+
end
|
498
|
+
end
|
499
|
+
|
500
|
+
describe "and :sourceselect is set to :all" do
|
501
|
+
before do
|
502
|
+
@file[:sourceselect] = :all
|
503
|
+
end
|
504
|
+
|
505
|
+
it "should return every found file that is not in a previous source" do
|
506
|
+
klass = Puppet::FileServing::Metadata
|
507
|
+
@file[:source] = %w{/one /two /three /four}
|
508
|
+
@file.stubs(:newchild).returns @resource
|
509
|
+
|
510
|
+
one = [klass.new("/one", :relative_path => "a")]
|
511
|
+
@file.expects(:perform_recursion).with("/one").returns one
|
512
|
+
@file.expects(:newchild).with("a").returns @resource
|
513
|
+
|
514
|
+
two = [klass.new("/two", :relative_path => "a"), klass.new("/two", :relative_path => "b")]
|
515
|
+
@file.expects(:perform_recursion).with("/two").returns two
|
516
|
+
@file.expects(:newchild).with("b").returns @resource
|
517
|
+
|
518
|
+
three = [klass.new("/three", :relative_path => "a"), klass.new("/three", :relative_path => "c")]
|
519
|
+
@file.expects(:perform_recursion).with("/three").returns three
|
520
|
+
@file.expects(:newchild).with("c").returns @resource
|
521
|
+
|
522
|
+
@file.expects(:perform_recursion).with("/four").returns []
|
523
|
+
|
524
|
+
@file.recurse_remote({})
|
525
|
+
end
|
526
|
+
end
|
527
|
+
end
|
528
|
+
end
|
529
|
+
|
530
|
+
describe "when returning resources with :eval_generate" do
|
531
|
+
before do
|
532
|
+
@graph = stub 'graph', :add_edge => nil
|
533
|
+
@catalog.stubs(:relationship_graph).returns @graph
|
534
|
+
|
535
|
+
@file.catalog = @catalog
|
536
|
+
@file[:recurse] = true
|
537
|
+
end
|
538
|
+
|
539
|
+
it "should recurse if recursion is enabled" do
|
540
|
+
resource = stub('resource', :[] => "resource")
|
541
|
+
@file.expects(:recurse?).returns true
|
542
|
+
@file.expects(:recurse).returns [resource]
|
543
|
+
@file.eval_generate.should == [resource]
|
544
|
+
end
|
545
|
+
|
546
|
+
it "should not recurse if recursion is disabled" do
|
547
|
+
@file.expects(:recurse?).returns false
|
548
|
+
@file.expects(:recurse).never
|
549
|
+
@file.eval_generate.should == []
|
550
|
+
end
|
551
|
+
|
552
|
+
it "should return each resource found through recursion" do
|
553
|
+
foo = stub 'foo', :[] => "/foo"
|
554
|
+
bar = stub 'bar', :[] => "/bar"
|
555
|
+
bar2 = stub 'bar2', :[] => "/bar"
|
556
|
+
|
557
|
+
@file.expects(:recurse).returns [foo, bar]
|
558
|
+
|
559
|
+
@file.eval_generate.should == [foo, bar]
|
560
|
+
end
|
561
|
+
end
|
562
|
+
|
563
|
+
describe "when recursing" do
|
564
|
+
before do
|
565
|
+
@file[:recurse] = true
|
566
|
+
@metadata = Puppet::FileServing::Metadata
|
567
|
+
end
|
568
|
+
|
569
|
+
describe "and a source is set" do
|
570
|
+
before { @file[:source] = "/my/source" }
|
571
|
+
|
572
|
+
it "should pass the already-discovered resources to recurse_remote" do
|
573
|
+
@file.stubs(:recurse_local).returns(:foo => "bar")
|
574
|
+
@file.expects(:recurse_remote).with(:foo => "bar").returns []
|
575
|
+
@file.recurse
|
576
|
+
end
|
577
|
+
end
|
578
|
+
|
579
|
+
describe "and a target is set" do
|
580
|
+
before { @file[:target] = "/link/target" }
|
581
|
+
|
582
|
+
it "should use recurse_link" do
|
583
|
+
@file.stubs(:recurse_local).returns(:foo => "bar")
|
584
|
+
@file.expects(:recurse_link).with(:foo => "bar").returns []
|
585
|
+
@file.recurse
|
586
|
+
end
|
587
|
+
end
|
588
|
+
|
589
|
+
it "should use recurse_local if recurse is not remote" do
|
590
|
+
@file.expects(:recurse_local).returns({})
|
591
|
+
@file.recurse
|
592
|
+
end
|
593
|
+
|
594
|
+
it "should not use recurse_local if recurse remote" do
|
595
|
+
@file[:recurse] = :remote
|
596
|
+
@file.expects(:recurse_local).never
|
597
|
+
@file.recurse
|
598
|
+
end
|
599
|
+
|
600
|
+
it "should return the generated resources as an array sorted by file path" do
|
601
|
+
one = stub 'one', :[] => "/one"
|
602
|
+
two = stub 'two', :[] => "/one/two"
|
603
|
+
three = stub 'three', :[] => "/three"
|
604
|
+
@file.expects(:recurse_local).returns(:one => one, :two => two, :three => three)
|
605
|
+
@file.recurse.should == [one, two, three]
|
606
|
+
end
|
607
|
+
|
608
|
+
describe "and purging is enabled" do
|
609
|
+
before do
|
610
|
+
@file[:purge] = true
|
611
|
+
end
|
612
|
+
|
613
|
+
it "should configure each file to be removed" do
|
614
|
+
local = stub 'local'
|
615
|
+
local.stubs(:[]).with(:source).returns nil # Thus, a local file
|
616
|
+
local.stubs(:[]).with(:path).returns "foo"
|
617
|
+
@file.expects(:recurse_local).returns("local" => local)
|
618
|
+
local.expects(:[]=).with(:ensure, :absent)
|
619
|
+
|
620
|
+
@file.recurse
|
621
|
+
end
|
622
|
+
|
623
|
+
it "should not remove files that exist in the remote repository" do
|
624
|
+
@file["source"] = "/my/file"
|
625
|
+
@file.expects(:recurse_local).returns({})
|
626
|
+
|
627
|
+
remote = stub 'remote'
|
628
|
+
remote.stubs(:[]).with(:source).returns "/whatever" # Thus, a remote file
|
629
|
+
remote.stubs(:[]).with(:path).returns "foo"
|
630
|
+
|
631
|
+
@file.expects(:recurse_remote).with { |hash| hash["remote"] = remote }
|
632
|
+
remote.expects(:[]=).with(:ensure, :absent).never
|
633
|
+
|
634
|
+
@file.recurse
|
635
|
+
end
|
636
|
+
end
|
637
|
+
|
638
|
+
describe "and making a new child resource" do
|
639
|
+
it "should not copy the parent resource's parent" do
|
640
|
+
Puppet::Type.type(:file).expects(:new).with { |options| ! options.include?(:parent) }
|
641
|
+
@file.newchild("my/path")
|
642
|
+
end
|
643
|
+
|
644
|
+
{:recurse => true, :target => "/foo/bar", :ensure => :present, :alias => "yay", :source => "/foo/bar"}.each do |param, value|
|
645
|
+
it "should not pass on #{param} to the sub resource" do
|
646
|
+
@file = Puppet::Type::File.new(:name => @path, param => value, :catalog => @catalog)
|
647
|
+
|
648
|
+
@file.class.expects(:new).with { |params| params[param].nil? }
|
649
|
+
|
650
|
+
@file.newchild("sub/file")
|
651
|
+
end
|
652
|
+
end
|
653
|
+
|
654
|
+
it "should copy all of the parent resource's 'should' values that were set at initialization" do
|
655
|
+
file = @file.class.new(:path => "/foo/bar", :owner => "root", :group => "wheel")
|
656
|
+
@catalog.add_resource(file)
|
657
|
+
file.class.expects(:new).with { |options| options[:owner] == "root" and options[:group] == "wheel" }
|
658
|
+
file.newchild("my/path")
|
659
|
+
end
|
660
|
+
|
661
|
+
it "should not copy default values to the new child" do
|
662
|
+
@file.class.expects(:new).with { |params| params[:backup].nil? }
|
663
|
+
@file.newchild("my/path")
|
664
|
+
end
|
665
|
+
|
666
|
+
it "should not copy values to the child which were set by the source" do
|
667
|
+
@file[:source] = "/foo/bar"
|
668
|
+
metadata = stub 'metadata', :owner => "root", :group => "root", :mode => 0755, :ftype => "file", :checksum => "{md5}whatever"
|
669
|
+
@file.parameter(:source).stubs(:metadata).returns metadata
|
670
|
+
|
671
|
+
@file.parameter(:source).copy_source_values
|
672
|
+
|
673
|
+
@file.class.expects(:new).with { |params| params[:group].nil? }
|
674
|
+
@file.newchild("my/path")
|
675
|
+
end
|
676
|
+
end
|
677
|
+
end
|
678
|
+
|
679
|
+
describe "when setting the backup" do
|
680
|
+
it "should default to 'puppet'" do
|
681
|
+
Puppet::Type::File.new(:name => "/my/file")[:backup].should == "puppet"
|
682
|
+
end
|
683
|
+
|
684
|
+
it "should allow setting backup to 'false'" do
|
685
|
+
Puppet::Type::File.new(:name => "/my/file", :backup => false)[:backup].should be_false
|
686
|
+
end
|
687
|
+
|
688
|
+
it "should set the backup to '.puppet-bak' if it is set to true" do
|
689
|
+
Puppet::Type::File.new(:name => "/my/file", :backup => true)[:backup].should == ".puppet-bak"
|
690
|
+
end
|
691
|
+
|
692
|
+
it "should support any other backup extension" do
|
693
|
+
Puppet::Type::File.new(:name => "/my/file", :backup => ".bak")[:backup].should == ".bak"
|
694
|
+
end
|
695
|
+
|
696
|
+
it "should set the filebucket when backup is set to a string matching the name of a filebucket in the catalog" do
|
697
|
+
catalog = Puppet::Resource::Catalog.new
|
698
|
+
bucket_resource = Puppet::Type.type(:filebucket).new :name => "foo", :path => "/my/file/bucket"
|
699
|
+
catalog.add_resource bucket_resource
|
700
|
+
|
701
|
+
file = Puppet::Type::File.new(:name => "/my/file")
|
702
|
+
catalog.add_resource file
|
703
|
+
|
704
|
+
file[:backup] = "foo"
|
705
|
+
file.bucket.should == bucket_resource.bucket
|
706
|
+
end
|
707
|
+
|
708
|
+
it "should find filebuckets added to the catalog after the file resource was created" do
|
709
|
+
catalog = Puppet::Resource::Catalog.new
|
710
|
+
|
711
|
+
file = Puppet::Type::File.new(:name => "/my/file", :backup => "foo")
|
712
|
+
catalog.add_resource file
|
713
|
+
|
714
|
+
bucket_resource = Puppet::Type.type(:filebucket).new :name => "foo", :path => "/my/file/bucket"
|
715
|
+
catalog.add_resource bucket_resource
|
716
|
+
|
717
|
+
file.bucket.should == bucket_resource.bucket
|
718
|
+
end
|
719
|
+
|
720
|
+
it "should have a nil filebucket if backup is false" do
|
721
|
+
catalog = Puppet::Resource::Catalog.new
|
722
|
+
bucket_resource = Puppet::Type.type(:filebucket).new :name => "foo", :path => "/my/file/bucket"
|
723
|
+
catalog.add_resource bucket_resource
|
724
|
+
|
725
|
+
file = Puppet::Type::File.new(:name => "/my/file", :backup => false)
|
726
|
+
catalog.add_resource file
|
727
|
+
|
728
|
+
file.bucket.should be_nil
|
729
|
+
end
|
730
|
+
|
731
|
+
it "should have a nil filebucket if backup is set to a string starting with '.'" do
|
732
|
+
catalog = Puppet::Resource::Catalog.new
|
733
|
+
bucket_resource = Puppet::Type.type(:filebucket).new :name => "foo", :path => "/my/file/bucket"
|
734
|
+
catalog.add_resource bucket_resource
|
735
|
+
|
736
|
+
file = Puppet::Type::File.new(:name => "/my/file", :backup => ".foo")
|
737
|
+
catalog.add_resource file
|
738
|
+
|
739
|
+
file.bucket.should be_nil
|
740
|
+
end
|
741
|
+
|
742
|
+
it "should fail if there's no catalog and backup is not false" do
|
743
|
+
file = Puppet::Type::File.new(:name => "/my/file", :backup => "foo")
|
744
|
+
|
745
|
+
lambda { file.bucket }.should raise_error(Puppet::Error)
|
746
|
+
end
|
747
|
+
|
748
|
+
it "should fail if a non-existent catalog is specified" do
|
749
|
+
file = Puppet::Type::File.new(:name => "/my/file", :backup => "foo")
|
750
|
+
catalog = Puppet::Resource::Catalog.new
|
751
|
+
catalog.add_resource file
|
752
|
+
|
753
|
+
lambda { file.bucket }.should raise_error(Puppet::Error)
|
754
|
+
end
|
755
|
+
|
756
|
+
it "should be able to use the default filebucket without a catalog" do
|
757
|
+
file = Puppet::Type::File.new(:name => "/my/file", :backup => "puppet")
|
758
|
+
file.bucket.should be_instance_of(Puppet::Network::Client::Dipper)
|
759
|
+
end
|
760
|
+
|
761
|
+
it "should look up the filebucket during finish()" do
|
762
|
+
file = Puppet::Type::File.new(:name => "/my/file", :backup => ".foo")
|
763
|
+
file.expects(:bucket)
|
764
|
+
file.finish
|
765
|
+
end
|
766
|
+
end
|
767
|
+
|
768
|
+
describe "when writing the file" do
|
769
|
+
it "should propagate failures encountered when renaming the temporary file" do
|
770
|
+
File.stubs(:open)
|
771
|
+
|
772
|
+
File.expects(:rename).raises ArgumentError
|
773
|
+
file = Puppet::Type::File.new(:name => "/my/file", :backup => "puppet")
|
774
|
+
|
775
|
+
lambda { file.write("something", :content) }.should raise_error(Puppet::Error)
|
776
|
+
end
|
156
777
|
end
|
157
778
|
end
|