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
@@ -21,15 +21,18 @@ Puppet::Type.type(:service).provide :redhat, :parent => :init, :source => :init
21
21
  end
22
22
 
23
23
  def enabled?
24
- # Checkconfig always returns 0 on SuSE unless the --check flag is used.
25
- args = (Facter.value(:osfamily) == 'Suse' ? ['--check'] : [])
24
+ name = @resource[:name]
26
25
 
27
26
  begin
28
- chkconfig(@resource[:name], *args)
27
+ output = chkconfig name
29
28
  rescue Puppet::ExecutionFailure
30
29
  return :false
31
30
  end
32
31
 
32
+ # For Suse OS family, chkconfig returns 0 even if the service is disabled or non-existent
33
+ # Therefore, check the output for '<name> on' to see if it is enabled
34
+ return :false unless Facter.value(:osfamily) != 'Suse' || output =~ /^#{name}\s+on$/
35
+
33
36
  :true
34
37
  end
35
38
 
@@ -10,8 +10,8 @@ Puppet::Type.type(:service).provide :systemd, :parent => :base do
10
10
 
11
11
  def self.instances
12
12
  i = []
13
- output = systemctl('list-units', '--type', 'service', '--full', '--all', '--no-pager')
14
- output.scan(/^(\S+)\s+(loaded|error)\s+(active|inactive)\s+(active|waiting|running|plugged|mounted|dead|exited|listening|elapsed)\s*?(\S.*?)?$/i).each do |m|
13
+ output = systemctl('list-unit-files', '--type', 'service', '--full', '--all', '--no-pager')
14
+ output.scan(/^(\S+)\s+(disabled|enabled)\s*$/i).each do |m|
15
15
  i << new(:name => m[0])
16
16
  end
17
17
  return i
@@ -1,23 +1,45 @@
1
1
  require 'puppet/util/inifile'
2
2
 
3
3
  Puppet::Type.type(:yumrepo).provide(:inifile) do
4
- desc 'Manage yum repos'
4
+ desc <<-EOD
5
+ Manage yum repo configurations by parsing yum INI configuration files.
6
+
7
+ ## Fetching instances
8
+
9
+ When fetching repo instances, directory entries in '/etc/yum/repos.d',
10
+ '/etc/yum.repos.d', and the directory optionally specified by the reposdir
11
+ key in '/etc/yum.conf' will be checked. If a given directory does not exist it
12
+ will be ignored. In addition, all sections in '/etc/yum.conf' aside from
13
+ 'main' will be created as sections.
14
+
15
+ ## Storing instances
16
+
17
+ When creating a new repository, a new section will be added in the first
18
+ yum repo directory that exists. The custom directory specified by the
19
+ '/etc/yum.conf' reposdir property is checked first, followed by
20
+ '/etc/yum/repos.d', and then '/etc/yum.repos.d'. If none of these exist, the
21
+ section will be created in '/etc/yum.conf'.
22
+ EOD
5
23
 
6
24
  PROPERTIES = Puppet::Type.type(:yumrepo).validproperties
7
25
 
8
- # @return [Array<Puppet::Providers>] Return all the providers built up from
9
- # discovered content on the local node.
26
+ # Retrieve all providers based on existing yum repositories
27
+ #
28
+ # @api public
29
+ # @return [Array<Puppet::Provider>] providers generated from existing yum
30
+ # repository definitions.
10
31
  def self.instances
11
32
  instances = []
12
- # Iterate over each section of our virtual file.
33
+
13
34
  virtual_inifile.each_section do |section|
35
+ # Ignore the 'main' section in yum.conf since it's not a repository.
36
+ next if section.name == "main"
37
+
14
38
  attributes_hash = {:name => section.name, :ensure => :present, :provider => :yumrepo}
15
- # We need to build up a attributes hash
39
+
16
40
  section.entries.each do |key, value|
17
41
  key = key.to_sym
18
42
  if valid_property?(key)
