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
@@ -1,4 +1,3 @@
1
-
2
1
  # Whole new package, so include pack stuff
3
2
  require 'puppet/provider/package'
4
3
 
@@ -9,243 +8,234 @@ Puppet::Type.type(:package).provide :portupgrade, :parent => Puppet::Provider::P
9
8
  Use the port's full origin as the resource name. eg (ports-mgmt/portupgrade)
10
9
  for the portupgrade port."
11
10
 
12
- ## has_features is usually autodetected based on defs below.
13
- # has_features :installable, :uninstallable, :upgradeable
11
+ ## has_features is usually autodetected based on defs below.
12
+ # has_features :installable, :uninstallable, :upgradeable
14
13
 
15
- commands :portupgrade => "/usr/local/sbin/portupgrade",
16
- :portinstall => "/usr/local/sbin/portinstall",
17
- :portversion => "/usr/local/sbin/portversion",
18
- :portuninstall => "/usr/local/sbin/pkg_deinstall",
19
- :portinfo => "/usr/sbin/pkg_info"
14
+ commands :portupgrade => "/usr/local/sbin/portupgrade",
15
+ :portinstall => "/usr/local/sbin/portinstall",
16
+ :portversion => "/usr/local/sbin/portversion",
17
+ :portuninstall => "/usr/local/sbin/pkg_deinstall",
18
+ :portinfo => "/usr/sbin/pkg_info"
20
19
 
21
- ## Activate this only once approved by someone important.
22
- # defaultfor :operatingsystem => :freebsd
20
+ ## Activate this only once approved by someone important.
21
+ # defaultfor :operatingsystem => :freebsd
23
22
 
24
- # Remove unwanted environment variables.
25
- %w{INTERACTIVE UNAME}.each do |var|
26
- if ENV.include?(var)
27
- ENV.delete(var)
28
- end
29
- end
23
+ # Remove unwanted environment variables.
24
+ %w{INTERACTIVE UNAME}.each do |var|
25
+ if ENV.include?(var)
26
+ ENV.delete(var)
27
+ end
28
+ end
30
29
 
31
- ######## instances sub command (builds the installed packages list)
30
+ ######## instances sub command (builds the installed packages list)
32
31
 
33
- def self.instances
34
- Puppet.debug "portupgrade.rb Building packages list from installed ports"
32
+ def self.instances
33
+ Puppet.debug "portupgrade.rb Building packages list from installed ports"
35
34
 
36
- # regex to match output from pkg_info
37
- regex = %r{^(\S+)-([^-\s]+):(\S+)$}
38
- # Corresponding field names
39
- fields = [:portname, :ensure, :portorigin]
40
- # define Temporary hash used, packages array of hashes
41
- hash = Hash.new
42
- packages = []
35
+ # regex to match output from pkg_info
36
+ regex = %r{^(\S+)-([^-\s]+):(\S+)$}
37
+ # Corresponding field names
38
+ fields = [:portname, :ensure, :portorigin]
39
+ # define Temporary hash used, packages array of hashes
40
+ hash = Hash.new
41
+ packages = []
43
42
 
44
- # exec command
45
- cmdline = ["-aoQ"]
46
- begin
47
- output = portinfo(*cmdline)
48
- rescue Puppet::ExecutionFailure
49
- raise Puppet::Error.new(output)
50
- return nil
51
- end
43
+ # exec command
44
+ cmdline = ["-aoQ"]
45
+ begin
46
+ output = portinfo(*cmdline)
47
+ rescue Puppet::ExecutionFailure
48
+ raise Puppet::Error.new(output)
49
+ return nil
50
+ end
52
51
 
