puppet 7.9.0 → 7.10.0

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.

Files changed (182) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +6 -6
  3. data/{ext → examples/enc}/regexp_nodes/classes/databases +0 -0
  4. data/{ext → examples/enc}/regexp_nodes/classes/webservers +0 -0
  5. data/{ext → examples/enc}/regexp_nodes/environment/development +0 -0
  6. data/{ext → examples/enc}/regexp_nodes/parameters/service/prod +0 -0
  7. data/{ext → examples/enc}/regexp_nodes/parameters/service/qa +0 -0
  8. data/{ext → examples/enc}/regexp_nodes/parameters/service/sandbox +0 -0
  9. data/{ext → examples/enc}/regexp_nodes/regexp_nodes.rb +0 -0
  10. data/{ext → examples}/nagios/check_puppet.rb +2 -2
  11. data/ext/README.md +13 -0
  12. data/lib/puppet/configurer.rb +155 -46
  13. data/lib/puppet/defaults.rb +51 -26
  14. data/lib/puppet/environments.rb +66 -26
  15. data/lib/puppet/file_serving/configuration.rb +2 -0
  16. data/lib/puppet/file_serving/configuration/parser.rb +2 -0
  17. data/lib/puppet/file_serving/mount/scripts.rb +24 -0
  18. data/lib/puppet/functions/find_template.rb +2 -2
  19. data/lib/puppet/http/service/compiler.rb +6 -1
  20. data/lib/puppet/indirector/catalog/compiler.rb +21 -3
  21. data/lib/puppet/indirector/catalog/rest.rb +1 -0
  22. data/lib/puppet/indirector/terminus.rb +4 -0
  23. data/lib/puppet/module/plan.rb +0 -1
  24. data/lib/puppet/module/task.rb +1 -1
  25. data/lib/puppet/module_tool/applications/installer.rb +8 -4
  26. data/lib/puppet/network/http/api/indirected_routes.rb +1 -1
  27. data/lib/puppet/node/environment.rb +10 -11
  28. data/lib/puppet/pops/serialization/to_data_converter.rb +18 -6
  29. data/lib/puppet/provider/package/pkg.rb +8 -1
  30. data/lib/puppet/provider/service/launchd.rb +1 -1
  31. data/lib/puppet/provider/service/systemd.rb +1 -1
  32. data/lib/puppet/provider/user/useradd.rb +42 -9
  33. data/lib/puppet/transaction/persistence.rb +11 -1
  34. data/lib/puppet/transaction/report.rb +15 -1
  35. data/lib/puppet/type.rb +1 -1
  36. data/lib/puppet/type/exec.rb +10 -1
  37. data/lib/puppet/type/file.rb +6 -6
  38. data/lib/puppet/type/filebucket.rb +2 -2
  39. data/lib/puppet/version.rb +1 -1
  40. data/locales/puppet.pot +134 -94
  41. data/man/man5/puppet.conf.5 +65 -25
  42. data/man/man8/puppet-agent.8 +1 -1
  43. data/man/man8/puppet-apply.8 +1 -1
  44. data/man/man8/puppet-catalog.8 +1 -1
  45. data/man/man8/puppet-config.8 +1 -1
  46. data/man/man8/puppet-describe.8 +1 -1
  47. data/man/man8/puppet-device.8 +1 -1
  48. data/man/man8/puppet-doc.8 +1 -1
  49. data/man/man8/puppet-epp.8 +1 -1
  50. data/man/man8/puppet-facts.8 +1 -1
  51. data/man/man8/puppet-filebucket.8 +1 -1
  52. data/man/man8/puppet-generate.8 +1 -1
  53. data/man/man8/puppet-help.8 +1 -1
  54. data/man/man8/puppet-lookup.8 +1 -1
  55. data/man/man8/puppet-module.8 +3 -3
  56. data/man/man8/puppet-node.8 +1 -1
  57. data/man/man8/puppet-parser.8 +1 -1
  58. data/man/man8/puppet-plugin.8 +1 -1
  59. data/man/man8/puppet-report.8 +1 -1
  60. data/man/man8/puppet-resource.8 +1 -1
  61. data/man/man8/puppet-script.8 +1 -1
  62. data/man/man8/puppet-ssl.8 +1 -1
  63. data/man/man8/puppet.8 +2 -2
  64. data/spec/fixtures/integration/application/agent/lib/facter/agent_spec_role.rb +3 -0
  65. data/spec/fixtures/integration/l10n/envs/prod/modules/demo/Gemfile +4 -0
  66. data/spec/fixtures/integration/l10n/envs/prod/modules/demo/Rakefile +3 -0
  67. data/spec/fixtures/integration/l10n/envs/prod/modules/demo/lib/puppet/functions/l10n.rb +8 -0
  68. data/spec/fixtures/integration/l10n/envs/prod/modules/demo/locales/config.yaml +25 -0
  69. data/spec/fixtures/integration/l10n/envs/prod/modules/demo/locales/ja/puppet-l10n.po +19 -0
  70. data/spec/fixtures/integration/l10n/envs/prod/modules/demo/locales/puppet-l10n.pot +20 -0
  71. data/spec/fixtures/integration/l10n/envs/prod/modules/demo/metadata.json +8 -0
  72. data/spec/integration/application/agent_spec.rb +102 -52
  73. data/spec/integration/application/filebucket_spec.rb +5 -0
  74. data/spec/integration/configurer_spec.rb +17 -1
  75. data/spec/integration/l10n/compiler_spec.rb +37 -0
  76. data/spec/lib/puppet_spec/modules.rb +13 -2
  77. data/spec/lib/puppet_spec/puppetserver.rb +15 -0
  78. data/spec/shared_behaviours/documentation_on_faces.rb +0 -2
  79. data/spec/shared_contexts/l10n.rb +27 -0
  80. data/spec/spec_helper.rb +1 -10
  81. data/spec/unit/configurer_spec.rb +265 -54
  82. data/spec/unit/environments_spec.rb +150 -1
  83. data/spec/unit/file_serving/configuration/parser_spec.rb +23 -0
  84. data/spec/unit/file_serving/configuration_spec.rb +12 -4
  85. data/spec/unit/file_serving/mount/scripts_spec.rb +69 -0
  86. data/spec/unit/functions/logging_spec.rb +1 -0
  87. data/spec/unit/http/service/compiler_spec.rb +8 -0
  88. data/spec/unit/indirector/catalog/compiler_spec.rb +87 -0
  89. data/spec/unit/indirector/catalog/rest_spec.rb +8 -0
  90. data/spec/unit/interface/action_spec.rb +0 -9
  91. data/spec/unit/module_spec.rb +14 -0
  92. data/spec/unit/module_tool/applications/installer_spec.rb +39 -12
  93. data/spec/unit/pops/parser/parse_containers_spec.rb +0 -11
  94. data/spec/unit/pops/serialization/to_from_hr_spec.rb +58 -0
  95. data/spec/unit/provider/package/pkg_spec.rb +19 -5
  96. data/spec/unit/provider/service/launchd_spec.rb +11 -0
  97. data/spec/unit/provider/service/systemd_spec.rb +1 -1
  98. data/spec/unit/provider/user/useradd_spec.rb +3 -2
  99. metadata +34 -94
  100. data/ext/README.environment +0 -8
  101. data/ext/dbfix.sql +0 -132
  102. data/ext/debian/README.Debian +0 -8
  103. data/ext/debian/README.source +0 -2
  104. data/ext/debian/TODO.Debian +0 -1
  105. data/ext/debian/changelog.erb +0 -1122
  106. data/ext/debian/compat +0 -1
  107. data/ext/debian/control +0 -144
  108. data/ext/debian/copyright +0 -339
  109. data/ext/debian/docs +0 -1
  110. data/ext/debian/fileserver.conf +0 -41
  111. data/ext/debian/puppet-common.dirs +0 -13
  112. data/ext/debian/puppet-common.install +0 -3
  113. data/ext/debian/puppet-common.lintian-overrides +0 -5
  114. data/ext/debian/puppet-common.manpages +0 -28
  115. data/ext/debian/puppet-common.postinst +0 -35
  116. data/ext/debian/puppet-common.postrm +0 -33
  117. data/ext/debian/puppet-el.dirs +0 -1
  118. data/ext/debian/puppet-el.emacsen-install +0 -25
  119. data/ext/debian/puppet-el.emacsen-remove +0 -11
  120. data/ext/debian/puppet-el.emacsen-startup +0 -9
  121. data/ext/debian/puppet-el.install +0 -1
  122. data/ext/debian/puppet-testsuite.install +0 -2
  123. data/ext/debian/puppet-testsuite.lintian-overrides +0 -4
  124. data/ext/debian/puppet.lintian-overrides +0 -3
  125. data/ext/debian/puppet.logrotate +0 -20
  126. data/ext/debian/puppet.postinst +0 -20
  127. data/ext/debian/puppet.postrm +0 -20
  128. data/ext/debian/puppet.preinst +0 -20
  129. data/ext/debian/puppetmaster-common.install +0 -2
  130. data/ext/debian/puppetmaster-common.manpages +0 -2
  131. data/ext/debian/puppetmaster-common.postinst +0 -6
  132. data/ext/debian/puppetmaster-passenger.dirs +0 -4
  133. data/ext/debian/puppetmaster-passenger.postinst +0 -162
  134. data/ext/debian/puppetmaster-passenger.postrm +0 -61
  135. data/ext/debian/puppetmaster.README.debian +0 -17
  136. data/ext/debian/puppetmaster.default +0 -14
  137. data/ext/debian/puppetmaster.init +0 -137
  138. data/ext/debian/puppetmaster.lintian-overrides +0 -3
  139. data/ext/debian/puppetmaster.postinst +0 -20
  140. data/ext/debian/puppetmaster.postrm +0 -5
  141. data/ext/debian/puppetmaster.preinst +0 -22
  142. data/ext/debian/rules +0 -132
  143. data/ext/debian/source/format +0 -1
  144. data/ext/debian/source/options +0 -1
  145. data/ext/debian/vim-puppet.README.Debian +0 -13
  146. data/ext/debian/vim-puppet.dirs +0 -5
  147. data/ext/debian/vim-puppet.yaml +0 -7
  148. data/ext/debian/watch +0 -2
  149. data/ext/freebsd/puppetd +0 -26
  150. data/ext/freebsd/puppetmasterd +0 -26
  151. data/ext/gentoo/conf.d/puppet +0 -5
  152. data/ext/gentoo/conf.d/puppetmaster +0 -12
  153. data/ext/gentoo/init.d/puppet +0 -38
  154. data/ext/gentoo/init.d/puppetmaster +0 -51
  155. data/ext/gentoo/puppet/fileserver.conf +0 -41
  156. data/ext/ips/puppet-agent +0 -44
  157. data/ext/ips/puppet-master +0 -44
  158. data/ext/ips/puppet.p5m.erb +0 -12
  159. data/ext/ips/puppetagent.xml +0 -42
  160. data/ext/ips/puppetmaster.xml +0 -42
  161. data/ext/ips/rules +0 -19
  162. data/ext/ips/transforms +0 -34
  163. data/ext/ldap/puppet.schema +0 -24
  164. data/ext/logcheck/puppet +0 -23
  165. data/ext/osx/file_mapping.yaml +0 -28
  166. data/ext/osx/postflight.erb +0 -109
  167. data/ext/osx/preflight.erb +0 -52
  168. data/ext/osx/prototype.plist.erb +0 -38
  169. data/ext/redhat/fileserver.conf +0 -41
  170. data/ext/redhat/logrotate +0 -21
  171. data/ext/redhat/puppet.spec.erb +0 -841
  172. data/ext/redhat/server.init +0 -128
  173. data/ext/redhat/server.sysconfig +0 -13
  174. data/ext/solaris/pkginfo +0 -6
  175. data/ext/solaris/smf/puppetd.xml +0 -77
  176. data/ext/solaris/smf/puppetmasterd.xml +0 -77
  177. data/ext/solaris/smf/svc-puppetd +0 -71
  178. data/ext/solaris/smf/svc-puppetmasterd +0 -67
  179. data/ext/suse/puppet.spec +0 -310
  180. data/ext/suse/server.init +0 -173
  181. data/ext/yaml_nodes.rb +0 -105
  182. data/spec/unit/indirector/store_configs_spec.rb +0 -7
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "PUPPET\-REPORT" "8" "July 2021" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-REPORT" "8" "August 2021" "Puppet, Inc." "Puppet manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBpuppet\-report\fR \- Create, display, and submit reports\.
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "PUPPET\-RESOURCE" "8" "July 2021" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-RESOURCE" "8" "August 2021" "Puppet, Inc." "Puppet manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBpuppet\-resource\fR \- The resource abstraction layer shell
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "PUPPET\-SCRIPT" "8" "July 2021" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-SCRIPT" "8" "August 2021" "Puppet, Inc." "Puppet manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBpuppet\-script\fR \- Run a puppet manifests as a script without compiling a catalog
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "PUPPET\-SSL" "8" "July 2021" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-SSL" "8" "August 2021" "Puppet, Inc." "Puppet manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBpuppet\-ssl\fR \- Manage SSL keys and certificates for puppet SSL clients
data/man/man8/puppet.8 CHANGED
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "PUPPET" "8" "July 2021" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET" "8" "August 2021" "Puppet, Inc." "Puppet manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBpuppet\fR
@@ -25,4 +25,4 @@ Specialized:
25
25
  catalog Compile, save, view, and convert catalogs\. describe Display help about resource types device Manage remote network devices doc Generate Puppet references epp Interact directly with the EPP template parser/renderer\. facts Retrieve and store facts\. filebucket Store and retrieve files in a filebucket generate Generates Puppet code from Ruby definitions\. node View and manage node definitions\. parser Interact directly with the parser\. plugin Interact with the Puppet plugin system\. script Run a puppet manifests as a script without compiling a catalog ssl Manage SSL keys and certificates for puppet SSL clients