19
- # We strip the values here to handle cases where distros set values
20
- # like enabled = 1 with spaces.
21
43
  attributes_hash[key] = value
22
44
  elsif key == :name
23
45
  attributes_hash[:descr] = value
@@ -25,11 +47,15 @@ Puppet::Type.type(:yumrepo).provide(:inifile) do
25
47
  end
26
48
  instances << new(attributes_hash)
27
49
  end
28
- return instances
50
+
51
+ instances
29
52
  end
30
53
 
31
- # @param resources [Array<Puppet::Resource>] Resources to prefetch.
32
- # @return [Array<Puppet::Resource>] Resources with providers set.
54
+ # Match catalog type instances to provider instances.
55
+ #
56
+ # @api public
57
+ # @param resources [Array<Puppet::Type::Yumrepo>] Resources to prefetch.
58
+ # @return [void]
33
59
  def self.prefetch(resources)
34
60
  repos = instances
35
61
  resources.keys.each do |name|
@@ -39,10 +65,12 @@ Puppet::Type.type(:yumrepo).provide(:inifile) do
39
65
  end
40
66
  end
41
67
 
42
- # Return a list of existing directories that could contain repo files. Fail if none found.
68
+ # Return a list of existing directories that could contain repo files.
69
+ #
70
+ # @api private
43
71
  # @param conf [String] Configuration file to look for directories in.
44
- # @param dirs [Array] Default locations for yum repos.
45
- # @return [Array] Directories that were found to exist on the node.
72
+ # @param dirs [Array<String>] Default locations for yum repos.
73
+ # @return [Array<String>] All present directories that may contain yum repo configs.
46
74
  def self.reposdir(conf='/etc/yum.conf', dirs=['/etc/yum.repos.d', '/etc/yum/repos.d'])
47
75
  reposdir = find_conf_value('reposdir', conf)
48
76
  dirs << reposdir if reposdir
@@ -51,70 +79,103 @@ Puppet::Type.type(:yumrepo).provide(:inifile) do
51
79
  # dirs.select! { |dir| Puppet::FileSystem.exist?(dir) }
52
80
  dirs.delete_if { |dir| ! Puppet::FileSystem.exist?(dir) }
53
81
  if dirs.empty?
54
- fail('No yum directories were found on the local filesystem')
55
- else
56
- return dirs
82
+ Puppet.debug('No yum directories were found on the local filesystem')
57
83
  end
84
+
85
+ dirs
86
+ end
87
+
88
+ # Used for testing only
89
+ # @api private
90
+ def self.clear
91
+ @virtual = nil
58
92
  end
59
93
 
60
94
  # Helper method to look up specific values in ini style files.
61
- # @todo Migrate this into Puppet::Util::IniConfig.
95
+ #
96
+ # @api private
62
97
  # @param value [String] Value to look for in the configuration file.
63
98
  # @param conf [String] Configuration file to check for value.
64
99
  # @return [String] The value of a looked up key from the configuration file.
65
100
  def self.find_conf_value(value, conf='/etc/yum.conf')
66
101
  if Puppet::FileSystem.exist?(conf)
67
- contents = Puppet::FileSystem.read(conf)
68
- match = /^#{value}\s*=\s*(.*)/.match(contents)
102
+ file = Puppet::Util::IniConfig::PhysicalFile.new(conf)
103
+ if (main = file.get_section('main'))
104
+ main[value]
105
+ end
106
+ end
107
+ end
108
+
109
+ # Enumerate all files that may contain yum repository configs.
110
+ # '/etc/yum.conf' is always included.
111
+ #
112
+ # @api private
113
+ # @return [Array<String>
114
+ def self.repofiles
115
+ files = ["/etc/yum.conf"]
116
+ reposdir.each do |dir|
117
+ Dir.glob("#{dir}/*.repo").each do |file|
118
+ files << file
119
+ end
69
120
  end
70
121
 
71
- return match.captures[0] if match
122
+ files
72
123
  end