53
- # split output and match it and populate temp hash
54
- output.split("\n").each { |data|
55
- # reset hash to nil for each line
56
- hash.clear
57
- if match = regex.match(data)
58
- # Output matched regex
52
+ # split output and match it and populate temp hash
53
+ output.split("\n").each { |data|
54
+ # reset hash to nil for each line
55
+ hash.clear
56
+ if match = regex.match(data)
57
+ # Output matched regex
59
58
  fields.zip(match.captures) { |field, value|
60
59
  hash[field] = value
61
- }
62
-
63
- # populate the actual :name field from the :portorigin
64
- # Set :provider to this object name
65
- hash[:name] = hash[:portorigin]
66
- hash[:provider] = self.name
67
-
68
- # Add to the full packages listing
69
- packages << new(hash)
70
-
71
- else
72
- # unrecognised output from pkg_info
73
- Puppet.debug "portupgrade.Instances() - unable to match output: #{data}"
74
- end
75
60
  }
76
61
 
77
- # return the packages array of hashes
78
- return packages
62
+ # populate the actual :name field from the :portorigin
63
+ # Set :provider to this object name
64
+ hash[:name] = hash[:portorigin]
65
+ hash[:provider] = self.name
79
66
 
80
- end
67
+ # Add to the full packages listing
68
+ packages << new(hash)
69
+ else
70
+ # unrecognised output from pkg_info
71
+ Puppet.debug "portupgrade.Instances() - unable to match output: #{data}"
72
+ end
73
+ }
74
+
75
+ # return the packages array of hashes
76
+ return packages
77
+ end
81
78
 
82
- ######## Installation sub command
79
+ ######## Installation sub command
83
80
 
84
- def install
85
- Puppet.debug "portupgrade.install() - Installation call on #{@resource[:name]}"
86
- # -M: yes, we're a batch, so don't ask any questions
87
- cmdline = ["-M BATCH=yes", @resource[:name]]
81
+ def install
82
+ Puppet.debug "portupgrade.install() - Installation call on #{@resource[:name]}"
83
+ # -M: yes, we're a batch, so don't ask any questions
84
+ cmdline = ["-M BATCH=yes", @resource[:name]]
88
85
 
89
- # FIXME: it's possible that portinstall prompts for data so locks up.
86
+ # FIXME: it's possible that portinstall prompts for data so locks up.
90
87
  begin
91
88
  output = portinstall(*cmdline)
92
- rescue Puppet::ExecutionFailure
93
- raise Puppet::Error.new(output)
94
- end
95
-
96
- if output =~ /\*\* No such /
97
- raise Puppet::ExecutionFailure, "Could not find package #{@resource[:name]}"
98
- end
89
+ rescue Puppet::ExecutionFailure
90
+ raise Puppet::Error.new(output)
91
+ end
99
92
 
100
- # No return code required, so do nil to be clean
101
- return nil
93
+ if output =~ /\*\* No such /
94
+ raise Puppet::ExecutionFailure, "Could not find package #{@resource[:name]}"
102
95
  end
103
96
 
104
- ######## Latest subcommand (returns the latest version available, or current version if installed is latest)
97
+ # No return code required, so do nil to be clean
98
+ return nil
99
+ end
105
100
 
106
- def latest
107
- Puppet.debug "portupgrade.latest() - Latest check called on #{@resource[:name]}"
108
- # search for latest version available, or return current version.
109
- # cmdline = "portversion -v <portorigin>", returns "<portname> <code> <stuff>"
110
- # or "** No matching package found: <portname>"
111
- cmdline = ["-v", @resource[:name]]
101
+ ######## Latest subcommand (returns the latest version available, or current version if installed is latest)
112
102
 
113
- begin
114
- output = portversion(*cmdline)
115
- rescue Puppet::ExecutionFailure
116
- raise Puppet::Error.new(output)
117
- end
103
+ def latest
104
+ Puppet.debug "portupgrade.latest() - Latest check called on #{@resource[:name]}"
105
+ # search for latest version available, or return current version.
106
+ # cmdline = "portversion -v <portorigin>", returns "<portname> <code> <stuff>"
107
+ # or "** No matching package found: <portname>"
108
+ cmdline = ["-v", @resource[:name]]
118
109
 
