puppet 0.25.5 → 2.6.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 (1474) hide show
  1. data/CHANGELOG +667 -0
  2. data/LICENSE +2 -2
  3. data/README +5 -1
  4. data/README.queueing +1 -1
  5. data/README.rst +7 -4
  6. data/Rakefile +6 -18
  7. data/bin/filebucket +0 -94
  8. data/bin/pi +2 -47
  9. data/bin/puppet +2 -69
  10. data/bin/puppetca +2 -100
  11. data/bin/puppetd +2 -158
  12. data/bin/puppetdoc +2 -63
  13. data/bin/puppetmasterd +2 -64
  14. data/bin/puppetqd +2 -51
  15. data/bin/puppetrun +2 -127
  16. data/bin/ralsh +2 -87
  17. data/conf/epm.list +2 -2
  18. data/conf/osx/PackageInfo.plist +1 -1
  19. data/conf/redhat/client.init +11 -8
  20. data/conf/redhat/puppet.conf +1 -1
  21. data/conf/redhat/puppet.spec +1 -1
  22. data/conf/redhat/rundir-perms.patch +13 -13
  23. data/conf/redhat/server.init +11 -5
  24. data/conf/solaris/pkginfo +2 -2
  25. data/conf/solaris/smf/puppetd.xml +3 -3
  26. data/conf/solaris/smf/puppetmasterd.xml +3 -3
  27. data/conf/suse/client.init +3 -2
  28. data/conf/suse/puppet.spec +22 -18
  29. data/conf/suse/server.init +12 -11
  30. data/examples/modules/sample-module/README.txt +3 -3
  31. data/examples/modules/sample-module/lib/puppet/parser/functions/hostname_to_dn.rb +4 -4
  32. data/ext/extlookup.rb +94 -96
  33. data/ext/nagios/check_puppet.rb +94 -88
  34. data/ext/nagios/naggen +3 -3
  35. data/ext/puppet-test +27 -3
  36. data/ext/puppetlisten/puppetlisten.rb +39 -39
  37. data/ext/puppetlisten/puppetrun.rb +6 -6
  38. data/ext/puppetstoredconfigclean.rb +49 -43
  39. data/ext/pure_ruby_dsl/dsl_test.rb +7 -0
  40. data/ext/regexp_nodes/regexp_nodes.rb +133 -133
  41. data/ext/yaml_nodes.rb +99 -0
  42. data/install.rb +109 -118
  43. data/lib/puppet.rb +118 -131
  44. data/lib/puppet/agent.rb +86 -119
  45. data/lib/puppet/agent/locker.rb +28 -30
  46. data/lib/puppet/application.rb +276 -184
  47. data/lib/puppet/application/agent.rb +266 -0
  48. data/lib/puppet/application/apply.rb +165 -0
  49. data/lib/puppet/application/cert.rb +85 -0
  50. data/lib/puppet/application/describe.rb +203 -0
  51. data/lib/puppet/application/doc.rb +215 -0
  52. data/lib/puppet/application/filebucket.rb +73 -73
  53. data/lib/puppet/application/kick.rb +212 -0
  54. data/lib/puppet/application/master.rb +156 -0
  55. data/lib/puppet/application/queue.rb +91 -0
  56. data/lib/puppet/application/resource.rb +118 -0
  57. data/lib/puppet/configurer.rb +214 -197
  58. data/lib/puppet/configurer/downloader.rb +63 -63
  59. data/lib/puppet/configurer/fact_handler.rb +51 -51
  60. data/lib/puppet/configurer/plugin_handler.rb +19 -19
  61. data/lib/puppet/daemon.rb +100 -103
  62. data/lib/puppet/defaults.rb +793 -796
  63. data/lib/puppet/dsl.rb +5 -269
  64. data/lib/puppet/dsl/resource_api.rb +120 -0
  65. data/lib/puppet/dsl/resource_type_api.rb +40 -0
  66. data/lib/puppet/error.rb +34 -36
  67. data/lib/puppet/external/base64.rb +8 -8
  68. data/lib/puppet/external/dot.rb +262 -262
  69. data/lib/puppet/external/event-loop/better-definers.rb +297 -297
  70. data/lib/puppet/external/event-loop/event-loop.rb +264 -272
  71. data/lib/puppet/external/event-loop/signal-system.rb +161 -163
  72. data/lib/puppet/external/lock.rb +41 -41
  73. data/lib/puppet/external/nagios.rb +32 -32
  74. data/lib/puppet/external/nagios/base.rb +453 -458
  75. data/lib/puppet/external/nagios/parser.rb +264 -287
  76. data/lib/puppet/external/pson/common.rb +8 -5
  77. data/lib/puppet/external/pson/pure/generator.rb +26 -26
  78. data/lib/puppet/external/pson/pure/parser.rb +43 -48
  79. data/lib/puppet/feature/base.rb +21 -1
  80. data/lib/puppet/feature/pson.rb +4 -4
  81. data/lib/puppet/feature/rack.rb +14 -14
  82. data/lib/puppet/feature/rails.rb +23 -25
  83. data/lib/puppet/file_bucket.rb +4 -0
  84. data/lib/puppet/file_bucket/dipper.rb +99 -0
  85. data/lib/puppet/file_bucket/file.rb +136 -0
  86. data/lib/puppet/file_bucket/file/indirection_hooks.rb +9 -0
  87. data/lib/puppet/file_collection.rb +20 -20
  88. data/lib/puppet/file_collection/lookup.rb +11 -11
  89. data/lib/puppet/file_serving/base.rb +67 -71
  90. data/lib/puppet/file_serving/configuration.rb +84 -86
  91. data/lib/puppet/file_serving/configuration/parser.rb +103 -102
  92. data/lib/puppet/file_serving/content.rb +34 -33
  93. data/lib/puppet/file_serving/fileset.rb +131 -133
  94. data/lib/puppet/file_serving/indirection_hooks.rb +17 -17
  95. data/lib/puppet/file_serving/metadata.rb +98 -95
  96. data/lib/puppet/file_serving/mount.rb +22 -22
  97. data/lib/puppet/file_serving/mount/file.rb +101 -106
  98. data/lib/puppet/file_serving/mount/modules.rb +15 -15
  99. data/lib/puppet/file_serving/mount/plugins.rb +15 -16
  100. data/lib/puppet/file_serving/terminus_helper.rb +13 -13
  101. data/lib/puppet/indirector.rb +48 -49
  102. data/lib/puppet/indirector/active_record.rb +19 -19
  103. data/lib/puppet/indirector/catalog/active_record.rb +25 -25
  104. data/lib/puppet/indirector/catalog/compiler.rb +134 -145
  105. data/lib/puppet/indirector/catalog/rest.rb +1 -1
  106. data/lib/puppet/indirector/catalog/yaml.rb +13 -13
  107. data/lib/puppet/indirector/certificate/ca.rb +3 -3
  108. data/lib/puppet/indirector/certificate/file.rb +3 -3
  109. data/lib/puppet/indirector/certificate/rest.rb +8 -8
  110. data/lib/puppet/indirector/certificate_request/ca.rb +7 -7
  111. data/lib/puppet/indirector/certificate_request/file.rb +2 -2
  112. data/lib/puppet/indirector/certificate_request/rest.rb +3 -3
  113. data/lib/puppet/indirector/certificate_revocation_list/ca.rb +2 -2
  114. data/lib/puppet/indirector/certificate_revocation_list/file.rb +2 -2
  115. data/lib/puppet/indirector/certificate_revocation_list/rest.rb +3 -3
  116. data/lib/puppet/indirector/couch.rb +76 -0
  117. data/lib/puppet/indirector/direct_file_server.rb +11 -11
  118. data/lib/puppet/indirector/envelope.rb +4 -4
  119. data/lib/puppet/indirector/exec.rb +38 -42
  120. data/lib/puppet/indirector/facts/active_record.rb +24 -24
  121. data/lib/puppet/indirector/facts/couch.rb +31 -0
  122. data/lib/puppet/indirector/facts/facter.rb +63 -61
  123. data/lib/puppet/indirector/facts/memory.rb +4 -4
  124. data/lib/puppet/indirector/facts/rest.rb +1 -1
  125. data/lib/puppet/indirector/facts/yaml.rb +2 -2
  126. data/lib/puppet/indirector/file.rb +67 -46
  127. data/lib/puppet/indirector/file_bucket_file/file.rb +146 -0
  128. data/lib/puppet/indirector/file_bucket_file/rest.rb +8 -0
  129. data/lib/puppet/indirector/file_content/file.rb +1 -1
  130. data/lib/puppet/indirector/file_content/file_server.rb +1 -1
  131. data/lib/puppet/indirector/file_content/rest.rb +1 -1
  132. data/lib/puppet/indirector/file_metadata/file.rb +11 -11
  133. data/lib/puppet/indirector/file_metadata/file_server.rb +1 -1
  134. data/lib/puppet/indirector/file_metadata/rest.rb +1 -1
  135. data/lib/puppet/indirector/file_server.rb +44 -44
  136. data/lib/puppet/indirector/indirection.rb +249 -260
  137. data/lib/puppet/indirector/key/ca.rb +5 -5
  138. data/lib/puppet/indirector/key/file.rb +29 -29
  139. data/lib/puppet/indirector/ldap.rb +62 -64
  140. data/lib/puppet/indirector/memory.rb +13 -13
  141. data/lib/puppet/indirector/node/active_record.rb +6 -6
  142. data/lib/puppet/indirector/node/exec.rb +40 -44
  143. data/lib/puppet/indirector/node/ldap.rb +246 -212
  144. data/lib/puppet/indirector/node/memory.rb +5 -5
  145. data/lib/puppet/indirector/node/plain.rb +12 -12
  146. data/lib/puppet/indirector/node/rest.rb +2 -2
  147. data/lib/puppet/indirector/node/yaml.rb +2 -2
  148. data/lib/puppet/indirector/plain.rb +4 -4
  149. data/lib/puppet/indirector/queue.rb +49 -51
  150. data/lib/puppet/indirector/report/processor.rb +34 -37
  151. data/lib/puppet/indirector/report/rest.rb +3 -3
  152. data/lib/puppet/indirector/request.rb +171 -157
  153. data/lib/puppet/indirector/resource/ral.rb +48 -0
  154. data/lib/puppet/indirector/resource/rest.rb +5 -0
  155. data/lib/puppet/indirector/resource_type.rb +5 -0
  156. data/lib/puppet/indirector/resource_type/parser.rb +27 -0
  157. data/lib/puppet/indirector/resource_type/rest.rb +7 -0
  158. data/lib/puppet/indirector/rest.rb +83 -79
  159. data/lib/puppet/indirector/run/local.rb +8 -0
  160. data/lib/puppet/indirector/run/rest.rb +6 -0
  161. data/lib/puppet/indirector/ssl_file.rb +165 -165
  162. data/lib/puppet/indirector/status.rb +3 -0
  163. data/lib/puppet/indirector/status/local.rb +7 -0
  164. data/lib/puppet/indirector/status/rest.rb +5 -0
  165. data/lib/puppet/indirector/terminus.rb +129 -133
  166. data/lib/puppet/indirector/yaml.rb +47 -49
  167. data/lib/puppet/metatype/manager.rb +120 -114
  168. data/lib/puppet/module.rb +182 -124
  169. data/lib/puppet/network/authconfig.rb +146 -156
  170. data/lib/puppet/network/authorization.rb +63 -70
  171. data/lib/puppet/network/authstore.rb +226 -232
  172. data/lib/puppet/network/client.rb +141 -152
  173. data/lib/puppet/network/client/ca.rb +47 -49
  174. data/lib/puppet/network/client/file.rb +3 -3
  175. data/lib/puppet/network/client/proxy.rb +19 -19
  176. data/lib/puppet/network/client/report.rb +17 -21
  177. data/lib/puppet/network/client/runner.rb +5 -7
  178. data/lib/puppet/network/client/status.rb +1 -1
  179. data/lib/puppet/network/client_request.rb +20 -22
  180. data/lib/puppet/network/format.rb +79 -81
  181. data/lib/puppet/network/format_handler.rb +135 -130
  182. data/lib/puppet/network/formats.rb +128 -154
  183. data/lib/puppet/network/handler.rb +43 -46
  184. data/lib/puppet/network/handler/ca.rb +129 -135
  185. data/lib/puppet/network/handler/filebucket.rb +39 -170
  186. data/lib/puppet/network/handler/fileserver.rb +624 -656
  187. data/lib/puppet/network/handler/master.rb +62 -75
  188. data/lib/puppet/network/handler/report.rb +60 -67
  189. data/lib/puppet/network/handler/runner.rb +20 -20
  190. data/lib/puppet/network/handler/status.rb +9 -9
  191. data/lib/puppet/network/http.rb +12 -12
  192. data/lib/puppet/network/http/api/v1.rb +49 -44
  193. data/lib/puppet/network/http/compression.rb +111 -0
  194. data/lib/puppet/network/http/handler.rb +183 -183
  195. data/lib/puppet/network/http/mongrel.rb +46 -48
  196. data/lib/puppet/network/http/mongrel/rest.rb +73 -66
  197. data/lib/puppet/network/http/rack.rb +45 -45
  198. data/lib/puppet/network/http/rack/httphandler.rb +7 -7
  199. data/lib/puppet/network/http/rack/rest.rb +84 -61
  200. data/lib/puppet/network/http/rack/xmlrpc.rb +49 -49
  201. data/lib/puppet/network/http/webrick.rb +108 -112
  202. data/lib/puppet/network/http/webrick/rest.rb +60 -57
  203. data/lib/puppet/network/http_pool.rb +95 -83
  204. data/lib/puppet/network/http_server/mongrel.rb +90 -90
  205. data/lib/puppet/network/http_server/webrick.rb +139 -148
  206. data/lib/puppet/network/rest_authconfig.rb +76 -71
  207. data/lib/puppet/network/rest_authorization.rb +11 -13
  208. data/lib/puppet/network/rights.rb +217 -226
  209. data/lib/puppet/network/server.rb +147 -151
  210. data/lib/puppet/network/xmlrpc/client.rb +197 -205
  211. data/lib/puppet/network/xmlrpc/processor.rb +68 -72
  212. data/lib/puppet/network/xmlrpc/server.rb +10 -10
  213. data/lib/puppet/network/xmlrpc/webrick_servlet.rb +94 -100
  214. data/lib/puppet/node.rb +99 -107
  215. data/lib/puppet/node/environment.rb +109 -62
  216. data/lib/puppet/node/facts.rb +48 -43
  217. data/lib/puppet/parameter.rb +246 -498
  218. data/lib/puppet/parameter/value.rb +63 -0
  219. data/lib/puppet/parameter/value_collection.rb +143 -0
  220. data/lib/puppet/parser.rb +4 -0
  221. data/lib/puppet/parser/ast.rb +81 -67
  222. data/lib/puppet/parser/ast/arithmetic_operator.rb +27 -29
  223. data/lib/puppet/parser/ast/astarray.rb +50 -50
  224. data/lib/puppet/parser/ast/asthash.rb +37 -0
  225. data/lib/puppet/parser/ast/boolean_operator.rb +33 -35
  226. data/lib/puppet/parser/ast/branch.rb +29 -31
  227. data/lib/puppet/parser/ast/caseopt.rb +50 -56
  228. data/lib/puppet/parser/ast/casestatement.rb +30 -30
  229. data/lib/puppet/parser/ast/collection.rb +43 -37
  230. data/lib/puppet/parser/ast/collexpr.rb +66 -69
  231. data/lib/puppet/parser/ast/comparison_operator.rb +32 -35
  232. data/lib/puppet/parser/ast/else.rb +13 -13
  233. data/lib/puppet/parser/ast/function.rb +34 -43
  234. data/lib/puppet/parser/ast/ifstatement.rb +23 -27
  235. data/lib/puppet/parser/ast/in_operator.rb +24 -0
  236. data/lib/puppet/parser/ast/leaf.rb +173 -156
  237. data/lib/puppet/parser/ast/match_operator.rb +16 -19
  238. data/lib/puppet/parser/ast/minus.rb +13 -13
  239. data/lib/puppet/parser/ast/nop.rb +6 -6
  240. data/lib/puppet/parser/ast/not.rb +9 -9
  241. data/lib/puppet/parser/ast/relationship.rb +60 -0
  242. data/lib/puppet/parser/ast/resource.rb +58 -57
  243. data/lib/puppet/parser/ast/resource_defaults.rb +16 -16
  244. data/lib/puppet/parser/ast/resource_override.rb +51 -51
  245. data/lib/puppet/parser/ast/resource_reference.rb +17 -72
  246. data/lib/puppet/parser/ast/resourceparam.rb +20 -17
  247. data/lib/puppet/parser/ast/selector.rb +30 -34
  248. data/lib/puppet/parser/ast/tag.rb +16 -16
  249. data/lib/puppet/parser/ast/vardef.rb +20 -16
  250. data/lib/puppet/parser/collector.rb +181 -189
  251. data/lib/puppet/parser/compiler.rb +395 -364
  252. data/lib/puppet/parser/files.rb +65 -69
  253. data/lib/puppet/parser/functions.rb +85 -97
  254. data/lib/puppet/parser/functions/defined.rb +23 -23
  255. data/lib/puppet/parser/functions/fail.rb +2 -2
  256. data/lib/puppet/parser/functions/file.rb +21 -19
  257. data/lib/puppet/parser/functions/fqdn_rand.rb +7 -7
  258. data/lib/puppet/parser/functions/generate.rb +24 -26
  259. data/lib/puppet/parser/functions/include.rb +16 -18
  260. data/lib/puppet/parser/functions/inline_template.rb +16 -17
  261. data/lib/puppet/parser/functions/realize.rb +8 -8
  262. data/lib/puppet/parser/functions/regsubst.rb +74 -59
  263. data/lib/puppet/parser/functions/require.rb +35 -33
  264. data/lib/puppet/parser/functions/search.rb +5 -5
  265. data/lib/puppet/parser/functions/sha1.rb +3 -4
  266. data/lib/puppet/parser/functions/shellquote.rb +31 -33
  267. data/lib/puppet/parser/functions/split.rb +8 -8
  268. data/lib/puppet/parser/functions/sprintf.rb +10 -9
  269. data/lib/puppet/parser/functions/tag.rb +3 -3
  270. data/lib/puppet/parser/functions/tagged.rb +13 -13
  271. data/lib/puppet/parser/functions/template.rb +18 -19
  272. data/lib/puppet/parser/functions/versioncmp.rb +17 -14
  273. data/lib/puppet/parser/grammar.ra +485 -422
  274. data/lib/puppet/parser/lexer.rb +500 -442
  275. data/lib/puppet/parser/parser.rb +1438 -1084
  276. data/lib/puppet/parser/parser_support.rb +227 -502
  277. data/lib/puppet/parser/relationship.rb +43 -0
  278. data/lib/puppet/parser/resource.rb +280 -375
  279. data/lib/puppet/parser/resource/param.rb +18 -18
  280. data/lib/puppet/parser/scope.rb +450 -447
  281. data/lib/puppet/parser/templatewrapper.rb +92 -94
  282. data/lib/puppet/parser/type_loader.rb +146 -0
  283. data/lib/puppet/parser/yaml_trimmer.rb +6 -8
  284. data/lib/puppet/property.rb +290 -453
  285. data/lib/puppet/property/ensure.rb +92 -0
  286. data/lib/puppet/property/keyvalue.rb +74 -82
  287. data/lib/puppet/property/list.rb +71 -81
  288. data/lib/puppet/property/ordered_list.rb +15 -15
  289. data/lib/puppet/provider.rb +229 -241
  290. data/lib/puppet/provider/augeas/augeas.rb +318 -320
  291. data/lib/puppet/provider/computer/computer.rb +13 -13
  292. data/lib/puppet/provider/confine.rb +63 -63
  293. data/lib/puppet/provider/confine/exists.rb +14 -14
  294. data/lib/puppet/provider/confine/false.rb +12 -12
  295. data/lib/puppet/provider/confine/feature.rb +10 -10
  296. data/lib/puppet/provider/confine/true.rb +13 -13
  297. data/lib/puppet/provider/confine/variable.rb +51 -54
  298. data/lib/puppet/provider/confine_collection.rb +38 -38
  299. data/lib/puppet/provider/confiner.rb +10 -14
  300. data/lib/puppet/provider/cron/crontab.rb +172 -173
  301. data/lib/puppet/provider/file/posix.rb +99 -0
  302. data/lib/puppet/provider/file/win32.rb +74 -0
  303. data/lib/puppet/provider/group/directoryservice.rb +6 -6
  304. data/lib/puppet/provider/group/groupadd.rb +18 -20
  305. data/lib/puppet/provider/group/ldap.rb +40 -43
  306. data/lib/puppet/provider/group/pw.rb +23 -23
  307. data/lib/puppet/provider/host/parsed.rb +51 -50
  308. data/lib/puppet/provider/ldap.rb +121 -123
  309. data/lib/puppet/provider/macauthorization/macauthorization.rb +263 -272
  310. data/lib/puppet/provider/mailalias/aliases.rb +34 -31
  311. data/lib/puppet/provider/maillist/mailman.rb +87 -93
  312. data/lib/puppet/provider/mcx/mcxcontent.rb +155 -151
  313. data/lib/puppet/provider/mount.rb +36 -40
  314. data/lib/puppet/provider/mount/parsed.rb +28 -26
  315. data/lib/puppet/provider/naginator.rb +46 -48
  316. data/lib/puppet/provider/nameservice.rb +215 -257
  317. data/lib/puppet/provider/nameservice/directoryservice.rb +455 -471
  318. data/lib/puppet/provider/nameservice/objectadd.rb +21 -21
  319. data/lib/puppet/provider/nameservice/pw.rb +13 -13
  320. data/lib/puppet/provider/package.rb +18 -20
  321. data/lib/puppet/provider/package/aix.rb +128 -0
  322. data/lib/puppet/provider/package/appdmg.rb +78 -82
  323. data/lib/puppet/provider/package/apple.rb +39 -40
  324. data/lib/puppet/provider/package/apt.rb +95 -104
  325. data/lib/puppet/provider/package/aptitude.rb +19 -21
  326. data/lib/puppet/provider/package/aptrpm.rb +70 -72
  327. data/lib/puppet/provider/package/blastwave.rb +88 -94
  328. data/lib/puppet/provider/package/darwinport.rb +67 -69
  329. data/lib/puppet/provider/package/dpkg.rb +123 -97
  330. data/lib/puppet/provider/package/fink.rb +66 -68
  331. data/lib/puppet/provider/package/freebsd.rb +38 -40
  332. data/lib/puppet/provider/package/gem.rb +98 -102
  333. data/lib/puppet/provider/package/hpux.rb +37 -39
  334. data/lib/puppet/provider/package/nim.rb +35 -0
  335. data/lib/puppet/provider/package/openbsd.rb +100 -75
  336. data/lib/puppet/provider/package/pkg.rb +108 -0
  337. data/lib/puppet/provider/package/pkgdmg.rb +95 -87
  338. data/lib/puppet/provider/package/portage.rb +101 -104
  339. data/lib/puppet/provider/package/ports.rb +71 -73
  340. data/lib/puppet/provider/package/portupgrade.rb +251 -0
  341. data/lib/puppet/provider/package/rpm.rb +113 -115
  342. data/lib/puppet/provider/package/rug.rb +46 -46
  343. data/lib/puppet/provider/package/sun.rb +135 -151
  344. data/lib/puppet/provider/package/sunfreeware.rb +5 -5
  345. data/lib/puppet/provider/package/up2date.rb +31 -31
  346. data/lib/puppet/provider/package/urpmi.rb +51 -51
  347. data/lib/puppet/provider/package/yum.rb +90 -98
  348. data/lib/puppet/provider/package/zypper.rb +52 -0
  349. data/lib/puppet/provider/parsedfile.rb +306 -329
  350. data/lib/puppet/provider/port/parsed.rb +5 -5
  351. data/lib/puppet/provider/selboolean/getsetsebool.rb +34 -34
  352. data/lib/puppet/provider/selmodule/semodule.rb +103 -111
  353. data/lib/puppet/provider/service/base.rb +134 -139
  354. data/lib/puppet/provider/service/bsd.rb +48 -0
  355. data/lib/puppet/provider/service/daemontools.rb +158 -162
  356. data/lib/puppet/provider/service/debian.rb +36 -36
  357. data/lib/puppet/provider/service/freebsd.rb +118 -38
  358. data/lib/puppet/provider/service/gentoo.rb +33 -39
  359. data/lib/puppet/provider/service/init.rb +125 -125
  360. data/lib/puppet/provider/service/launchd.rb +234 -254
  361. data/lib/puppet/provider/service/redhat.rb +58 -58
  362. data/lib/puppet/provider/service/runit.rb +74 -74
  363. data/lib/puppet/provider/service/smf.rb +81 -85
  364. data/lib/puppet/provider/service/src.rb +87 -0
  365. data/lib/puppet/provider/ssh_authorized_key/parsed.rb +73 -81
  366. data/lib/puppet/provider/sshkey/parsed.rb +24 -21
  367. data/lib/puppet/provider/user/directoryservice.rb +71 -71
  368. data/lib/puppet/provider/user/hpux.rb +20 -20
  369. data/lib/puppet/provider/user/ldap.rb +106 -110
  370. data/lib/puppet/provider/user/pw.rb +33 -37
  371. data/lib/puppet/provider/user/user_role_add.rb +168 -183
  372. data/lib/puppet/provider/user/useradd.rb +50 -51
  373. data/lib/puppet/provider/zfs/solaris.rb +35 -35
  374. data/lib/puppet/provider/zone/solaris.rb +206 -205
  375. data/lib/puppet/provider/zpool/solaris.rb +95 -97
  376. data/lib/puppet/rails.rb +115 -122
  377. data/lib/puppet/rails/benchmark.rb +43 -49
  378. data/lib/puppet/rails/database/001_add_created_at_to_all_tables.rb +8 -12
  379. data/lib/puppet/rails/database/002_remove_duplicated_index_on_all_tables.rb +8 -12
  380. data/lib/puppet/rails/database/003_add_environment_to_host.rb +6 -10
  381. data/lib/puppet/rails/database/schema.rb +100 -97
  382. data/lib/puppet/rails/fact_name.rb +1 -1
  383. data/lib/puppet/rails/fact_value.rb +5 -5
  384. data/lib/puppet/rails/host.rb +252 -249
  385. data/lib/puppet/rails/param_name.rb +15 -15
  386. data/lib/puppet/rails/param_value.rb +55 -55
  387. data/lib/puppet/rails/puppet_tag.rb +4 -4
  388. data/lib/puppet/rails/resource.rb +189 -203
  389. data/lib/puppet/rails/resource_tag.rb +19 -19
  390. data/lib/puppet/rails/source_file.rb +5 -5
  391. data/lib/puppet/reference/configuration.rb +53 -56
  392. data/lib/puppet/reference/function.rb +1 -1
  393. data/lib/puppet/reference/indirection.rb +13 -13
  394. data/lib/puppet/reference/metaparameter.rb +40 -40
  395. data/lib/puppet/reference/network.rb +16 -16
  396. data/lib/puppet/reference/providers.rb +97 -98
  397. data/lib/puppet/reference/report.rb +1 -1
  398. data/lib/puppet/reference/type.rb +67 -70
  399. data/lib/puppet/relationship.rb +65 -67
  400. data/lib/puppet/reports.rb +32 -34
  401. data/lib/puppet/reports/http.rb +22 -0
  402. data/lib/puppet/reports/log.rb +7 -6
  403. data/lib/puppet/reports/rrdgraph.rb +105 -114
  404. data/lib/puppet/reports/store.rb +53 -56
  405. data/lib/puppet/reports/tagmail.rb +149 -157
  406. data/lib/puppet/resource.rb +428 -194
  407. data/lib/puppet/resource/catalog.rb +496 -512
  408. data/lib/puppet/resource/status.rb +58 -0
  409. data/lib/puppet/resource/type.rb +311 -0
  410. data/lib/puppet/resource/type_collection.rb +217 -0
  411. data/lib/puppet/resource/type_collection_helper.rb +7 -0
  412. data/lib/puppet/run.rb +77 -0
  413. data/lib/puppet/simple_graph.rb +381 -413
  414. data/lib/puppet/ssl.rb +2 -1
  415. data/lib/puppet/ssl/base.rb +60 -43
  416. data/lib/puppet/ssl/certificate.rb +21 -21
  417. data/lib/puppet/ssl/certificate_authority.rb +215 -229
  418. data/lib/puppet/ssl/certificate_authority/interface.rb +84 -68
  419. data/lib/puppet/ssl/certificate_factory.rb +119 -119
  420. data/lib/puppet/ssl/certificate_request.rb +52 -45
  421. data/lib/puppet/ssl/certificate_revocation_list.rb +78 -78
  422. data/lib/puppet/ssl/host.rb +230 -228
  423. data/lib/puppet/ssl/inventory.rb +33 -33
  424. data/lib/puppet/ssl/key.rb +37 -37
  425. data/lib/puppet/sslcertificates.rb +124 -123
  426. data/lib/puppet/sslcertificates/ca.rb +327 -344
  427. data/lib/puppet/sslcertificates/certificate.rb +197 -224
  428. data/lib/puppet/sslcertificates/inventory.rb +27 -29
  429. data/lib/puppet/sslcertificates/support.rb +113 -119
  430. data/lib/puppet/status.rb +28 -0
  431. data/lib/puppet/transaction.rb +349 -696
  432. data/lib/puppet/transaction/change.rb +80 -85
  433. data/lib/puppet/transaction/event.rb +54 -14
  434. data/lib/puppet/transaction/event_manager.rb +99 -0
  435. data/lib/puppet/transaction/report.rb +121 -59
  436. data/lib/puppet/transaction/resource_harness.rb +150 -0
  437. data/lib/puppet/transportable.rb +215 -226
  438. data/lib/puppet/type.rb +1644 -1849
  439. data/lib/puppet/type/augeas.rb +153 -134
  440. data/lib/puppet/type/component.rb +63 -65
  441. data/lib/puppet/type/computer.rb +44 -44
  442. data/lib/puppet/type/cron.rb +364 -384
  443. data/lib/puppet/type/exec.rb +583 -521
  444. data/lib/puppet/type/file.rb +786 -823
  445. data/lib/puppet/type/file/checksum.rb +23 -240
  446. data/lib/puppet/type/file/content.rb +193 -129
  447. data/lib/puppet/type/file/ensure.rb +149 -153
  448. data/lib/puppet/type/file/group.rb +94 -104
  449. data/lib/puppet/type/file/mode.rb +109 -122
  450. data/lib/puppet/type/file/owner.rb +39 -131
  451. data/lib/puppet/type/file/selcontext.rb +69 -73
  452. data/lib/puppet/type/file/source.rb +165 -153
  453. data/lib/puppet/type/file/target.rb +56 -60
  454. data/lib/puppet/type/file/type.rb +18 -18
  455. data/lib/puppet/type/filebucket.rb +91 -92
  456. data/lib/puppet/type/group.rb +77 -82
  457. data/lib/puppet/type/host.rb +85 -85
  458. data/lib/puppet/type/k5login.rb +65 -65
  459. data/lib/puppet/type/macauthorization.rb +141 -143
  460. data/lib/puppet/type/mailalias.rb +37 -37
  461. data/lib/puppet/type/maillist.rb +51 -51
  462. data/lib/puppet/type/mcx.rb +62 -62
  463. data/lib/puppet/type/mount.rb +199 -193
  464. data/lib/puppet/type/notify.rb +33 -33
  465. data/lib/puppet/type/package.rb +301 -298
  466. data/lib/puppet/type/port.rb +4 -4
  467. data/lib/puppet/type/resources.rb +107 -123
  468. data/lib/puppet/type/schedule.rb +317 -326
  469. data/lib/puppet/type/selboolean.rb +19 -19
  470. data/lib/puppet/type/selmodule.rb +34 -34
  471. data/lib/puppet/type/service.rb +152 -152
  472. data/lib/puppet/type/ssh_authorized_key.rb +74 -78
  473. data/lib/puppet/type/sshkey.rb +52 -56
  474. data/lib/puppet/type/stage.rb +18 -0
  475. data/lib/puppet/type/tidy.rb +289 -300
  476. data/lib/puppet/type/user.rb +300 -312
  477. data/lib/puppet/type/yumrepo.rb +300 -335
  478. data/lib/puppet/type/zfs.rb +36 -36
  479. data/lib/puppet/type/zone.rb +376 -347
  480. data/lib/puppet/type/zpool.rb +71 -77
  481. data/lib/puppet/util.rb +383 -387
  482. data/lib/puppet/util/autoload.rb +125 -143
  483. data/lib/puppet/util/autoload/file_cache.rb +78 -101
  484. data/lib/puppet/util/backups.rb +66 -66
  485. data/lib/puppet/util/cacher.rb +112 -120
  486. data/lib/puppet/util/checksums.rb +119 -84
  487. data/lib/puppet/util/classgen.rb +157 -167
  488. data/lib/puppet/util/command_line.rb +95 -0
  489. data/lib/puppet/util/command_line/filebucket +97 -0
  490. data/lib/puppet/util/command_line/pi +48 -0
  491. data/lib/puppet/util/command_line/puppet +69 -0
  492. data/lib/puppet/util/command_line/puppetca +110 -0
  493. data/lib/puppet/util/command_line/puppetd +186 -0
  494. data/lib/puppet/util/command_line/puppetdoc +67 -0
  495. data/lib/puppet/util/command_line/puppetmasterd +65 -0
  496. data/lib/puppet/util/command_line/puppetqd +53 -0
  497. data/lib/puppet/util/command_line/puppetrun +128 -0
  498. data/lib/puppet/util/command_line/ralsh +89 -0
  499. data/lib/puppet/util/constant_inflector.rb +7 -7
  500. data/lib/puppet/util/diff.rb +59 -56
  501. data/lib/puppet/util/docs.rb +97 -99
  502. data/lib/puppet/util/errors.rb +53 -44
  503. data/lib/puppet/util/execution.rb +15 -15
  504. data/lib/puppet/util/feature.rb +62 -72
  505. data/lib/puppet/util/file_locking.rb +33 -33
  506. data/lib/puppet/util/fileparsing.rb +292 -318
  507. data/lib/puppet/util/filetype.rb +246 -263
  508. data/lib/puppet/util/graph.rb +16 -18
  509. data/lib/puppet/util/inifile.rb +170 -184
  510. data/lib/puppet/util/inline_docs.rb +26 -0
  511. data/lib/puppet/util/instance_loader.rb +58 -58
  512. data/lib/puppet/util/ldap/connection.rb +57 -59
  513. data/lib/puppet/util/ldap/generator.rb +31 -31
  514. data/lib/puppet/util/ldap/manager.rb +233 -235
  515. data/lib/puppet/util/loadedfile.rb +49 -51
  516. data/lib/puppet/util/log.rb +210 -494
  517. data/lib/puppet/util/log/destination.rb +49 -0
  518. data/lib/puppet/util/log/destinations.rb +217 -0
  519. data/lib/puppet/util/log_paths.rb +15 -17
  520. data/lib/puppet/util/logging.rb +34 -13
  521. data/lib/puppet/util/metaid.rb +15 -15
  522. data/lib/puppet/util/methodhelper.rb +24 -26
  523. data/lib/puppet/util/metric.rb +123 -125
  524. data/lib/puppet/util/monkey_patches.rb +21 -20
  525. data/lib/puppet/util/nagios_maker.rb +41 -41
  526. data/lib/puppet/util/package.rb +24 -26
  527. data/lib/puppet/util/pidlock.rb +49 -49
  528. data/lib/puppet/util/posix.rb +115 -115
  529. data/lib/puppet/util/provider_features.rb +147 -155
  530. data/lib/puppet/util/pson.rb +5 -5
  531. data/lib/puppet/util/queue.rb +55 -55
  532. data/lib/puppet/util/queue/stomp.rb +27 -27
  533. data/lib/puppet/util/rails/cache_accumulator.rb +49 -49
  534. data/lib/puppet/util/rails/collection_merger.rb +13 -13
  535. data/lib/puppet/util/rails/reference_serializer.rb +26 -26
  536. data/lib/puppet/util/rdoc.rb +77 -74
  537. data/lib/puppet/util/rdoc/code_objects.rb +235 -217
  538. data/lib/puppet/util/rdoc/generators/puppet_generator.rb +732 -676
  539. data/lib/puppet/util/rdoc/generators/template/puppet/puppet.rb +38 -12
  540. data/lib/puppet/util/rdoc/parser.rb +418 -392
  541. data/lib/puppet/util/reference.rb +168 -174
  542. data/lib/puppet/util/resource_template.rb +17 -17
  543. data/lib/puppet/util/run_mode.rb +81 -0
  544. data/lib/puppet/util/selinux.rb +184 -200
  545. data/lib/puppet/util/settings.rb +886 -919
  546. data/lib/puppet/util/settings/boolean_setting.rb +20 -23
  547. data/lib/puppet/util/settings/file_setting.rb +98 -99
  548. data/lib/puppet/util/settings/setting.rb +71 -87
  549. data/lib/puppet/util/storage.rb +73 -84
  550. data/lib/puppet/util/subclass_loader.rb +59 -66
  551. data/lib/puppet/util/suidmanager.rb +87 -84
  552. data/lib/puppet/util/tagging.rb +37 -39
  553. data/lib/puppet/util/user_attr.rb +14 -14
  554. data/lib/puppet/util/warnings.rb +20 -20
  555. data/lib/puppet/util/zaml.rb +242 -241
  556. data/man/man5/puppet.conf.5 +148 -76
  557. data/man/man8/filebucket.8 +6 -6
  558. data/man/man8/pi.8 +5 -5
  559. data/man/man8/puppet.8 +2 -73
  560. data/man/man8/puppetca.8 +47 -32
  561. data/man/man8/puppetd.8 +118 -76
  562. data/man/man8/puppetdoc.8 +16 -12
  563. data/man/man8/puppetmasterd.8 +4 -4
  564. data/man/man8/puppetqd.8 +4 -4
  565. data/man/man8/puppetrun.8 +23 -22
  566. data/man/man8/ralsh.8 +16 -17
  567. data/spec/fixtures/yaml/test.local.yaml +16 -0
  568. data/spec/integration/application/apply_spec.rb +33 -0
  569. data/spec/integration/configurer_spec.rb +35 -0
  570. data/spec/integration/defaults_spec.rb +258 -0
  571. data/spec/integration/file_serving/content_spec.rb +20 -0
  572. data/spec/integration/file_serving/fileset_spec.rb +14 -0
  573. data/spec/integration/file_serving/metadata_spec.rb +21 -0
  574. data/spec/integration/file_serving/terminus_helper_spec.rb +22 -0
  575. data/spec/integration/indirector/bucket_file/rest_spec.rb +68 -0
  576. data/spec/integration/indirector/catalog/compiler_spec.rb +68 -0
  577. data/spec/integration/indirector/catalog/queue_spec.rb +61 -0
  578. data/spec/integration/indirector/certificate/rest_spec.rb +68 -0
  579. data/spec/integration/indirector/certificate_request/rest_spec.rb +88 -0
  580. data/spec/integration/indirector/certificate_revocation_list/rest_spec.rb +76 -0
  581. data/spec/integration/indirector/direct_file_server_spec.rb +73 -0
  582. data/spec/integration/indirector/file_content/file_server_spec.rb +94 -0
  583. data/spec/integration/indirector/file_metadata/file_server_spec.rb +18 -0
  584. data/spec/integration/indirector/node/ldap_spec.rb +15 -0
  585. data/spec/integration/indirector/report/rest_spec.rb +96 -0
  586. data/spec/integration/indirector/rest_spec.rb +524 -0
  587. data/spec/integration/network/client_spec.rb +19 -0
  588. data/spec/integration/network/formats_spec.rb +110 -0
  589. data/spec/integration/network/handler_spec.rb +25 -0
  590. data/spec/integration/network/server/mongrel_spec.rb +66 -0
  591. data/spec/integration/network/server/webrick_spec.rb +85 -0
  592. data/spec/integration/node/environment_spec.rb +58 -0
  593. data/spec/integration/node/facts_spec.rb +47 -0
  594. data/spec/integration/node_spec.rb +93 -0
  595. data/spec/integration/parser/collector_spec.rb +38 -0
  596. data/spec/integration/parser/compiler_spec.rb +29 -0
  597. data/spec/integration/parser/functions/require_spec.rb +44 -0
  598. data/spec/integration/parser/parser_spec.rb +113 -0
  599. data/spec/integration/provider/mailalias/aliases_spec.rb +25 -0
  600. data/spec/integration/provider/package_spec.rb +26 -0
  601. data/spec/integration/provider/service/init_spec.rb +32 -0
  602. data/spec/integration/reference/providers_spec.rb +17 -0
  603. data/spec/integration/reports_spec.rb +18 -0
  604. data/spec/integration/resource/catalog_spec.rb +61 -0
  605. data/spec/integration/resource/type_collection_spec.rb +96 -0
  606. data/spec/integration/ssl/certificate_authority_spec.rb +135 -0
  607. data/spec/integration/ssl/certificate_request_spec.rb +61 -0
  608. data/spec/integration/ssl/certificate_revocation_list_spec.rb +42 -0
  609. data/spec/integration/ssl/host_spec.rb +90 -0
  610. data/spec/integration/transaction/report_spec.rb +29 -0
  611. data/spec/integration/transaction_spec.rb +284 -0
  612. data/spec/integration/type/file_spec.rb +506 -0
  613. data/spec/integration/type/package_spec.rb +25 -0
  614. data/spec/integration/type/tidy_spec.rb +32 -0
  615. data/spec/integration/type_spec.rb +22 -0
  616. data/spec/integration/util/autoload_spec.rb +114 -0
  617. data/spec/integration/util/feature_spec.rb +54 -0
  618. data/spec/integration/util/file_locking_spec.rb +37 -0
  619. data/spec/integration/util/rdoc/parser_spec.rb +59 -0
  620. data/spec/integration/util/settings_spec.rb +30 -0
  621. data/spec/lib/puppet_spec/files.rb +16 -6
  622. data/spec/monkey_patches/add_confine_and_runnable_to_rspec_dsl.rb +27 -27
  623. data/spec/monkey_patches/alias_should_to_must.rb +4 -4
  624. data/spec/shared_behaviours/file_server_terminus.rb +28 -28
  625. data/spec/shared_behaviours/file_serving.rb +53 -53
  626. data/spec/shared_behaviours/memory_terminus.rb +22 -22
  627. data/spec/spec.opts +1 -0
  628. data/spec/spec_helper.rb +61 -18
  629. data/spec/spec_specs/runnable_spec.rb +95 -0
  630. data/spec/unit/agent/locker_spec.rb +100 -0
  631. data/spec/unit/agent_spec.rb +281 -0
  632. data/spec/unit/application/agent_spec.rb +588 -0
  633. data/spec/unit/application/apply_spec.rb +387 -0
  634. data/spec/unit/application/cert_spec.rb +194 -0
  635. data/spec/unit/application/describe_spec.rb +84 -0
  636. data/spec/unit/application/doc_spec.rb +368 -0
  637. data/spec/unit/application/filebucket_spec.rb +223 -0
  638. data/spec/unit/application/kick_spec.rb +313 -0
  639. data/spec/unit/application/master_spec.rb +453 -0
  640. data/spec/unit/application/queue_spec.rb +186 -0
  641. data/spec/unit/application/resource_spec.rb +233 -0
  642. data/spec/unit/application_spec.rb +531 -0
  643. data/spec/unit/configurer/downloader_spec.rb +188 -0
  644. data/spec/unit/configurer/fact_handler_spec.rb +164 -0
  645. data/spec/unit/configurer/plugin_handler_spec.rb +112 -0
  646. data/spec/unit/configurer_spec.rb +494 -0
  647. data/spec/unit/daemon_spec.rb +306 -0
  648. data/spec/unit/dsl/resource_api_spec.rb +181 -0
  649. data/spec/unit/dsl/resource_type_api_spec.rb +46 -0
  650. data/spec/unit/file_bucket/dipper_spec.rb +122 -0
  651. data/spec/unit/file_bucket/file_spec.rb +230 -0
  652. data/spec/unit/file_collection/lookup_spec.rb +46 -0
  653. data/spec/unit/file_collection_spec.rb +53 -0
  654. data/spec/unit/file_serving/base_spec.rb +132 -0
  655. data/spec/unit/file_serving/configuration/parser_spec.rb +181 -0
  656. data/spec/unit/file_serving/configuration_spec.rb +249 -0
  657. data/spec/unit/file_serving/content_spec.rb +118 -0
  658. data/spec/unit/file_serving/fileset_spec.rb +347 -0
  659. data/spec/unit/file_serving/indirection_hooks_spec.rb +63 -0
  660. data/spec/unit/file_serving/metadata_spec.rb +286 -0
  661. data/spec/unit/file_serving/mount/file_spec.rb +196 -0
  662. data/spec/unit/file_serving/mount/modules_spec.rb +63 -0
  663. data/spec/unit/file_serving/mount/plugins_spec.rb +61 -0
  664. data/spec/unit/file_serving/mount_spec.rb +32 -0
  665. data/spec/unit/file_serving/terminus_helper_spec.rb +98 -0
  666. data/spec/unit/indirector/active_record_spec.rb +76 -0
  667. data/spec/unit/indirector/catalog/active_record_spec.rb +141 -0
  668. data/spec/unit/indirector/catalog/compiler_spec.rb +275 -0
  669. data/spec/unit/indirector/catalog/queue_spec.rb +20 -0
  670. data/spec/unit/indirector/catalog/rest_spec.rb +11 -0
  671. data/spec/unit/indirector/catalog/yaml_spec.rb +25 -0
  672. data/spec/unit/indirector/certificate/ca_spec.rb +28 -0
  673. data/spec/unit/indirector/certificate/file_spec.rb +28 -0
  674. data/spec/unit/indirector/certificate/rest_spec.rb +58 -0
  675. data/spec/unit/indirector/certificate_request/ca_spec.rb +19 -0
  676. data/spec/unit/indirector/certificate_request/file_spec.rb +19 -0
  677. data/spec/unit/indirector/certificate_request/rest_spec.rb +23 -0
  678. data/spec/unit/indirector/certificate_revocation_list/ca_spec.rb +21 -0
  679. data/spec/unit/indirector/certificate_revocation_list/file_spec.rb +20 -0
  680. data/spec/unit/indirector/certificate_revocation_list/rest_spec.rb +23 -0
  681. data/spec/unit/indirector/code_spec.rb +33 -0
  682. data/spec/unit/indirector/direct_file_server_spec.rb +84 -0
  683. data/spec/unit/indirector/envelope_spec.rb +47 -0
  684. data/spec/unit/indirector/exec_spec.rb +56 -0
  685. data/spec/unit/indirector/facts/active_record_spec.rb +104 -0
  686. data/spec/unit/indirector/facts/couch_spec.rb +98 -0
  687. data/spec/unit/indirector/facts/facter_spec.rb +143 -0
  688. data/spec/unit/indirector/facts/rest_spec.rb +11 -0
  689. data/spec/unit/indirector/facts/yaml_spec.rb +26 -0
  690. data/spec/unit/indirector/file_bucket_file/file_spec.rb +290 -0
  691. data/spec/unit/indirector/file_bucket_file/rest_spec.rb +11 -0
  692. data/spec/unit/indirector/file_content/file_server_spec.rb +18 -0
  693. data/spec/unit/indirector/file_content/file_spec.rb +18 -0
  694. data/spec/unit/indirector/file_content/rest_spec.rb +11 -0
  695. data/spec/unit/indirector/file_metadata/file_server_spec.rb +18 -0
  696. data/spec/unit/indirector/file_metadata/file_spec.rb +52 -0
  697. data/spec/unit/indirector/file_metadata/rest_spec.rb +9 -0
  698. data/spec/unit/indirector/file_server_spec.rb +267 -0
  699. data/spec/unit/indirector/file_spec.rb +181 -0
  700. data/spec/unit/indirector/indirection_spec.rb +795 -0
  701. data/spec/unit/indirector/key/ca_spec.rb +28 -0
  702. data/spec/unit/indirector/key/file_spec.rb +104 -0
  703. data/spec/unit/indirector/ldap_spec.rb +143 -0
  704. data/spec/unit/indirector/memory_spec.rb +29 -0
  705. data/spec/unit/indirector/node/active_record_spec.rb +41 -0
  706. data/spec/unit/indirector/node/exec_spec.rb +70 -0
  707. data/spec/unit/indirector/node/ldap_spec.rb +456 -0
  708. data/spec/unit/indirector/node/memory_spec.rb +19 -0
  709. data/spec/unit/indirector/node/plain_spec.rb +19 -0
  710. data/spec/unit/indirector/node/rest_spec.rb +13 -0
  711. data/spec/unit/indirector/node/yaml_spec.rb +25 -0
  712. data/spec/unit/indirector/plain_spec.rb +29 -0
  713. data/spec/unit/indirector/queue_spec.rb +123 -0
  714. data/spec/unit/indirector/report/processor_spec.rb +81 -0
  715. data/spec/unit/indirector/report/rest_spec.rb +28 -0
  716. data/spec/unit/indirector/request_spec.rb +304 -0
  717. data/spec/unit/indirector/resource/ral_spec.rb +129 -0
  718. data/spec/unit/indirector/resource/rest_spec.rb +11 -0
  719. data/spec/unit/indirector/resource_type/parser_spec.rb +75 -0
  720. data/spec/unit/indirector/resource_type/rest_spec.rb +15 -0
  721. data/spec/unit/indirector/rest_spec.rb +455 -0
  722. data/spec/unit/indirector/run/local_spec.rb +20 -0
  723. data/spec/unit/indirector/run/rest_spec.rb +11 -0
  724. data/spec/unit/indirector/ssl_file_spec.rb +281 -0
  725. data/spec/unit/indirector/status/rest_spec.rb +11 -0
  726. data/spec/unit/indirector/terminus_spec.rb +245 -0
  727. data/spec/unit/indirector/yaml_spec.rb +146 -0
  728. data/spec/unit/indirector_spec.rb +157 -0
  729. data/spec/unit/module_spec.rb +547 -0
  730. data/spec/unit/network/authconfig_spec.rb +292 -0
  731. data/spec/unit/network/authstore_spec.rb +370 -0
  732. data/spec/unit/network/client_spec.rb +45 -0
  733. data/spec/unit/network/format_handler_spec.rb +336 -0
  734. data/spec/unit/network/format_spec.rb +198 -0
  735. data/spec/unit/network/formats_spec.rb +337 -0
  736. data/spec/unit/network/handler/fileserver_spec.rb +172 -0
  737. data/spec/unit/network/http/api/v1_spec.rb +122 -0
  738. data/spec/unit/network/http/compression_spec.rb +199 -0
  739. data/spec/unit/network/http/handler_spec.rb +455 -0
  740. data/spec/unit/network/http/mongrel/rest_spec.rb +249 -0
  741. data/spec/unit/network/http/mongrel/{xmlrpc.rb → xmlrpc_spec.rb} +0 -0
  742. data/spec/unit/network/http/mongrel_spec.rb +131 -0
  743. data/spec/unit/network/http/rack/rest_spec.rb +249 -0
  744. data/spec/unit/network/http/rack/xmlrpc_spec.rb +157 -0
  745. data/spec/unit/network/http/rack_spec.rb +102 -0
  746. data/spec/unit/network/http/webrick/rest_spec.rb +180 -0
  747. data/spec/unit/network/http/webrick/{xmlrpc.rb → xmlrpc_spec.rb} +0 -0
  748. data/spec/unit/network/http/webrick_spec.rb +339 -0
  749. data/spec/unit/network/http_pool_spec.rb +206 -0
  750. data/spec/unit/network/http_spec.rb +35 -0
  751. data/spec/unit/network/rest_authconfig_spec.rb +148 -0
  752. data/spec/unit/network/rest_authorization_spec.rb +43 -0
  753. data/spec/unit/network/rights_spec.rb +519 -0
  754. data/spec/unit/network/server_spec.rb +534 -0
  755. data/spec/unit/network/xmlrpc/client_spec.rb +171 -0
  756. data/spec/unit/node/environment_spec.rb +248 -0
  757. data/spec/unit/node/facts_spec.rb +102 -0
  758. data/spec/unit/node_spec.rb +210 -0
  759. data/spec/unit/other/selinux_spec.rb +94 -0
  760. data/spec/unit/other/transbucket_spec.rb +188 -0
  761. data/spec/unit/other/transobject_spec.rb +112 -0
  762. data/spec/unit/parameter/value_collection_spec.rb +167 -0
  763. data/spec/unit/parameter/value_spec.rb +88 -0
  764. data/spec/unit/parameter_spec.rb +172 -0
  765. data/spec/unit/parser/ast/arithmetic_operator_spec.rb +73 -0
  766. data/spec/unit/parser/ast/astarray_spec.rb +72 -0
  767. data/spec/unit/parser/ast/asthash_spec.rb +98 -0
  768. data/spec/unit/parser/ast/boolean_operator_spec.rb +53 -0
  769. data/spec/unit/parser/ast/casestatement_spec.rb +161 -0
  770. data/spec/unit/parser/ast/collection_spec.rb +63 -0
  771. data/spec/unit/parser/ast/collexpr_spec.rb +115 -0
  772. data/spec/unit/parser/ast/comparison_operator_spec.rb +116 -0
  773. data/spec/unit/parser/ast/function_spec.rb +83 -0
  774. data/spec/unit/parser/ast/ifstatement_spec.rb +76 -0
  775. data/spec/unit/parser/ast/in_operator_spec.rb +60 -0
  776. data/spec/unit/parser/ast/leaf_spec.rb +362 -0
  777. data/spec/unit/parser/ast/match_operator_spec.rb +50 -0
  778. data/spec/unit/parser/ast/minus_spec.rb +36 -0
  779. data/spec/unit/parser/ast/nop_spec.rb +20 -0
  780. data/spec/unit/parser/ast/not_spec.rb +30 -0
  781. data/spec/unit/parser/ast/relationship_spec.rb +88 -0
  782. data/spec/unit/parser/ast/resource_defaults_spec.rb +22 -0
  783. data/spec/unit/parser/ast/resource_override_spec.rb +51 -0
  784. data/spec/unit/parser/ast/resource_reference_spec.rb +46 -0
  785. data/spec/unit/parser/ast/resource_spec.rb +120 -0
  786. data/spec/unit/parser/ast/selector_spec.rb +139 -0
  787. data/spec/unit/parser/ast/vardef_spec.rb +60 -0
  788. data/spec/unit/parser/ast_spec.rb +111 -0
  789. data/spec/unit/parser/collector_spec.rb +559 -0
  790. data/spec/unit/parser/compiler_spec.rb +754 -0
  791. data/spec/unit/parser/files_spec.rb +201 -0
  792. data/spec/unit/parser/functions/defined_spec.rb +50 -0
  793. data/spec/unit/parser/functions/fqdn_rand_spec.rb +62 -0
  794. data/spec/unit/parser/functions/generate_spec.rb +41 -0
  795. data/spec/unit/parser/functions/inline_template_spec.rb +59 -0
  796. data/spec/unit/parser/functions/realize_spec.rb +51 -0
  797. data/spec/unit/parser/functions/regsubst_spec.rb +192 -0
  798. data/spec/unit/parser/functions/require_spec.rb +74 -0
  799. data/spec/unit/parser/functions/shellquote_spec.rb +81 -0
  800. data/spec/unit/parser/functions/split_spec.rb +49 -0
  801. data/spec/unit/parser/functions/sprintf_spec.rb +41 -0
  802. data/spec/unit/parser/functions/tag_spec.rb +24 -0
  803. data/spec/unit/parser/functions/template_spec.rb +62 -0
  804. data/spec/unit/parser/functions/versioncmp_spec.rb +29 -0
  805. data/spec/unit/parser/functions_spec.rb +102 -0
  806. data/spec/unit/parser/lexer_spec.rb +646 -0
  807. data/spec/unit/parser/parser_spec.rb +412 -0
  808. data/spec/unit/parser/relationship_spec.rb +70 -0
  809. data/spec/unit/parser/resource_spec.rb +564 -0
  810. data/spec/unit/parser/scope_spec.rb +629 -0
  811. data/spec/unit/parser/templatewrapper_spec.rb +144 -0
  812. data/spec/unit/parser/type_loader_spec.rb +201 -0
  813. data/spec/unit/property/ensure_spec.rb +13 -0
  814. data/spec/unit/property/keyvalue_spec.rb +168 -0
  815. data/spec/unit/property/list_spec.rb +166 -0
  816. data/spec/unit/property/ordered_list_spec.rb +64 -0
  817. data/spec/unit/property_spec.rb +410 -0
  818. data/spec/unit/provider/augeas/augeas_spec.rb +413 -0
  819. data/spec/unit/provider/confine/exists_spec.rb +81 -0
  820. data/spec/unit/provider/confine/false_spec.rb +53 -0
  821. data/spec/unit/provider/confine/feature_spec.rb +60 -0
  822. data/spec/unit/provider/confine/true_spec.rb +53 -0
  823. data/spec/unit/provider/confine/variable_spec.rb +107 -0
  824. data/spec/unit/provider/confine_collection_spec.rb +134 -0
  825. data/spec/unit/provider/confine_spec.rb +78 -0
  826. data/spec/unit/provider/confiner_spec.rb +63 -0
  827. data/spec/unit/provider/group/groupadd_spec.rb +31 -0
  828. data/spec/unit/provider/group/ldap_spec.rb +105 -0
  829. data/spec/unit/provider/ldap_spec.rb +248 -0
  830. data/spec/unit/provider/macauthorization_spec.rb +147 -0
  831. data/spec/unit/provider/mcx/mcxcontent_spec.rb +175 -0
  832. data/spec/unit/provider/mount/parsed_spec.rb +193 -0
  833. data/spec/unit/provider/mount_spec.rb +130 -0
  834. data/spec/unit/provider/naginator_spec.rb +58 -0
  835. data/spec/unit/provider/package/aix_spec.rb +66 -0
  836. data/spec/unit/provider/package/apt_spec.rb +145 -0
  837. data/spec/unit/provider/package/dpkg_spec.rb +225 -0
  838. data/spec/unit/provider/package/gem_spec.rb +87 -0
  839. data/spec/unit/provider/package/hpux_spec.rb +52 -0
  840. data/spec/unit/provider/package/nim_spec.rb +42 -0
  841. data/spec/unit/provider/package/pkg_spec.rb +63 -0
  842. data/spec/unit/provider/package/pkgdmg_spec.rb +84 -0
  843. data/spec/unit/provider/package/zypper_spec.rb +81 -0
  844. data/spec/unit/provider/parsedfile_spec.rb +95 -0
  845. data/spec/unit/provider/selboolean_spec.rb +37 -0
  846. data/spec/unit/provider/selmodule_spec.rb +66 -0
  847. data/spec/unit/provider/service/daemontools_spec.rb +166 -0
  848. data/spec/unit/provider/service/debian_spec.rb +89 -0
  849. data/spec/unit/provider/service/init_spec.rb +168 -0
  850. data/spec/unit/provider/service/launchd_spec.rb +200 -0
  851. data/spec/unit/provider/service/redhat_spec.rb +121 -0
  852. data/spec/unit/provider/service/runit_spec.rb +140 -0
  853. data/spec/unit/provider/service/src_spec.rb +97 -0
  854. data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +228 -0
  855. data/spec/unit/provider/sshkey/parsed_spec.rb +38 -0
  856. data/spec/unit/provider/user/hpux_spec.rb +25 -0
  857. data/spec/unit/provider/user/ldap_spec.rb +279 -0
  858. data/spec/unit/provider/user/user_role_add_spec.rb +249 -0
  859. data/spec/unit/provider/user/useradd_spec.rb +115 -0
  860. data/spec/unit/provider/zfs/solaris_spec.rb +99 -0
  861. data/spec/unit/provider/zone/solaris_spec.rb +55 -0
  862. data/spec/unit/provider/zpool/solaris_spec.rb +179 -0
  863. data/spec/unit/provider_spec.rb +31 -0
  864. data/spec/unit/puppet_spec.rb +12 -0
  865. data/spec/unit/rails/host_spec.rb +163 -0
  866. data/spec/unit/rails/param_value_spec.rb +49 -0
  867. data/spec/unit/rails/resource_spec.rb +123 -0
  868. data/spec/unit/rails_spec.rb +258 -0
  869. data/spec/unit/relationship_spec.rb +236 -0
  870. data/spec/unit/reports/http_spec.rb +56 -0
  871. data/spec/unit/reports/tagmail_spec.rb +94 -0
  872. data/spec/unit/reports_spec.rb +61 -0
  873. data/spec/unit/resource/catalog_spec.rb +1078 -0
  874. data/spec/unit/resource/status_spec.rb +103 -0
  875. data/spec/unit/resource/type_collection_helper_spec.rb +25 -0
  876. data/spec/unit/resource/type_collection_spec.rb +432 -0
  877. data/spec/unit/resource/type_spec.rb +722 -0
  878. data/spec/unit/resource_spec.rb +818 -0
  879. data/spec/unit/run_spec.rb +137 -0
  880. data/spec/unit/simple_graph_spec.rb +544 -0
  881. data/spec/unit/ssl/base_spec.rb +43 -0
  882. data/spec/unit/ssl/certificate_authority/interface_spec.rb +333 -0
  883. data/spec/unit/ssl/certificate_authority_spec.rb +772 -0
  884. data/spec/unit/ssl/certificate_factory_spec.rb +107 -0
  885. data/spec/unit/ssl/certificate_request_spec.rb +220 -0
  886. data/spec/unit/ssl/certificate_revocation_list_spec.rb +168 -0
  887. data/spec/unit/ssl/certificate_spec.rb +124 -0
  888. data/spec/unit/ssl/host_spec.rb +707 -0
  889. data/spec/unit/ssl/inventory_spec.rb +180 -0
  890. data/spec/unit/ssl/key_spec.rb +198 -0
  891. data/spec/unit/status_spec.rb +31 -0
  892. data/spec/unit/transaction/change_spec.rb +193 -0
  893. data/spec/unit/transaction/event_manager_spec.rb +260 -0
  894. data/spec/unit/transaction/event_spec.rb +108 -0
  895. data/spec/unit/transaction/report_spec.rb +234 -0
  896. data/spec/unit/transaction/resource_harness_spec.rb +401 -0
  897. data/spec/unit/transaction_spec.rb +452 -0
  898. data/spec/unit/transportable_spec.rb +0 -0
  899. data/spec/unit/type/augeas_spec.rb +122 -0
  900. data/spec/unit/type/component_spec.rb +63 -0
  901. data/spec/unit/type/computer_spec.rb +81 -0
  902. data/spec/unit/type/cron_spec.rb +33 -0
  903. data/spec/unit/type/exec_spec.rb +162 -0
  904. data/spec/unit/type/file/checksum_spec.rb +73 -0
  905. data/spec/unit/type/file/content_spec.rb +460 -0
  906. data/spec/unit/type/file/ensure_spec.rb +84 -0
  907. data/spec/unit/type/file/group_spec.rb +123 -0
  908. data/spec/unit/type/file/owner_spec.rb +150 -0
  909. data/spec/unit/type/file/selinux_spec.rb +83 -0
  910. data/spec/unit/type/file/source_spec.rb +272 -0
  911. data/spec/unit/type/file_spec.rb +1070 -0
  912. data/spec/unit/type/filebucket_spec.rb +74 -0
  913. data/spec/unit/type/group_spec.rb +57 -0
  914. data/spec/unit/type/macauthorization_spec.rb +111 -0
  915. data/spec/unit/type/maillist_spec.rb +42 -0
  916. data/spec/unit/type/mcx_spec.rb +100 -0
  917. data/spec/unit/type/mount_spec.rb +261 -0
  918. data/spec/unit/type/nagios_spec.rb +63 -0
  919. data/spec/unit/type/noop_metaparam_spec.rb +37 -0
  920. data/spec/unit/type/package_spec.rb +240 -0
  921. data/spec/unit/type/resources_spec.rb +102 -0
  922. data/spec/unit/type/schedule_spec.rb +333 -0
  923. data/spec/unit/type/selboolean_spec.rb +45 -0
  924. data/spec/unit/type/selmodule_spec.rb +18 -0
  925. data/spec/unit/type/service_spec.rb +222 -0
  926. data/spec/unit/type/ssh_authorized_key_spec.rb +152 -0
  927. data/spec/unit/type/stage_spec.rb +9 -0
  928. data/spec/unit/type/tidy_spec.rb +424 -0
  929. data/spec/unit/type/user_spec.rb +281 -0
  930. data/spec/unit/type/zfs_spec.rb +45 -0
  931. data/spec/unit/type/zone_spec.rb +60 -0
  932. data/spec/unit/type/zpool_spec.rb +110 -0
  933. data/spec/unit/type_spec.rb +566 -0
  934. data/spec/unit/util/autoload/file_cache_spec.rb +159 -0
  935. data/spec/unit/util/autoload_spec.rb +120 -0
  936. data/spec/unit/util/backups_spec.rb +159 -0
  937. data/spec/unit/util/cache_accumulator_spec.rb +75 -0
  938. data/spec/unit/util/cacher_spec.rb +185 -0
  939. data/spec/unit/util/checksums_spec.rb +153 -0
  940. data/spec/unit/util/command_line_spec.rb +108 -0
  941. data/spec/unit/util/constant_inflector_spec.rb +70 -0
  942. data/spec/unit/util/errors_spec.rb +38 -0
  943. data/spec/unit/util/feature_spec.rb +72 -0
  944. data/spec/unit/util/file_locking_spec.rb +156 -0
  945. data/spec/unit/util/filetype_spec.rb +100 -0
  946. data/spec/unit/util/inline_docs_spec.rb +32 -0
  947. data/spec/unit/util/json_spec.rb +21 -0
  948. data/spec/unit/util/ldap/connection_spec.rb +169 -0
  949. data/spec/unit/util/ldap/generator_spec.rb +54 -0
  950. data/spec/unit/util/ldap/manager_spec.rb +654 -0
  951. data/spec/unit/util/loadedfile_spec.rb +65 -0
  952. data/spec/unit/util/log/destinations_spec.rb +24 -0
  953. data/spec/unit/util/log_spec.rb +215 -0
  954. data/spec/unit/util/logging_spec.rb +95 -0
  955. data/spec/unit/util/metric_spec.rb +95 -0
  956. data/spec/unit/util/monkey_patches_spec.rb +7 -0
  957. data/spec/unit/util/nagios_maker_spec.rb +126 -0
  958. data/spec/unit/util/package_spec.rb +21 -0
  959. data/spec/unit/util/posix_spec.rb +256 -0
  960. data/spec/unit/util/queue/stomp_spec.rb +140 -0
  961. data/spec/unit/util/queue_spec.rb +96 -0
  962. data/spec/unit/util/rdoc/parser_spec.rb +540 -0
  963. data/spec/unit/util/rdoc_spec.rb +165 -0
  964. data/spec/unit/util/reference_serializer_spec.rb +52 -0
  965. data/spec/unit/util/resource_template_spec.rb +58 -0
  966. data/spec/unit/util/run_mode_spec.rb +51 -0
  967. data/spec/unit/util/selinux_spec.rb +278 -0
  968. data/spec/unit/util/settings/file_setting_spec.rb +256 -0
  969. data/spec/unit/util/settings_spec.rb +1099 -0
  970. data/spec/unit/util/storage_spec.rb +235 -0
  971. data/spec/unit/util/tagging_spec.rb +102 -0
  972. data/spec/unit/util/user_attr_spec.rb +47 -0
  973. data/spec/unit/util/warnings_spec.rb +39 -0
  974. data/spec/unit/util/zaml_spec.rb +38 -0
  975. data/tasks/rake/git_workflow.rake +1 -1
  976. data/tasks/rake/sign.rake +2 -2
  977. data/test/certmgr/ca.rb +61 -61
  978. data/test/certmgr/certmgr.rb +292 -283
  979. data/test/certmgr/inventory.rb +44 -42
  980. data/test/certmgr/support.rb +78 -77
  981. data/test/data/providers/ssh_authorized_key/parsed/authorized_keys +1 -1
  982. data/test/data/snippets/hash.pp +33 -0
  983. data/test/language/ast.rb +68 -117
  984. data/test/language/ast/variable.rb +14 -15
  985. data/test/language/functions.rb +404 -463
  986. data/test/language/parser.rb +670 -1135
  987. data/test/language/scope.rb +198 -402
  988. data/test/language/snippets.rb +439 -447
  989. data/test/language/transportable.rb +67 -66
  990. data/test/lib/puppettest.rb +260 -268
  991. data/test/lib/puppettest/certificates.rb +51 -53
  992. data/test/lib/puppettest/exetest.rb +107 -111
  993. data/test/lib/puppettest/fakes.rb +153 -158
  994. data/test/lib/puppettest/fileparsing.rb +17 -17
  995. data/test/lib/puppettest/filetesting.rb +204 -213
  996. data/test/lib/puppettest/parsertesting.rb +382 -365
  997. data/test/lib/puppettest/railstesting.rb +49 -50
  998. data/test/lib/puppettest/reporttesting.rb +10 -10
  999. data/test/lib/puppettest/resourcetesting.rb +45 -36
  1000. data/test/lib/puppettest/runnable_test.rb +36 -28
  1001. data/test/lib/puppettest/servertest.rb +54 -51
  1002. data/test/lib/puppettest/support/assertions.rb +48 -55
  1003. data/test/lib/puppettest/support/helpers.rb +12 -16
  1004. data/test/lib/puppettest/support/resources.rb +23 -25
  1005. data/test/lib/puppettest/support/utils.rb +138 -148
  1006. data/test/lib/puppettest/testcase.rb +15 -17
  1007. data/test/lib/rake/puppet_test_loader.rb +1 -3
  1008. data/test/lib/rake/puppet_testtask.rb +10 -10
  1009. data/test/network/authconfig.rb +48 -50
  1010. data/test/network/authorization.rb +114 -113
  1011. data/test/network/authstore.rb +454 -406
  1012. data/test/network/client/ca.rb +46 -48
  1013. data/test/network/client/dipper.rb +22 -22
  1014. data/test/network/client_request.rb +20 -20
  1015. data/test/network/handler/ca.rb +251 -252
  1016. data/test/network/handler/fileserver.rb +1071 -1001
  1017. data/test/network/handler/master.rb +58 -58
  1018. data/test/network/handler/report.rb +64 -64
  1019. data/test/network/handler/runner.rb +8 -8
  1020. data/test/network/rights.rb +22 -19
  1021. data/test/network/server/mongrel_test.rb +87 -87
  1022. data/test/network/server/webrick.rb +99 -87
  1023. data/test/network/xmlrpc/client.rb +30 -30
  1024. data/test/network/xmlrpc/processor.rb +52 -53
  1025. data/test/network/xmlrpc/server.rb +10 -11
  1026. data/test/network/xmlrpc/webrick_servlet.rb +21 -18
  1027. data/test/other/provider.rb +69 -84
  1028. data/test/other/puppet.rb +61 -76
  1029. data/test/other/relationships.rb +73 -65
  1030. data/test/other/report.rb +88 -187
  1031. data/test/other/transactions.rb +363 -885
  1032. data/test/puppet/defaults.rb +51 -54
  1033. data/test/puppet/errortest.rb +8 -8
  1034. data/test/puppet/tc_suidmanager.rb +106 -103
  1035. data/test/rails/rails.rb +8 -9
  1036. data/test/rails/railsparameter.rb +60 -54
  1037. data/test/ral/manager/attributes.rb +262 -260
  1038. data/test/ral/manager/instances.rb +77 -78
  1039. data/test/ral/manager/manager.rb +36 -36
  1040. data/test/ral/manager/provider.rb +56 -79
  1041. data/test/ral/manager/type.rb +308 -449
  1042. data/test/ral/providers/cron/crontab.rb +561 -545
  1043. data/test/ral/providers/group.rb +203 -212
  1044. data/test/ral/providers/host/parsed.rb +189 -180
  1045. data/test/ral/providers/mailalias/aliases.rb +40 -40
  1046. data/test/ral/providers/nameservice.rb +21 -21
  1047. data/test/ral/providers/package.rb +207 -214
  1048. data/test/ral/providers/package/aptitude.rb +75 -63
  1049. data/test/ral/providers/package/aptrpm.rb +84 -72
  1050. data/test/ral/providers/parsedfile.rb +510 -509
  1051. data/test/ral/providers/port/parsed.rb +5 -5
  1052. data/test/ral/providers/provider.rb +421 -421
  1053. data/test/ral/providers/service/base.rb +59 -53
  1054. data/test/ral/providers/sshkey/parsed.rb +86 -83
  1055. data/test/ral/providers/user.rb +471 -451
  1056. data/test/ral/providers/user/useradd.rb +168 -177
  1057. data/test/ral/type/cron.rb +406 -393
  1058. data/test/ral/type/exec.rb +721 -641
  1059. data/test/ral/type/file.rb +827 -896
  1060. data/test/ral/type/file/target.rb +295 -251
  1061. data/test/ral/type/fileignoresource.rb +232 -205
  1062. data/test/ral/type/filesources.rb +446 -485
  1063. data/test/ral/type/host.rb +124 -153
  1064. data/test/ral/type/mailalias.rb +28 -31
  1065. data/test/ral/type/port.rb +7 -7
  1066. data/test/ral/type/resources.rb +88 -93
  1067. data/test/ral/type/service.rb +19 -19
  1068. data/test/ral/type/sshkey.rb +120 -160
  1069. data/test/ral/type/user.rb +132 -414
  1070. data/test/ral/type/yumrepo.rb +95 -92
  1071. data/test/ral/type/zone.rb +316 -287
  1072. data/test/test +1 -1
  1073. data/test/util/classgen.rb +182 -167
  1074. data/test/util/execution.rb +18 -18
  1075. data/test/util/fileparsing.rb +580 -540
  1076. data/test/util/inifile.rb +117 -106
  1077. data/test/util/instance_loader.rb +29 -29
  1078. data/test/util/log.rb +202 -198
  1079. data/test/util/metrics.rb +51 -51
  1080. data/test/util/package.rb +11 -12
  1081. data/test/util/pidlock.rb +115 -115
  1082. data/test/util/settings.rb +613 -557
  1083. data/test/util/storage.rb +71 -88
  1084. data/test/util/subclass_loader.rb +69 -72
  1085. data/test/util/utiltest.rb +204 -203
  1086. metadata +493 -395
  1087. data/lib/puppet/agent/runner.rb +0 -65
  1088. data/lib/puppet/application/pi.rb +0 -214
  1089. data/lib/puppet/application/puppet.rb +0 -181
  1090. data/lib/puppet/application/puppetca.rb +0 -71
  1091. data/lib/puppet/application/puppetd.rb +0 -250
  1092. data/lib/puppet/application/puppetdoc.rb +0 -224
  1093. data/lib/puppet/application/puppetmasterd.rb +0 -168
  1094. data/lib/puppet/application/puppetqd.rb +0 -96
  1095. data/lib/puppet/application/puppetrun.rb +0 -210
  1096. data/lib/puppet/application/ralsh.rb +0 -152
  1097. data/lib/puppet/checksum.rb +0 -57
  1098. data/lib/puppet/indirector/checksum/file.rb +0 -33
  1099. data/lib/puppet/indirector/runner/rest.rb +0 -7
  1100. data/lib/puppet/network/client/dipper.rb +0 -85
  1101. data/lib/puppet/network/client/resource.rb +0 -38
  1102. data/lib/puppet/network/handler/resource.rb +0 -190
  1103. data/lib/puppet/parser/ast/definition.rb +0 -207
  1104. data/lib/puppet/parser/ast/hostclass.rb +0 -95
  1105. data/lib/puppet/parser/ast/node.rb +0 -42
  1106. data/lib/puppet/parser/interpreter.rb +0 -84
  1107. data/lib/puppet/parser/loaded_code.rb +0 -119
  1108. data/lib/puppet/parser/resource/reference.rb +0 -99
  1109. data/lib/puppet/resource/reference.rb +0 -90
  1110. data/lib/puppet/util/config_store.rb +0 -61
  1111. data/spec/integration/application/puppet.rb +0 -33
  1112. data/spec/integration/bin/puppetmasterd.rb +0 -122
  1113. data/spec/integration/checksum.rb +0 -48
  1114. data/spec/integration/configurer.rb +0 -18
  1115. data/spec/integration/defaults.rb +0 -230
  1116. data/spec/integration/file_serving/content.rb +0 -20
  1117. data/spec/integration/file_serving/fileset.rb +0 -14
  1118. data/spec/integration/file_serving/metadata.rb +0 -21
  1119. data/spec/integration/file_serving/terminus_helper.rb +0 -22
  1120. data/spec/integration/indirector/catalog/compiler.rb +0 -67
  1121. data/spec/integration/indirector/catalog/queue.rb +0 -61
  1122. data/spec/integration/indirector/certificate/rest.rb +0 -70
  1123. data/spec/integration/indirector/certificate_request/rest.rb +0 -88
  1124. data/spec/integration/indirector/certificate_revocation_list/rest.rb +0 -76
  1125. data/spec/integration/indirector/direct_file_server.rb +0 -73
  1126. data/spec/integration/indirector/file_content/file_server.rb +0 -94
  1127. data/spec/integration/indirector/file_metadata/file_server.rb +0 -18
  1128. data/spec/integration/indirector/node/ldap.rb +0 -15
  1129. data/spec/integration/indirector/report/rest.rb +0 -94
  1130. data/spec/integration/indirector/rest.rb +0 -523
  1131. data/spec/integration/network/client.rb +0 -19
  1132. data/spec/integration/network/formats.rb +0 -110
  1133. data/spec/integration/network/handler.rb +0 -25
  1134. data/spec/integration/network/server/mongrel.rb +0 -66
  1135. data/spec/integration/network/server/webrick.rb +0 -86
  1136. data/spec/integration/node.rb +0 -93
  1137. data/spec/integration/node/environment.rb +0 -58
  1138. data/spec/integration/node/facts.rb +0 -47
  1139. data/spec/integration/parser/compiler.rb +0 -29
  1140. data/spec/integration/parser/functions/require.rb +0 -86
  1141. data/spec/integration/provider/mailalias/aliases.rb +0 -25
  1142. data/spec/integration/provider/package.rb +0 -26
  1143. data/spec/integration/provider/service/init.rb +0 -32
  1144. data/spec/integration/reference/providers.rb +0 -17
  1145. data/spec/integration/reports.rb +0 -18
  1146. data/spec/integration/resource/catalog.rb +0 -61
  1147. data/spec/integration/ssl/certificate_authority.rb +0 -135
  1148. data/spec/integration/ssl/certificate_request.rb +0 -61
  1149. data/spec/integration/ssl/certificate_revocation_list.rb +0 -42
  1150. data/spec/integration/ssl/host.rb +0 -90
  1151. data/spec/integration/transaction.rb +0 -66
  1152. data/spec/integration/transaction/report.rb +0 -29
  1153. data/spec/integration/type.rb +0 -22
  1154. data/spec/integration/type/file.rb +0 -477
  1155. data/spec/integration/type/package.rb +0 -25
  1156. data/spec/integration/type/tidy.rb +0 -27
  1157. data/spec/integration/util/autoload.rb +0 -114
  1158. data/spec/integration/util/feature.rb +0 -54
  1159. data/spec/integration/util/file_locking.rb +0 -37
  1160. data/spec/integration/util/settings.rb +0 -27
  1161. data/spec/unit/agent.rb +0 -259
  1162. data/spec/unit/agent/locker.rb +0 -100
  1163. data/spec/unit/agent/runner.rb +0 -118
  1164. data/spec/unit/application.rb +0 -420
  1165. data/spec/unit/application/filebucket.rb +0 -220
  1166. data/spec/unit/application/pi.rb +0 -84
  1167. data/spec/unit/application/puppet.rb +0 -399
  1168. data/spec/unit/application/puppetca.rb +0 -142
  1169. data/spec/unit/application/puppetd.rb +0 -502
  1170. data/spec/unit/application/puppetdoc.rb +0 -360
  1171. data/spec/unit/application/puppetmasterd.rb +0 -457
  1172. data/spec/unit/application/puppetqd.rb +0 -186
  1173. data/spec/unit/application/puppetrun.rb +0 -289
  1174. data/spec/unit/application/ralsh.rb +0 -254
  1175. data/spec/unit/configurer.rb +0 -339
  1176. data/spec/unit/configurer/downloader.rb +0 -188
  1177. data/spec/unit/configurer/fact_handler.rb +0 -164
  1178. data/spec/unit/configurer/plugin_handler.rb +0 -112
  1179. data/spec/unit/daemon.rb +0 -287
  1180. data/spec/unit/file_collection.rb +0 -53
  1181. data/spec/unit/file_collection/lookup.rb +0 -46
  1182. data/spec/unit/file_serving/base.rb +0 -132
  1183. data/spec/unit/file_serving/configuration.rb +0 -249
  1184. data/spec/unit/file_serving/configuration/parser.rb +0 -181
  1185. data/spec/unit/file_serving/content.rb +0 -110
  1186. data/spec/unit/file_serving/fileset.rb +0 -347
  1187. data/spec/unit/file_serving/indirection_hooks.rb +0 -63
  1188. data/spec/unit/file_serving/metadata.rb +0 -286
  1189. data/spec/unit/file_serving/mount.rb +0 -32
  1190. data/spec/unit/file_serving/mount/file.rb +0 -196
  1191. data/spec/unit/file_serving/mount/modules.rb +0 -63
  1192. data/spec/unit/file_serving/mount/plugins.rb +0 -61
  1193. data/spec/unit/file_serving/terminus_helper.rb +0 -98
  1194. data/spec/unit/indirector.rb +0 -157
  1195. data/spec/unit/indirector/active_record.rb +0 -76
  1196. data/spec/unit/indirector/catalog/active_record.rb +0 -141
  1197. data/spec/unit/indirector/catalog/compiler.rb +0 -261
  1198. data/spec/unit/indirector/catalog/queue.rb +0 -20
  1199. data/spec/unit/indirector/catalog/rest.rb +0 -11
  1200. data/spec/unit/indirector/catalog/yaml.rb +0 -25
  1201. data/spec/unit/indirector/certificate/ca.rb +0 -28
  1202. data/spec/unit/indirector/certificate/file.rb +0 -28
  1203. data/spec/unit/indirector/certificate/rest.rb +0 -57
  1204. data/spec/unit/indirector/certificate_request/ca.rb +0 -19
  1205. data/spec/unit/indirector/certificate_request/file.rb +0 -19
  1206. data/spec/unit/indirector/certificate_request/rest.rb +0 -23
  1207. data/spec/unit/indirector/certificate_revocation_list/ca.rb +0 -21
  1208. data/spec/unit/indirector/certificate_revocation_list/file.rb +0 -20
  1209. data/spec/unit/indirector/certificate_revocation_list/rest.rb +0 -23
  1210. data/spec/unit/indirector/checksum/file.rb +0 -139
  1211. data/spec/unit/indirector/code.rb +0 -33
  1212. data/spec/unit/indirector/direct_file_server.rb +0 -84
  1213. data/spec/unit/indirector/envelope.rb +0 -47
  1214. data/spec/unit/indirector/exec.rb +0 -56
  1215. data/spec/unit/indirector/facts/active_record.rb +0 -104
  1216. data/spec/unit/indirector/facts/facter.rb +0 -142
  1217. data/spec/unit/indirector/facts/rest.rb +0 -11
  1218. data/spec/unit/indirector/facts/yaml.rb +0 -26
  1219. data/spec/unit/indirector/file.rb +0 -161
  1220. data/spec/unit/indirector/file_content/file.rb +0 -18
  1221. data/spec/unit/indirector/file_content/file_server.rb +0 -18
  1222. data/spec/unit/indirector/file_content/rest.rb +0 -11
  1223. data/spec/unit/indirector/file_metadata/file.rb +0 -52
  1224. data/spec/unit/indirector/file_metadata/file_server.rb +0 -18
  1225. data/spec/unit/indirector/file_metadata/rest.rb +0 -9
  1226. data/spec/unit/indirector/file_server.rb +0 -267
  1227. data/spec/unit/indirector/indirection.rb +0 -795
  1228. data/spec/unit/indirector/key/ca.rb +0 -28
  1229. data/spec/unit/indirector/key/file.rb +0 -104
  1230. data/spec/unit/indirector/ldap.rb +0 -143
  1231. data/spec/unit/indirector/memory.rb +0 -29
  1232. data/spec/unit/indirector/node/active_record.rb +0 -34
  1233. data/spec/unit/indirector/node/exec.rb +0 -69
  1234. data/spec/unit/indirector/node/ldap.rb +0 -458
  1235. data/spec/unit/indirector/node/memory.rb +0 -19
  1236. data/spec/unit/indirector/node/plain.rb +0 -19
  1237. data/spec/unit/indirector/node/rest.rb +0 -13
  1238. data/spec/unit/indirector/node/yaml.rb +0 -25
  1239. data/spec/unit/indirector/plain.rb +0 -29
  1240. data/spec/unit/indirector/queue.rb +0 -123
  1241. data/spec/unit/indirector/report/processor.rb +0 -81
  1242. data/spec/unit/indirector/report/rest.rb +0 -28
  1243. data/spec/unit/indirector/request.rb +0 -308
  1244. data/spec/unit/indirector/rest.rb +0 -403
  1245. data/spec/unit/indirector/runner/rest.rb +0 -11
  1246. data/spec/unit/indirector/ssl_file.rb +0 -280
  1247. data/spec/unit/indirector/terminus.rb +0 -245
  1248. data/spec/unit/indirector/yaml.rb +0 -145
  1249. data/spec/unit/module.rb +0 -247
  1250. data/spec/unit/network/authconfig.rb +0 -292
  1251. data/spec/unit/network/authstore.rb +0 -370
  1252. data/spec/unit/network/client.rb +0 -45
  1253. data/spec/unit/network/client/dipper.rb +0 -16
  1254. data/spec/unit/network/format.rb +0 -191
  1255. data/spec/unit/network/format_handler.rb +0 -327
  1256. data/spec/unit/network/formats.rb +0 -365
  1257. data/spec/unit/network/handler/fileserver.rb +0 -176
  1258. data/spec/unit/network/http.rb +0 -35
  1259. data/spec/unit/network/http/api/v1.rb +0 -122
  1260. data/spec/unit/network/http/handler.rb +0 -458
  1261. data/spec/unit/network/http/mongrel.rb +0 -131
  1262. data/spec/unit/network/http/mongrel/rest.rb +0 -232
  1263. data/spec/unit/network/http/rack.rb +0 -102
  1264. data/spec/unit/network/http/rack/rest.rb +0 -199
  1265. data/spec/unit/network/http/rack/xmlrpc.rb +0 -157
  1266. data/spec/unit/network/http/webrick.rb +0 -339
  1267. data/spec/unit/network/http/webrick/rest.rb +0 -157
  1268. data/spec/unit/network/http_pool.rb +0 -206
  1269. data/spec/unit/network/rest_authconfig.rb +0 -146
  1270. data/spec/unit/network/rest_authorization.rb +0 -43
  1271. data/spec/unit/network/rights.rb +0 -519
  1272. data/spec/unit/network/server.rb +0 -534
  1273. data/spec/unit/network/xmlrpc/client.rb +0 -171
  1274. data/spec/unit/node.rb +0 -200
  1275. data/spec/unit/node/environment.rb +0 -187
  1276. data/spec/unit/node/facts.rb +0 -97
  1277. data/spec/unit/other/checksum.rb +0 -92
  1278. data/spec/unit/other/selinux.rb +0 -85
  1279. data/spec/unit/other/transbucket.rb +0 -188
  1280. data/spec/unit/other/transobject.rb +0 -112
  1281. data/spec/unit/parameter.rb +0 -405
  1282. data/spec/unit/parser/ast.rb +0 -41
  1283. data/spec/unit/parser/ast/arithmetic_operator.rb +0 -73
  1284. data/spec/unit/parser/ast/astarray.rb +0 -72
  1285. data/spec/unit/parser/ast/boolean_operator.rb +0 -53
  1286. data/spec/unit/parser/ast/casestatement.rb +0 -135
  1287. data/spec/unit/parser/ast/collection.rb +0 -63
  1288. data/spec/unit/parser/ast/collexpr.rb +0 -115
  1289. data/spec/unit/parser/ast/comparison_operator.rb +0 -92
  1290. data/spec/unit/parser/ast/definition.rb +0 -213
  1291. data/spec/unit/parser/ast/function.rb +0 -83
  1292. data/spec/unit/parser/ast/hostclass.rb +0 -148
  1293. data/spec/unit/parser/ast/ifstatement.rb +0 -76
  1294. data/spec/unit/parser/ast/leaf.rb +0 -298
  1295. data/spec/unit/parser/ast/match_operator.rb +0 -50
  1296. data/spec/unit/parser/ast/minus.rb +0 -36
  1297. data/spec/unit/parser/ast/node.rb +0 -145
  1298. data/spec/unit/parser/ast/nop.rb +0 -20
  1299. data/spec/unit/parser/ast/not.rb +0 -30
  1300. data/spec/unit/parser/ast/resource.rb +0 -103
  1301. data/spec/unit/parser/ast/resource_override.rb +0 -51
  1302. data/spec/unit/parser/ast/resource_reference.rb +0 -69
  1303. data/spec/unit/parser/ast/selector.rb +0 -155
  1304. data/spec/unit/parser/ast/vardef.rb +0 -47
  1305. data/spec/unit/parser/collector.rb +0 -556
  1306. data/spec/unit/parser/compiler.rb +0 -604
  1307. data/spec/unit/parser/files.rb +0 -190
  1308. data/spec/unit/parser/functions.rb +0 -83
  1309. data/spec/unit/parser/functions/fqdn_rand.rb +0 -62
  1310. data/spec/unit/parser/functions/generate.rb +0 -41
  1311. data/spec/unit/parser/functions/inline_template.rb +0 -59
  1312. data/spec/unit/parser/functions/realize.rb +0 -51
  1313. data/spec/unit/parser/functions/regsubst.rb +0 -168
  1314. data/spec/unit/parser/functions/require.rb +0 -69
  1315. data/spec/unit/parser/functions/shellquote.rb +0 -92
  1316. data/spec/unit/parser/functions/split.rb +0 -51
  1317. data/spec/unit/parser/functions/sprintf.rb +0 -42
  1318. data/spec/unit/parser/functions/template.rb +0 -62
  1319. data/spec/unit/parser/functions/versioncmp.rb +0 -29
  1320. data/spec/unit/parser/interpreter.rb +0 -147
  1321. data/spec/unit/parser/lexer.rb +0 -731
  1322. data/spec/unit/parser/loaded_code.rb +0 -215
  1323. data/spec/unit/parser/parser.rb +0 -423
  1324. data/spec/unit/parser/resource.rb +0 -529
  1325. data/spec/unit/parser/resource/reference.rb +0 -111
  1326. data/spec/unit/parser/scope.rb +0 -387
  1327. data/spec/unit/parser/templatewrapper.rb +0 -134
  1328. data/spec/unit/property.rb +0 -305
  1329. data/spec/unit/property/keyvalue.rb +0 -168
  1330. data/spec/unit/property/list.rb +0 -166
  1331. data/spec/unit/property/ordered_list.rb +0 -64
  1332. data/spec/unit/provider.rb +0 -31
  1333. data/spec/unit/provider/augeas/augeas.rb +0 -413
  1334. data/spec/unit/provider/confine.rb +0 -78
  1335. data/spec/unit/provider/confine/exists.rb +0 -81
  1336. data/spec/unit/provider/confine/false.rb +0 -53
  1337. data/spec/unit/provider/confine/feature.rb +0 -60
  1338. data/spec/unit/provider/confine/true.rb +0 -53
  1339. data/spec/unit/provider/confine/variable.rb +0 -107
  1340. data/spec/unit/provider/confine_collection.rb +0 -134
  1341. data/spec/unit/provider/confiner.rb +0 -63
  1342. data/spec/unit/provider/group/groupadd.rb +0 -31
  1343. data/spec/unit/provider/group/ldap.rb +0 -105
  1344. data/spec/unit/provider/ldap.rb +0 -248
  1345. data/spec/unit/provider/macauthorization.rb +0 -147
  1346. data/spec/unit/provider/mcx/mcxcontent.rb +0 -175
  1347. data/spec/unit/provider/mount.rb +0 -130
  1348. data/spec/unit/provider/mount/parsed.rb +0 -194
  1349. data/spec/unit/provider/naginator.rb +0 -58
  1350. data/spec/unit/provider/package/apt.rb +0 -138
  1351. data/spec/unit/provider/package/dpkg.rb +0 -170
  1352. data/spec/unit/provider/package/gem.rb +0 -87
  1353. data/spec/unit/provider/package/hpux.rb +0 -52
  1354. data/spec/unit/provider/package/pkgdmg.rb +0 -73
  1355. data/spec/unit/provider/parsedfile.rb +0 -95
  1356. data/spec/unit/provider/selboolean.rb +0 -37
  1357. data/spec/unit/provider/selmodule.rb +0 -66
  1358. data/spec/unit/provider/service/daemontools.rb +0 -166
  1359. data/spec/unit/provider/service/debian.rb +0 -89
  1360. data/spec/unit/provider/service/init.rb +0 -121
  1361. data/spec/unit/provider/service/launchd.rb +0 -200
  1362. data/spec/unit/provider/service/redhat.rb +0 -96
  1363. data/spec/unit/provider/service/runit.rb +0 -140
  1364. data/spec/unit/provider/ssh_authorized_key/parsed.rb +0 -206
  1365. data/spec/unit/provider/sshkey/parsed.rb +0 -38
  1366. data/spec/unit/provider/user/hpux.rb +0 -25
  1367. data/spec/unit/provider/user/ldap.rb +0 -279
  1368. data/spec/unit/provider/user/user_role_add.rb +0 -249
  1369. data/spec/unit/provider/user/useradd.rb +0 -115
  1370. data/spec/unit/provider/zfs/solaris.rb +0 -99
  1371. data/spec/unit/provider/zone/solaris.rb +0 -42
  1372. data/spec/unit/provider/zpool/solaris.rb +0 -179
  1373. data/spec/unit/rails.rb +0 -133
  1374. data/spec/unit/rails/host.rb +0 -163
  1375. data/spec/unit/rails/param_value.rb +0 -49
  1376. data/spec/unit/rails/resource.rb +0 -107
  1377. data/spec/unit/relationship.rb +0 -236
  1378. data/spec/unit/reports.rb +0 -61
  1379. data/spec/unit/resource.rb +0 -495
  1380. data/spec/unit/resource/catalog.rb +0 -1053
  1381. data/spec/unit/resource/reference.rb +0 -111
  1382. data/spec/unit/simple_graph.rb +0 -551
  1383. data/spec/unit/ssl/certificate.rb +0 -124
  1384. data/spec/unit/ssl/certificate_authority.rb +0 -741
  1385. data/spec/unit/ssl/certificate_authority/interface.rb +0 -269
  1386. data/spec/unit/ssl/certificate_factory.rb +0 -107
  1387. data/spec/unit/ssl/certificate_request.rb +0 -193
  1388. data/spec/unit/ssl/certificate_revocation_list.rb +0 -168
  1389. data/spec/unit/ssl/host.rb +0 -704
  1390. data/spec/unit/ssl/inventory.rb +0 -180
  1391. data/spec/unit/ssl/key.rb +0 -198
  1392. data/spec/unit/transaction.rb +0 -146
  1393. data/spec/unit/transaction/change.rb +0 -187
  1394. data/spec/unit/transaction/event.rb +0 -25
  1395. data/spec/unit/transaction/report.rb +0 -40
  1396. data/spec/unit/type.rb +0 -426
  1397. data/spec/unit/type/augeas.rb +0 -106
  1398. data/spec/unit/type/component.rb +0 -63
  1399. data/spec/unit/type/computer.rb +0 -78
  1400. data/spec/unit/type/cron.rb +0 -33
  1401. data/spec/unit/type/exec.rb +0 -116
  1402. data/spec/unit/type/file.rb +0 -810
  1403. data/spec/unit/type/file/checksum.rb +0 -28
  1404. data/spec/unit/type/file/content.rb +0 -297
  1405. data/spec/unit/type/file/ensure.rb +0 -84
  1406. data/spec/unit/type/file/group.rb +0 -123
  1407. data/spec/unit/type/file/owner.rb +0 -143
  1408. data/spec/unit/type/file/selinux.rb +0 -84
  1409. data/spec/unit/type/file/source.rb +0 -264
  1410. data/spec/unit/type/filebucket.rb +0 -74
  1411. data/spec/unit/type/group.rb +0 -39
  1412. data/spec/unit/type/macauthorization.rb +0 -111
  1413. data/spec/unit/type/maillist.rb +0 -42
  1414. data/spec/unit/type/mcx.rb +0 -100
  1415. data/spec/unit/type/mount.rb +0 -211
  1416. data/spec/unit/type/nagios.rb +0 -63
  1417. data/spec/unit/type/noop_metaparam.rb +0 -37
  1418. data/spec/unit/type/package.rb +0 -236
  1419. data/spec/unit/type/resources.rb +0 -89
  1420. data/spec/unit/type/schedule.rb +0 -333
  1421. data/spec/unit/type/selboolean.rb +0 -45
  1422. data/spec/unit/type/selmodule.rb +0 -18
  1423. data/spec/unit/type/service.rb +0 -230
  1424. data/spec/unit/type/ssh_authorized_key.rb +0 -140
  1425. data/spec/unit/type/tidy.rb +0 -422
  1426. data/spec/unit/type/user.rb +0 -285
  1427. data/spec/unit/type/zfs.rb +0 -45
  1428. data/spec/unit/type/zone.rb +0 -20
  1429. data/spec/unit/type/zpool.rb +0 -110
  1430. data/spec/unit/util/autoload.rb +0 -133
  1431. data/spec/unit/util/autoload/file_cache.rb +0 -183
  1432. data/spec/unit/util/backups.rb +0 -159
  1433. data/spec/unit/util/cache_accumulator.rb +0 -69
  1434. data/spec/unit/util/cacher.rb +0 -185
  1435. data/spec/unit/util/checksums.rb +0 -113
  1436. data/spec/unit/util/constant_inflector.rb +0 -70
  1437. data/spec/unit/util/feature.rb +0 -72
  1438. data/spec/unit/util/file_locking.rb +0 -115
  1439. data/spec/unit/util/filetype.rb +0 -100
  1440. data/spec/unit/util/json.rb +0 -21
  1441. data/spec/unit/util/ldap/connection.rb +0 -169
  1442. data/spec/unit/util/ldap/generator.rb +0 -54
  1443. data/spec/unit/util/ldap/manager.rb +0 -654
  1444. data/spec/unit/util/loadedfile.rb +0 -65
  1445. data/spec/unit/util/log.rb +0 -202
  1446. data/spec/unit/util/metric.rb +0 -95
  1447. data/spec/unit/util/monkey_patches.rb +0 -103
  1448. data/spec/unit/util/nagios_maker.rb +0 -126
  1449. data/spec/unit/util/package.rb +0 -21
  1450. data/spec/unit/util/posix.rb +0 -256
  1451. data/spec/unit/util/queue.rb +0 -96
  1452. data/spec/unit/util/queue/stomp.rb +0 -140
  1453. data/spec/unit/util/reference_serializer.rb +0 -52
  1454. data/spec/unit/util/resource_template.rb +0 -58
  1455. data/spec/unit/util/selinux.rb +0 -280
  1456. data/spec/unit/util/settings.rb +0 -1058
  1457. data/spec/unit/util/settings/file_setting.rb +0 -248
  1458. data/spec/unit/util/storage.rb +0 -248
  1459. data/spec/unit/util/tagging.rb +0 -102
  1460. data/spec/unit/util/user_attr.rb +0 -47
  1461. data/spec/unit/util/warnings.rb +0 -39
  1462. data/spec/unit/util/zaml.rb +0 -38
  1463. data/test/language/ast/casestatement.rb +0 -103
  1464. data/test/language/ast/resource.rb +0 -58
  1465. data/test/language/ast/resource_reference.rb +0 -77
  1466. data/test/language/ast/selector.rb +0 -61
  1467. data/test/language/resource.rb +0 -172
  1468. data/test/lib/puppettest/support/collection.rb +0 -29
  1469. data/test/network/client/resource.rb +0 -52
  1470. data/test/network/handler/bucket.rb +0 -313
  1471. data/test/network/handler/resource.rb +0 -250
  1472. data/test/other/dsl.rb +0 -215
  1473. data/test/other/events.rb +0 -124
  1474. data/test/ral/type/group.rb +0 -170