73
124
 
74
- # Build a virtual inifile by reading in numerous .repo
75
- # files into a single virtual file to ease manipulation.
125
+ # Build a virtual inifile by reading in numerous .repo files into a single
126
+ # virtual file to ease manipulation.
127
+ # @api private
76
128
  # @return [Puppet::Util::IniConfig::File] The virtual inifile representing
77
129
  # multiple real files.
78
130
  def self.virtual_inifile
79
131
  unless @virtual
80
132
  @virtual = Puppet::Util::IniConfig::File.new
81
- reposdir.each do |dir|
82
- Dir.glob("#{dir}/*.repo").each do |file|
83
- @virtual.read(file) if Puppet::FileSystem.file?(file)
84
- end
133
+ self.repofiles.each do |file|
134
+ @virtual.read(file) if Puppet::FileSystem.file?(file)
85
135
  end
86
136
  end
87
137
  return @virtual
88
138
  end
89
139
 
140
+ # Is the given key a valid type property?
141
+ #
142
+ # @api private
90
143
  # @param key [String] The property to look up.
91
144
  # @return [Boolean] Returns true if the property is defined in the type.
92
145
  def self.valid_property?(key)
93
146
  PROPERTIES.include?(key)
94
147
  end
95
148
 
96
- # We need to return a valid section from the larger virtual inifile here,
97
- # which we do by first looking it up and then creating a new section for
98
- # the appropriate name if none was found.
149
+ # Return an existing INI section or create a new section in the default location
150
+ #
151
+ # The default location is determined based on what yum repo directories
152
+ # and files are present. If /etc/yum.conf has a value for 'reposdir' then that
153
+ # is preferred. If no such INI property is found then the first default yum
154
+ # repo directory that is present is used. If no default directories exist then
155
+ # /etc/yum.conf is used.
156
+ #
99
157
  # @param name [String] Section name to lookup in the virtual inifile.
100
158
  # @return [Puppet::Util::IniConfig] The IniConfig section
101
159
  def self.section(name)
102
160
  result = self.virtual_inifile[name]
103
161
  # Create a new section if not found.
104
162
  unless result
105
- # Previously we did an .each on reposdir with the effect that we
106
- # constantly created and overwrote result until the last entry of
107
- # the array. This was done because the ordering is
108
- # [defaults, custom] for reposdir and we want to use the custom if
109
- # we have it and the defaults if not.
110
- path = ::File.join(reposdir.last, "#{name}.repo")
111
- Puppet.info("create new repo #{name} in file #{path}")
163
+ dirs = reposdir()
164
+ if dirs.empty?
165
+ # If no repo directories are present, default to using yum.conf.
166
+ path = '/etc/yum.conf'
167
+ else
168
+ # The ordering of reposdir is [defaults, custom], and we want to use
169
+ # the custom directory if present.
170
+ path = File.join(dirs.last, "#{name}.repo")
171
+ end
112
172
  result = self.virtual_inifile.add_section(name, path)
113
173
  end
114
174
  result
115
175
  end
116
176
 
117
- # Here we store all modifications to disk, forcing the output file to 0644 if it differs.
177
+ # Save all yum repository files and force the mode to 0644
178
+ # @api private
118
179
  # @return [void]
119
180
  def self.store
120
181
  inifile = self.virtual_inifile
@@ -130,6 +191,10 @@ Puppet::Type.type(:yumrepo).provide(:inifile) do
130
191
  end
131
192
  end
132
193
 
194
+ # Create a new section for the given repository and set all the specified
195
+ # properties in the section.
196
+ #
197
+ # @api public
133
198
  # @return [void]
134
199
  def create
135
200
  @property_hash[:ensure] = :present
@@ -143,20 +208,26 @@ Puppet::Type.type(:yumrepo).provide(:inifile) do
143
208
  PROPERTIES.each do |property|
144
209
  next if property == :ensure
145
210
 
146
-
147
211
  if value = @resource.should(property)