119
- # Check: output format.
120
- if output =~ /^\S+-([^-\s]+)\s+(\S)\s+(.*)/
121
- # $1 = installed version, $2 = comparison, $3 other data
122
- # latest installed
123
- installedversion = $1
124
- comparison = $2
125
- otherdata = $3
126
-
127
- # Only return a new version number when it's clear that there is a new version
128
- # all others return the current version so no unexpected 'upgrades' occur.
129
- case comparison
130
- when "=", ">"
131
- Puppet.debug "portupgrade.latest() - Installed package is latest (#{installedversion})"
132
- return installedversion
133
- when "<"
134
- # "portpkg-1.7_5 < needs updating (port has 1.14)"
135
- # "portpkg-1.7_5 < needs updating (port has 1.14) (=> 'newport/pkg')
136
- if otherdata =~ /\(port has (\S+)\)/
137
- newversion = $1
138
- Puppet.debug "portupgrade.latest() - Installed version needs updating to (#{newversion})"
139
- return newversion
140
- else
141
- Puppet.debug "portupgrade.latest() - Unable to determine new version from (#{otherdata})"
142
- return installedversion
143
- end
144
- when "?", "!", "#"
145
- Puppet.debug "portupgrade.latest() - Comparison Error reported from portversion (#{output})"
146
- return installedversion
147
- else
148
- Puppet.debug "portupgrade.latest() - Unknown code from portversion output (#{output})"
149
- return installedversion
150
- end
110
+ begin
111
+ output = portversion(*cmdline)
112
+ rescue Puppet::ExecutionFailure
113
+ raise Puppet::Error.new(output)
114
+ end
151
115
 
116
+ # Check: output format.
117
+ if output =~ /^\S+-([^-\s]+)\s+(\S)\s+(.*)/
118
+ installedversion = $1
119
+ comparison = $2
120
+ otherdata = $3
121
+
122
+ # Only return a new version number when it's clear that there is a new version
123
+ # all others return the current version so no unexpected 'upgrades' occur.
124
+ case comparison
125
+ when "=", ">"
126
+ Puppet.debug "portupgrade.latest() - Installed package is latest (#{installedversion})"
127
+ return installedversion
128
+ when "<"
129
+ # "portpkg-1.7_5 < needs updating (port has 1.14)"
130
+ # "portpkg-1.7_5 < needs updating (port has 1.14) (=> 'newport/pkg')
131
+ if otherdata =~ /\(port has (\S+)\)/
132
+ newversion = $1
133
+ Puppet.debug "portupgrade.latest() - Installed version needs updating to (#{newversion})"
134
+ return newversion
152
135
  else
153
- # error: output not parsed correctly, error out with nil.
154
- # Seriously - this section should never be called in a perfect world.
155
- # as verification that the port is installed has already happened in query.
156
- if output =~ /^\*\* No matching package /
157
- raise Puppet::ExecutionFailure, "Could not find package #{@resource[:name]}"
158
- else
159
- # Any other error (dump output to log)
160
- raise Puppet::ExecutionFailure, "Unexpected output from portversion: #{output}"
161
- end
162
-
163
- # Just in case we still are running, return nil
164
- return nil
136
+ Puppet.debug "portupgrade.latest() - Unable to determine new version from (#{otherdata})"
137
+ return installedversion
165
138
  end
139
+ when "?", "!", "#"
140
+ Puppet.debug "portupgrade.latest() - Comparison Error reported from portversion (#{output})"
141
+ return installedversion
142
+ else
143
+ Puppet.debug "portupgrade.latest() - Unknown code from portversion output (#{output})"
144
+ return installedversion
145
+ end
166
146
 
167
- # At this point normal operation has finished and we shouldn't have been called.
168
- # Error out and let the admin deal with it.
169
- raise Puppet::Error, "portversion.latest() - fatal error with portversion: #{output}"
170
- return nil
147
+ else
148
+ # error: output not parsed correctly, error out with nil.
149
+ # Seriously - this section should never be called in a perfect world.
150
+ # as verification that the port is installed has already happened in query.
151
+ if output =~ /^\*\* No matching package /
152
+ raise Puppet::ExecutionFailure, "Could not find package #{@resource[:name]}"
153
+ else
154
+ # Any other error (dump output to log)
155
+ raise Puppet::ExecutionFailure, "Unexpected output from portversion: #{output}"
156
+ end
171
157
 
