puppet 0.23.2 → 0.24.0

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 (629) hide show
  1. data/CHANGELOG +112 -1
  2. data/README +1 -1
  3. data/Rakefile +1 -2
  4. data/bin/filebucket +2 -3
  5. data/bin/puppet +55 -39
  6. data/bin/puppetca +20 -11
  7. data/bin/puppetd +30 -31
  8. data/bin/puppetdoc +27 -28
  9. data/bin/puppetmasterd +24 -42
  10. data/bin/puppetrun +3 -4
  11. data/bin/ralsh +5 -7
  12. data/conf/redhat/puppet.spec +4 -1
  13. data/conf/solaris/smf/svc-puppetd +1 -1
  14. data/conf/solaris/smf/svc-puppetmasterd +1 -1
  15. data/examples/code/allatonce +1 -1
  16. data/examples/code/assignments +1 -1
  17. data/examples/code/components +1 -1
  18. data/examples/code/file.bl +1 -1
  19. data/examples/code/filedefaults +1 -1
  20. data/examples/code/fileparsing +1 -1
  21. data/examples/code/filerecursion +1 -1
  22. data/examples/code/functions +1 -1
  23. data/examples/code/groups +1 -1
  24. data/examples/code/head +1 -1
  25. data/examples/code/importing +1 -1
  26. data/examples/code/modules/sample-module.pp +10 -0
  27. data/examples/code/modules/sample-module/README.txt +17 -0
  28. data/examples/code/modules/sample-module/lib/puppet/parser/functions/hostname_to_dn.rb +36 -0
  29. data/examples/code/modules/sample-module/manifests/init.pp +12 -0
  30. data/examples/code/modules/sample-module/templates/sample.erb +5 -0
  31. data/examples/code/nodes +1 -1
  32. data/examples/code/one +1 -1
  33. data/examples/code/relationships +1 -1
  34. data/examples/code/selectors +1 -1
  35. data/examples/code/simpletests +1 -1
  36. data/examples/root/etc/init.d/sleeper +1 -1
  37. data/examples/root/etc/puppet/fileserver.conf +1 -1
  38. data/ext/ldap/puppet.schema +1 -1
  39. data/ext/module_puppet +30 -21
  40. data/ext/puppet-test +3 -3
  41. data/ext/vim/filetype.vim +1 -1
  42. data/install.rb +1 -2
  43. data/lib/puppet.rb +20 -19
  44. data/lib/puppet/checksum.rb +57 -0
  45. data/lib/puppet/config_stores/rest.rb +1 -1
  46. data/lib/puppet/daemon.rb +0 -1
  47. data/lib/puppet/{configuration.rb → defaults.rb} +56 -23
  48. data/lib/puppet/dsl.rb +22 -116
  49. data/lib/puppet/error.rb +0 -9
  50. data/lib/puppet/event.rb +0 -1
  51. data/lib/puppet/external/gratr/rdot.rb +0 -1
  52. data/lib/puppet/external/lock.rb +0 -1
  53. data/lib/puppet/feature/base.rb +3 -2
  54. data/lib/puppet/feature/rails.rb +0 -1
  55. data/lib/puppet/file_serving.rb +7 -0
  56. data/lib/puppet/file_serving/configuration.rb +129 -0
  57. data/lib/puppet/file_serving/configuration/parser.rb +124 -0
  58. data/lib/puppet/file_serving/content.rb +34 -0
  59. data/lib/puppet/file_serving/file_base.rb +63 -0
  60. data/lib/puppet/file_serving/fileset.rb +138 -0
  61. data/lib/puppet/file_serving/indirection_hooks.rb +44 -0
  62. data/lib/puppet/file_serving/metadata.rb +69 -0
  63. data/lib/puppet/file_serving/mount.rb +186 -0
  64. data/lib/puppet/file_serving/terminus_helper.rb +19 -0
  65. data/lib/puppet/indirector.rb +68 -0
  66. data/lib/puppet/indirector/catalog/compiler.rb +173 -0
  67. data/lib/puppet/indirector/catalog/yaml.rb +24 -0
  68. data/lib/puppet/indirector/checksum/file.rb +33 -0
  69. data/lib/puppet/indirector/code.rb +6 -0
  70. data/lib/puppet/indirector/direct_file_server.rb +27 -0
  71. data/lib/puppet/indirector/exec.rb +57 -0
  72. data/lib/puppet/indirector/facts/facter.rb +65 -0
  73. data/lib/puppet/indirector/facts/memory.rb +9 -0
  74. data/lib/puppet/indirector/facts/yaml.rb +7 -0
  75. data/lib/puppet/indirector/file.rb +54 -0
  76. data/lib/puppet/indirector/file_content.rb +5 -0
  77. data/lib/puppet/indirector/file_content/file.rb +11 -0
  78. data/lib/puppet/indirector/file_content/file_server.rb +11 -0
  79. data/lib/puppet/indirector/file_content/modules.rb +11 -0
  80. data/lib/puppet/indirector/file_content/rest.rb +12 -0
  81. data/lib/puppet/indirector/file_metadata.rb +5 -0
  82. data/lib/puppet/indirector/file_metadata/file.rb +26 -0
  83. data/lib/puppet/indirector/file_metadata/file_server.rb +11 -0
  84. data/lib/puppet/indirector/file_metadata/modules.rb +17 -0
  85. data/lib/puppet/indirector/file_metadata/rest.rb +12 -0
  86. data/lib/puppet/indirector/file_server.rb +56 -0
  87. data/lib/puppet/indirector/indirection.rb +237 -0
  88. data/lib/puppet/indirector/ldap.rb +90 -0
  89. data/lib/puppet/indirector/memory.rb +21 -0
  90. data/lib/puppet/indirector/module_files.rb +82 -0
  91. data/lib/puppet/indirector/node/exec.rb +52 -0
  92. data/lib/puppet/indirector/node/ldap.rb +120 -0
  93. data/lib/puppet/indirector/node/memory.rb +10 -0
  94. data/lib/puppet/indirector/node/plain.rb +19 -0
  95. data/lib/puppet/indirector/node/rest.rb +7 -0
  96. data/lib/puppet/indirector/node/yaml.rb +7 -0
  97. data/lib/puppet/indirector/plain.rb +9 -0
  98. data/lib/puppet/indirector/report/processor.rb +50 -0
  99. data/lib/puppet/indirector/rest.rb +8 -0
  100. data/lib/puppet/indirector/ssl_rsa.rb +5 -0
  101. data/lib/puppet/indirector/ssl_rsa/file.rb +33 -0
  102. data/lib/puppet/indirector/terminus.rb +178 -0
  103. data/lib/puppet/indirector/yaml.rb +57 -0
  104. data/lib/puppet/metatype/attributes.rb +3 -3
  105. data/lib/puppet/metatype/closure.rb +0 -66
  106. data/lib/puppet/metatype/container.rb +0 -9
  107. data/lib/puppet/metatype/evaluation.rb +10 -2
  108. data/lib/puppet/metatype/instances.rb +16 -30
  109. data/lib/puppet/metatype/manager.rb +1 -2
  110. data/lib/puppet/metatype/metaparams.rb +27 -21
  111. data/lib/puppet/metatype/providers.rb +3 -2
  112. data/lib/puppet/metatype/relationships.rb +1 -2
  113. data/lib/puppet/metatype/schedules.rb +0 -1
  114. data/lib/puppet/metatype/tags.rb +0 -1
  115. data/lib/puppet/module.rb +60 -32
  116. data/lib/puppet/network/authconfig.rb +0 -1
  117. data/lib/puppet/network/authorization.rb +0 -1
  118. data/lib/puppet/network/authstore.rb +0 -1
  119. data/lib/puppet/network/client.rb +13 -4
  120. data/lib/puppet/network/client/ca.rb +4 -5
  121. data/lib/puppet/network/client/dipper.rb +0 -1
  122. data/lib/puppet/network/client/file.rb +0 -1
  123. data/lib/puppet/network/client/master.rb +127 -235
  124. data/lib/puppet/network/client/proxy.rb +0 -1
  125. data/lib/puppet/network/client/report.rb +0 -1
  126. data/lib/puppet/network/client/resource.rb +0 -1
  127. data/lib/puppet/network/client/runner.rb +0 -1
  128. data/lib/puppet/network/client/status.rb +0 -1
  129. data/lib/puppet/network/client_request.rb +0 -1
  130. data/lib/puppet/network/handler.rb +5 -2
  131. data/lib/puppet/network/handler/ca.rb +1 -2
  132. data/lib/puppet/network/handler/configuration.rb +184 -0
  133. data/lib/puppet/network/handler/filebucket.rb +1 -2
  134. data/lib/puppet/network/handler/fileserver.rb +279 -107
  135. data/lib/puppet/network/handler/master.rb +57 -152
  136. data/lib/puppet/network/handler/report.rb +6 -65
  137. data/lib/puppet/network/handler/resource.rb +5 -13
  138. data/lib/puppet/network/handler/runner.rb +3 -4
  139. data/lib/puppet/network/handler/status.rb +0 -1
  140. data/lib/puppet/network/http.rb +13 -0
  141. data/lib/puppet/network/http/handler.rb +109 -0
  142. data/lib/puppet/network/http/mongrel.rb +54 -0
  143. data/lib/puppet/network/http/mongrel/rest.rb +37 -0
  144. data/lib/puppet/network/http/mongrel/xmlrpc.rb +4 -0
  145. data/lib/puppet/network/http/webrick.rb +51 -0
  146. data/lib/puppet/network/http/webrick/rest.rb +41 -0
  147. data/lib/puppet/network/http/webrick/xmlrpc.rb +4 -0
  148. data/lib/puppet/network/http_server.rb +3 -0
  149. data/lib/puppet/network/{server → http_server}/mongrel.rb +11 -5
  150. data/lib/puppet/network/{server → http_server}/webrick.rb +9 -5
  151. data/lib/puppet/network/rest_controller.rb +2 -0
  152. data/lib/puppet/network/rights.rb +0 -1
  153. data/lib/puppet/network/server.rb +63 -3
  154. data/lib/puppet/network/xmlrpc/client.rb +90 -23
  155. data/lib/puppet/network/xmlrpc/processor.rb +0 -1
  156. data/lib/puppet/network/xmlrpc/server.rb +0 -1
  157. data/lib/puppet/network/xmlrpc/webrick_servlet.rb +0 -1
  158. data/lib/puppet/node.rb +165 -0
  159. data/lib/puppet/node/catalog.rb +480 -0
  160. data/lib/puppet/node/environment.rb +46 -0
  161. data/lib/puppet/node/facts.rb +36 -0
  162. data/lib/puppet/parameter.rb +34 -28
  163. data/lib/puppet/parser/ast.rb +0 -1
  164. data/lib/puppet/parser/ast/astarray.rb +30 -53
  165. data/lib/puppet/parser/ast/branch.rb +0 -10
  166. data/lib/puppet/parser/ast/caseopt.rb +0 -11
  167. data/lib/puppet/parser/ast/casestatement.rb +0 -12
  168. data/lib/puppet/parser/ast/collection.rb +1 -3
  169. data/lib/puppet/parser/ast/collexpr.rb +0 -2
  170. data/lib/puppet/parser/ast/{component.rb → definition.rb} +58 -72
  171. data/lib/puppet/parser/ast/else.rb +0 -10
  172. data/lib/puppet/parser/ast/function.rb +0 -2
  173. data/lib/puppet/parser/ast/hostclass.rb +21 -19
  174. data/lib/puppet/parser/ast/ifstatement.rb +0 -13
  175. data/lib/puppet/parser/ast/leaf.rb +0 -8
  176. data/lib/puppet/parser/ast/node.rb +13 -10
  177. data/lib/puppet/parser/ast/resource.rb +75 -0
  178. data/lib/puppet/parser/ast/{resourcedefaults.rb → resource_defaults.rb} +4 -20
  179. data/lib/puppet/parser/ast/{resourceoverride.rb → resource_override.rb} +3 -5
  180. data/lib/puppet/parser/ast/resource_reference.rb +66 -0
  181. data/lib/puppet/parser/ast/resourceparam.rb +0 -14
  182. data/lib/puppet/parser/ast/selector.rb +0 -10
  183. data/lib/puppet/parser/ast/tag.rb +0 -2
  184. data/lib/puppet/parser/ast/vardef.rb +0 -14
  185. data/lib/puppet/parser/collector.rb +83 -101
  186. data/lib/puppet/parser/compile.rb +509 -0
  187. data/lib/puppet/parser/functions.rb +10 -10
  188. data/lib/puppet/parser/interpreter.rb +44 -662
  189. data/lib/puppet/parser/lexer.rb +1 -3
  190. data/lib/puppet/parser/parser.rb +674 -701
  191. data/lib/puppet/parser/parser_support.rb +33 -24
  192. data/lib/puppet/parser/resource.rb +219 -162
  193. data/lib/puppet/parser/resource/param.rb +1 -2
  194. data/lib/puppet/parser/resource/reference.rb +24 -16
  195. data/lib/puppet/parser/scope.rb +48 -459
  196. data/lib/puppet/parser/templatewrapper.rb +4 -5
  197. data/lib/puppet/pgraph.rb +10 -13
  198. data/lib/puppet/property.rb +25 -41
  199. data/lib/puppet/propertychange.rb +0 -2
  200. data/lib/puppet/provider.rb +15 -11
  201. data/lib/puppet/provider/cron/crontab.rb +6 -7
  202. data/lib/puppet/provider/group/groupadd.rb +0 -1
  203. data/lib/puppet/provider/group/netinfo.rb +0 -1
  204. data/lib/puppet/provider/group/pw.rb +0 -1
  205. data/lib/puppet/provider/host/netinfo.rb +0 -1
  206. data/lib/puppet/provider/host/parsed.rb +0 -1
  207. data/lib/puppet/provider/interface/redhat.rb +90 -91
  208. data/lib/puppet/provider/interface/sunos.rb +98 -81
  209. data/lib/puppet/provider/mailalias/aliases.rb +0 -1
  210. data/lib/puppet/provider/maillist/mailman.rb +2 -3
  211. data/lib/puppet/provider/mount.rb +10 -9
  212. data/lib/puppet/provider/mount/netinfo.rb +0 -1
  213. data/lib/puppet/provider/mount/parsed.rb +0 -1
  214. data/lib/puppet/provider/nameservice.rb +0 -1
  215. data/lib/puppet/provider/nameservice/netinfo.rb +0 -1
  216. data/lib/puppet/provider/nameservice/objectadd.rb +0 -1
  217. data/lib/puppet/provider/nameservice/pw.rb +0 -1
  218. data/lib/puppet/provider/package.rb +0 -2
  219. data/lib/puppet/provider/package/appdmg.rb +0 -1
  220. data/lib/puppet/provider/package/apple.rb +0 -1
  221. data/lib/puppet/provider/package/apt.rb +0 -1
  222. data/lib/puppet/provider/package/aptitude.rb +0 -1
  223. data/lib/puppet/provider/package/aptrpm.rb +0 -1
  224. data/lib/puppet/provider/package/blastwave.rb +0 -1
  225. data/lib/puppet/provider/package/darwinport.rb +0 -1
  226. data/lib/puppet/provider/package/dpkg.rb +9 -1
  227. data/lib/puppet/provider/package/fink.rb +0 -1
  228. data/lib/puppet/provider/package/freebsd.rb +0 -1
  229. data/lib/puppet/provider/package/gem.rb +0 -1
  230. data/lib/puppet/provider/package/openbsd.rb +1 -2
  231. data/lib/puppet/provider/package/pkgdmg.rb +14 -15
  232. data/lib/puppet/provider/package/portage.rb +6 -7
  233. data/lib/puppet/provider/package/ports.rb +1 -4
  234. data/lib/puppet/provider/package/rpm.rb +31 -45
  235. data/lib/puppet/provider/package/sun.rb +0 -3
  236. data/lib/puppet/provider/package/sunfreeware.rb +0 -1
  237. data/lib/puppet/provider/package/up2date.rb +0 -1
  238. data/lib/puppet/provider/package/urpmi.rb +0 -1
  239. data/lib/puppet/provider/package/yum.rb +45 -14
  240. data/lib/puppet/provider/package/yumhelper.py +37 -0
  241. data/lib/puppet/provider/parsedfile.rb +2 -3
  242. data/lib/puppet/provider/port/parsed.rb +0 -1
  243. data/lib/puppet/provider/service/base.rb +4 -1
  244. data/lib/puppet/provider/service/debian.rb +5 -2
  245. data/lib/puppet/provider/service/freebsd.rb +51 -0
  246. data/lib/puppet/provider/service/init.rb +16 -40
  247. data/lib/puppet/provider/service/redhat.rb +1 -6
  248. data/lib/puppet/provider/service/smf.rb +0 -1
  249. data/lib/puppet/provider/sshkey/parsed.rb +0 -1
  250. data/lib/puppet/provider/user/netinfo.rb +0 -1
  251. data/lib/puppet/provider/user/pw.rb +0 -1
  252. data/lib/puppet/provider/user/useradd.rb +0 -1
  253. data/lib/puppet/provider/zone/solaris.rb +0 -1
  254. data/lib/puppet/rails.rb +35 -30
  255. data/lib/puppet/rails/database/schema.rb +0 -1
  256. data/lib/puppet/rails/host.rb +6 -15
  257. data/lib/puppet/rails/param_name.rb +1 -2
  258. data/lib/puppet/rails/param_value.rb +0 -1
  259. data/lib/puppet/rails/puppet_class.rb +0 -1
  260. data/lib/puppet/rails/resource.rb +3 -5
  261. data/lib/puppet/reference/configuration.rb +12 -6
  262. data/lib/puppet/reference/indirection.rb +34 -0
  263. data/lib/puppet/reference/node_source.rb +9 -0
  264. data/lib/puppet/relationship.rb +10 -8
  265. data/lib/puppet/reports.rb +51 -0
  266. data/lib/puppet/reports/log.rb +2 -3
  267. data/lib/puppet/reports/rrdgraph.rb +2 -5
  268. data/lib/puppet/reports/store.rb +6 -7
  269. data/lib/puppet/reports/tagmail.rb +2 -3
  270. data/lib/puppet/resource_reference.rb +79 -0
  271. data/lib/puppet/simple_graph.rb +251 -0
  272. data/lib/puppet/sslcertificates.rb +19 -15
  273. data/lib/puppet/sslcertificates/ca.rb +56 -15
  274. data/lib/puppet/sslcertificates/certificate.rb +0 -1
  275. data/lib/puppet/sslcertificates/inventory.rb +2 -6
  276. data/lib/puppet/sslcertificates/monkey_patch.rb +6 -0
  277. data/lib/puppet/sslcertificates/support.rb +4 -5
  278. data/lib/puppet/transaction.rb +93 -96
  279. data/lib/puppet/transaction/report.rb +5 -1
  280. data/lib/puppet/transportable.rb +79 -125
  281. data/lib/puppet/type.rb +44 -10
  282. data/lib/puppet/type/component.rb +25 -110
  283. data/lib/puppet/type/cron.rb +1 -2
  284. data/lib/puppet/type/exec.rb +19 -13
  285. data/lib/puppet/type/group.rb +0 -1
  286. data/lib/puppet/type/host.rb +0 -1
  287. data/lib/puppet/type/interface.rb +6 -3
  288. data/lib/puppet/type/k5login.rb +87 -0
  289. data/lib/puppet/type/mailalias.rb +0 -1
  290. data/lib/puppet/type/maillist.rb +0 -1
  291. data/lib/puppet/type/mount.rb +7 -13
  292. data/lib/puppet/type/notify.rb +0 -1
  293. data/lib/puppet/type/package.rb +7 -63
  294. data/lib/puppet/type/pfile.rb +25 -32
  295. data/lib/puppet/type/pfile/checksum.rb +0 -1
  296. data/lib/puppet/type/pfile/content.rb +18 -3
  297. data/lib/puppet/type/pfile/ensure.rb +5 -6
  298. data/lib/puppet/type/pfile/group.rb +4 -1
  299. data/lib/puppet/type/pfile/mode.rb +0 -1
  300. data/lib/puppet/type/pfile/owner.rb +6 -9
  301. data/lib/puppet/type/pfile/source.rb +28 -11
  302. data/lib/puppet/type/pfile/target.rb +2 -1
  303. data/lib/puppet/type/pfile/type.rb +0 -1
  304. data/lib/puppet/type/pfilebucket.rb +0 -1
  305. data/lib/puppet/type/port.rb +0 -1
  306. data/lib/puppet/type/resources.rb +0 -1
  307. data/lib/puppet/type/schedule.rb +17 -15
  308. data/lib/puppet/type/service.rb +23 -159
  309. data/lib/puppet/type/sshkey.rb +0 -1
  310. data/lib/puppet/type/tidy.rb +15 -7
  311. data/lib/puppet/type/user.rb +0 -1
  312. data/lib/puppet/type/zone.rb +0 -1
  313. data/lib/puppet/util.rb +1 -2
  314. data/lib/puppet/util/autoload.rb +21 -23
  315. data/lib/puppet/util/checksums.rb +37 -0
  316. data/lib/puppet/util/classgen.rb +0 -1
  317. data/lib/puppet/util/diff.rb +71 -0
  318. data/lib/puppet/util/docs.rb +8 -2
  319. data/lib/puppet/util/errors.rb +0 -1
  320. data/lib/puppet/util/execution.rb +0 -1
  321. data/lib/puppet/util/fact_store.rb +0 -1
  322. data/lib/puppet/util/feature.rb +31 -22
  323. data/lib/puppet/util/fileparsing.rb +3 -2
  324. data/lib/puppet/util/filetype.rb +30 -12
  325. data/lib/puppet/util/graph.rb +0 -1
  326. data/lib/puppet/util/inifile.rb +0 -1
  327. data/lib/puppet/util/instance_loader.rb +11 -4
  328. data/lib/puppet/util/loadedfile.rb +0 -1
  329. data/lib/puppet/util/log.rb +0 -1
  330. data/lib/puppet/util/log_paths.rb +0 -1
  331. data/lib/puppet/util/logging.rb +0 -1
  332. data/lib/puppet/util/metaid.rb +0 -1
  333. data/lib/puppet/util/methodhelper.rb +0 -2
  334. data/lib/puppet/util/metric.rb +1 -2
  335. data/lib/puppet/util/plist.rb +0 -1
  336. data/lib/puppet/util/plist/generator.rb +0 -1
  337. data/lib/puppet/util/plist/parser.rb +0 -1
  338. data/lib/puppet/util/posix.rb +7 -1
  339. data/lib/puppet/util/provider_features.rb +11 -12
  340. data/lib/puppet/util/rails/collection_merger.rb +0 -1
  341. data/lib/puppet/util/reference.rb +2 -3
  342. data/lib/puppet/util/{config.rb → settings.rb} +424 -300
  343. data/lib/puppet/util/storage.rb +1 -3
  344. data/lib/puppet/util/subclass_loader.rb +0 -1
  345. data/lib/puppet/util/suidmanager.rb +25 -42
  346. data/lib/puppet/util/uri_helper.rb +22 -0
  347. data/lib/puppet/util/variables.rb +0 -1
  348. data/lib/puppet/util/warnings.rb +0 -1
  349. data/test/Rakefile +1 -1
  350. data/test/certmgr/ca.rb +8 -2
  351. data/test/certmgr/certmgr.rb +14 -6
  352. data/test/certmgr/inventory.rb +18 -30
  353. data/test/certmgr/support.rb +3 -2
  354. data/test/executables/filebucket.rb +1 -2
  355. data/test/executables/puppetbin.rb +1 -2
  356. data/test/executables/puppetca.rb +7 -2
  357. data/test/executables/puppetd.rb +23 -29
  358. data/test/executables/puppetmasterd.rb +1 -2
  359. data/test/executables/puppetmodule.rb +1 -2
  360. data/test/language/ast.rb +24 -29
  361. data/test/language/ast/casestatement.rb +1 -2
  362. data/test/language/ast/definition.rb +166 -0
  363. data/test/language/ast/hostclass.rb +50 -29
  364. data/test/language/ast/resource.rb +59 -0
  365. data/test/language/ast/{resourceref.rb → resource_reference.rb} +30 -20
  366. data/test/language/ast/selector.rb +1 -2
  367. data/test/language/ast/variable.rb +1 -2
  368. data/test/language/compile.rb +569 -0
  369. data/test/language/functions.rb +57 -76
  370. data/test/language/lexer.rb +20 -3
  371. data/test/language/parser.rb +45 -33
  372. data/test/language/resource.rb +275 -308
  373. data/test/language/scope.rb +135 -410
  374. data/test/language/snippets.rb +19 -41
  375. data/test/language/transportable.rb +8 -29
  376. data/test/lib/mocha/auto_verify.rb +6 -6
  377. data/test/lib/mocha/deprecation.rb +22 -0
  378. data/test/lib/mocha/exception_raiser.rb +17 -0
  379. data/test/lib/mocha/expectation.rb +167 -84
  380. data/test/lib/mocha/infinite_range.rb +4 -6
  381. data/test/lib/mocha/inspect.rb +3 -1
  382. data/test/lib/mocha/is_a.rb +9 -0
  383. data/test/lib/mocha/missing_expectation.rb +27 -0
  384. data/test/lib/mocha/mock.rb +192 -5
  385. data/test/lib/mocha/multiple_yields.rb +20 -0
  386. data/test/lib/mocha/no_yields.rb +11 -0
  387. data/test/lib/mocha/object.rb +11 -1
  388. data/test/lib/mocha/parameter_matchers.rb +9 -0
  389. data/test/lib/mocha/parameter_matchers/all_of.rb +39 -0
  390. data/test/lib/mocha/parameter_matchers/any_of.rb +44 -0
  391. data/test/lib/mocha/parameter_matchers/anything.rb +30 -0
  392. data/test/lib/mocha/parameter_matchers/has_entry.rb +39 -0
  393. data/test/lib/mocha/parameter_matchers/has_key.rb +39 -0
  394. data/test/lib/mocha/parameter_matchers/has_value.rb +39 -0
  395. data/test/lib/mocha/parameter_matchers/includes.rb +37 -0
  396. data/test/lib/mocha/return_values.rb +31 -0
  397. data/test/lib/mocha/single_return_value.rb +24 -0
  398. data/test/lib/mocha/single_yield.rb +18 -0
  399. data/test/lib/mocha/standalone.rb +2 -0
  400. data/test/lib/mocha/stub.rb +18 -0
  401. data/test/lib/mocha/test_case_adapter.rb +3 -3
  402. data/test/lib/mocha/yield_parameters.rb +31 -0
  403. data/test/lib/puppettest.rb +38 -20
  404. data/test/lib/puppettest/certificates.rb +0 -1
  405. data/test/lib/puppettest/exetest.rb +0 -1
  406. data/test/lib/puppettest/fakes.rb +0 -1
  407. data/test/lib/puppettest/fileparsing.rb +8 -15
  408. data/test/lib/puppettest/filetesting.rb +0 -1
  409. data/test/lib/puppettest/parsertesting.rb +37 -23
  410. data/test/lib/puppettest/railstesting.rb +3 -6
  411. data/test/lib/puppettest/reporttesting.rb +0 -1
  412. data/test/lib/puppettest/resourcetesting.rb +6 -34
  413. data/test/lib/puppettest/runnable_test.rb +30 -0
  414. data/test/lib/puppettest/servertest.rb +2 -3
  415. data/test/lib/puppettest/support/assertions.rb +13 -41
  416. data/test/lib/puppettest/support/collection.rb +0 -1
  417. data/test/lib/puppettest/support/helpers.rb +0 -1
  418. data/test/lib/puppettest/support/resources.rb +17 -17
  419. data/test/lib/puppettest/support/utils.rb +45 -27
  420. data/test/lib/puppettest/testcase.rb +2 -21
  421. data/test/lib/rake/puppet_test_loader.rb +0 -1
  422. data/test/lib/rake/puppet_testtask.rb +0 -1
  423. data/test/network/authconfig.rb +1 -2
  424. data/test/network/authorization.rb +1 -2
  425. data/test/network/authstore.rb +1 -2
  426. data/test/network/client/ca.rb +12 -7
  427. data/test/network/client/client.rb +17 -22
  428. data/test/network/client/dipper.rb +1 -2
  429. data/test/network/client/master.rb +70 -184
  430. data/test/network/client/resource.rb +9 -2
  431. data/test/network/client_request.rb +1 -2
  432. data/test/network/daemon.rb +1 -2
  433. data/test/network/handler/bucket.rb +2 -31
  434. data/test/network/handler/ca.rb +9 -3
  435. data/test/network/handler/configuration.rb +160 -0
  436. data/test/network/handler/fileserver.rb +24 -5
  437. data/test/network/handler/handler.rb +1 -2
  438. data/test/network/handler/master.rb +38 -243
  439. data/test/network/handler/report.rb +2 -104
  440. data/test/network/handler/resource.rb +5 -3
  441. data/test/network/handler/runner.rb +22 -60
  442. data/test/network/rights.rb +1 -2
  443. data/test/network/server/mongrel_test.rb +2 -3
  444. data/test/network/server/webrick.rb +17 -11
  445. data/test/network/xmlrpc/client.rb +27 -12
  446. data/test/network/xmlrpc/processor.rb +3 -4
  447. data/test/network/xmlrpc/server.rb +1 -2
  448. data/test/network/xmlrpc/webrick_servlet.rb +8 -2
  449. data/test/other/dsl.rb +2 -4
  450. data/test/other/events.rb +14 -56
  451. data/test/other/overrides.rb +3 -6
  452. data/test/other/propertychange.rb +1 -2
  453. data/test/other/provider.rb +1 -2
  454. data/test/other/puppet.rb +1 -2
  455. data/test/other/relationships.rb +15 -17
  456. data/test/other/report.rb +14 -20
  457. data/test/other/transactions.rb +109 -192
  458. data/test/puppet/conffiles.rb +3 -5
  459. data/test/puppet/defaults.rb +1 -28
  460. data/test/puppet/errortest.rb +1 -2
  461. data/test/puppet/tc_suidmanager.rb +77 -63
  462. data/test/rails/ast.rb +4 -4
  463. data/test/rails/configuration.rb +71 -0
  464. data/test/rails/host.rb +19 -30
  465. data/test/rails/rails.rb +1 -2
  466. data/test/rails/railsparameter.rb +3 -4
  467. data/test/rails/railsresource.rb +6 -5
  468. data/test/ral/manager/attributes.rb +1 -2
  469. data/test/ral/manager/instances.rb +3 -3
  470. data/test/ral/manager/manager.rb +1 -2
  471. data/test/ral/manager/provider.rb +1 -2
  472. data/test/ral/manager/type.rb +89 -93
  473. data/test/ral/providers/cron/crontab.rb +9 -11
  474. data/test/ral/providers/group.rb +1 -2
  475. data/test/ral/providers/host/netinfo.rb +1 -2
  476. data/test/ral/providers/host/parsed.rb +1 -2
  477. data/test/ral/providers/mailalias/aliases.rb +1 -2
  478. data/test/ral/providers/mount/netinfo.rb +1 -2
  479. data/test/ral/providers/nameservice.rb +1 -2
  480. data/test/ral/providers/package.rb +5 -4
  481. data/test/ral/providers/package/apt.rb +0 -1
  482. data/test/ral/providers/package/aptrpm.rb +0 -1
  483. data/test/ral/providers/parsedfile.rb +1 -2
  484. data/test/ral/providers/port/parsed.rb +1 -2
  485. data/test/ral/providers/provider.rb +10 -5
  486. data/test/ral/providers/service/base.rb +1 -2
  487. data/test/ral/providers/service/debian.rb +58 -0
  488. data/test/ral/providers/sshkey/parsed.rb +1 -2
  489. data/test/ral/providers/user.rb +3 -2
  490. data/test/ral/providers/user/useradd.rb +0 -1
  491. data/test/ral/types/basic.rb +4 -9
  492. data/test/ral/types/cron.rb +6 -12
  493. data/test/ral/types/exec.rb +6 -7
  494. data/test/ral/types/file.rb +35 -14
  495. data/test/ral/types/file/target.rb +6 -5
  496. data/test/ral/types/filebucket.rb +3 -2
  497. data/test/ral/types/fileignoresource.rb +10 -42
  498. data/test/ral/types/filesources.rb +21 -60
  499. data/test/ral/types/group.rb +3 -3
  500. data/test/ral/types/host.rb +6 -3
  501. data/test/ral/types/mailalias.rb +1 -2
  502. data/test/ral/types/parameter.rb +5 -3
  503. data/test/ral/types/port.rb +1 -2
  504. data/test/ral/types/property.rb +3 -3
  505. data/test/ral/types/resources.rb +1 -2
  506. data/test/ral/types/service.rb +5 -3
  507. data/test/ral/types/sshkey.rb +5 -3
  508. data/test/ral/types/tidy.rb +63 -3
  509. data/test/ral/types/user.rb +10 -11
  510. data/test/ral/types/yumrepo.rb +1 -1
  511. data/test/ral/types/zone.rb +1 -2
  512. data/test/util/autoload.rb +23 -27
  513. data/test/util/classgen.rb +1 -2
  514. data/test/util/execution.rb +1 -2
  515. data/test/util/features.rb +1 -3
  516. data/test/util/fileparsing.rb +11 -3
  517. data/test/util/filetype.rb +1 -2
  518. data/test/util/inifile.rb +1 -1
  519. data/test/util/instance_loader.rb +5 -6
  520. data/test/util/loadedfile.rb +1 -2
  521. data/test/util/log.rb +1 -2
  522. data/test/util/metrics.rb +1 -2
  523. data/test/util/package.rb +1 -2
  524. data/test/util/posixtest.rb +1 -2
  525. data/test/util/{config.rb → settings.rb} +123 -265
  526. data/test/util/storage.rb +1 -2
  527. data/test/util/subclass_loader.rb +1 -2
  528. data/test/util/utiltest.rb +1 -111
  529. metadata +130 -112
  530. data/ext/tools/passwd2puppet +0 -45
  531. data/lib/puppet/fact_stores/yaml.rb +0 -42
  532. data/lib/puppet/network/handler/facts.rb +0 -70
  533. data/lib/puppet/parser/ast/resourcedef.rb +0 -222
  534. data/lib/puppet/parser/ast/resourceref.rb +0 -58
  535. data/test/language/ast/component.rb +0 -142
  536. data/test/language/collector.rb +0 -179
  537. data/test/language/interpreter.rb +0 -804
  538. data/test/language/node.rb +0 -126
  539. data/test/lib/mocha/mock_methods.rb +0 -122
  540. data/test/lib/puppettest/graph.rb +0 -41
  541. data/test/lib/spec.rb +0 -8
  542. data/test/lib/spec/callback.rb +0 -11
  543. data/test/lib/spec/callback/callback_container.rb +0 -60
  544. data/test/lib/spec/callback/extensions/module.rb +0 -24
  545. data/test/lib/spec/callback/extensions/object.rb +0 -37
  546. data/test/lib/spec/deprecated.rb +0 -3
  547. data/test/lib/spec/expectations.rb +0 -59
  548. data/test/lib/spec/expectations/differs/default.rb +0 -62
  549. data/test/lib/spec/expectations/errors.rb +0 -6
  550. data/test/lib/spec/expectations/extensions.rb +0 -3
  551. data/test/lib/spec/expectations/extensions/object.rb +0 -109
  552. data/test/lib/spec/expectations/extensions/proc.rb +0 -57
  553. data/test/lib/spec/expectations/extensions/string_and_symbol.rb +0 -17
  554. data/test/lib/spec/expectations/handler.rb +0 -47
  555. data/test/lib/spec/expectations/should.rb +0 -5
  556. data/test/lib/spec/expectations/should/base.rb +0 -64
  557. data/test/lib/spec/expectations/should/change.rb +0 -69
  558. data/test/lib/spec/expectations/should/have.rb +0 -128
  559. data/test/lib/spec/expectations/should/not.rb +0 -74
  560. data/test/lib/spec/expectations/should/should.rb +0 -81
  561. data/test/lib/spec/expectations/sugar.rb +0 -47
  562. data/test/lib/spec/matchers.rb +0 -160
  563. data/test/lib/spec/matchers/be.rb +0 -161
  564. data/test/lib/spec/matchers/be_close.rb +0 -37
  565. data/test/lib/spec/matchers/change.rb +0 -120
  566. data/test/lib/spec/matchers/eql.rb +0 -43
  567. data/test/lib/spec/matchers/equal.rb +0 -43
  568. data/test/lib/spec/matchers/has.rb +0 -44
  569. data/test/lib/spec/matchers/have.rb +0 -140
  570. data/test/lib/spec/matchers/include.rb +0 -50
  571. data/test/lib/spec/matchers/match.rb +0 -41
  572. data/test/lib/spec/matchers/raise_error.rb +0 -100
  573. data/test/lib/spec/matchers/respond_to.rb +0 -35
  574. data/test/lib/spec/matchers/satisfy.rb +0 -47
  575. data/test/lib/spec/matchers/throw_symbol.rb +0 -75
  576. data/test/lib/spec/mocks.rb +0 -232
  577. data/test/lib/spec/mocks/argument_expectation.rb +0 -132
  578. data/test/lib/spec/mocks/error_generator.rb +0 -85
  579. data/test/lib/spec/mocks/errors.rb +0 -10
  580. data/test/lib/spec/mocks/extensions/object.rb +0 -3
  581. data/test/lib/spec/mocks/message_expectation.rb +0 -231
  582. data/test/lib/spec/mocks/methods.rb +0 -40
  583. data/test/lib/spec/mocks/mock.rb +0 -26
  584. data/test/lib/spec/mocks/mock_handler.rb +0 -166
  585. data/test/lib/spec/mocks/order_group.rb +0 -29
  586. data/test/lib/spec/rake/spectask.rb +0 -173
  587. data/test/lib/spec/rake/verify_rcov.rb +0 -47
  588. data/test/lib/spec/runner.rb +0 -132
  589. data/test/lib/spec/runner/backtrace_tweaker.rb +0 -55
  590. data/test/lib/spec/runner/command_line.rb +0 -34
  591. data/test/lib/spec/runner/context.rb +0 -154
  592. data/test/lib/spec/runner/context_eval.rb +0 -142
  593. data/test/lib/spec/runner/context_runner.rb +0 -55
  594. data/test/lib/spec/runner/drb_command_line.rb +0 -21
  595. data/test/lib/spec/runner/execution_context.rb +0 -17
  596. data/test/lib/spec/runner/extensions/kernel.rb +0 -17
  597. data/test/lib/spec/runner/extensions/object.rb +0 -32
  598. data/test/lib/spec/runner/formatter.rb +0 -5
  599. data/test/lib/spec/runner/formatter/base_text_formatter.rb +0 -118
  600. data/test/lib/spec/runner/formatter/html_formatter.rb +0 -219
  601. data/test/lib/spec/runner/formatter/progress_bar_formatter.rb +0 -27
  602. data/test/lib/spec/runner/formatter/rdoc_formatter.rb +0 -22
  603. data/test/lib/spec/runner/formatter/specdoc_formatter.rb +0 -23
  604. data/test/lib/spec/runner/heckle_runner.rb +0 -71
  605. data/test/lib/spec/runner/heckle_runner_win.rb +0 -10
  606. data/test/lib/spec/runner/option_parser.rb +0 -224
  607. data/test/lib/spec/runner/reporter.rb +0 -105
  608. data/test/lib/spec/runner/spec_matcher.rb +0 -25
  609. data/test/lib/spec/runner/spec_parser.rb +0 -41
  610. data/test/lib/spec/runner/spec_should_raise_handler.rb +0 -74
  611. data/test/lib/spec/runner/specification.rb +0 -114
  612. data/test/lib/spec/translator.rb +0 -87
  613. data/test/lib/spec/version.rb +0 -30
  614. data/test/network/handler/facts.rb +0 -112
  615. data/test/other/pgraph.rb +0 -290
  616. data/test/other/relationship.rb +0 -74
  617. data/test/puppet/modules.rb +0 -59
  618. data/test/rails/collection.rb +0 -247
  619. data/test/rails/interpreter.rb +0 -91
  620. data/test/ral/providers/mount/parsed.rb +0 -251
  621. data/test/ral/providers/service.rb +0 -235
  622. data/test/ral/types/component.rb +0 -113
  623. data/test/ral/types/interface.rb +0 -40
  624. data/test/ral/types/mount.rb +0 -362
  625. data/test/ral/types/package.rb +0 -154
  626. data/test/ral/types/schedule.rb +0 -357
  627. data/test/tagging/tagging.rb +0 -170
  628. data/test/util/fact_store.rb +0 -67
  629. data/test/util/graph.rb +0 -108