148
212
  self.send("#{property}=", value)
149
213
  end
150
214
  end
151
215
  end
152
216
 
153
- # @return [Boolean] Returns true if ensure => present.
217
+ # Does the given repository already exist?
218
+ #
219
+ # @api public
220
+ # @return [Boolean]
154
221
  def exists?
155
222
  @property_hash[:ensure] == :present
156
223
  end
157
224
 
158
- # We don't actually destroy the file here, merely mark it for
159
- # destruction in the section.
225
+ # Mark the given repository section for destruction.
226
+ #
227
+ # The actual removal of the section will be handled by {#flush} after the
228
+ # resource has been fully evaluated.
229
+ #
230
+ # @api public
160
231
  # @return [void]
161
232
  def destroy
162
233
  # Flag file for deletion on flush.
@@ -165,6 +236,9 @@ Puppet::Type.type(:yumrepo).provide(:inifile) do
165
236
  @property_hash.clear
166
237
  end
167
238
 
239
+ # Finalize the application of the given resource.
240
+ #
241
+ # @api public
168
242
  # @return [void]
169
243
  def flush
170
244
  self.class.store
@@ -216,7 +290,6 @@ Puppet::Type.type(:yumrepo).provide(:inifile) do
216
290
  @property_hash[property] = value
217
291
  end
218
292
 
219
- # @return [void]
220
293
  def section(name)
221
294
  self.class.section(name)
222
295
  end
@@ -251,7 +251,11 @@ class Puppet::Resource
251
251
  end
252
252
 
253
253
  def environment
254
- @environment ||= Puppet.lookup(:environments).get(Puppet[:environment])
254
+ @environment ||= if catalog
255
+ catalog.environment_instance
256
+ else
257
+ Puppet::Node::Environment::NONE
258
+ end
255
259
  end
256
260
 
257
261
  def environment=(environment)
@@ -383,6 +387,14 @@ class Puppet::Resource
383
387
  def copy_as_resource
384
388
  result = Puppet::Resource.new(type, title)
385
389
 
390
+ result.file = self.file
391
+ result.line = self.line
392
+ result.exported = self.exported
393
+ result.virtual = self.virtual
394
+ result.tag(*self.tags)
395
+ result.environment = environment
396
+ result.instance_variable_set(:@rstype, resource_type)
397
+
386
398
  to_hash.each do |p, v|
387
399
  if v.is_a?(Puppet::Resource)
388
400
  v = Puppet::Resource.new(v.type, v.title)
@@ -406,14 +418,6 @@ class Puppet::Resource
406
418
  end
407
419
  end
408
420
 
409
- result.file = self.file
410
- result.line = self.line
411
- result.exported = self.exported
412
- result.virtual = self.virtual
413
- result.tag(*self.tags)
414
- result.environment = environment
415
- result.instance_variable_set(:@rstype, resource_type)
416
-
417
421
  result
418
422
  end
419
423
 
@@ -46,9 +46,12 @@ class Puppet::Resource::Catalog < Puppet::Graph::SimpleGraph
46
46
  # Some metadata to help us compile and generally respond to the current state.
47
47
  attr_accessor :client_version, :server_version
48
48
 
49
- # The environment for this catalog
49
+ # A String representing the environment for this catalog
50
50
  attr_accessor :environment
51
51
 
52
+ # The actual environment instance that was used during compilation
53
+ attr_accessor :environment_instance
54
+
52
55
  # Add classes to our class list.
53
56
  def add_class(*classes)
54
57
  classes.each do |klass|
@@ -232,15 +235,17 @@ class Puppet::Resource::Catalog < Puppet::Graph::SimpleGraph
232
235
  host_config
233
236
  end
234
237
 
235
- def initialize(name = nil)
238
+ def initialize(name = nil, environment = Puppet::Node::Environment::NONE)
236
239
  super()
237
- @name = name if name
240
+ @name = name
238
241
  @classes = []
239
242
  @resource_table = {}
