puppet 7.9.0-universal-darwin → 7.12.1-universal-darwin

Sign up to get free protection for your applications and to get access to all the features.
Files changed (292) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -2
  3. data/Gemfile.lock +12 -12
  4. data/{ext → examples/enc}/regexp_nodes/classes/databases +0 -0
  5. data/{ext → examples/enc}/regexp_nodes/classes/webservers +0 -0
  6. data/{ext → examples/enc}/regexp_nodes/environment/development +0 -0
  7. data/{ext → examples/enc}/regexp_nodes/parameters/service/prod +0 -0
  8. data/{ext → examples/enc}/regexp_nodes/parameters/service/qa +0 -0
  9. data/{ext → examples/enc}/regexp_nodes/parameters/service/sandbox +0 -0
  10. data/{ext → examples/enc}/regexp_nodes/regexp_nodes.rb +0 -0
  11. data/{ext → examples}/nagios/check_puppet.rb +2 -2
  12. data/ext/README.md +13 -0
  13. data/lib/puppet/application/agent.rb +4 -0
  14. data/lib/puppet/application/apply.rb +20 -2
  15. data/lib/puppet/application/resource.rb +15 -13
  16. data/lib/puppet/concurrent/thread_local_singleton.rb +1 -0
  17. data/lib/puppet/configurer.rb +236 -58
  18. data/lib/puppet/confine/variable.rb +1 -1
  19. data/lib/puppet/defaults.rb +66 -29
  20. data/lib/puppet/environments.rb +66 -26
  21. data/lib/puppet/facter_impl.rb +96 -0
  22. data/lib/puppet/file_serving/configuration/parser.rb +2 -0
  23. data/lib/puppet/file_serving/configuration.rb +2 -0
  24. data/lib/puppet/file_serving/mount/file.rb +4 -4
  25. data/lib/puppet/file_serving/mount/scripts.rb +24 -0
  26. data/lib/puppet/file_system/file_impl.rb +3 -1
  27. data/lib/puppet/file_system.rb +2 -1
  28. data/lib/puppet/forge.rb +1 -1
  29. data/lib/puppet/functions/find_template.rb +2 -2
  30. data/lib/puppet/http/client.rb +1 -1
  31. data/lib/puppet/http/redirector.rb +5 -0
  32. data/lib/puppet/http/service/compiler.rb +6 -1
  33. data/lib/puppet/indirector/catalog/compiler.rb +24 -6
  34. data/lib/puppet/indirector/catalog/rest.rb +1 -0
  35. data/lib/puppet/indirector/facts/facter.rb +6 -6
  36. data/lib/puppet/indirector/indirection.rb +1 -1
  37. data/lib/puppet/indirector/terminus.rb +4 -0
  38. data/lib/puppet/module/plan.rb +0 -1
  39. data/lib/puppet/module/task.rb +1 -1
  40. data/lib/puppet/module_tool/applications/installer.rb +8 -4
  41. data/lib/puppet/module_tool/applications/uninstaller.rb +1 -1
  42. data/lib/puppet/module_tool/applications/upgrader.rb +1 -1
  43. data/lib/puppet/network/http/api/indirected_routes.rb +1 -1
  44. data/lib/puppet/node/environment.rb +10 -11
  45. data/lib/puppet/pal/pal_impl.rb +1 -1
  46. data/lib/puppet/parser/resource.rb +1 -1
  47. data/lib/puppet/parser/scope.rb +8 -7
  48. data/lib/puppet/parser/templatewrapper.rb +1 -0
  49. data/lib/puppet/pops/evaluator/closure.rb +7 -5
  50. data/lib/puppet/pops/evaluator/runtime3_resource_support.rb +1 -0
  51. data/lib/puppet/pops/lookup/lookup_adapter.rb +3 -2
  52. data/lib/puppet/pops/model/ast.rb +1 -0
  53. data/lib/puppet/pops/model/factory.rb +14 -13
  54. data/lib/puppet/pops/parser/egrammar.ra +2 -2
  55. data/lib/puppet/pops/parser/eparser.rb +752 -753
  56. data/lib/puppet/pops/parser/lexer2.rb +69 -68
  57. data/lib/puppet/pops/parser/slurp_support.rb +1 -0
  58. data/lib/puppet/pops/serialization/to_data_converter.rb +18 -6
  59. data/lib/puppet/pops/serialization/to_stringified_converter.rb +1 -1
  60. data/lib/puppet/pops/types/type_formatter.rb +7 -6
  61. data/lib/puppet/pops/types/types.rb +1 -1
  62. data/lib/puppet/provider/aix_object.rb +1 -1
  63. data/lib/puppet/provider/group/groupadd.rb +5 -2
  64. data/lib/puppet/provider/package/pkg.rb +19 -2
  65. data/lib/puppet/provider/package/puppet_gem.rb +1 -1
  66. data/lib/puppet/provider/package/puppetserver_gem.rb +1 -1
  67. data/lib/puppet/provider/package/yum.rb +1 -1
  68. data/lib/puppet/provider/service/base.rb +1 -1
  69. data/lib/puppet/provider/service/init.rb +5 -5
  70. data/lib/puppet/provider/service/launchd.rb +2 -2
  71. data/lib/puppet/provider/service/redhat.rb +1 -1
  72. data/lib/puppet/provider/service/smf.rb +3 -3
  73. data/lib/puppet/provider/service/systemd.rb +2 -2
  74. data/lib/puppet/provider/service/upstart.rb +5 -5
  75. data/lib/puppet/provider/user/aix.rb +44 -1
  76. data/lib/puppet/provider/user/directoryservice.rb +1 -1
  77. data/lib/puppet/provider/user/useradd.rb +72 -16
  78. data/lib/puppet/provider.rb +1 -1
  79. data/lib/puppet/reference/providers.rb +2 -2
  80. data/lib/puppet/resource/catalog.rb +1 -1
  81. data/lib/puppet/resource/type_collection.rb +2 -1
  82. data/lib/puppet/resource.rb +38 -5
  83. data/lib/puppet/runtime.rb +11 -1
  84. data/lib/puppet/settings/file_setting.rb +3 -8
  85. data/lib/puppet/settings.rb +2 -2
  86. data/lib/puppet/test/test_helper.rb +4 -1
  87. data/lib/puppet/transaction/persistence.rb +11 -1
  88. data/lib/puppet/transaction/report.rb +15 -1
  89. data/lib/puppet/type/exec.rb +19 -2
  90. data/lib/puppet/type/file.rb +6 -6
  91. data/lib/puppet/type/filebucket.rb +2 -2
  92. data/lib/puppet/type/group.rb +0 -1
  93. data/lib/puppet/type/resources.rb +1 -1
  94. data/lib/puppet/type/service.rb +8 -3
  95. data/lib/puppet/type/user.rb +0 -1
  96. data/lib/puppet/type.rb +1 -1
  97. data/lib/puppet/util/autoload.rb +1 -1
  98. data/lib/puppet/util/command_line.rb +1 -1
  99. data/lib/puppet/util/filetype.rb +2 -2
  100. data/lib/puppet/util/json.rb +3 -0
  101. data/lib/puppet/util/log.rb +1 -2
  102. data/lib/puppet/util/logging.rb +1 -25
  103. data/lib/puppet/util/pidlock.rb +1 -1
  104. data/lib/puppet/util/rdoc/parser/puppet_parser_core.rb +1 -1
  105. data/lib/puppet/util/suidmanager.rb +1 -2
  106. data/lib/puppet/util/tagging.rb +1 -0
  107. data/lib/puppet/util/windows/service.rb +0 -5
  108. data/lib/puppet/util/windows/user.rb +0 -1
  109. data/lib/puppet/util/windows.rb +3 -0
  110. data/lib/puppet/util.rb +4 -3
  111. data/lib/puppet/version.rb +1 -1
  112. data/lib/puppet.rb +2 -6
  113. data/locales/puppet.pot +265 -221
  114. data/man/man5/puppet.conf.5 +73 -25
  115. data/man/man8/puppet-agent.8 +4 -1
  116. data/man/man8/puppet-apply.8 +1 -1
  117. data/man/man8/puppet-catalog.8 +1 -1
  118. data/man/man8/puppet-config.8 +1 -1
  119. data/man/man8/puppet-describe.8 +1 -1
  120. data/man/man8/puppet-device.8 +1 -1
  121. data/man/man8/puppet-doc.8 +1 -1
  122. data/man/man8/puppet-epp.8 +1 -1
  123. data/man/man8/puppet-facts.8 +1 -1
  124. data/man/man8/puppet-filebucket.8 +1 -1
  125. data/man/man8/puppet-generate.8 +1 -1
  126. data/man/man8/puppet-help.8 +1 -1
  127. data/man/man8/puppet-lookup.8 +1 -1
  128. data/man/man8/puppet-module.8 +3 -3
  129. data/man/man8/puppet-node.8 +1 -1
  130. data/man/man8/puppet-parser.8 +1 -1
  131. data/man/man8/puppet-plugin.8 +1 -1
  132. data/man/man8/puppet-report.8 +1 -1
  133. data/man/man8/puppet-resource.8 +1 -1
  134. data/man/man8/puppet-script.8 +1 -1
  135. data/man/man8/puppet-ssl.8 +1 -1
  136. data/man/man8/puppet.8 +2 -2
  137. data/spec/fixtures/integration/application/agent/cached_deferred_catalog.json +2 -1
  138. data/spec/fixtures/integration/application/agent/lib/facter/agent_spec_role.rb +3 -0
  139. data/spec/fixtures/integration/l10n/envs/prod/modules/demo/Gemfile +4 -0
  140. data/spec/fixtures/integration/l10n/envs/prod/modules/demo/Rakefile +3 -0
  141. data/spec/fixtures/integration/l10n/envs/prod/modules/demo/lib/puppet/functions/l10n.rb +8 -0
  142. data/spec/fixtures/integration/l10n/envs/prod/modules/demo/locales/config.yaml +25 -0
  143. data/spec/fixtures/integration/l10n/envs/prod/modules/demo/locales/ja/puppet-l10n.po +19 -0
  144. data/spec/fixtures/integration/l10n/envs/prod/modules/demo/locales/puppet-l10n.pot +20 -0
  145. data/spec/fixtures/integration/l10n/envs/prod/modules/demo/metadata.json +8 -0
  146. data/spec/integration/application/agent_spec.rb +146 -52
  147. data/spec/integration/application/filebucket_spec.rb +5 -0
  148. data/spec/integration/configurer_spec.rb +18 -2
  149. data/spec/integration/indirector/facts/facter_spec.rb +3 -3
  150. data/spec/integration/l10n/compiler_spec.rb +37 -0
  151. data/spec/integration/parser/pcore_resource_spec.rb +10 -0
  152. data/spec/integration/transaction/report_spec.rb +1 -1
  153. data/spec/integration/type/file_spec.rb +2 -2
  154. data/spec/integration/type/package_spec.rb +6 -6
  155. data/spec/integration/util/rdoc/parser_spec.rb +1 -1
  156. data/spec/integration/util/windows/process_spec.rb +1 -9
  157. data/spec/lib/puppet_spec/modules.rb +13 -2
  158. data/spec/lib/puppet_spec/puppetserver.rb +15 -0
  159. data/spec/shared_behaviours/documentation_on_faces.rb +0 -2
  160. data/spec/shared_contexts/l10n.rb +27 -0
  161. data/spec/spec_helper.rb +1 -10
  162. data/spec/unit/application/apply_spec.rb +76 -56
  163. data/spec/unit/application/resource_spec.rb +29 -0
  164. data/spec/unit/configurer_spec.rb +353 -57
  165. data/spec/unit/environments_spec.rb +150 -1
  166. data/spec/unit/facter_impl_spec.rb +31 -0
  167. data/spec/unit/file_bucket/dipper_spec.rb +2 -2
  168. data/spec/unit/file_serving/configuration/parser_spec.rb +23 -0
  169. data/spec/unit/file_serving/configuration_spec.rb +12 -4
  170. data/spec/unit/file_serving/mount/scripts_spec.rb +69 -0
  171. data/spec/unit/file_system_spec.rb +7 -0
  172. data/spec/unit/functions/logging_spec.rb +1 -0
  173. data/spec/unit/functions/lookup_spec.rb +64 -0
  174. data/spec/unit/http/client_spec.rb +58 -1
  175. data/spec/unit/http/service/compiler_spec.rb +8 -0
  176. data/spec/unit/indirector/catalog/compiler_spec.rb +87 -0
  177. data/spec/unit/indirector/catalog/rest_spec.rb +8 -0
  178. data/spec/unit/indirector/indirection_spec.rb +10 -3
  179. data/spec/unit/interface/action_spec.rb +0 -9
  180. data/spec/unit/module_spec.rb +14 -0
  181. data/spec/unit/module_tool/applications/installer_spec.rb +39 -12
  182. data/spec/unit/network/formats_spec.rb +6 -0
  183. data/spec/unit/pops/parser/parse_containers_spec.rb +0 -11
  184. data/spec/unit/pops/serialization/to_from_hr_spec.rb +58 -0
  185. data/spec/unit/pops/serialization/to_stringified_spec.rb +5 -0
  186. data/spec/unit/pops/types/type_calculator_spec.rb +6 -0
  187. data/spec/unit/provider/package/gem_spec.rb +1 -1
  188. data/spec/unit/provider/package/pip2_spec.rb +1 -1
  189. data/spec/unit/provider/package/pip3_spec.rb +1 -1
  190. data/spec/unit/provider/package/pip_spec.rb +1 -1
  191. data/spec/unit/provider/package/pkg_spec.rb +34 -5
  192. data/spec/unit/provider/package/puppet_gem_spec.rb +1 -1
  193. data/spec/unit/provider/package/puppetserver_gem_spec.rb +1 -1
  194. data/spec/unit/provider/service/launchd_spec.rb +11 -0
  195. data/spec/unit/provider/service/systemd_spec.rb +1 -1
  196. data/spec/unit/provider/user/aix_spec.rb +100 -0
  197. data/spec/unit/provider/user/directoryservice_spec.rb +1 -1
  198. data/spec/unit/provider/user/useradd_spec.rb +43 -2
  199. data/spec/unit/provider_spec.rb +4 -4
  200. data/spec/unit/puppet_spec.rb +12 -4
  201. data/spec/unit/resource/catalog_spec.rb +14 -1
  202. data/spec/unit/resource_spec.rb +58 -2
  203. data/spec/unit/settings/file_setting_spec.rb +10 -7
  204. data/spec/unit/type/service_spec.rb +27 -0
  205. data/spec/unit/type_spec.rb +2 -2
  206. data/spec/unit/util/autoload_spec.rb +25 -8
  207. data/spec/unit/util/logging_spec.rb +2 -0
  208. data/tasks/parallel.rake +3 -3
  209. metadata +37 -94
  210. data/ext/README.environment +0 -8
  211. data/ext/dbfix.sql +0 -132
  212. data/ext/debian/README.Debian +0 -8
  213. data/ext/debian/README.source +0 -2
  214. data/ext/debian/TODO.Debian +0 -1
  215. data/ext/debian/changelog.erb +0 -1122
  216. data/ext/debian/compat +0 -1
  217. data/ext/debian/control +0 -144
  218. data/ext/debian/copyright +0 -339
  219. data/ext/debian/docs +0 -1
  220. data/ext/debian/fileserver.conf +0 -41
  221. data/ext/debian/puppet-common.dirs +0 -13
  222. data/ext/debian/puppet-common.install +0 -3
  223. data/ext/debian/puppet-common.lintian-overrides +0 -5
  224. data/ext/debian/puppet-common.manpages +0 -28
  225. data/ext/debian/puppet-common.postinst +0 -35
  226. data/ext/debian/puppet-common.postrm +0 -33
  227. data/ext/debian/puppet-el.dirs +0 -1
  228. data/ext/debian/puppet-el.emacsen-install +0 -25
  229. data/ext/debian/puppet-el.emacsen-remove +0 -11
  230. data/ext/debian/puppet-el.emacsen-startup +0 -9
  231. data/ext/debian/puppet-el.install +0 -1
  232. data/ext/debian/puppet-testsuite.install +0 -2
  233. data/ext/debian/puppet-testsuite.lintian-overrides +0 -4
  234. data/ext/debian/puppet.lintian-overrides +0 -3
  235. data/ext/debian/puppet.logrotate +0 -20
  236. data/ext/debian/puppet.postinst +0 -20
  237. data/ext/debian/puppet.postrm +0 -20
  238. data/ext/debian/puppet.preinst +0 -20
  239. data/ext/debian/puppetmaster-common.install +0 -2
  240. data/ext/debian/puppetmaster-common.manpages +0 -2
  241. data/ext/debian/puppetmaster-common.postinst +0 -6
  242. data/ext/debian/puppetmaster-passenger.dirs +0 -4
  243. data/ext/debian/puppetmaster-passenger.postinst +0 -162
  244. data/ext/debian/puppetmaster-passenger.postrm +0 -61
  245. data/ext/debian/puppetmaster.README.debian +0 -17
  246. data/ext/debian/puppetmaster.default +0 -14
  247. data/ext/debian/puppetmaster.init +0 -137
  248. data/ext/debian/puppetmaster.lintian-overrides +0 -3
  249. data/ext/debian/puppetmaster.postinst +0 -20
  250. data/ext/debian/puppetmaster.postrm +0 -5
  251. data/ext/debian/puppetmaster.preinst +0 -22
  252. data/ext/debian/rules +0 -132
  253. data/ext/debian/source/format +0 -1
  254. data/ext/debian/source/options +0 -1
  255. data/ext/debian/vim-puppet.README.Debian +0 -13
  256. data/ext/debian/vim-puppet.dirs +0 -5
  257. data/ext/debian/vim-puppet.yaml +0 -7
  258. data/ext/debian/watch +0 -2
  259. data/ext/freebsd/puppetd +0 -26
  260. data/ext/freebsd/puppetmasterd +0 -26
  261. data/ext/gentoo/conf.d/puppet +0 -5
  262. data/ext/gentoo/conf.d/puppetmaster +0 -12
  263. data/ext/gentoo/init.d/puppet +0 -38
  264. data/ext/gentoo/init.d/puppetmaster +0 -51
  265. data/ext/gentoo/puppet/fileserver.conf +0 -41
  266. data/ext/ips/puppet-agent +0 -44
  267. data/ext/ips/puppet-master +0 -44
  268. data/ext/ips/puppet.p5m.erb +0 -12
  269. data/ext/ips/puppetagent.xml +0 -42
  270. data/ext/ips/puppetmaster.xml +0 -42
  271. data/ext/ips/rules +0 -19
  272. data/ext/ips/transforms +0 -34
  273. data/ext/ldap/puppet.schema +0 -24
  274. data/ext/logcheck/puppet +0 -23
  275. data/ext/osx/file_mapping.yaml +0 -28
  276. data/ext/osx/postflight.erb +0 -109
  277. data/ext/osx/preflight.erb +0 -52
  278. data/ext/osx/prototype.plist.erb +0 -38
  279. data/ext/redhat/fileserver.conf +0 -41
  280. data/ext/redhat/logrotate +0 -21
  281. data/ext/redhat/puppet.spec.erb +0 -841
  282. data/ext/redhat/server.init +0 -128
  283. data/ext/redhat/server.sysconfig +0 -13
  284. data/ext/solaris/pkginfo +0 -6
  285. data/ext/solaris/smf/puppetd.xml +0 -77
  286. data/ext/solaris/smf/puppetmasterd.xml +0 -77
  287. data/ext/solaris/smf/svc-puppetd +0 -71
  288. data/ext/solaris/smf/svc-puppetmasterd +0 -67
  289. data/ext/suse/puppet.spec +0 -310
  290. data/ext/suse/server.init +0 -173
  291. data/ext/yaml_nodes.rb +0 -105
  292. data/spec/unit/indirector/store_configs_spec.rb +0 -7
