puppet 4.2.0 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CONTRIBUTING.md +1 -1
- data/Gemfile +5 -7
- data/README.md +1 -1
- data/Rakefile +20 -0
- data/ext/debian/puppet.init +0 -1
- data/ext/debian/puppet.logrotate +14 -5
- data/ext/osx/puppet.plist +2 -4
- data/ext/project_data.yaml +1 -1
- data/ext/redhat/client.init +65 -12
- data/ext/redhat/logrotate +15 -3
- data/ext/redhat/puppet.spec.erb +5 -1
- data/ext/redhat/server.init +1 -1
- data/ext/solaris/smf/puppet +44 -0
- data/ext/solaris/smf/puppet.xml +44 -0
- data/ext/suse/client.init +27 -27
- data/ext/suse/server.init +2 -2
- data/ext/systemd/puppet.service +1 -0
- data/install.rb +21 -39
- data/lib/hiera/puppet_function.rb +5 -5
- data/lib/puppet/agent/locker.rb +11 -2
- data/lib/puppet/agent.rb +4 -4
- data/lib/puppet/application/agent.rb +28 -14
- data/lib/puppet/application/apply.rb +17 -4
- data/lib/puppet/application/cert.rb +16 -0
- data/lib/puppet/application/filebucket.rb +78 -4
- data/lib/puppet/application/lookup.rb +356 -0
- data/lib/puppet/application/master.rb +5 -1
- data/lib/puppet/configurer.rb +9 -5
- data/lib/puppet/context/trusted_information.rb +21 -1
- data/lib/puppet/context.rb +16 -1
- data/lib/puppet/daemon.rb +17 -13
- data/lib/puppet/data_binding.rb +4 -2
- data/lib/puppet/data_providers/data_adapter.rb +7 -68
- data/lib/puppet/data_providers/data_function_support.rb +5 -26
- data/lib/puppet/data_providers/function_env_data_provider.rb +0 -10
- data/lib/puppet/data_providers/function_module_data_provider.rb +0 -22
- data/lib/puppet/data_providers/hiera_config.rb +106 -0
- data/lib/puppet/data_providers/hiera_env_data_provider.rb +18 -0
- data/lib/puppet/data_providers/hiera_interpolate.rb +97 -0
- data/lib/puppet/data_providers/hiera_module_data_provider.rb +23 -0
- data/lib/puppet/data_providers/hiera_support.rb +37 -0
- data/lib/puppet/data_providers/json_data_provider_factory.rb +31 -0
- data/lib/puppet/data_providers/lookup_adapter.rb +200 -0
- data/lib/puppet/data_providers/yaml_data_provider_factory.rb +32 -0
- data/lib/puppet/data_providers.rb +12 -13
- data/lib/puppet/defaults.rb +14 -3
- data/lib/puppet/environments.rb +94 -6
- data/lib/puppet/error.rb +4 -0
- data/lib/puppet/face/module/changes.rb +2 -1
- data/lib/puppet/feature/cfacter.rb +1 -0
- data/lib/puppet/file_bucket/dipper.rb +58 -2
- data/lib/puppet/file_system/windows.rb +3 -1
- data/lib/puppet/functions/assert_type.rb +48 -12
- data/lib/puppet/functions/defined.rb +79 -48
- data/lib/puppet/functions/each.rb +85 -27
- data/lib/puppet/functions/epp.rb +29 -37
- data/lib/puppet/functions/filter.rb +60 -25
- data/lib/puppet/functions/hiera.rb +76 -3
- data/lib/puppet/functions/hiera_array.rb +65 -3
- data/lib/puppet/functions/hiera_hash.rb +74 -2
- data/lib/puppet/functions/hiera_include.rb +77 -4
- data/lib/puppet/functions/inline_epp.rb +44 -71
- data/lib/puppet/functions/lookup.rb +19 -17
- data/lib/puppet/functions/map.rb +56 -21
- data/lib/puppet/functions/match.rb +29 -12
- data/lib/puppet/functions/reduce.rb +95 -58
- data/lib/puppet/functions/versioncmp.rb +36 -0
- data/lib/puppet/functions/with.rb +15 -7
- data/lib/puppet/functions.rb +2 -4
- data/lib/puppet/indirector/catalog/compiler.rb +3 -3
- data/lib/puppet/indirector/catalog/static_compiler.rb +46 -30
- data/lib/puppet/indirector/data_binding/none.rb +4 -1
- data/lib/puppet/indirector/file_bucket_file/file.rb +58 -1
- data/lib/puppet/indirector/hiera.rb +4 -0
- data/lib/puppet/indirector/indirection.rb +6 -1
- data/lib/puppet/indirector/json.rb +1 -1
- data/lib/puppet/indirector/msgpack.rb +1 -1
- data/lib/puppet/indirector/request.rb +7 -8
- data/lib/puppet/indirector/resource_type/parser.rb +5 -3
- data/lib/puppet/info_service/class_information_service.rb +111 -0
- data/lib/puppet/info_service.rb +7 -0
- data/lib/puppet/module_tool/applications/unpacker.rb +1 -1
- data/lib/puppet/module_tool/metadata.rb +32 -9
- data/lib/puppet/module_tool/skeleton/templates/generator/README.md.erb +42 -38
- data/lib/puppet/module_tool/skeleton/templates/generator/manifests/init.pp.erb +25 -18
- data/lib/puppet/network/authconfig.rb +21 -1
- data/lib/puppet/network/authorization.rb +8 -1
- data/lib/puppet/network/http/api/master/v3/environment.rb +59 -0
- data/lib/puppet/network/http/api/master/v3.rb +7 -1
- data/lib/puppet/node/environment.rb +9 -2
- data/lib/puppet/node.rb +11 -5
- data/lib/puppet/parser/ast/pops_bridge.rb +39 -1
- data/lib/puppet/parser/compiler/catalog_validator/env_relationship_validator.rb +64 -0
- data/lib/puppet/parser/compiler/catalog_validator/relationship_validator.rb +38 -0
- data/lib/puppet/parser/compiler/catalog_validator/site_validator.rb +20 -0
- data/lib/puppet/parser/compiler/catalog_validator.rb +33 -0
- data/lib/puppet/parser/compiler.rb +300 -12
- data/lib/puppet/parser/environment_compiler.rb +165 -0
- data/lib/puppet/parser/functions/assert_type.rb +46 -16
- data/lib/puppet/parser/functions/defined.rb +105 -68
- data/lib/puppet/parser/functions/each.rb +85 -27
- data/lib/puppet/parser/functions/epp.rb +29 -37
- data/lib/puppet/parser/functions/filter.rb +59 -23
- data/lib/puppet/parser/functions/hiera.rb +83 -27
- data/lib/puppet/parser/functions/hiera_array.rb +71 -28
- data/lib/puppet/parser/functions/hiera_hash.rb +81 -30
- data/lib/puppet/parser/functions/hiera_include.rb +81 -40
- data/lib/puppet/parser/functions/inline_epp.rb +35 -60
- data/lib/puppet/parser/functions/inline_template.rb +2 -2
- data/lib/puppet/parser/functions/map.rb +55 -20
- data/lib/puppet/parser/functions/match.rb +27 -12
- data/lib/puppet/parser/functions/reduce.rb +97 -60
- data/lib/puppet/parser/functions/with.rb +16 -8
- data/lib/puppet/parser/resource.rb +103 -21
- data/lib/puppet/parser.rb +3 -0
- data/lib/puppet/plugins/configuration.rb +3 -2
- data/lib/puppet/plugins/data_providers/data_provider.rb +283 -0
- data/lib/puppet/plugins/data_providers/registry.rb +84 -0
- data/lib/puppet/plugins/data_providers.rb +12 -60
- data/lib/puppet/pops/adapters.rb +12 -0
- data/lib/puppet/pops/binder/binder.rb +2 -2
- data/lib/puppet/pops/binder/bindings_checker.rb +1 -1
- data/lib/puppet/pops/binder/bindings_label_provider.rb +3 -1
- data/lib/puppet/pops/binder/bindings_loader.rb +6 -2
- data/lib/puppet/pops/binder/bindings_model_meta.rb +2 -2
- data/lib/puppet/pops/binder/config/binder_config.rb +1 -1
- data/lib/puppet/pops/binder/injector.rb +4 -4
- data/lib/puppet/pops/binder/key_factory.rb +3 -9
- data/lib/puppet/pops/binder/scheme_handler/module_scheme.rb +68 -9
- data/lib/puppet/pops/evaluator/access_operator.rb +27 -60
- data/lib/puppet/pops/evaluator/closure.rb +8 -8
- data/lib/puppet/pops/evaluator/collectors/abstract_collector.rb +1 -1
- data/lib/puppet/pops/evaluator/evaluator_impl.rb +10 -6
- data/lib/puppet/pops/evaluator/literal_evaluator.rb +87 -0
- data/lib/puppet/pops/evaluator/relationship_operator.rb +7 -1
- data/lib/puppet/pops/functions/dispatcher.rb +3 -3
- data/lib/puppet/pops/issues.rb +11 -3
- data/lib/puppet/pops/label_provider.rb +1 -1
- data/lib/puppet/pops/lookup/explainer.rb +402 -0
- data/lib/puppet/pops/lookup/invocation.rb +117 -0
- data/lib/puppet/pops/lookup.rb +25 -47
- data/lib/puppet/pops/merge_strategy.rb +73 -5
- data/lib/puppet/pops/model/factory.rb +38 -3
- data/lib/puppet/pops/model/model_label_provider.rb +10 -1
- data/lib/puppet/pops/model/model_meta.rb +19 -1
- data/lib/puppet/pops/model/model_tree_dumper.rb +18 -0
- data/lib/puppet/pops/parser/code_merger.rb +13 -1
- data/lib/puppet/pops/parser/egrammar.ra +65 -2
- data/lib/puppet/pops/parser/eparser.rb +1569 -1241
- data/lib/puppet/pops/parser/lexer2.rb +32 -1
- data/lib/puppet/pops/parser/locator.rb +1 -1
- data/lib/puppet/pops/parser/parser_support.rb +25 -13
- data/lib/puppet/pops/patterns.rb +3 -0
- data/lib/puppet/pops/types/enumeration.rb +1 -2
- data/lib/puppet/pops/types/type_asserter.rb +16 -15
- data/lib/puppet/pops/types/type_assertion_error.rb +1 -0
- data/lib/puppet/pops/types/type_calculator.rb +171 -1020
- data/lib/puppet/pops/types/type_factory.rb +87 -148
- data/lib/puppet/pops/types/type_mismatch_describer.rb +743 -0
- data/lib/puppet/pops/types/type_parser.rb +118 -129
- data/lib/puppet/pops/types/types.rb +1394 -255
- data/lib/puppet/pops/types/types_meta.rb +0 -234
- data/lib/puppet/pops/validation/checker4_0.rb +49 -1
- data/lib/puppet/pops/validation/validator_factory_4_0.rb +3 -1
- data/lib/puppet/pops/validation.rb +7 -2
- data/lib/puppet/pops.rb +19 -17
- data/lib/puppet/provider/augeas/augeas.rb +50 -0
- data/lib/puppet/provider/exec.rb +6 -1
- data/lib/puppet/provider/group/directoryservice.rb +10 -0
- data/lib/puppet/provider/package/dnf.rb +41 -0
- data/lib/puppet/provider/package/gem.rb +7 -2
- data/lib/puppet/provider/package/nim.rb +1 -1
- data/lib/puppet/provider/package/rpm.rb +1 -0
- data/lib/puppet/provider/package/windows/exe_package.rb +10 -8
- data/lib/puppet/provider/package/windows/msi_package.rb +4 -3
- data/lib/puppet/provider/package/windows/package.rb +9 -1
- data/lib/puppet/provider/package/yum.rb +20 -9
- data/lib/puppet/provider/service/bsd.rb +1 -1
- data/lib/puppet/provider/service/debian.rb +21 -0
- data/lib/puppet/provider/service/init.rb +6 -0
- data/lib/puppet/provider/service/launchd.rb +36 -7
- data/lib/puppet/provider/service/rcng.rb +51 -0
- data/lib/puppet/provider/service/redhat.rb +2 -1
- data/lib/puppet/provider/service/smf.rb +43 -2
- data/lib/puppet/provider/service/src.rb +27 -0
- data/lib/puppet/provider/service/systemd.rb +25 -5
- data/lib/puppet/provider/sshkey/parsed.rb +19 -9
- data/lib/puppet/provider/zone/solaris.rb +2 -2
- data/lib/puppet/reference/configuration.rb +10 -4
- data/lib/puppet/reference/report.rb +9 -12
- data/lib/puppet/reports.rb +5 -1
- data/lib/puppet/resource/capability_finder.rb +95 -0
- data/lib/puppet/resource/catalog.rb +47 -7
- data/lib/puppet/resource/status.rb +0 -2
- data/lib/puppet/resource/type.rb +238 -44
- data/lib/puppet/resource/type_collection.rb +60 -2
- data/lib/puppet/resource.rb +50 -73
- data/lib/puppet/settings/file_setting.rb +10 -9
- data/lib/puppet/settings.rb +2 -2
- data/lib/puppet/ssl/certificate_authority/interface.rb +2 -2
- data/lib/puppet/ssl/oids.rb +9 -1
- data/lib/puppet/transaction/additional_resource_generator.rb +71 -8
- data/lib/puppet/transaction/resource_harness.rb +9 -4
- data/lib/puppet/transaction.rb +8 -1
- data/lib/puppet/type/augeas.rb +8 -0
- data/lib/puppet/type/file/source.rb +14 -12
- data/lib/puppet/type/package.rb +9 -6
- data/lib/puppet/type/user.rb +4 -2
- data/lib/puppet/type.rb +78 -7
- data/lib/puppet/util/command_line.rb +4 -0
- data/lib/puppet/util/execution.rb +18 -2
- data/lib/puppet/util/tagging.rb +7 -1
- data/lib/puppet/util/windows/adsi.rb +5 -2
- data/lib/puppet/util/windows/security.rb +4 -1
- data/lib/puppet/util/windows/taskscheduler.rb +1 -1
- data/lib/puppet/util.rb +9 -1
- data/lib/puppet/version.rb +1 -1
- data/lib/puppet.rb +12 -0
- data/spec/fixtures/unit/application/environments/production/data/common.yaml +3 -0
- data/spec/fixtures/unit/application/environments/production/environment.conf +1 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_json/data/bad.json +3 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_json/environment.conf +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_json/hiera.yaml +5 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_json/manifests/site.pp +5 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_yaml/data/bad.yaml +3 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_yaml/environment.conf +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_yaml/hiera.yaml +5 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_yaml/manifests/site.pp +5 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_defaults/data/common.yaml +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_defaults/environment.conf +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_defaults/manifests/site.pp +1 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_defaults/modules/one/data/common.yaml +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_defaults/modules/one/manifests/init.pp +5 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_defaults/modules/one/metadata.json +9 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/data1/first.json +3 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/data1/name.yaml +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/data1/second.json +3 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/data1/single.yaml +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/data2/single.yaml +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/environment.conf +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/hiera.yaml +18 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/manifests/site.pp +5 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_misc/data/common.yaml +46 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_misc/environment.conf +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_misc/manifests/site.pp +1 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_misc/modules/one/data/common.yaml +30 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_misc/modules/one/manifests/init.pp +13 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_misc/modules/one/metadata.json +9 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/environment.conf +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/manifests/site.pp +1 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data1/first.json +3 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data1/name.yaml +1 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data1/second.json +3 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data1/single.yaml +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data2/single.yaml +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/hiera.yaml +18 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/manifests/init.pp +5 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/metadata.json +9 -0
- data/spec/fixtures/unit/data_providers/environments/sample/modules/dataprovider/lib/puppet_x/helindbe/sample_env_data.rb +1 -0
- data/spec/fixtures/unit/data_providers/environments/sample/modules/dataprovider/lib/puppet_x/helindbe/sample_module_data.rb +1 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/hieraprovider/data/first.json +3 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/hieraprovider/hiera.yaml +8 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/hieraprovider/manifests/init.pp +5 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/hieraprovider/metadata.json +9 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/meta/lib/puppet/functions/meta/data.rb +9 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/meta/manifests/init.pp +3 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/meta/metadata.json +9 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/metawcp/lib/puppet/bindings/metawcp/default.rb +10 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/metawcp/lib/puppet_x/thallgren/sample_module_data.rb +23 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/metawcp/manifests/init.pp +3 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/metawcp/metadata.json +9 -0
- data/spec/fixtures/unit/provider/package/yum/yum-check-update-security.txt +184 -0
- data/spec/fixtures/vcr/cassettes/Puppet_Network_HTTP_Connection/when_handling_requests/_request_get/should_yield_to_the_block.yml +24 -0
- data/spec/fixtures/vcr/cassettes/Puppet_Network_HTTP_Connection/when_handling_requests/_request_head/should_yield_to_the_block.yml +24 -0
- data/spec/fixtures/vcr/cassettes/Puppet_Network_HTTP_Connection/when_handling_requests/_request_post/should_yield_to_the_block.yml +24 -0
- data/spec/integration/data_binding_spec.rb +229 -0
- data/spec/integration/file_bucket/file_spec.rb +2 -2
- data/spec/integration/parser/compiler_spec.rb +30 -24
- data/spec/integration/parser/resource_expressions_spec.rb +4 -4
- data/spec/integration/parser/undef_param_spec.rb +1 -1
- data/spec/integration/provider/package_spec.rb +3 -1
- data/spec/integration/resource/catalog_spec.rb +1 -1
- data/spec/integration/ssl/certificate_authority_spec.rb +0 -1
- data/spec/integration/ssl/certificate_request_spec.rb +0 -1
- data/spec/integration/ssl/certificate_revocation_list_spec.rb +0 -1
- data/spec/integration/ssl/host_spec.rb +0 -1
- data/spec/integration/type/package_spec.rb +2 -0
- data/spec/integration/util/rdoc/parser_spec.rb +1 -1
- data/spec/integration/util/windows/security_spec.rb +18 -0
- data/spec/lib/matchers/include_in_order.rb +2 -2
- data/spec/shared_behaviours/iterative_functions.rb +8 -8
- data/spec/spec_helper.rb +7 -0
- data/spec/unit/agent/locker_spec.rb +4 -4
- data/spec/unit/agent_spec.rb +0 -8
- data/spec/unit/application/agent_spec.rb +5 -0
- data/spec/unit/application/apply_spec.rb +9 -1
- data/spec/unit/application/filebucket_spec.rb +88 -2
- data/spec/unit/application/lookup_spec.rb +195 -0
- data/spec/unit/application/master_spec.rb +2 -2
- data/spec/unit/application_spec.rb +3 -3
- data/spec/unit/appmgmt_spec.rb +657 -0
- data/spec/unit/capability_spec.rb +414 -0
- data/spec/unit/configurer_spec.rb +7 -1
- data/spec/unit/context/trusted_information_spec.rb +24 -1
- data/spec/unit/daemon_spec.rb +18 -8
- data/spec/unit/data_providers/hiera_data_provider_spec.rb +201 -0
- data/spec/unit/environments_spec.rb +2 -0
- data/spec/unit/face/node_spec.rb +1 -1
- data/spec/unit/file_bucket/dipper_spec.rb +210 -1
- data/spec/unit/file_serving/configuration_spec.rb +1 -1
- data/spec/unit/file_system_spec.rb +20 -0
- data/spec/unit/functions/assert_type_spec.rb +5 -7
- data/spec/unit/functions/defined_spec.rb +2 -2
- data/spec/unit/functions/epp_spec.rb +2 -2
- data/spec/unit/functions/filter_spec.rb +18 -0
- data/spec/unit/functions/hiera_spec.rb +2 -2
- data/spec/unit/functions/lookup_spec.rb +200 -9
- data/spec/unit/functions/regsubst_spec.rb +17 -8
- data/spec/unit/functions/scanf_spec.rb +1 -1
- data/spec/unit/functions/split_spec.rb +2 -2
- data/spec/unit/functions/versioncmp_spec.rb +36 -0
- data/spec/unit/functions4_spec.rb +58 -72
- data/spec/unit/graph/sequential_prioritizer_spec.rb +1 -1
- data/spec/unit/indirector/catalog/compiler_spec.rb +28 -8
- data/spec/unit/indirector/catalog/static_compiler_spec.rb +38 -20
- data/spec/unit/indirector/data_binding/none_spec.rb +2 -2
- data/spec/unit/indirector/file_bucket_file/file_spec.rb +52 -1
- data/spec/unit/indirector/indirection_spec.rb +13 -2
- data/spec/unit/indirector/request_spec.rb +8 -8
- data/spec/unit/indirector/ssl_file_spec.rb +1 -1
- data/spec/unit/indirector/yaml_spec.rb +1 -1
- data/spec/unit/info_service_spec.rb +236 -0
- data/spec/unit/module_tool/application_spec.rb +1 -1
- data/spec/unit/module_tool/applications/builder_spec.rb +1 -1
- data/spec/unit/module_tool/metadata_spec.rb +31 -2
- data/spec/unit/network/authconfig_spec.rb +62 -32
- data/spec/unit/network/authorization_spec.rb +30 -2
- data/spec/unit/network/authstore_spec.rb +1 -1
- data/spec/unit/network/http/compression_spec.rb +1 -1
- data/spec/unit/network/http/connection_spec.rb +14 -19
- data/spec/unit/network/http/handler_spec.rb +0 -5
- data/spec/unit/network/rights_spec.rb +3 -3
- data/spec/unit/node_spec.rb +27 -0
- data/spec/unit/parser/ast/leaf_spec.rb +1 -1
- data/spec/unit/parser/compiler_spec.rb +86 -2
- data/spec/unit/parser/functions/create_resources_spec.rb +1 -1
- data/spec/unit/parser/resource_spec.rb +2 -20
- data/spec/unit/pops/binder/config/binder_config_spec.rb +1 -1
- data/spec/unit/pops/binder/injector_spec.rb +3 -3
- data/spec/unit/pops/evaluator/access_ops_spec.rb +13 -11
- data/spec/unit/pops/evaluator/basic_expressions_spec.rb +1 -2
- data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +20 -11
- data/spec/unit/pops/evaluator/literal_evaluator_spec.rb +43 -0
- data/spec/unit/pops/label_provider_spec.rb +5 -1
- data/spec/unit/pops/parser/lexer2_spec.rb +39 -0
- data/spec/unit/pops/parser/parse_application_spec.rb +40 -0
- data/spec/unit/pops/parser/parse_basic_expressions_spec.rb +4 -0
- data/spec/unit/pops/parser/parse_capabilities_spec.rb +47 -0
- data/spec/unit/pops/parser/parse_site_spec.rb +38 -0
- data/spec/unit/pops/parser/parser_rspec_helper.rb +5 -0
- data/spec/unit/pops/parser/parser_spec.rb +18 -0
- data/spec/unit/pops/types/type_calculator_spec.rb +427 -444
- data/spec/unit/pops/types/type_factory_spec.rb +12 -12
- data/spec/unit/pops/types/type_parser_spec.rb +15 -12
- data/spec/unit/pops/validator/validator_spec.rb +68 -0
- data/spec/unit/property_spec.rb +1 -1
- data/spec/unit/provider/augeas/augeas_spec.rb +50 -0
- data/spec/unit/provider/group/directoryservice_spec.rb +33 -0
- data/spec/unit/provider/group/windows_adsi_spec.rb +3 -0
- data/spec/unit/provider/package/dnf_spec.rb +92 -0
- data/spec/unit/provider/package/gem_spec.rb +7 -0
- data/spec/unit/provider/package/nim_spec.rb +6 -6
- data/spec/unit/provider/package/rpm_spec.rb +25 -2
- data/spec/unit/provider/package/windows/package_spec.rb +41 -0
- data/spec/unit/provider/package/yum_spec.rb +35 -12
- data/spec/unit/provider/scheduled_task/win32_taskscheduler_spec.rb +10 -0
- data/spec/unit/provider/service/debian_spec.rb +28 -0
- data/spec/unit/provider/service/gentoo_spec.rb +1 -0
- data/spec/unit/provider/service/init_spec.rb +6 -0
- data/spec/unit/provider/service/launchd_spec.rb +85 -10
- data/spec/unit/provider/service/openrc_spec.rb +1 -0
- data/spec/unit/provider/service/rcng_spec.rb +41 -0
- data/spec/unit/provider/service/redhat_spec.rb +8 -1
- data/spec/unit/provider/service/smf_spec.rb +30 -5
- data/spec/unit/provider/service/src_spec.rb +20 -4
- data/spec/unit/provider/service/systemd_spec.rb +79 -29
- data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +1 -1
- data/spec/unit/provider/sshkey/parsed_spec.rb +23 -0
- data/spec/unit/provider/user/windows_adsi_spec.rb +2 -1
- data/spec/unit/provider/zone/solaris_spec.rb +19 -0
- data/spec/unit/reports_spec.rb +10 -0
- data/spec/unit/resource/capability_finder_spec.rb +56 -0
- data/spec/unit/resource/catalog_spec.rb +31 -8
- data/spec/unit/resource/type_collection_spec.rb +23 -2
- data/spec/unit/resource/type_spec.rb +1 -1
- data/spec/unit/resource_spec.rb +23 -5
- data/spec/unit/settings/file_setting_spec.rb +31 -0
- data/spec/unit/settings_spec.rb +91 -2
- data/spec/unit/ssl/certificate_authority/interface_spec.rb +4 -3
- data/spec/unit/ssl/certificate_authority_spec.rb +5 -3
- data/spec/unit/ssl/host_spec.rb +2 -2
- data/spec/unit/ssl/oids_spec.rb +8 -0
- data/spec/unit/transaction/additional_resource_generator_spec.rb +78 -5
- data/spec/unit/transaction/report_spec.rb +24 -1
- data/spec/unit/transaction_spec.rb +7 -0
- data/spec/unit/type/exec_spec.rb +16 -8
- data/spec/unit/type/host_spec.rb +4 -4
- data/spec/unit/type/package_spec.rb +1 -0
- data/spec/unit/type/tidy_spec.rb +4 -4
- data/spec/unit/type/user_spec.rb +14 -7
- data/spec/unit/type/vlan_spec.rb +1 -1
- data/spec/unit/type_spec.rb +1 -1
- data/spec/unit/util/ldap/generator_spec.rb +1 -1
- data/spec/unit/util/network_device/cisco/device_spec.rb +1 -1
- data/spec/unit/util/network_device/transport/ssh_spec.rb +1 -1
- data/spec/unit/util/network_device_spec.rb +1 -1
- data/spec/unit/util/storage_spec.rb +5 -1
- data/spec/unit/util/windows/adsi_spec.rb +13 -0
- data/spec/unit/util_spec.rb +21 -2
- metadata +173 -7
- data/lib/puppet/pops/evaluator/callable_mismatch_describer.rb +0 -175
- data/spec/integration/data_binding.rb +0 -104
|
@@ -2,78 +2,82 @@
|
|
|
2
2
|
|
|
3
3
|
#### Table of Contents
|
|
4
4
|
|
|
5
|
-
1. [
|
|
6
|
-
|
|
7
|
-
3. [Setup - The basics of getting started with <%= metadata.name %>](#setup)
|
|
5
|
+
1. [Description](#description)
|
|
6
|
+
1. [Setup - The basics of getting started with <%= metadata.name %>](#setup)
|
|
8
7
|
* [What <%= metadata.name %> affects](#what-<%= metadata.name %>-affects)
|
|
9
8
|
* [Setup requirements](#setup-requirements)
|
|
10
9
|
* [Beginning with <%= metadata.name %>](#beginning-with-<%= metadata.name %>)
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
1. [Usage - Configuration options and additional functionality](#usage)
|
|
11
|
+
1. [Reference - An under-the-hood peek at what the module is doing and how](#reference)
|
|
12
|
+
1. [Limitations - OS compatibility, etc.](#limitations)
|
|
13
|
+
1. [Development - Guide for contributing to the module](#development)
|
|
15
14
|
|
|
16
|
-
##
|
|
15
|
+
## Description
|
|
17
16
|
|
|
18
|
-
|
|
19
|
-
This is your 30
|
|
20
|
-
OS/Puppet version it works with.
|
|
17
|
+
Start with a one- or two-sentence summary of what the module does and/or what
|
|
18
|
+
problem it solves. This is your 30-second elevator pitch for your module.
|
|
19
|
+
Consider including OS/Puppet version it works with.
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
If applicable, this section should have a brief description of the technology
|
|
25
|
-
the module integrates with and what that integration enables. This section
|
|
21
|
+
You can give more descriptive information in a second paragraph. This paragraph
|
|
26
22
|
should answer the questions: "What does this module *do*?" and "Why would I use
|
|
27
|
-
it?"
|
|
28
|
-
|
|
29
|
-
If your module has a range of functionality (installation, configuration,
|
|
30
|
-
management, etc.) this is the time to mention it.
|
|
23
|
+
it?" If your module has a range of functionality (installation, configuration,
|
|
24
|
+
management, etc.), this is the time to mention it.
|
|
31
25
|
|
|
32
26
|
## Setup
|
|
33
27
|
|
|
34
|
-
### What <%= metadata.name %> affects
|
|
28
|
+
### What <%= metadata.name %> affects **OPTIONAL**
|
|
29
|
+
|
|
30
|
+
If it's obvious what your module touches, you can skip this section. For
|
|
31
|
+
example, folks can probably figure out that your mysql_instance module affects
|
|
32
|
+
their MySQL instances.
|
|
33
|
+
|
|
34
|
+
If there's more that they should know about, though, this is the place to mention:
|
|
35
35
|
|
|
36
36
|
* A list of files, packages, services, or operations that the module will alter,
|
|
37
|
-
impact, or execute
|
|
38
|
-
*
|
|
39
|
-
*
|
|
37
|
+
impact, or execute.
|
|
38
|
+
* Dependencies that your module automatically installs.
|
|
39
|
+
* Warnings or other important notices.
|
|
40
40
|
|
|
41
41
|
### Setup Requirements **OPTIONAL**
|
|
42
42
|
|
|
43
43
|
If your module requires anything extra before setting up (pluginsync enabled,
|
|
44
44
|
etc.), mention it here.
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
If your most recent release breaks compatibility or requires particular steps
|
|
47
|
+
for upgrading, you might want to include an additional "Upgrading" section
|
|
48
|
+
here.
|
|
47
49
|
|
|
48
|
-
|
|
50
|
+
### Beginning with <%= metadata.name %>
|
|
49
51
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
The very basic steps needed for a user to get the module up and running. This
|
|
53
|
+
can include setup steps, if necessary, or it can be an example of the most
|
|
54
|
+
basic use of the module.
|
|
53
55
|
|
|
54
56
|
## Usage
|
|
55
57
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
+
This section is where you describe how to customize, configure, and do the
|
|
59
|
+
fancy stuff with your module here. It's especially helpful if you include usage
|
|
60
|
+
examples and code samples for doing things with your module.
|
|
58
61
|
|
|
59
62
|
## Reference
|
|
60
63
|
|
|
61
|
-
Here, list
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
64
|
+
Here, include a complete list of your module's classes, types, providers,
|
|
65
|
+
facts, along with the parameters for each. Users refer to this section (thus
|
|
66
|
+
the name "Reference") to find specific details; most users don't read it per
|
|
67
|
+
se.
|
|
65
68
|
|
|
66
69
|
## Limitations
|
|
67
70
|
|
|
68
|
-
This is where you list OS compatibility, version compatibility, etc.
|
|
71
|
+
This is where you list OS compatibility, version compatibility, etc. If there
|
|
72
|
+
are Known Issues, you might want to include them under their own heading here.
|
|
69
73
|
|
|
70
74
|
## Development
|
|
71
75
|
|
|
72
76
|
Since your module is awesome, other users will want to play with it. Let them
|
|
73
77
|
know what the ground rules for contributing are.
|
|
74
78
|
|
|
75
|
-
## Release Notes/Contributors/Etc **Optional**
|
|
79
|
+
## Release Notes/Contributors/Etc. **Optional**
|
|
76
80
|
|
|
77
81
|
If you aren't using changelog, put your release notes here (though you should
|
|
78
|
-
consider using changelog). You
|
|
79
|
-
necessary or important to include here. Please use the `## ` header.
|
|
82
|
+
consider using changelog). You can also add any additional sections you feel
|
|
83
|
+
are necessary or important to include here. Please use the `## ` header.
|
|
@@ -1,37 +1,44 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Class: <%= metadata.name %>
|
|
2
|
+
# ===========================
|
|
2
3
|
#
|
|
3
4
|
# Full description of class <%= metadata.name %> here.
|
|
4
5
|
#
|
|
5
|
-
#
|
|
6
|
+
# Parameters
|
|
7
|
+
# ----------
|
|
6
8
|
#
|
|
7
9
|
# Document parameters here.
|
|
8
10
|
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
11
|
+
# * `sample parameter`
|
|
12
|
+
# Explanation of what this parameter affects and what it defaults to.
|
|
13
|
+
# e.g. "Specify one or more upstream ntp servers as an array."
|
|
12
14
|
#
|
|
13
|
-
#
|
|
15
|
+
# Variables
|
|
16
|
+
# ----------
|
|
14
17
|
#
|
|
15
18
|
# Here you should define a list of variables that this module would require.
|
|
16
19
|
#
|
|
17
|
-
#
|
|
18
|
-
#
|
|
19
|
-
#
|
|
20
|
-
#
|
|
21
|
-
#
|
|
22
|
-
#
|
|
20
|
+
# * `sample variable`
|
|
21
|
+
# Explanation of how this variable affects the function of this class and if
|
|
22
|
+
# it has a default. e.g. "The parameter enc_ntp_servers must be set by the
|
|
23
|
+
# External Node Classifier as a comma separated list of hostnames." (Note,
|
|
24
|
+
# global variables should be avoided in favor of class parameters as
|
|
25
|
+
# of Puppet 2.6.)
|
|
23
26
|
#
|
|
24
|
-
#
|
|
27
|
+
# Examples
|
|
28
|
+
# --------
|
|
25
29
|
#
|
|
26
|
-
#
|
|
27
|
-
#
|
|
28
|
-
#
|
|
30
|
+
# @example
|
|
31
|
+
# class { '<%= metadata.name %>':
|
|
32
|
+
# servers => [ 'pool.ntp.org', 'ntp.local.company.com' ],
|
|
33
|
+
# }
|
|
29
34
|
#
|
|
30
|
-
#
|
|
35
|
+
# Authors
|
|
36
|
+
# -------
|
|
31
37
|
#
|
|
32
38
|
# Author Name <author@domain.com>
|
|
33
39
|
#
|
|
34
|
-
#
|
|
40
|
+
# Copyright
|
|
41
|
+
# ---------
|
|
35
42
|
#
|
|
36
43
|
# Copyright <%= Time.now.year %> Your name here, unless otherwise noted.
|
|
37
44
|
#
|
|
@@ -3,7 +3,7 @@ require 'puppet/network/http'
|
|
|
3
3
|
|
|
4
4
|
module Puppet
|
|
5
5
|
class ConfigurationError < Puppet::Error; end
|
|
6
|
-
class Network::
|
|
6
|
+
class Network::DefaultAuthProvider
|
|
7
7
|
attr_accessor :rights
|
|
8
8
|
|
|
9
9
|
def self.master_url_prefix
|
|
@@ -89,4 +89,24 @@ module Puppet
|
|
|
89
89
|
insert_default_acl
|
|
90
90
|
end
|
|
91
91
|
end
|
|
92
|
+
|
|
93
|
+
class Network::AuthConfig
|
|
94
|
+
@@authprovider_class = nil
|
|
95
|
+
|
|
96
|
+
def self.authprovider_class=(klass)
|
|
97
|
+
@@authprovider_class = klass
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def self.authprovider_class
|
|
101
|
+
@@authprovider_class || Puppet::Network::DefaultAuthProvider
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def initialize(rights=nil)
|
|
105
|
+
@authprovider = self.class.authprovider_class.new(rights)
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def check_authorization(method, path, params)
|
|
109
|
+
@authprovider.check_authorization(method, path, params)
|
|
110
|
+
end
|
|
111
|
+
end
|
|
92
112
|
end
|
|
@@ -21,8 +21,15 @@ module Puppet::Network
|
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
module Authorization
|
|
24
|
+
@@authconfigloader_class = nil
|
|
25
|
+
|
|
26
|
+
def self.authconfigloader_class=(klass)
|
|
27
|
+
@@authconfigloader_class = klass
|
|
28
|
+
end
|
|
29
|
+
|
|
24
30
|
def authconfig
|
|
25
|
-
AuthConfigLoader
|
|
31
|
+
authconfigloader = @@authconfigloader_class || AuthConfigLoader
|
|
32
|
+
authconfigloader.authconfig
|
|
26
33
|
end
|
|
27
34
|
|
|
28
35
|
# Verify that our client has access.
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
require 'puppet/parser/environment_compiler'
|
|
3
|
+
|
|
4
|
+
class Puppet::Network::HTTP::API::Master::V3::Environment
|
|
5
|
+
def call(request, response)
|
|
6
|
+
env_name = request.routing_path.split('/').last
|
|
7
|
+
env = Puppet.lookup(:environments).get(env_name)
|
|
8
|
+
|
|
9
|
+
if env.nil?
|
|
10
|
+
raise Puppet::Network::HTTP::Error::HTTPNotFoundError.new("#{env_name} is not a known environment", Puppet::Network::HTTP::Issues::RESOURCE_NOT_FOUND)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
catalog = Puppet::Parser::EnvironmentCompiler.compile(env).to_resource
|
|
14
|
+
|
|
15
|
+
env_graph = {:environment => env.name, :applications => {}}
|
|
16
|
+
applications = catalog.resources.select do |res|
|
|
17
|
+
type = res.resource_type
|
|
18
|
+
type.is_a?(Puppet::Resource::Type) && type.application?
|
|
19
|
+
end
|
|
20
|
+
applications.each do |app|
|
|
21
|
+
app_components = {}
|
|
22
|
+
# Turn the 'nodes' hash into a map component ref => node name
|
|
23
|
+
node_mapping = {}
|
|
24
|
+
app['nodes'].each do |node, comps|
|
|
25
|
+
comps = [comps] unless comps.is_a?(Array)
|
|
26
|
+
comps.each do |comp|
|
|
27
|
+
raise Puppet::ParseError, "Application #{app} maps component #{comp} to multiple nodes" if node_mapping.include?(comp.ref)
|
|
28
|
+
node_mapping[comp.ref] = node.title
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
catalog.direct_dependents_of(app).each do |comp|
|
|
33
|
+
mapped_node = node_mapping[comp.ref]
|
|
34
|
+
if mapped_node.nil?
|
|
35
|
+
raise Puppet::ParseError, "Component #{comp} is not mapped to any node"
|
|
36
|
+
end
|
|
37
|
+
app_components[comp.ref] = {
|
|
38
|
+
:produces => comp.export.map(&:ref),
|
|
39
|
+
:consumes => prerequisites(comp).map(&:ref),
|
|
40
|
+
:node => mapped_node
|
|
41
|
+
}
|
|
42
|
+
end
|
|
43
|
+
env_graph[:applications][app.ref] = app_components
|
|
44
|
+
end
|
|
45
|
+
response.respond_with(200, "application/json", JSON.dump(env_graph))
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
private
|
|
49
|
+
|
|
50
|
+
# Finds all the prerequisites of component +comp+. They are all the
|
|
51
|
+
# capability resources that +comp+ depends on; this includes resources
|
|
52
|
+
# that +comp+ consumes but also resources it merely requires
|
|
53
|
+
def prerequisites(comp)
|
|
54
|
+
params = Puppet::Type.relationship_params.select { |p| p.direction == :in }.map(&:name)
|
|
55
|
+
params.map { |rel| comp[rel] }.flatten.compact.select do |rel|
|
|
56
|
+
rel.resource_type && rel.resource_type.is_capability?
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
class Puppet::Network::HTTP::API::Master::V3
|
|
2
2
|
require 'puppet/network/http/api/master/v3/authorization'
|
|
3
3
|
require 'puppet/network/http/api/master/v3/environments'
|
|
4
|
+
require 'puppet/network/http/api/master/v3/environment'
|
|
4
5
|
require 'puppet/network/http/api/indirected_routes'
|
|
5
6
|
|
|
6
7
|
AUTHZ = Authorization.new
|
|
@@ -14,9 +15,14 @@ class Puppet::Network::HTTP::API::Master::V3
|
|
|
14
15
|
Environments.new(Puppet.lookup(:environments))
|
|
15
16
|
end)
|
|
16
17
|
|
|
18
|
+
ENVIRONMENT = Puppet::Network::HTTP::Route.
|
|
19
|
+
path(%r{/environment/[^/]+$}).get(AUTHZ.wrap do
|
|
20
|
+
Environment.new
|
|
21
|
+
end)
|
|
22
|
+
|
|
17
23
|
def self.routes
|
|
18
24
|
Puppet::Network::HTTP::Route.path(%r{v3}).
|
|
19
25
|
any.
|
|
20
|
-
chain(ENVIRONMENTS, INDIRECTED)
|
|
26
|
+
chain(ENVIRONMENTS, ENVIRONMENT, INDIRECTED)
|
|
21
27
|
end
|
|
22
28
|
end
|
|
@@ -182,11 +182,18 @@ class Puppet::Node::Environment
|
|
|
182
182
|
# @api private
|
|
183
183
|
def conflicting_manifest_settings?
|
|
184
184
|
return false if !Puppet[:disable_per_environment_manifest]
|
|
185
|
-
|
|
186
|
-
original_manifest = environment_conf.raw_setting(:manifest)
|
|
185
|
+
original_manifest = configuration.raw_setting(:manifest)
|
|
187
186
|
!original_manifest.nil? && !original_manifest.empty? && original_manifest != Puppet[:default_manifest]
|
|
188
187
|
end
|
|
189
188
|
|
|
189
|
+
# Return the environment configuration
|
|
190
|
+
# @return [Puppet::Settings::EnvironmentConf] The configuration
|
|
191
|
+
#
|
|
192
|
+
# @api private
|
|
193
|
+
def configuration
|
|
194
|
+
Puppet.lookup(:environments).get_conf(name)
|
|
195
|
+
end
|
|
196
|
+
|
|
190
197
|
# Checks the environment and settings for any conflicts
|
|
191
198
|
# @return [Array<String>] an array of validation errors
|
|
192
199
|
# @api public
|
data/lib/puppet/node.rb
CHANGED
|
@@ -9,6 +9,9 @@ class Puppet::Node
|
|
|
9
9
|
# the node sources.
|
|
10
10
|
extend Puppet::Indirector
|
|
11
11
|
|
|
12
|
+
# Asymmetric serialization/deserialization required in this class via to/from datahash
|
|
13
|
+
include Puppet::Util::PsychSupport
|
|
14
|
+
|
|
12
15
|
# Use the node source as the indirection terminus.
|
|
13
16
|
indirects :node, :terminus_setting => :node_terminus, :doc => "Where to find node information.
|
|
14
17
|
A node is composed of its name, its facts, and its environment."
|
|
@@ -18,13 +21,16 @@ class Puppet::Node
|
|
|
18
21
|
|
|
19
22
|
attr_reader :server_facts
|
|
20
23
|
|
|
21
|
-
def
|
|
22
|
-
raise ArgumentError, "No name provided in serialized data"
|
|
24
|
+
def initialize_from_hash(data)
|
|
25
|
+
@name = data['name'] || (raise ArgumentError, "No name provided in serialized data")
|
|
26
|
+
@classes = data['classes'] || []
|
|
27
|
+
@parameters = data['parameters'] || {}
|
|
28
|
+
@environment_name = data['environment']
|
|
29
|
+
end
|
|
23
30
|
|
|
31
|
+
def self.from_data_hash(data)
|
|
24
32
|
node = new(name)
|
|
25
|
-
node.
|
|
26
|
-
node.parameters = data['parameters']
|
|
27
|
-
node.environment_name = data['environment']
|
|
33
|
+
node.initialize_from_hash(data)
|
|
28
34
|
node
|
|
29
35
|
end
|
|
30
36
|
|
|
@@ -88,12 +88,18 @@ class Puppet::Parser::AST::PopsBridge
|
|
|
88
88
|
instantiate_HostClassDefinition(d, modname)
|
|
89
89
|
when Puppet::Pops::Model::ResourceTypeDefinition
|
|
90
90
|
instantiate_ResourceTypeDefinition(d, modname)
|
|
91
|
+
when Puppet::Pops::Model::CapabilityMapping
|
|
92
|
+
instantiate_CapabilityMapping(d, modname)
|
|
91
93
|
when Puppet::Pops::Model::NodeDefinition
|
|
92
94
|
instantiate_NodeDefinition(d, modname)
|
|
95
|
+
when Puppet::Pops::Model::SiteDefinition
|
|
96
|
+
instantiate_SiteDefinition(d, modname)
|
|
93
97
|
when Puppet::Pops::Model::FunctionDefinition
|
|
94
98
|
instantiate_FunctionDefinition(d, modname)
|
|
95
99
|
# The 3x logic calling this will not know what to do with the result, it is compacted away at the end
|
|
96
100
|
next
|
|
101
|
+
when Puppet::Pops::Model::Application
|
|
102
|
+
instantiate_ApplicationDefinition(d, modname)
|
|
97
103
|
else
|
|
98
104
|
raise Puppet::ParseError, "Internal Error: Unknown type of definition - got '#{d.class}'"
|
|
99
105
|
end
|
|
@@ -182,6 +188,27 @@ class Puppet::Parser::AST::PopsBridge
|
|
|
182
188
|
Puppet::Resource::Type.new(:definition, o.name, @context.merge(args_from_definition(o, modname)))
|
|
183
189
|
end
|
|
184
190
|
|
|
191
|
+
def instantiate_CapabilityMapping(o, modname)
|
|
192
|
+
# Use an intermediate 'capability_mapping' type to pass this info to the compiler where the
|
|
193
|
+
# actual mapping takes place
|
|
194
|
+
Puppet::Resource::Type.new(:capability_mapping, "#{o.component} #{o.kind} #{o.capability}", { :arguments => {
|
|
195
|
+
'component' => o.component,
|
|
196
|
+
'kind' => o.kind,
|
|
197
|
+
'blueprint' => {
|
|
198
|
+
:capability => o.capability,
|
|
199
|
+
:mappings => o.mappings.reduce({}) do |memo, mapping|
|
|
200
|
+
memo[mapping.attribute_name] =
|
|
201
|
+
Expression.new(:value => mapping.value_expr)
|
|
202
|
+
memo
|
|
203
|
+
end
|
|
204
|
+
}}})
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
def instantiate_ApplicationDefinition(o, modname)
|
|
208
|
+
args = args_from_definition(o, modname)
|
|
209
|
+
Puppet::Resource::Type.new(:application, o.name, @context.merge(args))
|
|
210
|
+
end
|
|
211
|
+
|
|
185
212
|
def instantiate_NodeDefinition(o, modname)
|
|
186
213
|
args = { :module_name => modname }
|
|
187
214
|
|
|
@@ -192,14 +219,25 @@ class Puppet::Parser::AST::PopsBridge
|
|
|
192
219
|
unless is_nop?(o.parent)
|
|
193
220
|
args[:parent] = @ast_transformer.hostname(o.parent)
|
|
194
221
|
end
|
|
222
|
+
args = @ast_transformer.merge_location(args, o)
|
|
195
223
|
|
|
196
224
|
host_matches = @ast_transformer.hostname(o.host_matches)
|
|
197
|
-
@ast_transformer.merge_location(args, o)
|
|
198
225
|
host_matches.collect do |name|
|
|
199
226
|
Puppet::Resource::Type.new(:node, name, @context.merge(args))
|
|
200
227
|
end
|
|
201
228
|
end
|
|
202
229
|
|
|
230
|
+
def instantiate_SiteDefinition(o, modname)
|
|
231
|
+
args = { :module_name => modname }
|
|
232
|
+
|
|
233
|
+
unless is_nop?(o.body)
|
|
234
|
+
args[:code] = Expression.new(:value => o.body)
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
args = @ast_transformer.merge_location(args, o)
|
|
238
|
+
Puppet::Resource::Type.new(:site, 'site', @context.merge(args))
|
|
239
|
+
end
|
|
240
|
+
|
|
203
241
|
# Propagates a found Function to the appropriate loader.
|
|
204
242
|
# This is for 4x evaluator/loader
|
|
205
243
|
#
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
class Puppet::Parser::Compiler
|
|
2
|
+
# Validator that asserts that all capability resources that are referenced by 'consume' or 'require' has
|
|
3
|
+
# been exported by some other resource in the environment
|
|
4
|
+
class CatalogValidator::EnvironmentRelationshipValidator < CatalogValidator
|
|
5
|
+
|
|
6
|
+
def validate
|
|
7
|
+
assumed_exports = {}
|
|
8
|
+
exported = {}
|
|
9
|
+
catalog.resources.each do |resource|
|
|
10
|
+
next unless resource.is_a?(Puppet::Parser::Resource)
|
|
11
|
+
resource.eachparam do |param|
|
|
12
|
+
pclass = Puppet::Type.metaparamclass(param.name)
|
|
13
|
+
validate_relationship(resource, param, assumed_exports, exported) if !pclass.nil? && pclass < Puppet::Type::RelationshipMetaparam
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
assumed_exports.each_pair do |key, (param, cap)|
|
|
17
|
+
raise CatalogValidationError.new("Capability '#{cap}' referenced by '#{param.name}' is never exported", param.file, param.line) unless exported.include?(key)
|
|
18
|
+
end
|
|
19
|
+
nil
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
private
|
|
23
|
+
|
|
24
|
+
def validate_relationship(resource, param, assumed_exports, exported)
|
|
25
|
+
case param.name
|
|
26
|
+
when :require, :consume
|
|
27
|
+
add_capability_ref(param, param.value, assumed_exports)
|
|
28
|
+
when :export
|
|
29
|
+
add_exported(resource, param, param.value, exported)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def add_capability_ref(param, value, assumed_exports)
|
|
34
|
+
case value
|
|
35
|
+
when Array
|
|
36
|
+
value.each { |v| add_capability_ref(param, v, assumed_exports) }
|
|
37
|
+
when Puppet::Resource
|
|
38
|
+
rt = value.resource_type
|
|
39
|
+
unless rt.nil? || !rt.is_capability?
|
|
40
|
+
title_key = catalog.title_key_for_ref(value.ref)
|
|
41
|
+
assumed_exports[title_key] = [param, value]
|
|
42
|
+
end
|
|
43
|
+
nil
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def add_exported(resource, param, value, hash)
|
|
48
|
+
case value
|
|
49
|
+
when Array
|
|
50
|
+
value.each { |v| add_exported(resource, param, v, hash) }
|
|
51
|
+
when Puppet::Resource
|
|
52
|
+
rt = value.resource_type
|
|
53
|
+
unless rt.nil? || !rt.is_capability?
|
|
54
|
+
title_key = catalog.title_key_for_ref(value.ref)
|
|
55
|
+
if hash.include?(title_key)
|
|
56
|
+
raise CatalogValidationError.new("'#{value}' is exported by both '#{hash[title_key]}' and '#{resource}'", param.file, param.line)
|
|
57
|
+
else
|
|
58
|
+
hash[title_key] = resource
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
class Puppet::Parser::Compiler
|
|
2
|
+
# Validator that asserts that only 'require', 'consume', and 'export' is used when declaring relationships
|
|
3
|
+
# to capability resources.
|
|
4
|
+
class CatalogValidator::RelationshipValidator < CatalogValidator
|
|
5
|
+
def validate
|
|
6
|
+
catalog.resources.each do |resource|
|
|
7
|
+
next unless resource.is_a?(Puppet::Parser::Resource)
|
|
8
|
+
resource.eachparam do |param|
|
|
9
|
+
pclass = Puppet::Type.metaparamclass(param.name)
|
|
10
|
+
validate_relationship(param) if !pclass.nil? && pclass < Puppet::Type::RelationshipMetaparam
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
nil
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
private
|
|
17
|
+
|
|
18
|
+
def validate_relationship(param)
|
|
19
|
+
unless [:require, :consume, :export].find {|pname| pname == param.name }
|
|
20
|
+
raise CatalogValidationError.new("'#{param.name}' is not a valid relationship to a capability", param.file, param.line) if has_capability?(param.value)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def has_capability?(value)
|
|
25
|
+
case value
|
|
26
|
+
when Array
|
|
27
|
+
value.find { |v| has_capability?(v) }
|
|
28
|
+
when Puppet::Resource
|
|
29
|
+
rt = value.resource_type
|
|
30
|
+
!rt.nil? && rt.is_capability?
|
|
31
|
+
else
|
|
32
|
+
false
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
class Puppet::Parser::Compiler
|
|
2
|
+
# Validator that asserts that only application components can appear inside a site.
|
|
3
|
+
class CatalogValidator::SiteValidator < CatalogValidator
|
|
4
|
+
def self.validation_stage?(stage)
|
|
5
|
+
PRE_FINISH.equal?(stage)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def validate
|
|
9
|
+
the_site_resource = catalog.resource('Site', 'site')
|
|
10
|
+
return unless the_site_resource
|
|
11
|
+
|
|
12
|
+
catalog.downstream_from_vertex(the_site_resource).keys.each do |r|
|
|
13
|
+
unless r.is_application_component? || r.resource_type.application?
|
|
14
|
+
raise CatalogValidationError.new("Only application components can appear inside a site - #{r} is not allowed", r.file, r.line)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Abstract class for a catalog validator that can be registered with the compiler to run at
|
|
2
|
+
# a certain stage.
|
|
3
|
+
class Puppet::Parser::Compiler
|
|
4
|
+
class CatalogValidator
|
|
5
|
+
PRE_FINISH = :pre_finish
|
|
6
|
+
FINAL = :final
|
|
7
|
+
|
|
8
|
+
# Returns true if the validator should run at the given stage. The default
|
|
9
|
+
# implementation will only run at stage `FINAL`
|
|
10
|
+
#
|
|
11
|
+
# @param stage [Symbol] One of the stage constants defined in this class
|
|
12
|
+
# @return [Boolean] true if the validator should run at the given stage
|
|
13
|
+
#
|
|
14
|
+
def self.validation_stage?(stage)
|
|
15
|
+
FINAL.equal?(stage)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
attr_reader :catalog
|
|
19
|
+
|
|
20
|
+
# @param catalog [Puppet::Resource::Catalog] The catalog to validate
|
|
21
|
+
def initialize(catalog)
|
|
22
|
+
@catalog = catalog
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Validate some aspect of the catalog and raise a `CatalogValidationError` on failure
|
|
26
|
+
def validate
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
class CatalogValidationError < Puppet::Error
|
|
31
|
+
include Puppet::ExternalFileError
|
|
32
|
+
end
|
|
33
|
+
end
|