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
@@ -3,8 +3,17 @@ Puppet::Type.type(:exec).provide :shell, :parent => :posix do
3
3
 
4
4
  confine :feature => :posix
5
5
 
6
- desc "Execute external binaries directly, on POSIX systems.
7
- passing through a shell so that shell built ins are available."
6
+ desc <<-EOT
7
+ Passes the provided command through `/bin/sh`; only available on
8
+ POSIX systems. This allows the use of shell globbing and built-ins, and
9
+ does not require that the path to a command be fully-qualified. Although
10
+ this can be more convenient than the `posix` provider, it also means that
11
+ you need to be more careful with escaping; as ever, with great power comes
12
+ etc. etc.
13
+
14
+ This provider closely resembles the behavior of the `exec` type
15
+ in Puppet 0.25.x.
16
+ EOT
8
17
 
9
18
  def run(command, check = false)
10
19
  command = %Q{/bin/sh -c "#{command.gsub(/"/,'\"')}"}
@@ -0,0 +1,35 @@
1
+ require 'puppet/provider/exec'
2
+
3
+ Puppet::Type.type(:exec).provide :windows, :parent => Puppet::Provider::Exec do
4
+ include Puppet::Util::Execution
5
+
6
+ confine :feature => :microsoft_windows
7
+ defaultfor :feature => :microsoft_windows
8
+
9
+ desc "Execute external binaries directly, on Windows systems.
10
+ This does not pass through a shell, or perform any interpolation, but
11
+ only directly calls the command with the arguments given."
12
+
13
+ # Verify that we have the executable
14
+ def checkexe(command)
15
+ exe = extractexe(command)
16
+
17
+ if absolute_path?(exe)
18
+ if !File.exists?(exe)
19
+ raise ArgumentError, "Could not find command '#{exe}'"
20
+ elsif !File.file?(exe)
21
+ raise ArgumentError, "'#{exe}' is a #{File.ftype(exe)}, not a file"
22
+ end
23
+ return
24
+ end
25
+
26
+ path = resource[:path] || []
27
+
28
+ exts = [".exe", ".ps1", ".bat", ".com", ""]
29
+ withenv :PATH => path.join(File::PATH_SEPARATOR) do
30
+ return if exts.any? {|ext| which(exe + ext) }
31
+ end
32
+
33
+ raise ArgumentError, "Could not find command '#{exe}'"
34
+ end
35
+ end
@@ -0,0 +1,79 @@
1
+ class Puppet::Provider::Exec < Puppet::Provider
2
+ include Puppet::Util::Execution
3
+
4
+ def run(command, check = false)
5
+ output = nil
6
+ status = nil
7
+ dir = nil
8
+
9
+ checkexe(command)
10
+
11
+ if dir = resource[:cwd]
12
+ unless File.directory?(dir)
13
+ if check
14
+ dir = nil
15
+ else
16
+ self.fail "Working directory '#{dir}' does not exist"
17
+ end
18
+ end
19
+ end
20
+
21
+ dir ||= Dir.pwd
22
+
23
+ debug "Executing#{check ? " check": ""} '#{command}'"
24
+ begin
25
+ # Do our chdir
26
+ Dir.chdir(dir) do
27
+ environment = {}
28
+
29
+ environment[:PATH] = resource[:path].join(File::PATH_SEPARATOR) if resource[:path]
30
+
31
+ if envlist = resource[:environment]
32
+ envlist = [envlist] unless envlist.is_a? Array
33
+ envlist.each do |setting|
34
+ if setting =~ /^(\w+)=((.|\n)+)$/
35
+ env_name = $1
36
+ value = $2
37
+ if environment.include?(env_name) || environment.include?(env_name.to_sym)
38
+ warning "Overriding environment setting '#{env_name}' with '#{value}'"
39
+ end
40
+ environment[env_name] = value
41
+ else
42
+ warning "Cannot understand environment setting #{setting.inspect}"
43
+ end
44
+ end
45
+ end
46
+
47
+ withenv environment do
48
+ Timeout::timeout(resource[:timeout]) do
49
+ output, status = Puppet::Util::SUIDManager.
50
+ run_and_capture(command, resource[:user], resource[:group])
51
+ end
52
+ # The shell returns 127 if the command is missing.
53
+ if status.exitstatus == 127
54
+ raise ArgumentError, output
55
+ end
56
+ end
57
+ end
58
+ rescue Errno::ENOENT => detail
59
+ self.fail detail.to_s
60
+ end
61
+
62
+ return output, status
63
+ end
64
+
65
+ def extractexe(command)
66
+ # easy case: command was quoted
67
+ if command =~ /^"([^"]+)"/
68
+ $1
69
+ else
70
+ command.split(/ /)[0]
71
+ end
72
+ end
73
+
74
+ def validatecmd(command)
75
+ exe = extractexe(command)
76
+ # if we're not fully qualified, require a path
77
+ self.fail "'#{command}' is not qualified and no path was specified. Please qualify the command or specify a path." if !absolute_path?(exe) and resource[:path].nil?
78
+ end
79
+ end
@@ -0,0 +1,48 @@
1
+ require 'puppet/util/adsi'
2
+
3
+ Puppet::Type.type(:group).provide :windows_adsi do
4
+ desc "Group management for Windows"
5
+
6
+ defaultfor :operatingsystem => :windows
7
+ confine :operatingsystem => :windows
8
+ confine :feature => :microsoft_windows
9
+
10
+ has_features :manages_members
11
+
12
+ def group
13
+ @group ||= Puppet::Util::ADSI::Group.new(@resource[:name])
14
+ end
15
+
16
+ def members
17
+ group.members
18
+ end
19
+
20
+ def members=(members)
21
+ group.set_members(members)
22
+ end
23
+
24
+ def create
25
+ @group = Puppet::Util::ADSI::Group.create(@resource[:name])
26
+ self.members = @resource[:members]
27
+ end
28
+
29
+ def exists?
30
+ Puppet::Util::ADSI::Group.exists?(@resource[:name])
31
+ end
32
+
33
+ def delete
34
+ Puppet::Util::ADSI::Group.delete(@resource[:name])
35
+ end
36
+
37
+ def gid
38
+ nil
39
+ end
40
+
41
+ def gid=(value)
42
+ warning "No support for managing property gid of group #{@resource[:name]} on Windows"
43
+ end
44
+
45
+ def self.instances
46
+ Puppet::Util::ADSI::Group.map { |g| new(:ensure => :present, :name => g.name) }
47
+ end
48
+ end
@@ -3,6 +3,9 @@ require 'puppet/provider/parsedfile'
3
3
  hosts = nil