@@ -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
 
@@ -645,5 +626,118 @@ describe "puppet agent", unless: Puppet::Util::Platform.jruby? do
645
626
  expect(report.metrics).to_not be_empty
646
627
  end
647
628
  end
629
+
630
+ it "caches a report even if the REST request fails" do
631
+ server.start_server do |port|
632
+ Puppet[:serverport] = port
633
+ Puppet[:report_port] = "-1"
634
+ expect {
635
+ agent.command_line.args << '--test'
636
+ agent.run
637
+ }.to exit_with(0)
638
+ .and output(%r{Applied catalog}).to_stdout
639
+ .and output(%r{Could not send report}).to_stderr
640
+
641
+ report = Puppet::Transaction::Report.convert_from(:yaml, File.read(Puppet[:lastrunreport]))
642
+ expect(report).to be
643
+ end
644
+ end
645
+ end
646
+
647
+ context "environment convergence" do
648
+ it "falls back to making a node request if the last server-specified environment cannot be loaded" do
649
+ mounts = {}
650
+ mounts[:node] = -> (req, res) {
651
+ node = Puppet::Node.new('test', environment: Puppet::Node::Environment.remote('doesnotexistonagent'))
652
+ res.body = formatter.render(node)
653
+ res['Content-Type'] = formatter.mime
654
+ }
655
+
656
+ server.start_server(mounts: mounts) do |port|
657
+ Puppet[:serverport] = port
658
+ Puppet[:log_level] = 'debug'
659
+
660
+ expect {
661
+ agent.command_line.args << '--test'
662
+ agent.run
663
+ }.to exit_with(0)
664
+ .and output(a_string_matching(%r{Debug: Requesting environment from the server})).to_stdout
665
+
666
+ Puppet::Application.clear!
667
+
668
+ expect {
669
+ agent.command_line.args << '--test'
670
+ agent.run
671
+ }.to exit_with(0)
672
+ .and output(a_string_matching(%r{Debug: Successfully loaded last environment from the lastrunfile})).to_stdout
673
+ end
674
+ end
675
+
676
+ it "switches to 'newenv' environment and retries the run" do
677
+ first_run = true
678
+ libdir = File.join(my_fixture_dir, 'lib')
679
+
680
+ # we have to use the :facter terminus to reliably test that pluginsynced
681
+ # facts are included in the catalog request
682
+ Puppet::Node::Facts.indirection.terminus_class = :facter
683
+
684
+ mounts = {}
685
+
686
+ # During the first run, only return metadata for the top-level directory.
687
+ # During the second run, include metadata for all of the 'lib' fixtures
688
+ # due to the `recurse` option.
689
+ mounts[:file_metadatas] = -> (req, res) {
690
+ request = Puppet::FileServing::Metadata.indirection.request(
691
+ :search, libdir, nil, recurse: !first_run
692
+ )
693
+ data = Puppet::FileServing::Metadata.indirection.terminus(:file).search(request)
694
+ res.body = formatter.render(data)
695
+ res['Content-Type'] = formatter.mime
696
+ }
697
+
698
+ mounts[:file_content] = -> (req, res) {
699
+ request = Puppet::FileServing::Content.indirection.request(
700
+ :find, File.join(libdir, 'facter', 'agent_spec_role.rb'), nil
701
+ )
702
+ content = Puppet::FileServing::Content.indirection.terminus(:file).find(request)
703
+ res.body = content.content
704
+ res['Content-Length'] = content.content.length
705
+ res['Content-Type'] = 'application/octet-stream'
706
+ }
707
+
708
+ # During the first run, return an empty catalog referring to the newenv.
709
+ # During the second run, compile a catalog that depends on a fact that
710
+ # only exists in the second environment. If the fact is missing/empty,
711
+ # then compilation will fail since resources can't have an empty title.
712
+ mounts[:catalog] = -> (req, res) {
713
+ node = Puppet::Node.new('test')
714
+
715
+ code = if first_run
716
+ first_run = false
717
+ ''
718
+ else
719
+ data = CGI.unescape(req.query['facts'])
720
+ facts = Puppet::Node::Facts.convert_from('json', data)
721
+ node.fact_merge(facts)
722
+ 'notify { $facts["agent_spec_role"]: }'
723
+ end
724
+
725
+ catalog = compile_to_catalog(code, node)
726
+ catalog.environment = 'newenv'
727
+
728
+ res.body = formatter.render(catalog)
729
+ res['Content-Type'] = formatter.mime
730
+ }
731
+
732
+ server.start_server(mounts: mounts) do |port|
733
+ Puppet[:serverport] = port
734
+ expect {
735
+ agent.command_line.args << '--test'
736
+ agent.run
737
+ }.to exit_with(2)
738
+ .and output(a_string_matching(%r{Notice: Local environment: 'production' doesn't match server specified environment 'newenv', restarting agent run with environment 'newenv'})
739
+ .and matching(%r{defined 'message' as 'web'})).to_stdout
740
+ end
741
+ end
648
742
  end
649
743
  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 {
@@ -23,7 +23,7 @@ describe Puppet::Configurer do
23
23
  expect(Puppet::Transaction::Report.indirection).to receive(:save) do |report, x|
24
24
  expect(report.time).to be_a(Time)
25
25
  expect(report.logs.length).to be > 0
26
- end
26
+ end.twice
27
27
 
28
28
  Puppet[:report] = true
29
29
 
@@ -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
@@ -13,7 +13,7 @@ describe Puppet::Node::Facts::Facter do
13
13
  end
14
14
 
15
15
  it "preserves case in fact values" do
16
- Facter.add(:downcase_test) do
16
+ Puppet.runtime[:facter].add(:downcase_test) do
17
17
  setcode do
18
18
  "AaBbCc"
19
19
  end
@@ -34,9 +34,9 @@ describe Puppet::Node::Facts::Facter do
34
34
  FileUtils.mkdir_p(test_module)
35
35
 
36
36
  File.open(File.join(test_module, 'custom.rb'), 'wb') { |file| file.write(<<-EOF)}
37
- Facter.add(:custom) do
37
+ Puppet.runtime[:facter].add(:custom) do
38
38
  setcode do
39
- Facter.value('puppetversion')
39
+ Puppet.runtime[:facter].value('puppetversion')
40
40
  end
41
41
  end
42
42
  EOF
@@ -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
@@ -122,6 +122,16 @@ describe 'when pcore described resources types are in use' do
122
122
  expect(catalog.resource(:test3, "x/y")['message']).to eq('x/y works')
123
123
  end
124
124
 
125
+ it 'considers Pcore types to be builtin ' do
126
+ genface.types
127
+ catalog = compile_to_catalog(<<-MANIFEST)
128
+ test1 { 'a':
129
+ message => 'a works'
130
+ }
131
+ MANIFEST
132
+ expect(catalog.resource(:test1, "a").kind).to eq('compilable_type')
133
+ end
134
+
125
135
  it 'the validity of attribute names are checked' do
126
136
  genface.types
127
137
  expect do
@@ -48,7 +48,7 @@ describe Puppet::Transaction::Report do
48
48
  expect(Puppet::Transaction::Report.indirection).to receive(:save) do |report, x|
49
49
  last_run_report = report
50
50
  true
51
- end.twice
51
+ end.exactly(4)
52
52
 
53
53
  Puppet[:report] = true
54
54
  Puppet[:noop] = noop1
@@ -1710,11 +1710,11 @@ describe Puppet::Type.type(:file), :uses_checksums => true do
1710
1710
 
1711
1711
  describe "when using validate_cmd" do
1712
1712
  test_cmd = '/bin/test'
1713
- if Facter.value(:osfamily) == 'Debian'
1713
+ if Puppet.runtime[:facter].value(:osfamily) == 'Debian'
1714
1714
  test_cmd = '/usr/bin/test'
1715
1715
  end
1716
1716
 
1717
- if Facter.value(:operatingsystem) == 'Darwin'
1717
+ if Puppet.runtime[:facter].value(:operatingsystem) == 'Darwin'
1718
1718
  stat_cmd = "stat -f '%Lp'"
1719
1719
  else
1720
1720
  stat_cmd = "stat --format=%a"
@@ -9,7 +9,7 @@ describe Puppet::Type.type(:package), "when choosing a default package provider"
9
9
  def provider_name(os)
10
10
  case os
11
11
  when 'Solaris'
12
- if Puppet::Util::Package.versioncmp(Facter.value(:kernelrelease), '5.11') >= 0
12
+ if Puppet::Util::Package.versioncmp(Puppet.runtime[:facter].value(:kernelrelease), '5.11') >= 0
13
13
  :pkg
14
14
  else
15
15
  :sun
@@ -21,19 +21,19 @@ describe Puppet::Type.type(:package), "when choosing a default package provider"
21
21
  when 'Darwin'
22
22
  :pkgdmg
23
23
  when 'RedHat'
24
- if ['2.1', '3', '4'].include?(Facter.value(:lsbdistrelease))
24
+ if ['2.1', '3', '4'].include?(Puppet.runtime[:facter].value(:lsbdistrelease))
25
25
  :up2date
26
26
  else
27
27
  :yum
28
28
  end
29
29
  when 'Fedora'
30
- if Puppet::Util::Package.versioncmp(Facter.value(:operatingsystemmajrelease), '22') >= 0
30
+ if Puppet::Util::Package.versioncmp(Puppet.runtime[:facter].value(:operatingsystemmajrelease), '22') >= 0
31
31
  :dnf
32
32
  else
33
33
  :yum
34
34
  end
35
35
  when 'Suse'
36
- if Puppet::Util::Package.versioncmp(Facter.value(:operatingsystemmajrelease), '10') >= 0
36
+ if Puppet::Util::Package.versioncmp(Puppet.runtime[:facter].value(:operatingsystemmajrelease), '10') >= 0
37
37
  :zypper
38
38
  else
39
39
  :rug
@@ -54,8 +54,8 @@ describe Puppet::Type.type(:package), "when choosing a default package provider"
54
54
  end
55
55
 
56
56
  it "should choose the correct provider each platform" do
57
- unless default_provider = provider_name(Facter.value(:operatingsystem))
58
- pending("No default provider specified in this test for #{Facter.value(:operatingsystem)}")
57
+ unless default_provider = provider_name(Puppet.runtime[:facter].value(:operatingsystem))
58
+ pending("No default provider specified in this test for #{Puppet.runtime[:facter].value(:operatingsystem)}")
59
59
  end
60
60
  expect(Puppet::Type.type(:package).defaultprovider.name).to eq(default_provider)
61
61
  end
@@ -91,7 +91,7 @@ end
91
91
  File.join(modules_dir, 'a_module', 'lib', 'facter', 'a_fact.rb'),
92
92
  <<-EOF
93
93
  # The a_fact fact comment
94
- Facter.add("a_fact") do
94
+ Puppet.runtime[:facter].add("a_fact") do
95
95
  end
96
96
  EOF
97
97
  ],
@@ -1,22 +1,14 @@
1
1
  require 'spec_helper'
2
- require 'facter'
3
2
 
4
3
  describe "Puppet::Util::Windows::Process", :if => Puppet::Util::Platform.windows? do
5
4
  describe "as an admin" do
6
- it "should have the SeCreateSymbolicLinkPrivilege necessary to create symlinks on Vista / 2008+",
7
- :if => Facter.value(:kernelmajversion).to_f >= 6.0 && Puppet::Util::Platform.windows? do
5
+ it "should have the SeCreateSymbolicLinkPrivilege necessary to create symlinks" do
8
6
  # this is a bit of a lame duck test since it requires running user to be admin
9
7
  # a better integration test would create a new user with the privilege and verify
10
8
  expect(Puppet::Util::Windows::User).to be_admin
11
9
  expect(Puppet::Util::Windows::Process.process_privilege_symlink?).to be_truthy
12
10
  end
13
11
 
14
- it "should not have the SeCreateSymbolicLinkPrivilege necessary to create symlinks on 2003 and earlier",
15
- :if => Facter.value(:kernelmajversion).to_f < 6.0 && Puppet::Util::Platform.windows? do
16
- expect(Puppet::Util::Windows::User).to be_admin
17
- expect(Puppet::Util::Windows::Process.process_privilege_symlink?).to be_falsey
18
- end
19
-
20
12
  it "should be able to lookup a standard Windows process privilege" do
21
13
  Puppet::Util::Windows::Process.lookup_privilege_value('SeShutdownPrivilege') do |luid|
22
14
  expect(luid).not_to be_nil
@@ -36,7 +36,7 @@ module PuppetSpec::Modules
36
36
  end
37
37
  end
38
38
 
39
- if plans = options[:plans]
39
+ if (plans = options[:plans])
40
40
  plans_dir = File.join(module_dir, 'plans')
41
41
  FileUtils.mkdir_p(plans_dir)
42
42
  plans.each do |plan_file|
@@ -48,6 +48,17 @@ module PuppetSpec::Modules
48
48
  end
49
49
  end
50
50
 
51
+ if (scripts = options[:scripts])
52
+ scripts_dir = File.join(module_dir, 'scripts')
53
+ FileUtils.mkdir_p(scripts_dir)
54
+ scripts.each do |script_file|
55
+ if script_file.is_a?(String)
56
+ script_file = { :name => script_file, :content => "" }
57
+ end
58
+ File.write(File.join(scripts_dir, script_file[:name]), script_file[:content])
59
+ end
60
+ end
61
+
51
62
  (options[:files] || {}).each do |fname, content|
52
63
  path = File.join(module_dir, fname)
53
64
  FileUtils.mkdir_p(File.dirname(path))
@@ -61,7 +72,7 @@ module PuppetSpec::Modules
61
72
  module_dir = File.join(dir, name)
62
73
  FileUtils.mkdir_p(module_dir)
63
74
 
64
- if metadata = options[:metadata]
75
+ if (metadata = options[:metadata])
65
76
  File.open(File.join(module_dir, 'metadata.json'), 'w') do |f|
66
77
  f.write(metadata.to_json)
67
78
  end
@@ -31,6 +31,19 @@ class PuppetSpec::Puppetserver
31
31
  end
32
32
  end
33
33
 
34
+ class FileMetadataServlet < WEBrick::HTTPServlet::AbstractServlet
35
+ def do_GET request, response
36
+ response['Content-Type'] = 'application/json'
37
+ response.body = "{\"path\":\"/etc/puppetlabs/code/environments/production/modules\",\"relative_path\":\".\",\"links\":\"follow\",\"owner\":0,\"group\":0,\"mode\":493,\"checksum\":{\"type\":\"ctime\",\"value\":\"{ctime}2020-03-06 20:14:25 UTC\"},\"type\":\"directory\",\"destination\":null}"
38
+ end
39
+ end
40
+
41
+ class FileContentServlet < WEBrick::HTTPServlet::AbstractServlet
42
+ def do_GET request, response
43
+ response.status = 404
44
+ end
45
+ end
46
+
34
47
  class ReportServlet < WEBrick::HTTPServlet::AbstractServlet
35
48
  def do_PUT request, response
36
49
  response['Content-Type'] = 'application/json'
@@ -106,7 +119,9 @@ class PuppetSpec::Puppetserver
106
119
  register_mount('/status/v1/simple/server', proc { |req, res| }, nil)
107
120
  register_mount('/puppet/v3/node', mounts[:node], NodeServlet)
108
121
  register_mount('/puppet/v3/catalog', mounts[:catalog], CatalogServlet)
122
+ register_mount('/puppet/v3/file_metadata', mounts[:file_metadata], FileMetadataServlet)
109
123
  register_mount('/puppet/v3/file_metadatas', mounts[:file_metadatas], FileMetadatasServlet)
124
+ register_mount('/puppet/v3/file_content', mounts[:file_content], FileContentServlet)
110
125
  register_mount('/puppet/v3/static_file_content', mounts[:static_file_content], StaticFileContentServlet)
111
126
  register_mount('/puppet/v3/report', mounts[:report], ReportServlet)
112
127
  register_mount('/puppet/v3/file_bucket_file', mounts[:filebucket], FilebucketServlet)
@@ -176,8 +176,6 @@ shared_examples_for "documentation on faces" do
176
176
  subject.license = "foo"
177
177
  expect(subject.license).to eq("foo")
178
178
  end
179
-
180
- it "should accept symbols to specify existing licenses..."
181
179
  end
182
180
 
183
181
  describe "#copyright" do
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.shared_context('l10n') do |locale|
4
+ before :all do
5
+ @old_locale = Locale.current
6
+ Locale.current = locale
7
+ Puppet::GettextConfig.setup_locale
8
+
9
+ # overwrite stubs with real implementation
10
+ ::Object.send(:remove_method, :_)
11
+ ::Object.send(:remove_method, :n_)
12
+ class ::Object
13
+ include FastGettext::Translation
14
+ end
15
+ end
16
+
17
+ after :all do
18
+ Locale.current = @old_locale
19
+
20
+ # restore stubs
21
+ load File.expand_path(File.join(__dir__, '../../lib/puppet/gettext/stubs.rb'))
22
+ end
23
+
24
+ before :each do
25
+ Puppet[:disable_i18n] = false
26
+ end
27
+ end
data/spec/spec_helper.rb CHANGED
@@ -68,16 +68,7 @@ VCR.turn_off!
68
68
  RSpec.configure do |config|
69
69
  include PuppetSpec::Fixtures
70
70
 
71
- # Examples or groups can selectively tag themselves as broken.
72
- # For example;
73
- #
74
- # rbv = "#{RUBY_VERSION}-p#{RbConfig::CONFIG['PATCHLEVEL']}"
75
- # describe "mostly working", :broken => false unless rbv == "1.9.3-p327" do
76
- # it "parses a valid IP" do
77
- # IPAddr.new("::2:3:4:5:6:7:8")
78
- # end
79
- # end
80
- exclude_filters = {:broken => true}
71
+ exclude_filters = {}
81
72
  exclude_filters[:benchmark] = true unless ENV['BENCHMARK']
82
73
  config.filter_run_excluding exclude_filters
83
74