158
+ # Just in case we still are running, return nil
159
+ return nil
172
160
  end
173
161
 
174
- ###### Query subcommand - return a hash of details if exists, or nil if it doesn't.
175
- # Used to make sure the package is installed
162
+ # At this point normal operation has finished and we shouldn't have been called.
163
+ # Error out and let the admin deal with it.
164
+ raise Puppet::Error, "portversion.latest() - fatal error with portversion: #{output}"
165
+ return nil
166
+ end
176
167
 
177
- def query
178
- Puppet.debug "portupgrade.query() - Called on #{@resource[:name]}"
168
+ ###### Query subcommand - return a hash of details if exists, or nil if it doesn't.
169
+ # Used to make sure the package is installed
179
170
 
180
- cmdline = ["-qO", @resource[:name]]
181
- begin
182
- output = portinfo(*cmdline)
183
- rescue Puppet::ExecutionFailure
184
- raise Puppet::Error.new(output)
185
- end
171
+ def query
172
+ Puppet.debug "portupgrade.query() - Called on #{@resource[:name]}"
186
173
 
187
- # Check: if output isn't in the right format, return nil
188
- if output =~ /^(\S+)-([^-\s]+)/
189
- # Fill in the details
190
- hash = Hash.new
191
- hash[:portorigin] = self.name
192
- hash[:portname] = $1
193
- hash[:ensure] = $2
174
+ cmdline = ["-qO", @resource[:name]]
175
+ begin
176
+ output = portinfo(*cmdline)
177
+ rescue Puppet::ExecutionFailure
178
+ raise Puppet::Error.new(output)
179
+ end
194
180
 
195
- # If more details are required, then we can do another pkg_info query here
196
- # and parse out that output and add to the hash
181
+ # Check: if output isn't in the right format, return nil
182
+ if output =~ /^(\S+)-([^-\s]+)/
183
+ # Fill in the details
184
+ hash = Hash.new
185
+ hash[:portorigin] = self.name
186
+ hash[:portname] = $1
187
+ hash[:ensure] = $2
188
+
189
+ # If more details are required, then we can do another pkg_info
190
+ # query here and parse out that output and add to the hash
191
+ # return the hash to the caller
192
+ return hash
193
+ else
194
+ Puppet.debug "portupgrade.query() - package (#{@resource[:name]}) not installed"
195
+ return nil
196
+ end
197
+ end
197
198
 
198
- # return the hash to the caller
199
- return hash
200
- else
201
- Puppet.debug "portupgrade.query() - package (#{@resource[:name]}) not installed"
202
- return nil
203
- end
199
+ ####### Uninstall command
204
200
 
201
+ def uninstall
202
+ Puppet.debug "portupgrade.uninstall() - called on #{@resource[:name]}"
203
+ # Get full package name from port origin to uninstall with
204
+ cmdline = ["-qO", @resource[:name]]
205
+ begin
206
+ output = portinfo(*cmdline)
207
+ rescue Puppet::ExecutionFailure
208
+ raise Puppet::Error.new(output)
205
209
  end
206
210
 
207
- ####### Uninstall command
211
+ if output =~ /^(\S+)/
212
+ # output matches, so uninstall it
213
+ portuninstall $1
214
+ end
215
+ end
208
216
 
209
- def uninstall
210
- Puppet.debug "portupgrade.uninstall() - called on #{@resource[:name]}"
211
- # Get full package name from port origin to uninstall with
212
- cmdline = ["-qO", @resource[:name]]
213
- begin
214
- output = portinfo(*cmdline)
215
- rescue Puppet::ExecutionFailure
216
- raise Puppet::Error.new(output)
217
- end
217
+ ######## Update/upgrade command
218
218
 
