puppet 3.3.2 → 3.4.0.rc1
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/CONTRIBUTING.md +22 -0
- data/Gemfile +11 -2
- data/README.md +13 -17
- data/README_DEVELOPER.md +1 -1
- data/Rakefile +1 -1
- data/examples/hiera/README.md +4 -4
- data/ext/debian/puppetmaster.init +1 -0
- data/ext/debian/rules +2 -5
- data/ext/nagios/check_puppet.rb +7 -7
- data/ext/osx/file_mapping.yaml +1 -1
- data/ext/osx/preflight.erb +34 -19
- data/ext/rack/{files/config.ru → config.ru} +0 -0
- data/ext/rack/{files/apache2.conf → example-passenger-vhost.conf} +6 -0
- data/ext/redhat/puppet.spec.erb +20 -2
- data/ext/systemd/{puppetagent.service → puppet.service} +0 -0
- data/lib/hiera_puppet.rb +2 -2
- data/lib/puppet/agent.rb +1 -6
- data/lib/puppet/application.rb +15 -2
- data/lib/puppet/application/agent.rb +2 -7
- data/lib/puppet/application/apply.rb +8 -13
- data/lib/puppet/application/cert.rb +47 -7
- data/lib/puppet/application/device.rb +1 -6
- data/lib/puppet/application/face_base.rb +1 -1
- data/lib/puppet/application/filebucket.rb +1 -1
- data/lib/puppet/application/inspect.rb +3 -12
- data/lib/puppet/application/master.rb +1 -6
- data/lib/puppet/application/queue.rb +1 -6
- data/lib/puppet/application/resource.rb +2 -6
- data/lib/puppet/coercion.rb +11 -0
- data/lib/puppet/configurer.rb +5 -3
- data/lib/puppet/configurer/downloader.rb +3 -1
- data/lib/puppet/configurer/plugin_handler.rb +10 -0
- data/lib/puppet/confine.rb +80 -0
- data/lib/puppet/{provider/confine → confine}/exists.rb +3 -3
- data/lib/puppet/{provider/confine → confine}/false.rb +2 -2
- data/lib/puppet/{provider/confine → confine}/feature.rb +2 -2
- data/lib/puppet/{provider/confine → confine}/true.rb +2 -2
- data/lib/puppet/{provider/confine → confine}/variable.rb +2 -2
- data/lib/puppet/{provider/confine_collection.rb → confine_collection.rb} +4 -4
- data/lib/puppet/{provider/confiner.rb → confiner.rb} +4 -4
- data/lib/puppet/daemon.rb +2 -6
- data/lib/puppet/data_binding.rb +2 -30
- data/lib/puppet/defaults.rb +283 -174
- data/lib/puppet/error.rb +1 -0
- data/lib/puppet/external/nagios.rb +0 -2
- data/lib/puppet/external/nagios/base.rb +4 -3
- data/lib/puppet/external/nagios/grammar.ry +173 -112
- data/lib/puppet/external/nagios/parser.rb +233 -184
- data/lib/puppet/face/file/store.rb +1 -1
- data/lib/puppet/face/module/generate.rb +5 -7
- data/lib/puppet/face/parser.rb +12 -2
- data/lib/puppet/face/plugin.rb +6 -0
- data/lib/puppet/feature/base.rb +16 -0
- data/lib/puppet/feature/external_facts.rb +5 -0
- data/lib/puppet/feature/libuser.rb +1 -1
- data/lib/puppet/feature/msgpack.rb +1 -0
- data/lib/puppet/feature/rails.rb +2 -2
- data/lib/puppet/file_bucket/dipper.rb +8 -6
- data/lib/puppet/file_bucket/file.rb +17 -1
- data/lib/puppet/file_serving/base.rb +21 -10
- data/lib/puppet/file_serving/configuration.rb +5 -7
- data/lib/puppet/file_serving/configuration/parser.rb +1 -1
- data/lib/puppet/file_serving/content.rb +1 -1
- data/lib/puppet/file_serving/fileset.rb +3 -3
- data/lib/puppet/file_serving/metadata.rb +22 -18
- data/lib/puppet/file_serving/mount/file.rb +1 -1
- data/lib/puppet/file_serving/mount/pluginfacts.rb +35 -0
- data/lib/puppet/file_system.rb +3 -0
- data/lib/puppet/file_system/file.rb +261 -0
- data/lib/puppet/file_system/file18.rb +5 -0
- data/lib/puppet/file_system/file19.rb +5 -0
- data/lib/puppet/file_system/file19windows.rb +113 -0
- data/lib/puppet/file_system/memory_file.rb +31 -0
- data/lib/puppet/file_system/tempfile.rb +20 -0
- data/lib/puppet/indirector/active_record.rb +1 -0
- data/lib/puppet/indirector/catalog/compiler.rb +28 -0
- data/lib/puppet/indirector/certificate_request/memory.rb +6 -0
- data/lib/puppet/indirector/data_binding/hiera.rb +46 -2
- data/lib/puppet/indirector/direct_file_server.rb +2 -2
- data/lib/puppet/indirector/facts/facter.rb +25 -0
- data/lib/puppet/indirector/file_bucket_file/file.rb +60 -74
- data/lib/puppet/indirector/indirection.rb +5 -1
- data/lib/puppet/indirector/json.rb +1 -1
- data/lib/puppet/indirector/key/ca.rb +4 -0
- data/lib/puppet/indirector/key/file.rb +7 -3
- data/lib/puppet/indirector/key/memory.rb +6 -0
- data/lib/puppet/indirector/node/write_only_yaml.rb +2 -2
- data/lib/puppet/indirector/request.rb +17 -11
- data/lib/puppet/indirector/resource/ral.rb +5 -0
- data/lib/puppet/indirector/resource/rest.rb +1 -0
- data/lib/puppet/indirector/resource/store_configs.rb +4 -0
- data/lib/puppet/indirector/rest.rb +2 -1
- data/lib/puppet/indirector/ssl_file.rb +7 -7
- data/lib/puppet/indirector/terminus.rb +4 -0
- data/lib/puppet/indirector/yaml.rb +3 -3
- data/lib/puppet/interface/documentation.rb +4 -11
- data/lib/puppet/module.rb +19 -6
- data/lib/puppet/module_tool/applications/builder.rb +1 -1
- data/lib/puppet/module_tool/applications/installer.rb +1 -1
- data/lib/puppet/module_tool/checksums.rb +1 -1
- data/lib/puppet/module_tool/dependency.rb +7 -3
- data/lib/puppet/module_tool/metadata.rb +6 -2
- data/lib/puppet/module_tool/tar.rb +2 -1
- data/lib/puppet/module_tool/tar/gnu.rb +6 -2
- data/lib/puppet/module_tool/tar/mini.rb +2 -0
- data/lib/puppet/module_tool/tar/solaris.rb +2 -5
- data/lib/puppet/network/authconfig.rb +0 -2
- data/lib/puppet/network/authentication.rb +1 -1
- data/lib/puppet/network/authstore.rb +6 -7
- data/lib/puppet/network/format.rb +2 -3
- data/lib/puppet/network/format_handler.rb +16 -11
- data/lib/puppet/network/format_support.rb +14 -0
- data/lib/puppet/network/formats.rb +26 -0
- data/lib/puppet/network/http/connection.rb +8 -41
- data/lib/puppet/network/http/handler.rb +28 -32
- data/lib/puppet/network/http/webrick.rb +15 -22
- data/lib/puppet/network/http_pool.rb +43 -9
- data/lib/puppet/network/rights.rb +0 -0
- data/lib/puppet/node.rb +24 -8
- data/lib/puppet/node/environment.rb +18 -20
- data/lib/puppet/node/facts.rb +23 -6
- data/lib/puppet/parameter.rb +15 -2
- data/lib/puppet/parameter/boolean.rb +5 -0
- data/lib/puppet/parameter/value_collection.rb +6 -4
- data/lib/puppet/parser/ast/resourceparam.rb +2 -1
- data/lib/puppet/parser/compiler.rb +25 -9
- data/lib/puppet/parser/files.rb +1 -1
- data/lib/puppet/parser/functions.rb +12 -21
- data/lib/puppet/parser/functions/collect.rb +6 -35
- data/lib/puppet/parser/functions/contain.rb +26 -0
- data/lib/puppet/parser/functions/create_resources.rb +5 -0
- data/lib/puppet/parser/functions/extlookup.rb +2 -2
- data/lib/puppet/parser/functions/file.rb +1 -1
- data/lib/puppet/parser/functions/{reject.rb → filter.rb} +13 -12
- data/lib/puppet/parser/functions/fqdn_rand.rb +13 -5
- data/lib/puppet/parser/functions/include.rb +18 -1
- data/lib/puppet/parser/functions/map.rb +44 -0
- data/lib/puppet/parser/functions/select.rb +6 -38
- data/lib/puppet/parser/lexer.rb +1 -1
- data/lib/puppet/parser/parser_support.rb +1 -1
- data/lib/puppet/parser/resource.rb +6 -45
- data/lib/puppet/parser/scope.rb +33 -2
- data/lib/puppet/parser/type_loader.rb +4 -60
- data/lib/puppet/pops/binder/bindings_loader.rb +1 -1
- data/lib/puppet/pops/binder/config/binder_config.rb +3 -3
- data/lib/puppet/pops/binder/hiera2/bindings_provider.rb +1 -1
- data/lib/puppet/pops/binder/scheme_handler/confdir_hiera_scheme.rb +1 -1
- data/lib/puppet/pops/binder/scheme_handler/module_hiera_scheme.rb +2 -2
- data/lib/puppet/pops/issues.rb +4 -0
- data/lib/puppet/pops/model/ast_transformer.rb +4 -1
- data/lib/puppet/pops/model/model_label_provider.rb +1 -1
- data/lib/puppet/pops/parser/egrammar.ra +5 -24
- data/lib/puppet/pops/parser/eparser.rb +859 -902
- data/lib/puppet/pops/parser/lexer.rb +48 -30
- data/lib/puppet/pops/parser/parser_support.rb +1 -1
- data/lib/puppet/pops/patterns.rb +4 -4
- data/lib/puppet/pops/utils.rb +1 -1
- data/lib/puppet/pops/validation/checker3_1.rb +25 -20
- data/lib/puppet/provider.rb +23 -6
- data/lib/puppet/provider/aixobject.rb +0 -0
- data/lib/puppet/provider/augeas/augeas.rb +21 -5
- data/lib/puppet/provider/confine.rb +5 -79
- data/lib/puppet/provider/cron/crontab.rb +0 -0
- data/lib/puppet/provider/exec.rb +9 -7
- data/lib/puppet/provider/exec/posix.rb +10 -1
- data/lib/puppet/provider/exec/windows.rb +1 -1
- data/lib/puppet/provider/file/posix.rb +1 -0
- data/lib/puppet/provider/file/windows.rb +16 -5
- data/lib/puppet/provider/group/aix.rb +0 -0
- data/lib/puppet/provider/group/windows_adsi.rb +33 -1
- data/lib/puppet/provider/macauthorization/macauthorization.rb +1 -1
- data/lib/puppet/provider/mailalias/aliases.rb +0 -0
- data/lib/puppet/provider/maillist/mailman.rb +0 -0
- data/lib/puppet/provider/mount/parsed.rb +0 -0
- data/lib/puppet/provider/nameservice/directoryservice.rb +3 -3
- data/lib/puppet/provider/package/appdmg.rb +1 -1
- data/lib/puppet/provider/package/apple.rb +1 -1
- data/lib/puppet/provider/package/apt.rb +1 -1
- data/lib/puppet/provider/package/aptitude.rb +0 -0
- data/lib/puppet/provider/package/blastwave.rb +1 -1
- data/lib/puppet/provider/package/dpkg.rb +1 -1
- data/lib/puppet/provider/package/fink.rb +1 -1
- data/lib/puppet/provider/package/freebsd.rb +0 -0
- data/lib/puppet/provider/package/gem.rb +0 -0
- data/lib/puppet/provider/package/macports.rb +0 -0
- data/lib/puppet/provider/package/msi.rb +4 -10
- data/lib/puppet/provider/package/nim.rb +8 -8
- data/lib/puppet/provider/package/openbsd.rb +1 -1
- data/lib/puppet/provider/package/opkg.rb +0 -0
- data/lib/puppet/provider/package/pacman.rb +2 -2
- data/lib/puppet/provider/package/pkgdmg.rb +1 -1
- data/lib/puppet/provider/package/pkgutil.rb +1 -1
- data/lib/puppet/provider/package/ports.rb +0 -0
- data/lib/puppet/provider/package/rpm.rb +39 -3
- data/lib/puppet/provider/package/sun.rb +3 -3
- data/lib/puppet/provider/package/sunfreeware.rb +0 -0
- data/lib/puppet/provider/package/windows.rb +12 -19
- data/lib/puppet/provider/package/windows/package.rb +1 -1
- data/lib/puppet/provider/package/yum.rb +2 -2
- data/lib/puppet/provider/parsedfile.rb +0 -0
- data/lib/puppet/provider/port/parsed.rb +0 -0
- data/lib/puppet/provider/service/base.rb +0 -0
- data/lib/puppet/provider/service/bsd.rb +3 -3
- data/lib/puppet/provider/service/daemontools.rb +8 -8
- data/lib/puppet/provider/service/debian.rb +0 -0
- data/lib/puppet/provider/service/freebsd.rb +3 -3
- data/lib/puppet/provider/service/init.rb +5 -4
- data/lib/puppet/provider/service/launchd.rb +35 -24
- data/lib/puppet/provider/service/openbsd.rb +23 -0
- data/lib/puppet/provider/service/redhat.rb +0 -0
- data/lib/puppet/provider/service/runit.rb +3 -3
- data/lib/puppet/provider/service/smf.rb +0 -0
- data/lib/puppet/provider/service/src.rb +0 -0
- data/lib/puppet/provider/service/systemd.rb +0 -0
- data/lib/puppet/provider/service/upstart.rb +3 -3
- data/lib/puppet/provider/ssh_authorized_key/parsed.rb +2 -2
- data/lib/puppet/provider/sshkey/parsed.rb +0 -0
- data/lib/puppet/provider/user/aix.rb +0 -0
- data/lib/puppet/provider/user/directoryservice.rb +1 -1
- data/lib/puppet/provider/user/useradd.rb +1 -1
- data/lib/puppet/provider/zone/solaris.rb +1 -1
- data/lib/puppet/rails/benchmark.rb +1 -1
- data/lib/puppet/reference/configuration.rb +1 -2
- data/lib/puppet/reference/indirection.rb +12 -14
- data/lib/puppet/relationship.rb +7 -4
- data/lib/puppet/reports.rb +2 -2
- data/lib/puppet/reports/rrdgraph.rb +1 -1
- data/lib/puppet/reports/store.rb +3 -3
- data/lib/puppet/reports/tagmail.rb +2 -2
- data/lib/puppet/resource.rb +66 -8
- data/lib/puppet/resource/catalog.rb +18 -25
- data/lib/puppet/resource/status.rb +10 -4
- data/lib/puppet/run.rb +6 -2
- data/lib/puppet/settings.rb +39 -119
- data/lib/puppet/settings/base_setting.rb +8 -9
- data/lib/puppet/settings/directory_setting.rb +8 -0
- data/lib/puppet/settings/file_setting.rb +35 -1
- data/lib/puppet/settings/priority_setting.rb +42 -0
- data/lib/puppet/ssl.rb +4 -0
- data/lib/puppet/ssl/certificate.rb +18 -0
- data/lib/puppet/ssl/certificate_authority.rb +101 -72
- data/lib/puppet/ssl/certificate_authority/autosign_command.rb +44 -0
- data/lib/puppet/ssl/certificate_authority/interface.rb +21 -17
- data/lib/puppet/ssl/certificate_factory.rb +38 -12
- data/lib/puppet/ssl/certificate_request.rb +201 -47
- data/lib/puppet/ssl/certificate_request_attributes.rb +34 -0
- data/lib/puppet/ssl/certificate_revocation_list.rb +2 -2
- data/lib/puppet/ssl/host.rb +21 -10
- data/lib/puppet/ssl/inventory.rb +6 -10
- data/lib/puppet/ssl/key.rb +1 -1
- data/lib/puppet/ssl/oids.rb +78 -0
- data/lib/puppet/ssl/validator.rb +41 -97
- data/lib/puppet/ssl/validator/default_validator.rb +153 -0
- data/lib/puppet/ssl/validator/no_validator.rb +17 -0
- data/lib/puppet/status.rb +4 -0
- data/lib/puppet/test/test_helper.rb +5 -0
- data/lib/puppet/transaction.rb +13 -0
- data/lib/puppet/transaction/event.rb +8 -3
- data/lib/puppet/transaction/report.rb +6 -2
- data/lib/puppet/transaction/resource_harness.rb +173 -115
- data/lib/puppet/type.rb +30 -13
- data/lib/puppet/type/augeas.rb +12 -46
- data/lib/puppet/type/component.rb +1 -7
- data/lib/puppet/type/cron.rb +0 -0
- data/lib/puppet/type/exec.rb +13 -1
- data/lib/puppet/type/file.rb +19 -10
- data/lib/puppet/type/file/checksum.rb +0 -0
- data/lib/puppet/type/file/content.rb +3 -0
- data/lib/puppet/type/file/ensure.rb +33 -15
- data/lib/puppet/type/file/group.rb +0 -0
- data/lib/puppet/type/file/mode.rb +6 -2
- data/lib/puppet/type/file/owner.rb +0 -0
- data/lib/puppet/type/file/source.rb +65 -14
- data/lib/puppet/type/file/target.rb +6 -6
- data/lib/puppet/type/file/type.rb +0 -0
- data/lib/puppet/type/filebucket.rb +0 -0
- data/lib/puppet/type/group.rb +18 -0
- data/lib/puppet/type/host.rb +0 -0
- data/lib/puppet/type/k5login.rb +4 -4
- data/lib/puppet/type/mailalias.rb +0 -0
- data/lib/puppet/type/maillist.rb +0 -0
- data/lib/puppet/type/mount.rb +15 -1
- data/lib/puppet/type/package.rb +7 -1
- data/lib/puppet/type/port.rb +0 -0
- data/lib/puppet/type/schedule.rb +9 -4
- data/lib/puppet/type/service.rb +1 -1
- data/lib/puppet/type/sshkey.rb +0 -0
- data/lib/puppet/type/tidy.rb +1 -1
- data/lib/puppet/type/user.rb +3 -0
- data/lib/puppet/type/yumrepo.rb +8 -6
- data/lib/puppet/type/zpool.rb +0 -0
- data/lib/puppet/util.rb +4 -31
- data/lib/puppet/util/adsi.rb +73 -17
- data/lib/puppet/util/autoload.rb +3 -3
- data/lib/puppet/util/backups.rb +4 -4
- data/lib/puppet/util/cacher.rb +7 -13
- data/lib/puppet/util/checksums.rb +2 -2
- data/lib/puppet/util/classgen.rb +3 -1
- data/lib/puppet/util/colors.rb +1 -0
- data/lib/puppet/util/command_line.rb +5 -0
- data/lib/puppet/util/docs.rb +33 -27
- data/lib/puppet/util/execution.rb +42 -18
- data/lib/puppet/util/filetype.rb +3 -3
- data/lib/puppet/util/instance_loader.rb +2 -2
- data/lib/puppet/util/instrumentation.rb +23 -42
- data/lib/puppet/util/instrumentation/data.rb +11 -4
- data/lib/puppet/util/instrumentation/indirection_probe.rb +11 -4
- data/lib/puppet/util/instrumentation/instrumentable.rb +7 -14
- data/lib/puppet/util/instrumentation/listener.rb +15 -8
- data/lib/puppet/util/instrumentation/listeners/log.rb +4 -10
- data/lib/puppet/util/instrumentation/listeners/performance.rb +8 -14
- data/lib/puppet/util/limits.rb +12 -0
- data/lib/puppet/util/lockfile.rb +2 -2
- data/lib/puppet/util/log.rb +14 -6
- data/lib/puppet/util/log/destinations.rb +23 -1
- data/lib/puppet/util/metric.rb +9 -3
- data/lib/puppet/util/monkey_patches.rb +7 -2
- data/lib/puppet/util/network_device/config.rb +1 -1
- data/lib/puppet/util/plugins.rb +1 -1
- data/lib/puppet/util/posix.rb +0 -0
- data/lib/puppet/util/profiler.rb +7 -2
- data/lib/puppet/util/provider_features.rb +2 -2
- data/lib/puppet/util/rdoc.rb +28 -30
- data/lib/puppet/util/rdoc/code_objects.rb +75 -25
- data/lib/puppet/util/rdoc/generators/puppet_generator.rb +1 -1
- data/lib/puppet/util/rdoc/parser.rb +12 -487
- data/lib/puppet/util/rdoc/parser/puppet_parser_core.rb +477 -0
- data/lib/puppet/util/rdoc/parser/puppet_parser_rdoc1.rb +19 -0
- data/lib/puppet/util/rdoc/parser/puppet_parser_rdoc2.rb +14 -0
- data/lib/puppet/util/reference.rb +1 -1
- data/lib/puppet/util/resource_template.rb +1 -1
- data/lib/puppet/util/selinux.rb +1 -1
- data/lib/puppet/util/storage.rb +2 -2
- data/lib/puppet/util/suidmanager.rb +1 -1
- data/lib/puppet/util/tag_set.rb +29 -0
- data/lib/puppet/util/tagging.rb +8 -24
- data/lib/puppet/util/watched_file.rb +1 -1
- data/lib/puppet/util/watcher.rb +1 -1
- data/lib/puppet/util/windows.rb +3 -0
- data/lib/puppet/util/windows/access_control_entry.rb +84 -0
- data/lib/puppet/util/windows/access_control_list.rb +106 -0
- data/lib/puppet/util/windows/file.rb +213 -0
- data/lib/puppet/util/windows/process.rb +199 -0
- data/lib/puppet/util/windows/root_certs.rb +52 -37
- data/lib/puppet/util/windows/security.rb +270 -245
- data/lib/puppet/util/windows/security_descriptor.rb +62 -0
- data/lib/puppet/util/windows/sid.rb +26 -4
- data/lib/puppet/version.rb +2 -2
- data/spec/fixtures/releases/jamtur01-apache/lib/puppet/provider/a2mod/debian.rb +1 -1
- data/spec/fixtures/unit/indirector/{hiera → data_binding/hiera}/global.yaml +0 -0
- data/spec/fixtures/unit/indirector/data_binding/hiera/invalid.yaml +1 -0
- data/spec/fixtures/unit/module/trailing-comma.json +24 -0
- data/spec/fixtures/unit/util/monkey_patches/x509.pem +32 -0
- data/spec/integration/application/apply_spec.rb +1 -1
- data/spec/integration/application/doc_spec.rb +1 -1
- data/spec/integration/configurer_spec.rb +4 -2
- data/spec/integration/data_binding.rb +100 -0
- data/spec/integration/indirector/catalog/compiler_spec.rb +16 -13
- data/spec/integration/indirector/direct_file_server_spec.rb +3 -5
- data/spec/integration/indirector/file_content/file_server_spec.rb +2 -2
- data/spec/integration/node/facts_spec.rb +1 -1
- data/spec/integration/node_spec.rb +1 -1
- data/spec/integration/parser/compiler_spec.rb +90 -0
- data/spec/integration/parser/parser_spec.rb +2 -2
- data/spec/integration/provider/cron/crontab_spec.rb +3 -5
- data/spec/integration/resource/catalog_spec.rb +1 -1
- data/spec/integration/ssl/autosign_spec.rb +90 -0
- data/spec/integration/ssl/certificate_authority_spec.rb +62 -69
- data/spec/integration/ssl/certificate_revocation_list_spec.rb +1 -1
- data/spec/integration/ssl/host_spec.rb +1 -1
- data/spec/integration/transaction_spec.rb +13 -13
- data/spec/integration/type/exec_spec.rb +2 -2
- data/spec/integration/type/file_spec.rb +287 -45
- data/spec/integration/type/tidy_spec.rb +3 -3
- data/spec/integration/util/rdoc/parser_spec.rb +236 -35
- data/spec/integration/util/settings_spec.rb +1 -1
- data/spec/integration/util/windows/process_spec.rb +22 -0
- data/spec/integration/util/windows/security_spec.rb +316 -106
- data/spec/lib/matchers/containment_matchers.rb +52 -0
- data/spec/lib/puppet_spec/compiler.rb +6 -0
- data/spec/lib/puppet_spec/files.rb +20 -21
- data/spec/shared_behaviours/documentation_on_faces.rb +3 -3
- data/spec/shared_behaviours/file_server_terminus.rb +2 -2
- data/spec/shared_contexts/platform.rb +1 -0
- data/spec/spec_helper.rb +13 -1
- data/spec/unit/agent_spec.rb +0 -12
- data/spec/unit/application/agent_spec.rb +4 -4
- data/spec/unit/application/apply_spec.rb +18 -2
- data/spec/unit/application/cert_spec.rb +8 -6
- data/spec/unit/application/device_spec.rb +1 -1
- data/spec/unit/application/filebucket_spec.rb +1 -1
- data/spec/unit/application/inspect_spec.rb +1 -1
- data/spec/unit/application_spec.rb +24 -0
- data/spec/unit/configurer/downloader_spec.rb +8 -7
- data/spec/unit/configurer/fact_handler_spec.rb +23 -0
- data/spec/unit/configurer/plugin_handler_spec.rb +7 -2
- data/spec/unit/configurer_spec.rb +15 -5
- data/spec/unit/{provider/confine → confine}/exists_spec.rb +12 -12
- data/spec/unit/{provider/confine → confine}/false_spec.rb +9 -9
- data/spec/unit/{provider/confine → confine}/feature_spec.rb +10 -10
- data/spec/unit/{provider/confine → confine}/true_spec.rb +7 -7
- data/spec/unit/{provider/confine → confine}/variable_spec.rb +16 -16
- data/spec/unit/{provider/confine_collection_spec.rb → confine_collection_spec.rb} +30 -30
- data/spec/unit/{provider/confine_spec.rb → confine_spec.rb} +11 -11
- data/spec/unit/{provider/confiner_spec.rb → confiner_spec.rb} +4 -4
- data/spec/unit/face/parser_spec.rb +54 -0
- data/spec/unit/file_bucket/dipper_spec.rb +2 -2
- data/spec/unit/file_serving/base_spec.rb +32 -9
- data/spec/unit/file_serving/configuration_spec.rb +7 -7
- data/spec/unit/file_serving/content_spec.rb +12 -7
- data/spec/unit/file_serving/fileset_spec.rb +57 -27
- data/spec/unit/file_serving/metadata_spec.rb +74 -12
- data/spec/unit/file_serving/mount/file_spec.rb +10 -10
- data/spec/unit/file_serving/mount/pluginfacts_spec.rb +73 -0
- data/spec/unit/file_system/file_spec.rb +486 -0
- data/spec/unit/file_system/tempfile_spec.rb +48 -0
- data/spec/unit/graph/relationship_graph_spec.rb +0 -6
- data/spec/unit/hiera_puppet_spec.rb +2 -2
- data/spec/unit/indirector/catalog/compiler_spec.rb +15 -19
- data/spec/unit/indirector/certificate_status/file_spec.rb +30 -40
- data/spec/unit/indirector/data_binding/hiera_spec.rb +95 -2
- data/spec/unit/indirector/direct_file_server_spec.rb +6 -6
- data/spec/unit/indirector/facts/facter_spec.rb +33 -0
- data/spec/unit/indirector/file_bucket_file/file_spec.rb +61 -52
- data/spec/unit/indirector/file_metadata/file_spec.rb +2 -2
- data/spec/unit/indirector/file_server_spec.rb +4 -4
- data/spec/unit/indirector/json_spec.rb +4 -4
- data/spec/unit/indirector/key/file_spec.rb +13 -14
- data/spec/unit/indirector/resource/ral_spec.rb +7 -0
- data/spec/unit/indirector/resource/store_configs_spec.rb +11 -0
- data/spec/unit/indirector/rest_spec.rb +7 -3
- data/spec/unit/indirector/ssl_file_spec.rb +14 -17
- data/spec/unit/indirector/yaml_spec.rb +4 -4
- data/spec/unit/module_spec.rb +43 -15
- data/spec/unit/module_tool/tar/gnu_spec.rb +2 -2
- data/spec/unit/module_tool/tar/solaris_spec.rb +2 -2
- data/spec/unit/module_tool/tar_spec.rb +45 -0
- data/spec/unit/network/authconfig_spec.rb +2 -1
- data/spec/unit/network/authentication_spec.rb +2 -2
- data/spec/unit/network/format_handler_spec.rb +2 -2
- data/spec/unit/network/formats_spec.rb +24 -0
- data/spec/unit/network/http/connection_spec.rb +76 -199
- data/spec/unit/network/http/handler_spec.rb +33 -34
- data/spec/unit/network/http_pool_spec.rb +8 -5
- data/spec/unit/node/environment_spec.rb +76 -90
- data/spec/unit/node/facts_spec.rb +20 -3
- data/spec/unit/node_spec.rb +43 -0
- data/spec/unit/parameter/boolean_spec.rb +22 -12
- data/spec/unit/parser/ast/resourceparam_spec.rb +51 -0
- data/spec/unit/parser/compiler_spec.rb +103 -35
- data/spec/unit/parser/eparser_adapter_spec.rb +12 -12
- data/spec/unit/parser/files_spec.rb +11 -11
- data/spec/unit/parser/functions/contain_spec.rb +185 -0
- data/spec/unit/parser/functions/create_resources_spec.rb +13 -5
- data/spec/unit/parser/functions/generate_spec.rb +1 -1
- data/spec/unit/parser/functions_spec.rb +2 -2
- data/spec/unit/parser/lexer_spec.rb +1 -1
- data/spec/unit/parser/methods/each_spec.rb +1 -1
- data/spec/unit/parser/methods/{select_spec.rb → filter_spec.rb} +11 -11
- data/spec/unit/parser/methods/map_spec.rb +95 -0
- data/spec/unit/parser/methods/reduce_spec.rb +12 -11
- data/spec/unit/parser/methods/shared.rb +5 -5
- data/spec/unit/parser/methods/slice_spec.rb +13 -13
- data/spec/unit/parser/parser_spec.rb +1 -1
- data/spec/unit/parser/resource/param_spec.rb +44 -0
- data/spec/unit/parser/resource_spec.rb +16 -15
- data/spec/unit/pops/model/ast_transformer_spec.rb +18 -4
- data/spec/unit/pops/parser/lexer_spec.rb +22 -5
- data/spec/unit/pops/parser/parse_calls_spec.rb +5 -5
- data/spec/unit/pops/transformer/transform_calls_spec.rb +6 -6
- data/spec/unit/pops/transformer/transform_containers_spec.rb +2 -2
- data/spec/unit/pops/validator/validator_spec.rb +31 -0
- data/spec/unit/provider/augeas/augeas_spec.rb +57 -2
- data/spec/unit/provider/exec/posix_spec.rb +8 -3
- data/spec/unit/provider/file/posix_spec.rb +2 -2
- data/spec/unit/provider/group/windows_adsi_spec.rb +70 -3
- data/spec/unit/provider/nameservice/directoryservice_spec.rb +3 -3
- data/spec/unit/provider/package/apt_spec.rb +1 -1
- data/spec/unit/provider/package/msi_spec.rb +15 -42
- data/spec/unit/provider/package/openbsd_spec.rb +3 -3
- data/spec/unit/provider/package/rpm_spec.rb +56 -13
- data/spec/unit/provider/package/windows_spec.rb +15 -19
- data/spec/unit/provider/service/base_spec.rb +1 -1
- data/spec/unit/provider/service/daemontools_spec.rb +18 -8
- data/spec/unit/provider/service/freebsd_spec.rb +3 -3
- data/spec/unit/provider/service/gentoo_spec.rb +5 -2
- data/spec/unit/provider/service/init_spec.rb +17 -17
- data/spec/unit/provider/service/launchd_spec.rb +76 -23
- data/spec/unit/provider/service/openbsd_spec.rb +125 -0
- data/spec/unit/provider/service/openwrt_spec.rb +1 -1
- data/spec/unit/provider/service/runit_spec.rb +12 -5
- data/spec/unit/provider/service/upstart_spec.rb +4 -4
- data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +5 -5
- data/spec/unit/provider/user/directoryservice_spec.rb +4 -4
- data/spec/unit/provider/zone/solaris_spec.rb +1 -1
- data/spec/unit/provider_spec.rb +2 -2
- data/spec/unit/reports/http_spec.rb +19 -34
- data/spec/unit/reports/store_spec.rb +2 -2
- data/spec/unit/resource/catalog_spec.rb +81 -11
- data/spec/unit/resource/status_spec.rb +11 -1
- data/spec/unit/resource/type_spec.rb +30 -1
- data/spec/unit/resource_spec.rb +40 -4
- data/spec/unit/settings/file_setting_spec.rb +2 -2
- data/spec/unit/settings/path_setting_spec.rb +2 -2
- data/spec/unit/settings/priority_setting_spec.rb +66 -0
- data/spec/unit/settings_spec.rb +16 -31
- data/spec/unit/ssl/certificate_authority/autosign_command_spec.rb +30 -0
- data/spec/unit/ssl/certificate_authority_spec.rb +129 -134
- data/spec/unit/ssl/certificate_factory_spec.rb +18 -0
- data/spec/unit/ssl/certificate_request_attributes_spec.rb +61 -0
- data/spec/unit/ssl/certificate_request_spec.rb +103 -0
- data/spec/unit/ssl/certificate_spec.rb +31 -18
- data/spec/unit/ssl/host_spec.rb +34 -8
- data/spec/unit/ssl/inventory_spec.rb +27 -62
- data/spec/unit/ssl/key_spec.rb +4 -4
- data/spec/unit/ssl/oids_spec.rb +48 -0
- data/spec/unit/ssl/validator_spec.rb +49 -6
- data/spec/unit/status_spec.rb +9 -0
- data/spec/unit/transaction/event_spec.rb +1 -9
- data/spec/unit/transaction/report_spec.rb +20 -1
- data/spec/unit/transaction/resource_harness_spec.rb +60 -210
- data/spec/unit/transaction_spec.rb +54 -8
- data/spec/unit/type/component_spec.rb +2 -2
- data/spec/unit/type/exec_spec.rb +14 -7
- data/spec/unit/type/file/content_spec.rb +13 -2
- data/spec/unit/type/file/ctime_spec.rb +1 -1
- data/spec/unit/type/file/mode_spec.rb +48 -2
- data/spec/unit/type/file/mtime_spec.rb +1 -1
- data/spec/unit/type/file/source_spec.rb +177 -7
- data/spec/unit/type/file_spec.rb +63 -71
- data/spec/unit/type/group_spec.rb +20 -0
- data/spec/unit/type/k5login_spec.rb +3 -3
- data/spec/unit/type/mount_spec.rb +53 -0
- data/spec/unit/type/nagios_spec.rb +216 -0
- data/spec/unit/type/package_spec.rb +7 -1
- data/spec/unit/type/schedule_spec.rb +6 -0
- data/spec/unit/type/service_spec.rb +3 -3
- data/spec/unit/type/tidy_spec.rb +14 -14
- data/spec/unit/type/user_spec.rb +9 -0
- data/spec/unit/type_spec.rb +86 -4
- data/spec/unit/util/adsi_spec.rb +120 -12
- data/spec/unit/util/autoload_spec.rb +14 -14
- data/spec/unit/util/backups_spec.rb +29 -21
- data/spec/unit/util/checksums_spec.rb +2 -1
- data/spec/unit/util/command_line_spec.rb +41 -0
- data/spec/unit/util/docs_spec.rb +91 -0
- data/spec/unit/util/execution_spec.rb +26 -2
- data/spec/unit/util/filetype_spec.rb +7 -7
- data/spec/unit/util/lockfile_spec.rb +2 -2
- data/spec/unit/util/log/destinations_spec.rb +32 -0
- data/spec/unit/util/monkey_patches_spec.rb +41 -0
- data/spec/unit/util/pidlock_spec.rb +6 -6
- data/spec/unit/util/rdoc/parser_spec.rb +15 -13
- data/spec/unit/util/rdoc_spec.rb +18 -24
- data/spec/unit/util/resource_template_spec.rb +3 -3
- data/spec/unit/util/selinux_spec.rb +4 -2
- data/spec/unit/util/storage_spec.rb +4 -4
- data/spec/unit/util/suidmanager_spec.rb +7 -0
- data/spec/unit/util/tag_set_spec.rb +46 -0
- data/spec/unit/util/tagging_spec.rb +82 -45
- data/spec/unit/util/watcher_spec.rb +4 -1
- data/spec/unit/util/windows/access_control_entry_spec.rb +67 -0
- data/spec/unit/util/windows/access_control_list_spec.rb +133 -0
- data/spec/unit/util/windows/root_certs_spec.rb +10 -8
- data/spec/unit/util/windows/security_descriptor_spec.rb +117 -0
- data/spec/unit/util/windows/sid_spec.rb +69 -0
- data/spec/unit/util_spec.rb +7 -7
- data/tasks/ci.rake +17 -36
- metadata +2811 -2746
- checksums.yaml +0 -7
- data/examples/mac_automount.pp +0 -16
- data/examples/mcx_dock_absent.pp +0 -4
- data/examples/mcx_dock_default.pp +0 -118
- data/examples/mcx_dock_full.pp +0 -125
- data/examples/mcx_dock_invalid.pp +0 -9
- data/examples/mcx_nogroup.pp +0 -118
- data/examples/mcx_notexists_absent.pp +0 -4
- data/ext/rack/README +0 -58
- data/ext/rack/manifest.pp +0 -59
- data/lib/puppet/external/lock.rb +0 -63
- data/lib/puppet/indirector/hiera.rb +0 -39
- data/lib/puppet/parser/functions/foreach.rb +0 -95
- data/spec/integration/network/server/webrick_spec.rb +0 -76
- data/spec/integration/parser/functions_spec.rb +0 -16
- data/spec/unit/indirector/hiera_spec.rb +0 -154
- data/spec/unit/parser/methods/collect_spec.rb +0 -153
- data/spec/unit/parser/methods/foreach_spec.rb +0 -91
- data/spec/unit/parser/methods/reject_spec.rb +0 -73
- data/spec/unit/resource/resource_type.json +0 -34
data/lib/puppet/util/autoload.rb
CHANGED
@@ -85,7 +85,7 @@ class Puppet::Util::Autoload
|
|
85
85
|
# returns nil if no file is found
|
86
86
|
def get_file(name, env=nil)
|
87
87
|
name = name + '.rb' unless name =~ /\.rb$/
|
88
|
-
path = search_directories(env).find { |dir| File.exist?(File.join(dir, name)) }
|
88
|
+
path = search_directories(env).find { |dir| Puppet::FileSystem::File.exist?(File.join(dir, name)) }
|
89
89
|
path and File.join(path, name)
|
90
90
|
end
|
91
91
|
|
@@ -112,7 +112,7 @@ class Puppet::Util::Autoload
|
|
112
112
|
# We're using a per-thread cache of module directories so that we don't
|
113
113
|
# scan the filesystem each time we try to load something. This is reset
|
114
114
|
# at the beginning of compilation and at the end of an agent run.
|
115
|
-
|
115
|
+
$env_module_directories ||= {}
|
116
116
|
|
117
117
|
|
118
118
|
# This is a little bit of a hack. Basically, the autoloader is being
|
@@ -136,7 +136,7 @@ class Puppet::Util::Autoload
|
|
136
136
|
# --cprice 2012-03-16
|
137
137
|
if Puppet.settings.app_defaults_initialized?
|
138
138
|
# if the app defaults have been initialized then it should be safe to access the module path setting.
|
139
|
-
|
139
|
+
$env_module_directories[real_env] ||= real_env.modulepath.collect do |dir|
|
140
140
|
Dir.entries(dir).reject { |f| f =~ /^\./ }.collect { |f| File.join(dir, f) }
|
141
141
|
end.flatten.collect { |d| File.join(d, "lib") }.find_all do |d|
|
142
142
|
FileTest.directory?(d)
|
data/lib/puppet/util/backups.rb
CHANGED
@@ -10,7 +10,7 @@ module Puppet::Util::Backups
|
|
10
10
|
|
11
11
|
# let the path be specified
|
12
12
|
file ||= self[:path]
|
13
|
-
return true unless
|
13
|
+
return true unless Puppet::FileSystem::File.exist?(file)
|
14
14
|
|
15
15
|
return(self.bucket ? perform_backup_with_bucket(file) : perform_backup_with_backuplocal(file, self[:backup]))
|
16
16
|
end
|
@@ -19,7 +19,7 @@ module Puppet::Util::Backups
|
|
19
19
|
|
20
20
|
def perform_backup_with_bucket(fileobj)
|
21
21
|
file = (fileobj.class == String) ? fileobj : fileobj.name
|
22
|
-
case File.
|
22
|
+
case Puppet::FileSystem::File.new(file).lstat.ftype
|
23
23
|
when "directory"
|
24
24
|
# we don't need to backup directories when recurse is on
|
25
25
|
return true if self[:recurse]
|
@@ -58,7 +58,7 @@ module Puppet::Util::Backups
|
|
58
58
|
end
|
59
59
|
|
60
60
|
begin
|
61
|
-
stat = File.send(method
|
61
|
+
stat = Puppet::FileSystem::File.new(newfile).send(method)
|
62
62
|
rescue Errno::ENOENT
|
63
63
|
return
|
64
64
|
end
|
@@ -70,7 +70,7 @@ module Puppet::Util::Backups
|
|
70
70
|
info "Removing old backup of type #{stat.ftype}"
|
71
71
|
|
72
72
|
begin
|
73
|
-
File.unlink(newfile)
|
73
|
+
Puppet::FileSystem::File.unlink(newfile)
|
74
74
|
rescue => detail
|
75
75
|
message = "Could not remove old backup: #{detail}"
|
76
76
|
self.log_exception(detail, message)
|
data/lib/puppet/util/cacher.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'monitor'
|
2
|
-
|
3
1
|
module Puppet::Util::Cacher
|
4
2
|
# Our module has been extended in a class; we can only add the Instance methods,
|
5
3
|
# which become *class* methods in the class.
|
@@ -33,10 +31,8 @@ module Puppet::Util::Cacher
|
|
33
31
|
|
34
32
|
define_method(name.to_s + "=") do |value|
|
35
33
|
# Make sure the cache timestamp is set
|
36
|
-
value_cache
|
37
|
-
|
38
|
-
set_expiration(name)
|
39
|
-
end
|
34
|
+
value_cache[name] = value
|
35
|
+
set_expiration(name)
|
40
36
|
end
|
41
37
|
end
|
42
38
|
|
@@ -55,13 +51,11 @@ module Puppet::Util::Cacher
|
|
55
51
|
private
|
56
52
|
|
57
53
|
def cached_value(name)
|
58
|
-
value_cache.
|
59
|
-
|
60
|
-
|
61
|
-
set_expiration(name)
|
62
|
-
end
|
63
|
-
value_cache[name]
|
54
|
+
if value_cache[name].nil? or expired_by_ttl?(name)
|
55
|
+
value_cache[name] = send("init_#{name}")
|
56
|
+
set_expiration(name)
|
64
57
|
end
|
58
|
+
value_cache[name]
|
65
59
|
end
|
66
60
|
|
67
61
|
def expired_by_ttl?(name)
|
@@ -74,7 +68,7 @@ module Puppet::Util::Cacher
|
|
74
68
|
end
|
75
69
|
|
76
70
|
def value_cache
|
77
|
-
@value_cache ||= {}
|
71
|
+
@value_cache ||= {}
|
78
72
|
end
|
79
73
|
end
|
80
74
|
end
|
@@ -56,7 +56,7 @@ module Puppet::Util::Checksums
|
|
56
56
|
|
57
57
|
# Return the :mtime timestamp of a file.
|
58
58
|
def mtime_file(filename)
|
59
|
-
File.
|
59
|
+
Puppet::FileSystem::File.new(filename).stat.send(:mtime)
|
60
60
|
end
|
61
61
|
|
62
62
|
# by definition this doesn't exist
|
@@ -102,7 +102,7 @@ module Puppet::Util::Checksums
|
|
102
102
|
|
103
103
|
# Return the :ctime of a file.
|
104
104
|
def ctime_file(filename)
|
105
|
-
File.
|
105
|
+
Puppet::FileSystem::File.new(filename).stat.send(:ctime)
|
106
106
|
end
|
107
107
|
|
108
108
|
alias :ctime_stream :mtime_stream
|
data/lib/puppet/util/classgen.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'puppet/util/methodhelper'
|
2
|
+
|
1
3
|
module Puppet
|
2
4
|
class ConstantAlreadyDefined < Error; end
|
3
5
|
class SubclassAlreadyDefined < Error; end
|
@@ -67,7 +69,7 @@ module Puppet::Util::ClassGen
|
|
67
69
|
options = symbolize_options(options)
|
68
70
|
const = genconst_string(name, options)
|
69
71
|
retval = false
|
70
|
-
if
|
72
|
+
if is_constant_defined?(const)
|
71
73
|
remove_const(const)
|
72
74
|
retval = true
|
73
75
|
end
|
data/lib/puppet/util/colors.rb
CHANGED
@@ -13,6 +13,7 @@ require 'puppet'
|
|
13
13
|
require 'puppet/util'
|
14
14
|
require "puppet/util/plugins"
|
15
15
|
require "puppet/util/rubygems"
|
16
|
+
require "puppet/util/limits"
|
16
17
|
|
17
18
|
module Puppet
|
18
19
|
module Util
|
@@ -20,6 +21,8 @@ module Puppet
|
|
20
21
|
# is basically where the bootstrapping process / lifecycle of an app
|
21
22
|
# begins.
|
22
23
|
class CommandLine
|
24
|
+
include Puppet::Util::Limits
|
25
|
+
|
23
26
|
OPTION_OR_MANIFEST_FILE = /^-|\.pp$|\.rb$/
|
24
27
|
|
25
28
|
# @param zero [String] the name of the executable
|
@@ -83,6 +86,8 @@ module Puppet
|
|
83
86
|
Puppet.initialize_settings(args)
|
84
87
|
end
|
85
88
|
|
89
|
+
setpriority(Puppet[:priority])
|
90
|
+
|
86
91
|
find_subcommand.run
|
87
92
|
end
|
88
93
|
|
data/lib/puppet/util/docs.rb
CHANGED
@@ -20,10 +20,10 @@ module Puppet::Util::Docs
|
|
20
20
|
def doc
|
21
21
|
extra = methods.find_all { |m| m.to_s =~ /^dochook_.+/ }.sort.collect { |m|
|
22
22
|
self.send(m)
|
23
|
-
}.delete_if {|r| r.nil? }.join("
|
23
|
+
}.delete_if {|r| r.nil? }.collect {|r| "* #{r}"}.join("\n")
|
24
24
|
|
25
25
|
if @doc
|
26
|
-
@doc + (extra.empty? ? '' : "\n\n"
|
26
|
+
scrub(@doc) + (extra.empty? ? '' : "\n\n#{extra}")
|
27
27
|
else
|
28
28
|
extra
|
29
29
|
end
|
@@ -63,6 +63,7 @@ module Puppet::Util::Docs
|
|
63
63
|
str + "\n"
|
64
64
|
end
|
65
65
|
|
66
|
+
# There is nothing that would ever set this. It gets read in reference/type.rb, but will never have any value but nil.
|
66
67
|
attr_reader :nodoc
|
67
68
|
def nodoc?
|
68
69
|
nodoc
|
@@ -89,33 +90,38 @@ module Puppet::Util::Docs
|
|
89
90
|
str << "\n"
|
90
91
|
end
|
91
92
|
|
92
|
-
#
|
93
|
+
# Strip indentation and trailing whitespace from embedded doc fragments.
|
94
|
+
#
|
95
|
+
# Multi-line doc fragments are sometimes indented in order to preserve the
|
96
|
+
# formatting of the code they're embedded in. Since indents are syntactic
|
97
|
+
# elements in Markdown, we need to make sure we remove any indent that was
|
98
|
+
# added solely to preserve surrounding code formatting, but LEAVE any indent
|
99
|
+
# that delineates a Markdown element (code blocks, multi-line bulleted list
|
100
|
+
# items). We can do this by removing the *least common indent* from each line.
|
101
|
+
#
|
102
|
+
# Least common indent is defined as follows:
|
103
|
+
#
|
104
|
+
# * Find the smallest amount of leading space on any line...
|
105
|
+
# * ...excluding the first line (which may have zero indent without affecting
|
106
|
+
# the common indent)...
|
107
|
+
# * ...and excluding lines that consist solely of whitespace.
|
108
|
+
# * The least common indent may be a zero-length string, if the fragment is
|
109
|
+
# not indented to match code.
|
110
|
+
# * If there are hard tabs for some dumb reason, we assume they're at least
|
111
|
+
# consistent within this doc fragment.
|
112
|
+
#
|
113
|
+
# See tests in spec/unit/util/docs_spec.rb for examples.
|
93
114
|
def scrub(text)
|
94
|
-
#
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
indent
|
99
|
-
|
100
|
-
|
101
|
-
# indent from every line. However, ignore any indentation on the
|
102
|
-
# first line, since that can be inconsistent.
|
103
|
-
text = text.lstrip
|
104
|
-
text.gsub!(/^([\t]+)/) { |s| " "*8*s.length; } # Expand leading tabs
|
105
|
-
# Find first non-empty line after the first line:
|
106
|
-
line2start = (text =~ /(\n?\s*\n)/)
|
107
|
-
line2start += $1.length
|
108
|
-
if (text[line2start..-1] =~ /^([ ]+)\S/) == 0
|
109
|
-
indent = Regexp.quote($1)
|
110
|
-
begin
|
111
|
-
return text.gsub(/^#{indent}/,'')
|
112
|
-
rescue => detail
|
113
|
-
Puppet.log_exception(detail)
|
114
|
-
end
|
115
|
-
else
|
116
|
-
return text
|
115
|
+
# One-liners are easy!
|
116
|
+
return text.strip if text !~ /\n/
|
117
|
+
excluding_first_line = text.partition("\n").last
|
118
|
+
indent = excluding_first_line.scan(/^[ \t]*(?=\S)/).min || '' # prevent nil
|
119
|
+
# Clean hanging indent, if any
|
120
|
+
if indent.length > 0
|
121
|
+
text = text.gsub(/^#{indent}/, '')
|
117
122
|
end
|
118
|
-
|
123
|
+
# Clean trailing space
|
124
|
+
text.lines.map{|line|line.rstrip}.join("\n").rstrip
|
119
125
|
end
|
120
126
|
|
121
127
|
module_function :scrub
|
@@ -1,15 +1,33 @@
|
|
1
1
|
module Puppet
|
2
2
|
require 'rbconfig'
|
3
3
|
|
4
|
-
# A command failed to execute.
|
5
4
|
require 'puppet/error'
|
5
|
+
# A command failed to execute.
|
6
|
+
# @api public
|
6
7
|
class ExecutionFailure < Puppet::Error
|
7
8
|
end
|
9
|
+
end
|
8
10
|
|
9
11
|
# This module defines methods for execution of system commands. It is intented for inclusion
|
10
12
|
# in classes that needs to execute system commands.
|
11
13
|
# @api public
|
12
|
-
module Util::Execution
|
14
|
+
module Puppet::Util::Execution
|
15
|
+
|
16
|
+
# This is the full output from a process. The object itself (a String) is the
|
17
|
+
# stdout of the process.
|
18
|
+
#
|
19
|
+
# @api public
|
20
|
+
class ProcessOutput < String
|
21
|
+
# @return [Integer] The exit status of the process
|
22
|
+
# @api public
|
23
|
+
attr_reader :exitstatus
|
24
|
+
|
25
|
+
# @api private
|
26
|
+
def initialize(value,exitstatus)
|
27
|
+
super(value)
|
28
|
+
@exitstatus = exitstatus
|
29
|
+
end
|
30
|
+
end
|
13
31
|
|
14
32
|
# Executes the provided command with STDIN connected to a pipe, yielding the
|
15
33
|
# pipe object.
|
@@ -27,17 +45,12 @@ module Util::Execution
|
|
27
45
|
# @yield [pipe] to a block executing a subprocess
|
28
46
|
# @yieldparam pipe [IO] the opened pipe
|
29
47
|
# @yieldreturn [String] the output to return
|
30
|
-
# @raise [ExecutionFailure] if the executed chiled process did not exit with status == 0 and `failonfail` is
|
48
|
+
# @raise [Puppet::ExecutionFailure] if the executed chiled process did not exit with status == 0 and `failonfail` is
|
31
49
|
# `true`.
|
32
50
|
# @return [String] a string with the output from the subprocess executed by the given block
|
51
|
+
# @api public
|
33
52
|
#
|
34
53
|
def self.execpipe(command, failonfail = true)
|
35
|
-
if respond_to? :debug
|
36
|
-
debug "Executing '#{command}'"
|
37
|
-
else
|
38
|
-
Puppet.debug "Executing '#{command}'"
|
39
|
-
end
|
40
|
-
|
41
54
|
# Paste together an array with spaces. We used to paste directly
|
42
55
|
# together, no spaces, which made for odd invocations; the user had to
|
43
56
|
# include whitespace between arguments.
|
@@ -46,13 +59,20 @@ module Util::Execution
|
|
46
59
|
# shell anyhow, while no spaces makes for a small developer cost every
|
47
60
|
# time this is invoked. --daniel 2012-02-13
|
48
61
|
command_str = command.respond_to?(:join) ? command.join(' ') : command
|
62
|
+
|
63
|
+
if respond_to? :debug
|
64
|
+
debug "Executing '#{command_str}'"
|
65
|
+
else
|
66
|
+
Puppet.debug "Executing '#{command_str}'"
|
67
|
+
end
|
68
|
+
|
49
69
|
output = open("| #{command_str} 2>&1") do |pipe|
|
50
70
|
yield pipe
|
51
71
|
end
|
52
72
|
|
53
73
|
if failonfail
|
54
74
|
unless $CHILD_STATUS == 0
|
55
|
-
raise ExecutionFailure, output
|
75
|
+
raise Puppet::ExecutionFailure, output
|
56
76
|
end
|
57
77
|
end
|
58
78
|
|
@@ -62,10 +82,11 @@ module Util::Execution
|
|
62
82
|
# Wraps execution of {execute} with mapping of exception to given exception (and output as argument).
|
63
83
|
# @raise [exception] under same conditions as {execute}, but raises the given `exception` with the output as argument
|
64
84
|
# @return (see execute)
|
85
|
+
# @api public
|
65
86
|
def self.execfail(command, exception)
|
66
87
|
output = execute(command)
|
67
88
|
return output
|
68
|
-
rescue ExecutionFailure
|
89
|
+
rescue Puppet::ExecutionFailure
|
69
90
|
raise exception, output
|
70
91
|
end
|
71
92
|
|
@@ -80,8 +101,8 @@ module Util::Execution
|
|
80
101
|
# @param options [Hash] a Hash of options
|
81
102
|
# @option options [Boolean] :failonfail if this value is set to true, then this method will raise an error if the
|
82
103
|
# command is not executed successfully.
|
83
|
-
# @option options [
|
84
|
-
# @option options [
|
104
|
+
# @option options [Integer, String] :uid (nil) the user id of the user that the process should be run as
|
105
|
+
# @option options [Integer, String] :gid (nil) the group id of the group that the process should be run as
|
85
106
|
# @option options [Boolean] :combine sets whether or not to combine stdout/stderr in the output
|
86
107
|
# @option options [String] :stdinfile (nil) sets a file that can be used for stdin. Passing a string for stdin is not currently
|
87
108
|
# supported.
|
@@ -92,13 +113,16 @@ module Util::Execution
|
|
92
113
|
# Passing in a value of false for this option will allow the command to be executed using the user/system locale.
|
93
114
|
# @option options [Hash<{String => String}>] :custom_environment ({}) a hash of key/value pairs to set as environment variables for the duration
|
94
115
|
# of the command.
|
95
|
-
# @return [
|
116
|
+
# @return [Puppet::Util::Execution::ProcessOutput] output as specified by options
|
117
|
+
# @raise [Puppet::ExecutionFailure] if the executed chiled process did not exit with status == 0 and `failonfail` is
|
118
|
+
# `true`.
|
96
119
|
# @note Unfortunately, the default behavior for failonfail and combine (since
|
97
120
|
# 0.22.4 and 0.24.7, respectively) depend on whether options are specified
|
98
121
|
# or not. If specified, then failonfail and combine default to false (even
|
99
122
|
# when the options specified are neither failonfail nor combine). If no
|
100
123
|
# options are specified, then failonfail and combine default to true.
|
101
124
|
# @comment See commits efe9a833c and d32d7f30
|
125
|
+
# @api public
|
102
126
|
#
|
103
127
|
def self.execute(command, options = NoOptionsSpecified)
|
104
128
|
# specifying these here rather than in the method signature to allow callers to pass in a partial
|
@@ -161,15 +185,16 @@ module Util::Execution
|
|
161
185
|
end
|
162
186
|
|
163
187
|
if options[:failonfail] and exit_status != 0
|
164
|
-
raise ExecutionFailure, "Execution of '#{str}' returned #{exit_status}: #{output}"
|
188
|
+
raise Puppet::ExecutionFailure, "Execution of '#{str}' returned #{exit_status}: #{output}"
|
165
189
|
end
|
166
190
|
|
167
|
-
output
|
191
|
+
Puppet::Util::Execution::ProcessOutput.new(output || '', exit_status)
|
168
192
|
end
|
169
193
|
|
170
194
|
# Returns the path to the ruby executable (available via Config object, even if
|
171
195
|
# it's not in the PATH... so this is slightly safer than just using Puppet::Util.which)
|
172
196
|
# @return [String] the path to the Ruby executable
|
197
|
+
# @api private
|
173
198
|
#
|
174
199
|
def self.ruby_path()
|
175
200
|
File.join(RbConfig::CONFIG['bindir'],
|
@@ -261,7 +286,7 @@ module Util::Execution
|
|
261
286
|
# about a race condition because all of the places that we call this from are preceded by a call to "waitpid2",
|
262
287
|
# meaning that the processes responsible for writing the file have completed before we get here.)
|
263
288
|
2.times do |try|
|
264
|
-
if File.
|
289
|
+
if Puppet::FileSystem::File.exist?(stdout.path)
|
265
290
|
stdout.open
|
266
291
|
begin
|
267
292
|
return stdout.read
|
@@ -279,4 +304,3 @@ module Util::Execution
|
|
279
304
|
end
|
280
305
|
private_class_method :wait_for_output
|
281
306
|
end
|
282
|
-
end
|
data/lib/puppet/util/filetype.rb
CHANGED
@@ -98,12 +98,12 @@ class Puppet::Util::FileType
|
|
98
98
|
newfiletype(:flat) do
|
99
99
|
# Back the file up before replacing it.
|
100
100
|
def backup
|
101
|
-
bucket.backup(@path) if File.
|
101
|
+
bucket.backup(@path) if Puppet::FileSystem::File.exist?(@path)
|
102
102
|
end
|
103
103
|
|
104
104
|
# Read the file.
|
105
105
|
def read
|
106
|
-
if File.exist?(@path)
|
106
|
+
if Puppet::FileSystem::File.exist?(@path)
|
107
107
|
File.read(@path)
|
108
108
|
else
|
109
109
|
return nil
|
@@ -112,7 +112,7 @@ class Puppet::Util::FileType
|
|
112
112
|
|
113
113
|
# Remove the file.
|
114
114
|
def remove
|
115
|
-
File.unlink(@path) if File.exist?(@path)
|
115
|
+
Puppet::FileSystem::File.unlink(@path) if Puppet::FileSystem::File.exist?(@path)
|
116
116
|
end
|
117
117
|
|
118
118
|
# Overwrite the file.
|
@@ -42,9 +42,9 @@ module Puppet::Util::InstanceLoader
|
|
42
42
|
# Use this method so they all get loaded
|
43
43
|
loaded_instances(type).sort { |a,b| a.to_s <=> b.to_s }.each do |name|
|
44
44
|
mod = self.loaded_instance(name)
|
45
|
-
docs
|
45
|
+
docs << "#{name}\n#{"-" * name.to_s.length}\n"
|
46
46
|
|
47
|
-
docs
|
47
|
+
docs << Puppet::Util::Docs.scrub(mod.doc) << "\n\n"
|
48
48
|
end
|
49
49
|
|
50
50
|
docs
|
@@ -5,7 +5,6 @@ require 'puppet/util/instance_loader'
|
|
5
5
|
class Puppet::Util::Instrumentation
|
6
6
|
extend Puppet::Util::ClassGen
|
7
7
|
extend Puppet::Util::InstanceLoader
|
8
|
-
extend MonitorMixin
|
9
8
|
|
10
9
|
# we're using a ruby lazy autoloader to prevent a loop when requiring listeners
|
11
10
|
# since this class sets up an indirection which is also used in Puppet::Indirector::Indirection
|
@@ -71,11 +70,9 @@ class Puppet::Util::Instrumentation
|
|
71
70
|
end
|
72
71
|
|
73
72
|
def self.each_listener(label)
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
end
|
78
|
-
}.each do |l|
|
73
|
+
@listeners_of[label] ||= @listeners.select do |k,l|
|
74
|
+
l.listen_to?(label)
|
75
|
+
end.each do |l|
|
79
76
|
yield l
|
80
77
|
end
|
81
78
|
end
|
@@ -105,67 +102,51 @@ class Puppet::Util::Instrumentation
|
|
105
102
|
end
|
106
103
|
|
107
104
|
def self.subscribe(listener, label_pattern, event)
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
rehash
|
114
|
-
}
|
105
|
+
raise "Listener #{listener.name} is already subscribed" if @listeners.include?(listener.name)
|
106
|
+
Puppet.debug "registering instrumentation listener #{listener.name}"
|
107
|
+
@listeners[listener.name] = Listener.new(listener, label_pattern, event)
|
108
|
+
listener.subscribed if listener.respond_to?(:subscribed)
|
109
|
+
rehash
|
115
110
|
end
|
116
111
|
|
117
112
|
def self.unsubscribe(listener)
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
rehash
|
124
|
-
}
|
113
|
+
Puppet.warning("#{listener.name} hasn't been registered but asked to be unregistered") unless @listeners.include?(listener.name)
|
114
|
+
Puppet.info "unregistering instrumentation listener #{listener.name}"
|
115
|
+
@listeners.delete(listener.name)
|
116
|
+
listener.unsubscribed if listener.respond_to?(:unsubscribed)
|
117
|
+
rehash
|
125
118
|
end
|
126
119
|
|
127
120
|
def self.init
|
128
121
|
# let's init our probe indirection
|
129
122
|
require 'puppet/util/instrumentation/indirection_probe'
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
instance_loader(:listener).loadall
|
134
|
-
}
|
123
|
+
@listeners ||= {}
|
124
|
+
@listeners_of ||= {}
|
125
|
+
instance_loader(:listener).loadall
|
135
126
|
end
|
136
127
|
|
137
128
|
def self.clear
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
@id = 0
|
142
|
-
}
|
129
|
+
@listeners = {}
|
130
|
+
@listeners_of = {}
|
131
|
+
@id = 0
|
143
132
|
end
|
144
133
|
|
145
134
|
def self.[](key)
|
146
|
-
|
147
|
-
@listeners[key.intern]
|
148
|
-
}
|
135
|
+
@listeners[key.intern]
|
149
136
|
end
|
150
137
|
|
151
138
|
def self.[]=(key, value)
|
152
|
-
|
153
|
-
|
154
|
-
rehash
|
155
|
-
}
|
139
|
+
@listeners[key.intern] = value
|
140
|
+
rehash
|
156
141
|
end
|
157
142
|
|
158
143
|
private
|
159
144
|
|
160
|
-
# should be called only under the guard
|
161
|
-
# self.synchronize
|
162
145
|
def self.rehash
|
163
146
|
@listeners_of = {}
|
164
147
|
end
|
165
148
|
|
166
149
|
def self.next_id
|
167
|
-
|
168
|
-
@id = (@id || 0) + 1
|
169
|
-
}
|
150
|
+
@id = (@id || 0) + 1
|
170
151
|
end
|
171
152
|
end
|