@@ -25,4 +25,3 @@ class Puppet::Network::Client::ProxyClient < Puppet::Network::Client
25
25
  end
26
26
  end
27
27
 
28
- # $Id: proxy.rb 2259 2007-03-06 19:03:05Z luke $
@@ -28,4 +28,3 @@ class Puppet::Network::Client::Report < Puppet::Network::Client
28
28
  end
29
29
  end
30
30
 
31
- # $Id: report.rb 2259 2007-03-06 19:03:05Z luke $
@@ -49,4 +49,3 @@ class Puppet::Network::Client::Resource < Puppet::Network::Client
49
49
  end
50
50
  end
51
51
 
52
- # $Id: resource.rb 2259 2007-03-06 19:03:05Z luke $
@@ -10,4 +10,3 @@ class Puppet::Network::Client::Runner < Puppet::Network::Client::ProxyClient
10
10
  end
11
11
  end
12
12
 
13
- # $Id: runner.rb 2259 2007-03-06 19:03:05Z luke $
@@ -2,4 +2,3 @@ class Puppet::Network::Client::Status < Puppet::Network::Client::ProxyClient
2
2
  self.mkmethods
3
3
  end
4
4
 
5
- # $Id: status.rb 2259 2007-03-06 19:03:05Z luke $
@@ -29,4 +29,3 @@ module Puppet::Network # :nodoc:
29
29
  end
