puppet 3.5.1-x86-mingw32 → 3.6.0.rc1-x86-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.

Files changed (342) hide show
  1. data/CONTRIBUTING.md +5 -0
  2. data/Gemfile +17 -9
  3. data/README.md +1 -0
  4. data/conf/fileserver.conf +4 -3
  5. data/ext/README.environment +8 -0
  6. data/ext/build_defaults.yaml +1 -1
  7. data/ext/debian/control +2 -2
  8. data/ext/debian/puppet-common.dirs +4 -0
  9. data/ext/debian/rules +4 -0
  10. data/ext/emacs/puppet-mode-init.el +1 -1
  11. data/ext/emacs/puppet-mode.el +36 -17
  12. data/ext/redhat/client.init +3 -3
  13. data/ext/redhat/puppet.spec.erb +9 -0
  14. data/ext/systemd/puppet.service +3 -4
  15. data/ext/systemd/puppetmaster.service +1 -3
  16. data/install.rb +1 -1
  17. data/lib/puppet.rb +2 -1
  18. data/lib/puppet/agent.rb +1 -1
  19. data/lib/puppet/application.rb +17 -17
  20. data/lib/puppet/application/doc.rb +1 -1
  21. data/lib/puppet/configurer.rb +4 -1
  22. data/lib/puppet/configurer/downloader.rb +13 -12
  23. data/lib/puppet/configurer/plugin_handler.rb +3 -3
  24. data/lib/puppet/context.rb +6 -1
  25. data/lib/puppet/defaults.rb +82 -12
  26. data/lib/puppet/environments.rb +169 -13
  27. data/lib/puppet/external/nagios/grammar.ry +2 -0
  28. data/lib/puppet/external/nagios/parser.rb +28 -19
  29. data/lib/puppet/face/config.rb +19 -6
  30. data/lib/puppet/face/module/generate.rb +209 -7
  31. data/lib/puppet/face/module/install.rb +17 -16
  32. data/lib/puppet/face/module/list.rb +83 -82
  33. data/lib/puppet/face/module/search.rb +1 -1
  34. data/lib/puppet/face/module/upgrade.rb +10 -9
  35. data/lib/puppet/face/parser.rb +3 -2
  36. data/lib/puppet/face/plugin.rb +8 -4
  37. data/lib/puppet/file_bucket/dipper.rb +6 -3
  38. data/lib/puppet/file_bucket/file.rb +4 -2
  39. data/lib/puppet/file_serving/metadata.rb +1 -1
  40. data/lib/puppet/file_system/memory_file.rb +27 -1
  41. data/lib/puppet/file_system/memory_impl.rb +15 -1
  42. data/lib/puppet/forge.rb +148 -52
  43. data/lib/puppet/forge/cache.rb +5 -1
  44. data/lib/puppet/forge/errors.rb +10 -0
  45. data/lib/puppet/forge/repository.rb +61 -26
  46. data/lib/puppet/functions.rb +548 -0
  47. data/lib/puppet/functions/assert_type.rb +42 -0
  48. data/lib/puppet/functions/import.rb +7 -0
  49. data/lib/puppet/indirector/facts/facter.rb +1 -1
  50. data/lib/puppet/indirector/file_bucket_file/file.rb +3 -2
  51. data/lib/puppet/indirector/rest.rb +18 -0
  52. data/lib/puppet/loaders.rb +20 -0
  53. data/lib/puppet/module.rb +2 -2
  54. data/lib/puppet/module_tool.rb +40 -14
  55. data/lib/puppet/module_tool/applications.rb +0 -1
  56. data/lib/puppet/module_tool/applications/application.rb +35 -26
  57. data/lib/puppet/module_tool/applications/builder.rb +16 -6
  58. data/lib/puppet/module_tool/applications/checksummer.rb +25 -19
  59. data/lib/puppet/module_tool/applications/installer.rb +196 -35
  60. data/lib/puppet/module_tool/applications/searcher.rb +1 -0
  61. data/lib/puppet/module_tool/applications/uninstaller.rb +7 -1
  62. data/lib/puppet/module_tool/applications/unpacker.rb +57 -31
  63. data/lib/puppet/module_tool/applications/upgrader.rb +221 -65
  64. data/lib/puppet/module_tool/checksums.rb +5 -8
  65. data/lib/puppet/module_tool/errors/installer.rb +12 -44
  66. data/lib/puppet/module_tool/errors/shared.rb +84 -11
  67. data/lib/puppet/module_tool/errors/upgrader.rb +16 -45
  68. data/lib/puppet/module_tool/install_directory.rb +7 -6
  69. data/lib/puppet/module_tool/installed_modules.rb +92 -0
  70. data/lib/puppet/module_tool/local_tarball.rb +91 -0
  71. data/lib/puppet/module_tool/metadata.rb +119 -115
  72. data/lib/puppet/module_tool/modulefile.rb +9 -9
  73. data/lib/puppet/module_tool/shared_behaviors.rb +19 -7
  74. data/lib/puppet/module_tool/skeleton/templates/generator/README.md.erb +79 -0
  75. data/lib/puppet/module_tool/skeleton/templates/generator/Rakefile +18 -0
  76. data/lib/puppet/module_tool/skeleton/templates/generator/metadata.json.erb +1 -0
  77. data/lib/puppet/module_tool/skeleton/templates/generator/spec/classes/init_spec.rb.erb +7 -0
  78. data/lib/puppet/module_tool/tar.rb +3 -7
  79. data/lib/puppet/module_tool/tar/gnu.rb +21 -9
  80. data/lib/puppet/module_tool/tar/mini.rb +2 -8
  81. data/lib/puppet/network/http/api/v1.rb +1 -1
  82. data/lib/puppet/network/http/api/v2/authorization.rb +4 -2
  83. data/lib/puppet/network/http/issues.rb +1 -0
  84. data/lib/puppet/network/http_pool.rb +15 -6
  85. data/lib/puppet/node/environment.rb +91 -20
  86. data/lib/puppet/parser/ast/pops_bridge.rb +44 -3
  87. data/lib/puppet/parser/collector.rb +1 -1
  88. data/lib/puppet/parser/compiler.rb +50 -7
  89. data/lib/puppet/parser/functions.rb +6 -0
  90. data/lib/puppet/parser/functions/generate.rb +1 -1
  91. data/lib/puppet/parser/resource.rb +1 -1
  92. data/lib/puppet/pops.rb +22 -1
  93. data/lib/puppet/pops/adapters.rb +8 -1
  94. data/lib/puppet/pops/binder/bindings_composer.rb +1 -1
  95. data/lib/puppet/pops/binder/bindings_factory.rb +1 -1
  96. data/lib/puppet/pops/binder/config/binder_config_checker.rb +1 -1
  97. data/lib/puppet/pops/binder/producers.rb +2 -2
  98. data/lib/puppet/pops/evaluator/access_operator.rb +65 -25
  99. data/lib/puppet/pops/evaluator/callable_signature.rb +101 -0
  100. data/lib/puppet/pops/evaluator/closure.rb +57 -2
  101. data/lib/puppet/pops/evaluator/compare_operator.rb +1 -1
  102. data/lib/puppet/pops/evaluator/evaluator_impl.rb +9 -11
  103. data/lib/puppet/pops/evaluator/runtime3_support.rb +72 -21
  104. data/lib/puppet/pops/functions/dispatch.rb +71 -0
  105. data/lib/puppet/pops/functions/dispatcher.rb +237 -0
  106. data/lib/puppet/pops/functions/function.rb +77 -0
  107. data/lib/puppet/pops/issues.rb +12 -0
  108. data/lib/puppet/pops/loader/base_loader.rb +102 -0
  109. data/lib/puppet/pops/loader/dependency_loader.rb +60 -0
  110. data/lib/puppet/pops/loader/gem_support.rb +49 -0
  111. data/lib/puppet/pops/loader/loader.rb +180 -0
  112. data/lib/puppet/pops/loader/loader_paths.rb +137 -0
  113. data/lib/puppet/pops/loader/module_loaders.rb +242 -0
  114. data/lib/puppet/pops/loader/null_loader.rb +44 -0
  115. data/lib/puppet/pops/loader/ruby_function_instantiator.rb +34 -0
  116. data/lib/puppet/pops/loader/ruby_legacy_function_instantiator.rb +109 -0
  117. data/lib/puppet/pops/loader/simple_environment_loader.rb +20 -0
  118. data/lib/puppet/pops/loader/static_loader.rb +69 -0
  119. data/lib/puppet/pops/loader/uri_helper.rb +22 -0
  120. data/lib/puppet/pops/loaders.rb +240 -0
  121. data/lib/puppet/pops/model/factory.rb +13 -5
  122. data/lib/puppet/pops/model/model_tree_dumper.rb +12 -4
  123. data/lib/puppet/pops/parser/egrammar.ra +31 -18
  124. data/lib/puppet/pops/parser/eparser.rb +1137 -1106
  125. data/lib/puppet/pops/parser/lexer2.rb +17 -16
  126. data/lib/puppet/pops/semantic_error.rb +17 -0
  127. data/lib/puppet/pops/types/type_calculator.rb +150 -15
  128. data/lib/puppet/pops/types/type_factory.rb +69 -0
  129. data/lib/puppet/pops/types/type_parser.rb +9 -0
  130. data/lib/puppet/pops/types/types.rb +65 -4
  131. data/lib/puppet/pops/validation/checker4_0.rb +1 -1
  132. data/lib/puppet/pops/validation/validator_factory_4_0.rb +1 -1
  133. data/lib/puppet/property/list.rb +1 -1
  134. data/lib/puppet/provider/augeas/augeas.rb +2 -2
  135. data/lib/puppet/provider/cron/crontab.rb +13 -2
  136. data/lib/puppet/provider/package.rb +24 -0
  137. data/lib/puppet/provider/package/apt.rb +6 -1
  138. data/lib/puppet/provider/package/gem.rb +8 -2
  139. data/lib/puppet/provider/package/msi.rb +0 -15
  140. data/lib/puppet/provider/package/openbsd.rb +0 -24
  141. data/lib/puppet/provider/package/rpm.rb +3 -29
  142. data/lib/puppet/provider/package/windows.rb +0 -15
  143. data/lib/puppet/provider/package/yum.rb +101 -24
  144. data/lib/puppet/provider/package/yumhelper.py +31 -1
  145. data/lib/puppet/provider/package/zypper.rb +10 -28
  146. data/lib/puppet/provider/service/debian.rb +1 -1
  147. data/lib/puppet/provider/service/init.rb +3 -0
  148. data/lib/puppet/provider/service/openbsd.rb +318 -0
  149. data/lib/puppet/provider/service/redhat.rb +6 -3
  150. data/lib/puppet/provider/service/systemd.rb +2 -2
  151. data/lib/puppet/provider/yumrepo/inifile.rb +115 -42
  152. data/lib/puppet/resource.rb +13 -9
  153. data/lib/puppet/resource/catalog.rb +12 -6
  154. data/lib/puppet/resource/type_collection.rb +3 -3
  155. data/lib/puppet/settings.rb +57 -36
  156. data/lib/puppet/settings/config_file.rb +5 -0
  157. data/lib/puppet/settings/environment_conf.rb +147 -0
  158. data/lib/puppet/settings/ttl_setting.rb +48 -0
  159. data/lib/puppet/ssl/certificate_authority.rb +2 -3
  160. data/lib/puppet/ssl/certificate_authority/autosign_command.rb +1 -1
  161. data/lib/puppet/ssl/certificate_request.rb +4 -4
  162. data/lib/puppet/ssl/validator/default_validator.rb +2 -2
  163. data/lib/puppet/status.rb +1 -1
  164. data/lib/puppet/test/test_helper.rb +1 -0
  165. data/lib/puppet/type/augeas.rb +13 -1
  166. data/lib/puppet/type/cron.rb +32 -18
  167. data/lib/puppet/type/file.rb +4 -2
  168. data/lib/puppet/type/file/checksum.rb +15 -5
  169. data/lib/puppet/type/file/content.rb +3 -1
  170. data/lib/puppet/type/file/source.rb +5 -5
  171. data/lib/puppet/type/package.rb +12 -17
  172. data/lib/puppet/type/resources.rb +3 -1
  173. data/lib/puppet/type/scheduled_task.rb +4 -5
  174. data/lib/puppet/type/service.rb +12 -2
  175. data/lib/puppet/type/user.rb +106 -0
  176. data/lib/puppet/type/yumrepo.rb +9 -1
  177. data/lib/puppet/util/checksums.rb +60 -1
  178. data/lib/puppet/util/diff.rb +3 -1
  179. data/lib/puppet/util/execution.rb +20 -16
  180. data/lib/puppet/util/feature.rb +3 -0
  181. data/lib/puppet/util/logging.rb +19 -12
  182. data/lib/puppet/util/rubygems.rb +10 -0
  183. data/lib/puppet/util/watched_file.rb +1 -1
  184. data/lib/puppet/util/windows/security.rb +5 -3
  185. data/lib/puppet/vendor/load_semantic.rb +1 -0
  186. data/lib/puppet/vendor/require_vendored.rb +2 -0
  187. data/lib/puppet/vendor/semantic/Gemfile +20 -0
  188. data/lib/puppet/vendor/semantic/Rakefile +69 -0
  189. data/lib/puppet/vendor/semantic/lib/semantic.rb +7 -0
  190. data/lib/puppet/vendor/semantic/lib/semantic/dependency.rb +181 -0
  191. data/lib/puppet/vendor/semantic/lib/semantic/dependency/graph.rb +60 -0
  192. data/lib/puppet/vendor/semantic/lib/semantic/dependency/graph_node.rb +117 -0
  193. data/lib/puppet/vendor/semantic/lib/semantic/dependency/module_release.rb +46 -0
  194. data/lib/puppet/vendor/semantic/lib/semantic/dependency/source.rb +25 -0
  195. data/lib/puppet/vendor/semantic/lib/semantic/dependency/unsatisfiable_graph.rb +31 -0
  196. data/lib/puppet/vendor/semantic/lib/semantic/version.rb +168 -0
  197. data/lib/puppet/vendor/semantic/lib/semantic/version_range.rb +424 -0
  198. data/lib/puppet/vendor/semantic/spec/spec_helper.rb +24 -0
  199. data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/graph_node_spec.rb +141 -0
  200. data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/graph_spec.rb +162 -0
  201. data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/module_release_spec.rb +143 -0
  202. data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/source_spec.rb +5 -0
  203. data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/unsatisfiable_graph_spec.rb +44 -0
  204. data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency_spec.rb +383 -0
  205. data/lib/puppet/vendor/semantic/spec/unit/semantic/version_range_spec.rb +307 -0
  206. data/lib/puppet/vendor/semantic/spec/unit/semantic/version_spec.rb +608 -0
  207. data/lib/puppet/version.rb +1 -1
  208. data/spec/fixtures/java.tgz +0 -0
  209. data/spec/fixtures/stdlib.tgz +0 -0
  210. data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/usee/lib/puppet/functions/usee/callee.rb +5 -0
  211. data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/user/lib/puppet/functions/user/caller.rb +5 -0
  212. data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/user/metadata.json +9 -0
  213. data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/lib/puppet/functions/modulea/rb_func_a.rb +5 -0
  214. data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/lib/puppet/functions/rb_func_a.rb +5 -0
  215. data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/manifests/init.pp +3 -0
  216. data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/metadata.json +19 -0
  217. data/spec/fixtures/unit/pops/loaders/loaders/wo_metadata_module/modules/moduleb/lib/puppet/functions/moduleb/rb_func_b.rb +6 -0
  218. data/spec/fixtures/unit/pops/loaders/loaders/wo_metadata_module/modules/moduleb/manifests/init.pp +3 -0
  219. data/spec/fixtures/unit/provider/naginator/define_empty_param +6 -0
  220. data/spec/fixtures/unit/provider/service/systemd/list_unit_files_services +7 -0
  221. data/spec/fixtures/unit/type/user/authorized_keys +5 -0
  222. data/spec/integration/application/apply_spec.rb +1 -2
  223. data/spec/integration/configurer_spec.rb +2 -2
  224. data/spec/integration/faces/plugin_spec.rb +62 -0
  225. data/spec/integration/indirector/catalog/compiler_spec.rb +1 -1
  226. data/spec/integration/indirector/catalog/queue_spec.rb +1 -1
  227. data/spec/integration/node/environment_spec.rb +2 -2
  228. data/spec/integration/parser/future_compiler_spec.rb +96 -142
  229. data/spec/integration/parser/ruby_manifest_spec.rb +0 -5
  230. data/spec/integration/provider/cron/crontab_spec.rb +35 -0
  231. data/spec/integration/type/file_spec.rb +74 -72
  232. data/spec/integration/util/windows/security_spec.rb +17 -0
  233. data/spec/lib/matchers/resource.rb +45 -13
  234. data/spec/lib/puppet_spec/files.rb +18 -0
  235. data/spec/lib/puppet_spec/module_tool/shared_functions.rb +56 -0
  236. data/spec/lib/puppet_spec/module_tool/stub_source.rb +133 -0
  237. data/spec/shared_contexts/checksums.rb +55 -0
  238. data/spec/unit/application/apply_spec.rb +10 -7
  239. data/spec/unit/application/doc_spec.rb +17 -10
  240. data/spec/unit/application/indirection_base_spec.rb +18 -10
  241. data/spec/unit/application/inspect_spec.rb +22 -20
  242. data/spec/unit/configurer/downloader_spec.rb +7 -6
  243. data/spec/unit/configurer/plugin_handler_spec.rb +5 -8
  244. data/spec/unit/configurer_spec.rb +1 -1
  245. data/spec/unit/context_spec.rb +23 -0
  246. data/spec/unit/environments_spec.rb +274 -16
  247. data/spec/unit/face/config_spec.rb +111 -11
  248. data/spec/unit/face/module/install_spec.rb +14 -85
  249. data/spec/unit/face/module/list_spec.rb +108 -62
  250. data/spec/unit/face/module/search_spec.rb +1 -1
  251. data/spec/unit/face/module/uninstall_spec.rb +21 -42
  252. data/spec/unit/face/parser_spec.rb +5 -2
  253. data/spec/unit/file_bucket/dipper_spec.rb +92 -86
  254. data/spec/unit/file_bucket/file_spec.rb +23 -75
  255. data/spec/unit/file_serving/metadata_spec.rb +74 -74
  256. data/spec/unit/forge/module_release_spec.rb +131 -0
  257. data/spec/unit/forge/repository_spec.rb +21 -20
  258. data/spec/unit/forge_spec.rb +99 -23
  259. data/spec/unit/functions/assert_type_spec.rb +59 -0
  260. data/spec/unit/functions4_spec.rb +671 -0
  261. data/spec/unit/indirector/catalog/static_compiler_spec.rb +2 -2
  262. data/spec/unit/indirector/facts/facter_spec.rb +9 -3
  263. data/spec/unit/indirector/file_bucket_file/file_spec.rb +156 -155
  264. data/spec/unit/indirector/rest_spec.rb +8 -0
  265. data/spec/unit/interface/face_collection_spec.rb +35 -23
  266. data/spec/unit/module_spec.rb +20 -8
  267. data/spec/unit/module_tool/applications/builder_spec.rb +40 -12
  268. data/spec/unit/module_tool/applications/checksummer_spec.rb +86 -105
  269. data/spec/unit/module_tool/applications/installer_spec.rb +293 -261
  270. data/spec/unit/module_tool/applications/searcher_spec.rb +1 -1
  271. data/spec/unit/module_tool/applications/uninstaller_spec.rb +90 -154
  272. data/spec/unit/module_tool/applications/unpacker_spec.rb +12 -12
  273. data/spec/unit/module_tool/applications/upgrader_spec.rb +286 -18
  274. data/spec/unit/module_tool/metadata_spec.rb +223 -14
  275. data/spec/unit/module_tool/tar/gnu_spec.rb +12 -9
  276. data/spec/unit/module_tool/tar/mini_spec.rb +1 -1
  277. data/spec/unit/module_tool/tar_spec.rb +4 -18
  278. data/spec/unit/module_tool_spec.rb +123 -27
  279. data/spec/unit/network/formats_spec.rb +2 -2
  280. data/spec/unit/network/http_pool_spec.rb +21 -0
  281. data/spec/unit/network/rights_spec.rb +10 -8
  282. data/spec/unit/node/environment_spec.rb +27 -2
  283. data/spec/unit/parser/collector_spec.rb +1 -1
  284. data/spec/unit/parser/compiler_spec.rb +1 -1
  285. data/spec/unit/parser/functions/generate_spec.rb +4 -0
  286. data/spec/unit/pops/evaluator/access_ops_spec.rb +50 -11
  287. data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +25 -0
  288. data/spec/unit/pops/loaders/dependency_loader_spec.rb +44 -0
  289. data/spec/unit/pops/loaders/loader_paths_spec.rb +66 -0
  290. data/spec/unit/pops/loaders/loaders_spec.rb +105 -0
  291. data/spec/unit/pops/loaders/module_loaders_spec.rb +119 -0
  292. data/spec/unit/pops/loaders/static_loader_spec.rb +46 -0
  293. data/spec/unit/pops/types/type_calculator_spec.rb +145 -10
  294. data/spec/unit/pops/types/type_factory_spec.rb +101 -0
  295. data/spec/unit/pops/types/type_parser_spec.rb +22 -0
  296. data/spec/unit/property/list_spec.rb +9 -1
  297. data/spec/unit/provider/augeas/augeas_spec.rb +58 -11
  298. data/spec/unit/provider/cron/crontab_spec.rb +1 -0
  299. data/spec/unit/provider/cron/parsed_spec.rb +15 -0
  300. data/spec/unit/provider/naginator_spec.rb +14 -0
  301. data/spec/unit/provider/package/apt_spec.rb +78 -64
  302. data/spec/unit/provider/package/gem_spec.rb +15 -0
  303. data/spec/unit/provider/package/rpm_spec.rb +6 -6
  304. data/spec/unit/provider/package/windows_spec.rb +1 -1
  305. data/spec/unit/provider/package/yum_spec.rb +199 -104
  306. data/spec/unit/provider/package/zypper_spec.rb +41 -15
  307. data/spec/unit/provider/service/openbsd_spec.rb +129 -22
  308. data/spec/unit/provider/service/redhat_spec.rb +18 -4
  309. data/spec/unit/provider/service/systemd_spec.rb +5 -9
  310. data/spec/unit/provider/service/upstart_spec.rb +1 -1
  311. data/spec/unit/provider/user/directoryservice_spec.rb +10 -0
  312. data/spec/unit/provider/yumrepo/inifile_spec.rb +171 -15
  313. data/spec/unit/resource/catalog_spec.rb +20 -104
  314. data/spec/unit/resource/type_collection_spec.rb +10 -9
  315. data/spec/unit/settings/config_file_spec.rb +29 -6
  316. data/spec/unit/settings/environment_conf_spec.rb +51 -0
  317. data/spec/unit/settings_spec.rb +97 -12
  318. data/spec/unit/ssl/certificate_authority_spec.rb +2 -0
  319. data/spec/unit/type/augeas_spec.rb +1 -1
  320. data/spec/unit/type/cron_spec.rb +6 -7
  321. data/spec/unit/type/file/checksum_spec.rb +6 -0
  322. data/spec/unit/type/file/content_spec.rb +277 -207
  323. data/spec/unit/type/file_spec.rb +9 -7
  324. data/spec/unit/type/user_spec.rb +106 -18
  325. data/spec/unit/type/yumrepo_spec.rb +8 -0
  326. data/spec/unit/util/checksums_spec.rb +12 -5
  327. data/spec/unit/util/diff_spec.rb +8 -0
  328. data/spec/unit/util/execution_spec.rb +4 -4
  329. data/spec/unit/util/feature_spec.rb +2 -0
  330. data/spec/unit/util/logging_spec.rb +14 -4
  331. data/spec/unit/util/rdoc/parser_spec.rb +5 -4
  332. data/spec/unit/util/rubygems_spec.rb +14 -0
  333. data/tasks/parallel.rake +2 -2
  334. metadata +154 -21
  335. checksums.yaml +0 -7
  336. data/lib/puppet/module_tool/applications/generator.rb +0 -142
  337. data/lib/puppet/module_tool/skeleton.rb +0 -37
  338. data/lib/puppet/module_tool/skeleton/templates/generator/Modulefile.erb +0 -11
  339. data/lib/puppet/module_tool/skeleton/templates/generator/README.erb +0 -16
  340. data/lib/puppet/module_tool/tar/solaris.rb +0 -5
  341. data/spec/fixtures/unit/provider/service/systemd/list_units_services +0 -17
  342. data/spec/unit/module_tool/tar/solaris_spec.rb +0 -22