4
4
  case Facter.value(:operatingsystem)
5
5
  when "Solaris"; hosts = "/etc/inet/hosts"
6
+ when "windows"
7
+ require 'win32/resolv'
8
+ hosts = Win32::Resolv.get_hosts_path
6
9
  else
7
10
  hosts = "/etc/hosts"
8
11
  end
@@ -14,13 +14,13 @@ Puppet::Type.type(:macauthorization).provide :macauthorization, :parent => Puppe
14
14
 
15
15
  confine :operatingsystem => :darwin
16
16
 
17
- # This should be confined based on macosx_productversion once
18
- # http://projects.reductivelabs.com/issues/show/1796
19
- # is resolved.
17
+ # This should be confined based on macosx_productversion
18
+ # but puppet resource doesn't make the facts available and
19
+ # that interface is heavily used with this provider.
20
20
  if FileTest.exists?("/usr/bin/sw_vers")
21
21
  product_version = sw_vers "-productVersion"
22
22
 
23
- confine :true => if /^10.5/.match(product_version) or /^10.6/.match(product_version)
23
+ confine :true => unless /^10\.[0-4]/.match(product_version)
24
24
  true
25
25
  end
26
26
  end
@@ -1,6 +1,3 @@
1
- # Created by Luke Kanies on 2006-11-12.
2
- # Copyright (c) 2006. All rights reserved.
3
-
4
1
  require 'puppet'
5
2
 
6
3
  # A module just to store the mount/unmount methods. Individual providers
@@ -1,6 +1,3 @@
1
- # Created by Luke Kanies on 2007-11-27.
2
- # Copyright (c) 2007. All rights reserved.
3
-
4
1
  require 'puppet'
5
2
  require 'puppet/provider/parsedfile'
6
3
  require 'puppet/external/nagios'