30
30
  end
31
31
 
32
- # $Id: client_request.rb 2259 2007-03-06 19:03:05Z luke $
@@ -10,7 +10,7 @@ module Puppet::Network
10
10
  # This is so that the handlers can subclass just 'Handler', rather
11
11
  # then having to specify the full class path.
12
12
  Handler = self
13
- attr_accessor :server
13
+ attr_accessor :server, :local
14
14
 
15
15
  extend Puppet::Util::SubclassLoader
16
16
  extend Puppet::Util
@@ -44,7 +44,10 @@ module Puppet::Network
44
44
  # Create an empty init method with the same signature.
45
45
  def initialize(hash = {})
46
46
  end
47
+
48
+ def local?
49
+ self.local
50
+ end
47
51
  end
48
52
  end
49
53
 
50
- # $Id: handler.rb 2479 2007-05-07 22:29:44Z luke $
@@ -60,7 +60,7 @@ class Puppet::Network::Handler
60
60
  end
61
61
 
62
62
  def initialize(hash = {})
63
- Puppet.config.use(:main, :ssl, :ca)
63
+ Puppet.settings.use(:main, :ssl, :ca)
64
64
  if hash.include? :autosign
65
65
  @autosign = hash[:autosign]
66
66
  end
@@ -155,4 +155,3 @@ class Puppet::Network::Handler
155
155
  end