@@ -0,0 +1,55 @@
1
+ # Shared contexts for testing against all supported digest algorithms.
2
+ #
3
+ # These helpers define nested rspec example groups to test code against all our
4
+ # supported digest algorithms. Example groups that need to be run against all
5
+ # algorithms should use the `using_checksums_describe` helper which will
6
+ # create a new example group for each algorithm and will run the given block
7
+ # in each example group.
8
+ #
9
+ # For each algorithm a shared context is defined for the given algorithm that
10
+ # has precomputed checksum values and paths. These contexts are included
11
+ # automatically based on the rspec metadata selected with
12
+ # `using_checksums_describe`.
13
+
14
+ DIGEST_ALGORITHMS_TO_TRY = ['md5', 'sha256']
15
+
16
+ shared_context('with supported digest algorithms', :uses_checksums => true) do
17
+
18
+ def self.with_digest_algorithms(&block)
19
+ DIGEST_ALGORITHMS_TO_TRY.each do |digest_algorithm|
20
+ describe("when digest_algorithm is #{digest_algorithm}", :digest_algorithm => digest_algorithm) do
21
+ instance_eval(&block)
22
+ end
23
+ end
24
+ end
25
+ end
26
+
27
+ shared_context("when digest_algorithm is set to sha256", :digest_algorithm => 'sha256') do
28
+ before { Puppet[:digest_algorithm] = 'sha256' }
29
+ after { Puppet[:digest_algorithm] = nil }
30
+
31
+ let(:digest_algorithm) { 'sha256' }
32
+
33
+ let(:plaintext) { "my\r\ncontents" }
34
+ let(:checksum) { '409a11465ed0938227128b1756c677a8480a8b84814f1963853775e15a74d4b4' }
35
+ let(:bucket_dir) { '4/0/9/a/1/1/4/6/409a11465ed0938227128b1756c677a8480a8b84814f1963853775e15a74d4b4' }
36
+
37
+ def digest(content)
38
+ Puppet::Util::Checksums.sha256(content)
39
+ end
40
+ end
41
+
42
+ shared_context("when digest_algorithm is set to md5", :digest_algorithm => 'md5') do
43
+ before { Puppet[:digest_algorithm] = 'md5' }
44
+ after { Puppet[:digest_algorithm] = nil }
45
+
46
+ let(:digest_algorithm) { 'md5' }
47
+
48
+ let(:plaintext) { "my\r\ncontents" }
49
+ let(:checksum) { 'f0d7d4e480ad698ed56aeec8b6bd6dea' }
50
+ let(:bucket_dir) { 'f/0/d/7/d/4/e/4/f0d7d4e480ad698ed56aeec8b6bd6dea' }
51
+
52
+ def digest(content)
53
+ Puppet::Util::Checksums.md5(content)
54
+ end
55
+ end
@@ -180,7 +180,7 @@ describe Puppet::Application::Apply do
180
180
  @node = Puppet::Node.new(Puppet[:node_name_value])