@@ -13,220 +13,204 @@ require 'pathname'
13
13
 
14
14
  module Puppet::Util::SELinux
15
15
 
16
- def selinux_support?
17
- unless defined? Selinux
18
- return false
19
- end
20
- if Selinux.is_selinux_enabled == 1
21
- return true
22
- end
23
- return false
16
+ def selinux_support?
17
+ return false unless defined?(Selinux)
18
+ if Selinux.is_selinux_enabled == 1
19
+ return true
24
20
  end
25
-
26
- # Retrieve and return the full context of the file. If we don't have
27
- # SELinux support or if the SELinux call fails then return nil.
28
- def get_selinux_current_context(file)
29
- unless selinux_support?
30
- return nil
31
- end
32
- retval = Selinux.lgetfilecon(file)
33
- if retval == -1
34
- return nil
35
- end
36
- return retval[1]
21
+ false
22
+ end
23
+
24
+ # Retrieve and return the full context of the file. If we don't have
25
+ # SELinux support or if the SELinux call fails then return nil.
26
+ def get_selinux_current_context(file)
27
+ return nil unless selinux_support?
28
+ retval = Selinux.lgetfilecon(file)
29
+ if retval == -1
30
+ return nil
37
31
  end
38
-
39
- # Retrieve and return the default context of the file. If we don't have
40
- # SELinux support or if the SELinux call fails to file a default then return nil.
41
- def get_selinux_default_context(file)
42
- unless selinux_support?
43
- return nil
44
- end
45
- # If the filesystem has no support for SELinux labels, return a default of nil
46
- # instead of what matchpathcon would return
47
- unless selinux_label_support?(file)
48
- return nil
49
- end
50
- # If the file exists we should pass the mode to matchpathcon for the most specific
51
- # matching. If not, we can pass a mode of 0.
52
- begin
53
- filestat = File.lstat(file)
54
- mode = filestat.mode
55
- rescue Errno::ENOENT
56
- mode = 0
57
- end
58
- retval = Selinux.matchpathcon(file, mode)
59
- if retval == -1
60
- return nil
61
- end
62
- return retval[1]
32
+ retval[1]
33
+ end
34
+
35
+ # Retrieve and return the default context of the file. If we don't have
36
+ # SELinux support or if the SELinux call fails to file a default then return nil.
37
+ def get_selinux_default_context(file)
38
+ return nil unless selinux_support?
39
+ # If the filesystem has no support for SELinux labels, return a default of nil
40
+ # instead of what matchpathcon would return
41
+ return nil unless selinux_label_support?(file)
42
+ # If the file exists we should pass the mode to matchpathcon for the most specific
43
+ # matching. If not, we can pass a mode of 0.
44
+ begin
45
+ filestat = File.lstat(file)
46
+ mode = filestat.mode
47
+ rescue Errno::ENOENT
48
+ mode = 0
63
49
  end