156
156
  end
157
157
 
158
- # $Id: ca.rb 2612 2007-06-18 19:51:17Z luke $
@@ -0,0 +1,184 @@
1
+ require 'openssl'
2
+ require 'puppet'
3
+ require 'puppet/parser/interpreter'
4
+ require 'puppet/sslcertificates'
5
+ require 'xmlrpc/server'
6
+ require 'yaml'
7
+
8
+ class Puppet::Network::Handler
9
+ class Configuration < Handler
10
+ desc "Puppet's configuration compilation interface. Passed a node name
11
+ or other key, retrieves information about the node (using the ``node_source``)
12
+ and returns a compiled configuration."
13
+
14
+ include Puppet::Util
15
+
16
+ attr_accessor :local, :classes
17
+
18
+ @interface = XMLRPC::Service::Interface.new("configuration") { |iface|
19
+ iface.add_method("string configuration(string)")
20
+ iface.add_method("string version()")
21
+ }
22
+
23
+ # Compile a node's configuration.
24
+ def configuration(key, client = nil, clientip = nil)
25
+ # If we want to use the cert name as our key
26
+ if Puppet[:node_name] == 'cert' and client
27
+ key = client
28
+ end
29
+
30
+ # Note that this is reasonable, because either their node source should actually
31
+ # know about the node, or they should be using the ``none`` node source, which
32
+ # will always return data.
33
+ unless node = Puppet::Node.find_by_any_name(key)
34
+ raise Puppet::Error, "Could not find node '%s'" % key
35
+ end
36
+
37
+ # Add any external data to the node.
38
+ add_node_data(node)
39
+
40
+ configuration = compile(node)
41
+
42
+ return translate(configuration)
43
+ end
44
+
45
+ def initialize(options = {})
46
+ options.each do |param, value|
47
+ case param
48
+ when :Classes: @classes = value
49
+ when :Local: self.local = value
50
+ else
51
+ raise ArgumentError, "Configuration handler does not accept %s" % param
52
+ end
53
+ end
54
+
55
+ set_server_facts
56
+ end
57
+
58
+ # Are we running locally, or are our clients networked?
59
+ def local?
60
+ self.local
61
+ end
62
+
63
+ # Return the configuration version.
64
+ def version(client = nil, clientip = nil)
65
+ if client and node = Puppet::Node.find_by_any_name(client)
66
+ update_node_check(node)
67
+ return interpreter.configuration_version(node)
68
+ else
69
+ # Just return something that will always result in a recompile, because
70
+ # this is local.
71
+ return (Time.now + 1000).to_i
72
+ end
73
+ end
74
+
75
+ private
76
+
77
+ # Add any extra data necessary to the node.
78
+ def add_node_data(node)
79
+ # Merge in our server-side facts, so they can be used during compilation.
80
+ node.merge(@server_facts)
81
+
82
+ # Add any specified classes to the node's class list.
83
+ if @classes
84
+ @classes.each do |klass|
85
+ node.classes << klass
86
+ end
87
+ end
88
+ end
89
+
90
+ # Compile the actual configuration.
91
+ def compile(node)
92
+ # Pick the benchmark level.
93
+ if local?
94
+ level = :none
95
+ else
96
+ level = :notice
97
+ end
98
+
99
+ # Ask the interpreter to compile the configuration.
100
+ str = "Compiled configuration for %s" % node.name
101
+ if node.environment
102
+ str += " in environment %s" % node.environment
103
+ end
104
+ config = nil
105
+ benchmark(level, "Compiled configuration for %s" % node.name) do
106
+ begin
107
+ config = interpreter.compile(node)
108
+ rescue => detail
109
+ # If we're local, then we leave it to the local system
110
+ # to handle error reporting, but otherwise we do it here
111
+ # so the interpreter doesn't need to know if the parser
112
+ # is local or not.
113
+ Puppet.err(detail.to_s) unless local?
114
+ raise
115
+ end
116
+ end
117
+
118
+ return config
119
+ end
120
+
121
+ # Create our interpreter object.
122
+ def create_interpreter
123
+ return Puppet::Parser::Interpreter.new
124
+ end
125
+
126
+ # Create/return our interpreter.
127
+ def interpreter
128
+ unless defined?(@interpreter) and @interpreter
129
+ @interpreter = create_interpreter
130
+ end
131
+ @interpreter
132
+ end
133
+
134
+ # Initialize our server fact hash; we add these to each client, and they
135
+ # won't change while we're running, so it's safe to cache the values.
136
+ def set_server_facts
137
+ @server_facts = {}
138
+
139
+ # Add our server version to the fact list
140
+ @server_facts["serverversion"] = Puppet.version.to_s
141
+
142
+ # And then add the server name and IP
143
+ {"servername" => "fqdn",
144
+ "serverip" => "ipaddress"
145
+ }.each do |var, fact|
146
+ if value = Facter.value(fact)
147
+ @server_facts[var] = value
148
+ else
149
+ Puppet.warning "Could not retrieve fact %s" % fact
150
+ end
151
+ end
152
+
153
+ if @server_facts["servername"].nil?
154
+ host = Facter.value(:hostname)
155
+ if domain = Facter.value(:domain)
156
+ @server_facts["servername"] = [host, domain].join(".")
157
+ else
158
+ @server_facts["servername"] = host
159
+ end
160
+ end
161
+ end
162
+
163
+ # Translate our configuration appropriately for sending back to a client.
164
+ def translate(config)
165
+ if local?
166
+ config
167
+ else
168
+ CGI.escape(config.to_yaml(:UseBlock => true))
169
+ end
170
+ end
171
+
172
+ # Mark that the node has checked in. FIXME this needs to be moved into
173
+ # the Node class, or somewhere that's got abstract backends.
174
+ def update_node_check(node)
175
+ if Puppet.features.rails? and Puppet[:storeconfigs]
176
+ Puppet::Rails.connect
177
+
178
+ host = Puppet::Rails::Host.find_or_create_by_name(node.name)
179
+ host.last_freshcheck = Time.now
180
+ host.save
181
+ end
182
+ end
183
+ end
184
+ end
@@ -64,7 +64,7 @@ class Puppet::Network::Handler # :nodoc:
64
64
  end