181
181
  Puppet::Node.indirection.save(@node)
182
182
 
183
- @catalog = Puppet::Resource::Catalog.new
183
+ @catalog = Puppet::Resource::Catalog.new("testing", Puppet.lookup(:environments).get(Puppet[:environment]))
184
184
  @catalog.stubs(:to_ral).returns(@catalog)
185
185
 
186
186
  Puppet::Resource::Catalog.indirection.stubs(:find).returns(@catalog)
@@ -397,22 +397,24 @@ describe Puppet::Application::Apply do
397
397
 
398
398
  it "should read the catalog in from disk if a file name is provided" do
399
399
  @apply.options[:catalog] = temporary_catalog
400
- Puppet::Resource::Catalog.stubs(:convert_from).
401
- with(:pson,'"something"').returns(Puppet::Resource::Catalog.new)
400
+ catalog = Puppet::Resource::Catalog.new("testing", Puppet::Node::Environment::NONE)
401
+ Puppet::Resource::Catalog.stubs(:convert_from).with(:pson,'"something"').returns(catalog)
402
402
  @apply.apply
403
403
  end
404
404
 
405
405
  it "should read the catalog in from stdin if '-' is provided" do
406
406
  @apply.options[:catalog] = "-"
407
407
  $stdin.expects(:read).returns '"something"'
