puppet 4.5.3-x64-mingw32 → 4.6.1-x64-mingw32
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.
- checksums.yaml +7 -0
- data/Gemfile +10 -1
- data/ext/debian/control +2 -4
- data/ext/project_data.yaml +4 -4
- data/install.rb +6 -2
- data/lib/puppet.rb +3 -1
- data/lib/puppet/agent/locker.rb +1 -1
- data/lib/puppet/application.rb +6 -4
- data/lib/puppet/application/agent.rb +2 -1
- data/lib/puppet/application/cert.rb +35 -2
- data/lib/puppet/application/device.rb +1 -1
- data/lib/puppet/application/generate.rb +5 -0
- data/lib/puppet/application/lookup.rb +3 -3
- data/lib/puppet/application_support.rb +1 -1
- data/lib/puppet/compilable_resource_type.rb +15 -0
- data/lib/puppet/configurer.rb +67 -10
- data/lib/puppet/configurer/plugin_handler.rb +2 -4
- data/lib/puppet/data_providers/hiera_config.rb +1 -1
- data/lib/puppet/defaults.rb +34 -7
- data/lib/puppet/environments.rb +4 -2
- data/lib/puppet/error.rb +1 -1
- data/lib/puppet/external/dot.rb +1 -1
- data/lib/puppet/face/ca.rb +4 -1
- data/lib/puppet/face/certificate.rb +7 -1
- data/lib/puppet/face/epp.rb +5 -5
- data/lib/puppet/face/generate.rb +64 -0
- data/lib/puppet/face/help.rb +19 -13
- data/lib/puppet/face/man.rb +1 -1
- data/lib/puppet/feature/external_facts.rb +1 -1
- data/lib/puppet/file_system.rb +16 -0
- data/lib/puppet/file_system/file_impl.rb +5 -0
- data/lib/puppet/file_system/memory_impl.rb +4 -0
- data/lib/puppet/file_system/path_pattern.rb +1 -0
- data/lib/puppet/file_system/windows.rb +19 -0
- data/lib/puppet/functions.rb +3 -5
- data/lib/puppet/functions/assert_type.rb +1 -1
- data/lib/puppet/functions/defined.rb +7 -5
- data/lib/puppet/functions/dig.rb +2 -18
- data/lib/puppet/functions/hiera.rb +1 -1
- data/lib/puppet/functions/lest.rb +1 -37
- data/lib/puppet/functions/new.rb +2 -473
- data/lib/puppet/functions/reverse_each.rb +2 -59
- data/lib/puppet/functions/scanf.rb +4 -4
- data/lib/puppet/functions/step.rb +1 -63
- data/lib/puppet/functions/then.rb +1 -61
- data/lib/puppet/functions/type.rb +1 -40
- data/lib/puppet/functions/unwrap.rb +40 -0
- data/lib/puppet/generate/models/type/property.rb +70 -0
- data/lib/puppet/generate/models/type/type.rb +57 -0
- data/lib/puppet/generate/templates/type/pcore.erb +41 -0
- data/lib/puppet/generate/type.rb +239 -0
- data/lib/puppet/graph/simple_graph.rb +2 -6
- data/lib/puppet/indirector/catalog/static_compiler.rb +5 -2
- data/lib/puppet/indirector/facts/facter.rb +1 -1
- data/lib/puppet/indirector/key/ca.rb +2 -2
- data/lib/puppet/indirector/request.rb +25 -4
- data/lib/puppet/indirector/rest.rb +73 -3
- data/lib/puppet/info_service/class_information_service.rb +1 -2
- data/lib/puppet/interface/documentation.rb +1 -1
- data/lib/puppet/loaders.rb +2 -0
- data/lib/puppet/metatype/manager.rb +6 -6
- data/lib/puppet/module.rb +8 -1
- data/lib/puppet/module_tool.rb +2 -2
- data/lib/puppet/module_tool/checksums.rb +1 -1
- data/lib/puppet/module_tool/errors/installer.rb +2 -2
- data/lib/puppet/module_tool/metadata.rb +1 -1
- data/lib/puppet/network/http/api/indirected_routes.rb +23 -32
- data/lib/puppet/network/http/rack/rest.rb +15 -1
- data/lib/puppet/network/rights.rb +1 -11
- data/lib/puppet/node/environment.rb +7 -3
- data/lib/puppet/node/facts.rb +1 -1
- data/lib/puppet/parameter.rb +23 -3
- data/lib/puppet/parameter/boolean.rb +1 -1
- data/lib/puppet/parameter/value.rb +1 -1
- data/lib/puppet/parser.rb +0 -1
- data/lib/puppet/parser/ast/pops_bridge.rb +1 -1
- data/lib/puppet/parser/ast/resource.rb +5 -0
- data/lib/puppet/parser/ast/resource_instance.rb +5 -1
- data/lib/puppet/parser/ast/resourceparam.rb +5 -0
- data/lib/puppet/parser/compiler.rb +14 -17
- data/lib/puppet/parser/compiler/catalog_validator/relationship_validator.rb +1 -1
- data/lib/puppet/parser/environment_compiler.rb +10 -0
- data/lib/puppet/parser/functions/create_resources.rb +39 -24
- data/lib/puppet/parser/functions/defined.rb +2 -26
- data/lib/puppet/parser/functions/dig.rb +29 -0
- data/lib/puppet/parser/functions/lest.rb +49 -0
- data/lib/puppet/parser/functions/new.rb +530 -0
- data/lib/puppet/parser/functions/require.rb +1 -1
- data/lib/puppet/parser/functions/reverse_each.rb +83 -0
- data/lib/puppet/parser/functions/scanf.rb +4 -4
- data/lib/puppet/parser/functions/step.rb +84 -0
- data/lib/puppet/parser/functions/then.rb +73 -0
- data/lib/puppet/parser/functions/type.rb +53 -0
- data/lib/puppet/parser/resource.rb +16 -7
- data/lib/puppet/parser/scope.rb +36 -28
- data/lib/puppet/parser/type_loader.rb +1 -1
- data/lib/puppet/plugins/data_providers/data_provider.rb +1 -1
- data/lib/puppet/pops.rb +13 -0
- data/lib/puppet/pops/adapters.rb +49 -49
- data/lib/puppet/pops/binder/scheme_handler/confdir_scheme.rb +1 -1
- data/lib/puppet/pops/evaluator/access_operator.rb +39 -2
- data/lib/puppet/pops/evaluator/closure.rb +39 -13
- data/lib/puppet/pops/evaluator/collector_transformer.rb +10 -1
- data/lib/puppet/pops/evaluator/evaluator_impl.rb +16 -11
- data/lib/puppet/pops/evaluator/external_syntax_support.rb +1 -1
- data/lib/puppet/pops/evaluator/json_strict_literal_evaluator.rb +0 -1
- data/lib/puppet/pops/evaluator/literal_evaluator.rb +0 -1
- data/lib/puppet/pops/evaluator/relationship_operator.rb +1 -2
- data/lib/puppet/pops/evaluator/runtime3_resource_support.rb +119 -0
- data/lib/puppet/pops/evaluator/runtime3_support.rb +19 -45
- data/lib/puppet/pops/functions/function.rb +5 -0
- data/lib/puppet/pops/issues.rb +1 -1
- data/lib/puppet/pops/label_provider.rb +2 -2
- data/lib/puppet/pops/loader/base_loader.rb +12 -15
- data/lib/puppet/pops/loader/loader.rb +15 -50
- data/lib/puppet/pops/loader/loader_paths.rb +28 -2
- data/lib/puppet/pops/loader/module_loaders.rb +16 -1
- data/lib/puppet/pops/loader/null_loader.rb +17 -1
- data/lib/puppet/pops/loader/puppet_function_instantiator.rb +12 -11
- data/lib/puppet/pops/loader/puppet_resource_type_impl_instantiator.rb +80 -0
- data/lib/puppet/pops/loader/ruby_function_instantiator.rb +2 -3
- data/lib/puppet/pops/loader/runtime3_type_loader.rb +52 -13
- data/lib/puppet/pops/loader/static_loader.rb +55 -0
- data/lib/puppet/pops/loader/type_definition_instantiator.rb +30 -14
- data/lib/puppet/pops/loader/typed_name.rb +50 -0
- data/lib/puppet/pops/loaders.rb +64 -19
- data/lib/puppet/pops/merge_strategy.rb +7 -7
- data/lib/puppet/pops/migration/migration_checker.rb +4 -0
- data/lib/puppet/pops/model/model_label_provider.rb +2 -0
- data/lib/puppet/pops/parser/egrammar.ra +8 -5
- data/lib/puppet/pops/parser/eparser.rb +1550 -1498
- data/lib/puppet/pops/parser/evaluating_parser.rb +1 -1
- data/lib/puppet/pops/parser/interpolation_support.rb +7 -0
- data/lib/puppet/pops/parser/lexer2.rb +14 -1
- data/lib/puppet/pops/parser/locator.rb +30 -1
- data/lib/puppet/pops/parser/parser_support.rb +0 -3
- data/lib/puppet/pops/parser/slurp_support.rb +3 -3
- data/lib/puppet/pops/patterns.rb +9 -1
- data/lib/puppet/pops/pcore.rb +67 -11
- data/lib/puppet/pops/puppet_stack.rb +43 -0
- data/lib/puppet/pops/resource/param.rb +51 -0
- data/lib/puppet/pops/resource/resource_type_impl.rb +301 -0
- data/lib/puppet/pops/resource/resource_type_set.pcore +21 -0
- data/lib/puppet/pops/serialization.rb +17 -0
- data/lib/puppet/pops/serialization/abstract_reader.rb +149 -0
- data/lib/puppet/pops/serialization/abstract_writer.rb +179 -0
- data/lib/puppet/pops/serialization/deserializer.rb +60 -0
- data/lib/puppet/pops/serialization/extension.rb +126 -0
- data/lib/puppet/pops/serialization/instance_reader.rb +19 -0
- data/lib/puppet/pops/serialization/instance_writer.rb +14 -0
- data/lib/puppet/pops/serialization/json.rb +247 -0
- data/lib/puppet/pops/serialization/object.rb +63 -0
- data/lib/puppet/pops/serialization/rgen.rb +151 -0
- data/lib/puppet/pops/serialization/serializer.rb +91 -0
- data/lib/puppet/pops/serialization/time_factory.rb +66 -0
- data/lib/puppet/pops/types/annotatable.rb +36 -0
- data/lib/puppet/pops/types/implementation_registry.rb +3 -8
- data/lib/puppet/pops/types/p_meta_type.rb +83 -0
- data/lib/puppet/pops/types/p_object_type.rb +110 -117
- data/lib/puppet/pops/types/p_runtime_type.rb +13 -0
- data/lib/puppet/pops/types/p_sem_ver_range_type.rb +23 -0
- data/lib/puppet/pops/types/p_sem_ver_type.rb +30 -2
- data/lib/puppet/pops/types/p_sensitive_type.rb +69 -0
- data/lib/puppet/pops/types/p_type_set_type.rb +361 -0
- data/lib/puppet/pops/types/puppet_object.rb +0 -5
- data/lib/puppet/pops/types/ruby_generator.rb +9 -2
- data/lib/puppet/pops/types/type_calculator.rb +6 -1
- data/lib/puppet/pops/types/type_factory.rb +14 -12
- data/lib/puppet/pops/types/type_formatter.rb +78 -33
- data/lib/puppet/pops/types/type_mismatch_describer.rb +0 -2
- data/lib/puppet/pops/types/type_parser.rb +27 -2
- data/lib/puppet/pops/types/type_set_reference.rb +59 -0
- data/lib/puppet/pops/types/types.rb +366 -13
- data/lib/puppet/pops/validation.rb +4 -4
- data/lib/puppet/pops/validation/checker4_0.rb +5 -2
- data/lib/puppet/pops/visitor.rb +2 -2
- data/lib/puppet/property.rb +64 -5
- data/lib/puppet/provider.rb +1 -1
- data/lib/puppet/provider/aixobject.rb +3 -3
- data/lib/puppet/provider/group/aix.rb +4 -4
- data/lib/puppet/provider/macauthorization/macauthorization.rb +1 -1
- data/lib/puppet/provider/mailalias/aliases.rb +1 -1
- data/lib/puppet/provider/mcx/mcxcontent.rb +2 -2
- data/lib/puppet/provider/mount/parsed.rb +1 -1
- data/lib/puppet/provider/nameservice/directoryservice.rb +5 -5
- data/lib/puppet/provider/package/appdmg.rb +3 -3
- data/lib/puppet/provider/package/apple.rb +1 -1
- data/lib/puppet/provider/package/dnf.rb +5 -0
- data/lib/puppet/provider/package/nim.rb +1 -1
- data/lib/puppet/provider/package/pacman.rb +2 -2
- data/lib/puppet/provider/package/pip.rb +5 -3
- data/lib/puppet/provider/package/pip3.rb +1 -1
- data/lib/puppet/provider/package/pkg.rb +5 -5
- data/lib/puppet/provider/package/pkgdmg.rb +4 -4
- data/lib/puppet/provider/package/pkgin.rb +1 -1
- data/lib/puppet/provider/package/pkgutil.rb +1 -1
- data/lib/puppet/provider/package/portage.rb +48 -8
- data/lib/puppet/provider/package/sun.rb +1 -1
- data/lib/puppet/provider/package/tdnf.rb +28 -0
- data/lib/puppet/provider/package/yum.rb +22 -4
- data/lib/puppet/provider/parsedfile.rb +2 -2
- data/lib/puppet/provider/service/base.rb +1 -1
- data/lib/puppet/provider/service/bsd.rb +1 -1
- data/lib/puppet/provider/service/daemontools.rb +2 -2
- data/lib/puppet/provider/service/debian.rb +3 -3
- data/lib/puppet/provider/service/init.rb +5 -3
- data/lib/puppet/provider/service/launchd.rb +16 -2
- data/lib/puppet/provider/service/runit.rb +1 -1
- data/lib/puppet/provider/service/smf.rb +8 -1
- data/lib/puppet/provider/service/systemd.rb +39 -6
- data/lib/puppet/provider/ssh_authorized_key/parsed.rb +1 -1
- data/lib/puppet/provider/user/aix.rb +3 -2
- data/lib/puppet/provider/user/directoryservice.rb +4 -3
- data/lib/puppet/provider/user/hpux.rb +1 -1
- data/lib/puppet/provider/user/user_role_add.rb +1 -1
- data/lib/puppet/provider/user/windows_adsi.rb +3 -0
- data/lib/puppet/provider/zfs/zfs.rb +1 -1
- data/lib/puppet/reference/type.rb +1 -1
- data/lib/puppet/resource.rb +33 -7
- data/lib/puppet/resource/capability_finder.rb +74 -54
- data/lib/puppet/resource/status.rb +11 -2
- data/lib/puppet/settings.rb +17 -6
- data/lib/puppet/settings/environment_conf.rb +1 -1
- data/lib/puppet/settings/server_list_setting.rb +20 -0
- data/lib/puppet/ssl/certificate_authority.rb +32 -9
- data/lib/puppet/ssl/certificate_authority/interface.rb +164 -24
- data/lib/puppet/ssl/host.rb +3 -3
- data/lib/puppet/ssl/oids.rb +10 -0
- data/lib/puppet/ssl/validator/default_validator.rb +2 -2
- data/lib/puppet/test/test_helper.rb +2 -2
- data/lib/puppet/transaction.rb +12 -0
- data/lib/puppet/transaction/additional_resource_generator.rb +1 -1
- data/lib/puppet/transaction/event.rb +29 -2
- data/lib/puppet/transaction/event_manager.rb +1 -1
- data/lib/puppet/transaction/persistence.rb +84 -0
- data/lib/puppet/transaction/report.rb +49 -2
- data/lib/puppet/transaction/resource_harness.rb +98 -18
- data/lib/puppet/type.rb +63 -21
- data/lib/puppet/type/augeas.rb +3 -3
- data/lib/puppet/type/cron.rb +1 -1
- data/lib/puppet/type/file.rb +39 -2
- data/lib/puppet/type/file/data_sync.rb +13 -5
- data/lib/puppet/type/host.rb +1 -1
- data/lib/puppet/type/mount.rb +2 -6
- data/lib/puppet/type/notify.rb +1 -1
- data/lib/puppet/type/package.rb +1 -1
- data/lib/puppet/type/resources.rb +1 -1
- data/lib/puppet/type/scheduled_task.rb +1 -1
- data/lib/puppet/type/ssh_authorized_key.rb +2 -2
- data/lib/puppet/type/tidy.rb +1 -1
- data/lib/puppet/type/yumrepo.rb +3 -3
- data/lib/puppet/type/zone.rb +1 -1
- data/lib/puppet/util.rb +2 -2
- data/lib/puppet/util/classgen.rb +1 -1
- data/lib/puppet/util/command_line.rb +6 -2
- data/lib/puppet/util/command_line/trollop.rb +1 -1
- data/lib/puppet/util/execution.rb +2 -2
- data/lib/puppet/util/http_proxy.rb +1 -1
- data/lib/puppet/util/inifile.rb +1 -1
- data/lib/puppet/util/instance_loader.rb +1 -1
- data/lib/puppet/util/logging.rb +1 -1
- data/lib/puppet/util/multi_match.rb +1 -1
- data/lib/puppet/util/plist.rb +15 -5
- data/lib/puppet/util/profiler.rb +1 -1
- data/lib/puppet/util/profiler/around_profiler.rb +1 -1
- data/lib/puppet/util/psych_support.rb +1 -1
- data/lib/puppet/util/rdoc.rb +2 -2
- data/lib/puppet/util/rubygems.rb +1 -1
- data/lib/puppet/util/watcher/periodic_watcher.rb +2 -2
- data/lib/puppet/util/windows/access_control_entry.rb +1 -1
- data/lib/puppet/util/windows/adsi.rb +30 -8
- data/lib/puppet/util/windows/api_types.rb +1 -1
- data/lib/puppet/util/windows/file.rb +59 -0
- data/lib/puppet/util/windows/process.rb +10 -0
- data/lib/puppet/util/windows/security.rb +1 -1
- data/lib/puppet/util/windows/user.rb +22 -4
- data/lib/puppet/util/yaml.rb +15 -3
- data/lib/puppet/vendor/deep_merge/test/test_deep_merge.rb +1 -1
- data/lib/puppet/vendor/rgen_patch.rb +1 -1
- data/lib/puppet/version.rb +2 -2
- data/spec/fixtures/unit/pops/loaders/loaders/no_modules/manifests/site.pp +10 -0
- data/spec/integration/agent/logging_spec.rb +15 -14
- data/spec/integration/application/apply_spec.rb +1 -0
- data/spec/integration/directory_environments_spec.rb +16 -0
- data/spec/integration/environments/settings_spec.rb +32 -4
- data/spec/integration/faces/documentation_spec.rb +1 -1
- data/spec/integration/network/http/api/indirected_routes_spec.rb +33 -0
- data/spec/integration/node/environment_spec.rb +21 -0
- data/spec/integration/parser/collection_spec.rb +10 -0
- data/spec/integration/parser/compiler_spec.rb +76 -840
- data/spec/integration/parser/functions/require_spec.rb +3 -3
- data/spec/integration/parser/parameter_defaults_spec.rb +6 -2
- data/spec/integration/parser/pcore_resource_spec.rb +208 -0
- data/spec/integration/parser/resource_expressions_spec.rb +4 -2
- data/spec/integration/provider/yumrepo_spec.rb +4 -1
- data/spec/integration/transaction/report_spec.rb +666 -0
- data/spec/integration/type/file_spec.rb +11 -12
- data/spec/integration/util/windows/adsi_spec.rb +99 -0
- data/spec/integration/util/windows/principal_spec.rb +109 -60
- data/spec/integration/util/windows/process_spec.rb +4 -2
- data/spec/integration/util/windows/security_spec.rb +34 -8
- data/spec/integration/util/windows/user_spec.rb +26 -4
- data/spec/lib/puppet_spec/files.rb +2 -2
- data/spec/lib/puppet_spec/network.rb +12 -8
- data/spec/shared_examples/rhel_package_provider.rb +341 -0
- data/spec/spec_helper.rb +8 -2
- data/spec/unit/application/cert_spec.rb +20 -0
- data/spec/unit/configurer/plugin_handler_spec.rb +0 -26
- data/spec/unit/configurer_spec.rb +46 -0
- data/spec/unit/defaults_spec.rb +14 -0
- data/spec/unit/face/generate_spec.rb +230 -0
- data/spec/unit/face/help_spec.rb +53 -0
- data/spec/unit/face/parser_spec.rb +6 -0
- data/spec/unit/face/plugin_spec.rb +0 -4
- data/spec/unit/file_system_spec.rb +85 -0
- data/spec/unit/functions/lookup_spec.rb +4 -4
- data/spec/unit/functions/match_spec.rb +2 -2
- data/spec/unit/functions/regsubst_spec.rb +1 -1
- data/spec/unit/functions/split_spec.rb +1 -1
- data/spec/unit/functions/unwrap_spec.rb +29 -0
- data/spec/unit/functions/versioncmp_spec.rb +1 -1
- data/spec/unit/functions4_spec.rb +8 -8
- data/spec/unit/indirector/facts/facter_spec.rb +1 -9
- data/spec/unit/indirector/rest_spec.rb +95 -9
- data/spec/unit/module_spec.rb +43 -7
- data/spec/unit/module_tool/applications/installer_spec.rb +10 -1
- data/spec/unit/module_tool/applications/unpacker_spec.rb +2 -1
- data/spec/unit/module_tool/applications/upgrader_spec.rb +8 -0
- data/spec/unit/module_tool/tar/mini_spec.rb +3 -3
- data/spec/unit/network/http/api/indirected_routes_spec.rb +49 -58
- data/spec/unit/network/http/api/master/v3_spec.rb +7 -4
- data/spec/unit/network/rights_spec.rb +1 -1
- data/spec/unit/parameter_spec.rb +11 -0
- data/spec/unit/parser/compiler_spec.rb +19 -33
- data/spec/unit/{appmgmt_spec.rb → parser/environment_compiler_spec.rb} +12 -1
- data/spec/unit/parser/functions/create_resources_spec.rb +76 -4
- data/spec/unit/parser/functions/require_spec.rb +2 -2
- data/spec/unit/parser/resource_spec.rb +21 -11
- data/spec/unit/parser/scope_spec.rb +1 -5
- data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +1 -1
- data/spec/unit/pops/loaders/dependency_loader_spec.rb +1 -1
- data/spec/unit/pops/loaders/loader_paths_spec.rb +1 -1
- data/spec/unit/pops/loaders/loaders_spec.rb +63 -5
- data/spec/unit/pops/loaders/module_loaders_spec.rb +2 -2
- data/spec/unit/pops/loaders/static_loader_spec.rb +1 -1
- data/spec/unit/pops/parser/lexer2_spec.rb +27 -3
- data/spec/unit/pops/parser/parse_basic_expressions_spec.rb +8 -0
- data/spec/unit/pops/parser/parse_calls_spec.rb +9 -0
- data/spec/unit/pops/puppet_stack_spec.rb +79 -0
- data/spec/unit/pops/resource/resource_type_impl_spec.rb +37 -0
- data/spec/unit/pops/serialization/packer_spec.rb +153 -0
- data/spec/unit/pops/serialization/rgen_spec.rb +88 -0
- data/spec/unit/pops/serialization/serialization_spec.rb +228 -0
- data/spec/unit/pops/types/p_object_type_spec.rb +44 -2
- data/spec/unit/pops/types/p_sem_ver_type_spec.rb +42 -0
- data/spec/unit/pops/types/p_sensitive_type_spec.rb +139 -0
- data/spec/unit/pops/types/p_type_set_type_spec.rb +424 -0
- data/spec/unit/pops/types/ruby_generator_spec.rb +497 -181
- data/spec/unit/pops/types/type_calculator_spec.rb +10 -4
- data/spec/unit/pops/types/type_formatter_spec.rb +1 -1
- data/spec/unit/pops/types/type_mismatch_describer_spec.rb +2 -2
- data/spec/unit/pops/types/type_parser_spec.rb +1 -1
- data/spec/unit/pops/types/types_spec.rb +1 -1
- data/spec/unit/pops/validator/validator_spec.rb +18 -1
- data/spec/unit/property_spec.rb +48 -11
- data/spec/unit/provider/group/windows_adsi_spec.rb +11 -1
- data/spec/unit/provider/package/dnf_spec.rb +1 -99
- data/spec/unit/provider/package/pacman_spec.rb +4 -4
- data/spec/unit/provider/package/pip_spec.rb +14 -0
- data/spec/unit/provider/package/pkg_spec.rb +6 -0
- data/spec/unit/provider/package/pkgdmg_spec.rb +0 -3
- data/spec/unit/provider/package/portage_spec.rb +64 -8
- data/spec/unit/provider/package/tdnf_spec.rb +18 -0
- data/spec/unit/provider/package/windows/package_spec.rb +4 -1
- data/spec/unit/provider/package/windows_spec.rb +8 -2
- data/spec/unit/provider/package/yum_spec.rb +6 -377
- data/spec/unit/provider/service/base_spec.rb +6 -0
- data/spec/unit/provider/service/debian_spec.rb +16 -7
- data/spec/unit/provider/service/gentoo_spec.rb +6 -0
- data/spec/unit/provider/service/init_spec.rb +7 -0
- data/spec/unit/provider/service/launchd_spec.rb +35 -4
- data/spec/unit/provider/service/openrc_spec.rb +6 -0
- data/spec/unit/provider/service/smf_spec.rb +31 -6
- data/spec/unit/provider/service/src_spec.rb +6 -0
- data/spec/unit/provider/service/systemd_spec.rb +70 -20
- data/spec/unit/provider/service/upstart_spec.rb +6 -0
- data/spec/unit/provider/user/aix_spec.rb +7 -0
- data/spec/unit/provider/user/directoryservice_spec.rb +30 -1
- data/spec/unit/provider/user/windows_adsi_spec.rb +19 -0
- data/spec/unit/resource/capability_finder_spec.rb +51 -3
- data/spec/unit/resource/catalog_spec.rb +5 -0
- data/spec/unit/resource/type_spec.rb +2 -2
- data/spec/unit/resource_spec.rb +19 -0
- data/spec/unit/settings_spec.rb +13 -0
- data/spec/unit/ssl/certificate_authority/interface_spec.rb +176 -10
- data/spec/unit/ssl/certificate_authority_spec.rb +63 -22
- data/spec/unit/ssl/host_spec.rb +1 -1
- data/spec/unit/ssl/oids_spec.rb +24 -21
- data/spec/unit/transaction/event_spec.rb +3 -1
- data/spec/unit/transaction/persistence_spec.rb +173 -0
- data/spec/unit/transaction/report_spec.rb +64 -1
- data/spec/unit/transaction/resource_harness_spec.rb +91 -0
- data/spec/unit/type/file/content_spec.rb +47 -15
- data/spec/unit/type/file_spec.rb +28 -0
- data/spec/unit/type/mount_spec.rb +5 -12
- data/spec/unit/type/yumrepo_spec.rb +1 -5
- data/spec/unit/type_spec.rb +32 -0
- data/spec/unit/util/command_line_spec.rb +11 -0
- data/spec/unit/util/execution_spec.rb +1 -1
- data/spec/unit/util/plist_spec.rb +16 -3
- data/spec/unit/util/storage_spec.rb +4 -1
- data/spec/unit/util/windows/adsi_spec.rb +23 -2
- data/spec/unit/util/windows/file_spec.rb +56 -1
- data/spec/unit/util/windows/sid_spec.rb +31 -7
- data/spec/unit/util/yaml_spec.rb +12 -0
- data/spec/unit/util_spec.rb +87 -20
- metadata +91 -48
- data/ext/puppetlisten/puppetlisten.rb +0 -77
- data/ext/puppetlisten/puppetrun.rb +0 -38
- data/lib/puppet/resource/type_collection_helper.rb +0 -7
- data/spec/unit/parser/functions/defined_spec.rb +0 -120
- data/spec/unit/resource/type_collection_helper_spec.rb +0 -24
data/lib/puppet/transaction.rb
CHANGED
@@ -15,6 +15,7 @@ class Puppet::Transaction
|
|
15
15
|
require 'puppet/transaction/event_manager'
|
16
16
|
require 'puppet/transaction/resource_harness'
|
17
17
|
require 'puppet/resource/status'
|
18
|
+
require 'puppet/transaction/persistence'
|
18
19
|
|
19
20
|
attr_accessor :catalog, :ignoreschedules, :for_network_device
|
20
21
|
|
@@ -29,12 +30,19 @@ class Puppet::Transaction
|
|
29
30
|
|
30
31
|
attr_reader :prefetched_providers
|
31
32
|
|
33
|
+
# @!attribute [r] persistence
|
34
|
+
# @return [Puppet::Transaction::Persistence] persistence object for cross
|
35
|
+
# transaction storage.
|
36
|
+
attr_reader :persistence
|
37
|
+
|
32
38
|
include Puppet::Util
|
33
39
|
include Puppet::Util::Tagging
|
34
40
|
|
35
41
|
def initialize(catalog, report, prioritizer)
|
36
42
|
@catalog = catalog
|
37
43
|
|
44
|
+
@persistence = Puppet::Transaction::Persistence.new
|
45
|
+
|
38
46
|
@report = report || Puppet::Transaction::Report.new("apply", catalog.version, catalog.environment)
|
39
47
|
|
40
48
|
@prioritizer = prioritizer
|
@@ -85,6 +93,8 @@ class Puppet::Transaction
|
|
85
93
|
|
86
94
|
perform_pre_run_checks
|
87
95
|
|
96
|
+
persistence.load if catalog.host_config?
|
97
|
+
|
88
98
|
Puppet.info "Applying configuration version '#{catalog.version}'" if catalog.version
|
89
99
|
|
90
100
|
continue_while = lambda { !stop_processing? }
|
@@ -134,6 +144,8 @@ class Puppet::Transaction
|
|
134
144
|
Puppet.log_exception(detail, "post_resource_eval failed for provider #{provider}")
|
135
145
|
end
|
136
146
|
end
|
147
|
+
|
148
|
+
persistence.save if catalog.host_config?
|
137
149
|
end
|
138
150
|
|
139
151
|
# Generate the relationship graph, set up our generator to use it
|
@@ -26,7 +26,7 @@ class Puppet::Transaction::AdditionalResourceGenerator
|
|
26
26
|
@catalog.resource(res.ref) || res
|
27
27
|
end
|
28
28
|
unless resource.depthfirst?
|
29
|
-
# This is reversed
|
29
|
+
# This is reversed because PUP-1963 changed how generated
|
30
30
|
# resources were added to the catalog. It exists for backwards
|
31
31
|
# compatibility only, and can probably be removed in Puppet 5
|
32
32
|
#
|
@@ -11,8 +11,8 @@ class Puppet::Transaction::Event
|
|
11
11
|
include Puppet::Util::Logging
|
12
12
|
include Puppet::Network::FormatSupport
|
13
13
|
|
14
|
-
ATTRIBUTES = [:name, :resource, :property, :previous_value, :desired_value, :historical_value, :status, :message, :file, :line, :source_description, :audited, :invalidate_refreshes]
|
15
|
-
YAML_ATTRIBUTES = %w{@audited @property @previous_value @desired_value @historical_value @message @name @status @time}.map(&:to_sym)
|
14
|
+
ATTRIBUTES = [:name, :resource, :property, :previous_value, :desired_value, :historical_value, :status, :message, :file, :line, :source_description, :audited, :invalidate_refreshes, :redacted, :corrective_change]
|
15
|
+
YAML_ATTRIBUTES = %w{@audited @property @previous_value @desired_value @historical_value @message @name @status @time @redacted @corrective_change}.map(&:to_sym)
|
16
16
|
attr_accessor *ATTRIBUTES
|
17
17
|
attr_accessor :time
|
18
18
|
attr_reader :default_log_level
|
@@ -27,6 +27,8 @@ class Puppet::Transaction::Event
|
|
27
27
|
|
28
28
|
def initialize(options = {})
|
29
29
|
@audited = false
|
30
|
+
@redacted = false
|
31
|
+
@corrective_change = false
|
30
32
|
|
31
33
|
set_options(options)
|
32
34
|
@time = Time.now
|
@@ -43,6 +45,8 @@ class Puppet::Transaction::Event
|
|
43
45
|
@status = data['status']
|
44
46
|
@time = data['time']
|
45
47
|
@time = Time.parse(@time) if @time.is_a? String
|
48
|
+
@redacted = data.fetch('redacted', false)
|
49
|
+
@corrective_change = data['corrective_change']
|
46
50
|
end
|
47
51
|
|
48
52
|
def to_data_hash
|
@@ -56,10 +60,13 @@ class Puppet::Transaction::Event
|
|
56
60
|
'name' => @name,
|
57
61
|
'status' => @status,
|
58
62
|
'time' => @time.iso8601(9),
|
63
|
+
'redacted' => @redacted,
|
64
|
+
'corrective_change' => @corrective_change,
|
59
65
|
}
|
60
66
|
end
|
61
67
|
|
62
68
|
def property=(prop)
|
69
|
+
@property_instance = prop
|
63
70
|
@property = prop.to_s
|
64
71
|
end
|
65
72
|
|
@@ -91,6 +98,26 @@ class Puppet::Transaction::Event
|
|
91
98
|
YAML_ATTRIBUTES & super
|
92
99
|
end
|
93
100
|
|
101
|
+
# Calculate and set the corrective_change parameter, based on the old_system_value of the property.
|
102
|
+
# @param [Object] old_system_value system_value from last transaction
|
103
|
+
# @return [bool] true if this is a corrective_change
|
104
|
+
def calculate_corrective_change(old_system_value)
|
105
|
+
# Only idempotent properties, and cases where we have an old system_value
|
106
|
+
# are corrective_changes.
|
107
|
+
if @property_instance.idempotent? &&
|
108
|
+
!@property_instance.sensitive &&
|
109
|
+
!old_system_value.nil?
|
110
|
+
|
111
|
+
# If the values aren't insync, we have confirmed a corrective_change
|
112
|
+
insync = @property_instance.insync_values?(old_system_value, previous_value)
|
113
|
+
|
114
|
+
# Preserve the nil state, but flip true/false
|
115
|
+
@corrective_change = insync.nil? ? nil : !insync
|
116
|
+
else
|
117
|
+
@corrective_change = false
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
94
121
|
private
|
95
122
|
|
96
123
|
# If it's a failure, use 'err', else use either the resource's log level (if available)
|
@@ -13,7 +13,7 @@ class Puppet::Transaction::EventManager
|
|
13
13
|
# @!attribute [r] events
|
14
14
|
# @todo Determine if this instance variable is used for anything aside from testing.
|
15
15
|
# @return [Array<Puppet::Transaction::Events>] A list of events that can be
|
16
|
-
# handled by the target
|
16
|
+
# handled by the target resource. Events that cannot be handled by the
|
17
17
|
# target resource will be discarded.
|
18
18
|
attr_reader :events
|
19
19
|
|
@@ -0,0 +1,84 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'puppet/util/yaml'
|
3
|
+
|
4
|
+
# A persistence store implementation for storing information between
|
5
|
+
# transaction runs for the purposes of information inference (such
|
6
|
+
# as calculating corrective_change).
|
7
|
+
# @api private
|
8
|
+
class Puppet::Transaction::Persistence
|
9
|
+
def initialize
|
10
|
+
@old_data = {}
|
11
|
+
@new_data = {"resources" => {}}
|
12
|
+
end
|
13
|
+
|
14
|
+
# Obtain the full raw data from the persistence store.
|
15
|
+
# @return [Hash] hash of data stored in persistence store
|
16
|
+
def data
|
17
|
+
@old_data
|
18
|
+
end
|
19
|
+
|
20
|
+
# Retrieve the system value using the resource and parameter name
|
21
|
+
# @param [String] resource_name name of resource
|
22
|
+
# @param [String] param_name name of the parameter
|
23
|
+
# @return [Object,nil] the system_value
|
24
|
+
def get_system_value(resource_name, param_name)
|
25
|
+
if !@old_data["resources"].nil? &&
|
26
|
+
!@old_data["resources"][resource_name].nil? &&
|
27
|
+
!@old_data["resources"][resource_name]["parameters"].nil? &&
|
28
|
+
!@old_data["resources"][resource_name]["parameters"][param_name].nil?
|
29
|
+
@old_data["resources"][resource_name]["parameters"][param_name]["system_value"]
|
30
|
+
else
|
31
|
+
nil
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def set_system_value(resource_name, param_name, value)
|
36
|
+
@new_data["resources"] ||= {}
|
37
|
+
@new_data["resources"][resource_name] ||= {}
|
38
|
+
@new_data["resources"][resource_name]["parameters"] ||= {}
|
39
|
+
@new_data["resources"][resource_name]["parameters"][param_name] ||= {}
|
40
|
+
@new_data["resources"][resource_name]["parameters"][param_name]["system_value"] = value
|
41
|
+
end
|
42
|
+
|
43
|
+
# Load data from the persistence store on disk.
|
44
|
+
def load
|
45
|
+
filename = Puppet[:transactionstorefile]
|
46
|
+
unless Puppet::FileSystem.exist?(filename)
|
47
|
+
return
|
48
|
+
end
|
49
|
+
unless File.file?(filename)
|
50
|
+
Puppet.warning("Transaction store file #{filename} is not a file, ignoring")
|
51
|
+
return
|
52
|
+
end
|
53
|
+
|
54
|
+
result = nil
|
55
|
+
Puppet::Util.benchmark(:debug, "Loaded transaction store file") do
|
56
|
+
begin
|
57
|
+
result = Puppet::Util::Yaml.load_file(filename, false, true)
|
58
|
+
rescue Puppet::Util::Yaml::YamlLoadError => detail
|
59
|
+
Puppet.log_exception(detail, "Transaction store file #{filename} is corrupt (#{detail}); replacing", { :level => :warning })
|
60
|
+
|
61
|
+
begin
|
62
|
+
File.rename(filename, filename + ".bad")
|
63
|
+
rescue => detail
|
64
|
+
Puppet.log_exception(detail, "Unable to rename corrupt transaction store file: #{detail}")
|
65
|
+
raise Puppet::Error, "Could not rename corrupt transaction store file #{filename}; remove manually", detail.backtrace
|
66
|
+
end
|
67
|
+
|
68
|
+
result = {}
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
unless result.is_a?(Hash)
|
73
|
+
Puppet.err "Transaction store file #{filename} is valid YAML but not returning a hash. Check the file for corruption, or remove it before continuing."
|
74
|
+
return
|
75
|
+
end
|
76
|
+
|
77
|
+
@old_data = result
|
78
|
+
end
|
79
|
+
|
80
|
+
# Save data from internal class to persistence store on disk.
|
81
|
+
def save
|
82
|
+
Puppet::Util::Yaml.dump(@new_data, Puppet[:transactionstorefile])
|
83
|
+
end
|
84
|
+
end
|
@@ -59,6 +59,10 @@ class Puppet::Transaction::Report
|
|
59
59
|
# or 'on_failure'
|
60
60
|
attr_accessor :cached_catalog_status
|
61
61
|
|
62
|
+
# Contains the name and port of the master that was successfully contacted
|
63
|
+
# @return [String] a string of the format 'servername:port'
|
64
|
+
attr_accessor :master_used
|
65
|
+
|
62
66
|
# The host name for which the report is generated
|
63
67
|
# @return [String] the host name
|
64
68
|
attr_accessor :host
|
@@ -67,6 +71,11 @@ class Puppet::Transaction::Report
|
|
67
71
|
# @return [String] the environment name
|
68
72
|
attr_accessor :environment
|
69
73
|
|
74
|
+
# Whether there are changes that we decided not to apply because of noop
|
75
|
+
# @return [Boolean]
|
76
|
+
#
|
77
|
+
attr_accessor :noop_pending
|
78
|
+
|
70
79
|
# A hash with a map from resource to status
|
71
80
|
# @return [Hash{String => Puppet::Resource::Status}] Resource name to status.
|
72
81
|
attr_reader :resource_statuses
|
@@ -108,6 +117,16 @@ class Puppet::Transaction::Report
|
|
108
117
|
#
|
109
118
|
attr_reader :report_format
|
110
119
|
|
120
|
+
# Whether the puppet run was started in noop mode
|
121
|
+
# @return [Boolean]
|
122
|
+
#
|
123
|
+
attr_reader :noop
|
124
|
+
|
125
|
+
# @!attribute [r] corrective_change
|
126
|
+
# @return [Boolean] true if the report contains any events and resources that had
|
127
|
+
# corrective changes.
|
128
|
+
attr_reader :corrective_change
|
129
|
+
|
111
130
|
def self.from_data_hash(data)
|
112
131
|
obj = self.allocate
|
113
132
|
obj.initialize_from_hash(data)
|
@@ -157,6 +176,11 @@ class Puppet::Transaction::Report
|
|
157
176
|
end
|
158
177
|
end
|
159
178
|
|
179
|
+
# @api private
|
180
|
+
def has_noop_events?(resource)
|
181
|
+
resource.events.any? { |event| event.status == 'noop' }
|
182
|
+
end
|
183
|
+
|
160
184
|
# @api private
|
161
185
|
def prune_internal_data
|
162
186
|
resource_statuses.delete_if {|name,res| res.resource_type == 'Whit'}
|
@@ -165,6 +189,7 @@ class Puppet::Transaction::Report
|
|
165
189
|
# @api private
|
166
190
|
def finalize_report
|
167
191
|
prune_internal_data
|
192
|
+
calculate_report_corrective_change
|
168
193
|
|
169
194
|
resource_metrics = add_metric(:resources, calculate_resource_metrics)
|
170
195
|
add_metric(:time, calculate_time_metrics)
|
@@ -172,6 +197,7 @@ class Puppet::Transaction::Report
|
|
172
197
|
add_metric(:changes, {"total" => change_metric})
|
173
198
|
add_metric(:events, calculate_event_metrics)
|
174
199
|
@status = compute_status(resource_metrics, change_metric)
|
200
|
+
@noop_pending = @resource_statuses.any? { |name,res| has_noop_events?(res) }
|
175
201
|
end
|
176
202
|
|
177
203
|
# @api private
|
@@ -183,15 +209,19 @@ class Puppet::Transaction::Report
|
|
183
209
|
@host = Puppet[:node_name_value]
|
184
210
|
@time = Time.now
|
185
211
|
@kind = kind
|
186
|
-
@report_format =
|
212
|
+
@report_format = 6
|
187
213
|
@puppet_version = Puppet.version
|
188
214
|
@configuration_version = configuration_version
|
189
215
|
@transaction_uuid = transaction_uuid
|
190
216
|
@code_id = nil
|
191
217
|
@catalog_uuid = nil
|
192
218
|
@cached_catalog_status = nil
|
219
|
+
@master_used = nil
|
193
220
|
@environment = environment
|
194
221
|
@status = 'failed' # assume failed until the report is finalized
|
222
|
+
@noop = Puppet[:noop]
|
223
|
+
@noop_pending = false
|
224
|
+
@corrective_change = false
|
195
225
|
end
|
196
226
|
|
197
227
|
# @api private
|
@@ -202,8 +232,15 @@ class Puppet::Transaction::Report
|
|
202
232
|
@transaction_uuid = data['transaction_uuid']
|
203
233
|
@environment = data['environment']
|
204
234
|
@status = data['status']
|
235
|
+
@noop = data['noop']
|
236
|
+
@noop_pending = data['noop_pending']
|
205
237
|
@host = data['host']
|
206
238
|
@time = data['time']
|
239
|
+
@corrective_change = data['corrective_change']
|
240
|
+
|
241
|
+
if master_used = data['master_used']
|
242
|
+
@master_used = master_used
|
243
|
+
end
|
207
244
|
|
208
245
|
if catalog_uuid = data['catalog_uuid']
|
209
246
|
@catalog_uuid = catalog_uuid
|
@@ -255,11 +292,14 @@ class Puppet::Transaction::Report
|
|
255
292
|
'puppet_version' => @puppet_version,
|
256
293
|
'kind' => @kind,
|
257
294
|
'status' => @status,
|
295
|
+
'noop' => @noop,
|
296
|
+
'noop_pending' => @noop_pending,
|
258
297
|
'environment' => @environment,
|
259
|
-
|
298
|
+
'master_used' => @master_used,
|
260
299
|
'logs' => @logs,
|
261
300
|
'metrics' => @metrics,
|
262
301
|
'resource_statuses' => @resource_statuses,
|
302
|
+
'corrective_change' => @corrective_change,
|
263
303
|
}
|
264
304
|
end
|
265
305
|
|
@@ -354,6 +394,13 @@ class Puppet::Transaction::Report
|
|
354
394
|
|
355
395
|
private
|
356
396
|
|
397
|
+
# Mark the report as corrective, if there are any resource_status marked corrective.
|
398
|
+
def calculate_report_corrective_change
|
399
|
+
@corrective_change = resource_statuses.any? do |name, status|
|
400
|
+
status.corrective_change
|
401
|
+
end
|
402
|
+
end
|
403
|
+
|
357
404
|
def calculate_change_metric
|
358
405
|
resource_statuses.map { |name, status| status.change_count || 0 }.inject(0) { |a,b| a+b }
|
359
406
|
end
|
@@ -10,6 +10,7 @@ class Puppet::Transaction::ResourceHarness
|
|
10
10
|
|
11
11
|
def initialize(transaction)
|
12
12
|
@transaction = transaction
|
13
|
+
@persistence = transaction.persistence
|
13
14
|
end
|
14
15
|
|
15
16
|
def evaluate(resource)
|
@@ -92,6 +93,25 @@ class Puppet::Transaction::ResourceHarness
|
|
92
93
|
end
|
93
94
|
|
94
95
|
capture_audit_events(resource, context)
|
96
|
+
persist_system_values(resource, context)
|
97
|
+
end
|
98
|
+
|
99
|
+
# We persist the last known values for the properties of a resource after resource
|
100
|
+
# application.
|
101
|
+
# @param [Puppet::Type] resource resource whose values we are to persist.
|
102
|
+
# @param [ResourceApplicationContent] context the application context to operate on.
|
103
|
+
def persist_system_values(resource, context)
|
104
|
+
param_to_event = {}
|
105
|
+
context.status.events.each do |ev|
|
106
|
+
param_to_event[ev.property] = ev
|
107
|
+
end
|
108
|
+
|
109
|
+
context.system_value_params.each do |pname, param|
|
110
|
+
@persistence.set_system_value(resource.ref, pname.to_s,
|
111
|
+
new_system_value(param,
|
112
|
+
param_to_event[pname.to_s],
|
113
|
+
@persistence.get_system_value(resource.ref, pname.to_s)))
|
114
|
+
end
|
95
115
|
end
|
96
116
|
|
97
117
|
def sync_if_needed(param, context)
|
@@ -103,7 +123,7 @@ class Puppet::Transaction::ResourceHarness
|
|
103
123
|
if param.should && !param.safe_insync?(current_value)
|
104
124
|
event = create_change_event(param, current_value, historical_value)
|
105
125
|
if do_audit
|
106
|
-
event = audit_event(event, param)
|
126
|
+
event = audit_event(event, param, context)
|
107
127
|
end
|
108
128
|
|
109
129
|
brief_audit_message = audit_message(param, do_audit, historical_value, current_value)
|
@@ -124,16 +144,21 @@ class Puppet::Transaction::ResourceHarness
|
|
124
144
|
|
125
145
|
event = create_change_event(param, current_value, historical_value)
|
126
146
|
event.status = "failure"
|
127
|
-
event.message = "change from
|
147
|
+
event.message = param.format("change from %s to %s failed: #{detail}",
|
148
|
+
param.is_to_s(current_value),
|
149
|
+
param.should_to_s(param.should))
|
128
150
|
event
|
129
151
|
rescue Exception => detail
|
130
152
|
# Execution will halt on Exceptions, they get raised to the application
|
131
153
|
event = create_change_event(param, current_value, historical_value)
|
132
154
|
event.status = "failure"
|
133
|
-
event.message = "change from
|
155
|
+
event.message = param.format("change from %s to %s failed: #{detail}",
|
156
|
+
param.is_to_s(current_value),
|
157
|
+
param.should_to_s(param.should))
|
134
158
|
raise
|
135
159
|
ensure
|
136
160
|
if event
|
161
|
+
event.calculate_corrective_change(@persistence.get_system_value(context.resource.ref, param.name.to_s))
|
137
162
|
context.record(event)
|
138
163
|
event.send_log
|
139
164
|
context.synced_params << param.name
|
@@ -142,12 +167,20 @@ class Puppet::Transaction::ResourceHarness
|
|
142
167
|
end
|
143
168
|
|
144
169
|
def create_change_event(property, current_value, historical_value)
|
145
|
-
|
146
|
-
|
147
|
-
event.desired_value = property.should
|
148
|
-
event.historical_value = historical_value
|
170
|
+
options = {}
|
171
|
+
should = property.should
|
149
172
|
|
150
|
-
|
173
|
+
if property.sensitive
|
174
|
+
options[:previous_value] = current_value.nil? ? nil : '[redacted]'
|
175
|
+
options[:desired_value] = should.nil? ? nil : '[redacted]'
|
176
|
+
options[:historical_value] = historical_value.nil? ? nil : '[redacted]'
|
177
|
+
else
|
178
|
+
options[:previous_value] = current_value
|
179
|
+
options[:desired_value] = should
|
180
|
+
options[:historical_value] = historical_value
|
181
|
+
end
|
182
|
+
|
183
|
+
property.event(options)
|
151
184
|
end
|
152
185
|
|
153
186
|
# This method is an ugly hack because, given a Time object with nanosecond
|
@@ -162,11 +195,23 @@ class Puppet::Transaction::ResourceHarness
|
|
162
195
|
end
|
163
196
|
private :are_audited_values_equal
|
164
197
|
|
165
|
-
|
198
|
+
# Populate an existing event with audit information.
|
199
|
+
#
|
200
|
+
# @param event [Puppet::Transaction::Event] The event to be populated.
|
201
|
+
# @param property [Puppet::Property] The property being audited.
|
202
|
+
# @param context [ResourceApplicationContext]
|
203
|
+
#
|
204
|
+
# @return [Puppet::Transaction::Event] The given event, populated with the audit information.
|
205
|
+
def audit_event(event, property, context)
|
166
206
|
event.audited = true
|
167
207
|
event.status = "audit"
|
168
|
-
|
169
|
-
|
208
|
+
|
209
|
+
# The event we've been provided might have been redacted so we need to use the state stored within
|
210
|
+
# the resource application context to see if an event was actually generated.
|
211
|
+
if !are_audited_values_equal(context.historical_values[property.name], context.current_values[property.name])
|
212
|
+
event.message = property.format("audit change: previously recorded value %s has been changed to %s",
|
213
|
+
property.is_to_s(event.historical_value),
|
214
|
+
property.is_to_s(event.previous_value))
|
170
215
|
end
|
171
216
|
|
172
217
|
event
|
@@ -174,20 +219,26 @@ class Puppet::Transaction::ResourceHarness
|
|
174
219
|
|
175
220
|
def audit_message(param, do_audit, historical_value, current_value)
|
176
221
|
if do_audit && historical_value && !are_audited_values_equal(historical_value, current_value)
|
177
|
-
" (previously recorded value was
|
222
|
+
param.format(" (previously recorded value was %s)", param.is_to_s(historical_value))
|
178
223
|
else
|
179
224
|
""
|
180
225
|
end
|
181
226
|
end
|
182
227
|
|
183
228
|
def noop(event, param, current_value, audit_message)
|
184
|
-
event.message =
|
229
|
+
event.message = param.format("current_value %s, should be %s (noop)#{audit_message}",
|
230
|
+
param.is_to_s(current_value),
|
231
|
+
param.should_to_s(param.should))
|
185
232
|
event.status = "noop"
|
186
233
|
end
|
187
234
|
|
188
235
|
def sync(event, param, current_value, audit_message)
|
189
236
|
param.sync
|
190
|
-
|
237
|
+
if param.sensitive
|
238
|
+
event.message = param.format("changed %s to %s#{audit_message}", param.is_to_s(current_value), param.should_to_s(param.should))
|
239
|
+
else
|
240
|
+
event.message = "#{param.change_to_s(current_value, param.should)}#{audit_message}"
|
241
|
+
end
|
191
242
|
event.status = "success"
|
192
243
|
end
|
193
244
|
|
@@ -199,30 +250,59 @@ class Puppet::Transaction::ResourceHarness
|
|
199
250
|
event = audit_event(create_change_event(parameter,
|
200
251
|
context.current_values[param_name],
|
201
252
|
context.historical_values[param_name]),
|
202
|
-
parameter)
|
253
|
+
parameter, context)
|
203
254
|
event.send_log
|
204
255
|
context.record(event)
|
205
256
|
end
|
206
257
|
else
|
207
|
-
resource.property(param_name)
|
258
|
+
property = resource.property(param_name)
|
259
|
+
property.notice(property.format("audit change: newly-recorded value %s", context.current_values[param_name]))
|
208
260
|
end
|
209
261
|
end
|
210
262
|
end
|
211
263
|
|
264
|
+
# Given an event and its property, calculate the system_value to persist
|
265
|
+
# for future calculations.
|
266
|
+
# @param [Puppet::Transaction::Event] event event to use for processing
|
267
|
+
# @param [Puppet::Property] property correlating property
|
268
|
+
# @param [Object] old_system_value system_value from last transaction
|
269
|
+
# @return [Object] system_value to be used for next transaction
|
270
|
+
def new_system_value(property, event, old_system_value)
|
271
|
+
if event && event.status != "success"
|
272
|
+
# For non-success events, we persist the old_system_value if it is defined,
|
273
|
+
# or use the event previous_value.
|
274
|
+
# If we're using the event previous_value, we ensure that it's
|
275
|
+
# an array. This is needed because properties assume that their
|
276
|
+
# `should` value is an array, and we will use this value later
|
277
|
+
# on in property insync? logic.
|
278
|
+
event_value = [event.previous_value] unless event.previous_value.is_a?(Array)
|
279
|
+
old_system_value.nil? ? event_value : old_system_value
|
280
|
+
else
|
281
|
+
# For non events, or for success cases, we just want to store
|
282
|
+
# the parameters agent value.
|
283
|
+
# We use instance_variable_get here because we want this process to bypass any
|
284
|
+
# munging/unmunging or validation that the property might try to do, since those
|
285
|
+
# operations may not be correctly implemented for custom types.
|
286
|
+
property.instance_variable_get(:@should)
|
287
|
+
end
|
288
|
+
end
|
289
|
+
|
212
290
|
# @api private
|
213
291
|
ResourceApplicationContext = Struct.new(:resource,
|
214
292
|
:current_values,
|
215
293
|
:historical_values,
|
216
294
|
:audited_params,
|
217
295
|
:synced_params,
|
218
|
-
:status
|
296
|
+
:status,
|
297
|
+
:system_value_params) do
|
219
298
|
def self.from_resource(resource, status)
|
220
299
|
ResourceApplicationContext.new(resource,
|
221
300
|
resource.retrieve_resource.to_hash,
|
222
301
|
Puppet::Util::Storage.cache(resource).dup,
|
223
302
|
(resource[:audit] || []).map { |p| p.to_sym },
|
224
303
|
[],
|
225
|
-
status
|
304
|
+
status,
|
305
|
+
resource.parameters.select { |n,p| p.is_a?(Puppet::Property) && !p.sensitive })
|
226
306
|
end
|
227
307
|
|
228
308
|
def resource_present?
|