65
65
  end
66
66
 
67
- Puppet.config.use(:filebucket)
67
+ Puppet.settings.use(:filebucket)
68
68
 
69
69
  @name = "Filebucket[#{@path}]"
70
70
  end
@@ -180,4 +180,3 @@ class Puppet::Network::Handler # :nodoc:
180
180
  end
181
181
  end
182
182
 
183
- # $Id: filebucket.rb 2479 2007-05-07 22:29:44Z luke $
@@ -17,6 +17,7 @@ class Puppet::Network::Handler
17
17
 
18
18
  # Special filserver module for puppet's module system
19
19
  MODULES = "modules"
20
+ PLUGINS = "plugins"
20
21
 
21
22
  @interface = XMLRPC::Service::Interface.new("fileserver") { |iface|
22
23
  iface.add_method("string describe(string, string)")
@@ -28,6 +29,34 @@ class Puppet::Network::Handler
28
29
  CHECKPARAMS.dup
29
30
  end
30
31
 
32
+ # If the configuration file exists, then create (if necessary) a LoadedFile
33
+ # object to manage it; else, return nil.
34
+ def configuration
35
+ # Short-circuit the default case.
36
+ return @configuration if defined?(@configuration)
37
+
38
+ config_path = @passed_configuration_path || Puppet[:fileserverconfig]
39
+ return nil unless FileTest.exist?(config_path)
40
+
41
+ # The file exists but we don't have a LoadedFile instance for it.
42
+ @configuration = Puppet::Util::LoadedFile.new(config_path)
43
+ end
44
+
45
+ # Create our default mounts for modules and plugins. This is duplicated code,
46
+ # but I'm not really worried about that.
47
+ def create_default_mounts
48
+ @mounts = {}
49
+ Puppet.debug "No file server configuration file; autocreating #{MODULES} mount with default permissions"
50
+ mount = Mount.new(MODULES)
51
+ mount.allow("*")
52
+ @mounts[MODULES] = mount
53
+
54
+ Puppet.debug "No file server configuration file; autocreating #{PLUGINS} mount with default permissions"
55
+ mount = PluginMount.new(PLUGINS)
56
+ mount.allow("*")
57
+ @mounts[PLUGINS] = mount
58
+ end
59
+
31
60
  # Describe a given file. This returns all of the manageable aspects
32
61
  # of that file.
33
62
  def describe(url, links = :ignore, client = nil, clientip = nil)
@@ -44,7 +73,7 @@ class Puppet::Network::Handler
44
73
  end
45
74
 
46
75
  obj = nil
47
- unless obj = mount.getfileobject(path, links)
76
+ unless obj = mount.getfileobject(path, links, client)
48
77
  return ""
49
78
  end
50
79
 
@@ -79,13 +108,10 @@ class Puppet::Network::Handler
79
108
 
80
109
  if hash[:Config] == false
81
110
  @noreadconfig = true
82
- else
83
- @config = Puppet::Util::LoadedFile.new(
84
- hash[:Config] || Puppet[:fileserverconfig]
85
- )
86
- @noreadconfig = false
87
111
  end
88
112
 
113
+ @passed_configuration_path = hash[:Config]
114
+
89
115
  if hash.include?(:Mount)
90
116
  @passedconfig = true
91
117
  unless hash[:Mount].is_a?(Hash)
@@ -99,9 +125,14 @@ class Puppet::Network::Handler
99
125
  end
100
126
  }