408
- Puppet::Resource::Catalog.stubs(:convert_from).with(:pson,'"something"').returns Puppet::Resource::Catalog.new
408
+ catalog = Puppet::Resource::Catalog.new("testing", Puppet::Node::Environment::NONE)
409
+ Puppet::Resource::Catalog.stubs(:convert_from).with(:pson,'"something"').returns(catalog)
409
410
  @apply.apply
410
411
  end
411
412
 
412
413
  it "should deserialize the catalog from the default format" do
413
414
  @apply.options[:catalog] = temporary_catalog
414
415
  Puppet::Resource::Catalog.stubs(:default_format).returns :rot13_piglatin
415
- Puppet::Resource::Catalog.stubs(:convert_from).with(:rot13_piglatin,'"something"').returns Puppet::Resource::Catalog.new
416
+ catalog = Puppet::Resource::Catalog.new("testing", Puppet::Node::Environment::NONE)
417
+ Puppet::Resource::Catalog.stubs(:convert_from).with(:rot13_piglatin,'"something"').returns(catalog)
416
418
  @apply.apply
417
419
  end
418
420
 
@@ -424,13 +426,14 @@ describe Puppet::Application::Apply do
424
426
  it "should convert plain data structures into a catalog if deserialization does not do so" do
425
427
  @apply.options[:catalog] = temporary_catalog
426
428
  Puppet::Resource::Catalog.stubs(:convert_from).with(:pson,'"something"').returns({:foo => "bar"})
427
- Puppet::Resource::Catalog.expects(:pson_create).with({:foo => "bar"}).returns(Puppet::Resource::Catalog.new)
429
+ catalog = Puppet::Resource::Catalog.new("testing", Puppet::Node::Environment::NONE)
430
+ Puppet::Resource::Catalog.expects(:pson_create).with({:foo => "bar"}).returns(catalog)
428
431
  @apply.apply