26
26
  .
27
27
  .P
28
- See \'puppet help \fIsubcommand\fR \fIaction\fR\' for help on a specific subcommand action\. See \'puppet help \fIsubcommand\fR\' for help on a specific subcommand\. Puppet v7\.9\.0
28
+ See \'puppet help \fIsubcommand\fR \fIaction\fR\' for help on a specific subcommand action\. See \'puppet help \fIsubcommand\fR\' for help on a specific subcommand\. Puppet v7\.10\.0
@@ -0,0 +1,3 @@
1
+ Facter.add(:agent_spec_role) do
2
+ setcode { 'web' }
3
+ end
@@ -0,0 +1,4 @@
1
+ source ENV['GEM_SOURCE'] || "https://rubygems.org"
2
+
3
+ gem 'gettext-setup', '~> 0.28', require: false, platforms: [:ruby]
4
+ gem "rake"
@@ -0,0 +1,3 @@
1
+ spec = Gem::Specification.find_by_name 'gettext-setup'
2
+ load "#{spec.gem_dir}/lib/tasks/gettext.rake"
3
+ GettextSetup.initialize(File.absolute_path('locales', File.dirname(__FILE__)))
@@ -0,0 +1,8 @@
1
+ Puppet::Functions.create_function(:l10n) do
2
+ dispatch :l10n_impl do
3
+ end
4
+
5
+ def l10n_impl
6
+ _("IT'S HAPPY FUN TIME")
7
+ end
8
+ end
@@ -0,0 +1,25 @@
1
+ ---
2
+ # This is the project-specific configuration file for setting up
3
+ # fast_gettext for your project.
4
+ gettext:
5
+ # This is used for the name of the .pot and .po files; they will be
6
+ # called <project_name>.pot?
7
+ project_name: 'puppet-l10n'
8
+ # This is used in comments in the .pot and .po files to indicate what
9
+ # project the files belong to and should bea little more descriptive than
10
+ # <project_name>
11
+ package_name: puppet l10n demo
12
+ # The locale that the default messages in the .pot file are in
13
+ default_locale: en
14
+ # The email used for sending bug reports.
15
+ bugs_address: docs@puppetlabs.com
16
+ # The holder of the copyright.
17
+ copyright_holder: Puppet Labs, LLC.
18
+ # This determines which comments in code should be eligible for translation.
19
+ # Any comments that start with this string will be externalized. (Leave
20
+ # empty to include all.)
21
+ comments_tag: TRANSLATORS
22
+ # Patterns for +Dir.glob+ used to find all files that might contain
23
+ # translatable content, relative to the project root directory
24
+ source_files:
25
+ - 'lib/**/*.rb'
@@ -0,0 +1,19 @@
1
+ # Puppet, 2021
2
+ #
3
+ msgid ""
4
+ msgstr ""
5
+ "Project-Id-Version: 1.0\n"
6
+ "Report-Msgid-Bugs-To: \n"
7
+ "POT-Creation-Date: 2018-03-29 12:41+0000\n"
8
+ "PO-Revision-Date: 2018-03-29 12:43+0000\n"
9
+ "Last-Translator: Puppet\n"
10
+ "Language-Team: English\n"
11
+ "MIME-Version: 1.0\n"
12
+ "Content-Type: text/plain; charset=UTF-8\n"
13
+ "Content-Transfer-Encoding: 8bit\n"
14
+ "Language: en\n"
15
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
16
+
17
+ #: ../lib/puppet/functions/l10n.rb:5
18
+ msgid "IT'S HAPPY FUN TIME"
19
+ msgstr "それは楽しい時間です"
@@ -0,0 +1,20 @@
1
+ # SOME DESCRIPTIVE TITLE.
2
+ # Copyright (C) 2021 Puppet Labs, LLC.
3
+ # This file is distributed under the same license as the puppet l10n demo package.
4
+ # FIRST AUTHOR <EMAIL@ADDRESS>, 2021.
5
+ #
6
+ #, fuzzy
7
+ msgid ""
8
+ msgstr ""
9
+ "Project-Id-Version: puppet l10n demo 6.23.0-100-gdc4e95bd86\n"
10
+ "\n"
11
+ "Report-Msgid-Bugs-To: docs@puppetlabs.com\n"
12
+ "POT-Creation-Date: 2021-07-16 16:48-0700\n"
13
+ "PO-Revision-Date: 2021-07-16 16:48-0700\n"
14
+ "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
15
+ "Language-Team: LANGUAGE <LL@li.org>\n"
16
+ "Language: \n"
17
+ "MIME-Version: 1.0\n"
18
+ "Content-Type: text/plain; charset=UTF-8\n"
19
+ "Content-Transfer-Encoding: 8bit\n"
20
+ "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
@@ -0,0 +1,8 @@
1
+ {
2
+ "name": "puppet-l10n",
3
+ "version": "0.0.1",
4
+ "author": "puppet",
5
+ "source": "",
6
+ "license": "Apache-2.0",
7
+ "dependencies": []
8
+ }
@@ -469,83 +469,64 @@ describe "puppet agent", unless: Puppet::Util::Platform.jruby? do
469
469
  end
