puppet 2.7.3 → 2.7.4

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 (337) hide show
  1. data/CHANGELOG +166 -0
  2. data/install.rb +27 -7
  3. data/lib/puppet/application/agent.rb +29 -29
  4. data/lib/puppet/application/doc.rb +1 -1
  5. data/lib/puppet/application/inspect.rb +9 -1
  6. data/lib/puppet/application/master.rb +2 -0
  7. data/lib/puppet/application/queue.rb +1 -1
  8. data/lib/puppet/application/resource.rb +3 -0
  9. data/lib/puppet/application.rb +4 -5
  10. data/lib/puppet/configurer.rb +1 -4
  11. data/lib/puppet/defaults.rb +45 -15
  12. data/lib/puppet/feature/base.rb +28 -17
  13. data/lib/puppet/feature/rails.rb +0 -3
  14. data/lib/puppet/feature/rubygems.rb +0 -3
  15. data/lib/puppet/file_bucket/dipper.rb +3 -2
  16. data/lib/puppet/file_bucket/file.rb +3 -3
  17. data/lib/puppet/file_serving/base.rb +4 -5
  18. data/lib/puppet/file_serving/configuration.rb +7 -13
  19. data/lib/puppet/file_serving/content.rb +0 -4
  20. data/lib/puppet/file_serving/fileset.rb +7 -6
  21. data/lib/puppet/file_serving/indirection_hooks.rb +1 -4
  22. data/lib/puppet/file_serving/metadata.rb +0 -4
  23. data/lib/puppet/file_serving/mount/file.rb +9 -12
  24. data/lib/puppet/file_serving/mount.rb +0 -5
  25. data/lib/puppet/file_serving/terminus_helper.rb +0 -4
  26. data/lib/puppet/file_serving.rb +0 -4
  27. data/lib/puppet/indirector/catalog/compiler.rb +0 -18
  28. data/lib/puppet/indirector/catalog/store_configs.rb +5 -0
  29. data/lib/puppet/indirector/direct_file_server.rb +0 -4
  30. data/lib/puppet/indirector/facts/facter.rb +2 -2
  31. data/lib/puppet/indirector/facts/store_configs.rb +5 -0
  32. data/lib/puppet/indirector/file_content/file.rb +0 -4
  33. data/lib/puppet/indirector/file_content/file_server.rb +0 -4
  34. data/lib/puppet/indirector/file_content/rest.rb +0 -4
  35. data/lib/puppet/indirector/file_metadata/file.rb +0 -4
  36. data/lib/puppet/indirector/file_metadata/file_server.rb +0 -4
  37. data/lib/puppet/indirector/file_metadata/rest.rb +0 -4
  38. data/lib/puppet/indirector/file_server.rb +1 -5
  39. data/lib/puppet/indirector/indirection.rb +3 -5
  40. data/lib/puppet/indirector/node/store_configs.rb +5 -0
  41. data/lib/puppet/indirector/request.rb +3 -1
  42. data/lib/puppet/indirector/resource/active_record.rb +97 -0
  43. data/lib/puppet/indirector/resource/store_configs.rb +3 -0
  44. data/lib/puppet/indirector/ssl_file.rb +5 -1
  45. data/lib/puppet/indirector/store_configs.rb +30 -0
  46. data/lib/puppet/indirector/yaml.rb +5 -0
  47. data/lib/puppet/indirector.rb +7 -0
  48. data/lib/puppet/network/client.rb +0 -5
  49. data/lib/puppet/network/http_pool.rb +0 -56
  50. data/lib/puppet/node/environment.rb +9 -11
  51. data/lib/puppet/parameter/path.rb +1 -5
  52. data/lib/puppet/parameter.rb +1 -7
  53. data/lib/puppet/parser/ast/collection.rb +2 -2
  54. data/lib/puppet/parser/ast/collexpr.rb +10 -39
  55. data/lib/puppet/parser/collector.rb +41 -90
  56. data/lib/puppet/parser/compiler.rb +0 -3
  57. data/lib/puppet/parser/functions/create_resources.rb +22 -10
  58. data/lib/puppet/parser/functions/versioncmp.rb +9 -6
  59. data/lib/puppet/parser/resource.rb +1 -1
  60. data/lib/puppet/parser/type_loader.rb +2 -1
  61. data/lib/puppet/provider/augeas/augeas.rb +5 -3
  62. data/lib/puppet/provider/cron/crontab.rb +2 -2
  63. data/lib/puppet/provider/exec/posix.rb +23 -96
  64. data/lib/puppet/provider/exec/shell.rb +11 -2
  65. data/lib/puppet/provider/exec/windows.rb +35 -0
  66. data/lib/puppet/provider/exec.rb +79 -0
  67. data/lib/puppet/provider/group/windows_adsi.rb +48 -0
  68. data/lib/puppet/provider/host/parsed.rb +3 -0
  69. data/lib/puppet/provider/macauthorization/macauthorization.rb +4 -4
  70. data/lib/puppet/provider/mount.rb +0 -3
  71. data/lib/puppet/provider/naginator.rb +0 -3
  72. data/lib/puppet/provider/package/appdmg.rb +0 -1
  73. data/lib/puppet/provider/package/apple.rb +3 -7
  74. data/lib/puppet/provider/package/apt.rb +0 -1
  75. data/lib/puppet/provider/package/aptitude.rb +0 -1
  76. data/lib/puppet/provider/package/aptrpm.rb +0 -1
  77. data/lib/puppet/provider/package/blastwave.rb +0 -1
  78. data/lib/puppet/provider/package/dpkg.rb +5 -6
  79. data/lib/puppet/provider/package/fink.rb +3 -4
  80. data/lib/puppet/provider/package/freebsd.rb +0 -1
  81. data/lib/puppet/provider/package/gem.rb +0 -1
  82. data/lib/puppet/provider/package/hpux.rb +3 -3
  83. data/lib/puppet/provider/package/macports.rb +0 -1
  84. data/lib/puppet/provider/package/msi.rb +82 -0
  85. data/lib/puppet/provider/package/openbsd.rb +18 -19
  86. data/lib/puppet/provider/package/pip.rb +0 -1
  87. data/lib/puppet/provider/package/pkg.rb +0 -1
  88. data/lib/puppet/provider/package/pkgdmg.rb +9 -7
  89. data/lib/puppet/provider/package/pkgutil.rb +0 -1
  90. data/lib/puppet/provider/package/ports.rb +0 -1
  91. data/lib/puppet/provider/package/portupgrade.rb +183 -193
  92. data/lib/puppet/provider/package/rpm.rb +1 -1
  93. data/lib/puppet/provider/package/sun.rb +0 -1
  94. data/lib/puppet/provider/package/sunfreeware.rb +0 -2
  95. data/lib/puppet/provider/package/up2date.rb +0 -1
  96. data/lib/puppet/provider/package/urpmi.rb +0 -1
  97. data/lib/puppet/provider/package/yum.rb +1 -1
  98. data/lib/puppet/provider/package.rb +4 -3
  99. data/lib/puppet/provider/service/systemd.rb +64 -0
  100. data/lib/puppet/provider/service/windows.rb +110 -0
  101. data/lib/puppet/provider/user/windows_adsi.rb +71 -0
  102. data/lib/puppet/rails/resource.rb +1 -1
  103. data/lib/puppet/relationship.rb +0 -3
  104. data/lib/puppet/reports/tagmail.rb +15 -11
  105. data/lib/puppet/resource/catalog.rb +17 -24
  106. data/lib/puppet/ssl/certificate_authority.rb +7 -5
  107. data/lib/puppet/ssl/host.rb +6 -10
  108. data/lib/puppet/type/augeas.rb +19 -13
  109. data/lib/puppet/type/cron.rb +13 -12
  110. data/lib/puppet/type/exec.rb +17 -17
  111. data/lib/puppet/type/file/content.rb +7 -3
  112. data/lib/puppet/type/file/source.rb +14 -9
  113. data/lib/puppet/type/file.rb +44 -23
  114. data/lib/puppet/type/filebucket.rb +13 -5
  115. data/lib/puppet/type/package.rb +14 -1
  116. data/lib/puppet/type/service.rb +11 -1
  117. data/lib/puppet/type/ssh_authorized_key.rb +3 -1
  118. data/lib/puppet/type.rb +8 -17
  119. data/lib/puppet/util/adsi.rb +278 -0
  120. data/lib/puppet/util/autoload.rb +0 -2
  121. data/lib/puppet/util/cacher.rb +15 -67
  122. data/lib/puppet/util/feature.rb +0 -3
  123. data/lib/puppet/util/graph.rb +0 -3
  124. data/lib/puppet/util/ldap/connection.rb +0 -3
  125. data/lib/puppet/util/ldap/generator.rb +0 -3
  126. data/lib/puppet/util/ldap.rb +0 -3
  127. data/lib/puppet/util/log_paths.rb +0 -3
  128. data/lib/puppet/util/network_device/cisco/device.rb +2 -1
  129. data/lib/puppet/util/network_device/cisco/facts.rb +1 -1
  130. data/lib/puppet/util/pidlock.rb +5 -1
  131. data/lib/puppet/util/rdoc/parser.rb +3 -1
  132. data/lib/puppet/util/run_mode.rb +2 -2
  133. data/lib/puppet/util/settings/file_setting.rb +3 -2
  134. data/lib/puppet/util/settings.rb +4 -6
  135. data/lib/puppet/util/suidmanager.rb +62 -15
  136. data/lib/puppet/util.rb +113 -131
  137. data/lib/puppet.rb +1 -1
  138. data/spec/integration/application/doc_spec.rb +1 -1
  139. data/spec/integration/defaults_spec.rb +22 -17
  140. data/spec/integration/file_serving/content_spec.rb +0 -6
  141. data/spec/integration/file_serving/metadata_spec.rb +0 -6
  142. data/spec/integration/file_serving/terminus_helper_spec.rb +1 -1
  143. data/spec/integration/indirector/direct_file_server_spec.rb +5 -7
  144. data/spec/integration/indirector/file_content/file_server_spec.rb +2 -6
  145. data/spec/integration/indirector/file_metadata/file_server_spec.rb +1 -5
  146. data/spec/integration/network/server/webrick_spec.rb +6 -9
  147. data/spec/integration/node/facts_spec.rb +0 -6
  148. data/spec/integration/node_spec.rb +3 -4
  149. data/spec/integration/parser/compiler_spec.rb +2 -1
  150. data/spec/integration/parser/parser_spec.rb +2 -4
  151. data/spec/integration/provider/mount_spec.rb +1 -1
  152. data/spec/integration/provider/package_spec.rb +13 -3
  153. data/spec/integration/provider/ssh_authorized_key_spec.rb +4 -4
  154. data/spec/integration/reports_spec.rb +0 -4
  155. data/spec/integration/resource/catalog_spec.rb +0 -5
  156. data/spec/integration/ssl/certificate_authority_spec.rb +6 -14
  157. data/spec/integration/ssl/certificate_request_spec.rb +10 -17
  158. data/spec/integration/ssl/certificate_revocation_list_spec.rb +8 -13
  159. data/spec/integration/ssl/host_spec.rb +8 -14
  160. data/spec/integration/transaction/report_spec.rb +0 -5
  161. data/spec/integration/transaction_spec.rb +11 -13
  162. data/spec/integration/type/file_spec.rb +16 -16
  163. data/spec/integration/type/tidy_spec.rb +1 -1
  164. data/spec/integration/util/settings_spec.rb +2 -2
  165. data/spec/integration/util_spec.rb +13 -0
  166. data/spec/lib/puppet_spec/files.rb +18 -10
  167. data/spec/shared_behaviours/file_server_terminus.rb +1 -5
  168. data/spec/shared_behaviours/file_serving.rb +0 -4
  169. data/spec/shared_behaviours/memory_terminus.rb +0 -4
  170. data/spec/shared_behaviours/path_parameters.rb +20 -18
  171. data/spec/shared_behaviours/store_configs_terminus.rb +21 -0
  172. data/spec/spec_helper.rb +31 -0
  173. data/spec/unit/agent_spec.rb +0 -4
  174. data/spec/unit/application/apply_spec.rb +8 -2
  175. data/spec/unit/application/certificate_spec.rb +2 -0
  176. data/spec/unit/application/device_spec.rb +8 -6
  177. data/spec/unit/application/inspect_spec.rb +2 -1
  178. data/spec/unit/application/master_spec.rb +7 -2
  179. data/spec/unit/application/queue_spec.rb +3 -4
  180. data/spec/unit/application/resource_spec.rb +26 -0
  181. data/spec/unit/application/secret_agent_spec.rb +3 -1
  182. data/spec/unit/application_spec.rb +4 -0
  183. data/spec/unit/configurer/downloader_spec.rb +4 -3
  184. data/spec/unit/configurer_spec.rb +11 -4
  185. data/spec/unit/daemon_spec.rb +3 -1
  186. data/spec/unit/face/ca_spec.rb +1 -1
  187. data/spec/unit/face/node_spec.rb +5 -1
  188. data/spec/unit/face/secret_agent_spec.rb +3 -1
  189. data/spec/unit/file_bucket/dipper_spec.rb +4 -4
  190. data/spec/unit/file_bucket/file_spec.rb +9 -3
  191. data/spec/unit/file_serving/configuration_spec.rb +26 -37
  192. data/spec/unit/file_serving/fileset_spec.rb +71 -55
  193. data/spec/unit/file_serving/indirection_hooks_spec.rb +0 -4
  194. data/spec/unit/file_serving/mount/file_spec.rb +163 -169
  195. data/spec/unit/file_serving/terminus_helper_spec.rb +0 -4
  196. data/spec/unit/indirector/catalog/compiler_spec.rb +0 -22
  197. data/spec/unit/indirector/catalog/store_configs_spec.rb +17 -0
  198. data/spec/unit/indirector/certificate/ca_spec.rb +0 -4
  199. data/spec/unit/indirector/certificate/file_spec.rb +0 -4
  200. data/spec/unit/indirector/certificate_request/ca_spec.rb +1 -5
  201. data/spec/unit/indirector/certificate_request/file_spec.rb +0 -4
  202. data/spec/unit/indirector/certificate_revocation_list/ca_spec.rb +0 -4
  203. data/spec/unit/indirector/certificate_revocation_list/file_spec.rb +0 -4
  204. data/spec/unit/indirector/certificate_status/file_spec.rb +1 -1
  205. data/spec/unit/indirector/direct_file_server_spec.rb +0 -4
  206. data/spec/unit/indirector/facts/facter_spec.rb +0 -4
  207. data/spec/unit/indirector/facts/inventory_active_record_spec.rb +3 -0
  208. data/spec/unit/indirector/facts/store_configs_spec.rb +17 -0
  209. data/spec/unit/indirector/file_bucket_file/file_spec.rb +3 -3
  210. data/spec/unit/indirector/file_content/file_server_spec.rb +0 -4
  211. data/spec/unit/indirector/file_content/file_spec.rb +0 -4
  212. data/spec/unit/indirector/file_metadata/file_server_spec.rb +0 -4
  213. data/spec/unit/indirector/file_metadata/file_spec.rb +0 -4
  214. data/spec/unit/indirector/file_server_spec.rb +1 -5
  215. data/spec/unit/indirector/indirection_spec.rb +0 -4
  216. data/spec/unit/indirector/key/ca_spec.rb +0 -4
  217. data/spec/unit/indirector/key/file_spec.rb +0 -4
  218. data/spec/unit/indirector/node/store_configs_spec.rb +16 -0
  219. data/spec/unit/indirector/report/processor_spec.rb +0 -4
  220. data/spec/unit/indirector/resource/active_record_spec.rb +192 -0
  221. data/spec/unit/indirector/resource/ral_spec.rb +1 -1
  222. data/spec/unit/indirector/resource/store_configs_spec.rb +12 -0
  223. data/spec/unit/indirector/resource_type/parser_spec.rb +3 -3
  224. data/spec/unit/indirector/ssl_file_spec.rb +25 -6
  225. data/spec/unit/indirector/store_configs_spec.rb +8 -0
  226. data/spec/unit/indirector/yaml_spec.rb +14 -0
  227. data/spec/unit/module_spec.rb +2 -2
  228. data/spec/unit/network/handler/fileserver_spec.rb +5 -5
  229. data/spec/unit/network/http/mongrel_spec.rb +0 -4
  230. data/spec/unit/network/http/webrick_spec.rb +5 -9
  231. data/spec/unit/network/http_pool_spec.rb +4 -75
  232. data/spec/unit/network/http_spec.rb +0 -4
  233. data/spec/unit/network/server_spec.rb +0 -4
  234. data/spec/unit/node/environment_spec.rb +18 -31
  235. data/spec/unit/node/facts_spec.rb +0 -4
  236. data/spec/unit/node_spec.rb +1 -8
  237. data/spec/unit/other/selinux_spec.rb +3 -1
  238. data/spec/unit/parameter_spec.rb +0 -10
  239. data/spec/unit/parser/ast/collexpr_spec.rb +17 -13
  240. data/spec/unit/parser/collector_spec.rb +147 -263
  241. data/spec/unit/parser/compiler_spec.rb +3 -1
  242. data/spec/unit/parser/files_spec.rb +7 -4
  243. data/spec/unit/parser/functions/extlookup_spec.rb +6 -3
  244. data/spec/unit/parser/functions/sprintf_spec.rb +2 -1
  245. data/spec/unit/parser/type_loader_spec.rb +7 -7
  246. data/spec/unit/property_spec.rb +1 -1
  247. data/spec/unit/provider/augeas/augeas_spec.rb +14 -0
  248. data/spec/unit/provider/exec/posix_spec.rb +102 -106
  249. data/spec/unit/provider/exec/shell_spec.rb +1 -1
  250. data/spec/unit/provider/exec/windows_spec.rb +119 -0
  251. data/spec/unit/provider/group/ldap_spec.rb +0 -4
  252. data/spec/unit/provider/group/windows_adsi_spec.rb +79 -0
  253. data/spec/unit/provider/ldap_spec.rb +0 -4
  254. data/spec/unit/provider/macauthorization_spec.rb +5 -0
  255. data/spec/unit/provider/mount/parsed_spec.rb +1 -5
  256. data/spec/unit/provider/package/msi_spec.rb +170 -0
  257. data/spec/unit/provider/service/redhat_spec.rb +2 -0
  258. data/spec/unit/provider/service/smf_spec.rb +3 -0
  259. data/spec/unit/provider/service/systemd_spec.rb +25 -0
  260. data/spec/unit/provider/service/windows_spec.rb +166 -0
  261. data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +2 -2
  262. data/spec/unit/provider/user/ldap_spec.rb +0 -4
  263. data/spec/unit/provider/user/user_role_add_spec.rb +1 -1
  264. data/spec/unit/provider/user/useradd_spec.rb +1 -1
  265. data/spec/unit/provider/user/windows_adsi_spec.rb +110 -0
  266. data/spec/unit/relationship_spec.rb +0 -4
  267. data/spec/unit/resource/catalog_spec.rb +37 -25
  268. data/spec/unit/resource/status_spec.rb +4 -2
  269. data/spec/unit/resource_spec.rb +5 -5
  270. data/spec/unit/simple_graph_spec.rb +0 -4
  271. data/spec/unit/ssl/certificate_authority_spec.rb +2 -2
  272. data/spec/unit/ssl/host_spec.rb +12 -13
  273. data/spec/unit/ssl/inventory_spec.rb +2 -2
  274. data/spec/unit/sslcertificates/ca_spec.rb +6 -10
  275. data/spec/unit/transaction/event_manager_spec.rb +4 -2
  276. data/spec/unit/transaction/event_spec.rb +3 -1
  277. data/spec/unit/transaction/report_spec.rb +2 -6
  278. data/spec/unit/transaction/resource_harness_spec.rb +9 -5
  279. data/spec/unit/transaction_spec.rb +3 -1
  280. data/spec/unit/type/cron_spec.rb +1 -1
  281. data/spec/unit/type/exec_spec.rb +80 -47
  282. data/spec/unit/type/file/checksum_spec.rb +9 -8
  283. data/spec/unit/type/file/content_spec.rb +2 -1
  284. data/spec/unit/type/file/selinux_spec.rb +10 -8
  285. data/spec/unit/type/file/source_spec.rb +18 -36
  286. data/spec/unit/type/file_spec.rb +170 -217
  287. data/spec/unit/type/group_spec.rb +1 -1
  288. data/spec/unit/type/mount_spec.rb +5 -5
  289. data/spec/unit/type/noop_metaparam_spec.rb +3 -1
  290. data/spec/unit/type/package_spec.rb +15 -3
  291. data/spec/unit/type/resources_spec.rb +2 -2
  292. data/spec/unit/type/service_spec.rb +19 -4
  293. data/spec/unit/type/ssh_authorized_key_spec.rb +10 -4
  294. data/spec/unit/type/tidy_spec.rb +3 -1
  295. data/spec/unit/type/user_spec.rb +1 -1
  296. data/spec/unit/type_spec.rb +29 -34
  297. data/spec/unit/util/adsi_spec.rb +202 -0
  298. data/spec/unit/util/autoload_spec.rb +23 -19
  299. data/spec/unit/util/backups_spec.rb +16 -13
  300. data/spec/unit/util/cacher_spec.rb +64 -141
  301. data/spec/unit/util/checksums_spec.rb +0 -4
  302. data/spec/unit/util/constant_inflector_spec.rb +0 -4
  303. data/spec/unit/util/execution_stub_spec.rb +1 -1
  304. data/spec/unit/util/ldap/connection_spec.rb +0 -4
  305. data/spec/unit/util/ldap/generator_spec.rb +0 -4
  306. data/spec/unit/util/ldap/manager_spec.rb +0 -4
  307. data/spec/unit/util/log_spec.rb +4 -2
  308. data/spec/unit/util/logging_spec.rb +2 -2
  309. data/spec/unit/util/nagios_maker_spec.rb +0 -4
  310. data/spec/unit/util/network_device/cisco/device_spec.rb +2 -1
  311. data/spec/unit/util/network_device/cisco/facts_spec.rb +3 -1
  312. data/spec/unit/util/network_device/config_spec.rb +5 -3
  313. data/spec/unit/util/rdoc/parser_spec.rb +7 -1
  314. data/spec/unit/util/run_mode_spec.rb +6 -2
  315. data/spec/unit/util/settings/file_setting_spec.rb +29 -2
  316. data/spec/unit/util/settings_spec.rb +28 -15
  317. data/spec/unit/util/storage_spec.rb +1 -1
  318. data/spec/unit/util/suidmanager_spec.rb +310 -0
  319. data/spec/unit/util/tagging_spec.rb +0 -4
  320. data/spec/unit/util_spec.rb +335 -0
  321. data/test/language/ast/variable.rb +0 -4
  322. data/test/lib/puppettest/support/resources.rb +0 -4
  323. data/test/lib/puppettest/testcase.rb +0 -4
  324. data/test/lib/puppettest.rb +0 -1
  325. data/test/network/handler/master.rb +0 -5
  326. data/test/network/server/webrick.rb +5 -22
  327. data/test/ral/manager/attributes.rb +0 -4
  328. data/test/ral/manager/instances.rb +0 -4
  329. data/test/ral/manager/manager.rb +0 -4
  330. data/test/ral/providers/cron/crontab.rb +1 -0
  331. data/test/ral/providers/service/base.rb +0 -4
  332. data/test/ral/type/filesources.rb +0 -1
  333. data/test/ral/type/resources.rb +0 -4
  334. data/test/util/utiltest.rb +0 -13
  335. metadata +36 -9
  336. data/spec/unit/network/client_spec.rb +0 -45
  337. data/test/puppet/tc_suidmanager.rb +0 -120