429
432
  end
430
433
 
431
434
  it "should convert the catalog to a RAL catalog and use a Configurer instance to apply it" do
432
435
  @apply.options[:catalog] = temporary_catalog
433
- catalog = Puppet::Resource::Catalog.new
436
+ catalog = Puppet::Resource::Catalog.new("testing", Puppet::Node::Environment::NONE)
434
437
  Puppet::Resource::Catalog.stubs(:convert_from).with(:pson,'"something"').returns catalog
435
438
  catalog.expects(:to_ral).returns "mycatalog"
436
439
 
@@ -255,17 +255,16 @@ describe Puppet::Application::Doc do
255
255
 
256
256
  describe "when running" do
257
257
  describe "in rdoc mode" do
258
- let(:modules) { File.expand_path("modules") }
259
- let(:manifests) { File.expand_path("manifests") }
258
+ include PuppetSpec::Files
259
+
260
+ let(:envdir) { tmpdir('env') }
261
+ let(:modules) { File.join(envdir, "modules") }
262
+ let(:manifests) { File.join(envdir, "manifests") }
260
263
 
261
264
  before :each do
262
265
  @doc.manifest = false
263
266
  Puppet.stubs(:info)
264
267
  Puppet[:trace] = false
265
- @env = stub 'env'
266
- @env.stubs(:modulepath).returns([modules])
267
- @env.stubs(:[]).with(:manifest).returns('manifests/site.pp')
268
- Puppet::Node::Environment.stubs(:new).returns(@env)
269
268
  Puppet[:modulepath] = modules
270
269
  Puppet[:manifestdir] = manifests
271
270
  @doc.options[:all] = false
@@ -276,6 +275,14 @@ describe Puppet::Application::Doc do
276
275
  @doc.command_line.stubs(:args).returns([])
277
276
  end
278
277
 
278
+ around(:each) do |example|
279
+ FileUtils.mkdir_p(modules)
280
+ @env = Puppet::Node::Environment.create(Puppet[:environment].to_sym, [modules], "#{manifests}/site.pp")
281
+ Puppet.override(:environments => Puppet::Environments::Static.new(@env)) do
282
+ example.run
283
+ end
284
+ end
285
+
279
286
  it "should set document_all on --all" do
280
287
  @doc.options[:all] = true
281
288
  Puppet.settings.expects(:[]=).with(:document_all, true)
@@ -284,19 +291,19 @@ describe Puppet::Application::Doc do
284
291
  end
285
292
 
286
293
  it "should call Puppet::Util::RDoc.rdoc in full mode" do
287
- Puppet::Util::RDoc.expects(:rdoc).with('doc', [modules, 'manifests'], nil)
294
+ Puppet::Util::RDoc.expects(:rdoc).with('doc', [modules, manifests], nil)
288
295
  expect { @doc.rdoc }.to exit_with 0
289
296
  end
290
297
 
291
298
  it "should call Puppet::Util::RDoc.rdoc with a charset if --charset has been provided" do
292
299
  @doc.options[:charset] = 'utf-8'
293
- Puppet::Util::RDoc.expects(:rdoc).with('doc', [modules, 'manifests'], "utf-8")
300
+ Puppet::Util::RDoc.expects(:rdoc).with('doc', [modules, manifests], "utf-8")
294
301
  expect { @doc.rdoc }.to exit_with 0
295
302
  end
296
303
 
297
304
  it "should call Puppet::Util::RDoc.rdoc in full mode with outputdir set to doc if no --outputdir" do
298
305
  @doc.options[:outputdir] = false
299
- Puppet::Util::RDoc.expects(:rdoc).with('doc', [modules, 'manifests'], nil)
306
+ Puppet::Util::RDoc.expects(:rdoc).with('doc', [modules, manifests], nil)
300
307
  expect { @doc.rdoc }.to exit_with 0
301
308
  end
302
309
 
@@ -308,7 +315,7 @@ describe Puppet::Application::Doc do
308
315
 
309
316
  it "should get modulepath and manifestdir values from the environment" do
310
317
  @env.expects(:modulepath).returns(['envmodules1','envmodules2'])
311
- @env.expects(:[]).with(:manifest).returns('envmanifests/site.pp')
318
+ @env.expects(:manifest).returns('envmanifests/site.pp')
312
319
 
313
320
  Puppet::Util::RDoc.expects(:rdoc).with('doc', ['envmodules1','envmodules2','envmanifests'], nil)
314
321
 
@@ -8,19 +8,27 @@ require 'puppet/indirector/face'
8
8
  # Stub for testing; the names are critical, sadly. --daniel 2011-03-30
9
9
  class Puppet::Application::TestIndirection < Puppet::Application::IndirectionBase
10
10
  end
11
-
12
- face = Puppet::Indirector::Face.define(:test_indirection, '0.0.1') do
13
- summary "fake summary"
14
- copyright "Puppet Labs", 2011
15
- license "Apache 2 license; see COPYING"
16
- end
17
- # REVISIT: This horror is required because we don't allow anything to be
18
- # :current except for if it lives on, and is loaded from, disk. --daniel 2011-03-29
19
- face.instance_variable_set('@version', :current)
20
- Puppet::Face.register(face)
21
11
  ########################################################################
22
12
 
23
13
  describe Puppet::Application::IndirectionBase do
14
+ before :all do
15
+ @face = Puppet::Indirector::Face.define(:test_indirection, '0.0.1') do
16
+ summary "fake summary"
17
+ copyright "Puppet Labs", 2011
18
+ license "Apache 2 license; see COPYING"
19
+ end
20
+ # REVISIT: This horror is required because we don't allow anything to be
21
+ # :current except for if it lives on, and is loaded from, disk. --daniel 2011-03-29
22
+ @face.instance_variable_set('@version', :current)
23
+
24
+ Puppet::Face.register(@face)
25
+ end
26
+
27
+ after :all do
28
+ # Delete the face so that it doesn't interfere with other specs
29
+ Puppet::Interface::FaceCollection.instance_variable_get(:@faces).delete Puppet::Interface::FaceCollection.underscorize(@face.name)
30
+ end
31
+
24
32
  it "should accept a terminus command line option" do
25
33
  # It would be nice not to have to stub this, but whatever... writing an
26
34
  # entire indirection stack would cause us more grief. --daniel 2011-03-31
@@ -33,7 +33,7 @@ describe Puppet::Application::Inspect do
33
33
  end
34
34
  end
35
35
 
36
- describe "when executing" do
36
+ describe "when executing", :uses_checksums => true do
37
37
  before :each do
38
38
  Puppet[:report] = true
39
39
  @inspect.options[:setdest] = true
@@ -54,30 +54,32 @@ describe Puppet::Application::Inspect do
54
54
  @inspect.run_command
55
55
  end
56
56
 
57
- it "should audit the specified properties" do
58
- catalog = Puppet::Resource::Catalog.new
59
- file = Tempfile.new("foo")
60
- file.binmode
61
- file.puts("file contents")
62
- file.close
63
- resource = Puppet::Resource.new(:file, file.path, :parameters => {:audit => "all"})
64
- catalog.add_resource(resource)
65
- Puppet::Resource::Catalog::Yaml.any_instance.stubs(:find).returns(catalog)
57
+ with_digest_algorithms do
58
+ it "should audit the specified properties" do
59
+ catalog = Puppet::Resource::Catalog.new
60
+ file = Tempfile.new("foo")
61
+ file.binmode
62
+ file.print plaintext
63
+ file.close
64
+ resource = Puppet::Resource.new(:file, file.path, :parameters => {:audit => "all"})
65
+ catalog.add_resource(resource)
66
+ Puppet::Resource::Catalog::Yaml.any_instance.stubs(:find).returns(catalog)
66
67
 