240
243
  @resources = []
241
244
  @relationship_graph = nil
242
245
 
243
246
  @host_config = true
247
+ @environment_instance = environment
248
+ @environment = environment.to_s
244
249
 
245
250
  @aliases = {}
246
251
 
@@ -294,6 +299,7 @@ class Puppet::Resource::Catalog < Puppet::Graph::SimpleGraph
294
299
  # Reference class canonicalizes for us.
295
300
  res = Puppet::Resource.new(nil, type)
296
301
  end
302
+ res.catalog = self
297
303
  title_key = [res.type, res.title.to_s]
298
304
  uniqueness_key = [res.type, res.uniqueness_key].flatten
299
305
  @resource_table[title_key] || @resource_table[uniqueness_key]
@@ -314,7 +320,7 @@ class Puppet::Resource::Catalog < Puppet::Graph::SimpleGraph
314
320
  end
315
321
 
316
322
  def self.from_data_hash(data)
317
- result = new(data['name'])
323
+ result = new(data['name'], Puppet::Node::Environment::NONE)
318
324
 
319
325
  if tags = data['tags']
320
326
  result.tag(*tags)
@@ -326,6 +332,7 @@ class Puppet::Resource::Catalog < Puppet::Graph::SimpleGraph
326
332
 
327
333
  if environment = data['environment']
328
334
  result.environment = environment
335
+ result.environment_instance = Puppet::Node::Environment.remote(environment.to_sym)
329
336
  end
330
337
 
331
338
  if resources = data['resources']
@@ -484,10 +491,9 @@ class Puppet::Resource::Catalog < Puppet::Graph::SimpleGraph
484
491
  # This pretty much just converts all of the resources from one class to another, using
485
492
  # a conversion method.
486
493
  def to_catalog(convert)
487
- result = self.class.new(self.name)
494
+ result = self.class.new(self.name, self.environment_instance)
488
495
 
489
496
  result.version = self.version
490
- result.environment = self.environment
491
497
 
492
498
  map = {}
493
499
  resources.each do |resource|
@@ -139,16 +139,16 @@ class Puppet::Resource::TypeCollection
139
139
 
140
140
  def version
141
141
  if !defined?(@version)
142
- if environment[:config_version] == ""
142
+ if environment.config_version.nil? || environment.config_version == ""
143
143
  @version = Time.now.to_i
144
144
  else
145
- @version = Puppet::Util::Execution.execute([environment[:config_version]]).strip
145
+ @version = Puppet::Util::Execution.execute([environment.config_version]).strip
146
146
  end
147
147
  end
148
148
 
149
149
  @version
150
150
  rescue Puppet::ExecutionFailure => e
151
- raise Puppet::ParseError, "Execution of config_version command `#{environment[:config_version]}` failed: #{e.message}", e.backtrace
151
+ raise Puppet::ParseError, "Execution of config_version command `#{environment.config_version}` failed: #{e.message}", e.backtrace
152
152
  end
153
153
 
154
154
  def watch_file(filename)
@@ -18,10 +18,12 @@ class Puppet::Settings
18
18
  require 'puppet/settings/boolean_setting'
19
19
  require 'puppet/settings/terminus_setting'
20
20
  require 'puppet/settings/duration_setting'
21
+ require 'puppet/settings/ttl_setting'
21
22
  require 'puppet/settings/priority_setting'
22
23
  require 'puppet/settings/autosign_setting'
23
24
  require 'puppet/settings/config_file'
24
25
  require 'puppet/settings/value_translator'
26
+ require 'puppet/settings/environment_conf'
25
27
 
26
28
  # local reference for convenience
27
29
  PuppetOptionParser = Puppet::Util::CommandLine::PuppetOptionParser
@@ -107,6 +109,7 @@ class Puppet::Settings
107
109
  # @return [Object] the value of the setting
108
110
  # @api private
109
111
  def [](param)