64
-
65
- # Take the full SELinux context returned from the tools and parse it
66
- # out to the three (or four) component parts. Supports :seluser, :selrole,
67
- # :seltype, and on systems with range support, :selrange.
68
- def parse_selinux_context(component, context)
69
- if context.nil? or context == "unlabeled"
70
- return nil
71
- end
72
- unless context =~ /^([a-z0-9_]+):([a-z0-9_]+):([a-zA-Z0-9_]+)(?::([a-zA-Z0-9:,._-]+))?/
73
- raise Puppet::Error, "Invalid context to parse: #{context}"
74
- end
75
- ret = {
76
- :seluser => $1,
77
- :selrole => $2,
78
- :seltype => $3,
79
- :selrange => $4,
80
- }
81
- return ret[component]
50
+ retval = Selinux.matchpathcon(file, mode)
51
+ if retval == -1
52
+ return nil
82
53
  end
83
-
84
- # This updates the actual SELinux label on the file. You can update
85
- # only a single component or update the entire context.
86
- # The caveat is that since setting a partial context makes no sense the
87
- # file has to already exist. Puppet (via the File resource) will always
88
- # just try to set components, even if all values are specified by the manifest.
89
- # I believe that the OS should always provide at least a fall-through context
90
- # though on any well-running system.
91
- def set_selinux_context(file, value, component = false)
92
- unless selinux_support? && selinux_label_support?(file)
93
- return nil
94
- end
95
-
96
- if component
97
- # Must first get existing context to replace a single component
98
- context = Selinux.lgetfilecon(file)[1]
99
- if context == -1
100
- # We can't set partial context components when no context exists
101
- # unless/until we can find a way to make Puppet call this method
102
- # once for all selinux file label attributes.
103
- Puppet.warning "Can't set SELinux context on file unless the file already has some kind of context"
104
- return nil
105
- end
106
- context = context.split(':')
107
- case component
108
- when :seluser
109
- context[0] = value
110
- when :selrole
111
- context[1] = value
112
- when :seltype
113
- context[2] = value
114
- when :selrange
115
- context[3] = value
116
- else
117
- raise ArguementError, "set_selinux_context component must be one of :seluser, :selrole, :seltype, or :selrange"
118
- end
119
- context = context.join(':')
120
- else
121
- context = value
122
- end
123
-
124
- retval = Selinux.lsetfilecon(file, context)
125
- if retval == 0
126
- return true
127
- else
128
- Puppet.warning "Failed to set SELinux context %s on %s" % [context, file]
129
- return false
130
- end
54
+ retval[1]
55
+ end
56
+
57
+ # Take the full SELinux context returned from the tools and parse it
58
+ # out to the three (or four) component parts. Supports :seluser, :selrole,
59
+ # :seltype, and on systems with range support, :selrange.
60
+ def parse_selinux_context(component, context)
61
+ if context.nil? or context == "unlabeled"
62
+ return nil
131
63
  end