470
470
 
471
471
  context 'multiple agents running' do
472
- it "exits if an agent is already running" do
472
+ def with_another_agent_running(&block)
473
473
  path = Puppet[:agent_catalog_run_lockfile]
474
474
 
475
475
  th = Thread.new {
476
- %x{ruby -e "$0 = 'puppet'; File.write('#{path}', Process.pid); sleep(20)"}
476
+ %x{ruby -e "$0 = 'puppet'; File.write('#{path}', Process.pid); sleep(5)"}
477
477
  }
478
478
 
479
+ # ensure file is written before yielding
479
480
  until File.exists?(path) && File.size(path) > 0 do
480
481
  sleep 0.1
481
482
  end
482
483
 
483
- expect {
484
- agent.command_line.args << '--test'
485
- agent.run
486
- }.to exit_with(1).and output(/Run of Puppet configuration client already in progress; skipping/).to_stdout
484
+ begin
485
+ yield
486
+ ensure
487
+ th.kill # kill thread so we don't wait too much
488
+ end
489
+ end
487
490
 
488
- th.kill # kill thread so we don't wait too much
491
+ it "exits if an agent is already running" do
492
+ with_another_agent_running do
493
+ expect {
494
+ agent.command_line.args << '--test'
495
+ agent.run
496
+ }.to exit_with(1).and output(/Run of Puppet configuration client already in progress; skipping/).to_stdout
497
+ end
489
498
  end