67
- events = nil
68
+ events = nil
68
69
 
69
- Puppet::Transaction::Report::Rest.any_instance.expects(:save).with do |request|
70
- events = request.instance.resource_statuses.values.first.events
71
- end
70
+ Puppet::Transaction::Report::Rest.any_instance.expects(:save).with do |request|
71
+ events = request.instance.resource_statuses.values.first.events
72
+ end
72
73
 
73
- @inspect.run_command
74
+ @inspect.run_command
74
75
 
75
- properties = events.inject({}) do |property_values, event|
76
- property_values.merge(event.property => event.previous_value)
76
+ properties = events.inject({}) do |property_values, event|
77
+ property_values.merge(event.property => event.previous_value)
78
+ end
79
+ properties["ensure"].should == :file
80
+ properties["content"].should == "{#{digest_algorithm}}#{checksum}"
81
+ properties.has_key?("target").should == false
77
82
  end
78
- properties["ensure"].should == :file
79
- properties["content"].should == "{md5}#{Digest::MD5.hexdigest("file contents\n")}"
80
- properties.has_key?("target").should == false
81
83
  end
82
84
 
83
85
  it "should set audited to true for all events" do
@@ -51,6 +51,11 @@ describe Puppet::Configurer::Downloader do
51
51
  @dler.file
52
52
  end
53
53
 
54
+ it "should set source_permissions to ignore" do
55
+ Puppet::Type.type(:file).expects(:new).with { |opts| opts[:source_permissions] == :ignore }
56
+ @dler.file
57
+ end
58
+
54
59
  describe "on POSIX", :as_platform => :posix do
55
60
  it "should always set the owner to the current UID" do
56
61
  Process.expects(:uid).returns 51
@@ -75,11 +80,6 @@ describe Puppet::Configurer::Downloader do
75
80
  Puppet::Type.type(:file).expects(:new).with { |opts| opts[:group] == nil }
76
81
  @dler.file
77
82
  end
78
-
79
- it "should set source_permissions to ignore" do
80
- Puppet::Type.type(:file).expects(:new).with { |opts| opts[:source_permissions] == :ignore }
81
- @dler.file
82
- end
83
83
  end
84
84
 
85
85
  it "should always force the download" do
@@ -129,7 +129,8 @@ describe Puppet::Configurer::Downloader do
129
129
  @dl_name = tmpfile("downloadpath")
130
130
  source_name = tmpfile("source")
131
131
  File.open(source_name, 'w') {|f| f.write('hola mundo') }
132
- @dler = Puppet::Configurer::Downloader.new("foo", @dl_name, source_name)
132
+ env = Puppet::Node::Environment.remote('foo')
133
+ @dler = Puppet::Configurer::Downloader.new("foo", @dl_name, source_name, Puppet[:pluginsignore], env)
133
134
  end
134
135
 
135
136
  it "should not skip downloaded resources when filtering on tags" do
@@ -18,25 +18,22 @@ describe Puppet::Configurer::PluginHandler do
18
18
  end
19
19
 
20
20
  it "should use an Agent Downloader, with the name, source, destination, ignore, and environment set correctly, to download plugins when downloading is enabled" do
21
- downloader = mock 'downloader'
21
+ environment = Puppet::Node::Environment.create(:myenv, [])
22
22
  Puppet.features.stubs(:external_facts?).returns(:true)
23
- # This is needed in order to make sure we pass on windows
24
23
  plugindest = File.expand_path("/tmp/pdest")
25
-
26
24
  Puppet[:pluginsource] = "psource"
27
25
  Puppet[:plugindest] = plugindest
28
26
  Puppet[:pluginsignore] = "pignore"
29
-
30
27
  Puppet[:pluginfactsource] = "psource"
31
28
  Puppet[:pluginfactdest] = plugindest
32
29
 
33
- Puppet::Configurer::Downloader.expects(:new).with("pluginfacts", plugindest, "psource", "pignore", "myenv").returns downloader
34
- Puppet::Configurer::Downloader.expects(:new).with("plugin", plugindest, "psource", "pignore", "myenv").returns downloader
30
+ downloader = mock 'downloader'
31
+ Puppet::Configurer::Downloader.expects(:new).with("pluginfacts", plugindest, "psource", "pignore", environment).returns downloader
32
+ Puppet::Configurer::Downloader.expects(:new).with("plugin", plugindest, "psource", "pignore", environment).returns downloader
35
33
 
36
34
  downloader.stubs(:evaluate).returns([])
37
35
  downloader.expects(:evaluate).twice
38
36
 
39
- @pluginhandler.environment = "myenv"
40
- @pluginhandler.download_plugins
37
+ @pluginhandler.download_plugins(environment)
41
38
  end
42
39
  end
@@ -74,7 +74,7 @@ describe Puppet::Configurer do
74
74
  @facts = Puppet::Node::Facts.new(Puppet[:node_name_value])
75
75
  Puppet::Node::Facts.indirection.save(@facts)
76
76
 
77
- @catalog = Puppet::Resource::Catalog.new
77
+ @catalog = Puppet::Resource::Catalog.new("tester", Puppet::Node::Environment.remote(Puppet[:environment].to_sym))
78
78
  @catalog.stubs(:to_ral).returns(@catalog)
79
79
  Puppet::Resource::Catalog.indirection.terminus_class = :rest
80
80
  Puppet::Resource::Catalog.indirection.stubs(:find).returns(@catalog)
@@ -71,4 +71,27 @@ describe Puppet::Context do
71
71
  expect(context.lookup("a")).to eq(1)
72
72
  end
73
73
  end
74
+
75
+ context 'support lazy entries' do
76
+ it 'by evaluating a bound proc' do
77
+ result = nil
78
+ context.override(:a => lambda {|| 'yay'}) do
79
+ result = context.lookup(:a)
80
+ end
81
+ expect(result).to eq('yay')
82
+ end
83
+
84
+ it 'by memoizing the bound value' do
85
+ result1 = nil
86
+ result2 = nil
87
+ original = 'yay'
88
+ context.override(:a => lambda {|| tmp = original; original = 'no'; tmp}) do
89
+ result1 = context.lookup(:a)
90
+ result2 = context.lookup(:a)
91
+ end
92
+ expect(result1).to eq('yay')
93
+ expect(original).to eq('no')
94
+ expect(result2).to eq('yay')
95
+ end
96
+ end
74
97
  end
@@ -3,13 +3,17 @@ require 'puppet/environments'
3
3
  require 'puppet/file_system'
4
4
  require 'matchers/include'
5
5
 
6
+ module PuppetEnvironments
6
7
  describe Puppet::Environments do
7
8
  include Matchers::Include
8
- include PuppetSpec::Files
9
9
 
10
10
  FS = Puppet::FileSystem
11
11
 
12
12
  describe "directories loader" do
13
+ before(:each) do
14
+ Puppet.settings.initialize_global_settings
15
+ end
16
+
13
17
  it "lists environments" do
14
18
  global_path_1_location = File.expand_path("global_path_1")
15
19
  global_path_2_location = File.expand_path("global_path_2")
@@ -18,10 +22,13 @@ describe Puppet::Environments do
18
22
 
19
23
  envdir = FS::MemoryFile.a_directory(File.expand_path("envdir"), [
20
24
  FS::MemoryFile.a_directory("env1", [
25
+ FS::MemoryFile.a_missing_file("environment.conf"),
21
26
  FS::MemoryFile.a_directory("modules"),
22
27
  FS::MemoryFile.a_directory("manifests"),
23
28
  ]),
24
- FS::MemoryFile.a_directory("env2")
29
+ FS::MemoryFile.a_directory("env2", [
30
+ FS::MemoryFile.a_missing_file("environment.conf"),
31
+ ]),
25
32
  ])
26
33
 
