puppet 5.5.17-x64-mingw32 → 5.5.22-x64-mingw32
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of puppet might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CODEOWNERS +1 -1
- data/Gemfile +4 -5
- data/Gemfile.lock +59 -55
- data/ext/build_defaults.yaml +1 -0
- data/ext/cert_inspector +3 -3
- data/ext/puppet-test +2 -2
- data/ext/regexp_nodes/regexp_nodes.rb +4 -4
- data/ext/windows/service/daemon.rb +54 -8
- data/install.rb +6 -6
- data/lib/puppet.rb +5 -2
- data/lib/puppet/agent.rb +5 -13
- data/lib/puppet/application.rb +1 -1
- data/lib/puppet/application/agent.rb +3 -1
- data/lib/puppet/application/apply.rb +2 -2
- data/lib/puppet/application/describe.rb +3 -9
- data/lib/puppet/application/doc.rb +1 -1
- data/lib/puppet/application/filebucket.rb +13 -0
- data/lib/puppet/application/lookup.rb +1 -1
- data/lib/puppet/application/script.rb +2 -2
- data/lib/puppet/configurer.rb +106 -31
- data/lib/puppet/configurer/downloader.rb +33 -16
- data/lib/puppet/daemon.rb +1 -1
- data/lib/puppet/defaults.rb +86 -40
- data/lib/puppet/error.rb +9 -1
- data/lib/puppet/external/nagios/base.rb +1 -1
- data/lib/puppet/face/ca.rb +1 -1
- data/lib/puppet/face/module/list.rb +5 -5
- data/lib/puppet/face/module/search.rb +1 -1
- data/lib/puppet/face/module/uninstall.rb +1 -1
- data/lib/puppet/face/module/upgrade.rb +1 -1
- data/lib/puppet/file_serving/http_metadata.rb +1 -1
- data/lib/puppet/file_serving/mount/locales.rb +1 -2
- data/lib/puppet/file_serving/mount/pluginfacts.rb +1 -2
- data/lib/puppet/file_serving/mount/plugins.rb +1 -2
- data/lib/puppet/file_system.rb +0 -8
- data/lib/puppet/file_system/memory_file.rb +1 -1
- data/lib/puppet/file_system/posix.rb +3 -2
- data/lib/puppet/file_system/uniquefile.rb +4 -0
- data/lib/puppet/forge.rb +3 -3
- data/lib/puppet/functions/epp.rb +4 -4
- data/lib/puppet/functions/inline_epp.rb +5 -5
- data/lib/puppet/functions/new.rb +8 -3
- data/lib/puppet/functions/reduce.rb +2 -4
- data/lib/puppet/functions/reverse_each.rb +1 -1
- data/lib/puppet/functions/step.rb +1 -1
- data/lib/puppet/gettext/module_translations.rb +1 -1
- data/lib/puppet/graph/rb_tree_map.rb +2 -2
- data/lib/puppet/graph/simple_graph.rb +6 -5
- data/lib/puppet/indirector/catalog/compiler.rb +8 -0
- data/lib/puppet/indirector/file_bucket_file/file.rb +1 -1
- data/lib/puppet/indirector/hiera.rb +6 -0
- data/lib/puppet/indirector/resource/ral.rb +1 -3
- data/lib/puppet/indirector/resource/validator.rb +1 -1
- data/lib/puppet/interface.rb +2 -1
- data/lib/puppet/loaders.rb +0 -1
- data/lib/puppet/metatype/manager.rb +1 -1
- data/lib/puppet/module.rb +1 -1
- data/lib/puppet/module_tool/applications/builder.rb +1 -1
- data/lib/puppet/module_tool/applications/installer.rb +1 -1
- data/lib/puppet/module_tool/applications/uninstaller.rb +3 -3
- data/lib/puppet/module_tool/metadata.rb +1 -1
- data/lib/puppet/module_tool/shared_behaviors.rb +4 -4
- data/lib/puppet/module_tool/tar/mini.rb +1 -1
- data/lib/puppet/network/http/api/indirected_routes.rb +13 -12
- data/lib/puppet/network/http/api/master/v3/environment.rb +3 -0
- data/lib/puppet/network/http/connection.rb +14 -12
- data/lib/puppet/network/http/pool.rb +7 -1
- data/lib/puppet/network/http/rack/rest.rb +2 -2
- data/lib/puppet/network/http/site.rb +1 -1
- data/lib/puppet/network/resolver.rb +2 -2
- data/lib/puppet/node/environment.rb +11 -3
- data/lib/puppet/parser/ast.rb +1 -1
- data/lib/puppet/parser/ast/resourceparam.rb +1 -1
- data/lib/puppet/parser/compiler/catalog_validator/env_relationship_validator.rb +2 -0
- data/lib/puppet/parser/compiler/catalog_validator/site_validator.rb +2 -0
- data/lib/puppet/parser/environment_compiler.rb +3 -0
- data/lib/puppet/parser/functions.rb +14 -10
- data/lib/puppet/parser/functions/epp.rb +3 -3
- data/lib/puppet/parser/functions/inline_epp.rb +5 -5
- data/lib/puppet/parser/resource.rb +3 -2
- data/lib/puppet/parser/resource/param.rb +6 -0
- data/lib/puppet/pops/adaptable.rb +7 -13
- data/lib/puppet/pops/adapters.rb +8 -4
- data/lib/puppet/pops/evaluator/access_operator.rb +2 -2
- data/lib/puppet/pops/evaluator/collectors/abstract_collector.rb +1 -3
- data/lib/puppet/pops/evaluator/collectors/catalog_collector.rb +1 -1
- data/lib/puppet/pops/evaluator/collectors/exported_collector.rb +1 -1
- data/lib/puppet/pops/evaluator/evaluator_impl.rb +1 -1
- data/lib/puppet/pops/evaluator/external_syntax_support.rb +3 -2
- data/lib/puppet/pops/evaluator/runtime3_support.rb +4 -4
- data/lib/puppet/pops/issues.rb +5 -0
- data/lib/puppet/pops/loaders.rb +1 -1
- data/lib/puppet/pops/lookup/hiera_config.rb +1 -0
- data/lib/puppet/pops/lookup/sub_lookup.rb +1 -1
- data/lib/puppet/pops/merge_strategy.rb +22 -18
- data/lib/puppet/pops/parser/heredoc_support.rb +1 -1
- data/lib/puppet/pops/parser/interpolation_support.rb +4 -4
- data/lib/puppet/pops/parser/locator.rb +1 -1
- data/lib/puppet/pops/parser/pn_parser.rb +17 -16
- data/lib/puppet/pops/puppet_stack.rb +51 -48
- data/lib/puppet/pops/resource/resource_type_impl.rb +2 -0
- data/lib/puppet/pops/types/iterable.rb +34 -8
- data/lib/puppet/pops/types/p_meta_type.rb +1 -1
- data/lib/puppet/pops/types/p_sensitive_type.rb +1 -1
- data/lib/puppet/pops/types/p_type_set_type.rb +4 -0
- data/lib/puppet/pops/types/string_converter.rb +10 -10
- data/lib/puppet/pops/types/type_calculator.rb +24 -0
- data/lib/puppet/pops/types/types.rb +3 -3
- data/lib/puppet/pops/validation/checker4_0.rb +29 -15
- data/lib/puppet/pops/validation/validator_factory_4_0.rb +1 -0
- data/lib/puppet/property.rb +1 -1
- data/lib/puppet/property/ensure.rb +1 -1
- data/lib/puppet/provider/augeas/augeas.rb +1 -1
- data/lib/puppet/provider/cron/crontab.rb +1 -1
- data/lib/puppet/provider/exec.rb +6 -2
- data/lib/puppet/provider/group/groupadd.rb +19 -19
- data/lib/puppet/provider/group/windows_adsi.rb +3 -3
- data/lib/puppet/provider/mailalias/aliases.rb +1 -1
- data/lib/puppet/provider/mount.rb +1 -1
- data/lib/puppet/provider/mount/parsed.rb +8 -8
- data/lib/puppet/provider/nameservice/directoryservice.rb +1 -1
- data/lib/puppet/provider/nameservice/pw.rb +2 -2
- data/lib/puppet/provider/package/aix.rb +17 -2
- data/lib/puppet/provider/package/apt.rb +14 -3
- data/lib/puppet/provider/package/dnfmodule.rb +141 -0
- data/lib/puppet/provider/package/dpkg.rb +16 -18
- data/lib/puppet/provider/package/fink.rb +20 -3
- data/lib/puppet/provider/package/gem.rb +4 -2
- data/lib/puppet/provider/package/openbsd.rb +14 -2
- data/lib/puppet/provider/package/pip.rb +37 -10
- data/lib/puppet/provider/package/pkg.rb +18 -5
- data/lib/puppet/provider/package/pkgdmg.rb +1 -1
- data/lib/puppet/provider/package/pkgng.rb +16 -4
- data/lib/puppet/provider/package/portage.rb +4 -4
- data/lib/puppet/provider/package/puppet_gem.rb +5 -0
- data/lib/puppet/provider/package/rpm.rb +6 -6
- data/lib/puppet/provider/package/windows/package.rb +1 -1
- data/lib/puppet/provider/package/yum.rb +28 -20
- data/lib/puppet/provider/package/zypper.rb +1 -0
- data/lib/puppet/provider/package_targetable.rb +5 -4
- data/lib/puppet/provider/parsedfile.rb +1 -1
- data/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +3 -3
- data/lib/puppet/provider/selmodule/semodule.rb +43 -26
- data/lib/puppet/provider/service/daemontools.rb +9 -9
- data/lib/puppet/provider/service/openbsd.rb +1 -1
- data/lib/puppet/provider/service/rcng.rb +2 -2
- data/lib/puppet/provider/service/runit.rb +2 -8
- data/lib/puppet/provider/service/systemd.rb +31 -13
- data/lib/puppet/provider/user/directoryservice.rb +31 -6
- data/lib/puppet/provider/user/hpux.rb +1 -1
- data/lib/puppet/provider/user/user_role_add.rb +1 -1
- data/lib/puppet/provider/user/useradd.rb +39 -20
- data/lib/puppet/provider/user/windows_adsi.rb +4 -5
- data/lib/puppet/provider/yumrepo/inifile.rb +2 -2
- data/lib/puppet/reference/indirection.rb +2 -2
- data/lib/puppet/reference/metaparameter.rb +1 -3
- data/lib/puppet/reference/providers.rb +1 -1
- data/lib/puppet/reference/type.rb +3 -9
- data/lib/puppet/reports.rb +1 -1
- data/lib/puppet/resource.rb +1 -1
- data/lib/puppet/resource/catalog.rb +1 -1
- data/lib/puppet/resource/type.rb +10 -1
- data/lib/puppet/settings.rb +3 -3
- data/lib/puppet/settings/environment_conf.rb +1 -0
- data/lib/puppet/ssl/certificate.rb +2 -1
- data/lib/puppet/ssl/certificate_authority.rb +6 -5
- data/lib/puppet/ssl/certificate_authority/interface.rb +1 -1
- data/lib/puppet/ssl/certificate_factory.rb +2 -2
- data/lib/puppet/ssl/host.rb +3 -3
- data/lib/puppet/ssl/oids.rb +1 -1
- data/lib/puppet/test/test_helper.rb +20 -12
- data/lib/puppet/transaction/report.rb +1 -1
- data/lib/puppet/transaction/resource_harness.rb +1 -1
- data/lib/puppet/type.rb +8 -4
- data/lib/puppet/type/cron.rb +1 -1
- data/lib/puppet/type/exec.rb +7 -3
- data/lib/puppet/type/file.rb +14 -2
- data/lib/puppet/type/file/data_sync.rb +5 -1
- data/lib/puppet/type/group.rb +4 -2
- data/lib/puppet/type/interface.rb +1 -1
- data/lib/puppet/type/notify.rb +3 -2
- data/lib/puppet/type/package.rb +97 -8
- data/lib/puppet/type/schedule.rb +1 -1
- data/lib/puppet/type/selboolean.rb +17 -3
- data/lib/puppet/type/service.rb +2 -8
- data/lib/puppet/type/user.rb +5 -9
- data/lib/puppet/util.rb +35 -12
- data/lib/puppet/util/autoload.rb +9 -7
- data/lib/puppet/util/command_line/trollop.rb +1 -1
- data/lib/puppet/util/http_proxy.rb +8 -14
- data/lib/puppet/util/instance_loader.rb +1 -1
- data/lib/puppet/util/log.rb +1 -1
- data/lib/puppet/util/log/destinations.rb +3 -12
- data/lib/puppet/util/logging.rb +30 -18
- data/lib/puppet/util/metric.rb +2 -2
- data/lib/puppet/util/monkey_patches.rb +1 -1
- data/lib/puppet/util/nagios_maker.rb +2 -2
- data/lib/puppet/util/network_device/cisco/device.rb +1 -1
- data/lib/puppet/util/network_device/cisco/interface.rb +2 -2
- data/lib/puppet/util/network_device/transport/ssh.rb +1 -1
- data/lib/puppet/util/pidlock.rb +12 -6
- data/lib/puppet/util/plist.rb +6 -0
- data/lib/puppet/util/provider_features.rb +2 -4
- data/lib/puppet/util/rdoc.rb +1 -1
- data/lib/puppet/util/reference.rb +1 -1
- data/lib/puppet/util/resource_template.rb +1 -1
- data/lib/puppet/util/selinux.rb +3 -1
- data/lib/puppet/util/windows/adsi.rb +60 -30
- data/lib/puppet/util/windows/api_types.rb +45 -32
- data/lib/puppet/util/windows/eventlog.rb +1 -6
- data/lib/puppet/util/windows/principal.rb +8 -6
- data/lib/puppet/util/windows/process.rb +16 -15
- data/lib/puppet/util/windows/registry.rb +17 -15
- data/lib/puppet/util/windows/security.rb +1 -0
- data/lib/puppet/util/windows/sid.rb +3 -3
- data/lib/puppet/vendor.rb +1 -1
- data/lib/puppet/version.rb +1 -1
- data/lib/puppet_pal.rb +2 -2
- data/locales/puppet.pot +362 -318
- data/man/man5/puppet.conf.5 +39 -9
- data/man/man8/puppet-agent.8 +2 -2
- data/man/man8/puppet-apply.8 +1 -1
- 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 +1 -1
- 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 +16 -1
- 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 +1 -1
- 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-script.8 +1 -1
- data/man/man8/puppet-status.8 +1 -1
- data/man/man8/puppet.8 +2 -2
- data/spec/fixtures/integration/provider/mailalias/aliases/test1 +1 -0
- data/spec/fixtures/unit/provider/package/dnfmodule/dnf-module-list.txt +19 -0
- data/spec/fixtures/unit/provider/package/pkgng/pkg.version +2 -0
- data/spec/fixtures/unit/provider/package/yum/yum-check-update-subscription-manager.txt +9 -0
- data/spec/fixtures/unit/provider/service/systemd/list_unit_files_services +9 -0
- data/spec/integration/configurer_spec.rb +66 -0
- data/spec/integration/data_binding_spec.rb +1 -0
- data/spec/integration/defaults_spec.rb +1 -2
- data/spec/integration/faces/plugin_spec.rb +29 -47
- data/spec/integration/indirector/facts/facter_spec.rb +4 -0
- data/spec/integration/parser/compiler_spec.rb +11 -0
- data/spec/integration/type/notify_spec.rb +46 -0
- data/spec/integration/util/windows/adsi_spec.rb +6 -1
- data/spec/integration/util/windows/registry_spec.rb +7 -7
- data/spec/shared_contexts/types_setup.rb +2 -0
- data/spec/unit/agent_spec.rb +34 -26
- data/spec/unit/application/apply_spec.rb +2 -12
- data/spec/unit/configurer/downloader_spec.rb +10 -0
- data/spec/unit/configurer/fact_handler_spec.rb +0 -4
- data/spec/unit/configurer_spec.rb +430 -415
- data/spec/unit/daemon_spec.rb +0 -1
- data/spec/unit/file_serving/mount/locales_spec.rb +2 -2
- data/spec/unit/file_serving/mount/pluginfacts_spec.rb +2 -2
- data/spec/unit/file_serving/mount/plugins_spec.rb +2 -2
- data/spec/unit/file_system/uniquefile_spec.rb +11 -0
- data/spec/unit/forge/forge_spec.rb +1 -3
- data/spec/unit/forge/repository_spec.rb +1 -3
- data/spec/unit/indirector/catalog/compiler_spec.rb +45 -26
- data/spec/unit/indirector/resource/ral_spec.rb +4 -4
- data/spec/unit/network/http/api/indirected_routes_spec.rb +2 -1
- data/spec/unit/network/http/connection_spec.rb +43 -1
- data/spec/unit/network/http/pool_spec.rb +32 -0
- data/spec/unit/node_spec.rb +7 -4
- data/spec/unit/parser/environment_compiler_spec.rb +7 -0
- data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +8 -3
- data/spec/unit/provider/exec_spec.rb +209 -0
- data/spec/unit/provider/group/groupadd_spec.rb +30 -1
- data/spec/unit/provider/group/windows_adsi_spec.rb +43 -10
- data/spec/unit/provider/package/aix_spec.rb +29 -0
- data/spec/unit/provider/package/apt_spec.rb +13 -2
- data/spec/unit/provider/package/aptitude_spec.rb +1 -0
- data/spec/unit/provider/package/dnfmodule_spec.rb +247 -0
- data/spec/unit/provider/package/dpkg_spec.rb +35 -7
- data/spec/unit/provider/package/openbsd_spec.rb +17 -0
- data/spec/unit/provider/package/pip_spec.rb +93 -22
- data/spec/unit/provider/package/pkg_spec.rb +13 -1
- data/spec/unit/provider/package/pkgdmg_spec.rb +1 -1
- data/spec/unit/provider/package/pkgng_spec.rb +36 -0
- data/spec/unit/provider/package/portage_spec.rb +4 -4
- data/spec/unit/provider/package/puppet_gem_spec.rb +4 -1
- data/spec/unit/provider/package/yum_spec.rb +90 -0
- data/spec/unit/provider/package/zypper_spec.rb +13 -0
- data/spec/unit/provider/package_targetable_spec.rb +60 -0
- data/spec/unit/provider/selmodule_spec.rb +118 -47
- data/spec/unit/provider/service/daemontools_spec.rb +24 -0
- data/spec/unit/provider/service/runit_spec.rb +24 -0
- data/spec/unit/provider/service/systemd_spec.rb +109 -36
- data/spec/unit/provider/user/directoryservice_spec.rb +41 -0
- data/spec/unit/provider/user/hpux_spec.rb +2 -2
- data/spec/unit/provider/user/openbsd_spec.rb +1 -0
- data/spec/unit/provider/user/useradd_spec.rb +81 -16
- data/spec/unit/provider/user/windows_adsi_spec.rb +3 -3
- data/spec/unit/puppet_pal_2pec.rb +3 -0
- data/spec/unit/ssl/certificate_authority_spec.rb +2 -3
- data/spec/unit/ssl/certificate_spec.rb +7 -0
- data/spec/unit/ssl/host_spec.rb +2 -0
- data/spec/unit/test/test_helper_spec.rb +17 -0
- data/spec/unit/type/exec_spec.rb +6 -12
- data/spec/unit/type/file/content_spec.rb +9 -3
- data/spec/unit/type/file_spec.rb +9 -4
- data/spec/unit/type/package_spec.rb +8 -0
- data/spec/unit/type/selboolean_spec.rb +4 -6
- data/spec/unit/type/service_spec.rb +9 -8
- data/spec/unit/type/user_spec.rb +19 -13
- data/spec/unit/util/execution_spec.rb +16 -0
- data/spec/unit/util/http_proxy_spec.rb +97 -0
- data/spec/unit/util/log/destinations_spec.rb +2 -26
- data/spec/unit/util/log_spec.rb +0 -138
- data/spec/unit/util/logging_spec.rb +200 -0
- data/spec/unit/util/pidlock_spec.rb +67 -40
- data/spec/unit/util/plist_spec.rb +20 -0
- data/spec/unit/util/windows/adsi_spec.rb +55 -4
- data/spec/unit/util/windows/api_types_spec.rb +104 -40
- data/spec/unit/util/windows/sid_spec.rb +2 -2
- data/tasks/manpages.rake +1 -0
- metadata +16 -7
- data/lib/puppet/pops/loader/null_loader.rb +0 -60
- data/locales/ja/puppet.po +0 -12114
- data/spec/integration/test/test_helper_spec.rb +0 -31
@@ -14,14 +14,6 @@ describe Puppet::Application::Apply do
|
|
14
14
|
Puppet[:reports] = "none"
|
15
15
|
end
|
16
16
|
|
17
|
-
after :each do
|
18
|
-
Puppet::Node::Facts.indirection.reset_terminus_class
|
19
|
-
Puppet::Node::Facts.indirection.cache_class = nil
|
20
|
-
|
21
|
-
Puppet::Node.indirection.reset_terminus_class
|
22
|
-
Puppet::Node.indirection.cache_class = nil
|
23
|
-
end
|
24
|
-
|
25
17
|
[:debug,:loadclasses,:test,:verbose,:use_nodes,:detailed_exitcodes,:catalog, :write_catalog_summary].each do |option|
|
26
18
|
it "should declare handle_#{option} method" do
|
27
19
|
expect(@apply).to respond_to("handle_#{option}".to_sym)
|
@@ -182,13 +174,11 @@ describe Puppet::Application::Apply do
|
|
182
174
|
Puppet[:prerun_command] = ''
|
183
175
|
Puppet[:postrun_command] = ''
|
184
176
|
|
185
|
-
Puppet::Node::Facts.indirection.terminus_class = :memory
|
186
|
-
Puppet::Node::Facts.indirection.cache_class = :memory
|
187
177
|
Puppet::Node.indirection.terminus_class = :memory
|
188
178
|
Puppet::Node.indirection.cache_class = :memory
|
189
179
|
|
190
|
-
|
191
|
-
Puppet::Node::Facts.indirection.save(
|
180
|
+
facts = Puppet::Node::Facts.new(Puppet[:node_name_value])
|
181
|
+
Puppet::Node::Facts.indirection.save(facts)
|
192
182
|
|
193
183
|
@node = Puppet::Node.new(Puppet[:node_name_value])
|
194
184
|
Puppet::Node.indirection.save(@node)
|
@@ -228,5 +228,15 @@ describe Puppet::Configurer::Downloader do
|
|
228
228
|
|
229
229
|
expect { @dler.evaluate }.not_to raise_error
|
230
230
|
end
|
231
|
+
|
232
|
+
it "raises an exception if catalog application fails" do
|
233
|
+
Puppet[:ignore_plugin_errors] = false
|
234
|
+
|
235
|
+
expect(@dler.file).to receive(:retrieve).and_raise(Puppet::Error, "testing")
|
236
|
+
|
237
|
+
expect {
|
238
|
+
@dler.evaluate
|
239
|
+
}.to raise_error(Puppet::Error, /testing/)
|
240
|
+
end
|
231
241
|
end
|
232
242
|
end
|
@@ -22,10 +22,6 @@ describe Puppet::Configurer::FactHandler do
|
|
22
22
|
|
23
23
|
let(:facthandler) { FactHandlerTester.new('production') }
|
24
24
|
|
25
|
-
before :each do
|
26
|
-
Puppet::Node::Facts.indirection.terminus_class = :memory
|
27
|
-
end
|
28
|
-
|
29
25
|
describe "when finding facts" do
|
30
26
|
it "should use the node name value to retrieve the facts" do
|
31
27
|
foo_facts = Puppet::Node::Facts.new('foo')
|
@@ -1,108 +1,127 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'puppet/configurer'
|
3
|
+
require 'webmock/rspec'
|
3
4
|
|
4
5
|
describe Puppet::Configurer do
|
5
6
|
before do
|
6
|
-
allow(Puppet.settings).to receive(:use).and_return(true)
|
7
|
-
@agent = Puppet::Configurer.new
|
8
|
-
allow(@agent).to receive(:init_storage)
|
9
|
-
allow(Puppet::Util::Storage).to receive(:store)
|
10
7
|
Puppet[:server] = "puppetmaster"
|
11
8
|
Puppet[:report] = true
|
12
|
-
end
|
13
9
|
|
14
|
-
|
15
|
-
|
10
|
+
catalog.add_resource(resource)
|
11
|
+
|
12
|
+
allow(Puppet::SSL::Host).to receive(:localhost).and_return(double('host'))
|
16
13
|
end
|
17
14
|
|
15
|
+
let(:configurer) { Puppet::Configurer.new }
|
16
|
+
let(:report) { Puppet::Transaction::Report.new }
|
17
|
+
let(:catalog) { Puppet::Resource::Catalog.new("tester", Puppet::Node::Environment.remote(Puppet[:environment].to_sym)) }
|
18
|
+
let(:resource) { Puppet::Resource.new(:notice, 'a') }
|
19
|
+
let(:facts) { Puppet::Node::Facts.new(Puppet[:node_name_value]) }
|
20
|
+
|
18
21
|
describe "when executing a pre-run hook" do
|
19
22
|
it "should do nothing if the hook is set to an empty string" do
|
20
23
|
Puppet.settings[:prerun_command] = ""
|
21
|
-
expect(Puppet::Util).not_to receive(:
|
24
|
+
expect(Puppet::Util::Execution).not_to receive(:execute)
|
22
25
|
|
23
|
-
|
26
|
+
configurer.execute_prerun_command
|
24
27
|
end
|
25
28
|
|
26
29
|
it "should execute any pre-run command provided via the 'prerun_command' setting" do
|
27
30
|
Puppet.settings[:prerun_command] = "/my/command"
|
28
31
|
expect(Puppet::Util::Execution).to receive(:execute).with(["/my/command"]).and_raise(Puppet::ExecutionFailure, "Failed")
|
29
32
|
|
30
|
-
|
33
|
+
configurer.execute_prerun_command
|
31
34
|
end
|
32
35
|
|
33
36
|
it "should fail if the command fails" do
|
34
37
|
Puppet.settings[:prerun_command] = "/my/command"
|
35
38
|
expect(Puppet::Util::Execution).to receive(:execute).with(["/my/command"]).and_raise(Puppet::ExecutionFailure, "Failed")
|
36
39
|
|
37
|
-
expect(
|
40
|
+
expect(configurer.execute_prerun_command).to be_falsey
|
38
41
|
end
|
39
42
|
end
|
40
43
|
|
41
44
|
describe "when executing a post-run hook" do
|
42
45
|
it "should do nothing if the hook is set to an empty string" do
|
43
46
|
Puppet.settings[:postrun_command] = ""
|
44
|
-
expect(Puppet::Util).not_to receive(:
|
47
|
+
expect(Puppet::Util::Execution).not_to receive(:execute)
|
45
48
|
|
46
|
-
|
49
|
+
configurer.execute_postrun_command
|
47
50
|
end
|
48
51
|
|
49
52
|
it "should execute any post-run command provided via the 'postrun_command' setting" do
|
50
53
|
Puppet.settings[:postrun_command] = "/my/command"
|
51
54
|
expect(Puppet::Util::Execution).to receive(:execute).with(["/my/command"]).and_raise(Puppet::ExecutionFailure, "Failed")
|
52
55
|
|
53
|
-
|
56
|
+
configurer.execute_postrun_command
|
54
57
|
end
|
55
58
|
|
56
59
|
it "should fail if the command fails" do
|
57
60
|
Puppet.settings[:postrun_command] = "/my/command"
|
58
61
|
expect(Puppet::Util::Execution).to receive(:execute).with(["/my/command"]).and_raise(Puppet::ExecutionFailure, "Failed")
|
59
62
|
|
60
|
-
expect(
|
63
|
+
expect(configurer.execute_postrun_command).to be_falsey
|
61
64
|
end
|
62
65
|
end
|
63
66
|
|
64
67
|
describe "when executing a catalog run" do
|
65
68
|
before do
|
66
|
-
allow(Puppet.settings).to receive(:use).and_return(true)
|
67
|
-
allow(@agent).to receive(:download_plugins)
|
68
|
-
Puppet::Node::Facts.indirection.terminus_class = :memory
|
69
|
-
@facts = Puppet::Node::Facts.new(Puppet[:node_name_value])
|
70
|
-
Puppet::Node::Facts.indirection.save(@facts)
|
71
|
-
|
72
|
-
@catalog = Puppet::Resource::Catalog.new("tester", Puppet::Node::Environment.remote(Puppet[:environment].to_sym))
|
73
|
-
allow(@catalog).to receive(:to_ral).and_return(@catalog)
|
74
69
|
Puppet::Resource::Catalog.indirection.terminus_class = :rest
|
75
|
-
allow(Puppet::Resource::Catalog.indirection).to receive(:find).and_return(
|
76
|
-
allow(@agent).to receive(:send_report)
|
77
|
-
allow(@agent).to receive(:save_last_run_summary)
|
78
|
-
|
79
|
-
allow(Puppet::Util::Log).to receive(:close_all)
|
80
|
-
end
|
81
|
-
|
82
|
-
after :all do
|
83
|
-
Puppet::Node::Facts.indirection.reset_terminus_class
|
84
|
-
Puppet::Resource::Catalog.indirection.reset_terminus_class
|
85
|
-
end
|
86
|
-
|
87
|
-
it "should initialize storage" do
|
88
|
-
expect(Puppet::Util::Storage).to receive(:load)
|
89
|
-
@agent.run
|
70
|
+
allow(Puppet::Resource::Catalog.indirection).to receive(:find).and_return(catalog)
|
90
71
|
end
|
91
72
|
|
92
73
|
it "downloads plugins when told" do
|
93
|
-
expect(
|
94
|
-
|
74
|
+
expect(configurer).to receive(:download_plugins)
|
75
|
+
configurer.run(:pluginsync => true)
|
95
76
|
end
|
96
77
|
|
97
78
|
it "does not download plugins when told" do
|
98
|
-
expect(
|
99
|
-
|
79
|
+
expect(configurer).not_to receive(:download_plugins)
|
80
|
+
configurer.run(:pluginsync => false)
|
100
81
|
end
|
101
82
|
|
102
83
|
it "should carry on when it can't fetch its node definition" do
|
103
84
|
error = Net::HTTPError.new(400, 'dummy server communication error')
|
104
85
|
expect(Puppet::Node.indirection).to receive(:find).and_raise(error)
|
105
|
-
expect(
|
86
|
+
expect(configurer.run).to eq(0)
|
87
|
+
end
|
88
|
+
|
89
|
+
it "fails the run if pluginsync fails when usecacheonfailure is false" do
|
90
|
+
Puppet[:ignore_plugin_errors] = false
|
91
|
+
|
92
|
+
# --test implies these, set them so we don't fall back to a cached catalog
|
93
|
+
Puppet[:use_cached_catalog] = false
|
94
|
+
Puppet[:usecacheonfailure] = false
|
95
|
+
|
96
|
+
body = "{\"message\":\"Not Found: Could not find environment 'fasdfad'\",\"issue_kind\":\"RUNTIME_ERROR\"}"
|
97
|
+
stub_request(:get, %r{/puppet/v3/file_metadatas/pluginfacts}).to_return(
|
98
|
+
status: 404, body: body, headers: {'Content-Type' => 'application/json'}
|
99
|
+
)
|
100
|
+
stub_request(:get, %r{/puppet/v3/file_metadata/pluginfacts}).to_return(
|
101
|
+
status: 404, body: body, headers: {'Content-Type' => 'application/json'}
|
102
|
+
)
|
103
|
+
|
104
|
+
configurer.run(pluginsync: true)
|
105
|
+
|
106
|
+
expect(@logs).to include(an_object_having_attributes(level: :err, message: %r{Failed to apply catalog: Failed to retrieve pluginfacts: Could not retrieve information from environment production source\(s\) puppet:///pluginfacts}))
|
107
|
+
end
|
108
|
+
|
109
|
+
it "applies a cached catalog if pluginsync fails when usecacheonfailure is true" do
|
110
|
+
Puppet[:ignore_plugin_errors] = false
|
111
|
+
|
112
|
+
Puppet[:use_cached_catalog] = false
|
113
|
+
Puppet[:usecacheonfailure] = true
|
114
|
+
|
115
|
+
body = "{\"message\":\"Not Found: Could not find environment 'fasdfad'\",\"issue_kind\":\"RUNTIME_ERROR\"}"
|
116
|
+
stub_request(:get, %r{/puppet/v3/file_metadatas/pluginfacts}).to_return(
|
117
|
+
status: 404, body: body, headers: {'Content-Type' => 'application/json'}
|
118
|
+
)
|
119
|
+
stub_request(:get, %r{/puppet/v3/file_metadata/pluginfacts}).to_return(
|
120
|
+
status: 404, body: body, headers: {'Content-Type' => 'application/json'}
|
121
|
+
)
|
122
|
+
|
123
|
+
expect(configurer.run(pluginsync: true, :report => report)).to eq(0)
|
124
|
+
expect(report.cached_catalog_status).to eq('on_failure')
|
106
125
|
end
|
107
126
|
|
108
127
|
it "applies a cached catalog when it can't connect to the master" do
|
@@ -110,208 +129,159 @@ describe Puppet::Configurer do
|
|
110
129
|
|
111
130
|
expect(Puppet::Node.indirection).to receive(:find).and_raise(error)
|
112
131
|
expect(Puppet::Resource::Catalog.indirection).to receive(:find).with(anything, hash_including(:ignore_cache => true)).and_raise(error)
|
113
|
-
expect(Puppet::Resource::Catalog.indirection).to receive(:find).with(anything, hash_including(:ignore_terminus => true)).and_return(
|
132
|
+
expect(Puppet::Resource::Catalog.indirection).to receive(:find).with(anything, hash_including(:ignore_terminus => true)).and_return(catalog)
|
114
133
|
|
115
|
-
expect(
|
134
|
+
expect(configurer.run).to eq(0)
|
116
135
|
end
|
117
136
|
|
118
137
|
it "should initialize a transaction report if one is not provided" do
|
119
|
-
|
120
|
-
expect(Puppet::Transaction::Report).to receive(:new).and_return(report)
|
138
|
+
# host and settings catalogs each create a report...
|
139
|
+
expect(Puppet::Transaction::Report).to receive(:new).and_return(report).twice
|
121
140
|
|
122
|
-
|
141
|
+
configurer.run
|
123
142
|
end
|
124
143
|
|
125
144
|
it "should respect node_name_fact when setting the host on a report" do
|
126
145
|
Puppet[:node_name_fact] = 'my_name_fact'
|
127
|
-
|
128
|
-
|
129
|
-
report = Puppet::Transaction::Report.new
|
146
|
+
facts.values = {'my_name_fact' => 'node_name_from_fact'}
|
147
|
+
Puppet::Node::Facts.indirection.save(facts)
|
130
148
|
|
131
|
-
|
149
|
+
configurer.run(:report => report)
|
132
150
|
expect(report.host).to eq('node_name_from_fact')
|
133
151
|
end
|
134
152
|
|
135
|
-
it "
|
136
|
-
|
137
|
-
|
138
|
-
expect(@catalog).to receive(:apply).with(hash_including(report: report))
|
139
|
-
|
140
|
-
@agent.run
|
141
|
-
end
|
142
|
-
|
143
|
-
it "should use the provided report if it was passed one" do
|
144
|
-
report = Puppet::Transaction::Report.new
|
145
|
-
expect(@catalog).to receive(:apply).with(hash_including(report: report))
|
146
|
-
|
147
|
-
@agent.run(:report => report)
|
148
|
-
end
|
149
|
-
|
150
|
-
it "should set the report as a log destination" do
|
151
|
-
report = Puppet::Transaction::Report.new
|
152
|
-
|
153
|
-
expect(report).to receive(:<<).with(instance_of(Puppet::Util::Log)).at_least(:once)
|
153
|
+
it "creates a new report when applying the catalog" do
|
154
|
+
options = {}
|
155
|
+
configurer.run(options)
|
154
156
|
|
155
|
-
|
157
|
+
expect(options[:report].metrics['time']['catalog_application']).to be_an_instance_of(Float)
|
156
158
|
end
|
157
159
|
|
158
|
-
it "
|
159
|
-
|
160
|
+
it "uses the provided report when applying the catalog" do
|
161
|
+
configurer.run(:report => report)
|
160
162
|
|
161
|
-
|
163
|
+
expect(report.metrics['time']['catalog_application']).to be_an_instance_of(Float)
|
162
164
|
end
|
163
165
|
|
164
166
|
it "should log a failure and do nothing if no catalog can be retrieved" do
|
165
|
-
expect(
|
167
|
+
expect(configurer).to receive(:retrieve_catalog).and_return(nil)
|
166
168
|
|
167
169
|
expect(Puppet).to receive(:err).with("Could not retrieve catalog; skipping run")
|
168
170
|
|
169
|
-
|
171
|
+
configurer.run
|
170
172
|
end
|
171
173
|
|
172
|
-
it "
|
173
|
-
expect(
|
174
|
+
it "passes arbitrary options when applying the catalog" do
|
175
|
+
expect(catalog).to receive(:apply).with(hash_including(one: true))
|
174
176
|
|
175
|
-
|
176
|
-
@agent.run :one => true
|
177
|
-
end
|
178
|
-
|
179
|
-
it "should accept a catalog and use it instead of retrieving a different one" do
|
180
|
-
expect(@agent).not_to receive(:retrieve_catalog)
|
181
|
-
|
182
|
-
expect(@catalog).to receive(:apply)
|
183
|
-
@agent.run :one => true, :catalog => @catalog
|
177
|
+
configurer.run(catalog: catalog, one: true)
|
184
178
|
end
|
185
179
|
|
186
180
|
it "should benchmark how long it takes to apply the catalog" do
|
187
|
-
|
188
|
-
|
189
|
-
expect(@agent).to receive(:retrieve_catalog).and_return(@catalog)
|
190
|
-
|
191
|
-
expect(@catalog).not_to receive(:apply) # because we're not yielding
|
192
|
-
@agent.run
|
193
|
-
end
|
194
|
-
|
195
|
-
it "should execute post-run hooks after the run" do
|
196
|
-
expect(@agent).to receive(:execute_postrun_command)
|
181
|
+
configurer.run(report: report)
|
197
182
|
|
198
|
-
|
183
|
+
expect(report.logs).to include(an_object_having_attributes(level: :notice, message: /Applied catalog in .* seconds/))
|
199
184
|
end
|
200
185
|
|
201
186
|
it "should create report with passed transaction_uuid and job_id" do
|
202
|
-
|
203
|
-
allow(@agent).to receive(:init_storage)
|
187
|
+
configurer = Puppet::Configurer.new("test_tuuid", "test_jid")
|
204
188
|
|
205
189
|
report = Puppet::Transaction::Report.new(nil, "test", "aaaa")
|
206
190
|
expect(Puppet::Transaction::Report).to receive(:new).with(anything, anything, 'test_tuuid', 'test_jid').and_return(report)
|
207
|
-
expect(
|
191
|
+
expect(configurer).to receive(:send_report).with(report)
|
208
192
|
|
209
|
-
|
193
|
+
configurer.run
|
210
194
|
end
|
211
195
|
|
212
196
|
it "should send the report" do
|
213
197
|
report = Puppet::Transaction::Report.new(nil, "test", "aaaa")
|
214
198
|
expect(Puppet::Transaction::Report).to receive(:new).and_return(report)
|
215
|
-
expect(
|
199
|
+
expect(configurer).to receive(:send_report).with(report)
|
216
200
|
|
217
201
|
expect(report.environment).to eq("test")
|
218
202
|
expect(report.transaction_uuid).to eq("aaaa")
|
219
203
|
|
220
|
-
|
204
|
+
configurer.run
|
221
205
|
end
|
222
206
|
|
223
207
|
it "should send the transaction report even if the catalog could not be retrieved" do
|
224
|
-
expect(
|
208
|
+
expect(configurer).to receive(:retrieve_catalog).and_return(nil)
|
225
209
|
|
226
210
|
report = Puppet::Transaction::Report.new(nil, "test", "aaaa")
|
227
211
|
expect(Puppet::Transaction::Report).to receive(:new).and_return(report)
|
228
|
-
expect(
|
212
|
+
expect(configurer).to receive(:send_report).with(report)
|
229
213
|
|
230
214
|
expect(report.environment).to eq("test")
|
231
215
|
expect(report.transaction_uuid).to eq("aaaa")
|
232
216
|
|
233
|
-
|
217
|
+
configurer.run
|
234
218
|
end
|
235
219
|
|
236
220
|
it "should send the transaction report even if there is a failure" do
|
237
|
-
expect(
|
221
|
+
expect(configurer).to receive(:retrieve_catalog).and_raise("whatever")
|
238
222
|
|
239
223
|
report = Puppet::Transaction::Report.new(nil, "test", "aaaa")
|
240
224
|
expect(Puppet::Transaction::Report).to receive(:new).and_return(report)
|
241
|
-
expect(
|
225
|
+
expect(configurer).to receive(:send_report).with(report)
|
242
226
|
|
243
227
|
expect(report.environment).to eq("test")
|
244
228
|
expect(report.transaction_uuid).to eq("aaaa")
|
245
229
|
|
246
|
-
expect(
|
230
|
+
expect(configurer.run).to be_nil
|
247
231
|
end
|
248
232
|
|
249
233
|
it "should remove the report as a log destination when the run is finished" do
|
250
|
-
report
|
251
|
-
expect(Puppet::Transaction::Report).to receive(:new).and_return(report)
|
252
|
-
|
253
|
-
@agent.run
|
234
|
+
configurer.run(report: report)
|
254
235
|
|
255
236
|
expect(Puppet::Util::Log.destinations).not_to include(report)
|
256
237
|
end
|
257
238
|
|
258
|
-
it "should return
|
259
|
-
|
260
|
-
|
261
|
-
expect(report).to receive(:exit_status).and_return(1234)
|
239
|
+
it "should return an exit status of 2 due to the notify resource 'changing'" do
|
240
|
+
cat = Puppet::Resource::Catalog.new("tester", Puppet::Node::Environment.remote(Puppet[:environment].to_sym))
|
241
|
+
cat.add_resource(Puppet::Type.type(:notify).new(:name => 'something changed'))
|
262
242
|
|
263
|
-
expect(
|
243
|
+
expect(configurer.run(catalog: cat, report: report)).to eq(2)
|
264
244
|
end
|
265
245
|
|
266
246
|
it "should return nil if catalog application fails" do
|
267
|
-
expect(
|
268
|
-
|
269
|
-
expect(
|
247
|
+
expect(catalog).to receive(:apply).and_raise(Puppet::Error, 'One or more resource dependency cycles detected in graph')
|
248
|
+
|
249
|
+
expect(configurer.run(catalog: catalog, report: report)).to be_nil
|
270
250
|
end
|
271
251
|
|
272
252
|
it "should send the transaction report even if the pre-run command fails" do
|
273
|
-
report = Puppet::Transaction::Report.new
|
274
253
|
expect(Puppet::Transaction::Report).to receive(:new).and_return(report)
|
275
254
|
|
276
255
|
Puppet.settings[:prerun_command] = "/my/command"
|
277
256
|
expect(Puppet::Util::Execution).to receive(:execute).with(["/my/command"]).and_raise(Puppet::ExecutionFailure, "Failed")
|
278
|
-
expect(
|
257
|
+
expect(configurer).to receive(:send_report).with(report)
|
279
258
|
|
280
|
-
expect(
|
259
|
+
expect(configurer.run).to be_nil
|
281
260
|
end
|
282
261
|
|
283
262
|
it "should include the pre-run command failure in the report" do
|
284
|
-
report = Puppet::Transaction::Report.new
|
285
|
-
expect(Puppet::Transaction::Report).to receive(:new).and_return(report)
|
286
|
-
|
287
263
|
Puppet.settings[:prerun_command] = "/my/command"
|
288
264
|
expect(Puppet::Util::Execution).to receive(:execute).with(["/my/command"]).and_raise(Puppet::ExecutionFailure, "Failed")
|
289
265
|
|
290
|
-
expect(
|
266
|
+
expect(configurer.run(report: report)).to be_nil
|
291
267
|
expect(report.logs.find { |x| x.message =~ /Could not run command from prerun_command/ }).to be
|
292
268
|
end
|
293
269
|
|
294
270
|
it "should send the transaction report even if the post-run command fails" do
|
295
|
-
report = Puppet::Transaction::Report.new
|
296
|
-
expect(Puppet::Transaction::Report).to receive(:new).and_return(report)
|
297
|
-
|
298
271
|
Puppet.settings[:postrun_command] = "/my/command"
|
299
272
|
expect(Puppet::Util::Execution).to receive(:execute).with(["/my/command"]).and_raise(Puppet::ExecutionFailure, "Failed")
|
300
|
-
expect(
|
273
|
+
expect(configurer).to receive(:send_report).with(report)
|
301
274
|
|
302
|
-
expect(
|
275
|
+
expect(configurer.run(report: report)).to be_nil
|
303
276
|
end
|
304
277
|
|
305
278
|
it "should include the post-run command failure in the report" do
|
306
|
-
report = Puppet::Transaction::Report.new
|
307
|
-
expect(Puppet::Transaction::Report).to receive(:new).and_return(report)
|
308
|
-
|
309
279
|
Puppet.settings[:postrun_command] = "/my/command"
|
310
280
|
expect(Puppet::Util::Execution).to receive(:execute).with(["/my/command"]).and_raise(Puppet::ExecutionFailure, "Failed")
|
311
281
|
|
312
282
|
expect(report).to receive(:<<) { |log, _| expect(log.message).to match(/Could not run command from postrun_command/) }.at_least(:once)
|
313
283
|
|
314
|
-
expect(
|
284
|
+
expect(configurer.run(report: report)).to be_nil
|
315
285
|
end
|
316
286
|
|
317
287
|
it "should execute post-run command even if the pre-run command fails" do
|
@@ -320,47 +290,36 @@ describe Puppet::Configurer do
|
|
320
290
|
expect(Puppet::Util::Execution).to receive(:execute).with(["/my/precommand"]).and_raise(Puppet::ExecutionFailure, "Failed")
|
321
291
|
expect(Puppet::Util::Execution).to receive(:execute).with(["/my/postcommand"])
|
322
292
|
|
323
|
-
expect(
|
293
|
+
expect(configurer.run).to be_nil
|
324
294
|
end
|
325
295
|
|
326
296
|
it "should finalize the report" do
|
327
|
-
report = Puppet::Transaction::Report.new
|
328
|
-
expect(Puppet::Transaction::Report).to receive(:new).and_return(report)
|
329
|
-
|
330
297
|
expect(report).to receive(:finalize_report)
|
331
|
-
|
298
|
+
configurer.run(report: report)
|
332
299
|
end
|
333
300
|
|
334
301
|
it "should not apply the catalog if the pre-run command fails" do
|
335
|
-
report = Puppet::Transaction::Report.new
|
336
|
-
expect(Puppet::Transaction::Report).to receive(:new).and_return(report)
|
337
|
-
|
338
302
|
Puppet.settings[:prerun_command] = "/my/command"
|
339
303
|
expect(Puppet::Util::Execution).to receive(:execute).with(["/my/command"]).and_raise(Puppet::ExecutionFailure, "Failed")
|
340
304
|
|
341
|
-
|
342
|
-
expect(
|
305
|
+
expect_any_instance_of(Puppet::Resource::Catalog).not_to receive(:apply)
|
306
|
+
expect(configurer).to receive(:send_report)
|
343
307
|
|
344
|
-
expect(
|
308
|
+
expect(configurer.run(report: report)).to be_nil
|
345
309
|
end
|
346
310
|
|
347
311
|
it "should apply the catalog, send the report, and return nil if the post-run command fails" do
|
348
|
-
report = Puppet::Transaction::Report.new
|
349
|
-
expect(Puppet::Transaction::Report).to receive(:new).and_return(report)
|
350
|
-
|
351
312
|
Puppet.settings[:postrun_command] = "/my/command"
|
352
313
|
expect(Puppet::Util::Execution).to receive(:execute).with(["/my/command"]).and_raise(Puppet::ExecutionFailure, "Failed")
|
353
314
|
|
354
|
-
|
355
|
-
expect(
|
315
|
+
expect_any_instance_of(Puppet::Resource::Catalog).to receive(:apply)
|
316
|
+
expect(configurer).to receive(:send_report)
|
356
317
|
|
357
|
-
expect(
|
318
|
+
expect(configurer.run(report: report)).to be_nil
|
358
319
|
end
|
359
320
|
|
360
321
|
it 'includes total time metrics in the report after successfully applying the catalog' do
|
361
|
-
report
|
362
|
-
allow(@catalog).to receive(:apply).with(:report => report)
|
363
|
-
@agent.run(report: report)
|
322
|
+
configurer.run(report: report)
|
364
323
|
|
365
324
|
expect(report.metrics['time']).to be
|
366
325
|
expect(report.metrics['time']['total']).to be_a_kind_of(Numeric)
|
@@ -370,17 +329,15 @@ describe Puppet::Configurer do
|
|
370
329
|
Puppet.settings[:prerun_command] = "/my/command"
|
371
330
|
expect(Puppet::Util::Execution).to receive(:execute).with(["/my/command"]).and_raise(Puppet::ExecutionFailure, "Failed")
|
372
331
|
|
373
|
-
report
|
374
|
-
@agent.run(report: report)
|
332
|
+
configurer.run(report: report)
|
375
333
|
|
376
334
|
expect(report.metrics['time']).to be
|
377
335
|
expect(report.metrics['time']['total']).to be_a_kind_of(Numeric)
|
378
336
|
end
|
379
337
|
|
380
338
|
it 'includes total time metrics in the report even if catalog retrieval fails' do
|
381
|
-
|
382
|
-
|
383
|
-
@agent.run(:report => report)
|
339
|
+
allow(configurer).to receive(:prepare_and_retrieve_catalog_from_cache).and_raise
|
340
|
+
configurer.run(:report => report)
|
384
341
|
|
385
342
|
expect(report.metrics['time']).to be
|
386
343
|
expect(report.metrics['time']['total']).to be_a_kind_of(Numeric)
|
@@ -388,96 +345,93 @@ describe Puppet::Configurer do
|
|
388
345
|
|
389
346
|
it "should refetch the catalog if the server specifies a new environment in the catalog" do
|
390
347
|
catalog = Puppet::Resource::Catalog.new("tester", Puppet::Node::Environment.remote('second_env'))
|
391
|
-
expect(
|
348
|
+
expect(configurer).to receive(:retrieve_catalog).and_return(catalog).twice
|
392
349
|
|
393
|
-
|
350
|
+
configurer.run
|
394
351
|
end
|
395
352
|
|
396
|
-
it "
|
397
|
-
|
353
|
+
it "changes the configurer's environment if the server specifies a new environment in the catalog" do
|
354
|
+
allow_any_instance_of(Puppet::Resource::Catalog).to receive(:environment).and_return("second_env")
|
398
355
|
|
399
|
-
|
356
|
+
configurer.run
|
400
357
|
|
401
|
-
expect(
|
358
|
+
expect(configurer.environment).to eq("second_env")
|
402
359
|
end
|
403
360
|
|
404
|
-
it "
|
405
|
-
|
406
|
-
expect(Puppet::Transaction::Report).to receive(:new).and_return(report)
|
407
|
-
expect(@agent).to receive(:send_report).with(report)
|
408
|
-
|
409
|
-
allow(@catalog).to receive(:environment).and_return("second_env")
|
410
|
-
allow(@agent).to receive(:retrieve_catalog).and_return(@catalog)
|
361
|
+
it "changes the report's environment if the server specifies a new environment in the catalog" do
|
362
|
+
allow_any_instance_of(Puppet::Resource::Catalog).to receive(:environment).and_return("second_env")
|
411
363
|
|
412
|
-
|
364
|
+
configurer.run(report: report)
|
413
365
|
|
414
366
|
expect(report.environment).to eq("second_env")
|
415
367
|
end
|
416
368
|
|
417
369
|
it "sends the transaction uuid in a catalog request" do
|
418
|
-
|
370
|
+
configurer = Puppet::Configurer.new('aaa')
|
419
371
|
expect(Puppet::Resource::Catalog.indirection).to receive(:find).with(anything, hash_including(transaction_uuid: 'aaa'))
|
420
|
-
|
372
|
+
configurer.run
|
421
373
|
end
|
422
374
|
|
423
375
|
it "sends the transaction uuid in a catalog request" do
|
424
|
-
|
376
|
+
configurer = Puppet::Configurer.new('b', 'aaa')
|
425
377
|
expect(Puppet::Resource::Catalog.indirection).to receive(:find).with(anything, hash_including(job_id: 'aaa'))
|
426
|
-
|
378
|
+
configurer.run
|
427
379
|
end
|
428
380
|
|
429
381
|
it "sets the static_catalog query param to true in a catalog request" do
|
430
382
|
expect(Puppet::Resource::Catalog.indirection).to receive(:find).with(anything, hash_including(static_catalog: true))
|
431
|
-
|
383
|
+
configurer.run
|
432
384
|
end
|
433
385
|
|
434
386
|
it "sets the checksum_type query param to the default supported_checksum_types in a catalog request" do
|
435
387
|
expect(Puppet::Resource::Catalog.indirection).to receive(:find).with(anything,
|
436
388
|
hash_including(checksum_type: 'md5.sha256.sha384.sha512.sha224'))
|
437
|
-
|
389
|
+
configurer.run
|
438
390
|
end
|
439
391
|
|
440
392
|
it "sets the checksum_type query param to the supported_checksum_types setting in a catalog request" do
|
441
|
-
# Regenerate the agent to pick up the new setting
|
442
393
|
Puppet[:supported_checksum_types] = ['sha256']
|
443
|
-
|
444
|
-
|
445
|
-
allow(@agent).to receive(:download_plugins)
|
446
|
-
allow(@agent).to receive(:send_report)
|
447
|
-
allow(@agent).to receive(:save_last_run_summary)
|
394
|
+
# Regenerate the agent to pick up the new setting
|
395
|
+
configurer = Puppet::Configurer.new
|
448
396
|
|
449
397
|
expect(Puppet::Resource::Catalog.indirection).to receive(:find).with(anything, hash_including(checksum_type: 'sha256'))
|
450
|
-
|
398
|
+
configurer.run
|
451
399
|
end
|
452
400
|
|
453
401
|
describe "when not using a REST terminus for catalogs" do
|
454
402
|
it "should not pass any facts when retrieving the catalog" do
|
403
|
+
# This is weird, we collect facts when constructing the node,
|
404
|
+
# but we don't send them in the indirector request. Then the compiler
|
405
|
+
# looks up the node, and collects its facts, which we could have sent
|
406
|
+
# in the first place. This seems like a bug.
|
455
407
|
Puppet::Resource::Catalog.indirection.terminus_class = :compiler
|
456
|
-
|
408
|
+
|
457
409
|
expect(Puppet::Resource::Catalog.indirection).to receive(:find) do |name, options|
|
458
|
-
options[:facts].
|
459
|
-
end.and_return(
|
410
|
+
expect(options[:facts]).to be_nil
|
411
|
+
end.and_return(catalog)
|
460
412
|
|
461
|
-
|
413
|
+
configurer.run
|
462
414
|
end
|
463
415
|
end
|
464
416
|
|
465
417
|
describe "when using a REST terminus for catalogs" do
|
466
|
-
it "should pass the
|
418
|
+
it "should pass the url encoded facts and facts format as arguments when retrieving the catalog" do
|
467
419
|
Puppet::Resource::Catalog.indirection.terminus_class = :rest
|
468
|
-
expect(@agent).to receive(:facts_for_uploading).and_return(:facts => "myfacts", :facts_format => :foo)
|
469
|
-
expect(Puppet::Resource::Catalog.indirection).to receive(:find).with(anything, hash_including(facts: "myfacts", facts_format: :foo)).and_return(@catalog)
|
470
420
|
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
421
|
+
facts.values = { 'foo' => 'bar' }
|
422
|
+
Puppet::Node::Facts.indirection.save(facts)
|
423
|
+
|
424
|
+
expect(
|
425
|
+
Puppet::Resource::Catalog.indirection
|
426
|
+
).to receive(:find) do |_, options|
|
427
|
+
expect(options[:facts_format]).to eq("application/json")
|
475
428
|
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
429
|
+
unescaped = JSON.parse(CGI.unescape(options[:facts]))
|
430
|
+
expect(unescaped).to include("values" => {"foo" => "bar"})
|
431
|
+
end.and_return(catalog)
|
432
|
+
|
433
|
+
configurer.run
|
434
|
+
end
|
481
435
|
end
|
482
436
|
end
|
483
437
|
|
@@ -485,56 +439,52 @@ describe Puppet::Configurer do
|
|
485
439
|
include PuppetSpec::Files
|
486
440
|
|
487
441
|
before do
|
488
|
-
allow(Puppet.settings).to receive(:use).and_return(true)
|
489
|
-
@configurer = Puppet::Configurer.new
|
490
442
|
Puppet[:lastrunfile] = tmpfile('last_run_file')
|
491
|
-
|
492
|
-
@report = Puppet::Transaction::Report.new
|
493
443
|
Puppet[:reports] = "none"
|
494
444
|
end
|
495
445
|
|
496
446
|
it "should print a report summary if configured to do so" do
|
497
447
|
Puppet.settings[:summarize] = true
|
498
448
|
|
499
|
-
expect(
|
449
|
+
expect(report).to receive(:summary).and_return("stuff")
|
500
450
|
|
501
|
-
expect(
|
502
|
-
|
451
|
+
expect(configurer).to receive(:puts).with("stuff")
|
452
|
+
configurer.send_report(report)
|
503
453
|
end
|
504
454
|
|
505
455
|
it "should not print a report summary if not configured to do so" do
|
506
456
|
Puppet.settings[:summarize] = false
|
507
457
|
|
508
|
-
expect(
|
509
|
-
|
458
|
+
expect(configurer).not_to receive(:puts)
|
459
|
+
configurer.send_report(report)
|
510
460
|
end
|
511
461
|
|
512
462
|
it "should save the report if reporting is enabled" do
|
513
463
|
Puppet.settings[:report] = true
|
514
464
|
|
515
|
-
expect(Puppet::Transaction::Report.indirection).to receive(:save).with(
|
516
|
-
|
465
|
+
expect(Puppet::Transaction::Report.indirection).to receive(:save).with(report, nil, instance_of(Hash))
|
466
|
+
configurer.send_report(report)
|
517
467
|
end
|
518
468
|
|
519
469
|
it "should not save the report if reporting is disabled" do
|
520
470
|
Puppet.settings[:report] = false
|
521
471
|
|
522
|
-
expect(Puppet::Transaction::Report.indirection).not_to receive(:save).with(
|
523
|
-
|
472
|
+
expect(Puppet::Transaction::Report.indirection).not_to receive(:save).with(report, nil, instance_of(Hash))
|
473
|
+
configurer.send_report(report)
|
524
474
|
end
|
525
475
|
|
526
476
|
it "should save the last run summary if reporting is enabled" do
|
527
477
|
Puppet.settings[:report] = true
|
528
478
|
|
529
|
-
expect(
|
530
|
-
|
479
|
+
expect(configurer).to receive(:save_last_run_summary).with(report)
|
480
|
+
configurer.send_report(report)
|
531
481
|
end
|
532
482
|
|
533
483
|
it "should save the last run summary if reporting is disabled" do
|
534
484
|
Puppet.settings[:report] = false
|
535
485
|
|
536
|
-
expect(
|
537
|
-
|
486
|
+
expect(configurer).to receive(:save_last_run_summary).with(report)
|
487
|
+
configurer.send_report(report)
|
538
488
|
end
|
539
489
|
|
540
490
|
it "should log but not fail if saving the report fails" do
|
@@ -543,7 +493,7 @@ describe Puppet::Configurer do
|
|
543
493
|
expect(Puppet::Transaction::Report.indirection).to receive(:save).and_raise("whatever")
|
544
494
|
|
545
495
|
expect(Puppet).to receive(:err)
|
546
|
-
expect {
|
496
|
+
expect { configurer.send_report(report) }.not_to raise_error
|
547
497
|
end
|
548
498
|
end
|
549
499
|
|
@@ -551,22 +501,17 @@ describe Puppet::Configurer do
|
|
551
501
|
include PuppetSpec::Files
|
552
502
|
|
553
503
|
before do
|
554
|
-
allow(Puppet.settings).to receive(:use).and_return(true)
|
555
|
-
@configurer = Puppet::Configurer.new
|
556
|
-
|
557
|
-
@report = double('report', :raw_summary => {})
|
558
|
-
|
559
504
|
Puppet[:lastrunfile] = tmpfile('last_run_file')
|
560
505
|
end
|
561
506
|
|
562
507
|
it "should write the last run file" do
|
563
|
-
|
508
|
+
configurer.save_last_run_summary(report)
|
564
509
|
expect(Puppet::FileSystem.exist?(Puppet[:lastrunfile])).to be_truthy
|
565
510
|
end
|
566
511
|
|
567
512
|
it "should write the raw summary as yaml" do
|
568
|
-
expect(
|
569
|
-
|
513
|
+
expect(report).to receive(:raw_summary).and_return("summary")
|
514
|
+
configurer.save_last_run_summary(report)
|
570
515
|
expect(File.read(Puppet[:lastrunfile])).to eq(YAML.dump("summary"))
|
571
516
|
end
|
572
517
|
|
@@ -582,12 +527,12 @@ describe Puppet::Configurer do
|
|
582
527
|
expect(Puppet::Util).to receive(:replace_file).and_yield(fh)
|
583
528
|
|
584
529
|
expect(Puppet).to receive(:err)
|
585
|
-
expect {
|
530
|
+
expect { configurer.save_last_run_summary(report) }.to_not raise_error
|
586
531
|
end
|
587
532
|
|
588
533
|
it "should create the last run file with the correct mode" do
|
589
534
|
expect(Puppet.settings.setting(:lastrunfile)).to receive(:mode).and_return('664')
|
590
|
-
|
535
|
+
configurer.save_last_run_summary(report)
|
591
536
|
|
592
537
|
if Puppet::Util::Platform.windows?
|
593
538
|
require 'puppet/util/windows/security'
|
@@ -601,28 +546,37 @@ describe Puppet::Configurer do
|
|
601
546
|
it "should report invalid last run file permissions" do
|
602
547
|
expect(Puppet.settings.setting(:lastrunfile)).to receive(:mode).and_return('892')
|
603
548
|
expect(Puppet).to receive(:err).with(/Could not save last run local report.*892 is invalid/)
|
604
|
-
|
549
|
+
configurer.save_last_run_summary(report)
|
605
550
|
end
|
606
551
|
end
|
607
552
|
|
608
553
|
describe "when requesting a node" do
|
609
554
|
it "uses the transaction uuid in the request" do
|
610
555
|
expect(Puppet::Node.indirection).to receive(:find).with(anything, hash_including(transaction_uuid: anything)).twice
|
611
|
-
|
556
|
+
configurer.run
|
612
557
|
end
|
613
558
|
|
614
559
|
it "sends an explicitly configured environment request" do
|
615
560
|
expect(Puppet.settings).to receive(:set_by_config?).with(:environment).and_return(true)
|
616
561
|
expect(Puppet::Node.indirection).to receive(:find).with(anything, hash_including(configured_environment: Puppet[:environment])).twice
|
617
|
-
|
562
|
+
configurer.run
|
618
563
|
end
|
619
564
|
|
620
565
|
it "does not send a configured_environment when using the default" do
|
621
566
|
expect(Puppet::Node.indirection).to receive(:find).with(anything, hash_including(configured_environment: nil)).twice
|
622
|
-
|
567
|
+
configurer.run
|
623
568
|
end
|
624
569
|
end
|
625
570
|
|
571
|
+
def expects_pluginsync
|
572
|
+
metadata = "[{\"path\":\"/etc/puppetlabs/code\",\"relative_path\":\".\",\"links\":\"follow\",\"owner\":0,\"group\":0,\"mode\":420,\"checksum\":{\"type\":\"ctime\",\"value\":\"{ctime}2020-07-10 14:00:00 -0700\"},\"type\":\"directory\",\"destination\":null}]"
|
573
|
+
stub_request(:get, %r{/puppet/v3/file_metadatas/(plugins|locales)}).to_return(status: 200, body: metadata, headers: {'Content-Type' => 'application/json'})
|
574
|
+
|
575
|
+
# response retains owner/group/mode due to source_permissions => use
|
576
|
+
facts_metadata = "[{\"path\":\"/etc/puppetlabs/code\",\"relative_path\":\".\",\"links\":\"follow\",\"owner\":500,\"group\":500,\"mode\":493,\"checksum\":{\"type\":\"ctime\",\"value\":\"{ctime}2020-07-10 14:00:00 -0700\"},\"type\":\"directory\",\"destination\":null}]"
|
577
|
+
stub_request(:get, %r{/puppet/v3/file_metadatas/pluginfacts}).to_return(status: 200, body: facts_metadata, headers: {'Content-Type' => 'application/json'})
|
578
|
+
end
|
579
|
+
|
626
580
|
def expects_new_catalog_only(catalog)
|
627
581
|
expect(Puppet::Resource::Catalog.indirection).to receive(:find).with(anything, hash_including(ignore_cache: true)).and_return(catalog)
|
628
582
|
expect(Puppet::Resource::Catalog.indirection).not_to receive(:find).with(anything, hash_including(ignore_terminus: true))
|
@@ -639,6 +593,7 @@ describe Puppet::Configurer do
|
|
639
593
|
end
|
640
594
|
|
641
595
|
def expects_fallback_to_new_catalog(catalog)
|
596
|
+
expects_pluginsync
|
642
597
|
expect(Puppet::Resource::Catalog.indirection).to receive(:find).with(anything, hash_including(ignore_terminus: true)).and_return(nil)
|
643
598
|
expect(Puppet::Resource::Catalog.indirection).to receive(:find).with(anything, hash_including(ignore_cache: true)).and_return(catalog)
|
644
599
|
end
|
@@ -650,14 +605,6 @@ describe Puppet::Configurer do
|
|
650
605
|
|
651
606
|
describe "when retrieving a catalog" do
|
652
607
|
before do
|
653
|
-
allow(Puppet.settings).to receive(:use).and_return(true)
|
654
|
-
allow(@agent).to receive(:facts_for_uploading).and_return({})
|
655
|
-
allow(@agent).to receive(:download_plugins)
|
656
|
-
|
657
|
-
# retrieve a catalog in the current environment, so we don't try to converge unexpectedly
|
658
|
-
@catalog = Puppet::Resource::Catalog.new("tester", Puppet::Node::Environment.remote(Puppet[:environment].to_sym))
|
659
|
-
|
660
|
-
# this is the default when using a Configurer instance
|
661
608
|
allow(Puppet::Resource::Catalog.indirection).to receive(:terminus_class).and_return(:rest)
|
662
609
|
end
|
663
610
|
|
@@ -667,100 +614,127 @@ describe Puppet::Configurer do
|
|
667
614
|
end
|
668
615
|
|
669
616
|
it "should first look in the cache for a catalog" do
|
670
|
-
expects_cached_catalog_only(
|
617
|
+
expects_cached_catalog_only(catalog)
|
671
618
|
|
672
|
-
|
619
|
+
configurer.run
|
673
620
|
end
|
674
621
|
|
675
622
|
it "should not make a node request or pluginsync when a cached catalog is successfully retrieved" do
|
676
623
|
expect(Puppet::Node.indirection).not_to receive(:find)
|
677
|
-
expects_cached_catalog_only(
|
678
|
-
expect(
|
624
|
+
expects_cached_catalog_only(catalog)
|
625
|
+
expect(configurer).not_to receive(:download_plugins)
|
679
626
|
|
680
|
-
|
627
|
+
configurer.run
|
681
628
|
end
|
682
629
|
|
683
630
|
it "should make a node request and pluginsync when a cached catalog cannot be retrieved" do
|
684
631
|
expect(Puppet::Node.indirection).to receive(:find).and_return(nil)
|
685
|
-
expects_fallback_to_new_catalog(
|
686
|
-
expect(@agent).to receive(:download_plugins)
|
632
|
+
expects_fallback_to_new_catalog(catalog)
|
687
633
|
|
688
|
-
|
634
|
+
configurer.run
|
689
635
|
end
|
690
636
|
|
691
637
|
it "should set its cached_catalog_status to 'explicitly_requested'" do
|
692
|
-
expects_cached_catalog_only(
|
638
|
+
expects_cached_catalog_only(catalog)
|
693
639
|
|
694
|
-
|
695
|
-
|
640
|
+
options = {}
|
641
|
+
configurer.run(options)
|
642
|
+
|
643
|
+
expect(options[:report].cached_catalog_status).to eq('explicitly_requested')
|
696
644
|
end
|
697
645
|
|
698
646
|
it "should set its cached_catalog_status to 'explicitly requested' if the cached catalog is from a different environment" do
|
699
647
|
cached_catalog = Puppet::Resource::Catalog.new("tester", Puppet::Node::Environment.remote('second_env'))
|
700
648
|
expects_cached_catalog_only(cached_catalog)
|
701
649
|
|
702
|
-
|
703
|
-
|
650
|
+
options = {}
|
651
|
+
configurer.run(options)
|
652
|
+
|
653
|
+
expect(options[:report].cached_catalog_status).to eq('explicitly_requested')
|
704
654
|
end
|
705
655
|
|
706
656
|
it "should compile a new catalog if none is found in the cache" do
|
707
|
-
expects_fallback_to_new_catalog(
|
657
|
+
expects_fallback_to_new_catalog(catalog)
|
708
658
|
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
it "should set its cached_catalog_status to 'not_used' if no catalog is found in the cache" do
|
713
|
-
expects_fallback_to_new_catalog(@catalog)
|
659
|
+
options = {}
|
660
|
+
configurer.run(options)
|
714
661
|
|
715
|
-
|
716
|
-
expect(@agent.instance_variable_get(:@cached_catalog_status)).to eq('not_used')
|
662
|
+
expect(options[:report].cached_catalog_status).to eq('not_used')
|
717
663
|
end
|
718
664
|
|
719
665
|
it "should not attempt to retrieve a cached catalog again if the first attempt failed" do
|
720
666
|
expect(Puppet::Node.indirection).to receive(:find).and_return(nil)
|
721
667
|
expects_neither_new_or_cached_catalog
|
668
|
+
expects_pluginsync
|
722
669
|
|
723
|
-
|
670
|
+
configurer.run
|
724
671
|
end
|
725
672
|
|
726
673
|
it "should return the cached catalog when the environment doesn't match" do
|
727
674
|
cached_catalog = Puppet::Resource::Catalog.new("tester", Puppet::Node::Environment.remote('second_env'))
|
728
675
|
expects_cached_catalog_only(cached_catalog)
|
729
676
|
|
677
|
+
allow(Puppet).to receive(:info)
|
730
678
|
expect(Puppet).to receive(:info).with("Using cached catalog from environment 'second_env'")
|
731
|
-
|
679
|
+
|
680
|
+
configurer.run
|
681
|
+
end
|
682
|
+
|
683
|
+
it "applies the catalog passed as options when the catalog cache terminus is not set" do
|
684
|
+
expects_pluginsync
|
685
|
+
|
686
|
+
catalog.add_resource(Puppet::Resource.new('notify', 'from apply'))
|
687
|
+
configurer.run(catalog: catalog.to_ral)
|
688
|
+
|
689
|
+
# make sure cache class is not set to avoid surprises later
|
690
|
+
expect(Puppet::Resource::Catalog.indirection).to_not be_cache
|
691
|
+
expect(@logs).to include(an_object_having_attributes(level: :notice, message: /defined 'message' as 'from apply'/))
|
692
|
+
end
|
693
|
+
|
694
|
+
it "applies the cached catalog when the catalog cache terminus is set, ignoring the catalog passed as options" do
|
695
|
+
Puppet::Resource::Catalog.indirection.cache_class = :json
|
696
|
+
|
697
|
+
cached_catalog = Puppet::Resource::Catalog.new(Puppet[:node_name_value], Puppet[:environment])
|
698
|
+
cached_catalog.add_resource(Puppet::Resource.new('notify', 'from cache'))
|
699
|
+
|
700
|
+
# update cached catalog
|
701
|
+
Puppet.settings.use(:main, :agent)
|
702
|
+
path = Puppet::Resource::Catalog.indirection.cache.path(cached_catalog.name)
|
703
|
+
FileUtils.mkdir(File.dirname(path))
|
704
|
+
File.write(path, cached_catalog.render(:json))
|
705
|
+
|
706
|
+
configurer.run(catalog: catalog.to_ral)
|
707
|
+
|
708
|
+
expect(@logs).to include(an_object_having_attributes(level: :notice, message: /defined 'message' as 'from cache'/))
|
732
709
|
end
|
733
710
|
end
|
734
711
|
|
735
712
|
describe "and strict environment mode is set" do
|
736
713
|
before do
|
737
|
-
allow(@catalog).to receive(:to_ral).and_return(@catalog)
|
738
|
-
allow(@catalog).to receive(:write_class_file)
|
739
|
-
allow(@catalog).to receive(:write_resource_file)
|
740
|
-
allow(@agent).to receive(:send_report)
|
741
|
-
allow(@agent).to receive(:save_last_run_summary)
|
742
714
|
Puppet.settings[:strict_environment_mode] = true
|
743
715
|
end
|
744
716
|
|
745
717
|
it "should not make a node request" do
|
746
718
|
expect(Puppet::Node.indirection).not_to receive(:find)
|
747
719
|
|
748
|
-
|
720
|
+
configurer.run
|
749
721
|
end
|
750
722
|
|
751
723
|
it "should return nil when the catalog's environment doesn't match the agent specified environment" do
|
752
|
-
|
753
|
-
|
724
|
+
Puppet[:environment] = 'second_env'
|
725
|
+
configurer = Puppet::Configurer.new
|
726
|
+
|
727
|
+
catalog = Puppet::Resource::Catalog.new("tester", Puppet::Node::Environment.remote("production"))
|
728
|
+
expects_new_catalog_only(catalog)
|
754
729
|
|
755
730
|
expect(Puppet).to receive(:err).with("Not using catalog because its environment 'production' does not match agent specified environment 'second_env' and strict_environment_mode is set")
|
756
|
-
expect(
|
731
|
+
expect(configurer.run).to be_nil
|
757
732
|
end
|
758
733
|
|
759
|
-
it "should
|
760
|
-
|
761
|
-
expects_new_catalog_only(@catalog)
|
734
|
+
it "should return 0 when the catalog's environment matches the agent specified environment" do
|
735
|
+
expects_new_catalog_only(catalog)
|
762
736
|
|
763
|
-
expect(
|
737
|
+
expect(configurer.run).to eq(0)
|
764
738
|
end
|
765
739
|
|
766
740
|
describe "and a cached catalog is explicitly requested" do
|
@@ -769,83 +743,81 @@ describe Puppet::Configurer do
|
|
769
743
|
end
|
770
744
|
|
771
745
|
it "should return nil when the cached catalog's environment doesn't match the agent specified environment" do
|
772
|
-
|
773
|
-
|
746
|
+
Puppet[:environment] = 'second_env'
|
747
|
+
configurer = Puppet::Configurer.new
|
748
|
+
|
749
|
+
catalog = Puppet::Resource::Catalog.new("tester", Puppet::Node::Environment.remote("production"))
|
750
|
+
expects_cached_catalog_only(catalog)
|
774
751
|
|
775
752
|
expect(Puppet).to receive(:err).with("Not using catalog because its environment 'production' does not match agent specified environment 'second_env' and strict_environment_mode is set")
|
776
|
-
expect(
|
753
|
+
expect(configurer.run).to be_nil
|
777
754
|
end
|
778
755
|
|
779
756
|
it "should proceed with the cached catalog if its environment matchs the local environment" do
|
780
|
-
|
781
|
-
@agent.instance_variable_set(:@environment, 'production')
|
782
|
-
expects_cached_catalog_only(@catalog)
|
757
|
+
expects_cached_catalog_only(catalog)
|
783
758
|
|
784
|
-
expect(
|
759
|
+
expect(configurer.run).to eq(0)
|
785
760
|
end
|
786
761
|
end
|
787
762
|
end
|
788
763
|
|
789
|
-
it "should use the Catalog class to get its catalog" do
|
790
|
-
expect(Puppet::Resource::Catalog.indirection).to receive(:find).and_return(@catalog)
|
791
|
-
|
792
|
-
@agent.retrieve_catalog({})
|
793
|
-
end
|
794
|
-
|
795
764
|
it "should set its cached_catalog_status to 'not_used' when downloading a new catalog" do
|
796
|
-
expect(Puppet::Resource::Catalog.indirection).to receive(:find).with(anything, hash_including(ignore_cache: true)).and_return(
|
765
|
+
expect(Puppet::Resource::Catalog.indirection).to receive(:find).with(anything, hash_including(ignore_cache: true)).and_return(catalog)
|
797
766
|
|
798
|
-
|
799
|
-
|
767
|
+
options = {}
|
768
|
+
configurer.run(options)
|
769
|
+
|
770
|
+
expect(options[:report].cached_catalog_status).to eq('not_used')
|
800
771
|
end
|
801
772
|
|
802
773
|
it "should use its node_name_value to retrieve the catalog" do
|
803
|
-
|
804
|
-
Puppet.
|
805
|
-
expect(Puppet::Resource::Catalog.indirection).to receive(:find).with("myhost.domain.com", anything).and_return(@catalog)
|
806
|
-
|
807
|
-
@agent.retrieve_catalog({})
|
808
|
-
end
|
774
|
+
myhost_facts = Puppet::Node::Facts.new("myhost.domain.com")
|
775
|
+
Puppet::Node::Facts.indirection.save(myhost_facts)
|
809
776
|
|
810
|
-
|
811
|
-
expect(Puppet::Resource::Catalog.indirection).to receive(:find).with(
|
777
|
+
Puppet.settings[:node_name_value] = "myhost.domain.com"
|
778
|
+
expect(Puppet::Resource::Catalog.indirection).to receive(:find).with("myhost.domain.com", anything).and_return(catalog)
|
812
779
|
|
813
|
-
|
780
|
+
configurer.run
|
814
781
|
end
|
815
782
|
|
816
|
-
it "should log
|
817
|
-
expects_fallback_to_cached_catalog(
|
783
|
+
it "should log when no catalog can be retrieved from the server" do
|
784
|
+
expects_fallback_to_cached_catalog(catalog)
|
818
785
|
|
786
|
+
allow(Puppet).to receive(:info)
|
819
787
|
expect(Puppet).to receive(:info).with("Using cached catalog from environment 'production'")
|
820
|
-
|
788
|
+
configurer.run
|
821
789
|
end
|
822
790
|
|
823
791
|
it "should set its cached_catalog_status to 'on_failure' when no catalog can be retrieved from the server" do
|
824
|
-
expects_fallback_to_cached_catalog(
|
792
|
+
expects_fallback_to_cached_catalog(catalog)
|
793
|
+
|
794
|
+
options = {}
|
795
|
+
configurer.run(options)
|
825
796
|
|
826
|
-
|
827
|
-
expect(@agent.instance_variable_get(:@cached_catalog_status)).to eq('on_failure')
|
797
|
+
expect(options[:report].cached_catalog_status).to eq('on_failure')
|
828
798
|
end
|
829
799
|
|
830
800
|
it "should not look in the cache for a catalog if one is returned from the server" do
|
831
|
-
expects_new_catalog_only(
|
801
|
+
expects_new_catalog_only(catalog)
|
832
802
|
|
833
|
-
|
803
|
+
configurer.run
|
834
804
|
end
|
835
805
|
|
836
806
|
it "should return the cached catalog when retrieving the remote catalog throws an exception" do
|
837
807
|
expect(Puppet::Resource::Catalog.indirection).to receive(:find).with(anything, hash_including(ignore_cache: true)).and_raise("eh")
|
838
|
-
expect(Puppet::Resource::Catalog.indirection).to receive(:find).with(anything, hash_including(ignore_terminus: true)).and_return(
|
808
|
+
expect(Puppet::Resource::Catalog.indirection).to receive(:find).with(anything, hash_including(ignore_terminus: true)).and_return(catalog)
|
839
809
|
|
840
|
-
|
810
|
+
configurer.run
|
841
811
|
end
|
842
812
|
|
843
813
|
it "should set its cached_catalog_status to 'on_failure' when retrieving the remote catalog throws an exception" do
|
844
814
|
expect(Puppet::Resource::Catalog.indirection).to receive(:find).with(anything, hash_including(ignore_cache: true)).and_raise("eh")
|
845
|
-
expect(Puppet::Resource::Catalog.indirection).to receive(:find).with(anything, hash_including(ignore_terminus: true)).and_return(
|
815
|
+
expect(Puppet::Resource::Catalog.indirection).to receive(:find).with(anything, hash_including(ignore_terminus: true)).and_return(catalog)
|
816
|
+
|
817
|
+
options = {}
|
818
|
+
configurer.run(options)
|
846
819
|
|
847
|
-
|
848
|
-
expect(@agent.instance_variable_get(:@cached_catalog_status)).to eq('on_failure')
|
820
|
+
expect(options[:report].cached_catalog_status).to eq('on_failure')
|
849
821
|
end
|
850
822
|
|
851
823
|
it "should log and return nil if no catalog can be retrieved from the server and :usecacheonfailure is disabled" do
|
@@ -854,120 +826,173 @@ describe Puppet::Configurer do
|
|
854
826
|
|
855
827
|
expect(Puppet).to receive(:warning).with('Not using cache on failed catalog')
|
856
828
|
|
857
|
-
expect(
|
829
|
+
expect(configurer.run).to be_nil
|
858
830
|
end
|
859
831
|
|
860
832
|
it "should set its cached_catalog_status to 'not_used' if no catalog can be retrieved from the server and :usecacheonfailure is disabled or fails to retrieve a catalog" do
|
861
833
|
Puppet[:usecacheonfailure] = false
|
862
834
|
expect(Puppet::Resource::Catalog.indirection).to receive(:find).with(anything, hash_including(ignore_cache: true)).and_return(nil)
|
863
835
|
|
864
|
-
|
865
|
-
|
836
|
+
options = {}
|
837
|
+
configurer.run(options)
|
838
|
+
|
839
|
+
expect(options[:report].cached_catalog_status).to eq('not_used')
|
866
840
|
end
|
867
841
|
|
868
842
|
it "should return nil if no cached catalog is available and no catalog can be retrieved from the server" do
|
869
843
|
expects_neither_new_or_cached_catalog
|
870
844
|
|
871
|
-
expect(
|
845
|
+
expect(configurer.run).to be_nil
|
872
846
|
end
|
873
847
|
|
874
848
|
it "should return nil if its cached catalog environment doesn't match server-specified environment" do
|
875
849
|
cached_catalog = Puppet::Resource::Catalog.new("tester", Puppet::Node::Environment.remote('second_env'))
|
876
|
-
@agent.instance_variable_set(:@node_environment, 'production')
|
877
850
|
|
878
851
|
expects_fallback_to_cached_catalog(cached_catalog)
|
879
852
|
|
853
|
+
allow(Puppet).to receive(:err)
|
880
854
|
expect(Puppet).to receive(:err).with("Not using cached catalog because its environment 'second_env' does not match 'production'")
|
881
|
-
expect(
|
855
|
+
expect(configurer.run).to be_nil
|
882
856
|
end
|
883
857
|
|
884
858
|
it "should set its cached_catalog_status to 'not_used' if the cached catalog environment doesn't match server-specified environment" do
|
885
859
|
cached_catalog = Puppet::Resource::Catalog.new("tester", Puppet::Node::Environment.remote('second_env'))
|
886
|
-
@agent.instance_variable_set(:@node_environment, 'production')
|
887
|
-
|
888
|
-
expects_fallback_to_cached_catalog(cached_catalog)
|
889
|
-
|
890
|
-
@agent.retrieve_catalog({})
|
891
|
-
expect(@agent.instance_variable_get(:@cached_catalog_status)).to eq('not_used')
|
892
|
-
end
|
893
|
-
|
894
|
-
it "should return its cached catalog if the environment matches the server-specified environment" do
|
895
|
-
cached_catalog = Puppet::Resource::Catalog.new("tester", Puppet::Node::Environment.remote(Puppet[:environment]))
|
896
|
-
@agent.instance_variable_set(:@node_environment, cached_catalog.environment)
|
897
860
|
|
898
861
|
expects_fallback_to_cached_catalog(cached_catalog)
|
899
862
|
|
900
|
-
|
863
|
+
options = {}
|
864
|
+
configurer.run(options)
|
865
|
+
expect(options[:report].cached_catalog_status).to eq('not_used')
|
901
866
|
end
|
902
867
|
|
903
868
|
it "should set its cached_catalog_status to 'on_failure' if the cached catalog environment matches server-specified environment" do
|
904
|
-
|
905
|
-
@agent.instance_variable_set(:@node_environment, cached_catalog.environment)
|
906
|
-
|
907
|
-
expects_fallback_to_cached_catalog(cached_catalog)
|
869
|
+
expects_fallback_to_cached_catalog(catalog)
|
908
870
|
|
909
|
-
|
910
|
-
|
871
|
+
options = {}
|
872
|
+
configurer.run(options)
|
873
|
+
expect(options[:report].cached_catalog_status).to eq('on_failure')
|
911
874
|
end
|
912
875
|
|
913
876
|
it "should not update the cached catalog in noop mode" do
|
914
877
|
Puppet[:noop] = true
|
915
|
-
expect(Puppet::Resource::Catalog.indirection).to receive(:find).with(anything, hash_including(ignore_cache: true, ignore_cache_save: true)).and_return(@catalog)
|
916
878
|
|
917
|
-
|
879
|
+
stub_request(:get, %r{/puppet/v3/catalog}).to_return(:status => 200, :body => catalog.render(:json), :headers => {'Content-Type' => 'application/json'})
|
880
|
+
|
881
|
+
Puppet::Resource::Catalog.indirection.cache_class = :json
|
882
|
+
path = Puppet::Resource::Catalog.indirection.cache.path(catalog.name)
|
883
|
+
|
884
|
+
expect(File).to_not be_exist(path)
|
885
|
+
configurer.run
|
886
|
+
expect(File).to_not be_exist(path)
|
918
887
|
end
|
919
888
|
|
920
889
|
it "should update the cached catalog when not in noop mode" do
|
921
890
|
Puppet[:noop] = false
|
922
|
-
|
891
|
+
Puppet[:log_level] = 'info'
|
892
|
+
|
893
|
+
stub_request(:get, %r{/puppet/v3/catalog}).to_return(:status => 200, :body => catalog.render(:json), :headers => {'Content-Type' => 'application/json'})
|
894
|
+
|
895
|
+
Puppet::Resource::Catalog.indirection.cache_class = :json
|
896
|
+
cache_path = Puppet::Resource::Catalog.indirection.cache.path(Puppet[:node_name_value])
|
923
897
|
|
924
|
-
|
898
|
+
expect(File).to_not be_exist(cache_path)
|
899
|
+
configurer.run
|
900
|
+
expect(File).to be_exist(cache_path)
|
901
|
+
|
902
|
+
expect(@logs).to include(an_object_having_attributes(level: :info, message: "Caching catalog for #{Puppet[:node_name_value]}"))
|
903
|
+
end
|
904
|
+
|
905
|
+
it "successfully applies the catalog without a cache" do
|
906
|
+
stub_request(:get, %r{/puppet/v3/catalog}).to_return(:status => 200, :body => catalog.render(:json), :headers => {'Content-Type' => 'application/json'})
|
907
|
+
|
908
|
+
Puppet::Resource::Catalog.indirection.cache_class = nil
|
909
|
+
|
910
|
+
expect(configurer.run).to eq(0)
|
911
|
+
end
|
912
|
+
|
913
|
+
it "should not update the cached catalog when running puppet apply" do
|
914
|
+
Puppet::Resource::Catalog.indirection.cache_class = :json
|
915
|
+
path = Puppet::Resource::Catalog.indirection.cache.path(catalog.name)
|
916
|
+
|
917
|
+
expect(File).to_not be_exist(path)
|
918
|
+
configurer.run(catalog: catalog)
|
919
|
+
expect(File).to_not be_exist(path)
|
925
920
|
end
|
926
921
|
end
|
927
922
|
|
928
|
-
describe "when
|
929
|
-
|
930
|
-
|
923
|
+
describe "when converging the environment" do
|
924
|
+
let(:apple) { Puppet::Resource::Catalog.new(Puppet[:node_name_value], Puppet::Node::Environment.remote('apple')) }
|
925
|
+
let(:banana) { Puppet::Resource::Catalog.new(Puppet[:node_name_value], Puppet::Node::Environment.remote('banana')) }
|
931
926
|
|
932
|
-
|
927
|
+
before :each do
|
928
|
+
apple.add_resource(resource)
|
929
|
+
banana.add_resource(resource)
|
933
930
|
end
|
934
931
|
|
935
|
-
|
936
|
-
|
932
|
+
it "converges after multiple attempts" do
|
933
|
+
expect(Puppet::Resource::Catalog.indirection).to receive(:find).and_return(apple, banana, banana)
|
937
934
|
|
938
|
-
|
939
|
-
expect(
|
935
|
+
allow(Puppet).to receive(:notice)
|
936
|
+
expect(Puppet).to receive(:notice).with("Local environment: 'production' doesn't match server specified environment 'apple', restarting agent run with environment 'apple'")
|
937
|
+
expect(Puppet).to receive(:notice).with("Local environment: 'apple' doesn't match server specified environment 'banana', restarting agent run with environment 'banana'")
|
938
|
+
|
939
|
+
configurer.run
|
940
940
|
end
|
941
941
|
|
942
|
-
it "
|
943
|
-
expect(
|
942
|
+
it "raises if it can't converge after 4 tries after the initial catalog request" do
|
943
|
+
expect(Puppet::Resource::Catalog.indirection).to receive(:find).and_return(apple, banana, apple, banana, apple)
|
944
|
+
|
945
|
+
expect(Puppet).to receive(:err).with("Failed to apply catalog: Catalog environment didn't stabilize after 4 fetches, aborting run")
|
944
946
|
|
945
|
-
|
947
|
+
configurer.run
|
946
948
|
end
|
949
|
+
end
|
947
950
|
|
948
|
-
|
949
|
-
|
951
|
+
describe "when converting the catalog" do
|
952
|
+
it "converts Puppet::Resource into Puppet::Type::Notify" do
|
953
|
+
expect(configurer).to receive(:apply_catalog) do |ral, _|
|
954
|
+
expect(ral.resources).to contain(an_instance_of(Puppet::Type::Notify))
|
955
|
+
end
|
950
956
|
|
951
|
-
|
957
|
+
configurer.run(catalog: catalog)
|
952
958
|
end
|
953
959
|
|
954
|
-
it "
|
955
|
-
expect(
|
960
|
+
it "adds default schedules" do
|
961
|
+
expect(configurer).to receive(:apply_catalog) do |ral, _|
|
962
|
+
expect(ral.resources.map(&:to_ref)).to contain(%w{Schedule[puppet] Schedule[hourly] Schedule[daily] Schedule[weekly] Schedule[monthly] Schedule[never]})
|
963
|
+
end
|
956
964
|
|
957
|
-
|
965
|
+
configurer.run
|
958
966
|
end
|
959
967
|
|
960
|
-
it "
|
961
|
-
expect(
|
968
|
+
it "records the retrieval duration to the catalog" do
|
969
|
+
expect(configurer).to receive(:apply_catalog) do |ral, _|
|
970
|
+
expect(ral.retrieval_duration).to be_an_instance_of(Float)
|
971
|
+
end
|
962
972
|
|
963
|
-
|
973
|
+
configurer.run
|
964
974
|
end
|
965
975
|
|
966
|
-
it "
|
967
|
-
|
976
|
+
it "writes the class file containing applied settings classes" do
|
977
|
+
expect(File).to_not be_exist(Puppet[:classfile])
|
978
|
+
|
979
|
+
configurer.run
|
968
980
|
|
969
|
-
expect(
|
970
|
-
|
981
|
+
expect(File.read(Puppet[:classfile]).chomp).to eq('settings')
|
982
|
+
end
|
983
|
+
|
984
|
+
it "writes an empty resource file since no resources are 'managed'" do
|
985
|
+
expect(File).to_not be_exist(Puppet[:resourcefile])
|
986
|
+
|
987
|
+
configurer.run
|
988
|
+
|
989
|
+
expect(File.read(Puppet[:resourcefile]).chomp).to eq("")
|
990
|
+
end
|
991
|
+
|
992
|
+
it "adds the conversion time to the report" do
|
993
|
+
configurer.run(report: report)
|
994
|
+
|
995
|
+
expect(report.metrics['time']['convert_catalog']).to be_an_instance_of(Float)
|
971
996
|
end
|
972
997
|
end
|
973
998
|
|
@@ -1002,80 +1027,70 @@ describe Puppet::Configurer do
|
|
1002
1027
|
describe "when attempting failover" do
|
1003
1028
|
it "should not failover if server_list is not set" do
|
1004
1029
|
Puppet.settings[:server_list] = []
|
1005
|
-
|
1006
|
-
@agent.run
|
1030
|
+
configurer.run
|
1007
1031
|
end
|
1008
1032
|
|
1009
1033
|
it "should not failover during an apply run" do
|
1010
1034
|
Puppet.settings[:server_list] = ["myserver:123"]
|
1011
|
-
expect(@agent).not_to receive(:find_functional_server)
|
1012
1035
|
catalog = Puppet::Resource::Catalog.new("tester", Puppet::Node::Environment.remote(Puppet[:environment].to_sym))
|
1013
|
-
|
1036
|
+
configurer.run(catalog: catalog)
|
1014
1037
|
end
|
1015
1038
|
|
1016
1039
|
it "should select a server when it receives 200 OK response" do
|
1017
1040
|
Puppet.settings[:server_list] = ["myserver:123"]
|
1018
|
-
|
1019
|
-
|
1020
|
-
allow(@agent).to receive(:run_internal)
|
1041
|
+
|
1042
|
+
stub_request(:get, 'https://myserver:123/status/v1/simple/master').to_return(status: 200)
|
1021
1043
|
|
1022
1044
|
options = {}
|
1023
|
-
|
1045
|
+
configurer.run(options)
|
1024
1046
|
expect(options[:report].master_used).to eq('myserver:123')
|
1025
1047
|
end
|
1026
1048
|
|
1027
1049
|
it "should select a server when it receives 403 Forbidden" do
|
1028
1050
|
Puppet.settings[:server_list] = ["myserver:123"]
|
1029
|
-
|
1030
|
-
|
1031
|
-
allow(@agent).to receive(:run_internal)
|
1051
|
+
|
1052
|
+
stub_request(:get, 'https://myserver:123/status/v1/simple/master').to_return(status: 403)
|
1032
1053
|
|
1033
1054
|
options = {}
|
1034
|
-
|
1055
|
+
configurer.run(options)
|
1035
1056
|
expect(options[:report].master_used).to eq('myserver:123')
|
1036
1057
|
end
|
1037
1058
|
|
1038
|
-
it "queries the simple status for the 'master' service" do
|
1039
|
-
Puppet.settings[:server_list] = ["myserver:123"]
|
1040
|
-
response = Net::HTTPOK.new(nil, 200, 'OK')
|
1041
|
-
http = double('request')
|
1042
|
-
expect(http).to receive(:get).with('/status/v1/simple/master').and_return(response)
|
1043
|
-
allow(Puppet::Network::HttpPool).to receive(:http_ssl_instance).with('myserver', '123').and_return(http)
|
1044
|
-
allow(@agent).to receive(:run_internal)
|
1045
|
-
|
1046
|
-
@agent.run
|
1047
|
-
end
|
1048
|
-
|
1049
1059
|
it "should report when a server is unavailable" do
|
1050
1060
|
Puppet.settings[:server_list] = ["myserver:123"]
|
1051
|
-
response = Net::HTTPInternalServerError.new(nil, 500, 'Internal Server Error')
|
1052
|
-
allow(Puppet::Network::HttpPool).to receive(:http_ssl_instance).with('myserver', '123').and_return(double('request', get: response))
|
1053
|
-
allow(@agent).to receive(:run_internal)
|
1054
1061
|
|
1062
|
+
stub_request(:get, 'https://myserver:123/status/v1/simple/master').to_return(status: [500, "Internal Server Error"])
|
1063
|
+
|
1064
|
+
allow(Puppet).to receive(:debug)
|
1055
1065
|
expect(Puppet).to receive(:debug).with("Puppet server myserver:123 is unavailable: 500 Internal Server Error")
|
1056
|
-
expect {
|
1066
|
+
expect {
|
1067
|
+
configurer.run
|
1068
|
+
}.to raise_error(Puppet::Error, /Could not select a functional puppet master from server_list:/)
|
1057
1069
|
end
|
1058
1070
|
|
1059
1071
|
it "should error when no servers in 'server_list' are reachable" do
|
1060
1072
|
Puppet.settings[:server_list] = "myserver:123,someotherservername"
|
1061
|
-
|
1062
|
-
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
1066
|
-
|
1067
|
-
|
1068
|
-
expect{ @agent.run }.to raise_error(Puppet::Error, /Could not select a functional puppet master from server_list: 'myserver:123,someotherservername'/)
|
1073
|
+
|
1074
|
+
stub_request(:get, 'https://myserver/status/v1/simple/master').to_return(status: 400)
|
1075
|
+
stub_request(:get, 'https://someotherservername/status/v1/simple/master').to_return(status: 400)
|
1076
|
+
|
1077
|
+
expect{
|
1078
|
+
configurer.run
|
1079
|
+
}.to raise_error(Puppet::Error, /Could not select a functional puppet master from server_list: 'myserver:123,someotherservername'/)
|
1069
1080
|
end
|
1070
1081
|
|
1071
|
-
it "should not make multiple node
|
1072
|
-
response = Net::HTTPOK.new(nil, 200, 'OK')
|
1073
|
-
allow(Puppet::Network::HttpPool).to receive(:http_ssl_instance).with('myserver', '123').and_return(double('request', get: response))
|
1074
|
-
|
1082
|
+
it "should not make multiple node requests when the server is found" do
|
1075
1083
|
Puppet.settings[:server_list] = ["myserver:123"]
|
1076
|
-
|
1077
|
-
|
1078
|
-
|
1084
|
+
Puppet::Node.indirection.terminus_class = :rest
|
1085
|
+
Puppet::Resource::Catalog.indirection.terminus_class = :rest
|
1086
|
+
|
1087
|
+
stub_request(:get, 'https://myserver:123/status/v1/simple/master').to_return(status: 200)
|
1088
|
+
stub_request(:get, %r{https://myserver:123/puppet/v3/catalog}).to_return(status: 200)
|
1089
|
+
node_request = stub_request(:get, %r{https://myserver:123/puppet/v3/node/}).to_return(status: 200)
|
1090
|
+
|
1091
|
+
configurer.run
|
1092
|
+
|
1093
|
+
expect(node_request).to have_been_requested.once
|
1079
1094
|
end
|
1080
1095
|
end
|
1081
1096
|
end
|