132
-
133
- # Since this call relies on get_selinux_default_context it also needs a
134
- # full non-relative path to the file. Fortunately, that seems to be all
135
- # Puppet uses. This will set the file's SELinux context to the policy's
136
- # default context (if any) if it differs from the context currently on
137
- # the file.
138
- def set_selinux_default_context(file)
139
- new_context = get_selinux_default_context(file)
140
- unless new_context
141
- return nil
142
- end
143
- cur_context = get_selinux_current_context(file)
144
- if new_context != cur_context
145
- set_selinux_context(file, new_context)
146
- return new_context
147
- end
64
+ unless context =~ /^([a-z0-9_]+):([a-z0-9_]+):([a-zA-Z0-9_]+)(?::([a-zA-Z0-9:,._-]+))?/
65
+ raise Puppet::Error, "Invalid context to parse: #{context}"
66
+ end
67
+ ret = {
68
+ :seluser => $1,
69
+ :selrole => $2,
70
+ :seltype => $3,
71
+ :selrange => $4,
72
+ }
73
+ ret[component]
74
+ end
75
+
76
+ # This updates the actual SELinux label on the file. You can update
77
+ # only a single component or update the entire context.
78
+ # The caveat is that since setting a partial context makes no sense the
79
+ # file has to already exist. Puppet (via the File resource) will always
80
+ # just try to set components, even if all values are specified by the manifest.
81
+ # I believe that the OS should always provide at least a fall-through context
82
+ # though on any well-running system.
83
+ def set_selinux_context(file, value, component = false)
84
+ return nil unless selinux_support? && selinux_label_support?(file)
85
+
86
+ if component
87
+ # Must first get existing context to replace a single component
88
+ context = Selinux.lgetfilecon(file)[1]
89
+ if context == -1
90
+ # We can't set partial context components when no context exists
91
+ # unless/until we can find a way to make Puppet call this method
92
+ # once for all selinux file label attributes.
93
+ Puppet.warning "Can't set SELinux context on file unless the file already has some kind of context"
148
94
  return nil