490
499
 
491
500
  it "waits for other agent run to finish before starting" do
492
501
  server.start_server do |port|
493
- script = tmpfile('wait_for_log_entry')
494
- logdest = tmpfile('agent_log')
495
- path = Puppet[:agent_catalog_run_lockfile]
496
502
  Puppet[:serverport] = port
497
503
  Puppet[:waitforlock] = 1
498
504
 
499
- th = Thread.new {
500
- File.write(script, <<~SCRIPT)
501
- $0 = 'puppet'
502
- # lock pidfile
503
- File.write('#{path}', Process.pid)
504
- # wait for foreground agent to fail once
505
- until File.exists?("#{logdest}") && File.readlines("#{logdest}").grep(/Will try again/).any? do
506
- sleep 0.1
507
- end
508
- SCRIPT
509
- %x{ruby '#{script}'}
510
- }
505
+ with_another_agent_running do
506
+ expect {
507
+ agent.command_line.args << '--test'
508
+ agent.run
509
+ }.to exit_with(0)
510
+ .and output(a_string_matching(
511
+ /Info: Will try again in #{Puppet[:waitforlock]} seconds/
512
+ ).and matching(
513
+ /Applied catalog/
514
+ )).to_stdout
511
515
 
512
- until File.exists?(path) && File.size(path) > 0 do
513
- sleep 0.1
514
516
  end