101
127
  self.mount(nil, MODULES)
128
+ self.mount(nil, PLUGINS)
102
129
  else
103
130
  @passedconfig = false
104
- readconfig(false) # don't check the file the first time.
131
+ if configuration
132
+ readconfig(false) # don't check the file the first time.
133
+ else
134
+ create_default_mounts()
135
+ end
105
136
  end
106
137
  end
107
138
 
@@ -114,13 +145,11 @@ class Puppet::Network::Handler
114
145
  end
115
146
 
116
147
  obj = nil
117
- unless FileTest.exists?(path)
148
+ unless mount.path_exists?(path, client)
118
149
  return ""
119
150
  end
120
151
 
121
- # We pass two paths here, but reclist internally changes one
122
- # of the arguments when called internally.
123
- desc = reclist(mount, path, path, recurse, ignore)
152
+ desc = mount.list(path, recurse, ignore, client)
124
153
 
125
154
  if desc.length == 0
126
155
  mount.notice "Got no information on //%s/%s" %
@@ -137,6 +166,11 @@ class Puppet::Network::Handler
137
166
  self.local
138
167
  end
139
168
 
169
+ # Is a given mount available?
170
+ def mounted?(name)
171
+ @mounts.include?(name)
172
+ end
173
+
140
174
  # Mount a new directory with a name.
141
175
  def mount(path, name)
142
176
  if @mounts.include?(name)
@@ -167,13 +201,15 @@ class Puppet::Network::Handler
167
201
  mount.info "Sending %s to %s" % [url, client]
168
202
  end
169
203
 
170
- unless FileTest.exists?(path)
204
+ unless mount.path_exists?(path, client)
205
+ mount.debug "#{mount} reported that #{path} does not exist"
171
206
  return ""
172
207
  end
173
208
 
174
209
  links = links.intern if links.is_a? String
175
210
 