219
- if output =~ /^(\S+)/
220
- # output matches, so uninstall it
221
- portuninstall $1
222
- end
219
+ def update
220
+ Puppet.debug "portupgrade.update() - called on (#{@resource[:name]})"
223
221
 
222
+ cmdline = ["-qO", @resource[:name]]
223
+ begin
224
+ output = portinfo(*cmdline)
225
+ rescue Puppet::ExecutionFailure
226
+ raise Puppet::Error.new(output)
224
227
  end
225
228
 
226
- ######## Update/upgrade command
227
-
228
- def update
229
- Puppet.debug "portupgrade.update() - called on (#{@resource[:name]})"
230
-
231
- cmdline = ["-qO", @resource[:name]]
229
+ if output =~ /^(\S+)/
230
+ # output matches, so upgrade the software
231
+ cmdline = ["-M BATCH=yes", $1]
232
232
  begin
233
- output = portinfo(*cmdline)
234
- rescue Puppet::ExecutionFailure
235
- raise Puppet::Error.new(output)
236
- end
237
-
238
- if output =~ /^(\S+)/
239
- # output matches, so upgrade the software
240
- cmdline = ["-M BATCH=yes", $1]
241
- begin
242
- output = portupgrade(*cmdline)
243
- rescue Puppet::ExecutionFailure
244
- raise Puppet::Error.new(output)
245
- end
246
- end
233
+ output = portupgrade(*cmdline)
234
+ rescue Puppet::ExecutionFailure
235
+ raise Puppet::Error.new(output)
236
+ end
247
237
  end
238
+ end
248
239
 
249
- ## EOF
240
+ ## EOF
250
241
  end
251
-
@@ -1,4 +1,5 @@
1
1
  require 'puppet/provider/package'
2
+
2
3
  # RPM packaging. Should work anywhere that has rpm installed.
3
4
  Puppet::Type.type(:package).provide :rpm, :source => :rpm, :parent => Puppet::Provider::Package do
4
5
  desc "RPM packaging support; should work anywhere with a working `rpm`
@@ -129,4 +130,3 @@ Puppet::Type.type(:package).provide :rpm, :source => :rpm, :parent => Puppet::Pr
129
130
  hash
130
131
  end
131
132
  end
132
-
@@ -152,4 +152,3 @@ Puppet::Type.type(:package).provide :sun, :parent => Puppet::Provider::Package d
152
152
  self.install
153
153
  end
154
154
  end
155
-
@@ -6,6 +6,4 @@ Puppet::Type.type(:package).provide :sunfreeware, :parent => :blastwave, :source
6
6
  commands :pkgget => "pkg-get"
7
7
 
8
8
  confine :operatingsystem => :solaris
9
-
10
9
  end
11
-
@@ -39,4 +39,3 @@ Puppet::Type.type(:package).provide :up2date, :parent => :rpm, :source => :rpm d
39
39
  self.install
40
40
  end
41
41
  end
42
-
@@ -57,4 +57,3 @@ Puppet::Type.type(:package).provide :urpmi, :parent => :rpm, :source => :rpm do
57
57
  self.install
58
58
  end
59
59
  end
60
-
@@ -1,4 +1,5 @@
1
1
  require 'puppet/util/package'
2
+
2
3
  Puppet::Type.type(:package).provide :yum, :parent => :rpm, :source => :rpm do
3
4
  desc "Support via `yum`."
4
5
 
@@ -104,4 +105,3 @@ Puppet::Type.type(:package).provide :yum, :parent => :rpm, :source => :rpm do
104
105
  yum "-y", :erase, @resource[:name]
105
106
  end
106
107
  end
107
-
@@ -1,6 +1,3 @@
1
- # Created by Luke A. Kanies on 2007-06-05.
2
- # Copyright (c) 2007. All rights reserved.
3
-
4
1
  class Puppet::Provider::Package < Puppet::Provider
5
2
  # Prefetch our package list, yo.
6
3
  def self.prefetch(packages)
