puppet 0.24.5 → 0.24.6

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 (354) hide show
  1. data/CHANGELOG +206 -0
  2. data/Rakefile +53 -0
  3. data/bin/filebucket +0 -0
  4. data/bin/puppet +32 -11
  5. data/bin/puppetca +1 -0
  6. data/bin/puppetd +0 -0
  7. data/bin/puppetdoc +0 -0
  8. data/bin/puppetmasterd +0 -0
  9. data/bin/puppetrun +16 -8
  10. data/bin/ralsh +0 -0
  11. data/conf/debian/rules +0 -0
  12. data/conf/gentoo/init.d/puppetmaster +0 -0
  13. data/conf/osx/PackageInfo.plist +36 -0
  14. data/conf/osx/createpackage.sh +167 -0
  15. data/conf/osx/preflight +12 -0
  16. data/conf/redhat/client.init +1 -1
  17. data/conf/redhat/puppet.spec +34 -6
  18. data/conf/redhat/server.init +42 -7
  19. data/conf/redhat/server.sysconfig +22 -0
  20. data/conf/solaris/smf/svc-puppetd +0 -0
  21. data/conf/solaris/smf/svc-puppetmasterd +0 -0
  22. data/examples/etc/init.d/sleeper +0 -0
  23. data/examples/mac_dscl.pp +0 -0
  24. data/examples/mac_dscl_revert.pp +0 -0
  25. data/examples/mac_netinfo.pp +0 -0
  26. data/examples/mac_pkgdmg.pp +0 -0
  27. data/ext/bin/sleeper +0 -0
  28. data/ext/module_puppet +0 -0
  29. data/ext/nagios/check_puppet.rb +0 -0
  30. data/ext/passenger/README +63 -0
  31. data/ext/passenger/apache2.conf +29 -0
  32. data/ext/passenger/config.ru +40 -0
  33. data/ext/puppet-test +0 -0
  34. data/ext/puppetlast +6 -31
  35. data/ext/puppetstoredconfigclean.rb +87 -0
  36. data/install.rb +75 -20
  37. data/lib/puppet.rb +1 -1
  38. data/lib/puppet/daemon.rb +0 -0
  39. data/lib/puppet/defaults.rb +3 -7
  40. data/lib/puppet/external/base64.rb +0 -0
  41. data/lib/puppet/external/nagios.rb +0 -0
  42. data/lib/puppet/external/nagios/base.rb +0 -0
  43. data/lib/puppet/file_serving/fileset.rb +2 -2
  44. data/lib/puppet/file_serving/metadata.rb +3 -3
  45. data/lib/puppet/indirector/facts/facter.rb +3 -2
  46. data/lib/puppet/indirector/yaml.rb +10 -1
  47. data/lib/puppet/module.rb +36 -12
  48. data/lib/puppet/network/authstore.rb +0 -0
  49. data/lib/puppet/network/client/master.rb +12 -11
  50. data/lib/puppet/network/handler/filebucket.rb +0 -0
  51. data/lib/puppet/network/handler/fileserver.rb +38 -46
  52. data/lib/puppet/network/handler/master.rb +1 -1
  53. data/lib/puppet/network/handler/report.rb +0 -0
  54. data/lib/puppet/network/handler/resource.rb +0 -0
  55. data/lib/puppet/network/handler/runner.rb +0 -0
  56. data/lib/puppet/network/http_server/rack.rb +148 -0
  57. data/lib/puppet/network/rights.rb +0 -0
  58. data/lib/puppet/network/xmlrpc/client.rb +5 -5
  59. data/lib/puppet/node.rb +5 -9
  60. data/lib/puppet/node/environment.rb +1 -17
  61. data/lib/puppet/node/facts.rb +0 -0
  62. data/lib/puppet/parameter.rb +1 -28
  63. data/lib/puppet/parser/ast.rb +6 -0
  64. data/lib/puppet/parser/ast/arithmetic_operator.rb +41 -0
  65. data/lib/puppet/parser/ast/boolean_operator.rb +48 -0
  66. data/lib/puppet/parser/ast/collexpr.rb +6 -1
  67. data/lib/puppet/parser/ast/comparison_operator.rb +37 -0
  68. data/lib/puppet/parser/ast/minus.rb +23 -0
  69. data/lib/puppet/parser/ast/nop.rb +11 -0
  70. data/lib/puppet/parser/ast/not.rb +19 -0
  71. data/lib/puppet/parser/ast/resource_override.rb +23 -16
  72. data/lib/puppet/parser/ast/resource_reference.rb +10 -6
  73. data/lib/puppet/parser/ast/vardef.rb +2 -2
  74. data/lib/puppet/parser/collector.rb +2 -1
  75. data/lib/puppet/parser/functions.rb +7 -217
  76. data/lib/puppet/parser/functions/defined.rb +27 -0
  77. data/lib/puppet/parser/functions/fail.rb +4 -0
  78. data/lib/puppet/parser/functions/file.rb +21 -0
  79. data/lib/puppet/parser/functions/fqdn_rand.rb +15 -0
  80. data/lib/puppet/parser/functions/generate.rb +35 -0
  81. data/lib/puppet/parser/functions/include.rb +26 -0
  82. data/lib/puppet/parser/functions/realize.rb +14 -0
  83. data/lib/puppet/parser/functions/search.rb +7 -0
  84. data/lib/puppet/parser/functions/sha1.rb +6 -0
  85. data/lib/puppet/parser/functions/tag.rb +6 -0
  86. data/lib/puppet/parser/functions/tagged.rb +18 -0
  87. data/lib/puppet/parser/functions/template.rb +22 -0
  88. data/lib/puppet/parser/lexer.rb +15 -5
  89. data/lib/puppet/parser/parser.rb +1073 -715
  90. data/lib/puppet/parser/parser_support.rb +18 -13
  91. data/lib/puppet/parser/resource.rb +1 -1
  92. data/lib/puppet/parser/resource/param.rb +10 -2
  93. data/lib/puppet/parser/scope.rb +63 -5
  94. data/lib/puppet/parser/templatewrapper.rb +61 -15
  95. data/lib/puppet/property.rb +7 -1
  96. data/lib/puppet/property/keyvalue.rb +96 -0
  97. data/lib/puppet/property/list.rb +78 -0
  98. data/lib/puppet/provider/confine.rb +1 -1
  99. data/lib/puppet/provider/confine/variable.rb +10 -1
  100. data/lib/puppet/provider/cron/crontab.rb +0 -0
  101. data/lib/puppet/provider/mailalias/aliases.rb +0 -0
  102. data/lib/puppet/provider/maillist/mailman.rb +0 -0
  103. data/lib/puppet/provider/mount/parsed.rb +0 -0
  104. data/lib/puppet/provider/nameservice.rb +24 -39
  105. data/lib/puppet/provider/nameservice/directoryservice.rb +12 -3
  106. data/lib/puppet/provider/nameservice/netinfo.rb +12 -2
  107. data/lib/puppet/provider/nameservice/objectadd.rb +1 -10
  108. data/lib/puppet/provider/package/appdmg.rb +1 -1
  109. data/lib/puppet/provider/package/apple.rb +0 -0
  110. data/lib/puppet/provider/package/apt.rb +14 -21
  111. data/lib/puppet/provider/package/aptitude.rb +0 -0
  112. data/lib/puppet/provider/package/blastwave.rb +2 -0
  113. data/lib/puppet/provider/package/darwinport.rb +0 -0
  114. data/lib/puppet/provider/package/dpkg.rb +33 -51
  115. data/lib/puppet/provider/package/fink.rb +1 -1
  116. data/lib/puppet/provider/package/freebsd.rb +0 -0
  117. data/lib/puppet/provider/package/gem.rb +0 -0
  118. data/lib/puppet/provider/package/hpux.rb +46 -0
  119. data/lib/puppet/provider/package/openbsd.rb +0 -0
  120. data/lib/puppet/provider/package/pkgdmg.rb +1 -1
  121. data/lib/puppet/provider/package/portage.rb +3 -1
  122. data/lib/puppet/provider/package/ports.rb +3 -3
  123. data/lib/puppet/provider/package/rpm.rb +8 -1
  124. data/lib/puppet/provider/package/rug.rb +2 -2
  125. data/lib/puppet/provider/package/sun.rb +2 -0
  126. data/lib/puppet/provider/package/sunfreeware.rb +3 -0
  127. data/lib/puppet/provider/package/yum.rb +24 -17
  128. data/lib/puppet/provider/package/yumhelper.py +92 -11
  129. data/lib/puppet/provider/parsedfile.rb +0 -0
  130. data/lib/puppet/provider/port/parsed.rb +0 -0
  131. data/lib/puppet/provider/selboolean/getsetsebool.rb +47 -0
  132. data/lib/puppet/provider/selmodule/semodule.rb +143 -0
  133. data/lib/puppet/provider/service/base.rb +0 -0
  134. data/lib/puppet/provider/service/daemontools.rb +154 -0
  135. data/lib/puppet/provider/service/debian.rb +1 -1
  136. data/lib/puppet/provider/service/freebsd.rb +2 -0
  137. data/lib/puppet/provider/service/gentoo.rb +2 -0
  138. data/lib/puppet/provider/service/init.rb +0 -0
  139. data/lib/puppet/provider/service/redhat.rb +1 -1
  140. data/lib/puppet/provider/service/runit.rb +93 -0
  141. data/lib/puppet/provider/service/smf.rb +2 -0
  142. data/lib/puppet/provider/ssh_authorized_key/parsed.rb +7 -1
  143. data/lib/puppet/provider/sshkey/parsed.rb +0 -0
  144. data/lib/puppet/provider/user/hpux.rb +30 -0
  145. data/lib/puppet/provider/user/user_role_add.rb +156 -0
  146. data/lib/puppet/provider/user/useradd.rb +23 -14
  147. data/lib/puppet/rails/database/002_remove_duplicated_index_on_all_tables.rb +17 -0
  148. data/lib/puppet/rails/database/schema.rb +0 -8
  149. data/lib/puppet/rails/resource.rb +6 -6
  150. data/lib/puppet/reference/configuration.rb +0 -7
  151. data/lib/puppet/reports.rb +0 -0
  152. data/lib/puppet/reports/rrdgraph.rb +3 -2
  153. data/lib/puppet/sslcertificates.rb +0 -0
  154. data/lib/puppet/sslcertificates/inventory.rb +3 -2
  155. data/lib/puppet/sslcertificates/support.rb +3 -0
  156. data/lib/puppet/transaction/report.rb +1 -7
  157. data/lib/puppet/transportable.rb +10 -7
  158. data/lib/puppet/type.rb +2110 -14
  159. data/lib/puppet/type/cron.rb +0 -0
  160. data/lib/puppet/type/exec.rb +0 -0
  161. data/lib/puppet/type/file.rb +12 -2
  162. data/lib/puppet/type/file/checksum.rb +4 -0
  163. data/lib/puppet/type/file/content.rb +0 -0
  164. data/lib/puppet/type/file/ensure.rb +0 -0
  165. data/lib/puppet/type/file/group.rb +30 -43
  166. data/lib/puppet/type/file/mode.rb +0 -0
  167. data/lib/puppet/type/file/owner.rb +0 -0
  168. data/lib/puppet/type/file/selcontext.rb +104 -0
  169. data/lib/puppet/type/file/source.rb +0 -0
  170. data/lib/puppet/type/file/type.rb +0 -0
  171. data/lib/puppet/type/filebucket.rb +0 -0
  172. data/lib/puppet/type/group.rb +0 -8
  173. data/lib/puppet/type/host.rb +0 -0
  174. data/lib/puppet/type/mailalias.rb +0 -0
  175. data/lib/puppet/type/maillist.rb +0 -0
  176. data/lib/puppet/type/mount.rb +0 -0
  177. data/lib/puppet/type/package.rb +2 -2
  178. data/lib/puppet/type/port.rb +0 -0
  179. data/lib/puppet/type/schedule.rb +0 -0
  180. data/lib/puppet/type/selboolean.rb +31 -0
  181. data/lib/puppet/type/selmodule.rb +54 -0
  182. data/lib/puppet/type/ssh_authorized_key.rb +3 -3
  183. data/lib/puppet/type/sshkey.rb +0 -0
  184. data/lib/puppet/type/tidy.rb +0 -0
  185. data/lib/puppet/type/user.rb +153 -137
  186. data/lib/puppet/type/yumrepo.rb +18 -2
  187. data/lib/puppet/type/zone.rb +5 -1
  188. data/lib/puppet/util.rb +7 -7
  189. data/lib/puppet/util/filetype.rb +7 -0
  190. data/lib/puppet/util/instance_loader.rb +0 -0
  191. data/lib/puppet/util/ldap/connection.rb +11 -1
  192. data/lib/puppet/util/ldap/manager.rb +1 -1
  193. data/lib/puppet/util/loadedfile.rb +0 -0
  194. data/lib/puppet/util/log.rb +42 -43
  195. data/lib/puppet/util/metric.rb +23 -9
  196. data/lib/puppet/util/posix.rb +69 -18
  197. data/lib/puppet/util/selinux.rb +139 -0
  198. data/lib/puppet/util/settings.rb +5 -7
  199. data/lib/puppet/util/user_attr.rb +21 -0
  200. data/test/certmgr/ca.rb +0 -0
  201. data/test/certmgr/certmgr.rb +0 -0
  202. data/test/certmgr/inventory.rb +0 -0
  203. data/test/certmgr/support.rb +0 -0
  204. data/test/data/providers/ssh_authorized_key/parsed/authorized_keys1 +3 -0
  205. data/test/data/snippets/append.pp +11 -0
  206. data/test/data/snippets/arithmetic_expression.pp +8 -0
  207. data/test/data/snippets/arraytrailingcomma.pp +3 -0
  208. data/test/data/snippets/emptyifelse.pp +9 -0
  209. data/test/data/snippets/funccomma.pp +5 -0
  210. data/test/data/snippets/ifexpression.rb +6 -0
  211. data/test/data/snippets/subclass_name_duplication.pp +0 -0
  212. data/test/executables/filebucket.rb +0 -0
  213. data/test/executables/puppetbin.rb +0 -0
  214. data/test/executables/puppetca.rb +0 -0
  215. data/test/executables/puppetd.rb +0 -0
  216. data/test/executables/puppetmasterd.rb +0 -0
  217. data/test/executables/puppetmodule.rb +0 -0
  218. data/test/language/ast.rb +0 -0
  219. data/test/language/ast/casestatement.rb +0 -0
  220. data/test/language/ast/resource.rb +0 -0
  221. data/test/language/ast/resource_reference.rb +0 -28
  222. data/test/language/ast/selector.rb +0 -0
  223. data/test/language/ast/variable.rb +0 -0
  224. data/test/language/functions.rb +91 -12
  225. data/test/language/parser.rb +21 -0
  226. data/test/language/resource.rb +0 -0
  227. data/test/language/scope.rb +28 -0
  228. data/test/language/snippets.rb +14 -0
  229. data/test/language/transportable.rb +0 -0
  230. data/test/lib/puppettest.rb +0 -0
  231. data/test/lib/puppettest/reporttesting.rb +0 -2
  232. data/test/lib/puppettest/runnable_test.rb +2 -0
  233. data/test/lib/puppettest/support/resources.rb +0 -0
  234. data/test/network/authconfig.rb +0 -0
  235. data/test/network/authorization.rb +0 -0
  236. data/test/network/authstore.rb +0 -0
  237. data/test/network/client/ca.rb +0 -0
  238. data/test/network/client/client.rb +0 -0
  239. data/test/network/client/dipper.rb +0 -0
  240. data/test/network/client/master.rb +2 -6
  241. data/test/network/client/resource.rb +0 -0
  242. data/test/network/client_request.rb +0 -0
  243. data/test/network/daemon.rb +0 -0
  244. data/test/network/handler/bucket.rb +0 -0
  245. data/test/network/handler/ca.rb +0 -0
  246. data/test/network/handler/fileserver.rb +8 -0
  247. data/test/network/handler/handler.rb +0 -0
  248. data/test/network/handler/master.rb +3 -1
  249. data/test/network/handler/report.rb +0 -0
  250. data/test/network/handler/resource.rb +0 -0
  251. data/test/network/handler/runner.rb +0 -0
  252. data/test/network/rights.rb +0 -0
  253. data/test/network/server/mongrel_test.rb +0 -0
  254. data/test/network/server/webrick.rb +0 -0
  255. data/test/network/xmlrpc/client.rb +0 -0
  256. data/test/network/xmlrpc/processor.rb +0 -0
  257. data/test/network/xmlrpc/server.rb +0 -0
  258. data/test/network/xmlrpc/webrick_servlet.rb +0 -0
  259. data/test/other/dsl.rb +0 -0
  260. data/test/other/events.rb +0 -0
  261. data/test/other/overrides.rb +0 -0
  262. data/test/other/provider.rb +0 -0
  263. data/test/other/puppet.rb +0 -0
  264. data/test/other/relationships.rb +0 -0
  265. data/test/other/report.rb +2 -4
  266. data/test/other/transactions.rb +1 -1
  267. data/test/puppet/conffiles.rb +0 -0
  268. data/test/puppet/defaults.rb +0 -0
  269. data/test/puppet/errortest.rb +0 -0
  270. data/test/puppet/tc_suidmanager.rb +0 -0
  271. data/test/rails/ast.rb +0 -0
  272. data/test/rails/configuration.rb +0 -0
  273. data/test/rails/host.rb +0 -0
  274. data/test/rails/rails.rb +0 -0
  275. data/test/rails/railsparameter.rb +0 -0
  276. data/test/rails/railsresource.rb +0 -0
  277. data/test/ral/manager/attributes.rb +0 -0
  278. data/test/ral/manager/instances.rb +0 -0
  279. data/test/ral/manager/manager.rb +0 -0
  280. data/test/ral/manager/provider.rb +0 -0
  281. data/test/ral/manager/type.rb +0 -0
  282. data/test/ral/providers/cron/crontab.rb +0 -0
  283. data/test/ral/providers/group.rb +14 -13
  284. data/test/ral/providers/host/netinfo.rb +0 -0
  285. data/test/ral/providers/host/parsed.rb +0 -0
  286. data/test/ral/providers/mailalias/aliases.rb +0 -0
  287. data/test/ral/providers/mount/netinfo.rb +0 -0
  288. data/test/ral/providers/nameservice.rb +0 -0
  289. data/test/ral/providers/package.rb +0 -31
  290. data/test/ral/providers/package/aptitude.rb +1 -2
  291. data/test/ral/providers/package/aptrpm.rb +2 -2
  292. data/test/ral/providers/parsedfile.rb +0 -0
  293. data/test/ral/providers/port/parsed.rb +0 -0
  294. data/test/ral/providers/provider.rb +0 -0
  295. data/test/ral/providers/service/base.rb +0 -0
  296. data/test/ral/providers/service/debian.rb +0 -0
  297. data/test/ral/providers/sshkey/parsed.rb +0 -0
  298. data/test/ral/providers/user.rb +8 -8
  299. data/test/ral/providers/user/useradd.rb +0 -0
  300. data/test/ral/type/basic.rb +0 -0
  301. data/test/ral/type/cron.rb +0 -0
  302. data/test/ral/type/exec.rb +0 -0
  303. data/test/ral/type/file.rb +0 -0
  304. data/test/ral/type/file/target.rb +0 -0
  305. data/test/ral/type/filebucket.rb +0 -0
  306. data/test/ral/type/fileignoresource.rb +0 -0
  307. data/test/ral/type/filesources.rb +1 -3
  308. data/test/ral/type/group.rb +0 -0
  309. data/test/ral/type/host.rb +0 -0
  310. data/test/ral/type/mailalias.rb +1 -2
  311. data/test/ral/type/parameter.rb +0 -0
  312. data/test/ral/type/port.rb +0 -0
  313. data/test/ral/type/property.rb +0 -0
  314. data/test/ral/type/resources.rb +0 -0
  315. data/test/ral/type/service.rb +0 -0
  316. data/test/ral/type/sshkey.rb +0 -0
  317. data/test/ral/type/tidy.rb +0 -0
  318. data/test/ral/type/user.rb +0 -50
  319. data/test/ral/type/yumrepo.rb +7 -1
  320. data/test/ral/type/zone.rb +0 -0
  321. data/test/test +0 -0
  322. data/test/util/autoload.rb +0 -0
  323. data/test/util/classgen.rb +0 -0
  324. data/test/util/execution.rb +0 -0
  325. data/test/util/features.rb +0 -0
  326. data/test/util/fileparsing.rb +0 -0
  327. data/test/util/filetype.rb +0 -0
  328. data/test/util/inifile.rb +0 -0
  329. data/test/util/instance_loader.rb +0 -0
  330. data/test/util/log.rb +0 -59
  331. data/test/util/metrics.rb +0 -0
  332. data/test/util/package.rb +0 -0
  333. data/test/util/pidlock.rb +0 -0
  334. data/test/util/settings.rb +0 -0
  335. data/test/util/storage.rb +0 -0
  336. data/test/util/subclass_loader.rb +0 -0
  337. data/test/util/utiltest.rb +0 -0
  338. metadata +54 -19
  339. data/lib/puppet/metatype/attributes.rb +0 -685
  340. data/lib/puppet/metatype/closure.rb +0 -49
  341. data/lib/puppet/metatype/container.rb +0 -50
  342. data/lib/puppet/metatype/evaluation.rb +0 -163
  343. data/lib/puppet/metatype/instances.rb +0 -305
  344. data/lib/puppet/metatype/metaparams.rb +0 -423
  345. data/lib/puppet/metatype/providers.rb +0 -247
  346. data/lib/puppet/metatype/relationships.rb +0 -115
  347. data/lib/puppet/metatype/schedules.rb +0 -33
  348. data/lib/puppet/metatype/tags.rb +0 -38
  349. data/lib/puppet/util/plist.rb +0 -23
  350. data/lib/puppet/util/plist/generator.rb +0 -225
  351. data/lib/puppet/util/plist/parser.rb +0 -226
  352. data/test/ral/providers/package/apt.rb +0 -169
  353. data/test/ral/providers/package/dpkg.rb +0 -64
  354. data/test/util/posixtest.rb +0 -169