515
-
516
- expect {
517
- agent.command_line.args << '--test' << '--logdest' << logdest << '--logdest' << 'console'
518
- agent.run
519
- }.to exit_with(0)
520
- .and output(a_string_matching(
521
- /Info: Will try again in #{Puppet[:waitforlock]} seconds/
522
- ).and matching(
523
- /Applied catalog/
524
- )).to_stdout
525
-
526
- th.kill # kill thread so we don't wait too much
527
517
  end
528
518
  end
529
519
 
530
520
  it "exits if maxwaitforlock is exceeded" do
531
- path = Puppet[:agent_catalog_run_lockfile]
532
521
  Puppet[:waitforlock] = 1
533
522
  Puppet[:maxwaitforlock] = 0
534
523
 
535
- th = Thread.new {
536
- %x{ruby -e "$0 = 'puppet'; File.write('#{path}', Process.pid); sleep(20)"}
537
- }
538
-
539
- until File.exists?(path) && File.size(path) > 0 do
540
- sleep 0.1
524
+ with_another_agent_running do
525
+ expect {
526
+ agent.command_line.args << '--test'
527
+ agent.run
528
+ }.to exit_with(1).and output(/Exiting now because the maxwaitforlock timeout has been exceeded./).to_stdout
541
529
  end
542
-
543
- expect {
544
- agent.command_line.args << '--test'
545
- agent.run
546
- }.to exit_with(1).and output(/Exiting now because the maxwaitforlock timeout has been exceeded./).to_stdout
547
-
548
- th.kill # kill thread so we don't wait too much
549
530
  end