95
+ end
96
+ context = context.split(':')
97
+ case component
98
+ when :seluser
99
+ context[0] = value
100
+ when :selrole
101
+ context[1] = value
102
+ when :seltype
103
+ context[2] = value
104
+ when :selrange
105
+ context[3] = value
106
+ else
107
+ raise ArguementError, "set_selinux_context component must be one of :seluser, :selrole, :seltype, or :selrange"
108
+ end
109
+ context = context.join(':')
110
+ else
111
+ context = value
149
112
  end
150
113
 
151
- # Internal helper function to read and parse /proc/mounts
152
- def read_mounts
153
- mounts = ""
154
- begin
155
- if File.instance_methods.include? "read_nonblock"
156
- # If possible we use read_nonblock() in a loop rather than read() to work-
157
- # a linux kernel bug. See ticket #1963 for details.
158
- mountfh = File.open("/proc/mounts")
159
- mounts += mountfh.read_nonblock(1024) while true
160
- else
161
- # Otherwise we shell out and let cat do it for us
162
- mountfh = IO.popen("/bin/cat /proc/mounts")
163
- mounts = mountfh.read
164
- end
165
- rescue EOFError
166
- # that's expected
167
- rescue
168
- return nil
169
- ensure
170
- mountfh.close if mountfh
171
- end
172
-
173
- mntpoint = {}
174
-
175
- # Read all entries in /proc/mounts. The second column is the
176
- # mountpoint and the third column is the filesystem type.
177
- # We skip rootfs because it is always mounted at /
178
- mounts.collect do |line|
179
- params = line.split(' ')
180
- next if params[2] == 'rootfs'
181
- mntpoint[params[1]] = params[2]
182
- end
183
- return mntpoint
114
+ retval = Selinux.lsetfilecon(file, context)
115
+ if retval == 0
116
+ return true
117
+ else
118
+ Puppet.warning "Failed to set SELinux context #{context} on #{file}"
119
+ return false
184
120
  end