@@ -1,423 +0,0 @@
1
- require 'puppet'
2
- require 'puppet/type'
3
-
4
- class Puppet::Type
5
- # Add all of the meta parameters.
6
- #newmetaparam(:onerror) do
7
- # desc "How to handle errors -- roll back innermost
8
- # transaction, roll back entire transaction, ignore, etc. Currently
9
- # non-functional."
10
- #end
11
-
12
- newmetaparam(:noop) do
13
- desc "Boolean flag indicating whether work should actually
14
- be done."
15
-
16
- newvalues(:true, :false)
17
- munge do |value|
18
- case value
19
- when true, :true, "true": @resource.noop = true
20
- when false, :false, "false": @resource.noop = false
21
- end
22
- end
23
- end
24
-
25
- newmetaparam(:schedule) do
26
- desc "On what schedule the object should be managed. You must create a
27
- schedule object, and then reference the name of that object to use
28
- that for your schedule::
29
-
30
- schedule { daily:
31
- period => daily,
32
- range => \"2-4\"
33
- }
34
-
35
- exec { \"/usr/bin/apt-get update\":
36
- schedule => daily
37
- }
38
-
39
- The creation of the schedule object does not need to appear in the
40
- configuration before objects that use it."
41
- end
42
-
43
- newmetaparam(:check) do
44
- desc "Propertys which should have their values retrieved
45
- but which should not actually be modified. This is currently used
46
- internally, but will eventually be used for querying, so that you
47
- could specify that you wanted to check the install state of all
48
- packages, and then query the Puppet client daemon to get reports
49
- on all packages."
50
-
51
- munge do |args|
52
- # If they've specified all, collect all known properties
53
- if args == :all
54
- args = @resource.class.properties.find_all do |property|
55
- # Only get properties supported by our provider
56
- if @resource.provider
57
- @resource.provider.class.supports_parameter?(property)
58
- else
59
- true
60
- end
61
- end.collect do |property|
62
- property.name
63
- end
64
- end
65
-
66
- unless args.is_a?(Array)
67
- args = [args]
68
- end
69
-
70
- unless defined? @resource
71
- self.devfail "No parent for %s, %s?" %
72
- [self.class, self.name]
73
- end
74
-
75
- args.each { |property|
76
- unless property.is_a?(Symbol)
77
- property = property.intern
78
- end
79
- next if @resource.propertydefined?(property)
80
-
81
- unless propertyklass = @resource.class.validproperty?(property)
82
- if @resource.class.validattr?(property)
83
- next
84
- else
85
- raise Puppet::Error, "%s is not a valid attribute for %s" %
86
- [property, self.class.name]
87
- end
88
- end
89
- next unless propertyklass.checkable?
90
- @resource.newattr(property)
91
- }
92
- end
93
- end
94
-
95
- # We've got four relationship metaparameters, so this method is used
96
- # to reduce code duplication between them.
97
- def munge_relationship(param, values)
98
- # We need to support values passed in as an array or as a
99
- # resource reference.
100
- result = []
101
-
102
- # 'values' could be an array or a reference. If it's an array,
103
- # it could be an array of references or an array of arrays.
104
- if values.is_a?(Puppet::Type)
105
- result << [values.class.name, values.title]
106
- else
107
- unless values.is_a?(Array)
108
- devfail "Relationships must be resource references"
109
- end
110
- if values[0].is_a?(String) or values[0].is_a?(Symbol)
111
- # we're a type/title array reference
112
- values[0] = symbolize(values[0])
113
- result << values
114
- else
115
- # we're an array of stuff
116
- values.each do |value|
117
- if value.is_a?(Puppet::Type)
118
- result << [value.class.name, value.title]
119
- elsif value.is_a?(Array)
120
- value[0] = symbolize(value[0])
121
- result << value
122
- else
123
- devfail "Invalid relationship %s" % value.inspect
124
- end
125
- end
126
- end
127
- end
128
-
129
- if existing = self[param]
130
- result = existing + result
131
- end
132
-
133
- result
134
- end
135
-
136
- newmetaparam(:loglevel) do
137
- desc "Sets the level that information will be logged.
138
- The log levels have the biggest impact when logs are sent to
139
- syslog (which is currently the default)."
140
- defaultto :notice
141
-
142
- newvalues(*Puppet::Util::Log.levels)
143
- newvalues(:verbose)
144
-
145
- munge do |loglevel|
146
- val = super(loglevel)
147
- if val == :verbose
148
- val = :info
149
- end
150
- val
151
- end
152
- end
153
-
154
- newmetaparam(:alias) do
155
- desc "Creates an alias for the object. Puppet uses this internally when you
156
- provide a symbolic name::
157
-
158
- file { sshdconfig:
159
- path => $operatingsystem ? {
160
- solaris => \"/usr/local/etc/ssh/sshd_config\",
161
- default => \"/etc/ssh/sshd_config\"
162
- },
163
- source => \"...\"
164
- }
165
-
166
- service { sshd:
167
- subscribe => file[sshdconfig]
168
- }
169
-
170
- When you use this feature, the parser sets ``sshdconfig`` as the name,
171
- and the library sets that as an alias for the file so the dependency
172
- lookup for ``sshd`` works. You can use this parameter yourself,
173
- but note that only the library can use these aliases; for instance,
174
- the following code will not work::
175
-
176
- file { \"/etc/ssh/sshd_config\":
177
- owner => root,
178
- group => root,
179
- alias => sshdconfig
180
- }
181
-
182
- file { sshdconfig:
183
- mode => 644
184
- }
185
-
186
- There's no way here for the Puppet parser to know that these two stanzas
187
- should be affecting the same file.
188
-
189
- See the `LanguageTutorial language tutorial`:trac: for more information.
190
-
191
- "
192
-
193
- munge do |aliases|
194
- unless aliases.is_a?(Array)
195
- aliases = [aliases]
196
- end
197
-
198
- raise(ArgumentError, "Cannot add aliases without a catalog") unless @resource.catalog
199
-
200
- @resource.info "Adding aliases %s" % aliases.collect { |a| a.inspect }.join(", ")
201
-
202
- aliases.each do |other|
203
- if obj = @resource.catalog.resource(@resource.class.name, other)
204
- unless obj.object_id == @resource.object_id
205
- self.fail("%s can not create alias %s: object already exists" % [@resource.title, other])
206
- end
207
- next
208
- end
209
-
210
- # LAK:FIXME Old-school, add the alias to the class.
211
- @resource.class.alias(other, @resource)
212
-
213
- # Newschool, add it to the catalog.
214
- @resource.catalog.alias(@resource, other)
215
- end
216
- end
217
- end
218
-
219
- newmetaparam(:tag) do
220
- desc "Add the specified tags to the associated resource. While all resources
221
- are automatically tagged with as much information as possible
222
- (e.g., each class and definition containing the resource), it can
223
- be useful to add your own tags to a given resource.
224
-
225
- Tags are currently useful for things like applying a subset of a
226
- host's configuration::
227
-
228
- puppetd --test --tags mytag
229
-
230
- This way, when you're testing a configuration you can run just the
231
- portion you're testing."
232
-
233
- munge do |tags|
234
- tags = [tags] unless tags.is_a? Array
235
-
236
- tags.each do |tag|
237
- @resource.tag(tag)
238
- end
239
- end
240
- end
241
-
242
- class RelationshipMetaparam < Puppet::Parameter
243
- class << self
244
- attr_accessor :direction, :events, :callback, :subclasses
245
- end
246
-
247
- @subclasses = []
248
-
249
- def self.inherited(sub)
250
- @subclasses << sub
251
- end
252
-
253
- def munge(rels)
254
- @resource.munge_relationship(self.class.name, rels)
255
- end
256
-
257
- def validate_relationship
258
- @value.each do |value|
259
- unless @resource.catalog.resource(*value)
260
- description = self.class.direction == :in ? "dependency" : "dependent"
261
- fail Puppet::Error, "Could not find #{description} %s[%s] for %s" % [value[0].to_s.capitalize, value[1], resource.ref]
262
- end
263
- end
264
- end
265
-
266
- # Create edges from each of our relationships. :in
267
- # relationships are specified by the event-receivers, and :out
268
- # relationships are specified by the event generator. This
269
- # way 'source' and 'target' are consistent terms in both edges
270
- # and events -- that is, an event targets edges whose source matches
271
- # the event's source. The direction of the relationship determines
272
- # which resource is applied first and which resource is considered
273
- # to be the event generator.
274
- def to_edges
275
- @value.collect do |value|
276
- # we just have a name and a type, and we need to convert it
277
- # to an object...
278
- tname, name = value
279
- reference = Puppet::ResourceReference.new(tname, name)
280
-
281
- # Either of the two retrieval attempts could have returned
282
- # nil.
283
- unless object = reference.resolve
284
- self.fail "Could not retrieve dependency '%s' of %s" % [reference, @resource.ref]
285
- end
286
-
287
- # Are we requiring them, or vice versa? See the method docs
288
- # for futher info on this.
289
- if self.class.direction == :in
290
- source = object
291
- target = @resource
292
- else
293
- source = @resource
294
- target = object
295
- end
296
-
297
- if method = self.class.callback
298
- subargs = {
299
- :event => self.class.events,
300
- :callback => method
301
- }
302
- self.debug("subscribes to %s" % [object.ref])
303
- else
304
- # If there's no callback, there's no point in even adding
305
- # a label.
306
- subargs = nil
307
- self.debug("requires %s" % [object.ref])
308
- end
309
-
310
- rel = Puppet::Relationship.new(source, target, subargs)
311
- end
312
- end
313
- end
314
-
315
- def self.relationship_params
316
- RelationshipMetaparam.subclasses
317
- end
318
-
319
-
320
- # Note that the order in which the relationships params is defined
321
- # matters. The labelled params (notify and subcribe) must be later,
322
- # so that if both params are used, those ones win. It's a hackish
323
- # solution, but it works.
324
-
325
- newmetaparam(:require, :parent => RelationshipMetaparam, :attributes => {:direction => :in, :events => :NONE}) do
326
- desc "One or more objects that this object depends on.
327
- This is used purely for guaranteeing that changes to required objects
328
- happen before the dependent object. For instance::
329
-
330
- # Create the destination directory before you copy things down
331
- file { \"/usr/local/scripts\":
332
- ensure => directory
333
- }
334
-
335
- file { \"/usr/local/scripts/myscript\":
336
- source => \"puppet://server/module/myscript\",
337
- mode => 755,
338
- require => File[\"/usr/local/scripts\"]
339
- }
340
-
341
- Multiple dependencies can be specified by providing a comma-seperated list
342
- of resources, enclosed in square brackets::
343
-
344
- require => [ File[\"/usr/local\"], File[\"/usr/local/scripts\"] ]
345
-
346
- Note that Puppet will autorequire everything that it can, and
347
- there are hooks in place so that it's easy for resources to add new
348
- ways to autorequire objects, so if you think Puppet could be
349
- smarter here, let us know.
350
-
351
- In fact, the above code was redundant -- Puppet will autorequire
352
- any parent directories that are being managed; it will
353
- automatically realize that the parent directory should be created
354
- before the script is pulled down.
355
-
356
- Currently, exec resources will autorequire their CWD (if it is
357
- specified) plus any fully qualified paths that appear in the
358
- command. For instance, if you had an ``exec`` command that ran
359
- the ``myscript`` mentioned above, the above code that pulls the
360
- file down would be automatically listed as a requirement to the
361
- ``exec`` code, so that you would always be running againts the
362
- most recent version.
363
- "
364
- end
365
-
366
- newmetaparam(:subscribe, :parent => RelationshipMetaparam, :attributes => {:direction => :in, :events => :ALL_EVENTS, :callback => :refresh}) do
367
- desc "One or more objects that this object depends on. Changes in the
368
- subscribed to objects result in the dependent objects being
369
- refreshed (e.g., a service will get restarted). For instance::
370
-
371
- class nagios {
372
- file { \"/etc/nagios/nagios.conf\":
373
- source => \"puppet://server/module/nagios.conf\",
374
- alias => nagconf # just to make things easier for me
375
- }
376
- service { nagios:
377
- running => true,
378
- subscribe => File[nagconf]
379
- }
380
- }
381
-
382
- Currently the ``exec``, ``mount`` and ``service`` type support
383
- refreshing.
384
- "
385
- end
386
-
387
- newmetaparam(:before, :parent => RelationshipMetaparam, :attributes => {:direction => :out, :events => :NONE}) do
388
- desc %{This parameter is the opposite of **require** -- it guarantees
389
- that the specified object is applied later than the specifying
390
- object::
391
-
392
- file { "/var/nagios/configuration":
393
- source => "...",
394
- recurse => true,
395
- before => Exec["nagios-rebuid"]
396
- }
397
-
398
- exec { "nagios-rebuild":
399
- command => "/usr/bin/make",
400
- cwd => "/var/nagios/configuration"
401
- }
402
-
403
- This will make sure all of the files are up to date before the
404
- make command is run.}
405
- end
406
-
407
- newmetaparam(:notify, :parent => RelationshipMetaparam, :attributes => {:direction => :out, :events => :ALL_EVENTS, :callback => :refresh}) do
408
- desc %{This parameter is the opposite of **subscribe** -- it sends events
409
- to the specified object::
410
-
411
- file { "/etc/sshd_config":
412
- source => "....",
413
- notify => Service[sshd]
414
- }
415
-
416
- service { sshd:
417
- ensure => running
418
- }
419
-
420
- This will restart the sshd service if the sshd config file changes.}
421
- end
422
- end # Puppet::Type
423
-
@@ -1,247 +0,0 @@
1
- require 'puppet/provider'
2
- require 'puppet/util/provider_features'
3
- class Puppet::Type
4
- # Add the feature handling module.
5
- extend Puppet::Util::ProviderFeatures
6
-
7
- attr_reader :provider
8
-
9
- # the Type class attribute accessors
10
- class << self
11
- attr_accessor :providerloader
12
- attr_writer :defaultprovider
13
- end
14
-
15
- # Find the default provider.
16
- def self.defaultprovider
17
- unless defined? @defaultprovider and @defaultprovider
18
- suitable = suitableprovider()
19
-
20
- # Find which providers are a default for this system.
21
- defaults = suitable.find_all { |provider| provider.default? }
22
-
23
- # If we don't have any default we use suitable providers
24
- defaults = suitable if defaults.empty?
25
- max = defaults.collect { |provider| provider.defaultnum }.max
26
- defaults = defaults.find_all { |provider| provider.defaultnum == max }
27
-
28
- retval = nil
29
- if defaults.length > 1
30
- Puppet.warning(
31
- "Found multiple default providers for %s: %s; using %s" %
32
- [self.name, defaults.collect { |i| i.name.to_s }.join(", "),
33
- defaults[0].name]
34
- )
35
- retval = defaults.shift
36
- elsif defaults.length == 1
37
- retval = defaults.shift
38
- else
39
- raise Puppet::DevError, "Could not find a default provider for %s" %
40
- self.name
41
- end
42
-
43
- @defaultprovider = retval
44
- end
45
-
46
- return @defaultprovider
47
- end
48
-
49
- # Convert a hash, as provided by, um, a provider, into an instance of self.
50
- def self.hash2obj(hash)
51
- obj = nil
52
-
53
- namevar = self.namevar
54
- unless hash.include?(namevar) and hash[namevar]
55
- raise Puppet::DevError, "Hash was not passed with namevar"
56
- end
57
-
58
- # if the obj already exists with that name...
59
- if obj = self[hash[namevar]]
60
- # We're assuming here that objects with the same name
61
- # are the same object, which *should* be the case, assuming
62
- # we've set up our naming stuff correctly everywhere.
63
-
64
- # Mark found objects as present
65
- hash.each { |param, value|
66
- if property = obj.property(param)
67
- elsif val = obj[param]
68
- obj[param] = val
69
- else
70
- # There is a value on disk, but it should go away
71
- obj[param] = :absent
72
- end
73
- }
74
- else
75
- # create a new obj, since no existing one seems to
76
- # match
77
- obj = self.create(namevar => hash[namevar])
78
-
79
- # We can't just pass the hash in at object creation time,
80
- # because it sets the should value, not the is value.
81
- hash.delete(namevar)
82
- hash.each { |param, value|
83
- obj[param] = value unless obj.add_property_parameter(param)
84
- }
85
- end
86
-
87
- return obj
88
- end
89
-
90
- # Retrieve a provider by name.
91
- def self.provider(name)
92
- name = Puppet::Util.symbolize(name)
93
-
94
- # If we don't have it yet, try loading it.
95
- unless @providers.has_key?(name)
96
- @providerloader.load(name)
97
- end
98
- return @providers[name]
99
- end
100
-
101
- # Just list all of the providers.
102
- def self.providers
103
- @providers.keys
104
- end
105
-
106
- def self.validprovider?(name)
107
- name = Puppet::Util.symbolize(name)
108
-
109
- return (@providers.has_key?(name) && @providers[name].suitable?)
110
- end
111
-
112
- # Create a new provider of a type. This method must be called
113
- # directly on the type that it's implementing.
114
- def self.provide(name, options = {}, &block)
115
- name = Puppet::Util.symbolize(name)
116
-
117
- if obj = @providers[name]
118
- Puppet.debug "Reloading %s %s provider" % [name, self.name]
119
- unprovide(name)
120
- end
121
-
122
- parent = if pname = options[:parent]
123
- options.delete(:parent)
124
- if pname.is_a? Class
125
- pname
126
- else
127
- if provider = self.provider(pname)
128
- provider
129
- else
130
- raise Puppet::DevError,
131
- "Could not find parent provider %s of %s" %
132
- [pname, name]
133
- end
134
- end
135
- else
136
- Puppet::Provider
137
- end
138
-
139
- options[:resource_type] ||= self
140
-
141
- self.providify
142
-
143
- provider = genclass(name,
144
- :parent => parent,
145
- :hash => @providers,
146
- :prefix => "Provider",
147
- :block => block,
148
- :include => feature_module,
149
- :extend => feature_module,
150
- :attributes => options
151
- )
152
-
153
- return provider
154
- end
155
-
156
- # Make sure we have a :provider parameter defined. Only gets called if there
157
- # are providers.
158
- def self.providify
159
- return if @paramhash.has_key? :provider
160
-
161
- newparam(:provider) do
162
- desc "The specific backend for #{self.name.to_s} to use. You will
163
- seldom need to specify this -- Puppet will usually discover the
164
- appropriate provider for your platform."
165
-
166
- # This is so we can refer back to the type to get a list of
167
- # providers for documentation.
168
- class << self
169
- attr_accessor :parenttype
170
- end
171
-
172
- # We need to add documentation for each provider.
173
- def self.doc
174
- @doc + " Available providers are:\n\n" + parenttype().providers.sort { |a,b|
175
- a.to_s <=> b.to_s
176
- }.collect { |i|
177
- "* **%s**: %s" % [i, parenttype().provider(i).doc]
178
- }.join("\n")
179
- end
180
-
181
- defaultto {
182
- @resource.class.defaultprovider.name
183
- }
184
-
185
- validate do |provider_class|
186
- provider_class = provider_class[0] if provider_class.is_a? Array
187
- if provider_class.is_a?(Puppet::Provider)
188
- provider_class = provider_class.class.name
189
- end
190
-
191
- unless provider = @resource.class.provider(provider_class)
192
- raise ArgumentError, "Invalid %s provider '%s'" % [@resource.class.name, provider_class]
193
- end
194
- end
195
-
196
- munge do |provider|
197
- provider = provider[0] if provider.is_a? Array
198
- if provider.is_a? String
199
- provider = provider.intern
200
- end
201
- @resource.provider = provider
202
-
203
- if provider.is_a?(Puppet::Provider)
204
- provider.class.name
205
- else
206
- provider
207
- end
208
- end
209
- end.parenttype = self
210
- end
211
-
212
- def self.unprovide(name)
213
- if @providers.has_key? name
214
- rmclass(name,
215
- :hash => @providers,
216
- :prefix => "Provider"
217
- )
218
- if @defaultprovider and @defaultprovider.name == name
219
- @defaultprovider = nil
220
- end
221
- end
222
- end
223
-
224
- # Return an array of all of the suitable providers.
225
- def self.suitableprovider
226
- if @providers.empty?
227
- providerloader.loadall
228
- end
229
- @providers.find_all { |name, provider|
230
- provider.suitable?
231
- }.collect { |name, provider|
232
- provider
233
- }.reject { |p| p.name == :fake } # For testing
234
- end
235
-
236
- def provider=(name)
237
- if name.is_a?(Puppet::Provider)
238
- @provider = name
239
- @provider.resource = self
240
- elsif klass = self.class.provider(name)
241
- @provider = klass.new(self)
242
- else
243
- raise ArgumentError, "Could not find %s provider of %s" %
244
- [name, self.class.name]
245
- end
246
- end
247
- end