27
34
  loader_from(:filesystem => [envdir, global_path_1, global_path_2],
@@ -38,10 +45,14 @@ describe Puppet::Environments do
38
45
  end
39
46
 
40
47
  it "does not list files" do
41
- envdir = FS::MemoryFile.a_directory("envdir", [
48
+ envdir = FS::MemoryFile.a_directory(File.expand_path("envdir"), [
42
49
  FS::MemoryFile.a_regular_file_containing("foo", ''),
43
- FS::MemoryFile.a_directory("env1"),
44
- FS::MemoryFile.a_directory("env2"),
50
+ FS::MemoryFile.a_directory("env1", [
51
+ FS::MemoryFile.a_missing_file("environment.conf"),
52
+ ]),
53
+ FS::MemoryFile.a_directory("env2", [
54
+ FS::MemoryFile.a_missing_file("environment.conf"),
55
+ ]),
45
56
  ])
46
57
 
47
58
  loader_from(:filesystem => [envdir],
@@ -50,14 +61,18 @@ describe Puppet::Environments do
50
61
  end
51
62
  end
52
63
 
53
- it "it ignores directories that are not valid env names (alphanumeric and _)" do
54
- envdir = FS::MemoryFile.a_directory("envdir", [
64
+ it "ignores directories that are not valid env names (alphanumeric and _)" do
65
+ envdir = FS::MemoryFile.a_directory(File.expand_path("envdir"), [
55
66
  FS::MemoryFile.a_directory(".foo"),
56
67
  FS::MemoryFile.a_directory("bar-thing"),
57
68
  FS::MemoryFile.a_directory("with spaces"),
58
69
  FS::MemoryFile.a_directory("some.thing"),
59
- FS::MemoryFile.a_directory("env1"),
60
- FS::MemoryFile.a_directory("env2"),
70
+ FS::MemoryFile.a_directory("env1", [
71
+ FS::MemoryFile.a_missing_file("environment.conf"),
72
+ ]),
73
+ FS::MemoryFile.a_directory("env2", [
74
+ FS::MemoryFile.a_missing_file("environment.conf"),
75
+ ]),
61
76
  ])
62
77
 
63
78
  loader_from(:filesystem => [envdir],
@@ -67,9 +82,13 @@ describe Puppet::Environments do
67
82
  end
68
83
 
69
84
  it "gets a particular environment" do
70
- directory_tree = FS::MemoryFile.a_directory("envdir", [
71
- FS::MemoryFile.a_directory("env1"),
72
- FS::MemoryFile.a_directory("env2"),
85
+ directory_tree = FS::MemoryFile.a_directory(File.expand_path("envdir"), [
86
+ FS::MemoryFile.a_directory("env1", [
87
+ FS::MemoryFile.a_missing_file("environment.conf"),
88
+ ]),
89
+ FS::MemoryFile.a_directory("env2", [
90
+ FS::MemoryFile.a_missing_file("environment.conf"),
91
+ ]),
73
92
  ])
74
93
 
75
94
  loader_from(:filesystem => [directory_tree],
@@ -86,13 +105,243 @@ describe Puppet::Environments do
86
105
  expect(loader.get("env_not_in_this_list")).to be_nil
87
106
  end
88
107
  end
108
+
109
+ context "with an environment.conf" do
110
+ let(:envdir) do
111
+ FS::MemoryFile.a_directory(File.expand_path("envdir"), [
112
+ FS::MemoryFile.a_directory("env1", [
113
+ FS::MemoryFile.a_regular_file_containing("environment.conf", content),
114
+ ]),
115
+ ])
116
+ end
117
+ let(:manifestdir) { FS::MemoryFile.a_directory(File.expand_path("/some/manifest/path")) }
118
+ let(:modulepath) do
119
+ [
120
+ FS::MemoryFile.a_directory(File.expand_path("/some/module/path")),
121
+ FS::MemoryFile.a_directory(File.expand_path("/some/other/path")),
122
+ ]
123
+ end
124
+
125
+ let(:content) do
126
+ <<-EOF
127
+ manifest=#{manifestdir}
128
+ modulepath=#{modulepath.join(File::PATH_SEPARATOR)}
129
+ config_version=/some/script
130
+ EOF
131
+ end
132
+
133
+ it "reads environment.conf settings" do
134
+ loader_from(:filesystem => [envdir, manifestdir, modulepath].flatten,
135
+ :directory => envdir) do |loader|
136
+ expect(loader.get("env1")).to environment(:env1).
137
+ with_manifest(manifestdir.path).
138
+ with_modulepath(modulepath.map(&:path))
139
+ end
140
+ end
141
+
142
+ it "does not append global_module_path to environment.conf modulepath setting" do
143
+ global_path_location = File.expand_path("global_path")
144
+ global_path = FS::MemoryFile.a_directory(global_path_location)
145
+
146
+ loader_from(:filesystem => [envdir, manifestdir, modulepath, global_path].flatten,
147
+ :directory => envdir,
148
+ :modulepath => [global_path]) do |loader|
149
+ expect(loader.get("env1")).to environment(:env1).
150
+ with_manifest(manifestdir.path).
151
+ with_modulepath(modulepath.map(&:path))
152
+ end
153
+ end
154
+
155
+ it "reads config_version setting" do
156
+ loader_from(:filesystem => [envdir, manifestdir, modulepath].flatten,
157
+ :directory => envdir) do |loader|
158
+ expect(loader.get("env1")).to environment(:env1).
159
+ with_manifest(manifestdir.path).
160
+ with_modulepath(modulepath.map(&:path)).
161
+ with_config_version(File.expand_path('/some/script'))
162
+ end
163
+ end
164
+
165
+ it "accepts an empty environment.conf without warning" do
166
+ content = nil
167
+
168
+ envdir = FS::MemoryFile.a_directory(File.expand_path("envdir"), [
169
+ FS::MemoryFile.a_directory("env1", [
170
+ FS::MemoryFile.a_regular_file_containing("environment.conf", content),
171
+ ]),
172
+ ])
173
+
174
+ manifestdir = FS::MemoryFile.a_directory(File.join(envdir, "env1", "manifests"))
175
+ modulesdir = FS::MemoryFile.a_directory(File.join(envdir, "env1", "modules"))
176
+ global_path_location = File.expand_path("global_path")
177
+ global_path = FS::MemoryFile.a_directory(global_path_location)
178
+
179
+ loader_from(:filesystem => [envdir, manifestdir, modulesdir, global_path].flatten,
180
+ :directory => envdir,
181
+ :modulepath => [global_path]) do |loader|
182
+ expect(loader.get("env1")).to environment(:env1).
183
+ with_manifest("#{FS.path_string(envdir)}/env1/manifests").
184
+ with_modulepath(["#{FS.path_string(envdir)}/env1/modules", global_path_location]).
185
+ with_config_version(nil)
186
+ end
187
+
188
+ expect(@logs).to be_empty
189
+ end
190
+
191
+ it "logs a warning, but processes the main settings if there are extraneous sections" do
192
+ content << "[foo]"
193
+ loader_from(:filesystem => [envdir, manifestdir, modulepath].flatten,
194
+ :directory => envdir) do |loader|
195
+ expect(loader.get("env1")).to environment(:env1).
196
+ with_manifest(manifestdir.path).
197
+ with_modulepath(modulepath.map(&:path)).
198
+ with_config_version(File.expand_path('/some/script'))
199
+ end
200
+
201
+ expect(@logs.map(&:to_s).join).to match(/Invalid.*at.*#{envdir}\/env1.*may not have sections.*ignored: 'foo'/)
202
+ end
203
+
204
+ it "logs a warning, but processes the main settings if there are any extraneous settings" do
205
+ content << "dog=arf\n"
206
+ content << "cat=mew\n"
207
+ content << "[ignored]\n"
208
+ content << "cow=moo\n"
209
+ loader_from(:filesystem => [envdir, manifestdir, modulepath].flatten,
210
+ :directory => envdir) do |loader|
211
+ expect(loader.get("env1")).to environment(:env1).
212
+ with_manifest(manifestdir.path).
213
+ with_modulepath(modulepath.map(&:path)).
214
+ with_config_version(File.expand_path('/some/script'))
215
+ end
216
+
217
+ expect(@logs.map(&:to_s).join).to match(/Invalid.*at.*#{envdir}\/env1.*unknown setting.*dog, cat/)
218
+ end
219
+
220
+ it "interpretes relative paths from the environment's directory" do
221
+ content = <<-EOF
222
+ manifest=relative/manifest
223
+ modulepath=relative/modules
224
+ config_version=relative/script
225
+ EOF
226
+
227
+ envdir = FS::MemoryFile.a_directory(File.expand_path("envdir"), [
228
+ FS::MemoryFile.a_directory("env1", [
229
+ FS::MemoryFile.a_regular_file_containing("environment.conf", content),
230
+ FS::MemoryFile.a_missing_file("modules"),
231
+ FS::MemoryFile.a_directory('relative', [
232
+ FS::MemoryFile.a_directory('modules'),
233
+ ]),
234
+ ]),
235
+ ])
236
+
237
+ loader_from(:filesystem => [envdir],
238
+ :directory => envdir) do |loader|
239
+ expect(loader.get("env1")).to environment(:env1).
240
+ with_manifest(File.join(envdir, 'env1', 'relative', 'manifest')).
241
+ with_modulepath([File.join(envdir, 'env1', 'relative', 'modules')]).
242
+ with_config_version(File.join(envdir, 'env1', 'relative', 'script'))
243
+ end
244
+ end
245
+
246
+ it "interpolates other setting values correctly" do
247
+ modulepath = [
248
+ File.expand_path('/some/absolute'),
249
+ '$basemodulepath',
250
+ 'modules'
251
+ ].join(File::PATH_SEPARATOR)
252
+
253
+ content = <<-EOF
254
+ manifest=$confdir/whackymanifests
255
+ modulepath=#{modulepath}
256
+ config_version=$vardir/random/scripts
257
+ EOF
258
+
259
+ some_absolute_dir = FS::MemoryFile.a_directory(File.expand_path('/some/absolute'))
260
+ base_module_dirs = Puppet[:basemodulepath].split(File::PATH_SEPARATOR).map do |path|
261
+ FS::MemoryFile.a_directory(path)
262
+ end
263
+ envdir = FS::MemoryFile.a_directory(File.expand_path("envdir"), [
264
+ FS::MemoryFile.a_directory("env1", [
265
+ FS::MemoryFile.a_regular_file_containing("environment.conf", content),
266
+ FS::MemoryFile.a_directory("modules"),
267
+ ]),
268
+ ])
269
+
270
+ loader_from(:filesystem => [envdir, some_absolute_dir, base_module_dirs].flatten,
271
+ :directory => envdir) do |loader|
272
+ expect(loader.get("env1")).to environment(:env1).
273
+ with_manifest(File.join(Puppet[:confdir], 'whackymanifests')).
274
+ with_modulepath([some_absolute_dir.path,
275
+ base_module_dirs.map { |d| d.path },
276
+ File.join(envdir, 'env1', 'modules')].flatten).
277
+ with_config_version(File.join(Puppet[:vardir], 'random', 'scripts'))
278
+ end
279
+ end
280
+
281
+ it "uses environment.conf settings regardless of existence of modules and manifests subdirectories" do
282
+ envdir = FS::MemoryFile.a_directory(File.expand_path("envdir"), [
283
+ FS::MemoryFile.a_directory("env1", [
284
+ FS::MemoryFile.a_regular_file_containing("environment.conf", content),
285
+ FS::MemoryFile.a_directory("modules"),
286
+ FS::MemoryFile.a_directory("manifests"),
287
+ ]),
288
+ ])
289
+
290
+ loader_from(:filesystem => [envdir, manifestdir, modulepath].flatten,
291
+ :directory => envdir) do |loader|
292
+ expect(loader.get("env1")).to environment(:env1).
293
+ with_manifest(manifestdir.path).
294
+ with_modulepath(modulepath.map(&:path)).
295
+ with_config_version(File.expand_path('/some/script'))
296
+ end
297
+ end
298
+ end
299
+ end
300
+
301
+ describe "static loaders" do
302
+ let(:static1) { Puppet::Node::Environment.create(:static1, []) }
303
+ let(:static2) { Puppet::Node::Environment.create(:static2, []) }
304
+ let(:loader) { Puppet::Environments::Static.new(static1, static2) }
305
+
306
+ it "lists environments" do
307
+ expect(loader.list).to eq([static1, static2])
308
+ end
309
+
310
+ it "gets an environment" do
311
+ expect(loader.get(:static2)).to eq(static2)
312
+ end
313
+
314
+ it "returns nil if env not found" do
315
+ expect(loader.get(:doesnotexist)).to be_nil
316
+ end
317
+
318
+ it "gets a basic conf" do
319
+ conf = loader.get_conf(:static1)
320
+ expect(conf.modulepath).to eq('')
321
+ expect(conf.manifest).to eq(:no_manifest)
322
+ expect(conf.config_version).to be_nil
323
+ end
324
+
325
+ it "returns nil if you request a configuration from an env that doesn't exist" do
326
+ expect(loader.get_conf(:doesnotexist)).to be_nil
327
+ end
328
+
329
+ context "that are private" do
330
+ let(:private_env) { Puppet::Node::Environment.create(:private, []) }
331
+ let(:loader) { Puppet::Environments::StaticPrivate.new(private_env) }
332
+
333
+ it "lists nothing" do
334
+ expect(loader.list).to eq([])
335
+ end
336
+ end
89
337
  end
90
338
 
91
339
  RSpec::Matchers.define :environment do |name|
92
340
  match do |env|
93
341
  env.name == name &&
94
342
  (!@manifest || @manifest == env.manifest) &&
95
- (!@modulepath || @modulepath == env.modulepath)
343
+ (!@modulepath || @modulepath == env.modulepath) &&
344
+ (!@config_version || @config_version == env.config_version)
96
345
  end
97
346
 
98
347
  chain :with_manifest do |manifest|
@@ -103,23 +352,32 @@ describe Puppet::Environments do
103
352
  @modulepath = modulepath
104
353
  end
105
354
 
355
+ chain :with_config_version do |config_version|
356
+ @config_version = config_version
357
+ end
358
+
106
359
  description do
107
360
  "environment #{expected}" +
108
361
  (@manifest ? " with manifest #{@manifest}" : "") +
109
- (@modulepath ? " with modulepath [#{@modulepath.join(', ')}]" : "")
362
+ (@modulepath ? " with modulepath [#{@modulepath.join(', ')}]" : "") +
363
+ (@config_version ? " with config_version #{@config_version}" : "")
110
364
  end
111
365
 
112
366
  failure_message_for_should do |env|
113
- "expected <#{env.name}: modulepath = [#{env.modulepath.join(', ')}], manifest = #{env.manifest}> to be #{description}"
367
+ "expected <#{env.name}: modulepath = [#{env.modulepath.join(', ')}], manifest = #{env.manifest}, config_version = #{env.config_version}> to be #{description}"
114
368
  end
115
369
  end
116
370
 
117
371
  def loader_from(options, &block)
118
372
  FS.overlay(*options[:filesystem]) do
119
- yield Puppet::Environments::Directories.new(
373
+ environments = Puppet::Environments::Directories.new(
120
374
  options[:directory],
121
375
  options[:modulepath] || []
122
376
  )
377
+ Puppet.override(:environments => environments) do
378
+ yield environments
379
+ end
123
380
  end
124
381
  end
125
382
  end
383
+ end