185
-
186
- def realpath(path)
187
- path, rest = Pathname.new(path), []
188
- path, rest = path.dirname, [path.basename] + rest while ! path.exist?
189
- File.join( path.realpath, *rest )
121
+ end
122
+
123
+ # Since this call relies on get_selinux_default_context it also needs a
124
+ # full non-relative path to the file. Fortunately, that seems to be all
125
+ # Puppet uses. This will set the file's SELinux context to the policy's
126
+ # default context (if any) if it differs from the context currently on
127
+ # the file.
128
+ def set_selinux_default_context(file)
129
+ new_context = get_selinux_default_context(file)
130
+ return nil unless new_context
131
+ cur_context = get_selinux_current_context(file)
132
+ if new_context != cur_context
133
+ set_selinux_context(file, new_context)
134
+ return new_context
190
135
  end
191
-
192
- def parent_directory(path)
193
- Pathname.new(path).dirname.to_s
136
+ nil
137
+ end
138
+
139
+ # Internal helper function to read and parse /proc/mounts
140
+ def read_mounts
141
+ mounts = ""
142
+ begin
143
+ if File.instance_methods.include? "read_nonblock"
144
+ # If possible we use read_nonblock in a loop rather than read to work-
145
+ # a linux kernel bug. See ticket #1963 for details.
146
+ mountfh = File.open("/proc/mounts")
147
+ mounts += mountfh.read_nonblock(1024) while true
148
+ else
149
+ # Otherwise we shell out and let cat do it for us
150
+ mountfh = IO.popen("/bin/cat /proc/mounts")
151
+ mounts = mountfh.read
152
+ end
153
+ rescue EOFError
154
+ # that's expected
155
+ rescue
156
+ return nil
157
+ ensure
158
+ mountfh.close if mountfh
194
159
  end
195
160
 
196
- # Internal helper function to return which type of filesystem a
197
- # given file path resides on
198
- def find_fs(path)
199
- unless mnts = read_mounts()
200
- return nil
201
- end
202
-
203
- # For a given file:
204
- # Check if the filename is in the data structure;
205
- # return the fstype if it is.
206
- # Just in case: return something if you're down to "/" or ""
207
- # Remove the last slash and everything after it,
208
- # and repeat with that as the file for the next loop through.
209
- path = realpath(path)
210
- while not path.empty? do
211
- if mnts.has_key?(path)
212
- return mnts[path]
213
- end
214
- path = parent_directory(path)
215
- end
216
- return mnts['/']
161
+ mntpoint = {}
162
+
163
+ # Read all entries in /proc/mounts. The second column is the
164
+ # mountpoint and the third column is the filesystem type.
165
+ # We skip rootfs because it is always mounted at /
166
+ mounts.collect do |line|
167
+ params = line.split(' ')
168
+ next if params[2] == 'rootfs'
169
+ mntpoint[params[1]] = params[2]
170
+ end
171
+ mntpoint
172
+ end
173
+
174
+ def realpath(path)
175
+ path, rest = Pathname.new(path), []
176
+ path, rest = path.dirname, [path.basename] + rest while ! path.exist?
177
+ File.join( path.realpath, *rest )
178
+ end
179
+
180
+ def parent_directory(path)
181
+ Pathname.new(path).dirname.to_s
182
+ end
183
+
184
+ # Internal helper function to return which type of filesystem a
185
+ # given file path resides on
186
+ def find_fs(path)
187
+ unless mnts = read_mounts
188
+ return nil
217
189
  end
218
190
 
219
- # Check filesystem a path resides on for SELinux support against
220
- # whitelist of known-good filesystems.
221
- # Returns true if the filesystem can support SELinux labels and
222
- # false if not.
223
- def selinux_label_support?(file)
224
- fstype = find_fs(file)
225
- if fstype.nil?
226
- return false
227
- end
228
- filesystems = ['ext2', 'ext3', 'ext4', 'gfs', 'gfs2', 'xfs', 'jfs']
229
- return filesystems.include?(fstype)
191
+ # For a given file:
192
+ # Check if the filename is in the data structure;
193
+ # return the fstype if it is.
194
+ # Just in case: return something if you're down to "/" or ""
195
+ # Remove the last slash and everything after it,
196
+ # and repeat with that as the file for the next loop through.
197
+ path = realpath(path)
198
+ while not path.empty?
199
+ return mnts[path] if mnts.has_key?(path)
200
+ path = parent_directory(path)
230
201
  end
202
+ mnts['/']
203
+ end
204
+
205
+ # Check filesystem a path resides on for SELinux support against
206
+ # whitelist of known-good filesystems.
207
+ # Returns true if the filesystem can support SELinux labels and
208
+ # false if not.
209
+ def selinux_label_support?(file)
210
+ fstype = find_fs(file)
211
+ return false if fstype.nil?
212
+ filesystems = ['ext2', 'ext3', 'ext4', 'gfs', 'gfs2', 'xfs', 'jfs']
213
+ filesystems.include?(fstype)
214
+ end
231
215
 
232
216
  end
@@ -1,598 +1,580 @@
1
1
  require 'puppet'
2
2
  require 'sync'
3
- require 'puppet/transportable'
4
3
  require 'getoptlong'
5
-
6
4
  require 'puppet/external/event-loop'
7
5
  require 'puppet/util/cacher'
8
6
  require 'puppet/util/loadedfile'
9
7
 
10
8
  # The class for handling configuration files.
11
9
  class Puppet::Util::Settings
12
- include Enumerable
13
- include Puppet::Util::Cacher
14
-
15
- require 'puppet/util/settings/setting'
16
- require 'puppet/util/settings/file_setting'
17
- require 'puppet/util/settings/boolean_setting'
18
-
19
- attr_accessor :file
20
- attr_reader :timer
21
-
22
- # Retrieve a config value
23
- def [](param)
24
- value(param)
25
- end
26
-
27
- # Set a config value. This doesn't set the defaults, it sets the value itself.
28
- def []=(param, value)
29
- set_value(param, value, :memory)
30
- end
31
-
32
- # Generate the list of valid arguments, in a format that GetoptLong can
33
- # understand, and add them to the passed option list.
34
- def addargs(options)
35
- # Add all of the config parameters as valid options.
36
- self.each { |name, setting|
37
- setting.getopt_args.each { |args| options << args }
38
- }
39
-
40
- return options
41
- end
42
-
43
- # Generate the list of valid arguments, in a format that OptionParser can
44
- # understand, and add them to the passed option list.
45
- def optparse_addargs(options)
46
- # Add all of the config parameters as valid options.
47
- self.each { |name, setting|
48
- options << setting.optparse_args
49
- }
50
-
51
- return options
52
- end
53
-
54
- # Is our parameter a boolean parameter?
55
- def boolean?(param)
56
- param = param.to_sym
57
- if @config.include?(param) and @config[param].kind_of? BooleanSetting
58
- return true
59
- else
60
- return false
61
- end
62
- end
63
-
64
- # Remove all set values, potentially skipping cli values.
65
- def clear(exceptcli = false)
66
- @sync.synchronize do
67
- unsafe_clear(exceptcli)
68
- end
69
- end
70
-
71
- # Remove all set values, potentially skipping cli values.
72
- def unsafe_clear(exceptcli = false)
73
- @values.each do |name, values|
74
- @values.delete(name) unless exceptcli and name == :cli
75
- end
76
-
77
- # Don't clear the 'used' in this case, since it's a config file reparse,
78
- # and we want to retain this info.
79
- unless exceptcli
80
- @used = []
81
- end
82
-
83
- @cache.clear
84
-
85
- @name = nil
86
- end
87
-
88
- # This is mostly just used for testing.
89
- def clearused
90
- @cache.clear
91
- @used = []
92
- end
93
-
94
- # Do variable interpolation on the value.
95
- def convert(value, environment = nil)
96
- return value unless value
97
- return value unless value.is_a? String
98
- newval = value.gsub(/\$(\w+)|\$\{(\w+)\}/) do |value|
99
- varname = $2 || $1
100
- if varname == "environment" and environment
101
- environment
102
- elsif pval = self.value(varname)
103
- pval
104
- else
105
- raise Puppet::DevError, "Could not find value for %s" % value
106
- end
107
- end
108
-
109
- return newval
110
- end
111
-
112
- # Return a value's description.
113
- def description(name)
114
- if obj = @config[name.to_sym]
115
- obj.desc
116
- else
117
- nil
118
- end
119
- end
120
-
121
- def each
122
- @config.each { |name, object|
123
- yield name, object
124
- }
125
- end
126
-
127
- # Iterate over each section name.
128
- def eachsection
129
- yielded = []
130
- @config.each do |name, object|
131
- section = object.section
132
- unless yielded.include? section
133
- yield section
134
- yielded << section
135
- end
136
- end
137
- end
138
-
139
- # Return an object by name.
140
- def setting(param)
141
- param = param.to_sym
142
- @config[param]
143
- end
144
-
145
- # Handle a command-line argument.
146
- def handlearg(opt, value = nil)
147
- @cache.clear
148
- value = munge_value(value) if value
149
- str = opt.sub(/^--/,'')
150
-
151
- bool = true
152
- newstr = str.sub(/^no-/, '')
153
- if newstr != str
154
- str = newstr
155
- bool = false
156
- end
157
- str = str.intern
158
-
159
- if @config[str].is_a?(Puppet::Util::Settings::BooleanSetting)
160
- if value == "" or value.nil?
161
- value = bool
162
- end
163
- end
164
-
165
- set_value(str, value, :cli)
166
- end
167
-
168
- def without_noop
169
- old_noop = value(:noop,:cli) and set_value(:noop, false, :cli) if valid?(:noop)
170
- yield
171
- ensure
172
- set_value(:noop, old_noop, :cli) if valid?(:noop)
173
- end
174
-
175
- def include?(name)
176
- name = name.intern if name.is_a? String
177
- @config.include?(name)
178
- end
179
-
180
- # check to see if a short name is already defined
181
- def shortinclude?(short)
182
- short = short.intern if name.is_a? String
183
- @shortnames.include?(short)
184
- end
185
-
186
- # Create a new collection of config settings.
187
- def initialize
188
- @config = {}
189
- @shortnames = {}
190
-
191
- @created = []
192
- @searchpath = nil
193
-
194
- # Mutex-like thing to protect @values
195
- @sync = Sync.new
196
-
197
- # Keep track of set values.
198
- @values = Hash.new { |hash, key| hash[key] = {} }
199
-
200
- # And keep a per-environment cache
201
- @cache = Hash.new { |hash, key| hash[key] = {} }
202
-
203
- # A central concept of a name.
204
- @name = nil
205
-
206
- # The list of sections we've used.
207
- @used = []
208
- end
209
-
210
- # NOTE: ACS ahh the util classes. . .sigh
211
- # as part of a fix for 1183, I pulled the logic for the following 5 methods out of the executables and puppet.rb
212
- # They probably deserve their own class, but I don't want to do that until I can refactor environments
213
- # its a little better than where they were
214
-
215
- # Prints the contents of a config file with the available config settings, or it
216
- # prints a single value of a config setting.
217
- def print_config_options
218
- env = value(:environment)
219
- val = value(:configprint)
220
- if val == "all"
221
- hash = {}
222
- each do |name, obj|
223
- val = value(name,env)
224
- val = val.inspect if val == ""
225
- hash[name] = val
226
- end
227
- hash.sort { |a,b| a[0].to_s <=> b[0].to_s }.each do |name, val|
228
- puts "%s = %s" % [name, val]
229
- end
230
- else
231
- val.split(/\s*,\s*/).sort.each do |v|
232
- if include?(v)
233
- #if there is only one value, just print it for back compatibility
234
- if v == val
235
- puts value(val,env)
236
- break
237
- end
238
- puts "%s = %s" % [v, value(v,env)]
239
- else
240
- puts "invalid parameter: %s" % v
241
- return false
242
- end
243
- end
244
- end
245
- true
246
- end
247
-
248
- def generate_config
249
- puts to_config
250
- true
251
- end
252
-
253
- def generate_manifest
254
- puts to_manifest
255
- true
256
- end
257
-
258
- def print_configs
259
- return print_config_options if value(:configprint) != ""
260
- return generate_config if value(:genconfig)
261
- return generate_manifest if value(:genmanifest)
262
- end
263
-
264
- def print_configs?
265
- return (value(:configprint) != "" || value(:genconfig) || value(:genmanifest)) && true
266
- end
267
-
268
- # Return a given object's file metadata.
269
- def metadata(param)
270
- if obj = @config[param.to_sym] and obj.is_a?(FileSetting)
271
- return [:owner, :group, :mode].inject({}) do |meta, p|
272
- if v = obj.send(p)
273
- meta[p] = v
274
- end
275
- meta
276
- end
277
- else
278
- nil
279
- end
280
- end
281
-
282
- # Make a directory with the appropriate user, group, and mode
283
- def mkdir(default)
284
- obj = get_config_file_default(default)
285
-
286
- Puppet::Util::SUIDManager.asuser(obj.owner, obj.group) do
287
- mode = obj.mode || 0750
288
- Dir.mkdir(obj.value, mode)
289
- end
290
- end
291
-
292
- # Figure out our name.
293
- def name
294
- unless @name
295
- unless @config[:name]
296
- return nil
297
- end
298
- searchpath.each do |source|
299
- next if source == :name
300
- @sync.synchronize do
301
- @name = @values[source][:name]
302
- end
303
- break if @name
304
- end
305
- unless @name
306
- @name = convert(@config[:name].default).intern
307
- end
308
- end
309
- @name
310
- end
311
-
312
- # Return all of the parameters associated with a given section.
313
- def params(section = nil)
314
- if section
315
- section = section.intern if section.is_a? String
316
- @config.find_all { |name, obj|
317
- obj.section == section
318
- }.collect { |name, obj|
319
- name
320
- }
321
- else
322
- @config.keys
323
- end
324
- end
325
-
326
- # Parse the configuration file. Just provides
327
- # thread safety.
328
- def parse
329
- raise "No :config setting defined; cannot parse unknown config file" unless self[:config]
330
-
331
- # Create a timer so that this file will get checked automatically
332
- # and reparsed if necessary.
333
- set_filetimeout_timer()
334
-
335
- @sync.synchronize do
336
- unsafe_parse(self[:config])
337
- end
338
- end
339
-
340
- # Unsafely parse the file -- this isn't thread-safe and causes plenty of problems if used directly.
341
- def unsafe_parse(file)
342
- return unless FileTest.exist?(file)
343
- begin
344
- data = parse_file(file)
345
- rescue => details
346
- puts details.backtrace if Puppet[:trace]
347
- Puppet.err "Could not parse #{file}: #{details}"
348
- return
349
- end
350
-
351
- unsafe_clear(true)
352
-
353
- data.each do |area, values|
354
- @values[area] = values
355
- end
356
-
357
- # Determine our environment, if we have one.
358
- if @config[:environment]
359
- env = self.value(:environment).to_sym
10
+ include Enumerable
11
+ include Puppet::Util::Cacher
12
+
13
+ require 'puppet/util/settings/setting'
14
+ require 'puppet/util/settings/file_setting'
15
+ require 'puppet/util/settings/boolean_setting'
16
+
17
+ attr_accessor :file
18
+ attr_reader :timer
19
+
20
+ ReadOnly = [:run_mode, :name]
21
+
22
+ # Retrieve a config value
23
+ def [](param)
24
+ value(param)
25
+ end
26
+
27
+ # Set a config value. This doesn't set the defaults, it sets the value itself.
28
+ def []=(param, value)
29
+ set_value(param, value, :memory)
30
+ end
31
+
32
+ # Generate the list of valid arguments, in a format that GetoptLong can
33
+ # understand, and add them to the passed option list.
34
+ def addargs(options)
35
+ # Add all of the config parameters as valid options.
36
+ self.each { |name, setting|
37
+ setting.getopt_args.each { |args| options << args }
38
+ }
39
+
40
+ options
41
+ end
42
+
43
+ # Generate the list of valid arguments, in a format that OptionParser can
44
+ # understand, and add them to the passed option list.
45
+ def optparse_addargs(options)
46
+ # Add all of the config parameters as valid options.
47
+ self.each { |name, setting|
48
+ options << setting.optparse_args
49
+ }
50
+
51
+ options
52
+ end
53
+
54
+ # Is our parameter a boolean parameter?
55
+ def boolean?(param)
56
+ param = param.to_sym
57
+ !!(@config.include?(param) and @config[param].kind_of? BooleanSetting)
58
+ end
59
+
60
+ # Remove all set values, potentially skipping cli values.
61
+ def clear(exceptcli = false)
62
+ @sync.synchronize do
63
+ unsafe_clear(exceptcli)
64
+ end
65
+ end
66
+
67
+ # Remove all set values, potentially skipping cli values.
68
+ def unsafe_clear(exceptcli = false)
69
+ @values.each do |name, values|
70
+ @values.delete(name) unless exceptcli and name == :cli
71
+ end
72
+
73
+ # Don't clear the 'used' in this case, since it's a config file reparse,
74
+ # and we want to retain this info.
75
+ @used = [] unless exceptcli
76
+
77
+ @cache.clear
78
+ end
79
+
80
+ # This is mostly just used for testing.
81
+ def clearused
82
+ @cache.clear
83
+ @used = []
84
+ end
85
+
86
+ # Do variable interpolation on the value.
87
+ def convert(value, environment = nil)
88
+ return value unless value
89
+ return value unless value.is_a? String
90
+ newval = value.gsub(/\$(\w+)|\$\{(\w+)\}/) do |value|
91
+ varname = $2 || $1
92
+ if varname == "environment" and environment
93
+ environment
94
+ elsif pval = self.value(varname)
95
+ pval
96
+ else
97
+ raise Puppet::DevError, "Could not find value for #{value}"
98
+ end
99
+ end
100
+
101
+ newval
102
+ end
103
+
104
+ # Return a value's description.
105
+ def description(name)
106
+ if obj = @config[name.to_sym]
107
+ obj.desc
108
+ else
109
+ nil
110
+ end
111
+ end
112
+
113
+ def each
114
+ @config.each { |name, object|
115
+ yield name, object
116
+ }
117
+ end
118
+
119
+ # Iterate over each section name.
120
+ def eachsection
121
+ yielded = []
122
+ @config.each do |name, object|
123
+ section = object.section
124
+ unless yielded.include? section
125
+ yield section
126
+ yielded << section
127
+ end
128
+ end
129
+ end
130
+
131
+ # Return an object by name.
132
+ def setting(param)
133
+ param = param.to_sym
134
+ @config[param]
135
+ end
136
+
137
+ # Handle a command-line argument.
138
+ def handlearg(opt, value = nil)
139
+ @cache.clear
140
+ value &&= munge_value(value)
141
+ str = opt.sub(/^--/,'')
142
+
143
+ bool = true
144
+ newstr = str.sub(/^no-/, '')
145
+ if newstr != str
146
+ str = newstr
147
+ bool = false
148
+ end
149
+ str = str.intern
150
+
151
+ if @config[str].is_a?(Puppet::Util::Settings::BooleanSetting)
152
+ if value == "" or value.nil?
153
+ value = bool
154
+ end
155
+ end
156
+
157
+ set_value(str, value, :cli)
158
+ end
159
+
160
+ def include?(name)
161
+ name = name.intern if name.is_a? String
162
+ @config.include?(name)
163
+ end
164
+
165
+ # check to see if a short name is already defined
166
+ def shortinclude?(short)
167
+ short = short.intern if name.is_a? String
168
+ @shortnames.include?(short)
169
+ end
170
+
171
+ # Create a new collection of config settings.
172
+ def initialize
173
+ @config = {}
174
+ @shortnames = {}
175
+
176
+ @created = []
177
+ @searchpath = nil
178
+
179
+ # Mutex-like thing to protect @values
180
+ @sync = Sync.new
181
+
182
+ # Keep track of set values.
183
+ @values = Hash.new { |hash, key| hash[key] = {} }
184
+
185
+ # And keep a per-environment cache
186
+ @cache = Hash.new { |hash, key| hash[key] = {} }
187
+
188
+ # The list of sections we've used.
189
+ @used = []
190
+ end
191
+
192
+ # NOTE: ACS ahh the util classes. . .sigh
193
+ # as part of a fix for 1183, I pulled the logic for the following 5 methods out of the executables and puppet.rb
194
+ # They probably deserve their own class, but I don't want to do that until I can refactor environments
195
+ # its a little better than where they were
196
+
197
+ # Prints the contents of a config file with the available config settings, or it
198
+ # prints a single value of a config setting.
199
+ def print_config_options
200
+ env = value(:environment)
201
+ val = value(:configprint)
202
+ if val == "all"
203
+ hash = {}
204
+ each do |name, obj|
205
+ val = value(name,env)
206
+ val = val.inspect if val == ""
207
+ hash[name] = val
208
+ end
209
+ hash.sort { |a,b| a[0].to_s <=> b[0].to_s }.each do |name, val|
210
+ puts "#{name} = #{val}"
211
+ end
212
+ else
213
+ val.split(/\s*,\s*/).sort.each do |v|
214
+ if include?(v)
215
+ #if there is only one value, just print it for back compatibility
216
+ if v == val
217
+ puts value(val,env)
218
+ break
219
+ end
220
+ puts "#{v} = #{value(v,env)}"
360
221
  else
