puppet 3.2.4 → 3.3.0.rc2
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/COMMITTERS.md +101 -42
- data/Gemfile +15 -4
- data/README.md +5 -1
- data/README_DEVELOPER.md +117 -54
- data/Rakefile +4 -0
- data/ext/build_defaults.yaml +3 -2
- data/ext/debian/puppet-common.manpages +33 -1
- data/ext/gentoo/init.d/puppet +1 -1
- data/ext/gentoo/init.d/puppetmaster +1 -1
- data/ext/redhat/puppet.spec.erb +0 -1
- data/install.rb +2 -1
- data/lib/hiera/backend/puppet_backend.rb +1 -1
- data/lib/puppet/application.rb +10 -9
- data/lib/puppet/application/agent.rb +87 -93
- data/lib/puppet/application/apply.rb +0 -2
- data/lib/puppet/application/device.rb +3 -3
- data/lib/puppet/application/kick.rb +2 -2
- data/lib/puppet/application/master.rb +41 -19
- data/lib/puppet/application/queue.rb +5 -3
- data/lib/puppet/bindings.rb +147 -0
- data/lib/puppet/configurer.rb +25 -15
- data/lib/puppet/configurer/fact_handler.rb +2 -9
- data/lib/puppet/daemon.rb +44 -33
- data/lib/puppet/defaults.rb +57 -26
- data/lib/puppet/error.rb +1 -1
- data/lib/puppet/external/dot.rb +2 -2
- data/lib/puppet/external/nagios/base.rb +1 -6
- data/lib/puppet/external/pson/common.rb +2 -2
- data/lib/puppet/external/pson/pure/generator.rb +2 -2
- data/lib/puppet/external/pson/pure/parser.rb +1 -1
- data/lib/puppet/face/ca.rb +1 -1
- data/lib/puppet/face/config.rb +1 -1
- data/lib/puppet/face/help.rb +2 -2
- data/lib/puppet/face/module/list.rb +2 -2
- data/lib/puppet/feature/rails.rb +1 -1
- data/lib/puppet/file_bucket/dipper.rb +0 -1
- data/lib/puppet/file_serving/base.rb +1 -1
- data/lib/puppet/file_serving/configuration/parser.rb +20 -14
- data/lib/puppet/forge.rb +0 -32
- data/lib/puppet/forge/cache.rb +1 -1
- data/lib/puppet/forge/errors.rb +3 -3
- data/lib/puppet/forge/repository.rb +7 -42
- data/lib/puppet/graph.rb +11 -0
- data/lib/puppet/graph/key.rb +26 -0
- data/lib/puppet/graph/prioritizer.rb +29 -0
- data/lib/puppet/graph/random_prioritizer.rb +16 -0
- data/lib/puppet/{rb_tree_map.rb → graph/rb_tree_map.rb} +3 -3
- data/lib/puppet/graph/relationship_graph.rb +246 -0
- data/lib/puppet/graph/sequential_prioritizer.rb +31 -0
- data/lib/puppet/{simple_graph.rb → graph/simple_graph.rb} +22 -3
- data/lib/puppet/graph/title_hash_prioritizer.rb +16 -0
- data/lib/puppet/indirector.rb +2 -2
- data/lib/puppet/indirector/catalog/compiler.rb +10 -7
- data/lib/puppet/indirector/catalog/static_compiler.rb +50 -0
- data/lib/puppet/indirector/certificate/rest.rb +1 -1
- data/lib/puppet/indirector/exec.rb +1 -1
- data/lib/puppet/indirector/facts/facter.rb +2 -2
- data/lib/puppet/indirector/facts/inventory_active_record.rb +0 -1
- data/lib/puppet/indirector/facts/network_device.rb +1 -1
- data/lib/puppet/indirector/file_bucket_file/file.rb +0 -1
- data/lib/puppet/indirector/indirection.rb +2 -2
- data/lib/puppet/indirector/memory.rb +9 -0
- data/lib/puppet/indirector/node/ldap.rb +2 -4
- data/lib/puppet/indirector/report/processor.rb +1 -2
- data/lib/puppet/indirector/report/rest.rb +1 -1
- data/lib/puppet/indirector/request.rb +32 -10
- data/lib/puppet/indirector/resource/rest.rb +1 -1
- data/lib/puppet/indirector/resource_type/parser.rb +31 -12
- data/lib/puppet/interface.rb +1 -1
- data/lib/puppet/interface/documentation.rb +7 -11
- data/lib/puppet/interface/option.rb +1 -1
- data/lib/puppet/interface/option_builder.rb +1 -1
- data/lib/puppet/metatype/manager.rb +2 -2
- data/lib/puppet/module.rb +7 -1
- data/lib/puppet/module_tool.rb +1 -1
- data/lib/puppet/module_tool/applications/application.rb +10 -0
- data/lib/puppet/module_tool/applications/installer.rb +6 -3
- data/lib/puppet/module_tool/dependency.rb +2 -0
- data/lib/puppet/module_tool/errors/upgrader.rb +1 -1
- data/lib/puppet/module_tool/metadata.rb +25 -13
- data/lib/puppet/module_tool/modulefile.rb +7 -7
- data/lib/puppet/module_tool/shared_behaviors.rb +4 -2
- data/lib/puppet/module_tool/skeleton.rb +1 -1
- data/lib/puppet/module_tool/skeleton/templates/generator/manifests/init.pp.erb +5 -5
- data/lib/puppet/module_tool/skeleton/templates/generator/tests/init.pp.erb +5 -4
- data/lib/puppet/network/auth_config_parser.rb +3 -0
- data/lib/puppet/network/authconfig.rb +0 -1
- data/lib/puppet/network/authorization.rb +1 -1
- data/lib/puppet/network/authstore.rb +2 -2
- data/lib/puppet/network/format_handler.rb +25 -114
- data/lib/puppet/network/format_support.rb +106 -0
- data/lib/puppet/network/formats.rb +10 -4
- data/lib/puppet/network/http/compression.rb +1 -1
- data/lib/puppet/network/http/connection.rb +76 -32
- data/lib/puppet/network/http/handler.rb +122 -61
- data/lib/puppet/network/http/rack/rest.rb +1 -1
- data/lib/puppet/network/http/webrick/rest.rb +9 -3
- data/lib/puppet/network/http_pool.rb +2 -2
- data/lib/puppet/network/resolver.rb +1 -0
- data/lib/puppet/network/server.rb +5 -81
- data/lib/puppet/node/environment.rb +256 -13
- data/lib/puppet/node/facts.rb +28 -2
- data/lib/puppet/parameter.rb +27 -18
- data/lib/puppet/parameter/boolean.rb +20 -0
- data/lib/puppet/parameter/path.rb +1 -1
- data/lib/puppet/parameter/value.rb +1 -1
- data/lib/puppet/parameter/value_collection.rb +1 -1
- data/lib/puppet/parser/ast/arithmetic_operator.rb +8 -0
- data/lib/puppet/parser/ast/casestatement.rb +0 -3
- data/lib/puppet/parser/ast/lambda.rb +25 -6
- data/lib/puppet/parser/ast/leaf.rb +10 -3
- data/lib/puppet/parser/ast/nop.rb +1 -1
- data/lib/puppet/parser/ast/resource_override.rb +0 -2
- data/lib/puppet/parser/compiler.rb +92 -34
- data/lib/puppet/parser/files.rb +0 -5
- data/lib/puppet/parser/functions/create_resources.rb +23 -46
- data/lib/puppet/parser/functions/each.rb +0 -2
- data/lib/puppet/parser/functions/extlookup.rb +2 -2
- data/lib/puppet/parser/functions/foreach.rb +0 -2
- data/lib/puppet/parser/functions/hiera_include.rb +1 -1
- data/lib/puppet/parser/functions/lookup.rb +44 -0
- data/lib/puppet/parser/functions/slice.rb +1 -1
- data/lib/puppet/parser/grammar.ra +0 -1
- data/lib/puppet/parser/lexer.rb +0 -1
- data/lib/puppet/parser/parser.rb +0 -1
- data/lib/puppet/parser/parser_factory.rb +3 -2
- data/lib/puppet/parser/parser_support.rb +1 -1
- data/lib/puppet/parser/relationship.rb +1 -1
- data/lib/puppet/parser/scope.rb +49 -24
- data/lib/puppet/parser/type_loader.rb +13 -18
- data/lib/puppet/pops.rb +45 -0
- data/lib/puppet/pops/adaptable.rb +2 -2
- data/lib/puppet/pops/adapters.rb +4 -0
- data/lib/puppet/pops/binder/binder.rb +421 -0
- data/lib/puppet/pops/binder/binder_issues.rb +142 -0
- data/lib/puppet/pops/binder/bindings_checker.rb +217 -0
- data/lib/puppet/pops/binder/bindings_composer.rb +241 -0
- data/lib/puppet/pops/binder/bindings_factory.rb +847 -0
- data/lib/puppet/pops/binder/bindings_label_provider.rb +46 -0
- data/lib/puppet/pops/binder/bindings_loader.rb +79 -0
- data/lib/puppet/pops/binder/bindings_model.rb +215 -0
- data/lib/puppet/pops/binder/bindings_model_dumper.rb +205 -0
- data/lib/puppet/pops/binder/bindings_validator_factory.rb +28 -0
- data/lib/puppet/pops/binder/config/binder_config.rb +139 -0
- data/lib/puppet/pops/binder/config/binder_config_checker.rb +183 -0
- data/lib/puppet/pops/binder/config/diagnostic_producer.rb +32 -0
- data/lib/puppet/pops/binder/config/issues.rb +106 -0
- data/lib/puppet/pops/binder/hiera2.rb +10 -0
- data/lib/puppet/pops/binder/hiera2/bindings_provider.rb +148 -0
- data/lib/puppet/pops/binder/hiera2/config.rb +69 -0
- data/lib/puppet/pops/binder/hiera2/config_checker.rb +68 -0
- data/lib/puppet/pops/binder/hiera2/diagnostic_producer.rb +36 -0
- data/lib/puppet/pops/binder/hiera2/issues.rb +67 -0
- data/lib/puppet/pops/binder/hiera2/json_backend.rb +18 -0
- data/lib/puppet/pops/binder/hiera2/yaml_backend.rb +21 -0
- data/lib/puppet/pops/binder/injector.rb +688 -0
- data/lib/puppet/pops/binder/injector_entry.rb +53 -0
- data/lib/puppet/pops/binder/key_factory.rb +61 -0
- data/lib/puppet/pops/binder/producers.rb +829 -0
- data/lib/puppet/pops/binder/scheme_handler/confdir_hiera_scheme.rb +67 -0
- data/lib/puppet/pops/binder/scheme_handler/confdir_scheme.rb +34 -0
- data/lib/puppet/pops/binder/scheme_handler/module_hiera_scheme.rb +92 -0
- data/lib/puppet/pops/binder/scheme_handler/module_scheme.rb +84 -0
- data/lib/puppet/pops/binder/scheme_handler/symbolic_scheme.rb +54 -0
- data/lib/puppet/pops/binder/system_bindings.rb +72 -0
- data/lib/puppet/pops/issue_reporter.rb +75 -0
- data/lib/puppet/pops/issues.rb +9 -5
- data/lib/puppet/pops/model/ast_transformer.rb +4 -4
- data/lib/puppet/pops/model/ast_tree_dumper.rb +1 -1
- data/lib/puppet/pops/model/factory.rb +25 -13
- data/lib/puppet/pops/model/model.rb +1 -1
- data/lib/puppet/pops/model/tree_dumper.rb +2 -2
- data/lib/puppet/pops/parser/egrammar.ra +0 -1
- data/lib/puppet/pops/parser/eparser.rb +1 -2
- data/lib/puppet/pops/parser/evaluating_parser.rb +162 -0
- data/lib/puppet/pops/parser/lexer.rb +8 -6
- data/lib/puppet/pops/types/class_loader.rb +118 -0
- data/lib/puppet/pops/types/type_calculator.rb +557 -0
- data/lib/puppet/pops/types/type_factory.rb +147 -0
- data/lib/puppet/pops/types/type_parser.rb +117 -0
- data/lib/puppet/pops/types/types.rb +132 -0
- data/lib/puppet/pops/validation.rb +146 -17
- data/lib/puppet/pops/validation/checker3_1.rb +1 -1
- data/lib/puppet/pops/validation/validator_factory_3_1.rb +6 -16
- data/lib/puppet/property.rb +3 -3
- data/lib/puppet/property/keyvalue.rb +1 -1
- data/lib/puppet/provider.rb +2 -2
- data/lib/puppet/provider/aixobject.rb +19 -21
- data/lib/puppet/provider/augeas/augeas.rb +3 -1
- data/lib/puppet/provider/command.rb +2 -2
- data/lib/puppet/provider/group/aix.rb +1 -1
- data/lib/puppet/provider/group/ldap.rb +1 -1
- data/lib/puppet/provider/macauthorization/macauthorization.rb +1 -1
- data/lib/puppet/provider/mailalias/aliases.rb +3 -8
- data/lib/puppet/provider/mcx/mcxcontent.rb +7 -1
- data/lib/puppet/provider/mount.rb +8 -3
- data/lib/puppet/provider/nameservice.rb +1 -1
- data/lib/puppet/provider/nameservice/directoryservice.rb +5 -5
- data/lib/puppet/provider/package/appdmg.rb +1 -1
- data/lib/puppet/provider/package/apt.rb +0 -1
- data/lib/puppet/provider/package/dpkg.rb +86 -32
- data/lib/puppet/provider/package/fink.rb +0 -2
- data/lib/puppet/provider/package/freebsd.rb +0 -2
- data/lib/puppet/provider/package/openbsd.rb +57 -10
- data/lib/puppet/provider/package/opkg.rb +0 -1
- data/lib/puppet/provider/package/pacman.rb +0 -1
- data/lib/puppet/provider/package/pip.rb +1 -1
- data/lib/puppet/provider/package/pkgdmg.rb +17 -6
- data/lib/puppet/provider/package/pkgutil.rb +1 -1
- data/lib/puppet/provider/package/portage.rb +9 -1
- data/lib/puppet/provider/package/ports.rb +2 -2
- data/lib/puppet/provider/package/rpm.rb +29 -12
- data/lib/puppet/provider/package/rug.rb +1 -1
- data/lib/puppet/provider/package/urpmi.rb +11 -15
- data/lib/puppet/provider/package/windows/exe_package.rb +1 -1
- data/lib/puppet/provider/package/windows/package.rb +1 -26
- data/lib/puppet/provider/package/yum.rb +1 -1
- data/lib/puppet/provider/package/zypper.rb +22 -3
- data/lib/puppet/provider/parsedfile.rb +1 -12
- data/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +1 -1
- data/lib/puppet/provider/service/base.rb +1 -1
- data/lib/puppet/provider/service/daemontools.rb +3 -3
- data/lib/puppet/provider/service/debian.rb +1 -1
- data/lib/puppet/provider/service/init.rb +14 -20
- data/lib/puppet/provider/service/openrc.rb +3 -1
- data/lib/puppet/provider/service/redhat.rb +5 -8
- data/lib/puppet/provider/service/runit.rb +3 -2
- data/lib/puppet/provider/service/systemd.rb +1 -1
- data/lib/puppet/provider/ssh_authorized_key/parsed.rb +1 -1
- data/lib/puppet/provider/sshkey/parsed.rb +0 -2
- data/lib/puppet/provider/user/aix.rb +25 -12
- data/lib/puppet/provider/user/directoryservice.rb +4 -7
- data/lib/puppet/provider/user/ldap.rb +0 -1
- data/lib/puppet/provider/user/user_role_add.rb +2 -0
- data/lib/puppet/provider/user/useradd.rb +1 -1
- data/lib/puppet/provider/zone/solaris.rb +1 -2
- data/lib/puppet/reference/metaparameter.rb +1 -1
- data/lib/puppet/reference/type.rb +1 -1
- data/lib/puppet/reports/rrdgraph.rb +1 -1
- data/lib/puppet/reports/tagmail.rb +1 -1
- data/lib/puppet/resource.rb +16 -4
- data/lib/puppet/resource/catalog.rb +111 -173
- data/lib/puppet/resource/status.rb +42 -3
- data/lib/puppet/resource/type.rb +33 -46
- data/lib/puppet/resource/type_collection.rb +19 -15
- data/lib/puppet/run.rb +5 -1
- data/lib/puppet/scheduler/scheduler.rb +14 -15
- data/lib/puppet/settings.rb +78 -41
- data/lib/puppet/settings/boolean_setting.rb +0 -2
- data/lib/puppet/settings/config_file.rb +0 -2
- data/lib/puppet/settings/directory_setting.rb +0 -2
- data/lib/puppet/settings/duration_setting.rb +0 -2
- data/lib/puppet/settings/enum_setting.rb +16 -0
- data/lib/puppet/settings/file_setting.rb +0 -2
- data/lib/puppet/settings/path_setting.rb +0 -2
- data/lib/puppet/settings/string_setting.rb +0 -3
- data/lib/puppet/settings/terminus_setting.rb +0 -2
- data/lib/puppet/ssl/certificate_authority.rb +102 -9
- data/lib/puppet/test/test_helper.rb +1 -0
- data/lib/puppet/transaction.rb +130 -292
- data/lib/puppet/transaction/additional_resource_generator.rb +126 -0
- data/lib/puppet/transaction/event.rb +16 -1
- data/lib/puppet/transaction/report.rb +34 -14
- data/lib/puppet/transaction/resource_harness.rb +16 -19
- data/lib/puppet/type.rb +59 -53
- data/lib/puppet/type/component.rb +0 -2
- data/lib/puppet/type/cron.rb +13 -2
- data/lib/puppet/type/exec.rb +5 -7
- data/lib/puppet/type/file.rb +9 -32
- data/lib/puppet/type/file/content.rb +4 -1
- data/lib/puppet/type/file/ctime.rb +3 -1
- data/lib/puppet/type/file/ensure.rb +1 -1
- data/lib/puppet/type/file/mode.rb +0 -1
- data/lib/puppet/type/file/mtime.rb +2 -1
- data/lib/puppet/type/group.rb +7 -9
- data/lib/puppet/type/host.rb +1 -2
- data/lib/puppet/type/mcx.rb +0 -1
- data/lib/puppet/type/mount.rb +38 -6
- data/lib/puppet/type/package.rb +2 -2
- data/lib/puppet/type/resources.rb +5 -4
- data/lib/puppet/type/schedule.rb +1 -4
- data/lib/puppet/type/selmodule.rb +1 -1
- data/lib/puppet/type/service.rb +1 -3
- data/lib/puppet/type/tidy.rb +3 -3
- data/lib/puppet/type/user.rb +9 -13
- data/lib/puppet/type/yumrepo.rb +11 -7
- data/lib/puppet/util.rb +14 -7
- data/lib/puppet/util/autoload.rb +0 -1
- data/lib/puppet/util/backups.rb +1 -3
- data/lib/puppet/util/classgen.rb +1 -1
- data/lib/puppet/util/command_line/puppet_option_parser.rb +1 -3
- data/lib/puppet/util/command_line/trollop.rb +1 -1
- data/lib/puppet/util/constant_inflector.rb +1 -2
- data/lib/puppet/util/errors.rb +1 -0
- data/lib/puppet/util/file_watcher.rb +28 -0
- data/lib/puppet/util/fileparsing.rb +1 -3
- data/lib/puppet/util/filetype.rb +0 -1
- data/lib/puppet/util/http_proxy.rb +38 -0
- data/lib/puppet/util/ldap/manager.rb +1 -2
- data/lib/puppet/util/log.rb +31 -10
- data/lib/puppet/util/log/destinations.rb +0 -50
- data/lib/puppet/util/metric.rb +8 -1
- data/lib/puppet/util/monkey_patches.rb +14 -148
- data/lib/puppet/util/network_device/cisco/facts.rb +1 -1
- data/lib/puppet/util/network_device/config.rb +6 -9
- data/lib/puppet/util/network_device/transport/ssh.rb +1 -1
- data/lib/puppet/util/pidlock.rb +3 -0
- data/lib/puppet/util/posix.rb +1 -1
- data/lib/puppet/util/profiler.rb +1 -1
- data/lib/puppet/util/rdoc.rb +1 -1
- data/lib/puppet/util/rdoc/generators/puppet_generator.rb +0 -1
- data/lib/puppet/util/rdoc/generators/template/puppet/puppet.rb +50 -42
- data/lib/puppet/util/retryaction.rb +0 -1
- data/lib/puppet/util/symbolic_file_mode.rb +5 -1
- data/lib/puppet/util/tagging.rb +0 -2
- data/lib/puppet/util/warnings.rb +3 -0
- data/lib/puppet/util/watched_file.rb +37 -0
- data/lib/puppet/util/watcher.rb +17 -0
- data/lib/puppet/util/watcher/change_watcher.rb +33 -0
- data/lib/puppet/util/watcher/periodic_watcher.rb +37 -0
- data/lib/puppet/util/watcher/timer.rb +19 -0
- data/lib/puppet/util/windows/user.rb +1 -1
- data/lib/puppet/version.rb +1 -1
- data/lib/puppetx.rb +109 -0
- data/lib/puppetx/puppet/bindings_scheme_handler.rb +130 -0
- data/lib/puppetx/puppet/hiera2_backend.rb +31 -0
- data/lib/puppetx/puppet/syntax_checker.rb +91 -0
- data/lib/puppetx/puppetlabs/syntax_checkers/json.rb +39 -0
- data/lib/semver.rb +1 -1
- data/man/man8/puppet-kick.8 +1 -1
- data/spec/fixtures/integration/provider/cron/crontab/unspecialized +15 -0
- data/spec/fixtures/unit/pops/binder/bindings_composer/hiera1config/binder_config.yaml +18 -0
- data/spec/fixtures/unit/pops/binder/bindings_composer/hiera1config/hiera.yaml +8 -0
- data/spec/fixtures/unit/pops/binder/bindings_composer/hiera1config/modules/good/common.yaml +1 -0
- data/spec/fixtures/unit/pops/binder/bindings_composer/hiera1config/modules/good/hiera.yaml +10 -0
- data/spec/fixtures/unit/pops/binder/bindings_composer/ok/binder_config.yaml +19 -0
- data/spec/fixtures/unit/pops/binder/bindings_composer/ok/common.yaml +1 -0
- data/spec/fixtures/unit/pops/binder/bindings_composer/ok/hiera.yaml +11 -0
- data/spec/fixtures/unit/pops/binder/bindings_composer/ok/localhost.yaml +1 -0
- data/spec/fixtures/unit/pops/binder/bindings_composer/ok/modules/awesome/common.yaml +3 -0
- data/spec/fixtures/unit/pops/binder/bindings_composer/ok/modules/awesome/hiera.yaml +13 -0
- data/spec/fixtures/unit/pops/binder/bindings_composer/ok/modules/awesome/lib/puppet/bindings/awesome/default.rb +4 -0
- data/spec/fixtures/unit/pops/binder/bindings_composer/ok/modules/awesome/lib/puppetx/awesome/echo_backend.rb +11 -0
- data/spec/fixtures/unit/pops/binder/bindings_composer/ok/modules/awesome/lib/puppetx/awesome/echo_scheme_handler.rb +18 -0
- data/spec/fixtures/unit/pops/binder/bindings_composer/ok/modules/awesome/localhost.yaml +1 -0
- data/spec/fixtures/unit/pops/binder/bindings_composer/ok/modules/bad/common.yaml +3 -0
- data/spec/fixtures/unit/pops/binder/bindings_composer/ok/modules/bad/hiera_config.yaml +9 -0
- data/spec/fixtures/unit/pops/binder/bindings_composer/ok/modules/good/common.yaml +2 -0
- data/spec/fixtures/unit/pops/binder/bindings_composer/ok/modules/good/hiera.yaml +11 -0
- data/spec/fixtures/unit/pops/binder/config/binder_config/ok/binder_config.yaml +9 -0
- data/spec/fixtures/unit/pops/binder/hiera2/bindings_provider/ok/hiera.yaml +9 -0
- data/spec/fixtures/unit/pops/binder/hiera2/bindings_provider/ok/node.example.com.json +9 -0
- data/spec/fixtures/unit/pops/binder/hiera2/bindings_provider/ok/node.example.com.yaml +5 -0
- data/spec/fixtures/unit/pops/binder/hiera2/config/bad_syntax/hiera.yaml +10 -0
- data/spec/fixtures/unit/pops/binder/hiera2/config/malformed_hierarchy/hiera.yaml +8 -0
- data/spec/fixtures/unit/pops/binder/hiera2/config/missing/foo.txt +1 -0
- data/spec/fixtures/unit/pops/binder/hiera2/config/no_backends/hiera.yaml +7 -0
- data/spec/fixtures/unit/pops/binder/hiera2/config/no_hierarchy/hiera.yaml +4 -0
- data/spec/fixtures/unit/pops/binder/hiera2/config/not_a_hash/hiera.yaml +2 -0
- data/spec/fixtures/unit/pops/binder/hiera2/config/ok/hiera.yaml +8 -0
- data/spec/fixtures/unit/pops/binder/hiera2/yaml_backend/empty/common.yaml +0 -0
- data/spec/fixtures/unit/pops/binder/hiera2/yaml_backend/invalid/common.yaml +1 -0
- data/spec/fixtures/unit/pops/binder/hiera2/yaml_backend/ok/common.yaml +2 -0
- data/spec/fixtures/unit/provider/package/openbsd/pkginfo_flavors.list +2 -0
- data/spec/integration/agent/logging_spec.rb +178 -0
- data/spec/integration/configurer_spec.rb +1 -1
- data/spec/integration/defaults_spec.rb +0 -6
- data/spec/integration/network/authconfig_spec.rb +19 -0
- data/spec/integration/network/server/webrick_spec.rb +10 -11
- data/spec/integration/parser/catalog_spec.rb +85 -0
- data/spec/integration/provider/cron/crontab_spec.rb +11 -0
- data/spec/integration/provider/mount_spec.rb +1 -0
- data/spec/integration/transaction_spec.rb +8 -8
- data/spec/integration/type/file_spec.rb +1 -1
- data/spec/integration/util/settings_spec.rb +58 -11
- data/spec/lib/matchers/include_in_order.rb +21 -0
- data/spec/lib/matchers/include_in_order_spec.rb +30 -0
- data/spec/lib/matchers/relationship_graph_matchers.rb +48 -0
- data/spec/lib/puppet_spec/compiler.rb +24 -0
- data/spec/lib/puppet_spec/pops.rb +16 -0
- data/spec/spec_helper.rb +0 -1
- data/spec/unit/application/agent_spec.rb +145 -145
- data/spec/unit/application/apply_spec.rb +1 -1
- data/spec/unit/application/doc_spec.rb +1 -1
- data/spec/unit/application/face_base_spec.rb +3 -3
- data/spec/unit/application/facts_spec.rb +1 -0
- data/spec/unit/application/master_spec.rb +0 -15
- data/spec/unit/application/queue_spec.rb +6 -12
- data/spec/unit/application/resource_spec.rb +1 -1
- data/spec/unit/configurer/fact_handler_spec.rb +19 -50
- data/spec/unit/configurer_spec.rb +23 -7
- data/spec/unit/daemon_spec.rb +97 -121
- data/spec/unit/defaults_spec.rb +44 -0
- data/spec/unit/face/node_spec.rb +2 -2
- data/spec/unit/file_serving/configuration/parser_spec.rb +23 -33
- data/spec/unit/file_serving/configuration_spec.rb +2 -2
- data/spec/unit/file_serving/mount/file_spec.rb +4 -4
- data/spec/unit/forge/repository_spec.rb +9 -29
- data/spec/unit/graph/key_spec.rb +41 -0
- data/spec/unit/{rb_tree_map_spec.rb → graph/rb_tree_map_spec.rb} +7 -7
- data/spec/unit/graph/relationship_graph_spec.rb +393 -0
- data/spec/unit/graph/sequential_prioritizer_spec.rb +32 -0
- data/spec/unit/{simple_graph_spec.rb → graph/simple_graph.rb} +42 -254
- data/spec/unit/graph/title_hash_prioritizer_spec.rb +49 -0
- data/spec/unit/hiera_puppet_spec.rb +1 -1
- data/spec/unit/indirector/catalog/active_record_spec.rb +4 -2
- data/spec/unit/indirector/catalog/compiler_spec.rb +20 -26
- data/spec/unit/indirector/face_spec.rb +1 -1
- data/spec/unit/indirector/facts/facter_spec.rb +11 -1
- data/spec/unit/indirector/facts/network_device_spec.rb +11 -1
- data/spec/unit/indirector/hiera_spec.rb +1 -1
- data/spec/unit/indirector/instrumentation_data/local_spec.rb +1 -1
- data/spec/unit/indirector/instrumentation_listener/local_spec.rb +1 -1
- data/spec/unit/indirector/request_spec.rb +92 -39
- data/spec/unit/indirector/rest_spec.rb +1 -0
- data/spec/unit/indirector_spec.rb +2 -2
- data/spec/unit/interface/option_builder_spec.rb +1 -0
- data/spec/unit/interface/option_spec.rb +1 -0
- data/spec/unit/interface_spec.rb +2 -2
- data/spec/unit/module_tool/applications/installer_spec.rb +49 -2
- data/spec/unit/module_tool/metadata_spec.rb +13 -0
- data/spec/unit/network/authstore_spec.rb +1 -1
- data/spec/unit/network/format_handler_spec.rb +33 -282
- data/spec/unit/network/format_support_spec.rb +199 -0
- data/spec/unit/network/formats_spec.rb +2 -2
- data/spec/unit/network/http/connection_spec.rb +88 -7
- data/spec/unit/network/http/handler_spec.rb +271 -249
- data/spec/unit/network/http/rack/rest_spec.rb +1 -1
- data/spec/unit/network/http/webrick/rest_spec.rb +73 -22
- data/spec/unit/network/http_pool_spec.rb +40 -0
- data/spec/unit/network/server_spec.rb +18 -207
- data/spec/unit/node/facts_spec.rb +68 -17
- data/spec/unit/other/selinux_spec.rb +24 -20
- data/spec/unit/parameter/boolean_spec.rb +25 -0
- data/spec/unit/parameter/value_collection_spec.rb +7 -7
- data/spec/unit/parameter_spec.rb +10 -13
- data/spec/unit/parser/ast/function_spec.rb +4 -4
- data/spec/unit/parser/ast/leaf_spec.rb +45 -6
- data/spec/unit/parser/collector_spec.rb +3 -3
- data/spec/unit/parser/compiler_spec.rb +4 -3
- data/spec/unit/parser/functions/create_resources_spec.rb +9 -25
- data/spec/unit/parser/functions/extlookup_spec.rb +2 -2
- data/spec/unit/parser/functions/hiera_include_spec.rb +12 -0
- data/spec/unit/parser/functions/lookup_spec.rb +96 -0
- data/spec/unit/parser/functions/regsubst_spec.rb +2 -2
- data/spec/unit/parser/functions/split_spec.rb +2 -2
- data/spec/unit/parser/functions/sprintf_spec.rb +1 -1
- data/spec/unit/parser/functions/versioncmp_spec.rb +2 -2
- data/spec/unit/parser/functions_spec.rb +7 -7
- data/spec/unit/parser/lexer_spec.rb +1 -1
- data/spec/unit/parser/methods/collect_spec.rb +43 -0
- data/spec/unit/parser/resource_spec.rb +9 -9
- data/spec/unit/parser/scope_spec.rb +45 -2
- data/spec/unit/parser/type_loader_spec.rb +159 -175
- data/spec/unit/pops/binder/binder_spec.rb +62 -0
- data/spec/unit/pops/binder/bindings_checker_spec.rb +196 -0
- data/spec/unit/pops/binder/bindings_composer_spec.rb +89 -0
- data/spec/unit/pops/binder/bindings_validator_factory_spec.rb +18 -0
- data/spec/unit/pops/binder/config/binder_config_spec.rb +48 -0
- data/spec/unit/pops/binder/hiera2/bindings_provider_spec.rb +74 -0
- data/spec/unit/pops/binder/hiera2/config_spec.rb +61 -0
- data/spec/unit/pops/binder/hiera2/yaml_backend_spec.rb +33 -0
- data/spec/unit/pops/binder/injector_spec.rb +789 -0
- data/spec/unit/pops/containment_spec.rb +1 -0
- data/spec/unit/pops/issues_spec.rb +1 -1
- data/spec/unit/pops/parser/evaluating_parser_spec.rb +88 -0
- data/spec/unit/pops/parser/lexer_spec.rb +1 -1
- data/spec/unit/pops/parser/parse_calls_spec.rb +4 -0
- data/spec/unit/pops/parser/parser_spec.rb +1 -1
- data/spec/unit/pops/types/type_calculator_spec.rb +484 -0
- data/spec/unit/pops/types/type_factory_spec.rb +65 -0
- data/spec/unit/pops/types/type_parser_spec.rb +93 -0
- data/spec/unit/property/list_spec.rb +1 -1
- data/spec/unit/property/ordered_list_spec.rb +1 -1
- data/spec/unit/provider/aixobject_spec.rb +101 -0
- data/spec/unit/provider/augeas/augeas_spec.rb +14 -3
- data/spec/unit/provider/mcx/mcxcontent_spec.rb +52 -16
- data/spec/unit/provider/mount/parsed_spec.rb +44 -56
- data/spec/unit/provider/mount_spec.rb +11 -2
- data/spec/unit/provider/naginator_spec.rb +8 -0
- data/spec/unit/provider/package/apt_spec.rb +5 -1
- data/spec/unit/provider/package/aptitude_spec.rb +9 -5
- data/spec/unit/provider/package/aptrpm_spec.rb +2 -2
- data/spec/unit/provider/package/dpkg_spec.rb +274 -99
- data/spec/unit/provider/package/openbsd_spec.rb +84 -1
- data/spec/unit/provider/package/opkg_spec.rb +3 -3
- data/spec/unit/provider/package/pip_spec.rb +16 -0
- data/spec/unit/provider/package/pkgdmg_spec.rb +62 -7
- data/spec/unit/provider/package/rpm_spec.rb +112 -21
- data/spec/unit/provider/package/urpmi.rb +80 -0
- data/spec/unit/provider/package/windows/exe_package_spec.rb +1 -1
- data/spec/unit/provider/package/yum_spec.rb +85 -0
- data/spec/unit/provider/package/zypper_spec.rb +25 -6
- data/spec/unit/provider/parsedfile_spec.rb +3 -2
- data/spec/unit/provider/service/init_spec.rb +10 -10
- data/spec/unit/provider/service/openrc_spec.rb +16 -0
- data/spec/unit/provider/service/openwrt_spec.rb +1 -1
- data/spec/unit/provider/service/redhat_spec.rb +7 -0
- data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +2 -2
- data/spec/unit/provider/user/aix_spec.rb +89 -0
- data/spec/unit/provider/user/directoryservice_spec.rb +11 -4
- data/spec/unit/provider/user/user_role_add_spec.rb +18 -0
- data/spec/unit/provider_spec.rb +2 -13
- data/spec/unit/reports/http_spec.rb +1 -1
- data/spec/unit/resource/catalog_spec.rb +23 -97
- data/spec/unit/resource/resource_type.json +34 -0
- data/spec/unit/resource/status_spec.rb +56 -0
- data/spec/unit/resource/type_collection_spec.rb +6 -6
- data/spec/unit/resource/type_spec.rb +25 -5
- data/spec/unit/resource_spec.rb +68 -24
- data/spec/unit/run_spec.rb +16 -0
- data/spec/unit/scheduler/scheduler_spec.rb +14 -27
- data/spec/unit/semver_spec.rb +5 -0
- data/spec/unit/settings/enum_setting_spec.rb +27 -0
- data/spec/unit/settings_spec.rb +53 -44
- data/spec/unit/ssl/certificate_authority_spec.rb +155 -19
- data/spec/unit/transaction/additional_resource_generator_spec.rb +419 -0
- data/spec/unit/transaction/event_manager_spec.rb +2 -2
- data/spec/unit/transaction/event_spec.rb +57 -0
- data/spec/unit/transaction/report_spec.rb +66 -0
- data/spec/unit/transaction/resource_harness_spec.rb +27 -20
- data/spec/unit/transaction_spec.rb +182 -390
- data/spec/unit/type/augeas_spec.rb +3 -3
- data/spec/unit/type/component_spec.rb +0 -9
- data/spec/unit/type/computer_spec.rb +1 -1
- data/spec/unit/type/cron_spec.rb +2 -2
- data/spec/unit/type/exec_spec.rb +4 -2
- data/spec/unit/type/file/content_spec.rb +11 -0
- data/spec/unit/type/file/group_spec.rb +1 -1
- data/spec/unit/type/file_spec.rb +16 -8
- data/spec/unit/type/mount_spec.rb +445 -259
- data/spec/unit/type/package_spec.rb +4 -4
- data/spec/unit/type/resources_spec.rb +30 -1
- data/spec/unit/type/user_spec.rb +26 -3
- data/spec/unit/type/yumrepo_spec.rb +7 -27
- data/spec/unit/type/zone_spec.rb +4 -1
- data/spec/unit/type_spec.rb +66 -33
- data/spec/unit/util/backups_spec.rb +3 -3
- data/spec/unit/util/http_proxy_spec.rb +83 -0
- data/spec/unit/util/log_spec.rb +79 -8
- data/spec/unit/util/metric_spec.rb +12 -0
- data/spec/unit/util/monkey_patches_spec.rb +6 -0
- data/spec/unit/util/network_device/config_spec.rb +26 -64
- data/spec/unit/util/pidlock_spec.rb +4 -1
- data/spec/unit/util/tagging_spec.rb +5 -9
- data/spec/unit/util/warnings_spec.rb +1 -1
- data/spec/unit/util/watched_file_spec.rb +52 -0
- data/spec/unit/util/watcher/periodic_watcher_spec.rb +52 -0
- data/spec/unit/util/watcher_spec.rb +56 -0
- data/spec/unit/util_spec.rb +16 -0
- metadata +2767 -2576
- data/ext/debian/puppet.manpages +0 -32
- data/ext/osx/PackageInfo.plist +0 -36
- data/ext/osx/createpackage.sh +0 -187
- data/ext/redhat/rundir-perms.patch +0 -28
- data/lib/puppet/external/base64.rb +0 -19
- data/lib/puppet/util/graph.rb +0 -27
- data/lib/puppet/util/loadedfile.rb +0 -61
- data/lib/puppet/util/log_paths.rb +0 -22
- data/lib/puppet/util/subclass_loader.rb +0 -78
- data/spec/monkey_patches/publicize_methods.rb +0 -11
- data/spec/unit/util/loadedfile_spec.rb +0 -71
@@ -14,8 +14,32 @@ module Puppet::Network::HTTP::Handler
|
|
14
14
|
include Puppet::Network::Authorization
|
15
15
|
include Puppet::Network::Authentication
|
16
16
|
|
17
|
-
|
17
|
+
# These shouldn't be allowed to be set by clients
|
18
|
+
# in the query string, for security reasons.
|
19
|
+
DISALLOWED_KEYS = ["node", "ip"]
|
20
|
+
|
21
|
+
class HTTPError < Exception
|
22
|
+
attr_reader :status
|
23
|
+
|
24
|
+
def initialize(message, status)
|
25
|
+
super(message)
|
26
|
+
@status = status
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
class HTTPNotAcceptableError < HTTPError
|
31
|
+
def initialize(message)
|
32
|
+
super("Not Acceptable: " + message, 406)
|
33
|
+
end
|
34
|
+
end
|
18
35
|
|
36
|
+
class HTTPNotFoundError < HTTPError
|
37
|
+
def initialize(message)
|
38
|
+
super("Not Found: " + message, 404)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
attr_reader :server, :handler
|
19
43
|
|
20
44
|
# Retrieve all headers from the http request, as a hash with the header names
|
21
45
|
# (lower-cased) as the keys
|
@@ -33,29 +57,12 @@ module Puppet::Network::HTTP::Handler
|
|
33
57
|
raise NotImplementedError
|
34
58
|
end
|
35
59
|
|
36
|
-
# Which format to use when serializing our response or interpreting the request.
|
37
|
-
# IF the client provided a Content-Type use this, otherwise use the Accept header
|
38
|
-
# and just pick the first value.
|
39
|
-
def format_to_use(request)
|
40
|
-
unless header = accept_header(request)
|
41
|
-
raise ArgumentError, "An Accept header must be provided to pick the right format"
|
42
|
-
end
|
43
|
-
|
44
|
-
format = nil
|
45
|
-
header.split(/,\s*/).each do |name|
|
46
|
-
next unless format = Puppet::Network::FormatHandler.format(name)
|
47
|
-
next unless format.suitable?
|
48
|
-
return format
|
49
|
-
end
|
50
|
-
|
51
|
-
raise "No specified acceptable formats (#{header}) are functional on this machine"
|
52
|
-
end
|
53
|
-
|
54
60
|
def request_format(request)
|
55
61
|
if header = content_type_header(request)
|
56
62
|
header.gsub!(/\s*;.*$/,'') # strip any charset
|
57
63
|
format = Puppet::Network::FormatHandler.mime(header)
|
58
64
|
raise "Client sent a mime-type (#{header}) that doesn't correspond to a format we support" if format.nil?
|
65
|
+
report_if_deprecated(format)
|
59
66
|
return format.name.to_s if format.suitable?
|
60
67
|
end
|
61
68
|
|
@@ -89,6 +96,8 @@ module Puppet::Network::HTTP::Handler
|
|
89
96
|
end
|
90
97
|
rescue SystemExit,NoMemoryError
|
91
98
|
raise
|
99
|
+
rescue HTTPError => e
|
100
|
+
return do_exception(response, e.message, e.status)
|
92
101
|
rescue Exception => e
|
93
102
|
return do_exception(response, e)
|
94
103
|
ensure
|
@@ -111,9 +120,13 @@ module Puppet::Network::HTTP::Handler
|
|
111
120
|
# for authorization issues
|
112
121
|
status = 403 if status == 400
|
113
122
|
end
|
123
|
+
|
114
124
|
if exception.is_a?(Exception)
|
115
125
|
Puppet.log_exception(exception)
|
126
|
+
else
|
127
|
+
Puppet.notice(exception.to_s)
|
116
128
|
end
|
129
|
+
|
117
130
|
set_content_type(response, "text/plain")
|
118
131
|
set_response(response, exception.to_s, status)
|
119
132
|
end
|
@@ -125,21 +138,18 @@ module Puppet::Network::HTTP::Handler
|
|
125
138
|
|
126
139
|
# Execute our find.
|
127
140
|
def do_find(indirection_name, key, params, request, response)
|
128
|
-
|
129
|
-
|
130
|
-
|
141
|
+
model_class = model(indirection_name)
|
142
|
+
unless result = model_class.indirection.find(key, params)
|
143
|
+
raise HTTPNotFoundError, "Could not find #{indirection_name} #{key}"
|
131
144
|
end
|
132
145
|
|
133
|
-
|
134
|
-
# and it needs to be used for both the rendering and as
|
135
|
-
# the content type.
|
136
|
-
format = format_to_use(request)
|
146
|
+
format = accepted_response_formatter_for(model_class, request)
|
137
147
|
set_content_type(response, format)
|
138
148
|
|
139
149
|
rendered_result = result
|
140
150
|
if result.respond_to?(:render)
|
141
151
|
Puppet::Util::Profiler.profile("Rendered result in #{format}") do
|
142
|
-
|
152
|
+
rendered_result = result.render(format)
|
143
153
|
end
|
144
154
|
end
|
145
155
|
|
@@ -151,8 +161,7 @@ module Puppet::Network::HTTP::Handler
|
|
151
161
|
# Execute our head.
|
152
162
|
def do_head(indirection_name, key, params, request, response)
|
153
163
|
unless self.model(indirection_name).indirection.head(key, params)
|
154
|
-
|
155
|
-
return do_exception(response, "Could not find #{indirection_name} #{key}", 404)
|
164
|
+
raise HTTPNotFoundError, "Could not find #{indirection_name} #{key}"
|
156
165
|
end
|
157
166
|
|
158
167
|
# No need to set a response because no response is expected from a
|
@@ -165,10 +174,10 @@ module Puppet::Network::HTTP::Handler
|
|
165
174
|
result = model.indirection.search(key, params)
|
166
175
|
|
167
176
|
if result.nil?
|
168
|
-
|
177
|
+
raise HTTPNotFoundError, "Could not find instances in #{indirection_name} with '#{key}'"
|
169
178
|
end
|
170
179
|
|
171
|
-
format =
|
180
|
+
format = accepted_response_formatter_for(model, request)
|
172
181
|
set_content_type(response, format)
|
173
182
|
|
174
183
|
set_response(response, model.render_multiple(format, result))
|
@@ -176,20 +185,25 @@ module Puppet::Network::HTTP::Handler
|
|
176
185
|
|
177
186
|
# Execute our destroy.
|
178
187
|
def do_destroy(indirection_name, key, params, request, response)
|
179
|
-
|
188
|
+
model_class = model(indirection_name)
|
189
|
+
formatter = accepted_response_formatter_or_yaml_for(model_class, request)
|
180
190
|
|
181
|
-
|
191
|
+
result = model_class.indirection.destroy(key, params)
|
192
|
+
|
193
|
+
set_content_type(response, formatter)
|
194
|
+
set_response(response, formatter.render(result))
|
182
195
|
end
|
183
196
|
|
184
197
|
# Execute our save.
|
185
198
|
def do_save(indirection_name, key, params, request, response)
|
186
|
-
|
187
|
-
|
199
|
+
model_class = model(indirection_name)
|
200
|
+
formatter = accepted_response_formatter_or_yaml_for(model_class, request)
|
201
|
+
sent_object = read_body_into_model(model_class, request)
|
188
202
|
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
203
|
+
result = model_class.indirection.save(sent_object, key)
|
204
|
+
|
205
|
+
set_content_type(response, formatter)
|
206
|
+
set_response(response, formatter.render(result))
|
193
207
|
end
|
194
208
|
|
195
209
|
# resolve node name from peer's ip address
|
@@ -205,9 +219,41 @@ module Puppet::Network::HTTP::Handler
|
|
205
219
|
|
206
220
|
private
|
207
221
|
|
208
|
-
def
|
209
|
-
|
210
|
-
|
222
|
+
def report_if_deprecated(format)
|
223
|
+
if format.name == :yaml || format.name == :b64_zlib_yaml
|
224
|
+
Puppet.deprecation_warning("YAML in network requests is deprecated and will be removed in a future version. See http://links.puppetlabs.com/deprecate_yaml_on_network")
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
def accepted_response_formatter_for(model_class, request)
|
229
|
+
accepted_formats = accept_header(request) or raise HTTPNotAcceptableError, "Missing required Accept header"
|
230
|
+
response_formatter_for(model_class, request, accepted_formats)
|
231
|
+
end
|
232
|
+
|
233
|
+
def accepted_response_formatter_or_yaml_for(model_class, request)
|
234
|
+
accepted_formats = accept_header(request) || "yaml"
|
235
|
+
response_formatter_for(model_class, request, accepted_formats)
|
236
|
+
end
|
237
|
+
|
238
|
+
def response_formatter_for(model_class, request, accepted_formats)
|
239
|
+
formatter = Puppet::Network::FormatHandler.most_suitable_format_for(
|
240
|
+
accepted_formats.split(/\s*,\s*/),
|
241
|
+
model_class.supported_formats)
|
242
|
+
|
243
|
+
if formatter.nil?
|
244
|
+
raise HTTPNotAcceptableError, "No supported formats are acceptable (Accept: #{accepted_formats})"
|
245
|
+
end
|
246
|
+
|
247
|
+
report_if_deprecated(formatter)
|
248
|
+
formatter
|
249
|
+
end
|
250
|
+
|
251
|
+
def read_body_into_model(model_class, request)
|
252
|
+
data = body(request).to_s
|
253
|
+
raise ArgumentError, "No data to save" if !data or data.empty?
|
254
|
+
|
255
|
+
format = request_format(request)
|
256
|
+
model_class.convert_from(format, data)
|
211
257
|
end
|
212
258
|
|
213
259
|
def get?(request)
|
@@ -253,30 +299,45 @@ module Puppet::Network::HTTP::Handler
|
|
253
299
|
end
|
254
300
|
|
255
301
|
def decode_params(params)
|
256
|
-
params.inject({}) do |result, ary|
|
302
|
+
params.select { |key, _| allowed_parameter?(key) }.inject({}) do |result, ary|
|
257
303
|
param, value = ary
|
258
|
-
|
259
|
-
|
260
|
-
param = param.to_sym
|
261
|
-
|
262
|
-
# These shouldn't be allowed to be set by clients
|
263
|
-
# in the query string, for security reasons.
|
264
|
-
next result if param == :node
|
265
|
-
next result if param == :ip
|
266
|
-
value = CGI.unescape(value)
|
267
|
-
if value =~ /^---/
|
268
|
-
value = YAML.load(value, :safe => true, :deserialize_symbols => true)
|
269
|
-
else
|
270
|
-
value = true if value == "true"
|
271
|
-
value = false if value == "false"
|
272
|
-
value = Integer(value) if value =~ /^\d+$/
|
273
|
-
value = value.to_f if value =~ /^\d+\.\d+$/
|
274
|
-
end
|
275
|
-
result[param] = value
|
304
|
+
result[param.to_sym] = parse_parameter_value(param, value)
|
276
305
|
result
|
277
306
|
end
|
278
307
|
end
|
279
308
|
|
309
|
+
def allowed_parameter?(name)
|
310
|
+
not (name.nil? || name.empty? || DISALLOWED_KEYS.include?(name))
|
311
|
+
end
|
312
|
+
|
313
|
+
def parse_parameter_value(param, value)
|
314
|
+
case value
|
315
|
+
when /^---/
|
316
|
+
Puppet.debug("Found YAML while processing request parameter #{param} (value: <#{value}>)")
|
317
|
+
Puppet.deprecation_warning("YAML in network requests is deprecated and will be removed in a future version. See http://links.puppetlabs.com/deprecate_yaml_on_network")
|
318
|
+
YAML.load(value, :safe => true, :deserialize_symbols => true)
|
319
|
+
when Array
|
320
|
+
value.collect { |v| parse_primitive_parameter_value(v) }
|
321
|
+
else
|
322
|
+
parse_primitive_parameter_value(value)
|
323
|
+
end
|
324
|
+
end
|
325
|
+
|
326
|
+
def parse_primitive_parameter_value(value)
|
327
|
+
case value
|
328
|
+
when "true"
|
329
|
+
true
|
330
|
+
when "false"
|
331
|
+
false
|
332
|
+
when /^\d+$/
|
333
|
+
Integer(value)
|
334
|
+
when /^\d+\.\d+$/
|
335
|
+
value.to_f
|
336
|
+
else
|
337
|
+
value
|
338
|
+
end
|
339
|
+
end
|
340
|
+
|
280
341
|
def configure_profiler(request_headers, request_params)
|
281
342
|
if (request_headers.has_key?(Puppet::Network::HTTP::HEADER_ENABLE_PROFILING.downcase) or Puppet[:profile])
|
282
343
|
Puppet::Util::Profiler.current = Puppet::Util::Profiler::WallClock.new(Puppet.method(:debug), request_params.object_id)
|
@@ -51,7 +51,7 @@ class Puppet::Network::HTTP::RackREST < Puppet::Network::HTTP::RackHttpHandler
|
|
51
51
|
# Retrieve all headers from the http request, as a map.
|
52
52
|
def headers(request)
|
53
53
|
request.env.select {|k,v| k.start_with? 'HTTP_'}.inject({}) do |m, (k,v)|
|
54
|
-
m[k.sub(/^HTTP_/, '').downcase] = v
|
54
|
+
m[k.sub(/^HTTP_/, '').gsub('_','-').downcase] = v
|
55
55
|
m
|
56
56
|
end
|
57
57
|
end
|
@@ -15,9 +15,15 @@ class Puppet::Network::HTTP::WEBrickREST < WEBrick::HTTPServlet::AbstractServlet
|
|
15
15
|
|
16
16
|
# Retrieve the request parameters, including authentication information.
|
17
17
|
def params(request)
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
params = request.query || {}
|
19
|
+
|
20
|
+
params = Hash[params.collect do |key, value|
|
21
|
+
all_values = value.list
|
22
|
+
[key, all_values.length == 1 ? value : all_values]
|
23
|
+
end]
|
24
|
+
|
25
|
+
params = decode_params(params)
|
26
|
+
params.merge(client_information(request))
|
21
27
|
end
|
22
28
|
|
23
29
|
# WEBrick uses a service method to respond to requests. Simply delegate to the handler response method.
|
@@ -12,8 +12,8 @@ module Puppet::Network::HttpPool
|
|
12
12
|
|
13
13
|
# Retrieve a cached http instance if caching is enabled, else return
|
14
14
|
# a new one.
|
15
|
-
def self.http_instance(host, port, use_ssl = true)
|
16
|
-
Puppet::Network::HTTP::Connection.new(host, port, use_ssl)
|
15
|
+
def self.http_instance(host, port, use_ssl = true, verify_peer = true)
|
16
|
+
Puppet::Network::HTTP::Connection.new(host, port, :use_ssl => use_ssl, :verify_peer => verify_peer)
|
17
17
|
end
|
18
18
|
|
19
19
|
end
|
@@ -18,6 +18,7 @@ module Puppet::Network::Resolver
|
|
18
18
|
when :ca then service = '_x-puppet-ca'
|
19
19
|
when :report then service = '_x-puppet-report'
|
20
20
|
when :file then service = '_x-puppet-fileserver'
|
21
|
+
else service = "_x-puppet-#{service_name.to_s}"
|
21
22
|
end
|
22
23
|
srv_record = "#{service}._tcp.#{domain}"
|
23
24
|
|
@@ -1,114 +1,38 @@
|
|
1
1
|
require 'puppet/network/http'
|
2
|
-
require 'puppet/util/pidlock'
|
3
2
|
require 'puppet/network/http/webrick'
|
4
3
|
|
4
|
+
#
|
5
|
+
# @api private
|
5
6
|
class Puppet::Network::Server
|
6
7
|
attr_reader :address, :port
|
7
8
|
|
8
|
-
|
9
|
-
# the code in Puppet::Daemon, but that it's not actually called anywhere.
|
10
|
-
|
11
|
-
# Put the daemon into the background.
|
12
|
-
def daemonize
|
13
|
-
if pid = fork
|
14
|
-
Process.detach(pid)
|
15
|
-
exit(0)
|
16
|
-
end
|
17
|
-
|
18
|
-
# Get rid of console logging
|
19
|
-
Puppet::Util::Log.close(:console)
|
20
|
-
|
21
|
-
Process.setsid
|
22
|
-
Dir.chdir("/")
|
23
|
-
end
|
24
|
-
|
25
|
-
def close_streams()
|
26
|
-
Puppet::Daemon.close_streams()
|
27
|
-
end
|
28
|
-
|
29
|
-
# Create a pidfile for our daemon, so we can be stopped and others
|
30
|
-
# don't try to start.
|
31
|
-
def create_pidfile
|
32
|
-
Puppet::Util.synchronize_on(Puppet.run_mode.name,Sync::EX) do
|
33
|
-
raise "Could not create PID file: #{pidfile}" unless Puppet::Util::Pidlock.new(pidfile).lock
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
# Remove the pid file for our daemon.
|
38
|
-
def remove_pidfile
|
39
|
-
Puppet::Util.synchronize_on(Puppet.run_mode.name,Sync::EX) do
|
40
|
-
Puppet::Util::Pidlock.new(pidfile).unlock
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
# Provide the path to our pidfile.
|
45
|
-
def pidfile
|
46
|
-
Puppet[:pidfile]
|
47
|
-
end
|
48
|
-
|
49
|
-
def initialize(address, port, handlers = nil)
|
9
|
+
def initialize(address, port)
|
50
10
|
@port = port
|
51
11
|
@address = address
|
52
12
|
@http_server = Puppet::Network::HTTP::WEBrick.new
|
53
13
|
|
54
14
|
@listening = false
|
55
|
-
@routes = {}
|
56
|
-
self.register(handlers) if handlers
|
57
15
|
|
58
16
|
# Make sure we have all of the directories we need to function.
|
59
17
|
Puppet.settings.use(:main, :ssl, :application)
|
60
18
|
end
|
61
19
|
|
62
|
-
# Register handlers for REST networking, based on the Indirector.
|
63
|
-
def register(*indirections)
|
64
|
-
raise ArgumentError, "Indirection names are required." if indirections.empty?
|
65
|
-
indirections.flatten.each do |name|
|
66
|
-
Puppet::Indirector::Indirection.model(name) || raise(ArgumentError, "Cannot locate indirection '#{name}'.")
|
67
|
-
@routes[name.to_sym] = true
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
# Unregister Indirector handlers.
|
72
|
-
def unregister(*indirections)
|
73
|
-
raise "Cannot unregister indirections while server is listening." if listening?
|
74
|
-
indirections = @routes.keys if indirections.empty?
|
75
|
-
|
76
|
-
indirections.flatten.each do |i|
|
77
|
-
raise(ArgumentError, "Indirection [#{i}] is unknown.") unless @routes[i.to_sym]
|
78
|
-
end
|
79
|
-
|
80
|
-
indirections.flatten.each do |i|
|
81
|
-
@routes.delete(i.to_sym)
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
20
|
def listening?
|
86
21
|
@listening
|
87
22
|
end
|
88
23
|
|
89
|
-
def
|
24
|
+
def start
|
90
25
|
raise "Cannot listen -- already listening." if listening?
|
91
26
|
@listening = true
|
92
27
|
@http_server.listen(address, port)
|
93
28
|
end
|
94
29
|
|
95
|
-
def
|
30
|
+
def stop
|
96
31
|
raise "Cannot unlisten -- not currently listening." unless listening?
|
97
32
|
@http_server.unlisten
|
98
33
|
@listening = false
|
99
34
|
end
|
100
35
|
|
101
|
-
def start
|
102
|
-
create_pidfile
|
103
|
-
close_streams if Puppet[:daemonize]
|
104
|
-
listen
|
105
|
-
end
|
106
|
-
|
107
|
-
def stop
|
108
|
-
unlisten
|
109
|
-
remove_pidfile
|
110
|
-
end
|
111
|
-
|
112
36
|
def wait_for_shutdown
|
113
37
|
@http_server.wait_for_shutdown
|
114
38
|
end
|
@@ -7,10 +7,61 @@ require 'puppet/parser/parser_factory'
|
|
7
7
|
class Puppet::Node
|
8
8
|
end
|
9
9
|
|
10
|
-
#
|
11
|
-
#
|
10
|
+
# Puppet::Node::Environment acts as a container for all configuration
|
11
|
+
# that is expected to vary between environments.
|
12
|
+
#
|
13
|
+
# ## Thread local variables
|
14
|
+
#
|
15
|
+
# The Puppet::Node::Environment uses a number of `Thread.current` variables.
|
16
|
+
# Since all web servers that Puppet runs on are single threaded these
|
17
|
+
# variables are effectively global.
|
18
|
+
#
|
19
|
+
# ### `Thread.current[:environment]`
|
20
|
+
#
|
21
|
+
# The 'environment' thread variable represents the current environment that's
|
22
|
+
# being used in the compiler.
|
23
|
+
#
|
24
|
+
# ### `Thread.current[:known_resource_types]`
|
25
|
+
#
|
26
|
+
# The 'known_resource_types' thread variable represents a singleton instance
|
27
|
+
# of the Puppet::Resource::TypeCollection class. The variable is discarded
|
28
|
+
# and regenerated if it is accessed by an environment that doesn't match the
|
29
|
+
# environment of the 'known_resource_types'
|
30
|
+
#
|
31
|
+
# This behavior of discarding the known_resource_types every time the
|
32
|
+
# environment changes is not ideal. In the best case this can cause valid data
|
33
|
+
# to be discarded and reloaded. If Puppet is being used with numerous
|
34
|
+
# environments then this penalty will be repeatedly incurred.
|
35
|
+
#
|
36
|
+
# In the worst case (#15106) demonstrates that if a different environment is
|
37
|
+
# accessed during catalog compilation, for whatever reason, the
|
38
|
+
# known_resource_types can be discarded which loses information that cannot
|
39
|
+
# be recovered and can cause a catalog compilation to completely fail.
|
40
|
+
#
|
41
|
+
# ## The root environment
|
42
|
+
#
|
43
|
+
# In addition to normal environments that are defined by the user,there is a
|
44
|
+
# special 'root' environment. It is defined as an instance variable on the
|
45
|
+
# Puppet::Node::Environment metaclass. The environment name is `*root*` and can
|
46
|
+
# be accessed by calling {Puppet::Node::Environment.root}.
|
47
|
+
#
|
48
|
+
# The primary purpose of the root environment is to contain parser functions
|
49
|
+
# that are not bound to a specific environment. The main case for this is for
|
50
|
+
# logging functions. Logging functions are attached to the 'root' environment
|
51
|
+
# when {Puppet::Parser::Functions.reset} is called.
|
52
|
+
#
|
53
|
+
# The root environment is also used as a fallback environment when the
|
54
|
+
# current environment has been requested by {Puppet::Node::Environment.current}
|
55
|
+
# requested and no environment was set by {Puppet::Node::Environment.current=}
|
12
56
|
class Puppet::Node::Environment
|
57
|
+
|
58
|
+
# This defines a mixin for classes that have an environment. It implements
|
59
|
+
# `environment` and `environment=` that respects the semantics of the
|
60
|
+
# Puppet::Node::Environment class
|
61
|
+
#
|
62
|
+
# @api public
|
13
63
|
module Helper
|
64
|
+
|
14
65
|
def environment
|
15
66
|
Puppet::Node::Environment.new(@environment)
|
16
67
|
end
|
@@ -26,9 +77,34 @@ class Puppet::Node::Environment
|
|
26
77
|
|
27
78
|
include Puppet::Util::Cacher
|
28
79
|
|
80
|
+
# @!attribute seen
|
81
|
+
# @scope class
|
82
|
+
# @api private
|
83
|
+
# @return [Hash<Symbol, Puppet::Node::Environment>] All memoized environments
|
29
84
|
@seen = {}
|
30
85
|
|
31
|
-
#
|
86
|
+
# Create a new environment with the given name, or return an existing one
|
87
|
+
#
|
88
|
+
# The environment class memoizes instances so that attempts to instantiate an
|
89
|
+
# environment with the same name with an existing environment will return the
|
90
|
+
# existing environment.
|
91
|
+
#
|
92
|
+
# @overload self.new(environment)
|
93
|
+
# @param environment [Puppet::Node::Environment]
|
94
|
+
# @return [Puppet::Node::Environment] the environment passed as the param,
|
95
|
+
# this is implemented so that a calling class can use strings or
|
96
|
+
# environments interchangeably.
|
97
|
+
#
|
98
|
+
# @overload self.new(string)
|
99
|
+
# @param string [String, Symbol]
|
100
|
+
# @return [Puppet::Node::Environment] An existing environment if it exists,
|
101
|
+
# else a new environment with that name
|
102
|
+
#
|
103
|
+
# @overload self.new()
|
104
|
+
# @return [Puppet::Node::Environment] The environment as set by
|
105
|
+
# Puppet.settings[:environment]
|
106
|
+
#
|
107
|
+
# @api public
|
32
108
|
def self.new(name = nil)
|
33
109
|
return name if name.is_a?(self)
|
34
110
|
name ||= Puppet.settings.value(:environment)
|
@@ -44,35 +120,92 @@ class Puppet::Node::Environment
|
|
44
120
|
@seen[symbol] = obj
|
45
121
|
end
|
46
122
|
|
123
|
+
# Retrieve the environment for the current thread
|
124
|
+
#
|
125
|
+
# @note This should only used when a catalog is being compiled.
|
126
|
+
#
|
127
|
+
# @api private
|
128
|
+
#
|
129
|
+
# @return [Puppet::Node::Environment] the currently set environment if one
|
130
|
+
# has been explicitly set, else it will return the '*root*' environment
|
47
131
|
def self.current
|
48
132
|
Thread.current[:environment] || root
|
49
133
|
end
|
50
134
|
|
135
|
+
# Set the environment for the current thread
|
136
|
+
#
|
137
|
+
# @note This should only set when a catalog is being compiled. Under normal
|
138
|
+
# This value is initially set in {Puppet::Parser::Compiler#environment}
|
139
|
+
#
|
140
|
+
# @note Setting this affects global state during catalog compilation, and
|
141
|
+
# changing the current environment during compilation can cause unexpected
|
142
|
+
# and generally very bad behaviors.
|
143
|
+
#
|
144
|
+
# @api private
|
145
|
+
#
|
146
|
+
# @param env [Puppet::Node::Environment]
|
51
147
|
def self.current=(env)
|
52
148
|
Thread.current[:environment] = new(env)
|
53
149
|
end
|
54
150
|
|
151
|
+
|
152
|
+
# @return [Puppet::Node::Environment] The `*root*` environment.
|
153
|
+
#
|
154
|
+
# This is only used for handling functions that are not attached to a
|
155
|
+
# specific environment.
|
156
|
+
#
|
157
|
+
# @api private
|
55
158
|
def self.root
|
56
159
|
@root
|
57
160
|
end
|
58
161
|
|
162
|
+
# Clear all memoized environments and the 'current' environment
|
163
|
+
#
|
164
|
+
# @api private
|
59
165
|
def self.clear
|
60
166
|
@seen.clear
|
61
167
|
Thread.current[:environment] = nil
|
62
168
|
end
|
63
169
|
|
170
|
+
# @!attribute [r] name
|
171
|
+
# @api public
|
172
|
+
# @return [Symbol] the human readable environment name that serves as the
|
173
|
+
# environment identifier
|
64
174
|
attr_reader :name
|
65
175
|
|
66
|
-
# Return an environment-specific setting.
|
176
|
+
# Return an environment-specific Puppet setting.
|
177
|
+
#
|
178
|
+
# @api public
|
179
|
+
#
|
180
|
+
# @param param [String, Symbol] The environment setting to look up
|
181
|
+
# @return [Object] The resolved setting value
|
67
182
|
def [](param)
|
68
183
|
Puppet.settings.value(param, self.name)
|
69
184
|
end
|
70
185
|
|
186
|
+
# Instantiate a new environment
|
187
|
+
#
|
188
|
+
# @note {Puppet::Node::Environment.new} is overridden to return memoized
|
189
|
+
# objects, so this will not be invoked with the normal Ruby initialization
|
190
|
+
# semantics.
|
191
|
+
#
|
192
|
+
# @param name [Symbol] The environment name
|
71
193
|
def initialize(name)
|
72
194
|
@name = name
|
73
195
|
extend MonitorMixin
|
74
196
|
end
|
75
197
|
|
198
|
+
# The current global TypeCollection
|
199
|
+
#
|
200
|
+
# @note The environment is loosely coupled with the {Puppet::Resource::TypeCollection}
|
201
|
+
# class. While there is a 1:1 relationship between an environment and a
|
202
|
+
# TypeCollection instance, there is only one TypeCollection instance available
|
203
|
+
# at any given time. It is stored in the Thread.current collection as
|
204
|
+
# 'known_resource_types'. 'known_resource_types' is accessed as an instance
|
205
|
+
# method, but is global to all environment variables.
|
206
|
+
#
|
207
|
+
# @api public
|
208
|
+
# @return [Puppet::Resource::TypeCollection] The current global TypeCollection
|
76
209
|
def known_resource_types
|
77
210
|
# This makes use of short circuit evaluation to get the right thread-safe
|
78
211
|
# per environment semantics with an efficient most common cases; we almost
|
@@ -89,7 +222,8 @@ class Puppet::Node::Environment
|
|
89
222
|
}
|
90
223
|
end
|
91
224
|
|
92
|
-
# Yields each modules' plugin directory
|
225
|
+
# Yields each modules' plugin directory if the plugin directory (modulename/lib)
|
226
|
+
# is present on the filesystem.
|
93
227
|
#
|
94
228
|
# @yield [String] Yields the plugin directory from each module to the block.
|
95
229
|
# @api public
|
@@ -100,10 +234,22 @@ class Puppet::Node::Environment
|
|
100
234
|
end
|
101
235
|
end
|
102
236
|
|
237
|
+
# Locate a module instance by the module name alone.
|
238
|
+
#
|
239
|
+
# @api public
|
240
|
+
#
|
241
|
+
# @param name [String] The module name
|
242
|
+
# @return [Puppet::Module, nil] The module if found, else nil
|
103
243
|
def module(name)
|
104
244
|
modules.find {|mod| mod.name == name}
|
105
245
|
end
|
106
246
|
|
247
|
+
# Locate a module instance by the full forge name (EG authorname/module)
|
248
|
+
#
|
249
|
+
# @api public
|
250
|
+
#
|
251
|
+
# @param forge_name [String] The module name
|
252
|
+
# @return [Puppet::Module, nil] The module if found, else nil
|
107
253
|
def module_by_forge_name(forge_name)
|
108
254
|
author, modname = forge_name.split('/')
|
109
255
|
found_mod = self.module(modname)
|
@@ -112,17 +258,34 @@ class Puppet::Node::Environment
|
|
112
258
|
nil
|
113
259
|
end
|
114
260
|
|
115
|
-
#
|
116
|
-
# all
|
261
|
+
# @!attribute [r] modulepath
|
262
|
+
# Return all existent directories in the modulepath for this environment
|
263
|
+
# @note This value is cached so that the filesystem doesn't have to be
|
264
|
+
# re-enumerated every time this method is invoked, since that
|
265
|
+
# enumeration could be a costly operation and this method is called
|
266
|
+
# frequently. The cache expiry is determined by `Puppet[:filetimeout]`.
|
267
|
+
# @see Puppet::Util::Cacher.cached_attr
|
268
|
+
# @api public
|
269
|
+
# @return [Array<String>] All directories present in the modulepath
|
117
270
|
cached_attr(:modulepath, Puppet[:filetimeout]) do
|
118
271
|
dirs = self[:modulepath].split(File::PATH_SEPARATOR)
|
119
272
|
dirs = ENV["PUPPETLIB"].split(File::PATH_SEPARATOR) + dirs if ENV["PUPPETLIB"]
|
120
273
|
validate_dirs(dirs)
|
121
274
|
end
|
122
275
|
|
123
|
-
#
|
124
|
-
# in the
|
125
|
-
#
|
276
|
+
# @!attribute [r] modules
|
277
|
+
# Return all modules for this environment in the order they appear in the
|
278
|
+
# modulepath.
|
279
|
+
# @note If multiple modules with the same name are present they will
|
280
|
+
# both be added, but methods like {#module} and {#module_by_forge_name}
|
281
|
+
# will return the first matching entry in this list.
|
282
|
+
# @note This value is cached so that the filesystem doesn't have to be
|
283
|
+
# re-enumerated every time this method is invoked, since that
|
284
|
+
# enumeration could be a costly operation and this method is called
|
285
|
+
# frequently. The cache expiry is determined by `Puppet[:filetimeout]`.
|
286
|
+
# @see Puppet::Util::Cacher.cached_attr
|
287
|
+
# @api public
|
288
|
+
# @return [Array<Puppet::Module>] All modules for this environment
|
126
289
|
cached_attr(:modules, Puppet[:filetimeout]) do
|
127
290
|
module_references = []
|
128
291
|
seen_modules = {}
|
@@ -140,12 +303,18 @@ class Puppet::Node::Environment
|
|
140
303
|
module_references.collect do |reference|
|
141
304
|
begin
|
142
305
|
Puppet::Module.new(reference[:name], reference[:path], self)
|
143
|
-
rescue Puppet::Module::Error
|
306
|
+
rescue Puppet::Module::Error
|
144
307
|
nil
|
145
308
|
end
|
146
309
|
end.compact
|
147
310
|
end
|
148
311
|
|
312
|
+
# Generate a warning if the given directory in a module path entry is named `lib`.
|
313
|
+
#
|
314
|
+
# @api private
|
315
|
+
#
|
316
|
+
# @param path [String] The module directory containing the given directory
|
317
|
+
# @param name [String] The directory name
|
149
318
|
def warn_about_mistaken_path(path, name)
|
150
319
|
if name == "lib"
|
151
320
|
Puppet.debug("Warning: Found directory named 'lib' in module path ('#{path}/lib'); unless " +
|
@@ -155,6 +324,14 @@ class Puppet::Node::Environment
|
|
155
324
|
end
|
156
325
|
|
157
326
|
# Modules broken out by directory in the modulepath
|
327
|
+
#
|
328
|
+
# @note This method _changes_ the current working directory while enumerating
|
329
|
+
# the modules. This seems rather dangerous.
|
330
|
+
#
|
331
|
+
# @api public
|
332
|
+
#
|
333
|
+
# @return [Hash<String, Array<Puppet::Module>>] A hash whose keys are file
|
334
|
+
# paths, and whose values is an array of Puppet Modules for that path
|
158
335
|
def modules_by_path
|
159
336
|
modules_by_path = {}
|
160
337
|
modulepath.each do |path|
|
@@ -170,6 +347,33 @@ class Puppet::Node::Environment
|
|
170
347
|
modules_by_path
|
171
348
|
end
|
172
349
|
|
350
|
+
# All module requirements for all modules in the environment modulepath
|
351
|
+
#
|
352
|
+
# @api public
|
353
|
+
#
|
354
|
+
# @comment This has nothing to do with an environment. It seems like it was
|
355
|
+
# stuffed into the first convenient class that vaguely involved modules.
|
356
|
+
#
|
357
|
+
# @example
|
358
|
+
# environment.module_requirements
|
359
|
+
# # => {
|
360
|
+
# # 'username/amodule' => [
|
361
|
+
# # {
|
362
|
+
# # 'name' => 'username/moduledep',
|
363
|
+
# # 'version' => '1.2.3',
|
364
|
+
# # 'version_requirement' => '>= 1.0.0',
|
365
|
+
# # },
|
366
|
+
# # {
|
367
|
+
# # 'name' => 'username/anotherdep',
|
368
|
+
# # 'version' => '4.5.6',
|
369
|
+
# # 'version_requirement' => '>= 3.0.0',
|
370
|
+
# # }
|
371
|
+
# # ]
|
372
|
+
# # }
|
373
|
+
# #
|
374
|
+
#
|
375
|
+
# @return [Hash<String, Array<Hash<String, String>>>] See the method example
|
376
|
+
# for an explanation of the return value.
|
173
377
|
def module_requirements
|
174
378
|
deps = {}
|
175
379
|
modules.each do |mod|
|
@@ -191,21 +395,40 @@ class Puppet::Node::Environment
|
|
191
395
|
deps
|
192
396
|
end
|
193
397
|
|
398
|
+
# @return [String] The stringified value of the `name` instance variable
|
399
|
+
# @api public
|
194
400
|
def to_s
|
195
401
|
name.to_s
|
196
402
|
end
|
197
403
|
|
404
|
+
# @return [Symbol] The `name` value, cast to a string, then cast to a symbol.
|
405
|
+
#
|
406
|
+
# @api public
|
407
|
+
#
|
408
|
+
# @note the `name` instance variable is a Symbol, but this casts the value
|
409
|
+
# to a String and then converts it back into a Symbol which will needlessly
|
410
|
+
# create an object that needs to be garbage collected
|
198
411
|
def to_sym
|
199
412
|
to_s.to_sym
|
200
413
|
end
|
201
414
|
|
415
|
+
# Return only the environment name when serializing.
|
416
|
+
#
|
202
417
|
# The only thing we care about when serializing an environment is its
|
203
418
|
# identity; everything else is ephemeral and should not be stored or
|
204
419
|
# transmitted.
|
420
|
+
#
|
421
|
+
# @api public
|
205
422
|
def to_zaml(z)
|
206
423
|
self.to_s.to_zaml(z)
|
207
424
|
end
|
208
425
|
|
426
|
+
# Validate a list of file paths and return the paths that are directories on the filesystem
|
427
|
+
#
|
428
|
+
# @api private
|
429
|
+
#
|
430
|
+
# @param dirs [Array<String>] The file paths to validate
|
431
|
+
# @return [Array<String>] All file paths that exist and are directories
|
209
432
|
def validate_dirs(dirs)
|
210
433
|
dirs.collect do |dir|
|
211
434
|
File.expand_path(dir)
|
@@ -216,6 +439,22 @@ class Puppet::Node::Environment
|
|
216
439
|
|
217
440
|
private
|
218
441
|
|
442
|
+
# Reparse the manifests for the given environment
|
443
|
+
#
|
444
|
+
# There are two sources that can be used for the initial parse:
|
445
|
+
#
|
446
|
+
# 1. The value of `Puppet.settings[:code]`: Puppet can take a string from
|
447
|
+
# its settings and parse that as a manifest. This is used by various
|
448
|
+
# Puppet applications to read in a manifest and pass it to the
|
449
|
+
# environment as a side effect. This is attempted first.
|
450
|
+
# 2. The contents of `Puppet.settings[:manifest]`: Puppet will try to load
|
451
|
+
# the environment manifest. By default this is `$manifestdir/site.pp`
|
452
|
+
#
|
453
|
+
# @note This method will return an empty hostclass if
|
454
|
+
# `Puppet.settings[:ignoreimport]` is set to true.
|
455
|
+
#
|
456
|
+
# @return [Puppet::Parser::AST::Hostclass] The AST hostclass object
|
457
|
+
# representing the 'main' hostclass
|
219
458
|
def perform_initial_import
|
220
459
|
return empty_parse_result if Puppet.settings[:ignoreimport]
|
221
460
|
# parser = Puppet::Parser::Parser.new(self)
|
@@ -236,9 +475,13 @@ class Puppet::Node::Environment
|
|
236
475
|
raise error
|
237
476
|
end
|
238
477
|
|
478
|
+
# Return an empty toplevel hostclass to indicate that no file was loaded
|
479
|
+
#
|
480
|
+
# This is used as the return value of {#perform_initial_import} when
|
481
|
+
# `Puppet.settings[:ignoreimport]` is true.
|
482
|
+
#
|
483
|
+
# @return [Puppet::Parser::AST::Hostclass]
|
239
484
|
def empty_parse_result
|
240
|
-
# Return an empty toplevel hostclass to use as the result of
|
241
|
-
# perform_initial_import when no file was actually loaded.
|
242
485
|
return Puppet::Parser::AST::Hostclass.new('')
|
243
486
|
end
|
244
487
|
|