176
211
  if links == :ignore and FileTest.symlink?(path)
212
+ mount.debug "I think that #{path} is a symlink and we're ignoring them"
177
213
  return ""
178
214
  end
179
215
 
@@ -181,7 +217,7 @@ class Puppet::Network::Handler
181
217
  if links == :manage
182
218
  raise Puppet::Error, "Cannot copy links yet."
183
219
  else
184
- str = File.read(path)
220
+ str = mount.read_file(path, client)
185
221
  end
186
222
 
187
223
  if @local
@@ -210,6 +246,9 @@ class Puppet::Network::Handler
210
246
  end
211
247
  end
212
248
 
249
+ # Take a URL and some client info and return a mount and relative
250
+ # path pair.
251
+ #
213
252
  def convert(url, client, clientip)
214
253
  readconfig
215
254
 
@@ -219,37 +258,44 @@ class Puppet::Network::Handler
219
258
 
220
259
  authcheck(url, mount, client, clientip)
221
260
 
222
- path = nil
223
- unless path = mount.subdir(stub, client)
224
- mount.notice "Could not find subdirectory %s" %
225
- "//%s/%s" % [mount, stub]
226
- return ""
261
+ return mount, stub
262
+ end
263
+
264
+ # Return the mount for the Puppet modules; allows file copying from
265
+ # the modules.
266
+ def modules_mount(module_name, client)
267
+ # Find our environment, if we have one.
268
+ unless hostname = (client || Facter.value("hostname"))
269
+ raise ArgumentError, "Could not find hostname"
270
+ end
271
+ if node = Puppet::Node.find(hostname)
272
+ env = node.environment
273
+ else
274
+ env = nil
227
275
  end
228
276
 
229
- return mount, path
277
+ # And use the environment to look up the module.
278
+ mod = Puppet::Module::find(module_name, env)
279
+ if mod
280
+ return @mounts[MODULES].copy(mod.name, mod.files)
281
+ else
282
+ return nil
283
+ end
230
284
  end
231
285
 
232
- # Deal with ignore parameters.
233
- def handleignore(children, path, ignore)
234
- ignore.each { |ignore|
235
- Dir.glob(File.join(path,ignore), File::FNM_DOTMATCH) { |match|
236
- children.delete(File.basename(match))
237
- }
238
- }
239
- return children
240
- end
241
-
242
286
  # Read the configuration file.
243
287
  def readconfig(check = true)
244
288
  return if @noreadconfig
245
289
 
246
- if check and ! @config.changed?
290
+ return unless configuration
291
+
292
+ if check and ! @configuration.changed?
247
293
  return
248
294
  end
249
295
 
250
296
  newmounts = {}
251
297
  begin
252
- File.open(@config.file) { |f|
298
+ File.open(@configuration.file) { |f|
253
299
  mount = nil
254
300
  count = 1
255
301
  f.each { |line|
@@ -260,7 +306,7 @@ class Puppet::Network::Handler
260
306
  name = $1
261
307
  if newmounts.include?(name)
262
308
  raise FileServerError, "%s is already mounted at %s" %
263
- [newmounts[name], name], count, @config.file
309
+ [newmounts[name], name], count, @configuration.file
264
310
  end
265
311
  mount = Mount.new(name)
266
312
  newmounts[name] = mount
@@ -269,8 +315,12 @@ class Puppet::Network::Handler
269
315
  value = $2
270
316
  case var
271
317
  when "path":
318
+ if mount.name == PLUGINS
319
+ Puppet.warning "An explicit 'plugins' mount is deprecated. Please switch to using modules."
320
+ end
321
+
272
322
  if mount.name == MODULES
273
- Puppet.warning "The '#{MODULES}' module can not have a path. Ignoring attempt to set it"
323
+ Puppet.warning "The '#{mount.name}' module can not have a path. Ignoring attempt to set it"
274
324
  else
275
325
  begin
276
326
  mount.path = value
@@ -287,7 +337,7 @@ class Puppet::Network::Handler
287
337
  mount.allow(val)
288
338
  rescue AuthStoreError => detail
289
339
  raise FileServerError.new(detail.to_s,
290
- count, @config.file)
340
+ count, @configuration.file)
291
341
  end
292
342
  }
293
343
  when "deny":
@@ -297,115 +347,92 @@ class Puppet::Network::Handler
297
347
  mount.deny(val)
298
348
  rescue AuthStoreError => detail
299
349
  raise FileServerError.new(detail.to_s,
300
- count, @config.file)
350
+ count, @configuration.file)
301
351
  end
302
352
  }
303
353
  else
304
354
  raise FileServerError.new("Invalid argument '%s'" % var,
305
- count, @config.file)
355
+ count, @configuration.file)
306
356
  end
307
357
  else
308
358
  raise FileServerError.new("Invalid line '%s'" % line.chomp,
309
- count, @config.file)
359
+ count, @configuration.file)
310
360
  end
311
361
  count += 1
312
362
  }
313
363
  }
314
364
  rescue Errno::EACCES => detail
315
- Puppet.err "FileServer error: Cannot read %s; cannot serve" % @config
316
- #raise Puppet::Error, "Cannot read %s" % @config
365
+ Puppet.err "FileServer error: Cannot read %s; cannot serve" % @configuration
366
+ #raise Puppet::Error, "Cannot read %s" % @configuration
317
367
  rescue Errno::ENOENT => detail
318
368
  Puppet.err "FileServer error: '%s' does not exist; cannot serve" %
319
- @config
320
- #raise Puppet::Error, "%s does not exit" % @config
321
- #rescue FileServerError => detail
322
- # Puppet.err "FileServer error: %s" % detail
369
+ @configuration
323
370
  end
324
371
 
325
372
  unless newmounts[MODULES]
373
+ Puppet.debug "No #{MODULES} mount given; autocreating with default permissions"
326
374
  mount = Mount.new(MODULES)
327
375
  mount.allow("*")
328
376
  newmounts[MODULES] = mount
329
377
  end
330
-
378
+
379
+ unless newmounts[PLUGINS]
380
+ Puppet.debug "No #{PLUGINS} mount given; autocreating with default permissions"
381
+ mount = PluginMount.new(PLUGINS)
382
+ mount.allow("*")
383
+ newmounts[PLUGINS] = mount
384
+ end
385
+
386
+ unless newmounts[PLUGINS].valid?
387
+ Puppet.debug "No path given for #{PLUGINS} mount; creating a special PluginMount"
388
+ # We end up here if the user has specified access rules for
389
+ # the plugins mount, without specifying a path (which means
390
+ # they want to have the default behaviour for the mount, but
391
+ # special access control). So we need to move all the
392
+ # user-specified access controls into the new PluginMount
393
+ # object...
394
+ mount = PluginMount.new(PLUGINS)
395
+ # Yes, you're allowed to hate me for this.
396
+ mount.instance_variable_set(:@declarations,
397
+ newmounts[PLUGINS].instance_variable_get(:@declarations)
398
+ )
399
+ newmounts[PLUGINS] = mount
400
+ end
401
+
331
402
  # Verify each of the mounts are valid.
332
403
  # We let the check raise an error, so that it can raise an error
333
404
  # pointing to the specific problem.
334
405
  newmounts.each { |name, mount|
335
406
  unless mount.valid?
336
- raise FileServerError, "No path specified for mount %s" %
407
+ raise FileServerError, "Invalid mount %s" %
337
408
  name
338
409
  end
339
410
  }
340
411
  @mounts = newmounts
341
412
  end
342
413
 
343
- # Recursively list the directory. FIXME This should be using
344
- # puppet objects, not directly listing.
345
- def reclist(mount, root, path, recurse, ignore)
346
- # Take out the root of the path.
347
- name = path.sub(root, '')
348
- if name == ""
349
- name = "/"
350
- end
351
-
352
- if name == path
353
- raise FileServerError, "Could not match %s in %s" %
354
- [root, path]
355
- end
356
-
357
- desc = [name]
358
- ftype = File.stat(path).ftype
359
-
360
- desc << ftype
361
- if recurse.is_a?(Integer)
362
- recurse -= 1
363
- end
364
-
365
- ary = [desc]
366
- if recurse == true or (recurse.is_a?(Integer) and recurse > -1)
367
- if ftype == "directory"
368
- children = Dir.entries(path)
369
- if ignore
370
- children = handleignore(children, path, ignore)
371
- end
372
- children.each { |child|
373
- next if child =~ /^\.\.?$/
374
- reclist(mount, root, File.join(path, child), recurse, ignore).each { |cobj|
375
- ary << cobj
376
- }
377
- }
378
- end
379
- end
380
-
381
- return ary.reject { |c| c.nil? }
382
- end
383
-
384
414
  # Split the path into the separate mount point and path.
385
415
  def splitpath(dir, client)
386
416
  # the dir is based on one of the mounts
387
417
  # so first retrieve the mount path
388
418
  mount = nil
389
419
  path = nil