@@ -95,7 +95,7 @@ class Puppet::Node::Environment
95
95
 
96
96
  # Cache the modulepath, so that we aren't searching through
97
97
  # all known directories all the time.
98
- cached_attr(:modulepath, :ttl => Puppet[:filetimeout]) do
98
+ cached_attr(:modulepath, Puppet[:filetimeout]) do
99
99
  dirs = self[:modulepath].split(File::PATH_SEPARATOR)
100
100
  dirs = ENV["PUPPETLIB"].split(File::PATH_SEPARATOR) + dirs if ENV["PUPPETLIB"]
101
101
  validate_dirs(dirs)
@@ -103,7 +103,7 @@ class Puppet::Node::Environment
103
103
 
104
104
  # Return all modules from this environment.
105
105
  # Cache the list, because it can be expensive to create.
106
- cached_attr(:modules, :ttl => Puppet[:filetimeout]) do
106
+ cached_attr(:modules, Puppet[:filetimeout]) do
107
107
  module_names = modulepath.collect { |path| Dir.entries(path) }.flatten.uniq
108
108
  module_names.collect do |path|
109
109
  begin
@@ -114,12 +114,6 @@ class Puppet::Node::Environment
114
114
  end.compact
115
115
  end
116
116
 
117
- # Cache the manifestdir, so that we aren't searching through
118
- # all known directories all the time.
119
- cached_attr(:manifestdir, :ttl => Puppet[:filetimeout]) do
120
- validate_dirs(self[:manifestdir].split(File::PATH_SEPARATOR))
121
- end
122
-
123
117
  def to_s