112
+ Puppet.deprecation_warning("Accessing '#{param}' as a setting is deprecated. See http://links.puppetlabs.com/env-settings-deprecations") if DEPRECATED_SETTINGS.include?(param)
110
113
  value(param)
111
114
  end
112
115
 
@@ -115,6 +118,7 @@ class Puppet::Settings
115
118
  # @param value [Object] the new value of the setting
116
119
  # @api private
117
120
  def []=(param, value)
121
+ Puppet.deprecation_warning("Modifying '#{param}' as a setting is deprecated. See http://links.puppetlabs.com/env-settings-deprecations") if DEPRECATED_SETTINGS.include?(param)
118
122
  @value_sets[:memory].set(param, value)
119
123
  unsafe_flush_cache
120
124
  end
@@ -388,6 +392,10 @@ class Puppet::Settings
388
392
  end
389
393
  end
390
394
 
395
+ if FULLY_DEPRECATED_SETTINGS.include?(str)
396
+ Puppet.deprecation_warning("Setting #{str} is deprecated. See http://links.puppetlabs.com/env-settings-deprecations", "setting-#{str}")
397
+ end
398
+
391
399
  @value_sets[:cli].set(str, value)
392
400
  unsafe_flush_cache
393
401
  end
@@ -525,6 +533,8 @@ class Puppet::Settings
525
533
  # If we get here and don't have any data, we just return and don't muck with the current state of the world.
526
534
  return if data.nil?
527
535
 
536
+ issue_deprecations(data)
537
+
528
538
  # If we get here then we have some data, so we need to clear out any previous settings that may have come from
529
539
  # config files.
530
540
  unsafe_clear(false, false)
@@ -645,6 +655,7 @@ class Puppet::Settings
645
655
  :boolean => BooleanSetting,
646
656
  :terminus => TerminusSetting,
647
657
  :duration => DurationSetting,
658
+ :ttl => TTLSetting,
648
659
  :enum => EnumSetting,
649
660
  :priority => PrioritySetting,
650
661
  :autosign => AutosignSetting,
@@ -863,7 +874,7 @@ class Puppet::Settings
863
874
  def to_catalog(*sections)
864
875
  sections = nil if sections.empty?
865
876
 
866
- catalog = Puppet::Resource::Catalog.new("Settings")
877
+ catalog = Puppet::Resource::Catalog.new("Settings", Puppet::Node::Environment::NONE)
867
878
 
868
879
  @config.keys.find_all { |key| @config[key].is_a?(FileSetting) }.each do |key|
869
880
  file = @config[key]
@@ -1032,9 +1043,37 @@ Generated on #{Time.now}.
1032
1043
  end
1033
1044
  end
1034
1045
 
1046
+ # This method just turns a file into a new ConfigFile::Conf instance
1047
+ # @param file [String] absolute path to the configuration file
1048
+ # @return [Puppet::Settings::ConfigFile::Conf]
1049
+ # @api private
1050
+ def parse_file(file)
1051
+ @config_file_parser.parse_file(file, read_file(file))
1052
+ end
1035
1053
 
1036
1054
  private
1037
1055
 
1056
+ DEPRECATED_ENVIRONMENT_SETTINGS = [:manifest, :modulepath, :config_version].freeze
1057
+ FULLY_DEPRECATED_SETTINGS = [:templatedir, :manifestdir].freeze
1058
+ DEPRECATED_SETTINGS = (DEPRECATED_ENVIRONMENT_SETTINGS + FULLY_DEPRECATED_SETTINGS).freeze
1059
+
1060
+ def issue_deprecations(data)
1061
+ sections = data.sections.inject([]) do |accum,entry|
1062
+ accum << entry[1] if [:main, :master, :agent, :user].include?(entry[0])
1063
+ accum
1064
+ end
1065
+
1066
+ sections.each do |section|
1067
+ DEPRECATED_ENVIRONMENT_SETTINGS.each do |s|
1068
+ Puppet.deprecation_warning("Setting #{s} is deprecated in puppet.conf. See http://links.puppetlabs.com/env-settings-deprecations", "puppet-conf-setting-#{s}") if !section.setting(s).nil?
1069
+ end
1070
+
1071
+ FULLY_DEPRECATED_SETTINGS.each do |s|
1072
+ Puppet.deprecation_warning("Setting #{s} is deprecated. See http://links.puppetlabs.com/env-settings-deprecations", "setting-#{s}") if !section.setting(s).nil?
1073
+ end
1074
+ end
1075
+ end
1076
+
1038
1077
  def get_config_file_default(default)
