puppet 4.2.0 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CONTRIBUTING.md +1 -1
- data/Gemfile +5 -7
- data/README.md +1 -1
- data/Rakefile +20 -0
- data/ext/debian/puppet.init +0 -1
- data/ext/debian/puppet.logrotate +14 -5
- data/ext/osx/puppet.plist +2 -4
- data/ext/project_data.yaml +1 -1
- data/ext/redhat/client.init +65 -12
- data/ext/redhat/logrotate +15 -3
- data/ext/redhat/puppet.spec.erb +5 -1
- data/ext/redhat/server.init +1 -1
- data/ext/solaris/smf/puppet +44 -0
- data/ext/solaris/smf/puppet.xml +44 -0
- data/ext/suse/client.init +27 -27
- data/ext/suse/server.init +2 -2
- data/ext/systemd/puppet.service +1 -0
- data/install.rb +21 -39
- data/lib/hiera/puppet_function.rb +5 -5
- data/lib/puppet/agent/locker.rb +11 -2
- data/lib/puppet/agent.rb +4 -4
- data/lib/puppet/application/agent.rb +28 -14
- data/lib/puppet/application/apply.rb +17 -4
- data/lib/puppet/application/cert.rb +16 -0
- data/lib/puppet/application/filebucket.rb +78 -4
- data/lib/puppet/application/lookup.rb +356 -0
- data/lib/puppet/application/master.rb +5 -1
- data/lib/puppet/configurer.rb +9 -5
- data/lib/puppet/context/trusted_information.rb +21 -1
- data/lib/puppet/context.rb +16 -1
- data/lib/puppet/daemon.rb +17 -13
- data/lib/puppet/data_binding.rb +4 -2
- data/lib/puppet/data_providers/data_adapter.rb +7 -68
- data/lib/puppet/data_providers/data_function_support.rb +5 -26
- data/lib/puppet/data_providers/function_env_data_provider.rb +0 -10
- data/lib/puppet/data_providers/function_module_data_provider.rb +0 -22
- data/lib/puppet/data_providers/hiera_config.rb +106 -0
- data/lib/puppet/data_providers/hiera_env_data_provider.rb +18 -0
- data/lib/puppet/data_providers/hiera_interpolate.rb +97 -0
- data/lib/puppet/data_providers/hiera_module_data_provider.rb +23 -0
- data/lib/puppet/data_providers/hiera_support.rb +37 -0
- data/lib/puppet/data_providers/json_data_provider_factory.rb +31 -0
- data/lib/puppet/data_providers/lookup_adapter.rb +200 -0
- data/lib/puppet/data_providers/yaml_data_provider_factory.rb +32 -0
- data/lib/puppet/data_providers.rb +12 -13
- data/lib/puppet/defaults.rb +14 -3
- data/lib/puppet/environments.rb +94 -6
- data/lib/puppet/error.rb +4 -0
- data/lib/puppet/face/module/changes.rb +2 -1
- data/lib/puppet/feature/cfacter.rb +1 -0
- data/lib/puppet/file_bucket/dipper.rb +58 -2
- data/lib/puppet/file_system/windows.rb +3 -1
- data/lib/puppet/functions/assert_type.rb +48 -12
- data/lib/puppet/functions/defined.rb +79 -48
- data/lib/puppet/functions/each.rb +85 -27
- data/lib/puppet/functions/epp.rb +29 -37
- data/lib/puppet/functions/filter.rb +60 -25
- data/lib/puppet/functions/hiera.rb +76 -3
- data/lib/puppet/functions/hiera_array.rb +65 -3
- data/lib/puppet/functions/hiera_hash.rb +74 -2
- data/lib/puppet/functions/hiera_include.rb +77 -4
- data/lib/puppet/functions/inline_epp.rb +44 -71
- data/lib/puppet/functions/lookup.rb +19 -17
- data/lib/puppet/functions/map.rb +56 -21
- data/lib/puppet/functions/match.rb +29 -12
- data/lib/puppet/functions/reduce.rb +95 -58
- data/lib/puppet/functions/versioncmp.rb +36 -0
- data/lib/puppet/functions/with.rb +15 -7
- data/lib/puppet/functions.rb +2 -4
- data/lib/puppet/indirector/catalog/compiler.rb +3 -3
- data/lib/puppet/indirector/catalog/static_compiler.rb +46 -30
- data/lib/puppet/indirector/data_binding/none.rb +4 -1
- data/lib/puppet/indirector/file_bucket_file/file.rb +58 -1
- data/lib/puppet/indirector/hiera.rb +4 -0
- data/lib/puppet/indirector/indirection.rb +6 -1
- data/lib/puppet/indirector/json.rb +1 -1
- data/lib/puppet/indirector/msgpack.rb +1 -1
- data/lib/puppet/indirector/request.rb +7 -8
- data/lib/puppet/indirector/resource_type/parser.rb +5 -3
- data/lib/puppet/info_service/class_information_service.rb +111 -0
- data/lib/puppet/info_service.rb +7 -0
- data/lib/puppet/module_tool/applications/unpacker.rb +1 -1
- data/lib/puppet/module_tool/metadata.rb +32 -9
- data/lib/puppet/module_tool/skeleton/templates/generator/README.md.erb +42 -38
- data/lib/puppet/module_tool/skeleton/templates/generator/manifests/init.pp.erb +25 -18
- data/lib/puppet/network/authconfig.rb +21 -1
- data/lib/puppet/network/authorization.rb +8 -1
- data/lib/puppet/network/http/api/master/v3/environment.rb +59 -0
- data/lib/puppet/network/http/api/master/v3.rb +7 -1
- data/lib/puppet/node/environment.rb +9 -2
- data/lib/puppet/node.rb +11 -5
- data/lib/puppet/parser/ast/pops_bridge.rb +39 -1
- data/lib/puppet/parser/compiler/catalog_validator/env_relationship_validator.rb +64 -0
- data/lib/puppet/parser/compiler/catalog_validator/relationship_validator.rb +38 -0
- data/lib/puppet/parser/compiler/catalog_validator/site_validator.rb +20 -0
- data/lib/puppet/parser/compiler/catalog_validator.rb +33 -0
- data/lib/puppet/parser/compiler.rb +300 -12
- data/lib/puppet/parser/environment_compiler.rb +165 -0
- data/lib/puppet/parser/functions/assert_type.rb +46 -16
- data/lib/puppet/parser/functions/defined.rb +105 -68
- data/lib/puppet/parser/functions/each.rb +85 -27
- data/lib/puppet/parser/functions/epp.rb +29 -37
- data/lib/puppet/parser/functions/filter.rb +59 -23
- data/lib/puppet/parser/functions/hiera.rb +83 -27
- data/lib/puppet/parser/functions/hiera_array.rb +71 -28
- data/lib/puppet/parser/functions/hiera_hash.rb +81 -30
- data/lib/puppet/parser/functions/hiera_include.rb +81 -40
- data/lib/puppet/parser/functions/inline_epp.rb +35 -60
- data/lib/puppet/parser/functions/inline_template.rb +2 -2
- data/lib/puppet/parser/functions/map.rb +55 -20
- data/lib/puppet/parser/functions/match.rb +27 -12
- data/lib/puppet/parser/functions/reduce.rb +97 -60
- data/lib/puppet/parser/functions/with.rb +16 -8
- data/lib/puppet/parser/resource.rb +103 -21
- data/lib/puppet/parser.rb +3 -0
- data/lib/puppet/plugins/configuration.rb +3 -2
- data/lib/puppet/plugins/data_providers/data_provider.rb +283 -0
- data/lib/puppet/plugins/data_providers/registry.rb +84 -0
- data/lib/puppet/plugins/data_providers.rb +12 -60
- data/lib/puppet/pops/adapters.rb +12 -0
- data/lib/puppet/pops/binder/binder.rb +2 -2
- data/lib/puppet/pops/binder/bindings_checker.rb +1 -1
- data/lib/puppet/pops/binder/bindings_label_provider.rb +3 -1
- data/lib/puppet/pops/binder/bindings_loader.rb +6 -2
- data/lib/puppet/pops/binder/bindings_model_meta.rb +2 -2
- data/lib/puppet/pops/binder/config/binder_config.rb +1 -1
- data/lib/puppet/pops/binder/injector.rb +4 -4
- data/lib/puppet/pops/binder/key_factory.rb +3 -9
- data/lib/puppet/pops/binder/scheme_handler/module_scheme.rb +68 -9
- data/lib/puppet/pops/evaluator/access_operator.rb +27 -60
- data/lib/puppet/pops/evaluator/closure.rb +8 -8
- data/lib/puppet/pops/evaluator/collectors/abstract_collector.rb +1 -1
- data/lib/puppet/pops/evaluator/evaluator_impl.rb +10 -6
- data/lib/puppet/pops/evaluator/literal_evaluator.rb +87 -0
- data/lib/puppet/pops/evaluator/relationship_operator.rb +7 -1
- data/lib/puppet/pops/functions/dispatcher.rb +3 -3
- data/lib/puppet/pops/issues.rb +11 -3
- data/lib/puppet/pops/label_provider.rb +1 -1
- data/lib/puppet/pops/lookup/explainer.rb +402 -0
- data/lib/puppet/pops/lookup/invocation.rb +117 -0
- data/lib/puppet/pops/lookup.rb +25 -47
- data/lib/puppet/pops/merge_strategy.rb +73 -5
- data/lib/puppet/pops/model/factory.rb +38 -3
- data/lib/puppet/pops/model/model_label_provider.rb +10 -1
- data/lib/puppet/pops/model/model_meta.rb +19 -1
- data/lib/puppet/pops/model/model_tree_dumper.rb +18 -0
- data/lib/puppet/pops/parser/code_merger.rb +13 -1
- data/lib/puppet/pops/parser/egrammar.ra +65 -2
- data/lib/puppet/pops/parser/eparser.rb +1569 -1241
- data/lib/puppet/pops/parser/lexer2.rb +32 -1
- data/lib/puppet/pops/parser/locator.rb +1 -1
- data/lib/puppet/pops/parser/parser_support.rb +25 -13
- data/lib/puppet/pops/patterns.rb +3 -0
- data/lib/puppet/pops/types/enumeration.rb +1 -2
- data/lib/puppet/pops/types/type_asserter.rb +16 -15
- data/lib/puppet/pops/types/type_assertion_error.rb +1 -0
- data/lib/puppet/pops/types/type_calculator.rb +171 -1020
- data/lib/puppet/pops/types/type_factory.rb +87 -148
- data/lib/puppet/pops/types/type_mismatch_describer.rb +743 -0
- data/lib/puppet/pops/types/type_parser.rb +118 -129
- data/lib/puppet/pops/types/types.rb +1394 -255
- data/lib/puppet/pops/types/types_meta.rb +0 -234
- data/lib/puppet/pops/validation/checker4_0.rb +49 -1
- data/lib/puppet/pops/validation/validator_factory_4_0.rb +3 -1
- data/lib/puppet/pops/validation.rb +7 -2
- data/lib/puppet/pops.rb +19 -17
- data/lib/puppet/provider/augeas/augeas.rb +50 -0
- data/lib/puppet/provider/exec.rb +6 -1
- data/lib/puppet/provider/group/directoryservice.rb +10 -0
- data/lib/puppet/provider/package/dnf.rb +41 -0
- data/lib/puppet/provider/package/gem.rb +7 -2
- data/lib/puppet/provider/package/nim.rb +1 -1
- data/lib/puppet/provider/package/rpm.rb +1 -0
- data/lib/puppet/provider/package/windows/exe_package.rb +10 -8
- data/lib/puppet/provider/package/windows/msi_package.rb +4 -3
- data/lib/puppet/provider/package/windows/package.rb +9 -1
- data/lib/puppet/provider/package/yum.rb +20 -9
- data/lib/puppet/provider/service/bsd.rb +1 -1
- data/lib/puppet/provider/service/debian.rb +21 -0
- data/lib/puppet/provider/service/init.rb +6 -0
- data/lib/puppet/provider/service/launchd.rb +36 -7
- data/lib/puppet/provider/service/rcng.rb +51 -0
- data/lib/puppet/provider/service/redhat.rb +2 -1
- data/lib/puppet/provider/service/smf.rb +43 -2
- data/lib/puppet/provider/service/src.rb +27 -0
- data/lib/puppet/provider/service/systemd.rb +25 -5
- data/lib/puppet/provider/sshkey/parsed.rb +19 -9
- data/lib/puppet/provider/zone/solaris.rb +2 -2
- data/lib/puppet/reference/configuration.rb +10 -4
- data/lib/puppet/reference/report.rb +9 -12
- data/lib/puppet/reports.rb +5 -1
- data/lib/puppet/resource/capability_finder.rb +95 -0
- data/lib/puppet/resource/catalog.rb +47 -7
- data/lib/puppet/resource/status.rb +0 -2
- data/lib/puppet/resource/type.rb +238 -44
- data/lib/puppet/resource/type_collection.rb +60 -2
- data/lib/puppet/resource.rb +50 -73
- data/lib/puppet/settings/file_setting.rb +10 -9
- data/lib/puppet/settings.rb +2 -2
- data/lib/puppet/ssl/certificate_authority/interface.rb +2 -2
- data/lib/puppet/ssl/oids.rb +9 -1
- data/lib/puppet/transaction/additional_resource_generator.rb +71 -8
- data/lib/puppet/transaction/resource_harness.rb +9 -4
- data/lib/puppet/transaction.rb +8 -1
- data/lib/puppet/type/augeas.rb +8 -0
- data/lib/puppet/type/file/source.rb +14 -12
- data/lib/puppet/type/package.rb +9 -6
- data/lib/puppet/type/user.rb +4 -2
- data/lib/puppet/type.rb +78 -7
- data/lib/puppet/util/command_line.rb +4 -0
- data/lib/puppet/util/execution.rb +18 -2
- data/lib/puppet/util/tagging.rb +7 -1
- data/lib/puppet/util/windows/adsi.rb +5 -2
- data/lib/puppet/util/windows/security.rb +4 -1
- data/lib/puppet/util/windows/taskscheduler.rb +1 -1
- data/lib/puppet/util.rb +9 -1
- data/lib/puppet/version.rb +1 -1
- data/lib/puppet.rb +12 -0
- data/spec/fixtures/unit/application/environments/production/data/common.yaml +3 -0
- data/spec/fixtures/unit/application/environments/production/environment.conf +1 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_json/data/bad.json +3 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_json/environment.conf +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_json/hiera.yaml +5 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_json/manifests/site.pp +5 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_yaml/data/bad.yaml +3 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_yaml/environment.conf +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_yaml/hiera.yaml +5 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_yaml/manifests/site.pp +5 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_defaults/data/common.yaml +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_defaults/environment.conf +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_defaults/manifests/site.pp +1 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_defaults/modules/one/data/common.yaml +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_defaults/modules/one/manifests/init.pp +5 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_defaults/modules/one/metadata.json +9 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/data1/first.json +3 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/data1/name.yaml +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/data1/second.json +3 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/data1/single.yaml +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/data2/single.yaml +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/environment.conf +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/hiera.yaml +18 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/manifests/site.pp +5 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_misc/data/common.yaml +46 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_misc/environment.conf +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_misc/manifests/site.pp +1 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_misc/modules/one/data/common.yaml +30 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_misc/modules/one/manifests/init.pp +13 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_misc/modules/one/metadata.json +9 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/environment.conf +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/manifests/site.pp +1 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data1/first.json +3 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data1/name.yaml +1 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data1/second.json +3 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data1/single.yaml +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data2/single.yaml +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/hiera.yaml +18 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/manifests/init.pp +5 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/metadata.json +9 -0
- data/spec/fixtures/unit/data_providers/environments/sample/modules/dataprovider/lib/puppet_x/helindbe/sample_env_data.rb +1 -0
- data/spec/fixtures/unit/data_providers/environments/sample/modules/dataprovider/lib/puppet_x/helindbe/sample_module_data.rb +1 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/hieraprovider/data/first.json +3 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/hieraprovider/hiera.yaml +8 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/hieraprovider/manifests/init.pp +5 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/hieraprovider/metadata.json +9 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/meta/lib/puppet/functions/meta/data.rb +9 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/meta/manifests/init.pp +3 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/meta/metadata.json +9 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/metawcp/lib/puppet/bindings/metawcp/default.rb +10 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/metawcp/lib/puppet_x/thallgren/sample_module_data.rb +23 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/metawcp/manifests/init.pp +3 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/metawcp/metadata.json +9 -0
- data/spec/fixtures/unit/provider/package/yum/yum-check-update-security.txt +184 -0
- data/spec/fixtures/vcr/cassettes/Puppet_Network_HTTP_Connection/when_handling_requests/_request_get/should_yield_to_the_block.yml +24 -0
- data/spec/fixtures/vcr/cassettes/Puppet_Network_HTTP_Connection/when_handling_requests/_request_head/should_yield_to_the_block.yml +24 -0
- data/spec/fixtures/vcr/cassettes/Puppet_Network_HTTP_Connection/when_handling_requests/_request_post/should_yield_to_the_block.yml +24 -0
- data/spec/integration/data_binding_spec.rb +229 -0
- data/spec/integration/file_bucket/file_spec.rb +2 -2
- data/spec/integration/parser/compiler_spec.rb +30 -24
- data/spec/integration/parser/resource_expressions_spec.rb +4 -4
- data/spec/integration/parser/undef_param_spec.rb +1 -1
- data/spec/integration/provider/package_spec.rb +3 -1
- data/spec/integration/resource/catalog_spec.rb +1 -1
- data/spec/integration/ssl/certificate_authority_spec.rb +0 -1
- data/spec/integration/ssl/certificate_request_spec.rb +0 -1
- data/spec/integration/ssl/certificate_revocation_list_spec.rb +0 -1
- data/spec/integration/ssl/host_spec.rb +0 -1
- data/spec/integration/type/package_spec.rb +2 -0
- data/spec/integration/util/rdoc/parser_spec.rb +1 -1
- data/spec/integration/util/windows/security_spec.rb +18 -0
- data/spec/lib/matchers/include_in_order.rb +2 -2
- data/spec/shared_behaviours/iterative_functions.rb +8 -8
- data/spec/spec_helper.rb +7 -0
- data/spec/unit/agent/locker_spec.rb +4 -4
- data/spec/unit/agent_spec.rb +0 -8
- data/spec/unit/application/agent_spec.rb +5 -0
- data/spec/unit/application/apply_spec.rb +9 -1
- data/spec/unit/application/filebucket_spec.rb +88 -2
- data/spec/unit/application/lookup_spec.rb +195 -0
- data/spec/unit/application/master_spec.rb +2 -2
- data/spec/unit/application_spec.rb +3 -3
- data/spec/unit/appmgmt_spec.rb +657 -0
- data/spec/unit/capability_spec.rb +414 -0
- data/spec/unit/configurer_spec.rb +7 -1
- data/spec/unit/context/trusted_information_spec.rb +24 -1
- data/spec/unit/daemon_spec.rb +18 -8
- data/spec/unit/data_providers/hiera_data_provider_spec.rb +201 -0
- data/spec/unit/environments_spec.rb +2 -0
- data/spec/unit/face/node_spec.rb +1 -1
- data/spec/unit/file_bucket/dipper_spec.rb +210 -1
- data/spec/unit/file_serving/configuration_spec.rb +1 -1
- data/spec/unit/file_system_spec.rb +20 -0
- data/spec/unit/functions/assert_type_spec.rb +5 -7
- data/spec/unit/functions/defined_spec.rb +2 -2
- data/spec/unit/functions/epp_spec.rb +2 -2
- data/spec/unit/functions/filter_spec.rb +18 -0
- data/spec/unit/functions/hiera_spec.rb +2 -2
- data/spec/unit/functions/lookup_spec.rb +200 -9
- data/spec/unit/functions/regsubst_spec.rb +17 -8
- data/spec/unit/functions/scanf_spec.rb +1 -1
- data/spec/unit/functions/split_spec.rb +2 -2
- data/spec/unit/functions/versioncmp_spec.rb +36 -0
- data/spec/unit/functions4_spec.rb +58 -72
- data/spec/unit/graph/sequential_prioritizer_spec.rb +1 -1
- data/spec/unit/indirector/catalog/compiler_spec.rb +28 -8
- data/spec/unit/indirector/catalog/static_compiler_spec.rb +38 -20
- data/spec/unit/indirector/data_binding/none_spec.rb +2 -2
- data/spec/unit/indirector/file_bucket_file/file_spec.rb +52 -1
- data/spec/unit/indirector/indirection_spec.rb +13 -2
- data/spec/unit/indirector/request_spec.rb +8 -8
- data/spec/unit/indirector/ssl_file_spec.rb +1 -1
- data/spec/unit/indirector/yaml_spec.rb +1 -1
- data/spec/unit/info_service_spec.rb +236 -0
- data/spec/unit/module_tool/application_spec.rb +1 -1
- data/spec/unit/module_tool/applications/builder_spec.rb +1 -1
- data/spec/unit/module_tool/metadata_spec.rb +31 -2
- data/spec/unit/network/authconfig_spec.rb +62 -32
- data/spec/unit/network/authorization_spec.rb +30 -2
- data/spec/unit/network/authstore_spec.rb +1 -1
- data/spec/unit/network/http/compression_spec.rb +1 -1
- data/spec/unit/network/http/connection_spec.rb +14 -19
- data/spec/unit/network/http/handler_spec.rb +0 -5
- data/spec/unit/network/rights_spec.rb +3 -3
- data/spec/unit/node_spec.rb +27 -0
- data/spec/unit/parser/ast/leaf_spec.rb +1 -1
- data/spec/unit/parser/compiler_spec.rb +86 -2
- data/spec/unit/parser/functions/create_resources_spec.rb +1 -1
- data/spec/unit/parser/resource_spec.rb +2 -20
- data/spec/unit/pops/binder/config/binder_config_spec.rb +1 -1
- data/spec/unit/pops/binder/injector_spec.rb +3 -3
- data/spec/unit/pops/evaluator/access_ops_spec.rb +13 -11
- data/spec/unit/pops/evaluator/basic_expressions_spec.rb +1 -2
- data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +20 -11
- data/spec/unit/pops/evaluator/literal_evaluator_spec.rb +43 -0
- data/spec/unit/pops/label_provider_spec.rb +5 -1
- data/spec/unit/pops/parser/lexer2_spec.rb +39 -0
- data/spec/unit/pops/parser/parse_application_spec.rb +40 -0
- data/spec/unit/pops/parser/parse_basic_expressions_spec.rb +4 -0
- data/spec/unit/pops/parser/parse_capabilities_spec.rb +47 -0
- data/spec/unit/pops/parser/parse_site_spec.rb +38 -0
- data/spec/unit/pops/parser/parser_rspec_helper.rb +5 -0
- data/spec/unit/pops/parser/parser_spec.rb +18 -0
- data/spec/unit/pops/types/type_calculator_spec.rb +427 -444
- data/spec/unit/pops/types/type_factory_spec.rb +12 -12
- data/spec/unit/pops/types/type_parser_spec.rb +15 -12
- data/spec/unit/pops/validator/validator_spec.rb +68 -0
- data/spec/unit/property_spec.rb +1 -1
- data/spec/unit/provider/augeas/augeas_spec.rb +50 -0
- data/spec/unit/provider/group/directoryservice_spec.rb +33 -0
- data/spec/unit/provider/group/windows_adsi_spec.rb +3 -0
- data/spec/unit/provider/package/dnf_spec.rb +92 -0
- data/spec/unit/provider/package/gem_spec.rb +7 -0
- data/spec/unit/provider/package/nim_spec.rb +6 -6
- data/spec/unit/provider/package/rpm_spec.rb +25 -2
- data/spec/unit/provider/package/windows/package_spec.rb +41 -0
- data/spec/unit/provider/package/yum_spec.rb +35 -12
- data/spec/unit/provider/scheduled_task/win32_taskscheduler_spec.rb +10 -0
- data/spec/unit/provider/service/debian_spec.rb +28 -0
- data/spec/unit/provider/service/gentoo_spec.rb +1 -0
- data/spec/unit/provider/service/init_spec.rb +6 -0
- data/spec/unit/provider/service/launchd_spec.rb +85 -10
- data/spec/unit/provider/service/openrc_spec.rb +1 -0
- data/spec/unit/provider/service/rcng_spec.rb +41 -0
- data/spec/unit/provider/service/redhat_spec.rb +8 -1
- data/spec/unit/provider/service/smf_spec.rb +30 -5
- data/spec/unit/provider/service/src_spec.rb +20 -4
- data/spec/unit/provider/service/systemd_spec.rb +79 -29
- data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +1 -1
- data/spec/unit/provider/sshkey/parsed_spec.rb +23 -0
- data/spec/unit/provider/user/windows_adsi_spec.rb +2 -1
- data/spec/unit/provider/zone/solaris_spec.rb +19 -0
- data/spec/unit/reports_spec.rb +10 -0
- data/spec/unit/resource/capability_finder_spec.rb +56 -0
- data/spec/unit/resource/catalog_spec.rb +31 -8
- data/spec/unit/resource/type_collection_spec.rb +23 -2
- data/spec/unit/resource/type_spec.rb +1 -1
- data/spec/unit/resource_spec.rb +23 -5
- data/spec/unit/settings/file_setting_spec.rb +31 -0
- data/spec/unit/settings_spec.rb +91 -2
- data/spec/unit/ssl/certificate_authority/interface_spec.rb +4 -3
- data/spec/unit/ssl/certificate_authority_spec.rb +5 -3
- data/spec/unit/ssl/host_spec.rb +2 -2
- data/spec/unit/ssl/oids_spec.rb +8 -0
- data/spec/unit/transaction/additional_resource_generator_spec.rb +78 -5
- data/spec/unit/transaction/report_spec.rb +24 -1
- data/spec/unit/transaction_spec.rb +7 -0
- data/spec/unit/type/exec_spec.rb +16 -8
- data/spec/unit/type/host_spec.rb +4 -4
- data/spec/unit/type/package_spec.rb +1 -0
- data/spec/unit/type/tidy_spec.rb +4 -4
- data/spec/unit/type/user_spec.rb +14 -7
- data/spec/unit/type/vlan_spec.rb +1 -1
- data/spec/unit/type_spec.rb +1 -1
- data/spec/unit/util/ldap/generator_spec.rb +1 -1
- data/spec/unit/util/network_device/cisco/device_spec.rb +1 -1
- data/spec/unit/util/network_device/transport/ssh_spec.rb +1 -1
- data/spec/unit/util/network_device_spec.rb +1 -1
- data/spec/unit/util/storage_spec.rb +5 -1
- data/spec/unit/util/windows/adsi_spec.rb +13 -0
- data/spec/unit/util_spec.rb +21 -2
- metadata +173 -7
- data/lib/puppet/pops/evaluator/callable_mismatch_describer.rb +0 -175
- data/spec/integration/data_binding.rb +0 -104
|
@@ -22,7 +22,7 @@ describe provider_class do
|
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
before do
|
|
25
|
-
|
|
25
|
+
provider_class.stubs(:command).with(:cmd).returns('/usr/bin/yum')
|
|
26
26
|
provider.stubs(:rpm).returns 'rpm'
|
|
27
27
|
provider.stubs(:get).with(:version).returns '1'
|
|
28
28
|
provider.stubs(:get).with(:release).returns '1'
|
|
@@ -181,14 +181,29 @@ describe provider_class do
|
|
|
181
181
|
Puppet::Util.stubs(:which).with("rpm").returns("/bin/rpm")
|
|
182
182
|
provider.stubs(:which).with("rpm").returns("/bin/rpm")
|
|
183
183
|
Puppet::Util::Execution.expects(:execute).with(["/bin/rpm", "--version"], {:combine => true, :custom_environment => {}, :failonfail => true}).returns("4.10.1\n").at_most_once
|
|
184
|
+
Facter.stubs(:value).with(:operatingsystemmajrelease).returns('6')
|
|
184
185
|
end
|
|
185
186
|
|
|
186
187
|
it 'should call yum install for :installed' do
|
|
187
188
|
resource.stubs(:should).with(:ensure).returns :installed
|
|
188
|
-
|
|
189
|
+
Puppet::Util::Execution.expects(:execute).with(['/usr/bin/yum', '-d', '0', '-e', '0', '-y', :install, 'mypackage'])
|
|
189
190
|
provider.install
|
|
190
191
|
end
|
|
191
192
|
|
|
193
|
+
context 'on el-5' do
|
|
194
|
+
before(:each) do
|
|
195
|
+
Facter.stubs(:value).with(:operatingsystemmajrelease).returns('5')
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
it 'should catch yum install failures when status code is wrong' do
|
|
199
|
+
resource.stubs(:should).with(:ensure).returns :installed
|
|
200
|
+
Puppet::Util::Execution.expects(:execute).with(['/usr/bin/yum', '-e', '0', '-y', :install, name]).returns("No package #{name} available.")
|
|
201
|
+
expect {
|
|
202
|
+
provider.install
|
|
203
|
+
}.to raise_error(Puppet::Error, "Could not find package #{name}")
|
|
204
|
+
end
|
|
205
|
+
end
|
|
206
|
+
|
|
192
207
|
it 'should use :install to update' do
|
|
193
208
|
provider.expects(:install)
|
|
194
209
|
provider.update
|
|
@@ -197,7 +212,7 @@ describe provider_class do
|
|
|
197
212
|
it 'should be able to set version' do
|
|
198
213
|
version = '1.2'
|
|
199
214
|
resource[:ensure] = version
|
|
200
|
-
|
|
215
|
+
Puppet::Util::Execution.expects(:execute).with(['/usr/bin/yum', '-d', '0', '-e', '0', '-y', :install, "#{name}-#{version}"])
|
|
201
216
|
provider.stubs(:query).returns :ensure => version
|
|
202
217
|
provider.install
|
|
203
218
|
end
|
|
@@ -205,6 +220,7 @@ describe provider_class do
|
|
|
205
220
|
it 'should handle partial versions specified' do
|
|
206
221
|
version = '1.3.4'
|
|
207
222
|
resource[:ensure] = version
|
|
223
|
+
Puppet::Util::Execution.expects(:execute).with(['/usr/bin/yum', '-d', '0', '-e', '0', '-y', :install, 'mypackage-1.3.4'])
|
|
208
224
|
provider.stubs(:query).returns :ensure => '1.3.4-1.el6'
|
|
209
225
|
provider.install
|
|
210
226
|
end
|
|
@@ -213,7 +229,7 @@ describe provider_class do
|
|
|
213
229
|
current_version = '1.2'
|
|
214
230
|
version = '1.0'
|
|
215
231
|
resource[:ensure] = '1.0'
|
|
216
|
-
|
|
232
|
+
Puppet::Util::Execution.expects(:execute).with(['/usr/bin/yum', '-d', '0', '-e', '0', '-y', :downgrade, "#{name}-#{version}"])
|
|
217
233
|
provider.stubs(:query).returns(:ensure => current_version).then.returns(:ensure => version)
|
|
218
234
|
provider.install
|
|
219
235
|
end
|
|
@@ -222,22 +238,22 @@ describe provider_class do
|
|
|
222
238
|
resource[:ensure] = :installed
|
|
223
239
|
resource[:install_options] = ['-t', {'-x' => 'expackage'}]
|
|
224
240
|
|
|
225
|
-
|
|
241
|
+
Puppet::Util::Execution.expects(:execute).with(['/usr/bin/yum', '-d', '0', '-e', '0', '-y', ['-t', '-x=expackage'], :install, name])
|
|
226
242
|
provider.install
|
|
227
243
|
end
|
|
228
244
|
|
|
229
245
|
it 'allow virtual packages' do
|
|
230
246
|
resource[:ensure] = :installed
|
|
231
247
|
resource[:allow_virtual] = true
|
|
232
|
-
|
|
233
|
-
|
|
248
|
+
Puppet::Util::Execution.expects(:execute).with(['/usr/bin/yum', '-d', '0', '-e', '0', '-y', :list, name]).never
|
|
249
|
+
Puppet::Util::Execution.expects(:execute).with(['/usr/bin/yum', '-d', '0', '-e', '0', '-y', :install, name])
|
|
234
250
|
provider.install
|
|
235
251
|
end
|
|
236
252
|
end
|
|
237
253
|
|
|
238
254
|
describe 'when uninstalling' do
|
|
239
255
|
it 'should use erase to purge' do
|
|
240
|
-
|
|
256
|
+
Puppet::Util::Execution.expects(:execute).with(['/usr/bin/yum', '-y', :erase, name])
|
|
241
257
|
provider.purge
|
|
242
258
|
end
|
|
243
259
|
end
|
|
@@ -382,10 +398,6 @@ describe provider_class do
|
|
|
382
398
|
end
|
|
383
399
|
|
|
384
400
|
describe "executing yum check-update" do
|
|
385
|
-
before do
|
|
386
|
-
described_class.stubs(:command).with(:yum).returns '/usr/bin/yum'
|
|
387
|
-
end
|
|
388
|
-
|
|
389
401
|
it "passes repos to enable to 'yum check-update'" do
|
|
390
402
|
Puppet::Util::Execution.expects(:execute).with do |args, *rest|
|
|
391
403
|
expect(args).to eq %w[/usr/bin/yum check-update --enablerepo=updates --enablerepo=centosplus]
|
|
@@ -482,6 +494,17 @@ describe provider_class do
|
|
|
482
494
|
expect(output).not_to include("1:1.0.0-14.git20150121.b4ea599c.el7")
|
|
483
495
|
end
|
|
484
496
|
end
|
|
497
|
+
describe "with security notifications" do
|
|
498
|
+
let(:check_update) { File.read(my_fixture('yum-check-update-security.txt')) }
|
|
499
|
+
let(:output) { described_class.parse_updates(check_update) }
|
|
500
|
+
|
|
501
|
+
it "ignores all entries including and after 'Security'" do
|
|
502
|
+
expect(output).not_to include("Security")
|
|
503
|
+
end
|
|
504
|
+
it "includes updates before 'Security'" do
|
|
505
|
+
expect(output).to include("yum-plugin-fastestmirror.noarch")
|
|
506
|
+
end
|
|
507
|
+
end
|
|
485
508
|
end
|
|
486
509
|
|
|
487
510
|
describe "parsing a line from yum check-update" do
|
|
@@ -600,6 +600,16 @@ describe Puppet::Type.type(:scheduled_task).provider(:win32_taskscheduler), :if
|
|
|
600
600
|
|
|
601
601
|
expect(resource.provider.exists?).to eq(true)
|
|
602
602
|
end
|
|
603
|
+
|
|
604
|
+
it "uses SystemRoot in the path of Task folder" do
|
|
605
|
+
Win32::TaskScheduler.unstub(:new)
|
|
606
|
+
exists_test_task = Win32::TaskScheduler.new
|
|
607
|
+
Dir.stubs(:foreach).with('D:/WinNT/Tasks').returns([])
|
|
608
|
+
|
|
609
|
+
Puppet::Util.withenv('SystemRoot' => 'D:/WinNT') do
|
|
610
|
+
exists_test_task.exists?('Test Task')
|
|
611
|
+
end
|
|
612
|
+
end
|
|
603
613
|
end
|
|
604
614
|
|
|
605
615
|
describe '#clear_task' do
|
|
@@ -84,6 +84,7 @@ describe provider_class do
|
|
|
84
84
|
describe "when checking whether it is enabled" do
|
|
85
85
|
it "should call Kernel.system() with the appropriate parameters" do
|
|
86
86
|
@provider.expects(:system).with("/usr/sbin/invoke-rc.d", "--quiet", "--query", @resource[:name], "start").once
|
|
87
|
+
$CHILD_STATUS.stubs(:exitstatus).returns(0)
|
|
87
88
|
@provider.enabled?
|
|
88
89
|
end
|
|
89
90
|
|
|
@@ -140,4 +141,31 @@ describe provider_class do
|
|
|
140
141
|
end
|
|
141
142
|
end
|
|
142
143
|
|
|
144
|
+
describe "when checking service status" do
|
|
145
|
+
context "On systems which use the systemd-sysvinit compatibility layer" do
|
|
146
|
+
it "should call systemctl to determine running status in Debian" do
|
|
147
|
+
Facter.stubs(:value).with(:operatingsystem).returns('Debian')
|
|
148
|
+
Facter.stubs(:value).with(:operatingsystemmajrelease).returns('8')
|
|
149
|
+
@resource.stubs(:[]).with(:hasstatus).returns(:true)
|
|
150
|
+
expect(@provider.statuscmd).to eq(["systemctl", "is-active", @resource[:name]])
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
it "should call systemctl to determine running status in Ubuntu" do
|
|
154
|
+
Facter.stubs(:value).with(:operatingsystem).returns('Ubuntu')
|
|
155
|
+
Facter.stubs(:value).with(:operatingsystemmajrelease).returns('15.04')
|
|
156
|
+
@resource.stubs(:[]).with(:hasstatus).returns(:true)
|
|
157
|
+
expect(@provider.statuscmd).to eq(["systemctl", "is-active", @resource[:name]])
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
context "On systems which only use sysvinit" do
|
|
162
|
+
it "should use the service init script" do
|
|
163
|
+
Facter.stubs(:value).with(:operatingsystem).returns('Debian')
|
|
164
|
+
Facter.stubs(:value).with(:operatingsystemmajrelease).returns('7')
|
|
165
|
+
@resource.stubs(:[]).with(:hasstatus).returns(:true)
|
|
166
|
+
@provider.stubs(:initscript).returns("/etc/init.d/script")
|
|
167
|
+
expect(@provider.statuscmd).to eq(["/etc/init.d/script", :status])
|
|
168
|
+
end
|
|
169
|
+
end
|
|
170
|
+
end
|
|
143
171
|
end
|
|
@@ -159,6 +159,7 @@ describe Puppet::Type.type(:service).provider(:gentoo) do
|
|
|
159
159
|
provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd', :status => '/bin/foo'))
|
|
160
160
|
provider.expects(:execute).with(['/etc/init.d/sshd',:status], :failonfail => false, :override_locale => false, :squelch => false, :combine => true).never
|
|
161
161
|
provider.expects(:execute).with(['/bin/foo'], :failonfail => false, :override_locale => false, :squelch => false, :combine => true)
|
|
162
|
+
$CHILD_STATUS.stubs(:exitstatus).returns 0
|
|
162
163
|
provider.status
|
|
163
164
|
end
|
|
164
165
|
|
|
@@ -147,10 +147,14 @@ describe Puppet::Type.type(:service).provider(:init) do
|
|
|
147
147
|
expect(provider).to respond_to(method)
|
|
148
148
|
end
|
|
149
149
|
describe "when running #{method}" do
|
|
150
|
+
before :each do
|
|
151
|
+
$CHILD_STATUS.stubs(:exitstatus).returns(0)
|
|
152
|
+
end
|
|
150
153
|
|
|
151
154
|
it "should use any provided explicit command" do
|
|
152
155
|
resource[method] = "/user/specified/command"
|
|
153
156
|
provider.expects(:execute).with { |command, *args| command == ["/user/specified/command"] }
|
|
157
|
+
|
|
154
158
|
provider.send(method)
|
|
155
159
|
end
|
|
156
160
|
|
|
@@ -158,6 +162,7 @@ describe Puppet::Type.type(:service).provider(:init) do
|
|
|
158
162
|
resource[:hasrestart] = :true
|
|
159
163
|
resource[:hasstatus] = :true
|
|
160
164
|
provider.expects(:execute).with { |command, *args| command == ["/service/path/myservice",method]}
|
|
165
|
+
|
|
161
166
|
provider.send(method)
|
|
162
167
|
end
|
|
163
168
|
end
|
|
@@ -170,6 +175,7 @@ describe Puppet::Type.type(:service).provider(:init) do
|
|
|
170
175
|
end
|
|
171
176
|
it "should execute the command" do
|
|
172
177
|
provider.expects(:texecute).with(:status, ['/service/path/myservice', :status], false).returns("")
|
|
178
|
+
$CHILD_STATUS.stubs(:exitstatus).returns(0)
|
|
173
179
|
provider.status
|
|
174
180
|
end
|
|
175
181
|
it "should consider the process running if the command returns 0" do
|
|
@@ -6,8 +6,9 @@ require 'spec_helper'
|
|
|
6
6
|
describe Puppet::Type.type(:service).provider(:launchd) do
|
|
7
7
|
let (:joblabel) { "com.foo.food" }
|
|
8
8
|
let (:provider) { subject.class }
|
|
9
|
-
let (:launchd_overrides) { '/var/db/launchd.db/com.apple.launchd/overrides.plist' }
|
|
10
9
|
let(:resource) { Puppet::Type.type(:service).new(:name => joblabel, :provider => :launchd) }
|
|
10
|
+
let (:launchd_overrides_6_9) { '/var/db/launchd.db/com.apple.launchd/overrides.plist' }
|
|
11
|
+
let (:launchd_overrides_10_) { '/var/db/com.apple.xpc.launchd/disabled.plist' }
|
|
11
12
|
subject { resource.provider }
|
|
12
13
|
|
|
13
14
|
describe "the type interface" do
|
|
@@ -37,6 +38,56 @@ describe Puppet::Type.type(:service).provider(:launchd) do
|
|
|
37
38
|
end
|
|
38
39
|
end
|
|
39
40
|
|
|
41
|
+
[[10, '10.6'], [13, '10.9']].each do |kernel, version|
|
|
42
|
+
describe "when checking whether the service is enabled on OS X #{version}" do
|
|
43
|
+
it "should return true if the job plist says disabled is true and the global overrides says disabled is false" do
|
|
44
|
+
provider.expects(:get_os_version).returns(kernel).at_least_once
|
|
45
|
+
subject.expects(:plist_from_label).returns([joblabel, {"Disabled" => true}])
|
|
46
|
+
provider.expects(:read_plist).with(launchd_overrides_6_9).returns({joblabel => {"Disabled" => false}})
|
|
47
|
+
FileTest.expects(:file?).with(launchd_overrides_6_9).returns(true)
|
|
48
|
+
expect(subject.enabled?).to eq(:true)
|
|
49
|
+
end
|
|
50
|
+
it "should return false if the job plist says disabled is false and the global overrides says disabled is true" do
|
|
51
|
+
provider.expects(:get_os_version).returns(kernel).at_least_once
|
|
52
|
+
subject.expects(:plist_from_label).returns([joblabel, {"Disabled" => false}])
|
|
53
|
+
provider.expects(:read_plist).with(launchd_overrides_6_9).returns({joblabel => {"Disabled" => true}})
|
|
54
|
+
FileTest.expects(:file?).with(launchd_overrides_6_9).returns(true)
|
|
55
|
+
expect(subject.enabled?).to eq(:false)
|
|
56
|
+
end
|
|
57
|
+
it "should return true if the job plist and the global overrides have no disabled keys" do
|
|
58
|
+
provider.expects(:get_os_version).returns(kernel).at_least_once
|
|
59
|
+
subject.expects(:plist_from_label).returns([joblabel, {}])
|
|
60
|
+
provider.expects(:read_plist).with(launchd_overrides_6_9).returns({})
|
|
61
|
+
FileTest.expects(:file?).with(launchd_overrides_6_9).returns(true)
|
|
62
|
+
expect(subject.enabled?).to eq(:true)
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
describe "when checking whether the service is enabled on OS X 10.10" do
|
|
68
|
+
it "should return true if the job plist says disabled is true and the global overrides says disabled is false" do
|
|
69
|
+
provider.expects(:get_os_version).returns(14).at_least_once
|
|
70
|
+
subject.expects(:plist_from_label).returns([joblabel, {"Disabled" => true}])
|
|
71
|
+
provider.expects(:read_plist).with(launchd_overrides_10_).returns({joblabel => false})
|
|
72
|
+
FileTest.expects(:file?).with(launchd_overrides_10_).returns(true)
|
|
73
|
+
expect(subject.enabled?).to eq(:true)
|
|
74
|
+
end
|
|
75
|
+
it "should return false if the job plist says disabled is false and the global overrides says disabled is true" do
|
|
76
|
+
provider.expects(:get_os_version).returns(14).at_least_once
|
|
77
|
+
subject.expects(:plist_from_label).returns([joblabel, {"Disabled" => false}])
|
|
78
|
+
provider.expects(:read_plist).with(launchd_overrides_10_).returns({joblabel => true})
|
|
79
|
+
FileTest.expects(:file?).with(launchd_overrides_10_).returns(true)
|
|
80
|
+
expect(subject.enabled?).to eq(:false)
|
|
81
|
+
end
|
|
82
|
+
it "should return true if the job plist and the global overrides have no disabled keys" do
|
|
83
|
+
provider.expects(:get_os_version).returns(14).at_least_once
|
|
84
|
+
subject.expects(:plist_from_label).returns([joblabel, {}])
|
|
85
|
+
provider.expects(:read_plist).with(launchd_overrides_10_).returns({})
|
|
86
|
+
FileTest.expects(:file?).with(launchd_overrides_10_).returns(true)
|
|
87
|
+
expect(subject.enabled?).to eq(:true)
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
|
|
40
91
|
describe "when starting the service" do
|
|
41
92
|
it "should call any explicit 'start' command" do
|
|
42
93
|
resource[:start] = "/bin/false"
|
|
@@ -47,13 +98,13 @@ describe Puppet::Type.type(:service).provider(:launchd) do
|
|
|
47
98
|
it "should look for the relevant plist once" do
|
|
48
99
|
subject.expects(:plist_from_label).returns([joblabel, {}]).once
|
|
49
100
|
subject.expects(:enabled?).returns :true
|
|
50
|
-
subject.expects(:execute).with([:launchctl, :load, joblabel])
|
|
101
|
+
subject.expects(:execute).with([:launchctl, :load, "-w", joblabel])
|
|
51
102
|
subject.start
|
|
52
103
|
end
|
|
53
104
|
it "should execute 'launchctl load' once without writing to the plist if the job is enabled" do
|
|
54
105
|
subject.expects(:plist_from_label).returns([joblabel, {}])
|
|
55
106
|
subject.expects(:enabled?).returns :true
|
|
56
|
-
subject.expects(:execute).with([:launchctl, :load, joblabel]).once
|
|
107
|
+
subject.expects(:execute).with([:launchctl, :load, "-w", joblabel]).once
|
|
57
108
|
subject.start
|
|
58
109
|
end
|
|
59
110
|
it "should execute 'launchctl load' with writing to the plist once if the job is disabled" do
|
|
@@ -147,21 +198,45 @@ describe Puppet::Type.type(:service).provider(:launchd) do
|
|
|
147
198
|
end
|
|
148
199
|
end
|
|
149
200
|
|
|
150
|
-
|
|
201
|
+
[[10, "10.6"], [13, "10.9"]].each do |kernel, version|
|
|
202
|
+
describe "when enabling the service on OS X #{version}" do
|
|
203
|
+
it "should write to the global launchd overrides file once" do
|
|
204
|
+
resource[:enable] = true
|
|
205
|
+
provider.expects(:get_os_version).returns(kernel).at_least_once
|
|
206
|
+
provider.expects(:read_plist).with(launchd_overrides_6_9).returns({})
|
|
207
|
+
Plist::Emit.expects(:save_plist).with(has_entry(resource[:name], {'Disabled' => false}), launchd_overrides_6_9).once
|
|
208
|
+
subject.enable
|
|
209
|
+
end
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
describe "when disabling the service on OS X #{version}" do
|
|
213
|
+
it "should write to the global launchd overrides file once" do
|
|
214
|
+
resource[:enable] = false
|
|
215
|
+
provider.expects(:get_os_version).returns(kernel).at_least_once
|
|
216
|
+
provider.expects(:read_plist).with(launchd_overrides_6_9).returns({})
|
|
217
|
+
Plist::Emit.expects(:save_plist).with(has_entry(resource[:name], {'Disabled' => true}), launchd_overrides_6_9).once
|
|
218
|
+
subject.disable
|
|
219
|
+
end
|
|
220
|
+
end
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
describe "when enabling the service on OS X 10.10" do
|
|
151
224
|
it "should write to the global launchd overrides file once" do
|
|
152
225
|
resource[:enable] = true
|
|
153
|
-
provider.expects(:
|
|
154
|
-
|
|
226
|
+
provider.expects(:get_os_version).returns(14).at_least_once
|
|
227
|
+
provider.expects(:read_plist).with(launchd_overrides_10_).returns({})
|
|
228
|
+
Plist::Emit.expects(:save_plist).with(has_entry(resource[:name], false), launchd_overrides_10_).once
|
|
155
229
|
subject.enable
|
|
156
230
|
end
|
|
157
231
|
end
|
|
158
232
|
|
|
159
|
-
describe "when disabling the service" do
|
|
233
|
+
describe "when disabling the service on OS X 10.10" do
|
|
160
234
|
it "should write to the global launchd overrides file once" do
|
|
161
235
|
resource[:enable] = false
|
|
162
|
-
provider.
|
|
163
|
-
|
|
164
|
-
|
|
236
|
+
provider.expects(:get_os_version).returns(14).at_least_once
|
|
237
|
+
provider.expects(:read_plist).with(launchd_overrides_10_).returns({})
|
|
238
|
+
Plist::Emit.expects(:save_plist).with(has_entry(resource[:name], true), launchd_overrides_10_).once
|
|
239
|
+
subject.disable
|
|
165
240
|
end
|
|
166
241
|
end
|
|
167
242
|
|
|
@@ -146,6 +146,7 @@ describe Puppet::Type.type(:service).provider(:openrc) do
|
|
|
146
146
|
provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd', :status => '/bin/foo'))
|
|
147
147
|
provider.expects(:execute).with(['/sbin/rc-service','sshd',:status], :failonfail => false, :override_locale => false, :squelch => false, :combine => true).never
|
|
148
148
|
provider.expects(:execute).with(['/bin/foo'], :failonfail => false, :override_locale => false, :squelch => false, :combine => true)
|
|
149
|
+
$CHILD_STATUS.stubs(:exitstatus).returns 0
|
|
149
150
|
provider.status
|
|
150
151
|
end
|
|
151
152
|
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
provider_class = Puppet::Type.type(:service).provider(:rcng)
|
|
6
|
+
|
|
7
|
+
describe provider_class, :unless => Puppet.features.microsoft_windows? do
|
|
8
|
+
before :each do
|
|
9
|
+
Puppet::Type.type(:service).stubs(:defaultprovider).returns described_class
|
|
10
|
+
Facter.stubs(:value).with(:operatingsystem).returns :netbsd
|
|
11
|
+
Facter.stubs(:value).with(:osfamily).returns 'NetBSD'
|
|
12
|
+
described_class.stubs(:defpath).returns('/etc/rc.d')
|
|
13
|
+
@provider = provider_class.new
|
|
14
|
+
@provider.stubs(:initscript)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
describe "#enable" do
|
|
18
|
+
it "should have an enable method" do
|
|
19
|
+
expect(@provider).to respond_to(:enable)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it "should set the proper contents to enable" do
|
|
23
|
+
provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd'))
|
|
24
|
+
Dir.stubs(:mkdir).with('/etc/rc.conf.d')
|
|
25
|
+
fh = stub 'fh'
|
|
26
|
+
Puppet::Util.expects(:replace_file).with('/etc/rc.conf.d/sshd', 0644).yields(fh)
|
|
27
|
+
fh.expects(:puts).with("sshd=${sshd:=YES}\n")
|
|
28
|
+
provider.enable
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "should set the proper contents to enable when disabled" do
|
|
32
|
+
provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd'))
|
|
33
|
+
Dir.stubs(:mkdir).with('/etc/rc.conf.d')
|
|
34
|
+
File.stubs(:read).with('/etc/rc.conf.d/sshd').returns("sshd_enable=\"NO\"\n")
|
|
35
|
+
fh = stub 'fh'
|
|
36
|
+
Puppet::Util.expects(:replace_file).with('/etc/rc.conf.d/sshd', 0644).yields(fh)
|
|
37
|
+
fh.expects(:puts).with("sshd=${sshd:=YES}\n")
|
|
38
|
+
provider.enable
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -23,7 +23,7 @@ describe provider_class, :if => Puppet.features.posix? do
|
|
|
23
23
|
Facter.stubs(:value).with(:osfamily).returns 'RedHat'
|
|
24
24
|
end
|
|
25
25
|
|
|
26
|
-
osfamily = [ 'RedHat'
|
|
26
|
+
osfamily = [ 'RedHat' ]
|
|
27
27
|
|
|
28
28
|
osfamily.each do |osfamily|
|
|
29
29
|
it "should be the default provider on #{osfamily}" do
|
|
@@ -32,6 +32,13 @@ describe provider_class, :if => Puppet.features.posix? do
|
|
|
32
32
|
end
|
|
33
33
|
end
|
|
34
34
|
|
|
35
|
+
it "should be the default provider on sles11" do
|
|
36
|
+
Facter.stubs(:value).with(:osfamily).returns(:suse)
|
|
37
|
+
Facter.stubs(:value).with(:operatingsystem).returns(:suse)
|
|
38
|
+
Facter.stubs(:value).with(:operatingsystemmajrelease).returns("11")
|
|
39
|
+
expect(described_class.default?).to be_truthy
|
|
40
|
+
end
|
|
41
|
+
|
|
35
42
|
# test self.instances
|
|
36
43
|
describe "when getting all service instances" do
|
|
37
44
|
before :each do
|
|
@@ -28,7 +28,7 @@ describe provider_class, :if => Puppet.features.posix? do
|
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
it "should get a list of services (excluding legacy)" do
|
|
31
|
-
provider_class.expects(:svcs).with().returns File.read(my_fixture('svcs.out'))
|
|
31
|
+
provider_class.expects(:svcs).with('-H').returns File.read(my_fixture('svcs.out'))
|
|
32
32
|
instances = provider_class.instances.map { |p| {:name => p.get(:name), :ensure => p.get(:ensure)} }
|
|
33
33
|
# we dont manage legacy
|
|
34
34
|
expect(instances.size).to eq(2)
|
|
@@ -99,21 +99,31 @@ describe provider_class, :if => Puppet.features.posix? do
|
|
|
99
99
|
describe "when starting" do
|
|
100
100
|
it "should enable the service if it is not enabled" do
|
|
101
101
|
@provider.expects(:status).returns :stopped
|
|
102
|
-
@provider.expects(:texecute)
|
|
102
|
+
@provider.expects(:texecute).with(:start, ['/usr/sbin/svcadm', :enable, '-s', '/system/myservice'], true)
|
|
103
|
+
@provider.expects(:wait).with('online')
|
|
103
104
|
@provider.start
|
|
104
105
|
end
|
|
105
106
|
|
|
106
107
|
it "should always execute external command 'svcadm enable /system/myservice'" do
|
|
107
|
-
@provider.
|
|
108
|
-
@provider.expects(:texecute).with(:start, [
|
|
108
|
+
@provider.expects(:status).returns :running
|
|
109
|
+
@provider.expects(:texecute).with(:start, ['/usr/sbin/svcadm', :enable, '-s', '/system/myservice'], true)
|
|
110
|
+
@provider.expects(:wait).with('online')
|
|
109
111
|
@provider.start
|
|
110
112
|
end
|
|
111
113
|
|
|
112
114
|
it "should execute external command 'svcadm clear /system/myservice' if in maintenance" do
|
|
113
115
|
@provider.stubs(:status).returns :maintenance
|
|
114
116
|
@provider.expects(:texecute).with(:start, ["/usr/sbin/svcadm", :clear, "/system/myservice"], true)
|
|
117
|
+
@provider.expects(:wait).with('online')
|
|
115
118
|
@provider.start
|
|
116
119
|
end
|
|
120
|
+
|
|
121
|
+
it "should error if timeout occurs while starting the service" do
|
|
122
|
+
@provider.expects(:status).returns :stopped
|
|
123
|
+
@provider.expects(:texecute).with(:start, ["/usr/sbin/svcadm", :enable, "-s", "/system/myservice"], true)
|
|
124
|
+
Timeout.expects(:timeout).with(60).raises(Timeout::Error)
|
|
125
|
+
expect { @provider.start }.to raise_error Puppet::Error, ('Timed out waiting for /system/myservice to transition states')
|
|
126
|
+
end
|
|
117
127
|
end
|
|
118
128
|
|
|
119
129
|
describe "when starting a service with a manifest" do
|
|
@@ -126,6 +136,7 @@ describe provider_class, :if => Puppet.features.posix? do
|
|
|
126
136
|
it "should import the manifest if service is missing" do
|
|
127
137
|
@provider.expects(:svccfg).with(:import, "/tmp/myservice.xml")
|
|
128
138
|
@provider.expects(:texecute).with(:start, ["/usr/sbin/svcadm", :enable, "-s", "/system/myservice"], true)
|
|
139
|
+
@provider.expects(:wait).with('online')
|
|
129
140
|
@provider.expects(:svcs).with('-H', '-o', 'state,nstate', "/system/myservice").returns("online\t-")
|
|
130
141
|
@provider.start
|
|
131
142
|
end
|
|
@@ -139,15 +150,29 @@ describe provider_class, :if => Puppet.features.posix? do
|
|
|
139
150
|
describe "when stopping" do
|
|
140
151
|
it "should execute external command 'svcadm disable /system/myservice'" do
|
|
141
152
|
@provider.expects(:texecute).with(:stop, ["/usr/sbin/svcadm", :disable, "-s", "/system/myservice"], true)
|
|
153
|
+
@provider.expects(:wait).with('offline', 'disabled', 'uninitialized')
|
|
142
154
|
@provider.stop
|
|
143
155
|
end
|
|
156
|
+
|
|
157
|
+
it "should error if timeout occurs while stopping the service" do
|
|
158
|
+
@provider.expects(:texecute).with(:stop, ["/usr/sbin/svcadm", :disable, "-s", "/system/myservice"], true)
|
|
159
|
+
Timeout.expects(:timeout).with(60).raises(Timeout::Error)
|
|
160
|
+
expect { @provider.stop }.to raise_error Puppet::Error, ('Timed out waiting for /system/myservice to transition states')
|
|
161
|
+
end
|
|
144
162
|
end
|
|
145
163
|
|
|
146
164
|
describe "when restarting" do
|
|
147
165
|
it "should call 'svcadm restart /system/myservice'" do
|
|
148
166
|
@provider.expects(:texecute).with(:restart, ["/usr/sbin/svcadm", :restart, "/system/myservice"], true)
|
|
167
|
+
@provider.expects(:wait).with('online')
|
|
149
168
|
@provider.restart
|
|
150
169
|
end
|
|
151
|
-
end
|
|
152
170
|
|
|
171
|
+
it "should error if timeout occurs while restarting the service" do
|
|
172
|
+
@provider.expects(:texecute).with(:restart, ["/usr/sbin/svcadm", :restart, "/system/myservice"], true)
|
|
173
|
+
Timeout.expects(:timeout).with(60).raises(Timeout::Error)
|
|
174
|
+
expect { @provider.restart }.to raise_error Puppet::Error, ('Timed out waiting for /system/myservice to transition states')
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
end
|
|
153
178
|
end
|
|
@@ -37,7 +37,7 @@ describe provider_class do
|
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
describe ".instances" do
|
|
40
|
-
it "should
|
|
40
|
+
it "should have a .instances method" do
|
|
41
41
|
expect(provider_class).to respond_to :instances
|
|
42
42
|
end
|
|
43
43
|
|
|
@@ -63,15 +63,29 @@ _EOF_
|
|
|
63
63
|
describe "when starting a service" do
|
|
64
64
|
it "should execute the startsrc command" do
|
|
65
65
|
@provider.expects(:execute).with(['/usr/bin/startsrc', '-s', "myservice"], {:override_locale => false, :squelch => false, :combine => true, :failonfail => true})
|
|
66
|
+
@provider.expects(:status).returns :running
|
|
66
67
|
@provider.start
|
|
67
68
|
end
|
|
69
|
+
|
|
70
|
+
it "should error if timeout occurs while stopping the service" do
|
|
71
|
+
@provider.expects(:execute).with(['/usr/bin/startsrc', '-s', "myservice"], {:override_locale => false, :squelch => false, :combine => true, :failonfail => true})
|
|
72
|
+
Timeout.expects(:timeout).with(60).raises(Timeout::Error)
|
|
73
|
+
expect { @provider.start }.to raise_error Puppet::Error, ('Timed out waiting for myservice to transition states')
|
|
74
|
+
end
|
|
68
75
|
end
|
|
69
76
|
|
|
70
77
|
describe "when stopping a service" do
|
|
71
78
|
it "should execute the stopsrc command" do
|
|
72
79
|
@provider.expects(:execute).with(['/usr/bin/stopsrc', '-s', "myservice"], {:override_locale => false, :squelch => false, :combine => true, :failonfail => true})
|
|
80
|
+
@provider.expects(:status).returns :stopped
|
|
73
81
|
@provider.stop
|
|
74
82
|
end
|
|
83
|
+
|
|
84
|
+
it "should error if timeout occurs while stopping the service" do
|
|
85
|
+
@provider.expects(:execute).with(['/usr/bin/stopsrc', '-s', "myservice"], {:override_locale => false, :squelch => false, :combine => true, :failonfail => true})
|
|
86
|
+
Timeout.expects(:timeout).with(60).raises(Timeout::Error)
|
|
87
|
+
expect { @provider.stop }.to raise_error Puppet::Error, ('Timed out waiting for myservice to transition states')
|
|
88
|
+
end
|
|
75
89
|
end
|
|
76
90
|
|
|
77
91
|
describe "should have a set of methods" do
|
|
@@ -99,6 +113,7 @@ _EOF_
|
|
|
99
113
|
describe "when checking if it is enabled" do
|
|
100
114
|
it "should execute the lsitab command" do
|
|
101
115
|
@provider.expects(:execute).with(['/usr/sbin/lsitab', 'myservice'], {:combine => true, :failonfail => false})
|
|
116
|
+
$CHILD_STATUS.stubs(:exitstatus).returns(0)
|
|
102
117
|
@provider.enabled?
|
|
103
118
|
end
|
|
104
119
|
|
|
@@ -159,14 +174,15 @@ _EOF_
|
|
|
159
174
|
@provider.restart
|
|
160
175
|
end
|
|
161
176
|
|
|
162
|
-
it "should execute restart which runs
|
|
177
|
+
it "should execute restart which runs stop then start" do
|
|
163
178
|
sample_output = <<_EOF_
|
|
164
179
|
#subsysname:synonym:cmdargs:path:uid:auditid:standin:standout:standerr:action:multi:contact:svrkey:svrmtype:priority:signorm:sigforce:display:waittime:grpname:
|
|
165
180
|
myservice::--no-daemonize:/usr/sbin/puppetd:0:0:/dev/null:/var/log/puppet.log:/var/log/puppet.log:-O:-Q:-S:0:0:20:15:9:-d:20::"
|
|
166
181
|
_EOF_
|
|
182
|
+
|
|
167
183
|
@provider.expects(:execute).with(['/usr/bin/lssrc', '-Ss', "myservice"]).returns sample_output
|
|
168
|
-
@provider.expects(:
|
|
169
|
-
@provider.expects(:
|
|
184
|
+
@provider.expects(:stop)
|
|
185
|
+
@provider.expects(:start)
|
|
170
186
|
@provider.restart
|
|
171
187
|
end
|
|
172
188
|
end
|