124
118
  name.to_s
125
119
  end
@@ -136,14 +130,18 @@ class Puppet::Node::Environment
136
130
  end
137
131
 
138
132
  def validate_dirs(dirs)
133
+ dir_regex = Puppet.features.microsoft_windows? ? /^[A-Za-z]:#{File::SEPARATOR}/ : /^#{File::SEPARATOR}/
134
+ # REMIND: Dir.getwd on windows returns a path containing backslashes, which when joined with
135
+ # dir containing forward slashes, breaks our regex matching. In general, path validation needs
136
+ # to be refactored which will be handled in a future commit.
139
137
  dirs.collect do |dir|
140
- if dir !~ /^#{File::SEPARATOR}/
141
- File.join(Dir.getwd, dir)
138
+ if dir !~ dir_regex
139
+ File.expand_path(File.join(Dir.getwd, dir))
142
140
  else
143
141
  dir
144
142
  end
145
143
  end.find_all do |p|
146
- p =~ /^#{File::SEPARATOR}/ && FileTest.directory?(p)
144
+ p =~ dir_regex && FileTest.directory?(p)
147
145
  end
148
146
  end
149
147
 
@@ -17,11 +17,7 @@ class Puppet::Parameter::Path < Puppet::Parameter
17
17
  absolute = "[/#{::Regexp.quote(::File::SEPARATOR)}]"