@@ -24,4 +21,8 @@ class Puppet::Provider::Package < Puppet::Provider
24
21
  end
25
22
  @property_hash.dup
26
23
  end
24
+
25
+ def validate_source(value)
26
+ true
27
+ end
27
28
  end
@@ -0,0 +1,64 @@
1
+ # Manage systemd services using /bin/systemctl
2
+
3
+ Puppet::Type.type(:service).provide :systemd, :parent => :base do
4
+ desc "Manage systemd services using /bin/systemctl"
5
+
6
+ commands :systemctl => "/bin/systemctl"
7
+
8
+ #defaultfor :operatingsystem => [:redhat, :fedora, :suse, :centos, :sles, :oel, :ovm]
9
+
10
+ def self.instances
11
+ i = []
12
+ output = `systemctl list-units --full --all --no-pager`
13
+ 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|
14
+ i << m[0]
15
+ end
16
+ return i
17
+ rescue Puppet::ExecutionFailure
18
+ return []
19
+ end
20
+
21
+ def disable
22
+ output = systemctl(:disable, @resource[:name])
23
+ rescue Puppet::ExecutionFailure
24
+ raise Puppet::Error, "Could not disable #{self.name}: #{output}"
25
+ end
26
+
27
+ def enabled?
28
+ begin
29
+ systemctl("is-enabled", @resource[:name])
30
+ rescue Puppet::ExecutionFailure
31
+ return :false
32
+ end
33
+
34
+ :true
35
+ end
36
+
37
+ def status
38
+ begin
39
+ output = systemctl("is-active", @resource[:name])
40
+ rescue Puppet::ExecutionFailure
41
+ return :stopped
42
+ end
43
+ return :running
44
+ end
45
+
46
+ def enable
47
+ output = systemctl("enable", @resource[:name])
48
+ rescue Puppet::ExecutionFailure
49
+ raise Puppet::Error, "Could not enable #{self.name}: #{output}"
50
+ end
51
+
52
+ def restartcmd
53
+ [command(:systemctl), "restart", @resource[:name]]
54
+ end
55
+
56
+ def startcmd
57
+ [command(:systemctl), "start", @resource[:name]]
58
+ end
59
+
60
+ def stopcmd
61
+ [command(:systemctl), "stop", @resource[:name]]
62
+ end
63
+ end
64
+
@@ -0,0 +1,110 @@
1
+ # Windows Service Control Manager (SCM) provider
2
+
3
+ require 'win32/service' if Puppet.features.microsoft_windows?
4
+
5
+ Puppet::Type.type(:service).provide :windows do
6
+
7
+ desc "Support for Windows Service Control Manager (SCM).
8
+
9
+ Services are controlled according to win32-service gem.
10
+
11
+ * All SCM operations (start/stop/enable/disable/query) are supported.
12
+
13
+ * Control of service groups (dependencies) is not yet supported."
14
+
15
+ defaultfor :operatingsystem => :windows
16
+ confine :operatingsystem => :windows
17
+
18
+ has_feature :refreshable
19
+
20
+ def enable
21
+ w32ss = Win32::Service.configure( 'service_name' => @resource[:name], 'start_type' => Win32::Service::SERVICE_AUTO_START )
22
+ raise Puppet::Error.new("Win32 service enable of #{@resource[:name]} failed" ) if( w32ss.nil? )
23
+ rescue Win32::Service::Error => detail
24
+ raise Puppet::Error.new("Cannot enable #{@resource[:name]}, error was: #{detail}" )
25
+ end
26
+
27
+ def disable
28
+ w32ss = Win32::Service.configure( 'service_name' => @resource[:name], 'start_type' => Win32::Service::SERVICE_DISABLED )
29
+ raise Puppet::Error.new("Win32 service disable of #{@resource[:name]} failed" ) if( w32ss.nil? )
30
+ rescue Win32::Service::Error => detail
31
+ raise Puppet::Error.new("Cannot disable #{@resource[:name]}, error was: #{detail}" )
32
+ end
33
+
34
+ def manual_start
35
+ w32ss = Win32::Service.configure( 'service_name' => @resource[:name], 'start_type' => Win32::Service::SERVICE_DEMAND_START )
36
+ raise Puppet::Error.new("Win32 service manual enable of #{@resource[:name]} failed" ) if( w32ss.nil? )
37
+ rescue Win32::Service::Error => detail
38
+ raise Puppet::Error.new("Cannot enable #{@resource[:name]} for manual start, error was: #{detail}" )
39
+ end
40
+
41
+ def enabled?
42
+ w32ss = Win32::Service.config_info( @resource[:name] )
43
+ raise Puppet::Error.new("Win32 service query of #{@resource[:name]} failed" ) unless( !w32ss.nil? && w32ss.instance_of?( Struct::ServiceConfigInfo ) )
44
+ debug("Service #{@resource[:name]} start type is #{w32ss.start_type}")
45
+ case w32ss.start_type
46
+ when Win32::Service.get_start_type(Win32::Service::SERVICE_AUTO_START),
47
+ Win32::Service.get_start_type(Win32::Service::SERVICE_BOOT_START),
48
+ Win32::Service.get_start_type(Win32::Service::SERVICE_SYSTEM_START)
49
+ :true
50
+ when Win32::Service.get_start_type(Win32::Service::SERVICE_DEMAND_START)
51
+ :manual
52
+ when Win32::Service.get_start_type(Win32::Service::SERVICE_DISABLED)
53
+ :false
54
+ else
55
+ raise Puppet::Error.new("Unknown start type: #{w32ss.start_type}")
56
+ end
57
+ rescue Win32::Service::Error => detail
58
+ raise Puppet::Error.new("Cannot get start type for #{@resource[:name]}, error was: #{detail}" )
59
+ end
60
+
61
+ def start
62
+ if enabled? == :false
63
+ # If disabled and not managing enable, respect disabled and fail.
64
+ if @resource[:enable].nil?
65
+ raise Puppet::Error, "Will not start disabled service #{@resource[:name]} without managing enable. Specify 'enable => false' to override."
66
+ # Otherwise start. If enable => false, we will later sync enable and
67
+ # disable the service again.
68
+ elsif @resource[:enable] == :true
69
+ enable
70
+ else
71
+ manual_start
72
+ end
73
+ end
74
+
75
+ Win32::Service.start( @resource[:name] )
76
+ rescue Win32::Service::Error => detail
77
+ raise Puppet::Error.new("Cannot start #{@resource[:name]}, error was: #{detail}" )
78
+ end
79
+
80
+ def stop
81
+ Win32::Service.stop( @resource[:name] )
82
+ rescue Win32::Service::Error => detail
83
+ raise Puppet::Error.new("Cannot stop #{@resource[:name]}, error was: #{detail}" )
84
+ end
85
+
86
+ def restart
87
+ self.stop
88
+ self.start
89
+ end
90
+
91
+ def status
92
+ w32ss = Win32::Service.status( @resource[:name] )
93
+ raise Puppet::Error.new("Win32 service query of #{@resource[:name]} failed" ) unless( !w32ss.nil? && w32ss.instance_of?( Struct::ServiceStatus ) )
94
+ state = case w32ss.current_state
95
+ when "stopped", "pause pending", "stop pending", "paused" then :stopped
96
+ when "running", "continue pending", "start pending" then :running
97
+ else
98
+ raise Puppet::Error.new("Unknown service state '#{w32ss.current_state}' for service '#{@resource[:name]}'")
99
+ end
100
+ debug("Service #{@resource[:name]} is #{w32ss.current_state}")
101
+ return state
102
+ rescue Win32::Service::Error => detail
103
+ raise Puppet::Error.new("Cannot get status of #{@resource[:name]}, error was: #{detail}" )
104
+ end
105
+
106
+ # returns all providers for all existing services and startup state
107
+ def self.instances
108
+ Win32::Service.services.collect { |s| new(:name => s.service_name) }
109
+ end
110
+ end