390
- if dir =~ %r{/([-\w]+)/?}
391
- tmp = $1
392
- path = dir.sub(%r{/#{tmp}/?}, '')
420
+ if dir =~ %r{/([-\w]+)}
421
+ # Strip off the mount name.
422
+ mount_name, path = dir.sub(%r{^/}, '').split(File::Separator, 2)
393
423
 
394
- mod = Puppet::Module::find(tmp)
395
- if mod
396
- mount = @mounts[MODULES].copy(mod.name, mod.files)
397
- else
398
- unless mount = @mounts[tmp]
399
- raise FileServerError, "Fileserver module '%s' not mounted" % tmp
424
+ unless mount = modules_mount(mount_name, client)
425
+ unless mount = @mounts[mount_name]
426
+ raise FileServerError, "Fileserver module '%s' not mounted" % mount_name
400
427
  end
401
428
  end
402
429
  else
403
430
  raise FileServerError, "Fileserver error: Invalid path '%s'" % dir
404
431
  end
405
432
 
406
- if path == ""
407
- path = nil
408
- else
433
+ if path.nil? or path == ''
434
+ path = '/'
435
+ elsif path
409
436
  # Remove any double slashes that might have occurred
410
437
  path = URI.unescape(path.gsub(/\/\//, "/"))
411
438
  end
@@ -429,13 +456,13 @@ class Puppet::Network::Handler
429
456
 
430
457
  Puppet::Util.logmethods(self, true)
431
458
 
432
- def getfileobject(dir, links)
433
- unless FileTest.exists?(dir)
434
- self.notice "File source %s does not exist" % dir
459
+ def getfileobject(dir, links, client = nil)
460
+ unless path_exists?(dir, client)
461
+ self.debug "File source %s does not exist" % dir
435
462
  return nil
436
463
  end
437
464
 
438
- return fileobj(dir, links)
465
+ return fileobj(dir, links, client)
439
466
  end
440
467
 
441
468
  # Run 'retrieve' on a file. This gets the actual parameters, so
@@ -519,6 +546,19 @@ class Puppet::Network::Handler
519
546
  end
520
547
  end
521
548
 
549
+ # Return a fully qualified path, given a short path and
550
+ # possibly a client name.
551
+ def file_path(relative_path, node = nil)
552
+ full_path = path(node)
553
+
554
+ raise ArgumentError.new("Mounts without paths are not usable") unless full_path
555
+
556
+ # If there's no relative path name, then we're serving the mount itself.
557
+ return full_path unless relative_path and relative_path != "/"
558
+
559
+ return File.join(full_path, relative_path)
560
+ end
561
+
522
562
  # Create out object. It must have a name.
523
563
  def initialize(name, path = nil)
524
564
  unless name =~ %r{^[-\w]+$}
@@ -535,9 +575,9 @@ class Puppet::Network::Handler
535
575
  super()
536
576
  end
537
577
 
538
- def fileobj(path, links)
578
+ def fileobj(path, links, client)
539
579
  obj = nil
540
- if obj = Puppet.type(:file)[path]
580
+ if obj = Puppet.type(:file)[file_path(path, client)]
541
581
  # This can only happen in local fileserving, but it's an
542
582
  # important one. It'd be nice if we didn't just set
543
583
  # the check params every time, but I'm not sure it's worth
@@ -545,7 +585,7 @@ class Puppet::Network::Handler
545
585
  obj[:check] = CHECKPARAMS
546
586
  else
547
587
  obj = Puppet.type(:file).create(
548
- :name => path,
588
+ :name => file_path(path, client),
549
589
  :check => CHECKPARAMS
550
590
  )
551
591
  end
@@ -562,6 +602,11 @@ class Puppet::Network::Handler
562
602
  return obj
563
603
  end
564
604
 
605
+ # Read the contents of the file at the relative path given.
606
+ def read_file(relpath, client)
607
+ File.read(file_path(relpath, client))
608
+ end
609
+
565
610
  # Cache this manufactured map, since if it's used it's likely
566
611
  # to get used a lot.
567
612
  def localmap
@@ -607,6 +652,12 @@ class Puppet::Network::Handler
607
652
  @path = path
608
653
  end
609
654
 
655
+ # Verify that the path given exists within this mount's subtree.
656
+ #
657
+ def path_exists?(relpath, client = nil)
658
+ File.exists?(file_path(relpath, client))
659
+ end
660
+
610
661
  # Return the current values for the object.
611
662
  def properties(obj)
612
663
  obj.retrieve.inject({}) { |props, ary| props[ary[0].name] = ary[1]; props }
@@ -618,7 +669,7 @@ class Puppet::Network::Handler
618
669
  basedir = self.path(client)
619
670
 
620
671
  dirname = if dir
621
- File.join(basedir, dir.split("/").join(File::SEPARATOR))
672
+ File.join(basedir, *dir.split("/"))
622
673
  else
623
674
  basedir
624
675
  end
@@ -653,8 +704,129 @@ class Puppet::Network::Handler
653
704
  result.instance_variable_set(:@name, name)
654
705
  return result
655
706
  end
707
+
708
+ # List the contents of the relative path +relpath+ of this mount.
709
+ #
710
+ # +recurse+ is the number of levels to recurse into the tree,
711
+ # or false to provide no recursion or true if you just want to
712
+ # go for broke.
713
+ #
714
+ # +ignore+ is an array of filenames to ignore when traversing
715
+ # the list.
716
+ #
717
+ # The return value of this method is a complex nest of arrays,
718
+ # which describes a directory tree. Each file or directory is
719
+ # represented by an array, where the first element is the path
720
+ # of the file (relative to the root of the mount), and the
721
+ # second element is the type. A directory is represented by an
722
+ # array as well, where the first element is a "directory" array,
723
+ # while the remaining elements are other file or directory
724
+ # arrays. Confusing? Hell yes. As an added bonus, all names
725
+ # must start with a slash, because... well, I'm fairly certain
726
+ # a complete explanation would involve the words "crack pipe"
727
+ # and "bad batch".
728
+ #
729
+ def list(relpath, recurse, ignore, client = nil)
730
+ reclist(file_path(relpath, client), nil, recurse, ignore)
731
+ end
732
+
733
+ # Recursively list the files in this tree.
734
+ def reclist(basepath, abspath, recurse, ignore)
735
+ abspath = basepath if abspath.nil?
736
+ relpath = abspath.sub(%r{^#{basepath}}, '')
737
+ relpath = "/#{relpath}" if relpath[0] != ?/ #/
738
+
739
+ return unless FileTest.exists?(abspath)
740
+
741
+ desc = [relpath]
742
+
743
+ ftype = File.stat(abspath).ftype
744
+
745
+ desc << ftype
746
+ if recurse.is_a?(Integer)
747
+ recurse -= 1
748
+ end
749
+
750
+ ary = [desc]
751
+ if recurse == true or (recurse.is_a?(Integer) and recurse > -1)
752
+ if ftype == "directory"
753
+ children = Dir.entries(abspath)
754
+ if ignore
755
+ children = handleignore(children, abspath, ignore)
756
+ end
757
+ children.each { |child|
758
+ next if child =~ /^\.\.?$/
759
+ reclist(basepath, File.join(abspath, child), recurse, ignore).each { |cobj|
760
+ ary << cobj
761
+ }
762
+ }
763
+ end
764
+ end
765
+
766
+ return ary.compact
767
+ end
768
+
769
+ # Deal with ignore parameters.
770
+ def handleignore(files, path, ignore_patterns)
771
+ ignore_patterns.each do |ignore|
772
+ files.delete_if do |entry|
773
+ File.fnmatch(ignore, entry, File::FNM_DOTMATCH)
774
+ end
775
+ end
776
+ return files
777
+ end
778
+ end
779
+
780
+ # A special mount class specifically for the plugins mount -- just
781
+ # has some magic to effectively do a union mount of the 'plugins'
782
+ # directory of all modules.
783
+ #
784
+ class PluginMount < Mount
785
+ def path(client)
786
+ ''
787
+ end
788
+
789
+ def mod_path_exists?(mod, relpath, client = nil)
790
+ File.exists?(File.join(mod, PLUGINS, relpath))
791
+ end
792
+
793
+ def path_exists?(relpath, client = nil)
794
+ !valid_modules.find { |m| mod_path_exists?(m, relpath, client) }.nil?
795
+ end
796
+
797
+ def valid?
798
+ true
799
+ end
800
+
801
+ def mod_file_path(mod, relpath, client = nil)
802
+ File.join(mod, PLUGINS, relpath)
803
+ end
804
+
805
+ def file_path(relpath, client = nil)
806
+ mod = valid_modules.map { |m| mod_path_exists?(m, relpath, client) ? m : nil }.compact.first
807
+ mod_file_path(mod, relpath, client)
808
+ end
809
+
810
+ # create a list of files by merging all modules
811
+ def list(relpath, recurse, ignore, client = nil)
812
+ result = []
813
+ valid_modules.each do |m|
814
+ ary = reclist(mod_file_path(m, relpath, client), nil, recurse, ignore)
815
+ ary = [] if ary.nil?
816
+ result += ary
817
+ end
818
+ result
819
+ end
820
+
821
+ private
822
+ def valid_modules
823
+ Puppet::Module.all.find_all { |m| File.directory?(File.join(m, PLUGINS)) }
824
+ end
825
+
826
+ def add_to_filetree(f, filetree)
827
+ first, rest = f.split(File::SEPARATOR, 2)
828
+ end
656
829
  end
657
830
  end
658
831
  end
659
832
 
660
- # $Id: fileserver.rb 2653 2007-07-06 00:54:51Z luke $