@@ -107,4 +107,3 @@ Puppet::Type.type(:package).provide(:appdmg, :parent => Puppet::Provider::Packag
107
107
  self.class.installpkgdmg(source,name)
108
108
  end
109
109
  end
110
-
@@ -13,13 +13,10 @@ Puppet::Type.type(:package).provide :apple, :parent => Puppet::Provider::Package
13
13
 
14
14
  def self.instances
15
15
  instance_by_name.collect do |name|
16
-
17
- self.new(
18
-
19
- :name => name,
16
+ self.new(
17
+ :name => name,
20
18
  :provider => :apple,
21
-
22
- :ensure => :installed
19
+ :ensure => :installed
23
20
  )
24
21
  end
25
22
  end
@@ -48,4 +45,3 @@ Puppet::Type.type(:package).provide :apple, :parent => Puppet::Provider::Package
48
45
  installer "-pkg", source, "-target", "/"
49
46
  end
50
47
  end
51
-
@@ -109,4 +109,3 @@ Puppet::Type.type(:package).provide :apt, :parent => :dpkg, :source => :dpkg do
109
109
  super
110
110
  end
111
111
  end
112
-
@@ -27,4 +27,3 @@ Puppet::Type.type(:package).provide :aptitude, :parent => :apt, :source => :dpkg
27
27
  aptitude '-y', 'purge', @resource[:name]
28
28
  end
29
29
  end
30
-
@@ -81,4 +81,3 @@ Puppet::Type.type(:package).provide :aptrpm, :parent => :rpm, :source => :rpm do
81
81
  aptget '-y', '-q', 'remove', '--purge', @resource[:name]
82
82
  end
83
83
  end
84
-
@@ -109,4 +109,3 @@ Puppet::Type.type(:package).provide :blastwave, :parent => :sun, :source => :sun
109
109
  pkgget_with_cat "-f", :remove, @resource[:name]
110
110
  end
111
111
  end
112
-
@@ -102,16 +102,15 @@ Puppet::Type.type(:package).provide :dpkg, :parent => Puppet::Provider::Package
102
102
 
103
103
  # list out our specific package
104
104
  begin
105
-
106
- output = dpkgquery(
107
- "-W", "--showformat",
108
-
109
- '${Status} ${Package} ${Version}\\n', @resource[:name]
105
+ output = dpkgquery(
106
+ "-W",
107
+ "--showformat",
108
+ '${Status} ${Package} ${Version}\\n',
109
+ @resource[:name]
110
110
  )
111
111
  rescue Puppet::ExecutionFailure
112
112
  # dpkg-query exits 1 if the package is not found.
113
113
  return {:ensure => :purged, :status => 'missing', :name => @resource[:name], :error => 'ok'}
114
-
115
114
  end
116
115
 
117
116
  hash = self.class.parse_line(output) || {:ensure => :absent, :status => 'missing', :name => @resource[:name], :error => 'ok'}
@@ -48,11 +48,11 @@ Puppet::Type.type(:package).provide :fink, :parent => :dpkg, :source => :dpkg do
48
48
 
49
49
  if output =~ /Candidate:\s+(\S+)\s/
50
50
  return $1
51
- else
51
+ else
52
52
  self.err "Could not find latest version"
53
53
  return nil
54
- end
55
- end
54
+ end
55
+ end
56
56
 
57
57
  #
58
58
  # preseeds answers to dpkg-set-selection from the "responsefile"
@@ -79,4 +79,3 @@ Puppet::Type.type(:package).provide :fink, :parent => :dpkg, :source => :dpkg do
79
79
  aptget '-y', '-q', 'remove', '--purge', @resource[:name]
80
80
  end
81
81
  end
82
-
@@ -47,4 +47,3 @@ Puppet::Type.type(:package).provide :freebsd, :parent => :openbsd do
47
47
  pkgdelete "#{@resource[:name]}-#{@resource.should(:ensure)}"
48
48
  end
49
49
  end
50
-
@@ -121,4 +121,3 @@ Puppet::Type.type(:package).provide :gem, :parent => Puppet::Provider::Package d
121
121
  self.install(false)
122
122
  end
123
123
  end
124
-
@@ -27,10 +27,10 @@ Puppet::Type.type(:package).provide :hpux, :parent => Puppet::Provider::Package
27
27
  end
28
28
 
29
29
  def query
30
- swlist resource[:name]
31
- {:ensure => :present}
30
+ swlist resource[:name]
31
+ {:ensure => :present}
32
32
  rescue
33
- {:ensure => :absent}
33
+ {:ensure => :absent}
34
34
  end
35
35
 
36
36
  def uninstall
@@ -103,4 +103,3 @@ Puppet::Type.type(:package).provide :macports, :parent => Puppet::Provider::Pack
103
103
  end
104
104
  end
105
105
  end
106
-
@@ -0,0 +1,82 @@
1
+ require 'puppet/provider/package'
2
+
3
+ Puppet::Type.type(:package).provide(:msi, :parent => Puppet::Provider::Package) do
4
+ desc "Package management by installing and removing MSIs."
5
+
6
+ confine :operatingsystem => :windows
7
+ defaultfor :operatingsystem => :windows
8
+
9
+ has_feature :install_options
10
+
11
+ # This is just here to make sure we can find it, and fail if we
12
+ # can't. Unfortunately, we need to do "special" quoting of the
13
+ # install options or msiexec.exe won't know what to do with them, if
14
+ # the value contains a space.
15
+ commands :msiexec => "msiexec.exe"
16
+
17
+ def self.instances
18
+ Dir.entries(installed_listing_dir).reject {|d| d == '.' or d == '..'}.collect do |name|
19
+ new(:name => File.basename(name, '.yml'), :provider => :msi, :ensure => :installed)
20
+ end
21
+ end
22
+
23
+ def query
24
+ {:name => resource[:name], :ensure => :installed} if FileTest.exists?(state_file)
25
+ end
26
+
27
+ def install
28
+ properties_for_command = nil
29
+ if resource[:install_options]
30
+ properties_for_command = resource[:install_options].collect do |k,v|
31
+ property = shell_quote k
32
+ value = shell_quote v
33
+
34
+ "#{property}=#{value}"
35
+ end
36
+ end
37
+
38
+ # Unfortunately, we can't use the msiexec method defined earlier,
39
+ # because of the special quoting we need to do around the MSI
40
+ # properties to use.
41
+ execute ['msiexec.exe', '/qn', '/norestart', '/i', shell_quote(resource[:source]), properties_for_command].flatten.compact.join(' ')
42
+
43
+ File.open(state_file, 'w') do |f|
44
+ metadata = {
45
+ 'name' => resource[:name],
46
+ 'install_options' => resource[:install_options],
47
+ 'source' => resource[:source]
48
+ }
49
+
50
+ f.puts(YAML.dump metadata)
51
+ end
52
+ end
53
+
54
+ def uninstall
55
+ msiexec '/qn', '/norestart', '/x', resource[:source]
56
+
57
+ File.delete state_file
58
+ end
59
+
60
+ def validate_source(value)
61
+ fail("The source parameter is required when using the MSI provider.") if value.nil?
62
+ fail("The source parameter cannot be empty when using the MSI provider.") if value.empty?
63
+ end
64
+
65
+ private
66
+
67
+ def self.installed_listing_dir
68
+ listing_dir = File.join(Puppet[:vardir], 'db', 'package', 'msi')
69
+
70
+ FileUtils.mkdir_p listing_dir unless File.directory? listing_dir
71
+
72
+ listing_dir
73
+ end
74
+
75
+ def state_file
76
+ File.join(self.class.installed_listing_dir, "#{resource[:name]}.yml")
77
+ end
78
+
79
+ def shell_quote(value)
80
+ value.include?(' ') ? %Q["#{value.gsub(/"/, '\"')}"] : value
81
+ end
82
+ end
@@ -72,27 +72,27 @@ Puppet::Type.type(:package).provide :openbsd, :parent => Puppet::Provider::Packa
72
72
  end
73
73
 
74
74
  def get_version
75
- execpipe([command(:pkginfo), " -I ", @resource[:name]]) do |process|
76
- # our regex for matching pkg_info output
77
- regex = /^(.*)-(\d[^-]*)[-]?(\D*)(.*)$/
78
- fields = [ :name, :version, :flavor ]
79
- master_version = 0
80
-
81
- process.each do |line|
82
- if match = regex.match(line.split[0])
83
- # now we return the first version, unless ensure is latest
84
- version = match.captures[1]
85
- return version unless @resource[:ensure] == "latest"
86
-
87
- master_version = version unless master_version > version
88
- end
75
+ execpipe([command(:pkginfo), " -I ", @resource[:name]]) do |process|
76
+ # our regex for matching pkg_info output
77
+ regex = /^(.*)-(\d[^-]*)[-]?(\D*)(.*)$/
78
+ fields = [ :name, :version, :flavor ]
79
+ master_version = 0
80
+
81
+ process.each do |line|
82
+ if match = regex.match(line.split[0])
83
+ # now we return the first version, unless ensure is latest
84
+ version = match.captures[1]
85
+ return version unless @resource[:ensure] == "latest"
86
+
87
+ master_version = version unless master_version > version
89
88
  end
90
-
91
- return master_version unless master_version == 0
92
- raise Puppet::Error, "#{version} is not available for this package"
93
89
  end
90
+
91
+ return master_version unless master_version == 0
92
+ raise Puppet::Error, "#{version} is not available for this package"
93
+ end
94
94
  rescue Puppet::ExecutionFailure
95
- return nil
95
+ return nil
96
96
  end
97
97
 
98
98
  def query
@@ -113,4 +113,3 @@ Puppet::Type.type(:package).provide :openbsd, :parent => Puppet::Provider::Packa
113
113
  pkgdelete @resource[:name]
114
114
  end
115
115
  end
116
-
@@ -105,5 +105,4 @@ Puppet::Type.type(:package).provide :pip,
105
105
  raise e
106
106
  end
107
107
  end
108
-
109
108
  end
@@ -104,5 +104,4 @@ Puppet::Type.type(:package).provide :pkg, :parent => Puppet::Provider::Package d
104
104
 
105
105
  hash
106
106
  end
107
-
108
107
  end
@@ -12,7 +12,13 @@ require 'puppet/provider/package'
12
12
  require 'facter/util/plist'
13
13
 
14
14
  Puppet::Type.type(:package).provide :pkgdmg, :parent => Puppet::Provider::Package do
15
- desc "Package management based on Apple's Installer.app and DiskUtility.app. This package works by checking the contents of a DMG image for Apple pkg or mpkg files. Any number of pkg or mpkg files may exist in the root directory of the DMG file system. Sub directories are not checked for packages. See `the wiki docs <http://projects.puppetlabs.com/projects/puppet/wiki/Package_Management_With_Dmg_Patterns>` for more detail."
15
+ desc "Package management based on Apple's Installer.app and
16
+ DiskUtility.app. This package works by checking the contents of a
17
+ DMG image for Apple pkg or mpkg files. Any number of pkg or mpkg
18
+ files may exist in the root directory of the DMG file system. Sub
19
+ directories are not checked for packages. See `the wiki docs
20
+ <http://projects.puppetlabs.com/projects/puppet/wiki/Package_Management_With_Dmg_Patterns>`
21
+ for more detail."
16
22
 
17
23
  confine :operatingsystem => :darwin
18
24
  defaultfor :operatingsystem => :darwin
@@ -33,13 +39,10 @@ Puppet::Type.type(:package).provide :pkgdmg, :parent => Puppet::Provider::Packag
33
39
 
34
40
  def self.instances
35
41
  instance_by_name.collect do |name|
36
-
37
42
  new(
38
-
39
- :name => name,
43
+ :name => name,
40
44
  :provider => :pkgdmg,
41
-
42
- :ensure => :installed
45
+ :ensure => :installed
43
46
  )
44
47
  end
45
48
  end
@@ -124,4 +127,3 @@ Puppet::Type.type(:package).provide :pkgdmg, :parent => Puppet::Provider::Packag
124
127
  self.class.installpkgdmg(source,name)
125
128
  end
126
129
  end
127
-
@@ -172,4 +172,3 @@ Puppet::Type.type(:package).provide :pkgutil, :parent => :sun, :source => :sun d
172
172
  pkguti "-y", "-r", @resource[:name]
173
173
  end
174
174
  end
175
-
@@ -92,4 +92,3 @@ Puppet::Type.type(:package).provide :ports, :parent => :freebsd, :source => :fre
92
92
  install
93
93
  end
94
94
  end
95
-