550
531
  end
551
532
 
@@ -585,7 +566,7 @@ describe "puppet agent", unless: Puppet::Util::Platform.jruby? do
585
566
  ).and matching(
586
567
  /Notify\[a message\]\/message:/
587
568
  )).to_stdout
588
- .and output(/the agent run will continue/).to_stderr
569
+ .and output(/No more routes to fileserver/).to_stderr
589
570
  end
590
571
 
591
572
  it 'preserves the old cached catalog if validation fails with the old one' do
@@ -604,7 +585,7 @@ describe "puppet agent", unless: Puppet::Util::Platform.jruby? do
604
585
  agent.command_line.args << '--test'
605
586
  agent.run
606
587
  }.to exit_with(1)
607
- .and output(/Using configured environment/).to_stdout
588
+ .and output(%r{Retrieving plugin}).to_stdout
608
589
  .and output(%r{Validation of Exec\[unqualified_command\] failed: 'unqualified_command' is not qualified and no path was specified}).to_stderr
609
590
  end
610
591
 
@@ -646,4 +627,73 @@ describe "puppet agent", unless: Puppet::Util::Platform.jruby? do
646
627
  end
647
628
  end
648
629
  end
630
+
631
+ context "environment convergence" do
632
+ it "switches to 'newenv' environment and retries the run" do
633
+ first_run = true
634
+ libdir = File.join(my_fixture_dir, 'lib')
635
+
636
+ # we have to use the :facter terminus to reliably test that pluginsynced
637
+ # facts are included in the catalog request
638
+ Puppet::Node::Facts.indirection.terminus_class = :facter
639
+
640
+ mounts = {}
641
+
642
+ # During the first run, only return metadata for the top-level directory.
643
+ # During the second run, include metadata for all of the 'lib' fixtures
644
+ # due to the `recurse` option.
645
+ mounts[:file_metadatas] = -> (req, res) {
646
+ request = Puppet::FileServing::Metadata.indirection.request(
647
+ :search, libdir, nil, recurse: !first_run
648
+ )
649
+ data = Puppet::FileServing::Metadata.indirection.terminus(:file).search(request)
650
+ res.body = formatter.render(data)
651
+ res['Content-Type'] = formatter.mime
652
+ }
653
+
654
+ mounts[:file_content] = -> (req, res) {
655
+ request = Puppet::FileServing::Content.indirection.request(
656
+ :find, File.join(libdir, 'facter', 'agent_spec_role.rb'), nil
657
+ )
658
+ content = Puppet::FileServing::Content.indirection.terminus(:file).find(request)
659
+ res.body = content.content
660
+ res['Content-Length'] = content.content.length
661
+ res['Content-Type'] = 'application/octet-stream'
662
+ }
663
+
664
+ # During the first run, return an empty catalog referring to the newenv.
665
+ # During the second run, compile a catalog that depends on a fact that
666
+ # only exists in the second environment. If the fact is missing/empty,
667
+ # then compilation will fail since resources can't have an empty title.
668
+ mounts[:catalog] = -> (req, res) {
669
+ node = Puppet::Node.new('test')
670
+
671
+ code = if first_run
672
+ first_run = false
673
+ ''
674
+ else
675
+ data = CGI.unescape(req.query['facts'])
676
+ facts = Puppet::Node::Facts.convert_from('json', data)
677
+ node.fact_merge(facts)
678
+ 'notify { $facts["agent_spec_role"]: }'
679
+ end
680
+
681
+ catalog = compile_to_catalog(code, node)
682
+ catalog.environment = 'newenv'
683
+
684
+ res.body = formatter.render(catalog)
685
+ res['Content-Type'] = formatter.mime
686
+ }
687
+
688
+ server.start_server(mounts: mounts) do |port|
689
+ Puppet[:serverport] = port
690
+ expect {
691
+ agent.command_line.args << '--test'
692
+ agent.run
693
+ }.to exit_with(2)
694
+ .and output(a_string_matching(%r{Notice: Local environment: 'production' doesn't match server specified environment 'newenv', restarting agent run with environment 'newenv'})
695
+ .and matching(%r{defined 'message' as 'web'})).to_stdout
696
+ end
697
+ end
698
+ end
649
699
  end
@@ -18,6 +18,11 @@ describe "puppet filebucket", unless: Puppet::Util::Platform.jruby? do
18
18
  File.binwrite(backup_file, text)
19
19
  end
20
20
 
21
+ after :each do
22
+ # mute debug messages generated during `after :each` blocks
23
+ Puppet::Util::Log.close_all
24
+ end
25
+
21
26
  it "backs up to and restores from the local filebucket" do
22
27
  filebucket.command_line.args = ['backup', backup_file, '--local']
23
28
  expect {
@@ -60,7 +60,8 @@ describe Puppet::Configurer do
60
60
  expect(summary["time"]["last_run"]).to be_between(t1, t2)
61
61
  end
62
62
 
63
- it "applies a cached catalog if pluginsync fails when usecacheonfailure is true" do
63
+ it "applies a cached catalog if pluginsync fails when usecacheonfailure is true and environment is valid" do
64
+ expect(@configurer).to receive(:valid_server_environment?).and_return(true)
64
65
  Puppet[:ignore_plugin_errors] = false
65
66
 
66
67
  Puppet[:use_cached_catalog] = false
@@ -74,6 +75,21 @@ describe Puppet::Configurer do
74
75
  expect(report.cached_catalog_status).to eq('on_failure')
75
76
  end
76
77
 
78
+ it "applies a cached catalog if pluginsync fails when usecacheonfailure is true and environment is invalid" do
79
+ expect(@configurer).to receive(:valid_server_environment?).and_return(false)
80
+ Puppet[:ignore_plugin_errors] = false
81
+
82
+ Puppet[:use_cached_catalog] = false
83
+ Puppet[:usecacheonfailure] = true
84
+
85
+ report = Puppet::Transaction::Report.new
86
+ expect(Puppet::Resource::Catalog.indirection).to receive(:find).and_raise(Puppet::Error, 'Cannot compile remote catalog')
87
+ expect(Puppet::Resource::Catalog.indirection).to receive(:find).and_return(@catalog)
88
+
89
+ @configurer.run(pluginsync: true, report: report)
90
+ expect(report.cached_catalog_status).to eq('on_failure')
91
+ end
92
+
77
93
  describe 'resubmitting facts' do
78
94
  context 'when resubmit_facts is set to false' do
79
95
  it 'should not send data' do
@@ -0,0 +1,37 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'compiler localization' do
4
+ include_context 'l10n', 'ja'
5
+
6
+ let(:envdir) { File.join(my_fixture_dir, '..', 'envs') }
7
+ let(:environments) do
8
+ Puppet::Environments::Cached.new(
9
+ Puppet::Environments::Directories.new(envdir, [])
10
+ )
11
+ end
12
+ let(:env) { Puppet::Node::Environment.create(:prod, [File.join(envdir, 'prod', 'modules')]) }
13
+ let(:node) { Puppet::Node.new('test', :environment => env) }
14
+
15
+ around(:each) do |example|
16
+ Puppet.override(current_environment: env,
17
+ loaders: Puppet::Pops::Loaders.new(env),
18
+ environments: environments) do
19
+ example.run
20
+ end
21
+ end
22
+
23
+ it 'localizes strings in functions' do
24
+ Puppet[:code] = <<~END
25
+ notify { 'demo':
26
+ message => l10n()
27
+ }
28
+ END
29
+
30
+ Puppet::Resource::Catalog.indirection.terminus_class = :compiler
31
+ catalog = Puppet::Resource::Catalog.indirection.find(node.name)
32
+ resource = catalog.resource(:notify, 'demo')
33
+
34
+ expect(resource).to be
35
+ expect(resource[:message]).to eq("それは楽しい時間です")
36
+ end
37
+ end