1039
1078
  obj = nil
1040
1079
  unless obj = @config[default]
@@ -1086,28 +1125,18 @@ Generated on #{Time.now}.
1086
1125
  values_from_section = ValuesFromSection.new(name, section)
1087
1126
  end
1088
1127
  end
1089
- if values_from_section.nil? && @global_defaults_initialized
1090
- values_from_section = ValuesFromCurrentEnvironment.new(name)
1128
+ if values_from_section.nil? && global_defaults_initialized?
1129
+ values_from_section = ValuesFromEnvironmentConf.new(name)
1091
1130
  end
1092
1131
  values_from_section
1093
1132
  end
1094
1133
  end.compact
1095
1134
  end
1096
1135
 
1097
- # This method just turns a file in to a hash of hashes.
1098
- def parse_file(file)
1099
- @config_file_parser.parse_file(file, read_file(file))
1100
- end
1101
-
1102
1136
  # Read the file in.
1137
+ # @api private
1103
1138
  def read_file(file)
1104
- begin
1105
- return File.read(file)
1106
- rescue Errno::ENOENT
1107
- raise ArgumentError, "No such file #{file}", $!.backtrace
1108
- rescue Errno::EACCES
1109
- raise ArgumentError, "Permission denied to file #{file}", $!.backtrace
1110
- end
1139
+ return Puppet::FileSystem.read(file)
1111
1140
  end
1112
1141
 
1113
1142
  # Private method for internal test use only; allows to do a comprehensive clear of all settings between tests.
@@ -1277,38 +1306,30 @@ Generated on #{Time.now}.
1277
1306
  end
1278
1307
 
1279
1308
  # @api private
1280
- class ValuesFromCurrentEnvironment
1281
- def initialize(desired_environment)
1282
- @desired_environment = desired_environment
1309
+ class ValuesFromEnvironmentConf
1310
+ def initialize(environment_name)
1311
+ @environment_name = environment_name
1283
1312
  end
1284
1313
 
1285
1314
  def include?(name)
1286
- return false unless name == :modulepath || name == :manifest
1287
- if i = instance
1288
- i.include?(name)
1315
+ if Puppet::Settings::EnvironmentConf::VALID_SETTINGS.include?(name) && conf
1316
+ return true
1289
1317
  end
1318
+ false
1290
1319
  end
1291
1320
 
1292
1321
  def lookup(name)
1293
- return nil unless name == :modulepath || name == :manifest
1294
- if i = instance
1295
- i[name]
1296
- end
1322
+ return nil unless Puppet::Settings::EnvironmentConf::VALID_SETTINGS.include?(name)
1323
+ conf.send(name) if conf
1297
1324
  end
1298
1325
 
1299
- private
1300
-
1301
- def instance
1302
- unless @instance
1303
- env = Puppet.lookup(:current_environment)
1304
- if env.name == @desired_environment
1305
- @instance = {
1306
- :modulepath => env.full_modulepath.join(File::PATH_SEPARATOR),
1307
- :manifest => env.manifest,
1308
- }
1326
+ def conf
1327
+ unless @conf
1328
+ if environments = Puppet.lookup(:environments)
1329
+ @conf = environments.get_conf(@environment_name)
1309
1330
  end
1310
1331
  end
1311
- return @instance
1332
+ return @conf
1312
1333
  end
1313
1334
  end
1314
1335
  end