361
- env = "none"
362
- end
363
-
364
- # Call any hooks we should be calling.
365
- settings_with_hooks.each do |setting|
366
- each_source(env) do |source|
367
- if value = @values[source][setting.name]
368
- # We still have to use value() to retrieve the value, since
369
- # we want the fully interpolated value, not $vardir/lib or whatever.
370
- # This results in extra work, but so few of the settings
371
- # will have associated hooks that it ends up being less work this
372
- # way overall.
373
- setting.handle(self.value(setting.name, env))
374
- break
375
- end
376
- end
377
- end
378
-
379
- # We have to do it in the reverse of the search path,
380
- # because multiple sections could set the same value
381
- # and I'm too lazy to only set the metadata once.
382
- searchpath.reverse.each do |source|
383
- if meta = @values[source][:_meta]
384
- set_metadata(meta)
385
- end
386
- end
387
- end
388
-
389
- # Create a new setting. The value is passed in because it's used to determine
390
- # what kind of setting we're creating, but the value itself might be either
391
- # a default or a value, so we can't actually assign it.
392
- def newsetting(hash)
393
- klass = nil
394
- if hash[:section]
395
- hash[:section] = hash[:section].to_sym
396
- end
397
- if type = hash[:type]
398
- unless klass = {:setting => Setting, :file => FileSetting, :boolean => BooleanSetting}[type]
399
- raise ArgumentError, "Invalid setting type '%s'" % type
400
- end
401
- hash.delete(:type)
402
- else
403
- case hash[:default]
404
- when true, false, "true", "false"
405
- klass = BooleanSetting
406
- when /^\$\w+\//, /^\//
407
- klass = FileSetting
408
- when String, Integer, Float # nothing
409
- klass = Setting
410
- else
411
- raise Puppet::Error, "Invalid value '%s' for %s" % [value.inspect, hash[:name]]
412
- end
413
- end
414
- hash[:settings] = self
415
- setting = klass.new(hash)
416
-
417
- return setting
418
- end
419
-
420
- # This has to be private, because it doesn't add the settings to @config
421
- private :newsetting
422
-
423
- # Iterate across all of the objects in a given section.
424
- def persection(section)
425
- section = section.to_sym
426
- self.each { |name, obj|
427
- if obj.section == section
428
- yield obj
429
- end
430
- }
431
- end
432
-
433
- # Cache this in an easily clearable way, since we were
434
- # having trouble cleaning it up after tests.
435
- cached_attr(:file) do
436
- if path = self[:config] and FileTest.exist?(path)
437
- Puppet::Util::LoadedFile.new(path)
438
- end
439
- end
440
-
441
- # Reparse our config file, if necessary.
442
- def reparse
443
- if file and file.changed?
444
- Puppet.notice "Reparsing %s" % file.file
445
- parse
446
- reuse()
447
- end
448
- end
449
-
450
- def reuse
451
- return unless defined? @used
452
- @sync.synchronize do # yay, thread-safe
453
- new = @used
454
- @used = []
455
- self.use(*new)
456
- end
457
- end
458
-
459
- # The order in which to search for values.
460
- def searchpath(environment = nil)
461
- if environment
462
- [:cli, :memory, environment, :name, :main]
463
- else
464
- [:cli, :memory, :name, :main]
465
- end
466
- end
467
-
468
- # Get a list of objects per section
469
- def sectionlist
470
- sectionlist = []
471
- self.each { |name, obj|
472
- section = obj.section || "puppet"
473
- sections[section] ||= []
474
- unless sectionlist.include?(section)
475
- sectionlist << section
476
- end
477
- sections[section] << obj
478
- }
479
-
480
- return sectionlist, sections
481
- end
482
-
483
- def service_user_available?
484
- return @service_user_available if defined?(@service_user_available)
485
-
486
- return @service_user_available = false unless user_name = self[:user]
487
-
488
- user = Puppet::Type.type(:user).new :name => self[:user], :check => :ensure
489
-
490
- return @service_user_available = user.exists?
491
- end
492
-
493
- def set_value(param, value, type)
494
- param = param.to_sym
495
- unless setting = @config[param]
496
- raise ArgumentError,
497
- "Attempt to assign a value to unknown configuration parameter %s" % param.inspect
498
- end
499
- if setting.respond_to?(:munge)
500
- value = setting.munge(value)
501
- end
502
- if setting.respond_to?(:handle)
503
- setting.handle(value)
504
- end
505
- # Reset the name, so it's looked up again.
506
- if param == :name
507
- @name = nil
508
- end
509
- @sync.synchronize do # yay, thread-safe
510
- @values[type][param] = value
511
- @cache.clear
512
-
513
- clearused
514
-
515
- # Clear the list of environments, because they cache, at least, the module path.
516
- # We *could* preferentially just clear them if the modulepath is changed,
517
- # but we don't really know if, say, the vardir is changed and the modulepath
518
- # is defined relative to it. We need the defined? stuff because of loading
519
- # order issues.
520
- Puppet::Node::Environment.clear if defined?(Puppet::Node) and defined?(Puppet::Node::Environment)
521
- end
522
-
523
- return value
524
- end
525
-
526
- private :set_value
527
-
528
- # Set a bunch of defaults in a given section. The sections are actually pretty
529
- # pointless, but they help break things up a bit, anyway.
530
- def setdefaults(section, defs)
531
- section = section.to_sym
532
- call = []
533
- defs.each { |name, hash|
534
- if hash.is_a? Array
535
- unless hash.length == 2
536
- raise ArgumentError, "Defaults specified as an array must contain only the default value and the decription"
537
- end
538
- tmp = hash
539
- hash = {}
540
- [:default, :desc].zip(tmp).each { |p,v| hash[p] = v }
541
- end
542
- name = name.to_sym
543
- hash[:name] = name
544
- hash[:section] = section
545
- if @config.include?(name)
546
- raise ArgumentError, "Parameter %s is already defined" % name
547
- end
548
- tryconfig = newsetting(hash)
549
- if short = tryconfig.short
550
- if other = @shortnames[short]
551
- raise ArgumentError, "Parameter %s is already using short name '%s'" % [other.name, short]
552
- end
553
- @shortnames[short] = tryconfig
554
- end
555
- @config[name] = tryconfig
556
-
557
- # Collect the settings that need to have their hooks called immediately.
558
- # We have to collect them so that we can be sure we're fully initialized before
559
- # the hook is called.
560
- call << tryconfig if tryconfig.call_on_define
561
- }
562
-
563
- call.each { |setting| setting.handle(self.value(setting.name)) }
564
- end
565
-
566
- # Create a timer to check whether the file should be reparsed.
567
- def set_filetimeout_timer
568
- return unless timeout = self[:filetimeout] and timeout = Integer(timeout) and timeout > 0
569
- timer = EventLoop::Timer.new(:interval => timeout, :tolerance => 1, :start? => true) { self.reparse() }
570
- end
571
-
572
- # Convert the settings we manage into a catalog full of resources that model those settings.
573
- # We currently have to go through Trans{Object,Bucket} instances,
574
- # because this hasn't been ported yet.
575
- def to_catalog(*sections)
576
- sections = nil if sections.empty?
577
-
578
- catalog = Puppet::Resource::Catalog.new("Settings")
579
-
580
- @config.values.find_all { |value| value.is_a?(FileSetting) }.each do |file|
581
- next unless (sections.nil? or sections.include?(file.section))
582
- next unless resource = file.to_resource
583
- next if catalog.resource(resource.ref)
584
-
585
- catalog.add_resource(resource)
586
- end
587
-
588
- add_user_resources(catalog, sections)
589
-
590
- catalog
591
- end
592
-
593
- # Convert our list of config settings into a configuration file.
594
- def to_config
595
- str = %{The configuration file for #{Puppet[:name]}. Note that this file
222
+ puts "invalid parameter: #{v}"
223
+ return false
224
+ end
225
+ end
226
+ end
227
+ true
228
+ end
229
+
230
+ def generate_config
231
+ puts to_config
232
+ true
233
+ end
234
+
235
+ def generate_manifest
236
+ puts to_manifest
237
+ true
238
+ end
239
+
240
+ def print_configs
241
+ return print_config_options if value(:configprint) != ""
242
+ return generate_config if value(:genconfig)
243
+ generate_manifest if value(:genmanifest)
244
+ end
245
+
246
+ def print_configs?
247
+ (value(:configprint) != "" || value(:genconfig) || value(:genmanifest)) && true
248
+ end
249
+
250
+ # Return a given object's file metadata.
251
+ def metadata(param)
252
+ if obj = @config[param.to_sym] and obj.is_a?(FileSetting)
253
+ return [:owner, :group, :mode].inject({}) do |meta, p|
254
+ if v = obj.send(p)
255
+ meta[p] = v
256
+ end
257
+ meta
258
+ end
259
+ else
260
+ nil
261
+ end
262
+ end
263
+
264
+ # Make a directory with the appropriate user, group, and mode
265
+ def mkdir(default)
266
+ obj = get_config_file_default(default)
267
+
268
+ Puppet::Util::SUIDManager.asuser(obj.owner, obj.group) do
269
+ mode = obj.mode || 0750
270
+ Dir.mkdir(obj.value, mode)
271
+ end
272
+ end
273
+
274
+ # Figure out the section name for the run_mode.
275
+ def run_mode
276
+ Puppet.run_mode.name
277
+ end
278
+
279
+ # Return all of the parameters associated with a given section.
280
+ def params(section = nil)
281
+ if section
282
+ section = section.intern if section.is_a? String
283
+ @config.find_all { |name, obj|
284
+ obj.section == section
285
+ }.collect { |name, obj|
286
+ name
287
+ }
288
+ else
289
+ @config.keys
290
+ end
291
+ end
292
+
293
+ # Parse the configuration file. Just provides
294
+ # thread safety.
295
+ def parse
296
+ raise "No :config setting defined; cannot parse unknown config file" unless self[:config]
297
+
298
+ @sync.synchronize do
299
+ unsafe_parse(self[:config])
300
+ end
301
+
302
+ # Create a timer so that this file will get checked automatically
303
+ # and reparsed if necessary.
304
+ set_filetimeout_timer
305
+ end
306
+
307
+ # Unsafely parse the file -- this isn't thread-safe and causes plenty of problems if used directly.
308
+ def unsafe_parse(file)
309
+ return unless FileTest.exist?(file)
310
+ begin
311
+ data = parse_file(file)
312
+ rescue => details
313
+ puts details.backtrace if Puppet[:trace]
314
+ Puppet.err "Could not parse #{file}: #{details}"
315
+ return
316
+ end
317
+
318
+ unsafe_clear(true)
319
+
320
+ metas = {}
321
+ data.each do |area, values|
322
+ metas[area] = values.delete(:_meta)
323
+ values.each do |key,value|
324
+ set_value(key, value, area, :dont_trigger_handles => true, :ignore_bad_settings => true )
325
+ end
326
+ end
327
+
328
+ # Determine our environment, if we have one.
329
+ if @config[:environment]
330
+ env = self.value(:environment).to_sym
331
+ else
332
+ env = "none"
333
+ end
334
+
335
+ # Call any hooks we should be calling.
336
+ settings_with_hooks.each do |setting|
337
+ each_source(env) do |source|
338
+ if value = @values[source][setting.name]
339
+ # We still have to use value to retrieve the value, since
340
+ # we want the fully interpolated value, not $vardir/lib or whatever.
341
+ # This results in extra work, but so few of the settings
342
+ # will have associated hooks that it ends up being less work this
343
+ # way overall.
344
+ setting.handle(self.value(setting.name, env))
345
+ break
346
+ end
347
+ end
348
+ end
349
+
350
+ # We have to do it in the reverse of the search path,
351
+ # because multiple sections could set the same value
352
+ # and I'm too lazy to only set the metadata once.
353
+ searchpath.reverse.each do |source|
354
+ source = run_mode if source == :run_mode
355
+ source = @name if (@name && source == :name)
356
+ if meta = metas[source]
357
+ set_metadata(meta)
358
+ end
359
+ end
360
+ end
361
+
362
+ # Create a new setting. The value is passed in because it's used to determine
363
+ # what kind of setting we're creating, but the value itself might be either
364
+ # a default or a value, so we can't actually assign it.
365
+ def newsetting(hash)
366
+ klass = nil
367
+ hash[:section] = hash[:section].to_sym if hash[:section]
368
+ if type = hash[:type]
369
+ unless klass = {:setting => Setting, :file => FileSetting, :boolean => BooleanSetting}[type]
370
+ raise ArgumentError, "Invalid setting type '#{type}'"
371
+ end
372
+ hash.delete(:type)
373
+ else
374
+ case hash[:default]
375
+ when true, false, "true", "false"
376
+ klass = BooleanSetting
377
+ when /^\$\w+\//, /^\//, /^\w:\//
378
+ klass = FileSetting
379
+ when String, Integer, Float # nothing
380
+ klass = Setting
381
+ else
382
+ raise ArgumentError, "Invalid value '#{hash[:default].inspect}' for #{hash[:name]}"
383
+ end
384
+ end
385
+ hash[:settings] = self
386
+ setting = klass.new(hash)
387
+
388
+ setting
389
+ end
390
+
391
+ # This has to be private, because it doesn't add the settings to @config
392
+ private :newsetting
393
+
394
+ # Iterate across all of the objects in a given section.
395
+ def persection(section)
396
+ section = section.to_sym
397
+ self.each { |name, obj|
398
+ if obj.section == section
399
+ yield obj
400
+ end
401
+ }
402
+ end
403
+
404
+ # Cache this in an easily clearable way, since we were
405
+ # having trouble cleaning it up after tests.
406
+ cached_attr(:file) do
407
+ if path = self[:config] and FileTest.exist?(path)
408
+ Puppet::Util::LoadedFile.new(path)
409
+ end
410
+ end
411
+
412
+ # Reparse our config file, if necessary.
413
+ def reparse
414
+ if file and file.changed?
415
+ Puppet.notice "Reparsing #{file.file}"
416
+ parse
417
+ reuse
418
+ end
419
+ end
420
+
421
+ def reuse
422
+ return unless defined?(@used)
423
+ @sync.synchronize do # yay, thread-safe
424
+ new = @used
425
+ @used = []
426
+ self.use(*new)
427
+ end
428
+ end
429
+
430
+ # The order in which to search for values.
431
+ def searchpath(environment = nil)
432
+ if environment
433
+ [:cli, :memory, environment, :run_mode, :main, :mutable_defaults]
434
+ else
435
+ [:cli, :memory, :run_mode, :main, :mutable_defaults]
436
+ end
437
+ end
438
+
439
+ # Get a list of objects per section
440
+ def sectionlist
441
+ sectionlist = []
442
+ self.each { |name, obj|
443
+ section = obj.section || "puppet"
444
+ sections[section] ||= []
445
+ sectionlist << section unless sectionlist.include?(section)
446
+ sections[section] << obj
447
+ }
448
+
449
+ return sectionlist, sections
450
+ end
451
+
452
+ def service_user_available?
453
+ return @service_user_available if defined?(@service_user_available)
454
+
455
+ return @service_user_available = false unless user_name = self[:user]
456
+
457
+ user = Puppet::Type.type(:user).new :name => self[:user], :audit => :ensure
458
+
459
+ @service_user_available = user.exists?
460
+ end
461
+
462
+ def legacy_to_mode(type, param)
463
+ if not defined?(@app_names)
464
+ require 'puppet/util/command_line'
465
+ command_line = Puppet::Util::CommandLine.new
466
+ @app_names = Puppet::Util::CommandLine::LegacyName.inject({}) do |hash, pair|
467
+ app, legacy = pair
468
+ command_line.require_application app
469
+ hash[legacy.to_sym] = Puppet::Application.find(app).run_mode.name
470
+ hash
471
+ end
472
+ end
473
+ if new_type = @app_names[type]
474
+ Puppet.warning "You have configuration parameter $#{param} specified in [#{type}], which is a deprecated section. I'm assuming you meant [#{new_type}]"
475
+ return new_type
476
+ end
477
+ type
478
+ end
479
+
480
+ def set_value(param, value, type, options = {})
481
+ param = param.to_sym
482
+ unless setting = @config[param]
483
+ if options[:ignore_bad_settings]
484
+ return
485
+ else
486
+ raise ArgumentError,
487
+ "Attempt to assign a value to unknown configuration parameter #{param.inspect}"
488
+ end
489
+ end
490
+ value = setting.munge(value) if setting.respond_to?(:munge)
491
+ setting.handle(value) if setting.respond_to?(:handle) and not options[:dont_trigger_handles]
492
+ if ReadOnly.include? param and type != :mutable_defaults
493
+ raise ArgumentError,
494
+ "You're attempting to set configuration parameter $#{param}, which is read-only."
495
+ end
496
+ type = legacy_to_mode(type, param)
497
+ @sync.synchronize do # yay, thread-safe
498
+ @values[type][param] = value
499
+ @cache.clear
500
+
501
+ clearused
502
+
503
+ # Clear the list of environments, because they cache, at least, the module path.
504
+ # We *could* preferentially just clear them if the modulepath is changed,
505
+ # but we don't really know if, say, the vardir is changed and the modulepath
506
+ # is defined relative to it. We need the defined?(stuff) because of loading
507
+ # order issues.
508
+ Puppet::Node::Environment.clear if defined?(Puppet::Node) and defined?(Puppet::Node::Environment)
509
+ end
510
+
511
+ value
512
+ end
513
+
514
+ # Set a bunch of defaults in a given section. The sections are actually pretty
515
+ # pointless, but they help break things up a bit, anyway.
516
+ def setdefaults(section, defs)
517
+ section = section.to_sym
518
+ call = []
519
+ defs.each { |name, hash|
520
+ if hash.is_a? Array
521
+ unless hash.length == 2
522
+ raise ArgumentError, "Defaults specified as an array must contain only the default value and the decription"
523
+ end
524
+ tmp = hash
525
+ hash = {}
526
+ [:default, :desc].zip(tmp).each { |p,v| hash[p] = v }
527
+ end
528
+ name = name.to_sym
529
+ hash[:name] = name
530
+ hash[:section] = section
531
+ raise ArgumentError, "Parameter #{name} is already defined" if @config.include?(name)
532
+ tryconfig = newsetting(hash)
533
+ if short = tryconfig.short
534
+ if other = @shortnames[short]
535
+ raise ArgumentError, "Parameter #{other.name} is already using short name '#{short}'"
536
+ end
537
+ @shortnames[short] = tryconfig
538
+ end
539
+ @config[name] = tryconfig
540
+
541
+ # Collect the settings that need to have their hooks called immediately.
542
+ # We have to collect them so that we can be sure we're fully initialized before
543
+ # the hook is called.
544
+ call << tryconfig if tryconfig.call_on_define
545
+ }
546
+
547
+ call.each { |setting| setting.handle(self.value(setting.name)) }
548
+ end
549
+
550
+ # Create a timer to check whether the file should be reparsed.
551
+ def set_filetimeout_timer
552
+ return unless timeout = self[:filetimeout] and timeout = Integer(timeout) and timeout > 0
553
+ timer = EventLoop::Timer.new(:interval => timeout, :tolerance => 1, :start? => true) { self.reparse }
554
+ end
555
+
556
+ # Convert the settings we manage into a catalog full of resources that model those settings.
557
+ def to_catalog(*sections)
558
+ sections = nil if sections.empty?
559
+
560
+ catalog = Puppet::Resource::Catalog.new("Settings")
561
+
562
+ @config.values.find_all { |value| value.is_a?(FileSetting) }.each do |file|
563
+ next unless (sections.nil? or sections.include?(file.section))
564
+ next unless resource = file.to_resource
565
+ next if catalog.resource(resource.ref)
566
+
567
+ catalog.add_resource(resource)
568
+ end
569
+
570
+ add_user_resources(catalog, sections)
571
+
572
+ catalog
573
+ end
574
+
575
+ # Convert our list of config settings into a configuration file.
576
+ def to_config
577
+ str = %{The configuration file for #{Puppet[:name]}. Note that this file
596
578
  is likely to have unused configuration parameters in it; any parameter that's
597
579
  valid anywhere in Puppet can be in any config file, even if it's not used.
598
580
 
@@ -605,361 +587,346 @@ Generated on #{Time.now}.
605
587
 
606
588
  }.gsub(/^/, "# ")
607
589
 
608
- # Add a section heading that matches our name.
609
- if @config.include?(:name)
610
- str += "[%s]\n" % self[:name]
611
- end
612
- eachsection do |section|
613
- persection(section) do |obj|
614
- str += obj.to_config + "\n"
615
- end
616
- end
617
-
618
- return str
619
- end
620
-
621
- # Convert to a parseable manifest
622
- def to_manifest
623
- catalog = to_catalog
624
- # The resource list is a list of references, not actual instances.
625
- catalog.resources.collect do |ref|
626
- catalog.resource(ref).to_manifest
627
- end.join("\n\n")
628
- end
629
-
630
- # Create the necessary objects to use a section. This is idempotent;
631
- # you can 'use' a section as many times as you want.
632
- def use(*sections)
633
- sections = sections.collect { |s| s.to_sym }
634
- @sync.synchronize do # yay, thread-safe
635
- sections = sections.reject { |s| @used.include?(s) }
636
-
637
- return if sections.empty?
638
-
639
- begin
640
- catalog = to_catalog(*sections).to_ral
641
- rescue => detail
642
- puts detail.backtrace if Puppet[:trace]
643
- Puppet.err "Could not create resources for managing Puppet's files and directories in sections %s: %s" % [sections.inspect, detail]
644
-
645
- # We need some way to get rid of any resources created during the catalog creation
646
- # but not cleaned up.
647
- return
648
- end
649
-
650
- begin
651
- catalog.host_config = false
652
- catalog.apply do |transaction|
653
- if transaction.any_failed?
654
- report = transaction.report
655
- failures = report.logs.find_all { |log| log.level == :err }
656
- raise "Got %s failure(s) while initializing: %s" % [failures.length, failures.collect { |l| l.to_s }.join("; ")]
657
- end
658
- end
659
- end
660
-
661
- sections.each { |s| @used << s }
662
- @used.uniq!
663
- end
664
- end
665
-
666
- def valid?(param)
667
- param = param.to_sym
668
- @config.has_key?(param)
669
- end
670
-
671
- def uninterpolated_value(param, environment = nil)
672
- param = param.to_sym
673
- environment = environment.to_sym if environment
674
-
675
- # See if we can find it within our searchable list of values
676
- val = catch :foundval do
677
- each_source(environment) do |source|
678
- # Look for the value. We have to test the hash for whether
679
- # it exists, because the value might be false.
680
- @sync.synchronize do
681
- if @values[source].include?(param)
682
- throw :foundval, @values[source][param]
683
- end
684
- end
685
- end
686
- throw :foundval, nil
590
+ # Add a section heading that matches our name.
591
+ if @config.include?(:run_mode)
592
+ str += "[#{self[:run_mode]}]\n"
593
+ end
594
+ eachsection do |section|
595
+ persection(section) do |obj|
596
+ str += obj.to_config + "\n" unless ReadOnly.include? obj.name
597
+ end
598
+ end
599
+
600
+ return str
601
+ end
602
+
603
+ # Convert to a parseable manifest
604
+ def to_manifest
605
+ catalog = to_catalog
606
+ catalog.resource_refs.collect do |ref|
607
+ catalog.resource(ref).to_manifest
608
+ end.join("\n\n")
609
+ end
610
+
611
+ # Create the necessary objects to use a section. This is idempotent;
612
+ # you can 'use' a section as many times as you want.
613
+ def use(*sections)
614
+ sections = sections.collect { |s| s.to_sym }
615
+ @sync.synchronize do # yay, thread-safe
616
+ sections = sections.reject { |s| @used.include?(s) }
617
+
618
+ return if sections.empty?
619
+
620
+ begin
621
+ catalog = to_catalog(*sections).to_ral
622
+ rescue => detail
623
+ puts detail.backtrace if Puppet[:trace]
624
+ Puppet.err "Could not create resources for managing Puppet's files and directories in sections #{sections.inspect}: #{detail}"
625
+
626
+ # We need some way to get rid of any resources created during the catalog creation
627
+ # but not cleaned up.
628
+ return
629
+ end
630
+
631
+ catalog.host_config = false
632
+ catalog.apply do |transaction|
633
+ if transaction.any_failed?
634
+ report = transaction.report
635
+ failures = report.logs.find_all { |log| log.level == :err }
636
+ raise "Got #{failures.length} failure(s) while initializing: #{failures.collect { |l| l.to_s }.join("; ")}"
637
+ end
638
+ end
639
+
640
+ sections.each { |s| @used << s }
641
+ @used.uniq!
642
+ end
643
+ end
644
+
645
+ def valid?(param)
646
+ param = param.to_sym
647
+ @config.has_key?(param)
648
+ end
649
+
650
+ def uninterpolated_value(param, environment = nil)
651
+ param = param.to_sym
652
+ environment &&= environment.to_sym
653
+
654
+ # See if we can find it within our searchable list of values
655
+ val = catch :foundval do
656
+ each_source(environment) do |source|
657
+ # Look for the value. We have to test the hash for whether
658
+ # it exists, because the value might be false.
659
+ @sync.synchronize do
660
+ throw :foundval, @values[source][param] if @values[source].include?(param)
687
661
  end
688
-
689
- # If we didn't get a value, use the default
690
- val = @config[param].default if val.nil?
691
-
692
- return val
662
+ end
663
+ throw :foundval, nil
693
664
  end
694
665
 
695
- # Find the correct value using our search path. Optionally accept an environment
696
- # in which to search before the other configuration sections.
697
- def value(param, environment = nil)
698
- param = param.to_sym
699
- environment = environment.to_sym if environment
700
-
701
- # Short circuit to nil for undefined parameters.
702
- return nil unless @config.include?(param)
666
+ # If we didn't get a value, use the default
667
+ val = @config[param].default if val.nil?
703
668
 
704
- # Yay, recursion.
705
- #self.reparse() unless [:config, :filetimeout].include?(param)
669
+ val
670
+ end
706
671
 
707
- # Check the cache first. It needs to be a per-environment
708
- # cache so that we don't spread values from one env
709
- # to another.
710
- if cached = @cache[environment||"none"][param]
711
- return cached
712
- end
713
-
714
- val = uninterpolated_value(param, environment)
672
+ # Find the correct value using our search path. Optionally accept an environment
673
+ # in which to search before the other configuration sections.
674
+ def value(param, environment = nil)
675
+ param = param.to_sym
676
+ environment &&= environment.to_sym
715
677
 
716
- # Convert it if necessary
717
- val = convert(val, environment)
678
+ # Short circuit to nil for undefined parameters.
679
+ return nil unless @config.include?(param)
718
680
 
719
- # And cache it
720
- @cache[environment||"none"][param] = val
721
- return val
722
- end
681
+ # Yay, recursion.
682
+ #self.reparse unless [:config, :filetimeout].include?(param)
723
683
 
724
- # Open a file with the appropriate user, group, and mode
725
- def write(default, *args, &bloc)
726
- obj = get_config_file_default(default)
727
- writesub(default, value(obj.name), *args, &bloc)
684
+ # Check the cache first. It needs to be a per-environment
685
+ # cache so that we don't spread values from one env
686
+ # to another.
687
+ if cached = @cache[environment||"none"][param]
688
+ return cached
728
689
  end
729
690
 
730
- # Open a non-default file under a default dir with the appropriate user,
731
- # group, and mode
732
- def writesub(default, file, *args, &bloc)
733
- obj = get_config_file_default(default)
734
- chown = nil
735
- if Puppet::Util::SUIDManager.uid == 0
736
- chown = [obj.owner, obj.group]
737
- else
738
- chown = [nil, nil]
739
- end
740
-
741
- Puppet::Util::SUIDManager.asuser(*chown) do
742
- mode = obj.mode || 0640
743
- if args.empty?
744
- args << "w"
745
- end
691
+ val = uninterpolated_value(param, environment)
746
692
 
747
- args << mode
748
-
749
- # Update the umask to make non-executable files
750
- Puppet::Util.withumask(File.umask ^ 0111) do
751
- File.open(file, *args) do |file|
752
- yield file
753
- end
754
- end
755
- end
756
- end
757
-
758
- def readwritelock(default, *args, &bloc)
759
- file = value(get_config_file_default(default).name)
760
- tmpfile = file + ".tmp"
761
- sync = Sync.new
762
- unless FileTest.directory?(File.dirname(tmpfile))
763
- raise Puppet::DevError, "Cannot create %s; directory %s does not exist" %
764
- [file, File.dirname(file)]
765
- end
766
-
767
- sync.synchronize(Sync::EX) do
768
- File.open(file, ::File::CREAT|::File::RDWR, 0600) do |rf|
769
- rf.lock_exclusive do
770
- if File.exist?(tmpfile)
771
- raise Puppet::Error, ".tmp file already exists for %s; Aborting locked write. Check the .tmp file and delete if appropriate" %
772
- [file]
773
- end
774
-
775
- # If there's a failure, remove our tmpfile
776
- begin
777
- writesub(default, tmpfile, *args, &bloc)
778
- rescue
779
- File.unlink(tmpfile) if FileTest.exist?(tmpfile)
780
- raise
781
- end
782
-
783
- begin
784
- File.rename(tmpfile, file)
785
- rescue => detail
786
- Puppet.err "Could not rename %s to %s: %s" % [file, tmpfile, detail]
787
- File.unlink(tmpfile) if FileTest.exist?(tmpfile)
788
- end
789
- end
790
- end
791
- end
693
+ if param == :code
694
+ # if we interpolate code, all hell breaks loose.
695
+ return val
792
696
  end
793
697
 
794
- private
698
+ # Convert it if necessary
699
+ val = convert(val, environment)
795
700
 
796
- def get_config_file_default(default)
797
- obj = nil
798
- unless obj = @config[default]
799
- raise ArgumentError, "Unknown default %s" % default
800
- end
701
+ # And cache it
702
+ @cache[environment||"none"][param] = val
703
+ val
704
+ end
801
705
 
802
- unless obj.is_a? FileSetting
803
- raise ArgumentError, "Default %s is not a file" % default
804
- end
706
+ # Open a file with the appropriate user, group, and mode
707
+ def write(default, *args, &bloc)
708
+ obj = get_config_file_default(default)
709
+ writesub(default, value(obj.name), *args, &bloc)
710
+ end
805
711
 
806
- return obj
712
+ # Open a non-default file under a default dir with the appropriate user,
713
+ # group, and mode
714
+ def writesub(default, file, *args, &bloc)
715
+ obj = get_config_file_default(default)
716
+ chown = nil
717
+ if Puppet.features.root?
718
+ chown = [obj.owner, obj.group]
719
+ else
720
+ chown = [nil, nil]
807
721
  end
808
722
 
809
- # Create the transportable objects for users and groups.
810
- def add_user_resources(catalog, sections)
811
- return unless Puppet.features.root?
812
- return unless self[:mkusers]
813
-
814
- @config.each do |name, setting|
815
- next unless setting.respond_to?(:owner)
816
- next unless sections.nil? or sections.include?(setting.section)
817
-
818
- if user = setting.owner and user != "root" and catalog.resource(:user, user).nil?
819
- resource = Puppet::Resource.new(:user, user, :ensure => :present)
820
- if self[:group]
821
- resource[:gid] = self[:group]
822
- end
823
- catalog.add_resource resource
824
- end
825
- if group = setting.group and ! %w{root wheel}.include?(group) and catalog.resource(:group, group).nil?
826
- catalog.add_resource Puppet::Resource.new(:group, group, :ensure => :present)
827
- end
828
- end
829
- end
723
+ Puppet::Util::SUIDManager.asuser(*chown) do
724
+ mode = obj.mode || 0640
725
+ args << "w" if args.empty?
830
726
 
831
- # Yield each search source in turn.
832
- def each_source(environment)
833
- searchpath(environment).each do |source|
834
- # Modify the source as necessary.
835
- source = self.name if source == :name
836
- yield source
837
- end
838
- end
727
+ args << mode
839
728
 
840
- # Return all settings that have associated hooks; this is so
841
- # we can call them after parsing the configuration file.
842
- def settings_with_hooks
843
- @config.values.find_all { |setting| setting.respond_to?(:handle) }
844
- end
845
-
846
- # Extract extra setting information for files.
847
- def extract_fileinfo(string)
848
- result = {}
849
- value = string.sub(/\{\s*([^}]+)\s*\}/) do
850
- params = $1
851
- params.split(/\s*,\s*/).each do |str|
852
- if str =~ /^\s*(\w+)\s*=\s*([\w\d]+)\s*$/
853
- param, value = $1.intern, $2
854
- result[param] = value
855
- unless [:owner, :mode, :group].include?(param)
856
- raise ArgumentError, "Invalid file option '%s'" % param
857
- end
858
-
859
- if param == :mode and value !~ /^\d+$/
860
- raise ArgumentError, "File modes must be numbers"
861
- end
862
- else
863
- raise ArgumentError, "Could not parse '%s'" % string
864
- end
865
- end
866
- ''
867
- end
868
- result[:value] = value.sub(/\s*$/, '')
869
- return result
870
- end
871
-
872
- # Convert arguments into booleans, integers, or whatever.
873
- def munge_value(value)
874
- # Handle different data types correctly
875
- return case value
876
- when /^false$/i; false
877
- when /^true$/i; true
878
- when /^\d+$/i; Integer(value)
879
- when true; true
880
- when false; false
881
- else
882
- value.gsub(/^["']|["']$/,'').sub(/\s+$/, '')
729
+ # Update the umask to make non-executable files
730
+ Puppet::Util.withumask(File.umask ^ 0111) do
731
+ File.open(file, *args) do |file|
732
+ yield file
733
+ end
734
+ end
735
+ end
736
+ end
737
+
738
+ def readwritelock(default, *args, &bloc)
739
+ file = value(get_config_file_default(default).name)
740
+ tmpfile = file + ".tmp"
741
+ sync = Sync.new
742
+ raise Puppet::DevError, "Cannot create #{file}; directory #{File.dirname(file)} does not exist" unless FileTest.directory?(File.dirname(tmpfile))
743
+
744
+ sync.synchronize(Sync::EX) do
745
+ File.open(file, ::File::CREAT|::File::RDWR, 0600) do |rf|
746
+ rf.lock_exclusive do
747
+ if File.exist?(tmpfile)
748
+ raise Puppet::Error, ".tmp file already exists for #{file}; Aborting locked write. Check the .tmp file and delete if appropriate"
749
+ end
750
+
751
+ # If there's a failure, remove our tmpfile
752
+ begin
753
+ writesub(default, tmpfile, *args, &bloc)
754
+ rescue
755
+ File.unlink(tmpfile) if FileTest.exist?(tmpfile)
756
+ raise
757
+ end
758
+
759
+ begin
760
+ File.rename(tmpfile, file)
761
+ rescue => detail
762
+ Puppet.err "Could not rename #{file} to #{tmpfile}: #{detail}"
763
+ File.unlink(tmpfile) if FileTest.exist?(tmpfile)
764
+ end
765
+ end
766
+ end
767
+ end
768
+ end
769
+
770
+ private
771
+
772
+ def get_config_file_default(default)
773
+ obj = nil
774
+ unless obj = @config[default]
775
+ raise ArgumentError, "Unknown default #{default}"
776
+ end
777
+
778
+ raise ArgumentError, "Default #{default} is not a file" unless obj.is_a? FileSetting
779
+
780
+ obj
781
+ end
782
+
783
+ # Create the transportable objects for users and groups.
784
+ def add_user_resources(catalog, sections)
785
+ return unless Puppet.features.root?
786
+ return unless self[:mkusers]
787
+
788
+ @config.each do |name, setting|
789
+ next unless setting.respond_to?(:owner)
790
+ next unless sections.nil? or sections.include?(setting.section)
791
+
792
+ if user = setting.owner and user != "root" and catalog.resource(:user, user).nil?
793
+ resource = Puppet::Resource.new(:user, user, :parameters => {:ensure => :present})
794
+ resource[:gid] = self[:group] if self[:group]
795
+ catalog.add_resource resource
796
+ end
797
+ if group = setting.group and ! %w{root wheel}.include?(group) and catalog.resource(:group, group).nil?
798
+ catalog.add_resource Puppet::Resource.new(:group, group, :parameters => {:ensure => :present})
799
+ end
800
+ end
801
+ end
802
+
803
+ # Yield each search source in turn.
804
+ def each_source(environment)
805
+ searchpath(environment).each do |source|
806
+ # Modify the source as necessary.
807
+ source = self.run_mode if source == :run_mode
808
+ yield source
809
+ end
810
+ end
811
+
812
+ # Return all settings that have associated hooks; this is so
813
+ # we can call them after parsing the configuration file.
814
+ def settings_with_hooks
815
+ @config.values.find_all { |setting| setting.respond_to?(:handle) }
816
+ end
817
+
818
+ # Extract extra setting information for files.
819
+ def extract_fileinfo(string)
820
+ result = {}
821
+ value = string.sub(/\{\s*([^}]+)\s*\}/) do
822
+ params = $1
823
+ params.split(/\s*,\s*/).each do |str|
824
+ if str =~ /^\s*(\w+)\s*=\s*([\w\d]+)\s*$/
825
+ param, value = $1.intern, $2
826
+ result[param] = value
827
+ raise ArgumentError, "Invalid file option '#{param}'" unless [:owner, :mode, :group].include?(param)
828
+
829
+ if param == :mode and value !~ /^\d+$/
830
+ raise ArgumentError, "File modes must be numbers"
831
+ end
832
+ else
833
+ raise ArgumentError, "Could not parse '#{string}'"
834
+ end
835
+ end
836
+ ''
837
+ end
838
+ result[:value] = value.sub(/\s*$/, '')
839
+ result
840
+ end
841
+
842
+ # Convert arguments into booleans, integers, or whatever.
843
+ def munge_value(value)
844
+ # Handle different data types correctly
845
+ return case value
846
+ when /^false$/i; false
847
+ when /^true$/i; true
848
+ when /^\d+$/i; Integer(value)
849
+ when true; true
850
+ when false; false
851
+ else
852
+ value.gsub(/^["']|["']$/,'').sub(/\s+$/, '')
853
+ end
854
+ end
855
+
856
+ # This method just turns a file in to a hash of hashes.
857
+ def parse_file(file)
858
+ text = read_file(file)
859
+
860
+ result = Hash.new { |names, name|
861
+ names[name] = {}
862
+ }
863
+
864
+ count = 0
865
+
866
+ # Default to 'main' for the section.
867
+ section = :main
868
+ result[section][:_meta] = {}
869
+ text.split(/\n/).each { |line|
870
+ count += 1
871
+ case line
872
+ when /^\s*\[(\w+)\]\s*$/
873
+ section = $1.intern # Section names
874
+ # Add a meta section
875
+ result[section][:_meta] ||= {}
876
+ when /^\s*#/; next # Skip comments
877
+ when /^\s*$/; next # Skip blanks
878
+ when /^\s*(\w+)\s*=\s*(.*?)\s*$/ # settings
879
+ var = $1.intern
880
+
881
+ # We don't want to munge modes, because they're specified in octal, so we'll
882
+ # just leave them as a String, since Puppet handles that case correctly.
883
+ if var == :mode
884
+ value = $2
885
+ else
886
+ value = munge_value($2)
883
887
  end
884
- end
885
888
 
886
- # This is an abstract method that just turns a file in to a hash of hashes.
887
- # We mostly need this for backward compatibility -- as of May 2007 we need to
888
- # support parsing old files with any section, or new files with just two
889
- # valid sections.
890
- def parse_file(file)
891
- text = read_file(file)
892
-
893
- result = Hash.new { |names, name|
894
- names[name] = {}
895
- }
896
-
897
- count = 0
898
-
899
- # Default to 'main' for the section.
900
- section = :main
901
- result[section][:_meta] = {}
902
- text.split(/\n/).each { |line|
903
- count += 1
904
- case line
905
- when /^\s*\[(\w+)\]$/
906
- section = $1.intern # Section names
907
- # Add a meta section
908
- result[section][:_meta] ||= {}
909
- when /^\s*#/; next # Skip comments
910
- when /^\s*$/; next # Skip blanks
911
- when /^\s*(\w+)\s*=\s*(.*)$/ # settings
912
- var = $1.intern
913
-
914
- # We don't want to munge modes, because they're specified in octal, so we'll
915
- # just leave them as a String, since Puppet handles that case correctly.
916
- if var == :mode
917
- value = $2
918
- else
919
- value = munge_value($2)
920
- end
921
-
922
- # Check to see if this is a file argument and it has extra options
923
- begin
924
- if value.is_a?(String) and options = extract_fileinfo(value)
925
- value = options[:value]
926
- options.delete(:value)
927
- result[section][:_meta][var] = options
928
- end
929
- result[section][var] = value
930
- rescue Puppet::Error => detail
931
- detail.file = file
932
- detail.line = line
933
- raise
934
- end
935
- else
936
- error = Puppet::Error.new("Could not match line %s" % line)
937
- error.file = file
938
- error.line = line
939
- raise error
940
- end
941
- }
942
-
943
- return result
944
- end
945
-
946
- # Read the file in.
947
- def read_file(file)
889
+ # Check to see if this is a file argument and it has extra options
948
890
  begin
949
- return File.read(file)
950
- rescue Errno::ENOENT
951
- raise ArgumentError, "No such file %s" % file
952
- rescue Errno::EACCES
953
- raise ArgumentError, "Permission denied to file %s" % file
954
- end
955
- end
956
-
957
- # Set file metadata.
958
- def set_metadata(meta)
959
- meta.each do |var, values|
960
- values.each do |param, value|
961
- @config[var].send(param.to_s + "=", value)
962
- end
963
- end
964
- end
891
+ if value.is_a?(String) and options = extract_fileinfo(value)
892
+ value = options[:value]
893
+ options.delete(:value)
894
+ result[section][:_meta][var] = options
895
+ end
896
+ result[section][var] = value
897
+ rescue Puppet::Error => detail
898
+ detail.file = file
899
+ detail.line = line
900
+ raise
901
+ end
902
+ else
903
+ error = Puppet::Error.new("Could not match line #{line}")
904
+ error.file = file
905
+ error.line = line
906
+ raise error
907
+ end
908
+ }
909
+
910
+ result
911
+ end
912
+
913
+ # Read the file in.
914
+ def read_file(file)
915
+ begin
916
+ return File.read(file)
917
+ rescue Errno::ENOENT
918
+ raise ArgumentError, "No such file #{file}"
919
+ rescue Errno::EACCES
920
+ raise ArgumentError, "Permission denied to file #{file}"
921
+ end
922
+ end
923
+
924
+ # Set file metadata.
925
+ def set_metadata(meta)
926
+ meta.each do |var, values|
927
+ values.each do |param, value|
928
+ @config[var].send(param.to_s + "=", value)
929
+ end
930
+ end
931
+ end
965
932
  end