puppet 5.3.7-universal-darwin → 5.4.0-universal-darwin
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 +4 -4
- data/CONTRIBUTING.md +42 -29
- data/README.md +8 -6
- data/ext/cert_inspector +2 -2
- data/ext/envpuppet +1 -1
- data/ext/gentoo/init.d/puppetmaster +4 -4
- data/ext/ips/puppet-agent +11 -11
- data/ext/ips/puppet-master +11 -11
- data/ext/puppet-test +1 -2
- data/ext/redhat/client.init +2 -2
- data/ext/redhat/logrotate +1 -1
- data/ext/solaris/smf/puppet +11 -11
- data/ext/solaris/smf/svc-puppetd +5 -5
- data/ext/solaris/smf/svc-puppetmasterd +5 -5
- data/ext/windows/service/daemon.rb +1 -1
- data/install.rb +2 -3
- data/lib/puppet/agent.rb +1 -1
- data/lib/puppet/application/cert.rb +1 -3
- data/lib/puppet/application/describe.rb +0 -1
- data/lib/puppet/application/device.rb +12 -99
- data/lib/puppet/application/filebucket.rb +32 -11
- data/lib/puppet/application/lookup.rb +1 -11
- data/lib/puppet/application/script.rb +261 -0
- data/lib/puppet/configurer.rb +3 -4
- data/lib/puppet/configurer/plugin_handler.rb +26 -9
- data/lib/puppet/context.rb +1 -1
- data/lib/puppet/datatypes.rb +213 -0
- data/lib/puppet/datatypes/error.rb +21 -0
- data/lib/puppet/datatypes/impl/error.rb +40 -0
- data/lib/puppet/defaults.rb +51 -20
- data/lib/puppet/environments.rb +17 -0
- data/lib/puppet/error.rb +17 -0
- data/lib/puppet/etc.rb +2 -2
- data/lib/puppet/external/pson/pure/generator.rb +1 -1
- data/lib/puppet/external/pson/pure/parser.rb +1 -1
- data/lib/puppet/face/config.rb +45 -0
- data/lib/puppet/face/epp.rb +3 -3
- data/lib/puppet/face/help/action.erb +3 -0
- data/lib/puppet/face/module/build.rb +1 -0
- data/lib/puppet/face/module/generate.rb +5 -0
- data/lib/puppet/face/module/install.rb +1 -0
- data/lib/puppet/face/module/search.rb +6 -2
- data/lib/puppet/face/module/uninstall.rb +1 -0
- data/lib/puppet/face/module/upgrade.rb +1 -0
- data/lib/puppet/face/parser.rb +0 -1
- data/lib/puppet/face/plugin.rb +1 -3
- data/lib/puppet/feature/base.rb +1 -1
- data/lib/puppet/feature/bolt.rb +3 -0
- data/lib/puppet/file_bucket/dipper.rb +1 -2
- data/lib/puppet/file_serving/http_metadata.rb +1 -1
- data/lib/puppet/file_system/uniquefile.rb +2 -2
- data/lib/puppet/forge.rb +6 -0
- data/lib/puppet/functions.rb +70 -88
- data/lib/puppet/functions/all.rb +6 -2
- data/lib/puppet/functions/annotate.rb +1 -1
- data/lib/puppet/functions/any.rb +7 -3
- data/lib/puppet/functions/contain.rb +6 -0
- data/lib/puppet/functions/convert_to.rb +32 -0
- data/lib/puppet/functions/defined.rb +0 -3
- data/lib/puppet/functions/each.rb +10 -6
- data/lib/puppet/functions/filter.rb +16 -10
- data/lib/puppet/functions/find_file.rb +0 -1
- data/lib/puppet/functions/include.rb +6 -0
- data/lib/puppet/functions/map.rb +12 -9
- data/lib/puppet/functions/module_directory.rb +41 -0
- data/lib/puppet/functions/new.rb +1 -4
- data/lib/puppet/functions/regsubst.rb +1 -1
- data/lib/puppet/functions/require.rb +6 -0
- data/lib/puppet/generate/type.rb +1 -1
- data/lib/puppet/gettext/config.rb +2 -2
- data/lib/puppet/gettext/stubs.rb +1 -1
- data/lib/puppet/indirector/catalog/compiler.rb +0 -1
- data/lib/puppet/indirector/file_bucket_file/file.rb +6 -2
- data/lib/puppet/indirector/file_server.rb +1 -1
- data/lib/puppet/indirector/node/ldap.rb +19 -3
- data/lib/puppet/indirector/request.rb +10 -6
- data/lib/puppet/indirector/rest.rb +11 -12
- data/lib/puppet/info_service/class_information_service.rb +1 -1
- data/lib/puppet/interface/action.rb +11 -0
- data/lib/puppet/interface/action_builder.rb +8 -0
- data/lib/puppet/interface/option_manager.rb +1 -1
- data/lib/puppet/loaders.rb +2 -0
- data/lib/puppet/module.rb +6 -2
- data/lib/puppet/module_tool/applications/builder.rb +4 -0
- data/lib/puppet/module_tool/applications/installer.rb +3 -0
- data/lib/puppet/module_tool/applications/uninstaller.rb +3 -0
- data/lib/puppet/module_tool/applications/unpacker.rb +1 -1
- data/lib/puppet/module_tool/applications/upgrader.rb +3 -0
- data/lib/puppet/module_tool/installed_modules.rb +1 -1
- data/lib/puppet/module_tool/metadata.rb +0 -1
- data/lib/puppet/network/authstore.rb +1 -1
- data/lib/puppet/network/http/api/indirected_routes.rb +1 -1
- data/lib/puppet/network/http/connection.rb +1 -9
- data/lib/puppet/network/http/factory.rb +0 -3
- data/lib/puppet/network/http/webrick.rb +1 -0
- data/lib/puppet/network/rights.rb +1 -1
- data/lib/puppet/node.rb +53 -0
- data/lib/puppet/node/environment.rb +1 -1
- data/lib/puppet/parameter/boolean.rb +1 -1
- data/lib/puppet/parser.rb +1 -0
- data/lib/puppet/parser/abstract_compiler.rb +36 -0
- data/lib/puppet/parser/ast/branch.rb +1 -1
- data/lib/puppet/parser/ast/pops_bridge.rb +8 -52
- data/lib/puppet/parser/compiler.rb +4 -54
- data/lib/puppet/parser/functions.rb +0 -1
- data/lib/puppet/parser/functions/create_resources.rb +6 -0
- data/lib/puppet/parser/functions/fqdn_rand.rb +6 -2
- data/lib/puppet/parser/functions/inline_template.rb +6 -0
- data/lib/puppet/parser/functions/new.rb +47 -32
- data/lib/puppet/parser/functions/realize.rb +6 -0
- data/lib/puppet/parser/functions/return.rb +1 -22
- data/lib/puppet/parser/functions/reverse_each.rb +1 -1
- data/lib/puppet/parser/functions/scanf.rb +1 -1
- data/lib/puppet/parser/functions/sha256.rb +5 -0
- data/lib/puppet/parser/functions/tag.rb +6 -0
- data/lib/puppet/parser/functions/tagged.rb +6 -0
- data/lib/puppet/parser/functions/template.rb +5 -0
- data/lib/puppet/parser/scope.rb +28 -4
- data/lib/puppet/parser/script_compiler.rb +118 -0
- data/lib/puppet/parser/type_loader.rb +1 -1
- data/lib/puppet/pops.rb +1 -1
- data/lib/puppet/pops/evaluator/access_operator.rb +38 -4
- data/lib/puppet/pops/evaluator/closure.rb +12 -4
- data/lib/puppet/pops/evaluator/compare_operator.rb +4 -4
- data/lib/puppet/pops/evaluator/epp_evaluator.rb +13 -0
- data/lib/puppet/pops/evaluator/evaluator_impl.rb +38 -10
- data/lib/puppet/pops/evaluator/literal_evaluator.rb +1 -1
- data/lib/puppet/pops/evaluator/runtime3_converter.rb +1 -1
- data/lib/puppet/pops/evaluator/runtime3_support.rb +2 -3
- data/lib/puppet/pops/functions/dispatch.rb +6 -5
- data/lib/puppet/pops/functions/function.rb +2 -2
- data/lib/puppet/pops/issues.rb +34 -2
- data/lib/puppet/pops/loader/base_loader.rb +10 -0
- data/lib/puppet/pops/loader/dependency_loader.rb +7 -0
- data/lib/puppet/pops/loader/loader.rb +21 -2
- data/lib/puppet/pops/loader/loader_paths.rb +180 -30
- data/lib/puppet/pops/loader/module_loaders.rb +202 -33
- data/lib/puppet/pops/loader/puppet_plan_instantiator.rb +84 -0
- data/lib/puppet/pops/loader/puppet_resource_type_impl_instantiator.rb +9 -9
- data/lib/puppet/pops/loader/ruby_data_type_instantiator.rb +40 -0
- data/lib/puppet/pops/loader/runtime3_type_loader.rb +6 -1
- data/lib/puppet/pops/loader/static_loader.rb +23 -8
- data/lib/puppet/pops/loader/task_instantiator.rb +69 -0
- data/lib/puppet/pops/loader/type_definition_instantiator.rb +4 -0
- data/lib/puppet/pops/loaders.rb +122 -11
- data/lib/puppet/pops/lookup/data_dig_function_provider.rb +1 -1
- data/lib/puppet/pops/lookup/interpolation.rb +1 -1
- data/lib/puppet/pops/lookup/lookup_adapter.rb +0 -1
- data/lib/puppet/pops/model/ast.pp +3 -0
- data/lib/puppet/pops/model/ast.rb +34 -1
- data/lib/puppet/pops/model/factory.rb +30 -3
- data/lib/puppet/pops/model/model_label_provider.rb +1 -0
- data/lib/puppet/pops/model/model_tree_dumper.rb +12 -1
- data/lib/puppet/pops/model/tree_dumper.rb +1 -1
- data/lib/puppet/pops/parser/code_merger.rb +2 -2
- data/lib/puppet/pops/parser/egrammar.ra +44 -15
- data/lib/puppet/pops/parser/eparser.rb +1687 -1571
- data/lib/puppet/pops/parser/epp_support.rb +1 -3
- data/lib/puppet/pops/parser/evaluating_parser.rb +1 -1
- data/lib/puppet/pops/parser/interpolation_support.rb +2 -2
- data/lib/puppet/pops/parser/lexer2.rb +4 -4
- data/lib/puppet/pops/parser/lexer_support.rb +2 -2
- data/lib/puppet/pops/parser/locatable.rb +1 -1
- data/lib/puppet/pops/parser/locator.rb +7 -13
- data/lib/puppet/pops/parser/parser_support.rb +3 -3
- data/lib/puppet/pops/parser/slurp_support.rb +0 -3
- data/lib/puppet/pops/pcore.rb +45 -0
- data/lib/puppet/pops/resource/param.rb +1 -1
- data/lib/puppet/pops/resource/resource_type_impl.rb +1 -1
- data/lib/puppet/pops/serialization/abstract_reader.rb +4 -0
- data/lib/puppet/pops/serialization/abstract_writer.rb +6 -0
- data/lib/puppet/pops/serialization/extension.rb +1 -0
- data/lib/puppet/pops/serialization/from_data_converter.rb +64 -10
- data/lib/puppet/pops/serialization/json_path.rb +2 -1
- data/lib/puppet/pops/serialization/object.rb +3 -4
- data/lib/puppet/pops/serialization/serializer.rb +2 -1
- data/lib/puppet/pops/serialization/to_data_converter.rb +7 -3
- data/lib/puppet/pops/time/timespan.rb +1 -1
- data/lib/puppet/pops/types/iterable.rb +38 -9
- data/lib/puppet/pops/types/p_init_type.rb +1 -1
- data/lib/puppet/pops/types/p_meta_type.rb +4 -0
- data/lib/puppet/pops/types/p_object_type.rb +146 -14
- data/lib/puppet/pops/types/p_object_type_extension.rb +218 -0
- data/lib/puppet/pops/types/p_sem_ver_range_type.rb +0 -1
- data/lib/puppet/pops/types/p_sem_ver_type.rb +10 -2
- data/lib/puppet/pops/types/p_type_set_type.rb +0 -1
- data/lib/puppet/pops/types/p_uri_type.rb +190 -0
- data/lib/puppet/pops/types/puppet_object.rb +15 -1
- data/lib/puppet/pops/types/ruby_generator.rb +46 -54
- data/lib/puppet/pops/types/string_converter.rb +22 -1
- data/lib/puppet/pops/types/type_acceptor.rb +1 -1
- data/lib/puppet/pops/types/type_calculator.rb +13 -4
- data/lib/puppet/pops/types/type_factory.rb +29 -5
- data/lib/puppet/pops/types/type_formatter.rb +67 -4
- data/lib/puppet/pops/types/type_parser.rb +92 -4
- data/lib/puppet/pops/types/type_with_members.rb +43 -0
- data/lib/puppet/pops/types/types.rb +212 -80
- data/lib/puppet/pops/validation/checker4_0.rb +10 -6
- data/lib/puppet/pops/validation/tasks_checker.rb +60 -0
- data/lib/puppet/pops/validation/validator_factory_4_0.rb +6 -1
- data/lib/puppet/property.rb +1 -1
- data/lib/puppet/provider.rb +18 -8
- data/lib/puppet/provider/augeas/augeas.rb +3 -4
- data/lib/puppet/provider/exec.rb +0 -2
- data/lib/puppet/provider/group/groupadd.rb +25 -1
- data/lib/puppet/provider/group/windows_adsi.rb +7 -4
- data/lib/puppet/provider/mount.rb +25 -8
- data/lib/puppet/provider/nameservice.rb +9 -4
- data/lib/puppet/provider/nameservice/directoryservice.rb +3 -3
- data/lib/puppet/provider/nameservice/objectadd.rb +13 -24
- data/lib/puppet/provider/nameservice/pw.rb +14 -14
- data/lib/puppet/provider/package/appdmg.rb +0 -1
- data/lib/puppet/provider/package/apple.rb +0 -1
- data/lib/puppet/provider/package/gem.rb +2 -2
- data/lib/puppet/provider/package/macports.rb +2 -2
- data/lib/puppet/provider/package/pkg.rb +3 -0
- data/lib/puppet/provider/package/pkgdmg.rb +0 -1
- data/lib/puppet/provider/package/portage.rb +0 -1
- data/lib/puppet/provider/package/yum.rb +23 -8
- data/lib/puppet/provider/package/zypper.rb +2 -2
- data/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +2 -2
- data/lib/puppet/provider/service/init.rb +1 -0
- data/lib/puppet/provider/service/launchd.rb +6 -7
- data/lib/puppet/provider/service/redhat.rb +3 -2
- data/lib/puppet/provider/service/systemd.rb +2 -2
- 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/openbsd.rb +1 -1
- data/lib/puppet/provider/user/pw.rb +1 -1
- data/lib/puppet/provider/user/user_role_add.rb +7 -1
- data/lib/puppet/provider/user/useradd.rb +36 -6
- data/lib/puppet/provider/user/windows_adsi.rb +1 -1
- data/lib/puppet/provider/yumrepo/inifile.rb +2 -4
- data/lib/puppet/provider/zfs/zfs.rb +23 -3
- data/lib/puppet/provider/zpool/zpool.rb +1 -1
- data/lib/puppet/reference/configuration.rb +0 -2
- data/lib/puppet/reference/type.rb +0 -1
- data/lib/puppet/resource.rb +1 -2
- data/lib/puppet/resource/catalog.rb +1 -1
- data/lib/puppet/resource/status.rb +0 -1
- data/lib/puppet/resource/type.rb +4 -4
- data/lib/puppet/resource/type_collection.rb +1 -1
- data/lib/puppet/settings/base_setting.rb +1 -1
- data/lib/puppet/settings/environment_conf.rb +0 -1
- data/lib/puppet/settings/ini_file.rb +66 -12
- data/lib/puppet/ssl/certificate_authority.rb +1 -1
- data/lib/puppet/ssl/certificate_request.rb +2 -2
- data/lib/puppet/ssl/certificate_revocation_list.rb +2 -1
- data/lib/puppet/ssl/certificate_signer.rb +11 -0
- data/lib/puppet/ssl/host.rb +2 -2
- data/lib/puppet/syntax_checkers/base64.rb +1 -1
- data/lib/puppet/transaction.rb +37 -14
- data/lib/puppet/transaction/report.rb +3 -1
- data/lib/puppet/type.rb +17 -4
- data/lib/puppet/type/cron.rb +1 -1
- data/lib/puppet/type/exec.rb +5 -4
- data/lib/puppet/type/file.rb +3 -3
- data/lib/puppet/type/file/checksum.rb +7 -1
- data/lib/puppet/type/file/checksum_value.rb +4 -3
- data/lib/puppet/type/group.rb +3 -0
- data/lib/puppet/type/k5login.rb +101 -0
- data/lib/puppet/type/macauthorization.rb +1 -1
- data/lib/puppet/type/mount.rb +6 -2
- data/lib/puppet/type/tidy.rb +6 -4
- data/lib/puppet/type/user.rb +26 -39
- data/lib/puppet/type/yumrepo.rb +9 -0
- data/lib/puppet/type/zfs.rb +4 -0
- data/lib/puppet/util.rb +8 -15
- data/lib/puppet/util/character_encoding.rb +2 -2
- data/lib/puppet/util/checksums.rb +82 -1
- data/lib/puppet/util/errors.rb +0 -2
- data/lib/puppet/util/filetype.rb +2 -2
- data/lib/puppet/util/json_lockfile.rb +1 -1
- data/lib/puppet/util/log.rb +1 -1
- data/lib/puppet/util/log/destinations.rb +10 -1
- data/lib/puppet/util/monkey_patches.rb +1 -1
- data/lib/puppet/util/network_device/cisco/device.rb +5 -5
- data/lib/puppet/util/network_device/config.rb +2 -3
- data/lib/puppet/util/platform.rb +13 -0
- data/lib/puppet/util/plist.rb +4 -4
- data/lib/puppet/util/rdoc/generators/puppet_generator.rb +2 -2
- data/lib/puppet/util/rdoc/parser/puppet_parser_rdoc2.rb +1 -1
- data/lib/puppet/util/reference.rb +8 -1
- data/lib/puppet/util/windows/adsi.rb +18 -15
- data/lib/puppet/util/windows/principal.rb +6 -7
- data/lib/puppet/util/windows/process.rb +1 -1
- data/lib/puppet/util/windows/registry.rb +2 -2
- data/lib/puppet/util/windows/sid.rb +7 -62
- data/lib/puppet/vendor/deep_merge/README.md +2 -2
- data/lib/puppet/vendor/pathspec/lib/pathspec/gitignorespec.rb +18 -18
- data/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/version.rb +2 -2
- data/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/version_range.rb +5 -5
- data/lib/puppet/vendor/semantic_puppet/locales/config.yaml +1 -1
- data/lib/puppet/version.rb +1 -1
- data/lib/puppet_pal.rb +874 -0
- data/locales/ja/puppet.po +140 -163
- data/locales/puppet.pot +940 -597
- data/man/man5/puppet.conf.5 +16 -91
- data/man/man8/puppet-agent.8 +2 -6
- data/man/man8/puppet-apply.8 +2 -2
- data/man/man8/puppet-ca.8 +1 -1
- data/man/man8/puppet-catalog.8 +1 -1
- data/man/man8/puppet-cert.8 +1 -1
- data/man/man8/puppet-certificate.8 +1 -1
- data/man/man8/puppet-certificate_request.8 +1 -1
- data/man/man8/puppet-certificate_revocation_list.8 +1 -1
- data/man/man8/puppet-config.8 +1 -1
- data/man/man8/puppet-describe.8 +1 -1
- data/man/man8/puppet-device.8 +11 -33
- data/man/man8/puppet-doc.8 +1 -1
- data/man/man8/puppet-epp.8 +1 -1
- data/man/man8/puppet-facts.8 +1 -1
- data/man/man8/puppet-filebucket.8 +4 -22
- data/man/man8/puppet-generate.8 +1 -1
- data/man/man8/puppet-help.8 +1 -1
- data/man/man8/puppet-key.8 +1 -1
- data/man/man8/puppet-lookup.8 +1 -1
- data/man/man8/puppet-man.8 +1 -1
- data/man/man8/puppet-master.8 +1 -1
- data/man/man8/puppet-module.8 +2 -11
- data/man/man8/puppet-node.8 +1 -1
- data/man/man8/puppet-parser.8 +1 -1
- data/man/man8/puppet-plugin.8 +1 -1
- data/man/man8/puppet-report.8 +1 -1
- data/man/man8/puppet-resource.8 +1 -1
- data/man/man8/puppet-status.8 +1 -1
- data/man/man8/puppet.8 +2 -2
- data/spec/integration/application/lookup_spec.rb +0 -21
- data/spec/integration/parser/compiler_spec.rb +18 -0
- data/spec/integration/parser/script_compiler_spec.rb +113 -0
- data/spec/integration/provider/mount_spec.rb +2 -0
- data/spec/integration/type/file_spec.rb +11 -3
- data/spec/integration/util/windows/adsi_spec.rb +1 -86
- data/spec/integration/util/windows/principal_spec.rb +1 -10
- data/spec/shared_contexts/checksum.rb +4 -1
- data/spec/shared_contexts/digests.rb +46 -1
- data/spec/shared_contexts/types_setup.rb +8 -3
- data/spec/unit/agent_spec.rb +2 -2
- data/spec/unit/application/cert_spec.rb +5 -17
- data/spec/unit/application/device_spec.rb +2 -96
- data/spec/unit/application/filebucket_spec.rb +18 -4
- data/spec/unit/configurer/plugin_handler_spec.rb +5 -32
- data/spec/unit/configurer_spec.rb +3 -3
- data/spec/unit/datatypes_spec.rb +304 -0
- data/spec/unit/defaults_spec.rb +41 -20
- data/spec/unit/face/config_spec.rb +46 -1
- data/spec/unit/face/epp_face_spec.rb +7 -3
- data/spec/unit/face/module/search_spec.rb +11 -0
- data/spec/unit/face/parser_spec.rb +2 -2
- data/spec/unit/file_bucket/dipper_spec.rb +12 -1
- data/spec/unit/forge/module_release_spec.rb +70 -0
- data/spec/unit/functions/break_spec.rb +34 -2
- data/spec/unit/functions/contain_spec.rb +1 -0
- data/spec/unit/functions/convert_to_spec.rb +22 -0
- data/spec/unit/functions/epp_spec.rb +5 -0
- data/spec/unit/functions/include_spec.rb +15 -0
- data/spec/unit/functions/module_directory_spec.rb +43 -0
- data/spec/unit/functions/new_spec.rb +14 -14
- data/spec/unit/functions/require_spec.rb +2 -0
- data/spec/unit/functions/shared.rb +12 -0
- data/spec/unit/functions/step_spec.rb +1 -1
- data/spec/unit/functions4_spec.rb +49 -4
- data/spec/unit/indirector/catalog/compiler_spec.rb +3 -3
- data/spec/unit/indirector/file_bucket_file/file_spec.rb +148 -94
- data/spec/unit/indirector/node/ldap_spec.rb +15 -12
- data/spec/unit/indirector/rest_spec.rb +0 -43
- data/spec/unit/interface/action_spec.rb +33 -0
- data/spec/unit/module_tool/applications/builder_spec.rb +7 -0
- data/spec/unit/module_tool/applications/installer_spec.rb +8 -0
- data/spec/unit/module_tool/applications/uninstaller_spec.rb +8 -0
- data/spec/unit/module_tool/applications/upgrader_spec.rb +6 -0
- data/spec/unit/network/http/connection_spec.rb +1 -1
- data/spec/unit/network/http/factory_spec.rb +28 -35
- data/spec/unit/parser/compiler_spec.rb +0 -8
- data/spec/unit/parser/environment_compiler_spec.rb +36 -0
- data/spec/unit/parser/functions/create_resources_spec.rb +9 -0
- data/spec/unit/parser/functions/inline_template_spec.rb +7 -0
- data/spec/unit/parser/functions/realize_spec.rb +9 -0
- data/spec/unit/parser/functions/tag_spec.rb +7 -0
- data/spec/unit/parser/functions/tagged_spec.rb +25 -0
- data/spec/unit/parser/functions/template_spec.rb +8 -0
- data/spec/unit/parser/scope_spec.rb +19 -0
- data/spec/unit/pops/evaluator/conditionals_spec.rb +1 -1
- data/spec/unit/pops/loaders/loader_spec.rb +516 -0
- data/spec/unit/pops/loaders/loaders_spec.rb +11 -0
- data/spec/unit/pops/loaders/module_loaders_spec.rb +43 -0
- data/spec/unit/pops/loaders/static_loader_spec.rb +15 -7
- data/spec/unit/pops/model/model_spec.rb +5 -0
- data/spec/unit/pops/parser/lexer2_spec.rb +15 -0
- data/spec/unit/pops/parser/locator_spec.rb +20 -0
- data/spec/unit/pops/parser/parse_basic_expressions_spec.rb +33 -0
- data/spec/unit/pops/parser/parse_calls_spec.rb +28 -0
- data/spec/unit/pops/parser/parse_conditionals_spec.rb +12 -0
- data/spec/unit/pops/parser/parse_plan_spec.rb +48 -0
- data/spec/unit/pops/serialization/packer_spec.rb +8 -0
- data/spec/unit/pops/serialization/serialization_spec.rb +30 -0
- data/spec/unit/pops/serialization/to_from_hr_spec.rb +31 -0
- data/spec/unit/pops/types/error_spec.rb +207 -0
- data/spec/unit/pops/types/p_init_type_spec.rb +98 -0
- data/spec/unit/pops/types/p_object_type_spec.rb +275 -10
- data/spec/unit/pops/types/p_uri_type_spec.rb +191 -0
- data/spec/unit/pops/types/ruby_generator_spec.rb +82 -44
- data/spec/unit/pops/types/task_spec.rb +353 -0
- data/spec/unit/pops/types/type_calculator_spec.rb +76 -5
- data/spec/unit/pops/types/type_formatter_spec.rb +31 -13
- data/spec/unit/pops/types/type_parser_spec.rb +13 -1
- data/spec/unit/pops/types/types_spec.rb +60 -0
- data/spec/unit/pops/validator/validator_spec.rb +76 -0
- data/spec/unit/provider/group/groupadd_spec.rb +77 -1
- data/spec/unit/provider/group/pw_spec.rb +4 -4
- data/spec/unit/provider/group/windows_adsi_spec.rb +22 -79
- data/spec/unit/provider/mount_spec.rb +18 -5
- data/spec/unit/provider/nameservice_spec.rb +5 -5
- data/spec/unit/provider/package/dnf_spec.rb +2 -2
- data/spec/unit/provider/package/gem_spec.rb +1 -1
- data/spec/unit/provider/package/pkg_spec.rb +3 -0
- data/spec/unit/provider/package/yum_spec.rb +40 -0
- data/spec/unit/provider/service/launchd_spec.rb +2 -1
- data/spec/unit/provider/service/redhat_spec.rb +5 -0
- data/spec/unit/provider/service/systemd_spec.rb +1 -1
- data/spec/unit/provider/user/hpux_spec.rb +2 -2
- data/spec/unit/provider/user/openbsd_spec.rb +2 -2
- data/spec/unit/provider/user/pw_spec.rb +14 -14
- data/spec/unit/provider/user/user_role_add_spec.rb +19 -2
- data/spec/unit/provider/user/useradd_spec.rb +188 -22
- data/spec/unit/provider/user/windows_adsi_spec.rb +4 -4
- data/spec/unit/provider/zfs/zfs_spec.rb +55 -1
- data/spec/unit/provider_spec.rb +48 -0
- data/spec/unit/puppet_pal_2pec.rb +1005 -0
- data/spec/unit/puppet_pal_spec.rb +11 -0
- data/spec/unit/settings/ini_file_spec.rb +313 -2
- data/spec/unit/ssl/certificate_request_spec.rb +42 -1
- data/spec/unit/ssl/certificate_revocation_list_spec.rb +2 -1
- data/spec/unit/transaction/report_spec.rb +1 -0
- data/spec/unit/transaction_spec.rb +112 -21
- data/spec/unit/type/file/checksum_spec.rb +20 -0
- data/spec/unit/type/file_spec.rb +8 -0
- data/spec/unit/type/group_spec.rb +8 -0
- data/spec/unit/type/k5login_spec.rb +22 -1
- data/spec/unit/type/scheduled_task_spec.rb +15 -0
- data/spec/unit/type/user_spec.rb +11 -1
- data/spec/unit/type/yumrepo_spec.rb +5 -0
- data/spec/unit/util/checksums_spec.rb +3 -3
- data/spec/unit/util/log/destinations_spec.rb +14 -0
- data/spec/unit/util/network_device/cisco/device_spec.rb +1 -1
- data/spec/unit/util/plist_spec.rb +3 -3
- data/spec/unit/util/windows/adsi_spec.rb +27 -31
- data/spec/unit/util/windows/sid_spec.rb +15 -86
- data/spec/unit/util_spec.rb +17 -3
- data/tasks/manpages.rake +1 -1
- metadata +218 -180
- data/lib/puppet/bindings.rb +0 -148
- data/lib/puppet/configurer/downloader_factory.rb +0 -44
- data/spec/unit/configurer/downloader_factory_spec.rb +0 -129
@@ -24,14 +24,14 @@ start)
|
|
24
24
|
;;
|
25
25
|
stop)
|
26
26
|
printf "Stopping Puppet server services:"
|
27
|
-
kill `cat $pidfile`
|
27
|
+
kill `cat "$pidfile"`
|
28
28
|
|
29
29
|
printf " puppetmasterd"
|
30
30
|
echo ""
|
31
31
|
;;
|
32
32
|
restart)
|
33
33
|
printf "Restarting Puppet server services:"
|
34
|
-
kill -HUP `cat $pidfile`
|
34
|
+
kill -HUP `cat "$pidfile"`
|
35
35
|
|
36
36
|
printf " puppetmasterd"
|
37
37
|
echo ""
|
@@ -39,14 +39,14 @@ restart)
|
|
39
39
|
reload)
|
40
40
|
printf "Reloading Puppet server services:"
|
41
41
|
|
42
|
-
kill -HUP `cat $pidfile`
|
42
|
+
kill -HUP `cat "$pidfile"`
|
43
43
|
|
44
44
|
printf " puppetmasterd"
|
45
45
|
echo ""
|
46
46
|
;;
|
47
47
|
status)
|
48
|
-
if [ -f $pidfile ]; then
|
49
|
-
pid=`cat $pidfile`
|
48
|
+
if [ -f "$pidfile" ]; then
|
49
|
+
pid=`cat "$pidfile"`
|
50
50
|
curpid=`pgrep puppetmasterd`
|
51
51
|
if [ "$pid" -eq "$curpid" ]; then
|
52
52
|
exit 0
|
data/install.rb
CHANGED
@@ -482,7 +482,6 @@ EOS
|
|
482
482
|
FileUtils.install(tmp_file2.path, File.join(target, "#{op_file}.bat"), :mode => 0755, :preserve => true, :verbose => true)
|
483
483
|
|
484
484
|
tmp_file2.unlink
|
485
|
-
installed_wrapper = true
|
486
485
|
end
|
487
486
|
end
|
488
487
|
end
|
@@ -495,8 +494,8 @@ FileUtils.cd File.dirname(__FILE__) do
|
|
495
494
|
# Set these values to what you want installed.
|
496
495
|
configs = glob(%w{conf/auth.conf conf/puppet.conf conf/hiera.yaml})
|
497
496
|
bins = glob(%w{bin/*})
|
498
|
-
rdoc = glob(%w{bin/* lib/**/*.rb README* }).reject { |e| e=~ /\.(bat|cmd)$/ }
|
499
|
-
ri = glob(%w{bin/*.rb lib/**/*.rb}).reject { |e| e=~ /\.(bat|cmd)$/ }
|
497
|
+
#rdoc = glob(%w{bin/* lib/**/*.rb README* }).reject { |e| e=~ /\.(bat|cmd)$/ }
|
498
|
+
#ri = glob(%w{bin/*.rb lib/**/*.rb}).reject { |e| e=~ /\.(bat|cmd)$/ }
|
500
499
|
man = glob(%w{man/man[0-9]/*})
|
501
500
|
libs = glob(%w{lib/**/*})
|
502
501
|
locales = glob(%w{locales/**/*})
|
data/lib/puppet/agent.rb
CHANGED
@@ -122,7 +122,7 @@ class Puppet::Agent
|
|
122
122
|
# to it during the yield.
|
123
123
|
def with_client(transaction_uuid, job_id = nil)
|
124
124
|
begin
|
125
|
-
@client = client_class.new(
|
125
|
+
@client = client_class.new(transaction_uuid, job_id)
|
126
126
|
rescue StandardError => detail
|
127
127
|
Puppet.log_exception(detail, _("Could not create instance of %{client_class}: %{detail}") % { client_class: client_class, detail: detail })
|
128
128
|
return
|
@@ -269,10 +269,8 @@ Copyright (c) 2011 Puppet Inc., LLC Licensed under the Apache 2.0 License
|
|
269
269
|
end
|
270
270
|
begin
|
271
271
|
if subcommand == :destroy
|
272
|
-
raise _("Refusing to destroy all certs, provide an explicit list of certs to destroy") if hosts == :all
|
273
|
-
|
274
272
|
signed_hosts = hosts - @ca.waiting?
|
275
|
-
apply(@ca, :revoke, options.merge(:to => signed_hosts))
|
273
|
+
apply(@ca, :revoke, options.merge(:to => signed_hosts))
|
276
274
|
end
|
277
275
|
apply(@ca, subcommand, options.merge(:to => hosts, :digest => @digest))
|
278
276
|
rescue => detail
|
@@ -24,16 +24,13 @@ class Puppet::Application::Device < Puppet::Application
|
|
24
24
|
end
|
25
25
|
|
26
26
|
{
|
27
|
-
:apply => nil,
|
28
27
|
:waitforcert => nil,
|
29
28
|
:detailed_exitcodes => false,
|
30
29
|
:verbose => false,
|
31
30
|
:debug => false,
|
32
31
|
:centrallogs => false,
|
33
32
|
:setdest => false,
|
34
|
-
:resource => false,
|
35
33
|
:target => nil,
|
36
|
-
:to_yaml => false,
|
37
34
|
}.each do |opt,val|
|
38
35
|
options[opt] = val
|
39
36
|
end
|
@@ -43,18 +40,12 @@ class Puppet::Application::Device < Puppet::Application
|
|
43
40
|
|
44
41
|
option("--centrallogging")
|
45
42
|
option("--debug","-d")
|
46
|
-
option("--resource","-r")
|
47
|
-
option("--to_yaml","-y")
|
48
43
|
option("--verbose","-v")
|
49
44
|
|
50
45
|
option("--detailed-exitcodes") do |arg|
|
51
46
|
options[:detailed_exitcodes] = true
|
52
47
|
end
|
53
48
|
|
54
|
-
option("--apply MANIFEST") do |arg|
|
55
|
-
options[:apply] = arg.to_s
|
56
|
-
end
|
57
|
-
|
58
49
|
option("--logdest DEST", "-l DEST") do |arg|
|
59
50
|
handle_logdest_arg(arg)
|
60
51
|
end
|
@@ -94,7 +85,6 @@ USAGE
|
|
94
85
|
puppet device [-d|--debug] [--detailed-exitcodes] [--deviceconfig <file>]
|
95
86
|
[-h|--help] [-l|--logdest syslog|<file>|console]
|
96
87
|
[-v|--verbose] [-w|--waitforcert <seconds>]
|
97
|
-
[-a|--apply <file>] [-r|--resource <type> [name]]
|
98
88
|
[-t|--target <device>] [--user=<user>] [-V|--version]
|
99
89
|
|
100
90
|
|
@@ -160,21 +150,10 @@ you can specify '--server <servername>' as an argument.
|
|
160
150
|
appending nature of logging. It must be appended manually to make the content
|
161
151
|
valid JSON.
|
162
152
|
|
163
|
-
* --apply:
|
164
|
-
Apply a manifest against a remote target. Target must be specified.
|
165
|
-
|
166
|
-
* --resource:
|
167
|
-
Displays a resource state as Puppet code, roughly equivalent to
|
168
|
-
`puppet resource`. Can be filterd by title. Requires --target be specified.
|
169
|
-
|
170
153
|
* --target:
|
171
154
|
Target a specific device/certificate in the device.conf. Doing so will perform a
|
172
155
|
device run against only that device/certificate.
|
173
156
|
|
174
|
-
* --to_yaml:
|
175
|
-
Output found resources in yaml format, suitable to use with Hiera and
|
176
|
-
create_resources.
|
177
|
-
|
178
157
|
* --user:
|
179
158
|
The user to run as.
|
180
159
|
|
@@ -191,7 +170,7 @@ you can specify '--server <servername>' as an argument.
|
|
191
170
|
|
192
171
|
EXAMPLE
|
193
172
|
-------
|
194
|
-
$ puppet device --
|
173
|
+
$ puppet device --server puppet.domain.com
|
195
174
|
|
196
175
|
AUTHOR
|
197
176
|
------
|
@@ -207,20 +186,6 @@ Licensed under the Apache 2.0 License
|
|
207
186
|
|
208
187
|
|
209
188
|
def main
|
210
|
-
if options[:resource] and !options[:target]
|
211
|
-
Puppet.err _("resource command requires target")
|
212
|
-
exit(1)
|
213
|
-
end
|
214
|
-
unless options[:apply].nil?
|
215
|
-
if options[:target].nil?
|
216
|
-
Puppet.err _("missing argument: --target is required when using --apply")
|
217
|
-
exit(1)
|
218
|
-
end
|
219
|
-
unless File.file?(options[:apply])
|
220
|
-
Puppet.err _("%{file} does not exist, cannot apply") % { file: options[:apply] }
|
221
|
-
exit(1)
|
222
|
-
end
|
223
|
-
end
|
224
189
|
vardir = Puppet[:vardir]
|
225
190
|
confdir = Puppet[:confdir]
|
226
191
|
certname = Puppet[:certname]
|
@@ -247,61 +212,27 @@ Licensed under the Apache 2.0 License
|
|
247
212
|
# Handle nil scheme & port
|
248
213
|
scheme = "#{device_url.scheme}://" if device_url.scheme
|
249
214
|
port = ":#{device_url.port}" if device_url.port
|
215
|
+
Puppet.info _("starting applying configuration to %{target} at %{scheme}%{url_host}%{port}%{url_path}") % { target: device.name, scheme: scheme, url_host: device_url.host, port: port, url_path: device_url.path }
|
250
216
|
|
251
217
|
# override local $vardir and $certname
|
252
218
|
Puppet[:confdir] = ::File.join(Puppet[:devicedir], device.name)
|
253
219
|
Puppet[:vardir] = ::File.join(Puppet[:devicedir], device.name)
|
254
220
|
Puppet[:certname] = device.name
|
255
221
|
|
222
|
+
# this will reload and recompute default settings and create the devices sub vardir, or we hope so :-)
|
223
|
+
Puppet.settings.use :main, :agent, :ssl
|
224
|
+
|
256
225
|
# this init the device singleton, so that the facts terminus
|
257
226
|
# and the various network_device provider can use it
|
258
227
|
Puppet::Util::NetworkDevice.init(device)
|
259
228
|
|
260
|
-
if
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
text = resources.map do |resource|
|
268
|
-
resource.prune_parameters(:parameters_to_include => @extra_params).to_hierayaml.force_encoding(Encoding.default_external)
|
269
|
-
end.join("\n")
|
270
|
-
text.prepend("#{type.downcase}:\n")
|
271
|
-
else
|
272
|
-
text = resources.map do |resource|
|
273
|
-
resource.prune_parameters(:parameters_to_include => @extra_params).to_manifest.force_encoding(Encoding.default_external)
|
274
|
-
end.join("\n")
|
275
|
-
end
|
276
|
-
(puts text)
|
277
|
-
elsif options[:apply]
|
278
|
-
# avoid reporting to server
|
279
|
-
Puppet::Transaction::Report.indirection.terminus_class = :yaml
|
280
|
-
Puppet::Resource::Catalog.indirection.cache_class = nil
|
281
|
-
|
282
|
-
require 'puppet/application/apply'
|
283
|
-
begin
|
284
|
-
|
285
|
-
Puppet[:node_terminus] = :plain
|
286
|
-
Puppet[:catalog_terminus] = :compiler
|
287
|
-
Puppet[:catalog_cache_terminus] = nil
|
288
|
-
Puppet[:facts_terminus] = :network_device
|
289
|
-
Puppet.override(:network_device => true) do
|
290
|
-
Puppet::Application::Apply.new(Puppet::Util::CommandLine.new('puppet', ["apply", options[:apply]])).run_command
|
291
|
-
end
|
292
|
-
end
|
293
|
-
else
|
294
|
-
Puppet.info _("starting applying configuration to %{target} at %{scheme}%{url_host}%{port}%{url_path}") % { target: device.name, scheme: scheme, url_host: device_url.host, port: port, url_path: device_url.path }
|
295
|
-
# this will reload and recompute default settings and create the devices sub vardir
|
296
|
-
Puppet.settings.use :main, :agent, :ssl
|
297
|
-
# ask for a ssl cert if needed, but at least
|
298
|
-
# setup the ssl system for this device.
|
299
|
-
setup_host
|
300
|
-
|
301
|
-
require 'puppet/configurer'
|
302
|
-
configurer = Puppet::Configurer.new
|
303
|
-
configurer.run(:network_device => true, :pluginsync => Puppet::Configurer.should_pluginsync?)
|
304
|
-
end
|
229
|
+
# ask for a ssl cert if needed, but at least
|
230
|
+
# setup the ssl system for this device.
|
231
|
+
setup_host
|
232
|
+
|
233
|
+
require 'puppet/configurer'
|
234
|
+
configurer = Puppet::Configurer.new
|
235
|
+
configurer.run(:network_device => true, :pluginsync => Puppet::Configurer.should_pluginsync?)
|
305
236
|
rescue => detail
|
306
237
|
Puppet.log_exception(detail)
|
307
238
|
# If we rescued an error, then we return 1 as the exit code
|
@@ -327,24 +258,6 @@ Licensed under the Apache 2.0 License
|
|
327
258
|
end
|
328
259
|
end
|
329
260
|
|
330
|
-
def parse_args(args)
|
331
|
-
type = args.shift or raise _("You must specify the type to display")
|
332
|
-
Puppet::Type.type(type) or raise _("Could not find type %{type}") % { type: type }
|
333
|
-
name = args.shift
|
334
|
-
|
335
|
-
[type, name]
|
336
|
-
end
|
337
|
-
|
338
|
-
def find_resources(type, name)
|
339
|
-
key = [type, name].join('/')
|
340
|
-
|
341
|
-
if name
|
342
|
-
[ Puppet::Resource.indirection.find( key ) ]
|
343
|
-
else
|
344
|
-
Puppet::Resource.indirection.search( key, {} )
|
345
|
-
end
|
346
|
-
end
|
347
|
-
|
348
261
|
def setup_host
|
349
262
|
@host = Puppet::SSL::Host.new
|
350
263
|
waitforcert = options[:waitforcert] || (Puppet[:onetime] ? 0 : Puppet[:waitforcert])
|
@@ -66,7 +66,8 @@ central filebucket.
|
|
66
66
|
Note that 'filebucket' defaults to using a network-based filebucket
|
67
67
|
available on the server named 'puppet'. To use this, you'll have to be
|
68
68
|
running as a user with valid Puppet certificates. Alternatively, you can
|
69
|
-
use your local file bucket by specifying '--local'
|
69
|
+
use your local file bucket by specifying '--local', or by specifying
|
70
|
+
'--bucket' with a local path.
|
70
71
|
|
71
72
|
|
72
73
|
OPTIONS
|
@@ -77,33 +78,40 @@ setting, so you can specify '--ssldir <directory>' as an
|
|
77
78
|
argument.
|
78
79
|
|
79
80
|
See the configuration file documentation at
|
80
|
-
https://
|
81
|
+
https://puppet.com/docs/puppet/latest/configuration.html for the
|
81
82
|
full list of acceptable parameters. A commented list of all
|
82
83
|
configuration options can also be generated by running puppet with
|
83
84
|
'--genconfig'.
|
84
85
|
|
86
|
+
* --bucket:
|
87
|
+
Specify a local filebucket path. This overrides the default path
|
88
|
+
set in '$clientbucketdir'.
|
89
|
+
|
85
90
|
* --debug:
|
86
91
|
Enable full debugging.
|
87
92
|
|
88
93
|
* --fromdate:
|
89
|
-
(list only) Select bucket files from 'fromdate'
|
94
|
+
(list only) Select bucket files from 'fromdate'.
|
90
95
|
|
91
96
|
* --help:
|
92
|
-
Print this help message
|
97
|
+
Print this help message.
|
93
98
|
|
94
99
|
* --local:
|
95
|
-
Use the local filebucket. This
|
96
|
-
information
|
100
|
+
Use the local filebucket. This uses the default configuration
|
101
|
+
information and the bucket located at the '$clientbucketdir'
|
102
|
+
setting by default. If '--bucket' is set, puppet uses that
|
103
|
+
path instead.
|
97
104
|
|
98
105
|
* --remote:
|
99
|
-
Use a remote filebucket. This
|
100
|
-
information
|
106
|
+
Use a remote filebucket. This uses the default configuration
|
107
|
+
information and the bucket located at the '$bucketdir' setting
|
108
|
+
by default.
|
101
109
|
|
102
110
|
* --server:
|
103
111
|
The server to send the file to, instead of locally.
|
104
112
|
|
105
113
|
* --todate:
|
106
|
-
(list only) Select bucket files until 'todate'
|
114
|
+
(list only) Select bucket files until 'todate'.
|
107
115
|
|
108
116
|
* --verbose:
|
109
117
|
Print extra information.
|
@@ -154,6 +162,11 @@ EXAMPLES
|
|
154
162
|
|
155
163
|
$ puppet filebucket -l -t "2015-05-11 09:30:00" list
|
156
164
|
d43a6ecaa892a1962398ac9170ea9bf2 2015-05-11 09:27:56 /tmp/TestFile
|
165
|
+
## Manage files in a specific local filebucket
|
166
|
+
$ puppet filebucket -b /tmp/TestBucket backup /tmp/TestFile2
|
167
|
+
/tmp/TestFile2: d41d8cd98f00b204e9800998ecf8427e
|
168
|
+
$ puppet filebucket -b /tmp/TestBucket list
|
169
|
+
d41d8cd98f00b204e9800998ecf8427e 2015-05-11 09:33:22 /tmp/TestFile2
|
157
170
|
|
158
171
|
## From a Puppet master, list files in the master bucketdir
|
159
172
|
$ puppet filebucket -b $(puppet config print bucketdir --section master) list
|
@@ -266,10 +279,18 @@ Copyright (c) 2011 Puppet Inc., LLC Licensed under the Apache 2.0 License
|
|
266
279
|
require 'puppet/file_bucket/dipper'
|
267
280
|
begin
|
268
281
|
if options[:local] or options[:bucket]
|
269
|
-
path = options[:bucket] || Puppet[:
|
282
|
+
path = options[:bucket] || Puppet[:clientbucketdir]
|
270
283
|
@client = Puppet::FileBucket::Dipper.new(:Path => path)
|
271
284
|
else
|
272
|
-
|
285
|
+
if Puppet[:server_list] && !Puppet[:server_list].empty?
|
286
|
+
server = Puppet[:server_list].first
|
287
|
+
@client = Puppet::FileBucket::Dipper.new(
|
288
|
+
:Server => server[0],
|
289
|
+
:Port => server[1]
|
290
|
+
)
|
291
|
+
else
|
292
|
+
@client = Puppet::FileBucket::Dipper.new(:Server => Puppet[:server])
|
293
|
+
end
|
273
294
|
end
|
274
295
|
rescue => detail
|
275
296
|
Puppet.log_exception(detail)
|
@@ -335,17 +335,7 @@ Copyright (c) 2015 Puppet Inc., LLC Licensed under the Apache 2.0 License
|
|
335
335
|
Puppet.settings[:facts_terminus] = 'facter'
|
336
336
|
end
|
337
337
|
|
338
|
-
unless node.is_a?(Puppet::Node) # to allow unit tests to pass a node instance
|
339
|
-
ni = Puppet::Node.indirection
|
340
|
-
tc = ni.terminus_class
|
341
|
-
if tc == :plain || options[:compile]
|
342
|
-
node = ni.find(node)
|
343
|
-
else
|
344
|
-
ni.terminus_class = :plain
|
345
|
-
node = ni.find(node)
|
346
|
-
ni.terminus_class = tc
|
347
|
-
end
|
348
|
-
end
|
338
|
+
node = Puppet::Node.indirection.find(node) unless node.is_a?(Puppet::Node) # to allow unit tests to pass a node instance
|
349
339
|
|
350
340
|
fact_file = options[:fact_file]
|
351
341
|
|
@@ -0,0 +1,261 @@
|
|
1
|
+
require 'puppet/application'
|
2
|
+
require 'puppet/configurer'
|
3
|
+
require 'puppet/util/profiler/aggregate'
|
4
|
+
require 'puppet/parser/script_compiler'
|
5
|
+
|
6
|
+
class Puppet::Application::Script < Puppet::Application
|
7
|
+
|
8
|
+
option("--debug","-d")
|
9
|
+
option("--execute EXECUTE","-e") do |arg|
|
10
|
+
options[:code] = arg
|
11
|
+
end
|
12
|
+
option("--test","-t")
|
13
|
+
option("--verbose","-v")
|
14
|
+
|
15
|
+
option("--logdest LOGDEST", "-l") do |arg|
|
16
|
+
handle_logdest_arg(arg)
|
17
|
+
end
|
18
|
+
|
19
|
+
def summary
|
20
|
+
_("Run a puppet manifests as a script without compiling a catalog")
|
21
|
+
end
|
22
|
+
|
23
|
+
def help
|
24
|
+
<<-HELP
|
25
|
+
|
26
|
+
puppet-script(8) -- #{summary}
|
27
|
+
========
|
28
|
+
|
29
|
+
SYNOPSIS
|
30
|
+
--------
|
31
|
+
Runs a puppet language script without compiling a catalog.
|
32
|
+
|
33
|
+
|
34
|
+
USAGE
|
35
|
+
-----
|
36
|
+
puppet script [-h|--help] [-V|--version] [-d|--debug] [-v|--verbose]
|
37
|
+
[-e|--execute]
|
38
|
+
[-l|--logdest syslog|eventlog|<FILE>|console] [--noop]
|
39
|
+
<file>
|
40
|
+
|
41
|
+
|
42
|
+
DESCRIPTION
|
43
|
+
-----------
|
44
|
+
This is a standalone puppet script runner tool; use it to run puppet code
|
45
|
+
without compiling a catalog.
|
46
|
+
|
47
|
+
When provided with a modulepath, via command line or config file, puppet
|
48
|
+
script can load functions, types, tasks and plans from modules.
|
49
|
+
|
50
|
+
OPTIONS
|
51
|
+
-------
|
52
|
+
Note that any setting that's valid in the configuration
|
53
|
+
file is also a valid long argument. For example, 'environment' is a
|
54
|
+
valid setting, so you can specify '--environment mytest'
|
55
|
+
as an argument.
|
56
|
+
|
57
|
+
See the configuration file documentation at
|
58
|
+
https://docs.puppetlabs.com/puppet/latest/reference/configuration.html for the
|
59
|
+
full list of acceptable parameters. A commented list of all
|
60
|
+
configuration options can also be generated by running puppet with
|
61
|
+
'--genconfig'.
|
62
|
+
|
63
|
+
* --debug:
|
64
|
+
Enable full debugging.
|
65
|
+
|
66
|
+
* --help:
|
67
|
+
Print this help message
|
68
|
+
|
69
|
+
|
70
|
+
* --logdest:
|
71
|
+
Where to send log messages. Choose between 'syslog' (the POSIX syslog
|
72
|
+
service), 'eventlog' (the Windows Event Log), 'console', or the path to a log
|
73
|
+
file. Defaults to 'console'.
|
74
|
+
|
75
|
+
A path ending with '.json' will receive structured output in JSON format. The
|
76
|
+
log file will not have an ending ']' automatically written to it due to the
|
77
|
+
appending nature of logging. It must be appended manually to make the content
|
78
|
+
valid JSON.
|
79
|
+
|
80
|
+
* --noop:
|
81
|
+
Use 'noop' mode where Puppet runs in a no-op or dry-run mode. This
|
82
|
+
is useful for seeing what changes Puppet will make without actually
|
83
|
+
executing the changes. Applies to tasks only.
|
84
|
+
|
85
|
+
* --execute:
|
86
|
+
Execute a specific piece of Puppet code
|
87
|
+
|
88
|
+
* --verbose:
|
89
|
+
Print extra information.
|
90
|
+
|
91
|
+
EXAMPLE
|
92
|
+
-------
|
93
|
+
$ puppet script -l /tmp/manifest.log manifest.pp
|
94
|
+
$ puppet script --modulepath=/root/dev/modules -e 'notice("hello world")'
|
95
|
+
|
96
|
+
|
97
|
+
AUTHOR
|
98
|
+
------
|
99
|
+
Henrik Lindberg
|
100
|
+
|
101
|
+
|
102
|
+
COPYRIGHT
|
103
|
+
---------
|
104
|
+
Copyright (c) 2017 Puppet Inc., LLC Licensed under the Apache 2.0 License
|
105
|
+
|
106
|
+
HELP
|
107
|
+
end
|
108
|
+
|
109
|
+
def app_defaults
|
110
|
+
super.merge({
|
111
|
+
:default_file_terminus => :file_server,
|
112
|
+
})
|
113
|
+
end
|
114
|
+
|
115
|
+
def run_command
|
116
|
+
if Puppet.features.bolt?
|
117
|
+
Puppet.override(:bolt_executor => Bolt::Executor.new) do
|
118
|
+
main
|
119
|
+
end
|
120
|
+
else
|
121
|
+
raise _("Bolt must be installed to use the script application")
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
def main
|
126
|
+
# The tasks feature is always on
|
127
|
+
Puppet[:tasks] = true
|
128
|
+
|
129
|
+
# Set the puppet code or file to use.
|
130
|
+
if options[:code] || command_line.args.length == 0
|
131
|
+
Puppet[:code] = options[:code] || STDIN.read
|
132
|
+
else
|
133
|
+
manifest = command_line.args.shift
|
134
|
+
raise _("Could not find file %{manifest}") % { manifest: manifest } unless Puppet::FileSystem.exist?(manifest)
|
135
|
+
Puppet.warning(_("Only one file can be used per run. Skipping %{files}") % { files: command_line.args.join(', ') }) if command_line.args.size > 0
|
136
|
+
end
|
137
|
+
|
138
|
+
unless Puppet[:node_name_fact].empty?
|
139
|
+
# Collect the facts specified for that node
|
140
|
+
unless facts = Puppet::Node::Facts.indirection.find(Puppet[:node_name_value])
|
141
|
+
raise _("Could not find facts for %{node}") % { node: Puppet[:node_name_value] }
|
142
|
+
end
|
143
|
+
|
144
|
+
Puppet[:node_name_value] = facts.values[Puppet[:node_name_fact]]
|
145
|
+
facts.name = Puppet[:node_name_value]
|
146
|
+
end
|
147
|
+
|
148
|
+
# Find the Node
|
149
|
+
unless node = Puppet::Node.indirection.find(Puppet[:node_name_value])
|
150
|
+
raise _("Could not find node %{node}") % { node: Puppet[:node_name_value] }
|
151
|
+
end
|
152
|
+
|
153
|
+
configured_environment = node.environment || Puppet.lookup(:current_environment)
|
154
|
+
|
155
|
+
apply_environment = manifest ?
|
156
|
+
configured_environment.override_with(:manifest => manifest) :
|
157
|
+
configured_environment
|
158
|
+
|
159
|
+
# Modify the node descriptor to use the special apply_environment.
|
160
|
+
# It is based on the actual environment from the node, or the locally
|
161
|
+
# configured environment if the node does not specify one.
|
162
|
+
# If a manifest file is passed on the command line, it overrides
|
163
|
+
# the :manifest setting of the apply_environment.
|
164
|
+
node.environment = apply_environment
|
165
|
+
|
166
|
+
# TRANSLATION, the string "For puppet script" is not user facing
|
167
|
+
Puppet.override({:current_environment => apply_environment}, "For puppet script") do
|
168
|
+
# Merge in the facts.
|
169
|
+
node.merge(facts.values) if facts
|
170
|
+
|
171
|
+
# Add server facts so $server_facts[environment] exists when doing a puppet script
|
172
|
+
# SCRIPT TODO: May be needed when running scripts under orchestrator. Leave it for now.
|
173
|
+
#
|
174
|
+
node.add_server_facts({})
|
175
|
+
|
176
|
+
begin
|
177
|
+
# Compile the catalog
|
178
|
+
|
179
|
+
# When compiling, the compiler traps and logs certain errors
|
180
|
+
# Those that do not lead to an immediate exit are caught by the general
|
181
|
+
# rule and gets logged.
|
182
|
+
#
|
183
|
+
begin
|
184
|
+
# support the following features when evaluating puppet code
|
185
|
+
# * $facts with facts from host running the script
|
186
|
+
# * $settings with 'settings::*' namespace populated, and '$settings::all_local' hash
|
187
|
+
# * $trusted as setup when using puppet apply
|
188
|
+
# * an environment
|
189
|
+
#
|
190
|
+
|
191
|
+
# fixup trusted information
|
192
|
+
node.sanitize()
|
193
|
+
|
194
|
+
compiler = Puppet::Parser::ScriptCompiler.new(node.environment, node.name)
|
195
|
+
topscope = compiler.topscope
|
196
|
+
|
197
|
+
# When scripting the trusted data are always local, but set them anyway
|
198
|
+
topscope.set_trusted(node.trusted_data)
|
199
|
+
|
200
|
+
# Server facts are always about the local node's version etc.
|
201
|
+
topscope.set_server_facts(node.server_facts)
|
202
|
+
|
203
|
+
# Set $facts for the node running the script
|
204
|
+
facts_hash = node.facts.nil? ? {} : node.facts.values
|
205
|
+
topscope.set_facts(facts_hash)
|
206
|
+
|
207
|
+
# create the $settings:: variables
|
208
|
+
topscope.merge_settings(node.environment.name, false)
|
209
|
+
|
210
|
+
compiler.compile()
|
211
|
+
|
212
|
+
rescue Puppet::ParseErrorWithIssue, Puppet::Error
|
213
|
+
# already logged and handled by the compiler for these two cases
|
214
|
+
exit(1)
|
215
|
+
end
|
216
|
+
|
217
|
+
exit(0)
|
218
|
+
rescue => detail
|
219
|
+
Puppet.log_exception(detail)
|
220
|
+
exit(1)
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
ensure
|
225
|
+
if @profiler
|
226
|
+
Puppet::Util::Profiler.remove_profiler(@profiler)
|
227
|
+
@profiler.shutdown
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
def setup
|
232
|
+
|
233
|
+
exit(Puppet.settings.print_configs ? 0 : 1) if Puppet.settings.print_configs?
|
234
|
+
|
235
|
+
Puppet::Util::Log.newdestination(:console) unless options[:setdest]
|
236
|
+
|
237
|
+
Signal.trap(:INT) do
|
238
|
+
$stderr.puts _("Exiting")
|
239
|
+
exit(1)
|
240
|
+
end
|
241
|
+
|
242
|
+
# TODO: This skips applying the settings catalog for these settings, but
|
243
|
+
# the effect of doing this is unknown. It may be that it only works if there is a puppet
|
244
|
+
# installed where a settings catalog have already been applied...
|
245
|
+
# This saves 1/5th of the startup time
|
246
|
+
|
247
|
+
# Puppet.settings.use :main, :agent, :ssl
|
248
|
+
|
249
|
+
# When running a script, the catalog is not relevant, and neither is caching of it
|
250
|
+
Puppet::Resource::Catalog.indirection.cache_class = nil
|
251
|
+
|
252
|
+
# we do not want the last report to be persisted
|
253
|
+
Puppet::Transaction::Report.indirection.cache_class = nil
|
254
|
+
|
255
|
+
set_log_level
|
256
|
+
|
257
|
+
if Puppet[:profile]
|
258
|
+
@profiler = Puppet::Util::Profiler.add_profiler(Puppet::Util::Profiler::Aggregate.new(Puppet.method(:info), "script"))
|
259
|
+
end
|
260
|
+
end
|
261
|
+
end
|