18
18
  win32 = Puppet.features.microsoft_windows?
19
19
 
20
- Array(paths).each do |path|
21
- next if path =~ %r{^#{absolute}}
22
- next if win32 and path =~ %r{^(?:[a-zA-Z]:)?#{absolute}}
23
- fail("#{name} must be a fully qualified path")
24
- end
20
+ fail("#{name} must be a fully qualified path") unless Array(paths).all? {|path| absolute_path?(path)}
25
21
 
26
22
  paths
27
23
  end
@@ -2,7 +2,6 @@ require 'puppet/util/methodhelper'
2
2
  require 'puppet/util/log_paths'
3
3
  require 'puppet/util/logging'
4
4
  require 'puppet/util/docs'
5
- require 'puppet/util/cacher'
6
5
 
7
6
  class Puppet::Parameter
8
7
  include Puppet::Util
@@ -10,7 +9,6 @@ class Puppet::Parameter
10
9
  include Puppet::Util::LogPaths
11
10
  include Puppet::Util::Logging
12
11
  include Puppet::Util::MethodHelper
13
- include Puppet::Util::Cacher
14
12
 
15
13
  require 'puppet/parameter/value_collection'
16
14
 
@@ -75,7 +73,7 @@ class Puppet::Parameter
75
73
  define_method(:unsafe_munge, &block)
76
74
  end
77
75
 
78
- # Does the parameter supports reverse munge?
76
+ # Does the parameter support reverse munging?
79
77
  # This will be called when something wants to access the parameter
80
78
  # in a canonical form different to what the storage form is.
81
79
  def unmunge(&block)
@@ -150,10 +148,6 @@ class Puppet::Parameter
150
148
  self.fail(Puppet::DevError, msg)
151
149
  end
152
150
 
153
- def expirer
154
- resource.catalog
155
- end
156
-
157
151
  def fail(*args)
158
152
  type = nil
159
153
  if args[0].is_a?(Class)
@@ -13,11 +13,11 @@ class Puppet::Parser::AST
13
13
 
14
14
  # We return an object that does a late-binding evaluation.
15
15
  def evaluate(scope)
16
- str, code = query && query.safeevaluate(scope)
16
+ match, code = query && query.safeevaluate(scope)
17
17
 
18
18
  resource_type = scope.find_resource_type(@type)
19
19
  fail "Resource type #{@type} doesn't exist" unless resource_type
20
- newcoll = Puppet::Parser::Collector.new(scope, resource_type.name, str, code, self.form)
20
+ newcoll = Puppet::Parser::Collector.new(scope, resource_type.name, match, code, self.form)
21
21
 
22
22
  scope.compiler.add_collection(newcoll)
23
23
 
@@ -19,8 +19,8 @@ class CollExpr < AST::Branch
19
19
  end
20
20
 
21
21
  # The code is only used for virtual lookups
22
- str1, code1 = @test1.safeevaluate scope
23
- str2, code2 = @test2.safeevaluate scope
22
+ match1, code1 = @test1.safeevaluate scope
23
+ match2, code2 = @test2.safeevaluate scope
24
24
 
25
25
  # First build up the virtual code.
26
26
  # If we're a conjunction operator, then we're calling code. I did
@@ -31,50 +31,21 @@ class CollExpr < AST::Branch
31
31
  when "and"; code1.call(resource) and code2.call(resource)
32
32
  when "or"; code1.call(resource) or code2.call(resource)
33
33
  when "=="
34
- if str1 == "tag"
35
- resource.tagged?(str2)
34
+ if match1 == "tag"
35
+ resource.tagged?(match2)
36
36
  else
37
- if resource[str1].is_a?(Array)
38
- resource[str1].include?(str2)
37
+ if resource[match1].is_a?(Array)
38
+ resource[match1].include?(match2)
39
39
  else
40
- resource[str1] == str2
40
+ resource[match1] == match2
41
41
  end
42
42
  end
43
- when "!="; resource[str1] != str2
43
+ when "!="; resource[match1] != match2
44
44
  end
45
45
  end
46
46
 
47
- # Now build up the rails conditions code
48
- if self.parens and self.form == :exported
49
- Puppet.warning "Parentheses are ignored in Rails searches"
50
- end
51
-
52
- case @oper
53
- when "and", "or"
54
- if form == :exported
55
- raise Puppet::ParseError, "Puppet does not currently support collecting exported resources with more than one condition"
56
- end
57
- oper = @oper.upcase
58
- when "=="; oper = "="
59
- else
60
- oper = @oper
61
- end
62
-
63
- if oper == "=" or oper == "!="
64
- # Add the rails association info where necessary
65
- case str1
66
- when "title"
67
- str = "title #{oper} '#{str2}'"
68
- when "tag"
69
- str = "puppet_tags.name #{oper} '#{str2}'"
70
- else
71
- str = "param_values.value #{oper} '#{str2}' and param_names.name = '#{str1}'"
72
- end
73
- else
74
- str = "(#{str1}) #{oper} (#{str2})"
75
- end
76
-
77
- return str, code
47
+ match = [match1, @oper, match2]
48
+ return match, code
78
49
  end
79
50
 
80
51
  def initialize(hash = {})
@@ -3,10 +3,11 @@
3
3
  class Puppet::Parser::Collector
4
4
  attr_accessor :type, :scope, :vquery, :equery, :form, :resources, :overrides, :collected
5
5
 
6
- # Call the collection method, mark all of the returned objects as non-virtual,
7
- # optionally applying parameter overrides. The collector can also delete himself
8
- # from the compiler if there is no more resources to collect (valid only for resource fixed-set collector
9
- # which get their resources from +collect_resources+ and not from the catalog)
6
+ # Call the collection method, mark all of the returned objects as
7
+ # non-virtual, optionally applying parameter overrides. The collector can
8
+ # also delete himself from the compiler if there is no more resources to
9
+ # collect (valid only for resource fixed-set collector which get their
10
+ # resources from +collect_resources+ and not from the catalog)
10
11
  def evaluate
11
12
  # Shortcut if we're not using storeconfigs and they're trying to collect
12
13
  # exported resources.
@@ -29,7 +30,6 @@ class Puppet::Parser::Collector
29
30
 
30
31
  # we have an override for the collected resources
31
32
  if @overrides and !objects.empty?
32
-
33
33
  # force the resource to be always child of any other resource
34
34
  overrides[:source].meta_def(:child_of?) do
35
35
  true
@@ -39,23 +39,20 @@ class Puppet::Parser::Collector
39
39
  # overrided those resources
40
40
  objects.each do |res|
41
41
  unless @collected.include?(res.ref)
42
-
43
- newres = Puppet::Parser::Resource.new(
44
- res.type, res.title,
45
- :parameters => overrides[:parameters],
46
- :file => overrides[:file],
47
- :line => overrides[:line],
48
- :source => overrides[:source],
49
-
50
- :scope => overrides[:scope]
51
- )
42
+ newres = Puppet::Parser::Resource.
43
+ new(res.type, res.title,
44
+ :parameters => overrides[:parameters],
45
+ :file => overrides[:file],
46
+ :line => overrides[:line],
47
+ :source => overrides[:source],
48
+ :scope => overrides[:scope])
52
49
 
53
50
  scope.compiler.add_override(newres)
54
51
  end
55
52
  end
56
53
  end
57
54
 
58
- # filter out object that already have been collected by ourself
55
+ # filter out object that this collector has previously found.
59
56
  objects.reject! { |o| @collected.include?(o.ref) }
60
57
 
61
58
  return false if objects.empty?
@@ -68,17 +65,19 @@ class Puppet::Parser::Collector
68
65
  end
69
66
 
70
67
  def initialize(scope, type, equery, vquery, form)
71
- @scope = scope
68
+ @scope = scope
69
+ @vquery = vquery
70
+ @equery = equery
72
71
 
73
72
  # initialisation
74
73
  @collected = {}
75
74
 
76
75
  # Canonize the type
77
76
  @type = Puppet::Resource.new(type, "whatever").type
78
- @equery = equery
79
- @vquery = vquery
80
77
 
81
- raise(ArgumentError, "Invalid query form #{form}") unless [:exported, :virtual].include?(form)
78
+ unless [:exported, :virtual].include?(form)
79
+ raise ArgumentError, "Invalid query form #{form}"
80
+ end
82
81
  @form = form
83
82
  end
84
83
 
@@ -92,65 +91,36 @@ class Puppet::Parser::Collector
92
91
 
93
92
  private
94
93
 
95
- # Create our active record query.
96
- def build_active_record_query
97
- Puppet::Rails.init unless ActiveRecord::Base.connected?
98
-
99
- raise Puppet::DevError, "Cannot collect resources for a nil host" unless @scope.host
100
- host = Puppet::Rails::Host.find_by_name(@scope.host)
101
-
102
- search = "(exported=? AND restype=?)"
103
- values = [true, @type]
104
-
105
- search += " AND (#{@equery})" if @equery
106
-
107
- # note:
108
- # we're not eagerly including any relations here because
109
- # it can creates so much objects we'll throw out later.
110
- # We used to eagerly include param_names/values but the way
111
- # the search filter is built ruined those efforts and we
112
- # were eagerly loading only the searched parameter and not
113
- # the other ones.
114
- query = {}
115
- case search
116
- when /puppet_tags/
117
- query = {:joins => {:resource_tags => :puppet_tag}}
118
- when /param_name/
119
- query = {:joins => {:param_values => :param_name}}
120
- end
121
-
122
- # We're going to collect objects from rails, but we don't want any
123
- # objects from this host.
124
- search = ("host_id != ? AND #{search}") and values.unshift(host.id) if host
125
-
126
- query[:conditions] = [search, *values]
127
-
128
- query
129
- end
130
-
131
94
  # Collect exported objects.
132
95
  def collect_exported
133
- # First get everything from the export table. Just reuse our
134
- # collect_virtual method but tell it to use 'exported? for the test.
135
- resources = collect_virtual(true).reject { |r| ! r.virtual? }
136
-
137
- count = resources.length
138
-
139
- query = build_active_record_query
96
+ resources = []
140
97
 
141
- # Now look them up in the rails db. When we support attribute comparison
142
- # and such, we'll need to vary the conditions, but this works with no
143
- # attributes, anyway.
144
98
  time = Puppet::Util.thinmark do
145
- Puppet::Rails::Resource.find(:all, query).each do |obj|
146
- if resource = exported_resource(obj)
147
- count += 1
148
- resources << resource
99
+ # First get everything from the export table. Just reuse our
100
+ # collect_virtual method but tell it to use 'exported? for the test.
101
+ resources = collect_virtual(true).reject { |r| ! r.virtual? }
102
+
103
+ # key is '#{type}/#{name}', and host and filter.
104
+ found = Puppet::Resource.indirection.
105
+ search(@type, :host => @scope.host, :filter => @equery)
106
+
107
+ found.map {|x| x.to_resource(@scope) }.each do |item|
108
+ if existing = @scope.findresource(item.type, item.title)
109
+ unless existing.collector_id == item.collector_id
110
+ # unless this is the one we've already collected
111
+ raise Puppet::ParseError,
112
+ "Exported resource #{item.ref} cannot override local resource"
113
+ end
114
+ else
115
+ item.exported = false
116
+ @scope.compiler.add_resource(@scope, item)
117
+ resources << item
149
118
  end
150
119
  end
151
120
  end
152
121
 
153
- scope.debug("Collected %s %s resource%s in %.2f seconds" % [count, @type, count == 1 ? "" : "s", time])
122
+ scope.debug("Collected %s %s resource%s in %.2f seconds" %
123
+ [resources.length, @type, resources.length == 1 ? "" : "s", time])
154
124
 
155
125
  resources
156
126
  end
@@ -192,25 +162,6 @@ class Puppet::Parser::Collector
192
162
  end
193
163
  end
194
164
 
195
- # Seek a specific exported resource.
196
- def exported_resource(obj)
197
- if existing = @scope.findresource(obj.restype, obj.title)
198
- # Next see if we've already collected this resource
199
- return nil if existing.rails_id == obj.id
200
-
201
- # This is the one we've already collected
202
- raise Puppet::ParseError, "Exported resource #{obj.ref} cannot override local resource"
203
- end
204
-
205
- resource = obj.to_resource(self.scope)
206
-
207
- resource.exported = false
208
-
209
- scope.compiler.add_resource(scope, resource)
210
-
211
- resource
212
- end
213
-
214
165
  # Does the resource match our tests? We don't yet support tests,
215
166
  # so it's always true at the moment.
216
167
  def match?(resource)
@@ -1,6 +1,3 @@
1
- # Created by Luke A. Kanies on 2007-08-13.
2
- # Copyright (c) 2007. All rights reserved.
3
-
4
1
  require 'puppet/node'
5
2
  require 'puppet/resource/catalog'
6
3
  require 'puppet/util/errors'
@@ -1,12 +1,24 @@
1
- Puppet::Parser::Functions::newfunction(:create_resources, :doc => '
2
- Converts a hash into a set of resources and adds them to the catalog.
3
- Takes two parameters:
4
- create_resource($type, $resources)
5
- Creates resources of type $type from the $resources hash. Assumes that
6
- hash is in the following form:
7
- {title=>{parameters}}
8
- This is currently tested for defined resources, classes, as well as native types
9
- ') do |args|
1
+ Puppet::Parser::Functions::newfunction(:create_resources, :doc => <<-'ENDHEREDOC') do |args|
2
+ Converts a hash into a set of resources and adds them to the catalog.
3
+
4
+ This function takes two arguments: a resource type, and a hash describing
5
+ a set of resources. The hash should be in the form `{title => {parameters} }`:
6
+
7
+ # A hash of user resources:
8
+ $myusers = {
9
+ 'nick' => { uid => '1330',
10
+ group => allstaff,
11
+ groups => ['developers', 'operations', 'release'], }
12
+ 'dan' => { uid => '1308',
13
+ group => allstaff,
14
+ groups => ['developers', 'prosvc', 'release'], }
15
+ }
16
+
17
+ create_resource(user, $myusers)
18
+
19
+ This function can be used to create defined resources and classes, as well
20
+ as native resources.
21
+ ENDHEREDOC
10
22
  raise ArgumentError, ("create_resources(): wrong number of arguments (#{args.length}; must be 2)") if args.length != 2
11
23
  #raise ArgumentError, 'requires resource type and param hash' if args.size < 2
12
24
  # figure out what kind of resource we are
@@ -19,7 +31,7 @@ Takes two parameters:
19
31
  type_of_resource = :type
20
32
  elsif resource = find_definition(type_name.downcase)
21
33
  type_of_resource = :define
22
- else
34
+ else
23
35
  raise ArgumentError, "could not create resource of unknown type #{type_name}"
24
36
  end
25
37
  end
@@ -4,19 +4,19 @@ require 'puppet/util/package'
4
4
  Puppet::Parser::Functions::newfunction(
5
5
  :versioncmp, :type => :rvalue,
6
6
 
7
- :doc => "Compares two versions
7
+ :doc => "Compares two version numbers.
8
8
 
9
9
  Prototype:
10
10
 
11
11
  \$result = versioncmp(a, b)
12
12
 
13
- Where a and b are arbitrary version strings
13
+ Where a and b are arbitrary version strings.
14
14
 
15
- This functions returns a number:
15
+ This function returns:
16
16
 
17
- * Greater than 0 if version a is greater than version b
18
- * Equal to 0 if both version are equals
19
- * Less than 0 if version a is less than version b
17
+ * `1` if version a is greater than version b
18
+ * `0` if the versions are equal
19
+ * `-1` if version a is less than version b
20
20
 
21
21
  Example:
22
22
 
@@ -24,6 +24,9 @@ Example:
24
24
  notice('2.6-1 is > than 2.4.5')
25
25
  }
26
26
 
27
+ This function uses the same version comparison algorithm used by Puppet's
28
+ `package` type.
29
+
27
30
  ") do |args|
28
31
 
29
32
  unless args.length == 2
@@ -20,7 +20,7 @@ class Puppet::Parser::Resource < Puppet::Resource
20
20
  include Puppet::Util::Tagging
21
21
  include Puppet::Parser::YamlTrimmer
22
22
 
23
- attr_accessor :source, :scope, :rails_id
23
+ attr_accessor :source, :scope, :collector_id
24
24
  attr_accessor :virtual, :override, :translated, :catalog, :evaluated
25
25
 
26
26
  attr_reader :exported, :parameters
@@ -80,7 +80,8 @@ class Puppet::Parser::TypeLoader
80
80
 
81
81
  loaded_asts = []
82
82
  files.each do |file|
83
- unless file =~ /^#{File::SEPARATOR}/
83
+ regex = Puppet.features.microsoft_windows? ? /^[A-Za-z]:#{File::SEPARATOR}/ : /^#{File::SEPARATOR}/
84
+ unless file =~ regex
84
85
  file = File.join(dir, file)
85
86
  end
86
87
  @loading_helper.do_once(file) do
@@ -290,8 +290,10 @@ Puppet::Type.type(:augeas).provide(:augeas) do
290
290
  set_augeas_save_mode(SAVE_NEWFILE)
291
291
  do_execute_changes
292
292
  save_result = @aug.save
293
+ fail("Save failed with return code #{save_result}") unless save_result
294
+
293
295
  saved_files = @aug.match("/augeas/events/saved")
294
- if save_result and saved_files.size > 0
296
+ if saved_files.size > 0
295
297
  root = resource[:root].sub(/^\/$/, "")
296
298
  saved_files.each do |key|
297
299
  saved_file = @aug.get(key).to_s.sub(/^\/files/, root)
@@ -305,13 +307,13 @@ Puppet::Type.type(:augeas).provide(:augeas) do
305
307
  debug("Files changed, should execute")
306
308
  return_value = true
307
309
  else
308
- debug("Skipping because no files were changed or save failed")
310
+ debug("Skipping because no files were changed")
309
311
  return_value = false
310
312
  end
311
313
  end
312
314
  end
313
315
  ensure
314
- if not return_value or resource.noop?
316
+ if not return_value or resource.noop? or not save_result
315
317
  close_augeas
316
318
  end
317
319
  end
@@ -14,13 +14,13 @@ tab = case Facter.value(:operatingsystem)
14
14
  Puppet::Type.type(:cron).provide(:crontab, :parent => Puppet::Provider::ParsedFile, :default_target => ENV["USER"] || "root", :filetype => tab) do
15
15
  commands :crontab => "crontab"
16
16
 
17
- text_line :comment, :match => %r{^#}, :post_parse => proc { |record|
17
+ text_line :comment, :match => %r{^\s*#}, :post_parse => proc { |record|
18
18
  record[:name] = $1 if record[:line] =~ /Puppet Name: (.+)\s*$/
19
19
  }
20
20
 
21
21
  text_line :blank, :match => %r{^\s*$}
22
22
 
23
- text_line :environment, :match => %r{^\w+=}
23
+ text_line :environment, :match => %r{^\s*\w+=}
24
24
 
25
25
  record_line :freebsd_special, :fields => %w{special command},
26
26
  :match => %r{^@(\w+)\s+(.+)$}, :pre_gen => proc { |record|
@@ -1,112 +1,39 @@
1
- Puppet::Type.type(:exec).provide :posix do
2
- include Puppet::Util::Execution
1
+ require 'puppet/provider/exec'
3
2
 
3
+ Puppet::Type.type(:exec).provide :posix, :parent => Puppet::Provider::Exec do
4
4
  confine :feature => :posix
5
5
  defaultfor :feature => :posix
6
6
 
7
- desc "Execute external binaries directly, on POSIX systems.
8
- This does not pass through a shell, or perform any interpolation, but
9
- only directly calls the command with the arguments given."
10
-
11
- def run(command, check = false)
12
- output = nil
13
- status = nil
14
- dir = nil
15
-
16
- checkexe(command)
17
-
18
- if dir = resource[:cwd]
19
- unless File.directory?(dir)
20
- if check
21
- dir = nil
22
- else
23
- self.fail "Working directory '#{dir}' does not exist"
24
- end
25
- end
26
- end
27
-
28
- dir ||= Dir.pwd
29
-
30
- debug "Executing#{check ? " check": ""} '#{command}'"
31
- begin
32
- # Do our chdir
33
- Dir.chdir(dir) do
34
- environment = {}
35
-
36
- environment[:PATH] = resource[:path].join(":") if resource[:path]
37
-
38
- if envlist = resource[:environment]
39
- envlist = [envlist] unless envlist.is_a? Array
40
- envlist.each do |setting|
41
- if setting =~ /^(\w+)=((.|\n)+)$/
42
- env_name = $1
43
- value = $2
44
- if environment.include?(env_name) || environment.include?(env_name.to_sym)
45
- warning "Overriding environment setting '#{env_name}' with '#{value}'"
46
- end
47
- environment[env_name] = value
48
- else
49
- warning "Cannot understand environment setting #{setting.inspect}"
50
- end
51
- end
52
- end
53
-
54
- withenv environment do
55
- Timeout::timeout(resource[:timeout]) do
56
- output, status = Puppet::Util::SUIDManager.
57
- run_and_capture([command], resource[:user], resource[:group])
58
- end
59
- # The shell returns 127 if the command is missing.
60
- if status.exitstatus == 127
61
- raise ArgumentError, output
62
- end
63
- end
64
- end
65
- rescue Errno::ENOENT => detail
66
- self.fail detail.to_s
67
- end
68
-
69
- return output, status
70
- end
7
+ desc <<-EOT
8
+ Executes external binaries directly, without passing through a shell or
9
+ performing any interpolation. This is a safer and more predictable way
10
+ to execute most commands, but prevents the use of globbing and shell
11
+ built-ins (including control logic like "for" and "if" statements).
12
+ EOT
71
13
 
72
14
  # Verify that we have the executable
73
15
  def checkexe(command)
74
16
  exe = extractexe(command)
75
17
 
76
- if resource[:path]
77
- if Puppet.features.posix? and !File.exists?(exe)
78
- withenv :PATH => resource[:path].join(File::PATH_SEPARATOR) do
79
- exe = which(exe) || raise(ArgumentError,"Could not find command '#{exe}'")
80
- end
81
- elsif Puppet.features.microsoft_windows? and !File.exists?(exe)
82
- resource[:path].each do |path|
83
- [".exe", ".ps1", ".bat", ".com", ""].each do |extension|
84
- file = File.join(path, exe+extension)
85
- return if File.exists?(file)
86
- end
87
- end
18
+ if File.expand_path(exe) == exe
19
+ if !File.exists?(exe)
20
+ raise ArgumentError, "Could not find command '#{exe}'"
21
+ elsif !File.file?(exe)
22
+ raise ArgumentError, "'#{exe}' is a #{File.ftype(exe)}, not a file"
23
+ elsif !File.executable?(exe)
24
+ raise ArgumentError, "'#{exe}' is not executable"
88
25
  end
26
+ return
89
27
  end
90
28
 
91
- raise ArgumentError, "Could not find command '#{exe}'" unless File.exists?(exe)
92
- unless File.executable?(exe)
93
- raise ArgumentError,
94
- "'#{exe}' is not executable"
95
- end
96
- end
97
-
98
- def extractexe(command)
99
- # easy case: command was quoted
100
- if command =~ /^"([^"]+)"/
101
- $1
102
- else
103
- command.split(/ /)[0]
29
+ if resource[:path]
30
+ withenv :PATH => resource[:path].join(File::PATH_SEPARATOR) do
31
+ return if which(exe)
32
+ end
104
33
  end
105
- end
106
34
 
107
- def validatecmd(command)
108
- exe = extractexe(command)
109
- # if we're not fully qualified, require a path
110
- self.fail "'#{command}' is not qualified and no path was specified. Please qualify the command or specify a path." if File.expand_path(exe) != exe and resource[:path].nil?
35
+ # 'which' will only return the command if it's executable, so we can't
36
+ # distinguish not found from not executable
37
+ raise ArgumentError, "Could not find command '#{exe}'"
111
38
  end
112
39
  end