puppet 3.0.0.rc5 → 3.0.0.rc7

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 (398) hide show
  1. data/LICENSE +1 -1
  2. data/README_DEVELOPER.md +209 -1
  3. data/README_HIERA.md +148 -0
  4. data/Rakefile +25 -27
  5. data/bin/extlookup2hiera +56 -0
  6. data/conf/auth.conf +34 -34
  7. data/examples/hiera/README.md +91 -0
  8. data/examples/hiera/etc/hiera.yaml +15 -0
  9. data/examples/hiera/etc/hieradb/common.yaml +3 -0
  10. data/examples/hiera/etc/hieradb/dc1.yaml +6 -0
  11. data/examples/hiera/etc/hieradb/development.yaml +2 -0
  12. data/examples/hiera/etc/puppet.conf +3 -0
  13. data/examples/hiera/modules/data/manifests/common.pp +3 -0
  14. data/examples/hiera/modules/ntp/manifests/config.pp +5 -0
  15. data/examples/hiera/modules/ntp/manifests/data.pp +3 -0
  16. data/examples/hiera/modules/ntp/templates/ntp.conf.erb +3 -0
  17. data/examples/hiera/modules/users/manifests/common.pp +3 -0
  18. data/examples/hiera/modules/users/manifests/dc1.pp +3 -0
  19. data/examples/hiera/modules/users/manifests/development.pp +3 -0
  20. data/examples/hiera/site.pp +3 -0
  21. data/ext/build_defaults.yaml +23 -0
  22. data/ext/debian/README.Debian +8 -0
  23. data/ext/debian/README.source +2 -0
  24. data/ext/debian/TODO.Debian +1 -0
  25. data/ext/debian/changelog.erb +1104 -0
  26. data/ext/debian/compat +1 -0
  27. data/ext/debian/control +143 -0
  28. data/ext/debian/copyright +361 -0
  29. data/ext/debian/docs +1 -0
  30. data/ext/debian/fileserver.conf +17 -0
  31. data/ext/debian/puppet-common.dirs +8 -0
  32. data/ext/debian/puppet-common.install +4 -0
  33. data/ext/debian/puppet-common.lintian-overrides +5 -0
  34. data/ext/debian/puppet-common.manpages +2 -0
  35. data/ext/debian/puppet-common.postinst +35 -0
  36. data/ext/debian/puppet-common.postrm +32 -0
  37. data/ext/debian/puppet-el.dirs +1 -0
  38. data/ext/debian/puppet-el.emacsen-install +25 -0
  39. data/ext/debian/puppet-el.emacsen-remove +11 -0
  40. data/ext/debian/puppet-el.emacsen-startup +9 -0
  41. data/ext/debian/puppet-el.install +1 -0
  42. data/ext/debian/puppet-testsuite.install +2 -0
  43. data/ext/debian/puppet-testsuite.lintian-overrides +4 -0
  44. data/ext/debian/puppet.conf +14 -0
  45. data/ext/debian/puppet.default +7 -0
  46. data/ext/debian/puppet.init +118 -0
  47. data/ext/debian/puppet.lintian-overrides +3 -0
  48. data/ext/debian/puppet.logrotate +11 -0
  49. data/ext/debian/puppet.manpages +32 -0
  50. data/ext/debian/puppet.postinst +20 -0
  51. data/ext/debian/puppet.postrm +20 -0
  52. data/ext/debian/puppet.preinst +20 -0
  53. data/ext/debian/puppetmaster-common.install +2 -0
  54. data/ext/debian/puppetmaster-common.manpages +2 -0
  55. data/ext/debian/puppetmaster-common.puppetqd.default +27 -0
  56. data/ext/debian/puppetmaster-common.puppetqd.init +84 -0
  57. data/ext/debian/puppetmaster-passenger.dirs +4 -0
  58. data/ext/debian/puppetmaster-passenger.postinst +66 -0
  59. data/ext/debian/puppetmaster-passenger.postrm +33 -0
  60. data/ext/debian/puppetmaster.README.debian +16 -0
  61. data/ext/debian/puppetmaster.default +38 -0
  62. data/ext/debian/puppetmaster.init +158 -0
  63. data/ext/debian/puppetmaster.lintian-overrides +3 -0
  64. data/ext/debian/puppetmaster.postinst +20 -0
  65. data/ext/debian/puppetmaster.postrm +5 -0
  66. data/ext/debian/puppetmaster.preinst +22 -0
  67. data/ext/debian/rules +128 -0
  68. data/ext/debian/source/format +1 -0
  69. data/ext/debian/source/options +1 -0
  70. data/ext/debian/vim-puppet.README.Debian +13 -0
  71. data/ext/debian/vim-puppet.dirs +3 -0
  72. data/ext/debian/vim-puppet.yaml +5 -0
  73. data/ext/debian/watch +2 -0
  74. data/ext/emacs/puppet-mode.el +1 -0
  75. data/ext/envpuppet +4 -0
  76. data/ext/envpuppet.bat +3 -2
  77. data/{conf → ext}/freebsd/puppetd +0 -0
  78. data/{conf → ext}/freebsd/puppetmasterd +0 -0
  79. data/{conf → ext}/gentoo/conf.d/puppet +0 -0
  80. data/{conf → ext}/gentoo/conf.d/puppetmaster +0 -0
  81. data/{conf → ext}/gentoo/init.d/puppet +0 -0
  82. data/{conf → ext}/gentoo/init.d/puppetmaster +0 -0
  83. data/{conf → ext}/gentoo/puppet/fileserver.conf +0 -0
  84. data/{conf → ext}/gentoo/puppet/puppet.conf +0 -0
  85. data/ext/ips/puppet-agent +49 -0
  86. data/ext/ips/puppet-master +44 -0
  87. data/ext/ips/puppet.conf +29 -0
  88. data/ext/ips/puppet.p5m.erb +12 -0
  89. data/ext/ips/puppetagent.xml +46 -0
  90. data/ext/ips/puppetmaster.xml +42 -0
  91. data/ext/ips/rules +19 -0
  92. data/ext/ips/transforms +34 -0
  93. data/{conf → ext}/osx/PackageInfo.plist +0 -0
  94. data/{conf → ext}/osx/createpackage.sh +1 -1
  95. data/ext/osx/file_mapping.yaml +33 -0
  96. data/ext/osx/preflight.erb +37 -0
  97. data/{tasks/rake/templates → ext/osx}/prototype.plist.erb +0 -0
  98. data/ext/packaging/README-Solaris.md +117 -0
  99. data/ext/packaging/README.md +89 -0
  100. data/ext/packaging/tasks/00_utils.rb +236 -0
  101. data/ext/packaging/tasks/10_setupvars.rake +62 -0
  102. data/ext/packaging/tasks/apple.rake +201 -0
  103. data/ext/packaging/tasks/clean.rake +5 -0
  104. data/ext/packaging/tasks/deb.rake +105 -0
  105. data/ext/packaging/tasks/gem.rake +52 -0
  106. data/ext/packaging/tasks/ips.rake +78 -0
  107. data/ext/packaging/tasks/mock.rake +88 -0
  108. data/ext/packaging/tasks/release.rake +20 -0
  109. data/ext/packaging/tasks/rpm.rake +39 -0
  110. data/ext/packaging/tasks/ship.rake +34 -0
  111. data/ext/packaging/tasks/sign.rake +76 -0
  112. data/ext/packaging/tasks/tar.rake +20 -0
  113. data/ext/project_data.yaml +25 -0
  114. data/ext/rack/files/apache2.conf +2 -1
  115. data/{conf → ext}/redhat/client.init +0 -0
  116. data/{conf → ext}/redhat/client.sysconfig +0 -0
  117. data/{conf → ext}/redhat/fileserver.conf +0 -0
  118. data/{conf → ext}/redhat/logrotate +0 -0
  119. data/{conf → ext}/redhat/puppet.conf +0 -0
  120. data/{conf/redhat/puppet.spec → ext/redhat/puppet.spec.erb} +140 -33
  121. data/{conf → ext}/redhat/queue.init +0 -0
  122. data/{conf → ext}/redhat/rundir-perms.patch +0 -0
  123. data/{conf → ext}/redhat/server.init +0 -0
  124. data/{conf → ext}/redhat/server.sysconfig +0 -0
  125. data/{conf → ext}/solaris/pkginfo +0 -0
  126. data/{conf → ext}/solaris/smf/puppetd.xml +0 -0
  127. data/{conf → ext}/solaris/smf/puppetmasterd.xml +0 -0
  128. data/{conf → ext}/solaris/smf/svc-puppetd +0 -0
  129. data/{conf → ext}/solaris/smf/svc-puppetmasterd +0 -0
  130. data/{conf → ext}/suse/client.init +0 -0
  131. data/{conf → ext}/suse/fileserver.conf +0 -0
  132. data/{conf → ext}/suse/logrotate +0 -0
  133. data/{conf → ext}/suse/puppet.conf +0 -0
  134. data/{conf → ext}/suse/puppet.spec +1 -1
  135. data/{conf → ext}/suse/server.init +0 -0
  136. data/ext/systemd/puppetagent.service +13 -0
  137. data/ext/systemd/puppetmaster.service +13 -0
  138. data/{conf → ext}/windows/eventlog/Rakefile +0 -0
  139. data/{conf → ext}/windows/eventlog/puppetres.dll +0 -0
  140. data/{conf → ext}/windows/eventlog/puppetres.mc +0 -0
  141. data/ext/windows/service/daemon.bat +6 -0
  142. data/ext/windows/service/daemon.rb +90 -0
  143. data/install.rb +22 -32
  144. data/lib/hiera/backend/puppet_backend.rb +102 -0
  145. data/lib/hiera/scope.rb +42 -0
  146. data/lib/hiera_puppet.rb +89 -0
  147. data/lib/puppet.rb +1 -1
  148. data/lib/puppet/agent.rb +2 -2
  149. data/lib/puppet/agent/locker.rb +12 -9
  150. data/lib/puppet/application.rb +10 -8
  151. data/lib/puppet/application/agent.rb +12 -8
  152. data/lib/puppet/application/apply.rb +2 -2
  153. data/lib/puppet/application/cert.rb +6 -6
  154. data/lib/puppet/application/certificate.rb +1 -4
  155. data/lib/puppet/application/describe.rb +1 -1
  156. data/lib/puppet/application/device.rb +5 -2
  157. data/lib/puppet/application/doc.rb +1 -1
  158. data/lib/puppet/application/face_base.rb +3 -13
  159. data/lib/puppet/application/filebucket.rb +1 -1
  160. data/lib/puppet/application/inspect.rb +1 -1
  161. data/lib/puppet/application/kick.rb +4 -2
  162. data/lib/puppet/application/master.rb +2 -2
  163. data/lib/puppet/application/queue.rb +3 -1
  164. data/lib/puppet/application/resource.rb +1 -1
  165. data/lib/puppet/configurer.rb +11 -7
  166. data/lib/puppet/configurer/downloader.rb +1 -4
  167. data/lib/puppet/daemon.rb +4 -4
  168. data/lib/puppet/defaults.rb +64 -60
  169. data/lib/puppet/external/dot.rb +1 -1
  170. data/lib/puppet/external/pson/common.rb +15 -0
  171. data/lib/puppet/external/pson/pure.rb +0 -62
  172. data/lib/puppet/external/pson/pure/generator.rb +1 -1
  173. data/lib/puppet/external/pson/pure/parser.rb +2 -2
  174. data/lib/puppet/face/ca.rb +19 -14
  175. data/lib/puppet/face/config.rb +2 -2
  176. data/lib/puppet/face/facts.rb +1 -1
  177. data/lib/puppet/face/help/action.erb +0 -1
  178. data/lib/puppet/face/help/face.erb +0 -1
  179. data/lib/puppet/face/help/man.erb +3 -6
  180. data/lib/puppet/face/module/install.rb +1 -1
  181. data/lib/puppet/face/module/list.rb +1 -1
  182. data/lib/puppet/face/module/uninstall.rb +1 -1
  183. data/lib/puppet/face/node.rb +1 -1
  184. data/lib/puppet/face/node/clean.rb +30 -25
  185. data/lib/puppet/feature/base.rb +0 -3
  186. data/lib/puppet/feature/rails.rb +2 -1
  187. data/lib/puppet/file_serving/terminus_selector.rb +1 -1
  188. data/lib/puppet/indirector/catalog/active_record.rb +5 -0
  189. data/lib/puppet/indirector/catalog/static_compiler.rb +2 -3
  190. data/lib/puppet/indirector/certificate/disabled_ca.rb +22 -0
  191. data/lib/puppet/indirector/certificate_request/disabled_ca.rb +22 -0
  192. data/lib/puppet/indirector/certificate_revocation_list/disabled_ca.rb +22 -0
  193. data/lib/puppet/indirector/face.rb +3 -3
  194. data/lib/puppet/indirector/facts/active_record.rb +5 -0
  195. data/lib/puppet/indirector/facts/facter.rb +1 -4
  196. data/lib/puppet/indirector/facts/inventory_active_record.rb +6 -0
  197. data/lib/puppet/indirector/file_bucket_file/file.rb +2 -1
  198. data/lib/puppet/indirector/indirection.rb +2 -2
  199. data/lib/puppet/indirector/key/disabled_ca.rb +22 -0
  200. data/lib/puppet/indirector/node/active_record.rb +5 -0
  201. data/lib/puppet/indirector/request.rb +4 -0
  202. data/lib/puppet/indirector/resource/active_record.rb +5 -0
  203. data/lib/puppet/network/authentication.rb +30 -0
  204. data/lib/puppet/network/http.rb +0 -13
  205. data/lib/puppet/network/http/connection.rb +10 -2
  206. data/lib/puppet/network/http/handler.rb +8 -0
  207. data/lib/puppet/network/http/mongrel/rest.rb +5 -0
  208. data/lib/puppet/network/http/rack/rest.rb +7 -0
  209. data/lib/puppet/network/http/webrick.rb +3 -6
  210. data/lib/puppet/network/http/webrick/rest.rb +4 -0
  211. data/lib/puppet/network/server.rb +9 -33
  212. data/lib/puppet/node.rb +1 -1
  213. data/lib/puppet/node/facts.rb +0 -1
  214. data/lib/puppet/parser/compiler.rb +1 -1
  215. data/lib/puppet/parser/functions.rb +12 -1
  216. data/lib/puppet/parser/functions/hiera.rb +8 -0
  217. data/lib/puppet/parser/functions/hiera_array.rb +8 -0
  218. data/lib/puppet/parser/functions/hiera_hash.rb +8 -0
  219. data/lib/puppet/parser/functions/hiera_include.rb +11 -0
  220. data/lib/puppet/parser/functions/shellquote.rb +21 -29
  221. data/lib/puppet/parser/lexer.rb +2 -1
  222. data/lib/puppet/parser/scope.rb +8 -0
  223. data/lib/puppet/provider/exec/windows.rb +1 -1
  224. data/lib/puppet/provider/group/groupadd.rb +2 -3
  225. data/lib/puppet/provider/package/pkg.rb +37 -10
  226. data/lib/puppet/provider/service/daemontools.rb +1 -1
  227. data/lib/puppet/provider/service/launchd.rb +1 -1
  228. data/lib/puppet/provider/service/redhat.rb +1 -1
  229. data/lib/puppet/provider/service/runit.rb +1 -1
  230. data/lib/puppet/provider/user/useradd.rb +8 -3
  231. data/lib/puppet/provider/user/windows_adsi.rb +11 -0
  232. data/lib/puppet/provider/zfs/zfs.rb +29 -2
  233. data/lib/puppet/provider/zone/solaris.rb +144 -39
  234. data/lib/puppet/provider/zpool/zpool.rb +7 -10
  235. data/lib/puppet/settings.rb +50 -86
  236. data/lib/puppet/settings/duration_setting.rb +34 -0
  237. data/lib/puppet/settings/terminus_setting.rb +16 -0
  238. data/lib/puppet/ssl/base.rb +49 -9
  239. data/lib/puppet/ssl/certificate.rb +13 -9
  240. data/lib/puppet/ssl/certificate_authority.rb +4 -0
  241. data/lib/puppet/ssl/certificate_authority/interface.rb +10 -17
  242. data/lib/puppet/ssl/certificate_factory.rb +4 -21
  243. data/lib/puppet/ssl/certificate_request.rb +1 -10
  244. data/lib/puppet/ssl/certificate_revocation_list.rb +1 -3
  245. data/lib/puppet/ssl/digest.rb +20 -0
  246. data/lib/puppet/ssl/host.rb +31 -6
  247. data/lib/puppet/test/test_helper.rb +1 -1
  248. data/lib/puppet/transaction/report.rb +2 -1
  249. data/lib/puppet/type.rb +1 -1
  250. data/lib/puppet/type/augeas.rb +1 -1
  251. data/lib/puppet/type/cron.rb +1 -1
  252. data/lib/puppet/type/exec.rb +7 -8
  253. data/lib/puppet/type/file.rb +1 -1
  254. data/lib/puppet/type/file/content.rb +2 -2
  255. data/lib/puppet/type/file/ensure.rb +1 -1
  256. data/lib/puppet/type/file/mode.rb +1 -1
  257. data/lib/puppet/type/file/selcontext.rb +6 -2
  258. data/lib/puppet/type/file/source.rb +1 -1
  259. data/lib/puppet/type/schedule.rb +1 -1
  260. data/lib/puppet/type/scheduled_task.rb +1 -1
  261. data/lib/puppet/type/tidy.rb +1 -1
  262. data/lib/puppet/type/zone.rb +126 -253
  263. data/lib/puppet/util.rb +10 -23
  264. data/lib/puppet/util/adsi.rb +22 -14
  265. data/lib/puppet/util/log/destinations.rb +7 -0
  266. data/lib/puppet/util/log/rate_limited_logger.rb +40 -0
  267. data/lib/puppet/util/metric.rb +2 -2
  268. data/lib/puppet/util/monkey_patches.rb +8 -0
  269. data/lib/puppet/util/platform.rb +7 -0
  270. data/lib/puppet/util/selinux.rb +31 -36
  271. data/lib/puppet/util/windows/error.rb +1 -1
  272. data/lib/puppet/util/windows/process.rb +3 -3
  273. data/lib/puppet/util/windows/security.rb +7 -7
  274. data/lib/puppet/util/windows/user.rb +65 -2
  275. data/lib/puppet/util/zaml.rb +90 -46
  276. data/lib/puppet/version.rb +1 -1
  277. data/spec/fixtures/hiera.yaml +9 -0
  278. data/spec/fixtures/manifests/site.pp +0 -0
  279. data/spec/integration/defaults_spec.rb +25 -11
  280. data/spec/integration/faces/ca_spec.rb +11 -16
  281. data/spec/integration/network/server/webrick_spec.rb +14 -27
  282. data/spec/integration/node_spec.rb +4 -1
  283. data/spec/integration/parser/functions/require_spec.rb +3 -3
  284. data/spec/integration/parser/undef_param_spec.rb +88 -0
  285. data/spec/integration/provider/mount_spec.rb +4 -1
  286. data/spec/integration/ssl/certificate_authority_spec.rb +18 -0
  287. data/spec/lib/puppet_spec/files.rb +3 -3
  288. data/spec/lib/puppet_spec/settings.rb +0 -1
  289. data/spec/shared_contexts/platform.rb +8 -0
  290. data/spec/spec_helper.rb +6 -0
  291. data/spec/unit/agent/locker_spec.rb +8 -2
  292. data/spec/unit/application/agent_spec.rb +29 -7
  293. data/spec/unit/application/apply_spec.rb +1 -1
  294. data/spec/unit/application/device_spec.rb +18 -1
  295. data/spec/unit/application/face_base_spec.rb +16 -2
  296. data/spec/unit/application/kick_spec.rb +8 -0
  297. data/spec/unit/application/queue_spec.rb +5 -0
  298. data/spec/unit/application_spec.rb +13 -23
  299. data/spec/unit/configurer/downloader_spec.rb +2 -11
  300. data/spec/unit/configurer_spec.rb +6 -0
  301. data/spec/unit/face/node_spec.rb +1 -1
  302. data/spec/unit/hiera/backend/puppet_backend_spec.rb +140 -0
  303. data/spec/unit/hiera/scope_spec.rb +62 -0
  304. data/spec/unit/hiera_puppet_spec.rb +111 -0
  305. data/spec/unit/indirector/catalog/active_record_spec.rb +4 -0
  306. data/spec/unit/indirector/catalog/static_compiler_spec.rb +194 -0
  307. data/spec/unit/indirector/certificate/disabled_ca_spec.rb +33 -0
  308. data/spec/unit/indirector/certificate_request/disabled_ca_spec.rb +33 -0
  309. data/spec/unit/indirector/certificate_revocation_list/disabled_ca_spec.rb +33 -0
  310. data/spec/unit/indirector/facts/active_record_spec.rb +37 -26
  311. data/spec/unit/indirector/facts/inventory_active_record_spec.rb +5 -0
  312. data/spec/unit/indirector/hiera_spec.rb +2 -1
  313. data/spec/unit/indirector/key/disabled_ca_spec.rb +33 -0
  314. data/spec/unit/indirector/node/active_record_spec.rb +7 -0
  315. data/spec/unit/indirector/request_spec.rb +22 -0
  316. data/spec/unit/indirector/resource/active_record_spec.rb +5 -0
  317. data/spec/unit/module_tool/application_spec.rb +1 -1
  318. data/spec/unit/network/authentication_spec.rb +86 -0
  319. data/spec/unit/network/http/connection_spec.rb +21 -0
  320. data/spec/unit/network/http/handler_spec.rb +12 -0
  321. data/spec/unit/network/http/rack/rest_spec.rb +7 -0
  322. data/spec/unit/network/http/webrick_spec.rb +11 -26
  323. data/spec/unit/network/server_spec.rb +79 -192
  324. data/spec/unit/node/facts_spec.rb +2 -2
  325. data/spec/unit/parser/ast/vardef_spec.rb +4 -4
  326. data/spec/unit/parser/files_spec.rb +3 -0
  327. data/spec/unit/parser/functions/defined_spec.rb +5 -5
  328. data/spec/unit/parser/functions/fqdn_rand_spec.rb +1 -1
  329. data/spec/unit/parser/functions/hiera_array_spec.rb +23 -0
  330. data/spec/unit/parser/functions/hiera_hash_spec.rb +19 -0
  331. data/spec/unit/parser/functions/hiera_include_spec.rb +19 -0
  332. data/spec/unit/parser/functions/hiera_spec.rb +21 -0
  333. data/spec/unit/parser/functions/include_spec.rb +3 -3
  334. data/spec/unit/parser/functions/realize_spec.rb +3 -3
  335. data/spec/unit/parser/functions/require_spec.rb +5 -5
  336. data/spec/unit/parser/functions/shellquote_spec.rb +0 -4
  337. data/spec/unit/parser/functions_spec.rb +6 -10
  338. data/spec/unit/parser/lexer_spec.rb +13 -0
  339. data/spec/unit/parser/scope_spec.rb +16 -1
  340. data/spec/unit/provider/exec/posix_spec.rb +7 -6
  341. data/spec/unit/provider/group/groupadd_spec.rb +36 -30
  342. data/spec/unit/provider/package/pkg_spec.rb +16 -2
  343. data/spec/unit/provider/service/redhat_spec.rb +2 -2
  344. data/spec/unit/provider/sshkey/parsed_spec.rb +4 -0
  345. data/spec/unit/provider/user/user_role_add_spec.rb +125 -126
  346. data/spec/unit/provider/user/useradd_spec.rb +147 -118
  347. data/spec/unit/provider/user/windows_adsi_spec.rb +22 -0
  348. data/spec/unit/provider/zone/solaris_spec.rb +126 -7
  349. data/spec/unit/provider/zpool/zpool_spec.rb +4 -3
  350. data/spec/unit/puppet_spec.rb +7 -0
  351. data/spec/unit/settings/duration_setting_spec.rb +45 -0
  352. data/spec/unit/settings/terminus_setting_spec.rb +28 -0
  353. data/spec/unit/settings_spec.rb +21 -23
  354. data/spec/unit/ssl/base_spec.rb +68 -19
  355. data/spec/unit/ssl/certificate_authority/interface_spec.rb +19 -30
  356. data/spec/unit/ssl/certificate_authority_spec.rb +3 -2
  357. data/spec/unit/ssl/certificate_factory_spec.rb +15 -6
  358. data/spec/unit/ssl/certificate_request_spec.rb +80 -113
  359. data/spec/unit/ssl/certificate_revocation_list_spec.rb +1 -1
  360. data/spec/unit/ssl/certificate_spec.rb +26 -2
  361. data/spec/unit/ssl/digest_spec.rb +35 -0
  362. data/spec/unit/ssl/host_spec.rb +73 -27
  363. data/spec/unit/ssl/key_spec.rb +0 -4
  364. data/spec/unit/type/exec_spec.rb +1 -1
  365. data/spec/unit/type/file_spec.rb +2 -1
  366. data/spec/unit/type/scheduled_task_spec.rb +2 -2
  367. data/spec/unit/type/zone_spec.rb +52 -10
  368. data/spec/unit/util/adsi_spec.rb +19 -0
  369. data/spec/unit/util/checksums_spec.rb +2 -3
  370. data/spec/unit/util/execution_spec.rb +1 -1
  371. data/spec/unit/util/log/destinations_spec.rb +1 -0
  372. data/spec/unit/util/log/rate_limited_logger_spec.rb +51 -0
  373. data/spec/unit/util/logging_spec.rb +6 -6
  374. data/spec/unit/util/selinux_spec.rb +24 -32
  375. data/spec/unit/util/zaml_spec.rb +94 -6
  376. data/spec/unit/util_spec.rb +17 -0
  377. data/spec/watchr.rb +2 -6
  378. data/tasks/{rake/manpages.rake → manpages.rake} +0 -0
  379. data/tasks/{rake/parser.rake → parser.rake} +0 -0
  380. metadata +1003 -119
  381. data/CHANGELOG +0 -9233
  382. data/conf/osx/preflight +0 -24
  383. data/lib/puppet/network/http/mongrel.rb +0 -35
  384. data/lib/puppet/util/config_timeout.rb +0 -24
  385. data/spec/unit/network/http/mongrel/rest_spec.rb +0 -257
  386. data/spec/unit/network/http/mongrel_spec.rb +0 -91
  387. data/spec/unit/network/http_spec.rb +0 -31
  388. data/spec/unit/util/config_timeout_spec.rb +0 -57
  389. data/tasks/rake/apple.rake +0 -176
  390. data/tasks/rake/changelog.rake +0 -15
  391. data/tasks/rake/ci.rake +0 -22
  392. data/tasks/rake/dailybuild.rake +0 -9
  393. data/tasks/rake/gem.rake +0 -63
  394. data/tasks/rake/git_workflow.rake +0 -134
  395. data/tasks/rake/metrics.rake +0 -14
  396. data/tasks/rake/sign.rake +0 -14
  397. data/tasks/rake/testbranch.rake +0 -16
  398. data/tasks/rake/yard.rake +0 -11
@@ -9,19 +9,15 @@ Puppet::Type.type(:zone).provide(:solaris) do
9
9
  # Convert the output of a list into a hash
10
10
  def self.line2hash(line)
11
11
  fields = [:id, :name, :ensure, :path, :uuid, :brand, :iptype]
12
+ properties = Hash[fields.zip(line.split(':'))]
12
13
 
13
- properties = {}
14
- line.split(":").each_with_index { |value, index|
15
- next unless fields[index]
16
- properties[fields[index]] = value
17
- }
18
-
14
+ del_id = [:brand, :uuid]
19
15
  # Configured but not installed zones do not have IDs
20
- properties.delete(:id) if properties[:id] == "-"
16
+ del_id << :id if properties[:id] == "-"
17
+ del_id.each { |p| properties.delete(p) }
21
18
 
22
19
  properties[:ensure] = properties[:ensure].intern
23
- properties.delete(:brand)
24
- properties.delete(:uuid)
20
+ properties[:iptype] = 'exclusive' if properties[:iptype] == 'excl'
25
21
 
26
22
  properties
27
23
  end
@@ -33,34 +29,135 @@ Puppet::Type.type(:zone).provide(:solaris) do
33
29
  end
34
30
  end
35
31
 
32
+ def multi_conf(name, should, &action)
33
+ has = properties[name]
34
+ has = [] if has == :absent
35
+ rms = has - should
36
+ adds = should - has
37
+ (rms.map{|o| action.call(:rm,o)} + adds.map{|o| action.call(:add,o)}).join("\n")
38
+ end
39
+
40
+ def self.def_prop(var, str)
41
+ define_method('%s_conf' % var.to_s) do |v|
42
+ str % v
43
+ end
44
+ define_method('%s=' % var.to_s) do |v|
45
+ setconfig self.send( ('%s_conf'% var).intern, v)
46
+ end
47
+ end
48
+
49
+ def self.def_multiprop(var, &conf)
50
+ define_method(var.to_s) do |v|
51
+ o = properties[var]
52
+ return '' if o.nil? or o == :absent
53
+ o.join(' ')
54
+ end
55
+ define_method('%s=' % var.to_s) do |v|
56
+ setconfig self.send( ('%s_conf'% var).intern, v)
57
+ end
58
+ define_method('%s_conf' % var.to_s) do |v|
59
+ multi_conf(var, v, &conf)
60
+ end
61
+ end
62
+
63
+ def_prop :iptype, "set ip-type=%s"
64
+ def_prop :autoboot, "set autoboot=%s"
65
+ def_prop :path, "set zonepath=%s"
66
+ def_prop :pool, "set pool=%s"
67
+ def_prop :shares, "add rctl\nset name=zone.cpu-shares\nadd value (priv=privileged,limit=%s,action=none)\nend"
68
+
69
+ def_multiprop :ip do |action, str|
70
+ interface, ip, defrouter = str.split(':')
71
+ case action
72
+ when :add
73
+ cmd = ["add net"]
74
+ cmd << "set physical=#{interface}" if interface
75
+ cmd << "set address=#{ip}" if ip
76
+ cmd << "set defrouter=#{defrouter}" if defrouter
77
+ cmd << "end"
78
+ cmd.join("\n")
79
+ when :rm
80
+ if ip
81
+ "remove net address=#{ip}"
82
+ elsif interface
83
+ "remove net physical=#{interface}"
84
+ else
85
+ raise ArgumentError, "can not remove network based on default router"
86
+ end
87
+ else self.fail action
88
+ end
89
+ end
90
+
91
+ def_multiprop :dataset do |action, str|
92
+ case action
93
+ when :add; ['add dataset',"set name=#{str}",'end'].join("\n")
94
+ when :rm; "remove dataset name=#{str}"
95
+ else self.fail action
96
+ end
97
+ end
98
+
99
+ def_multiprop :inherit do |action, str|
100
+ case action
101
+ when :add; ['add inherit-pkg-dir', "set dir=#{str}",'end'].join("\n")
102
+ when :rm; "remove inherit-pkg-dir dir=#{str}"
103
+ else self.fail action
104
+ end
105
+ end
106
+
107
+ def my_properties
108
+ [:path, :iptype, :autoboot, :pool, :shares, :ip, :dataset, :inherit]
109
+ end
110
+
36
111
  # Perform all of our configuration steps.
37
112
  def configure
38
113
  self.fail "Path is required" unless @resource[:path]
39
- # If the thing is entirely absent, then we need to create the config.
40
- # Is there someway to get this on one line?
41
- str = "create -b #{@resource[:create_args]}\nset zonepath=#{@resource[:path]}\n"
114
+ arr = ["create -b #{@resource[:create_args]}"]
42
115
 
43
116
  # Then perform all of our configuration steps. It's annoying
44
117
  # that we need this much internal info on the resource.
45
- @resource.send(:properties).each do |property|
46
- str += property.configtext + "\n" if property.is_a? ZoneConfigProperty and ! property.safe_insync?(properties[property.name])
118
+ self.resource.properties.each do |property|
119
+ next unless my_properties.include? property.name
120
+ method = (property.name.to_s + '_conf').intern
121
+ arr << self.send(method ,@resource[property.name]) unless property.safe_insync?(properties[property.name])
47
122
  end
48
-
49
- str += "commit\n"
50
- setconfig(str)
123
+ setconfig(arr.join("\n"))
51
124
  end
52
125
 
53
126
  def destroy
54
127
  zonecfg :delete, "-F"
55
128
  end
56
129
 
130
+ def add_cmd(cmd)
131
+ @cmds = [] if @cmds.nil?
132
+ @cmds << cmd
133
+ end
134
+
57
135
  def exists?
58
136
  properties[:ensure] != :absent
59
137
  end
60
138
 
139
+ # We cannot use the execpipe in util because the pipe is not opened in
140
+ # read/write mode.
141
+ def exec_cmd(var)
142
+ # In bash, the exit value of the last command is the exit value of the
143
+ # entire pipeline
144
+ out = execute("echo \"#{var[:input]}\" | #{var[:cmd]}", :failonfail => false, :combine => true)
145
+ st = $?.exitstatus
146
+ {:out => out, :exit => st}
147
+ end
148
+
61
149
  # Clear out the cached values.
62
150
  def flush
151
+ return if @cmds.nil? || @cmds.empty?
152
+ str = (@cmds << "commit" << "exit").join("\n")
153
+ @cmds = []
63
154
  @property_hash.clear
155
+
156
+ command = "#{command(:cfg)} -z #{@resource[:name]} -f -"
157
+ r = exec_cmd(:cmd => command, :input => str)
158
+ if r[:exit] != 0 or r[:out] =~ /not allowed/
159
+ raise ArgumentError, "Failed to apply configuration"
160
+ end
64
161
  end
65
162
 
66
163
  def install(dummy_argument=:work_arround_for_ruby_GC_bug)
@@ -84,7 +181,6 @@ Puppet::Type.type(:zone).provide(:solaris) do
84
181
  @property_hash[name] ||= :absent
85
182
  end
86
183
  end
87
-
88
184
  end
89
185
  @property_hash.dup
90
186
  end
@@ -92,19 +188,31 @@ Puppet::Type.type(:zone).provide(:solaris) do
92
188
  # We need a way to test whether a zone is in process. Our 'ensure'
93
189
  # property models the static states, but we need to handle the temporary ones.
94
190
  def processing?
95
- if hash = status
96
- case hash[:ensure]
97
- when "incomplete", "ready", "shutting_down"
98
- true
99
- else
100
- false
101
- end
102
- else
103
- false
104
- end
191
+ hash = status
192
+ return false unless hash
193
+ ["incomplete", "ready", "shutting_down"].include? hash[:ensure]
105
194
  end
106
195
 
107
- # Collect the configuration of the zone.
196
+ # Collect the configuration of the zone. The output looks like:
197
+ # zonename: z1
198
+ # zonepath: /export/z1
199
+ # brand: native
200
+ # autoboot: true
201
+ # bootargs:
202
+ # pool:
203
+ # limitpriv:
204
+ # scheduling-class:
205
+ # ip-type: shared
206
+ # hostid:
207
+ # net:
208
+ # address: 192.168.1.1
209
+ # physical: eg0001
210
+ # defrouter not specified
211
+ # net:
212
+ # address: 192.168.1.3
213
+ # physical: eg0002
214
+ # defrouter not specified
215
+ #
108
216
  def getconfig
109
217
  output = zonecfg :info
110
218
 
@@ -116,12 +224,11 @@ Puppet::Type.type(:zone).provide(:solaris) do
116
224
  when /^(\S+):\s*$/
117
225
  name = $1
118
226
  current = nil # reset it
119
- when /^(\S+):\s*(.+)$/
227
+ when /^(\S+):\s*(\S+)$/
120
228
  hash[$1.intern] = $2
121
229
  when /^\s+(\S+):\s*(.+)$/
122
230
  if name
123
- hash[name] = [] unless hash.include? name
124
-
231
+ hash[name] ||= []
125
232
  unless current
126
233
  current = {}
127
234
  hash[name] << current
@@ -141,16 +248,13 @@ Puppet::Type.type(:zone).provide(:solaris) do
141
248
  # Execute a configuration string. Can't be private because it's called
142
249
  # by the properties.
143
250
  def setconfig(str)
144
- output = cfg '-z', @resource[:name], str
145
- if output =~ /not allowed/ or $CHILD_STATUS != 0
146
- raise ArgumentError, "Failed to apply configuration"
147
- end
251
+ add_cmd str
148
252
  end
149
253
 
150
254
  def start
151
- self.fail "Path is required" unless @resource[:path]
152
255
  # Check the sysidcfg stuff
153
256
  if cfg = @resource[:sysidcfg]
257
+ self.fail "Path is required" unless @resource[:path]
154
258
  zoneetc = File.join(@resource[:path], "root", "etc")
155
259
  sysidcfg = File.join(zoneetc, "sysidcfg")
156
260
 
@@ -223,6 +327,7 @@ Puppet::Type.type(:zone).provide(:solaris) do
223
327
  if datasets = config["dataset"]
224
328
  result[:dataset] = datasets.collect { |dataset| dataset[:name] }
225
329
  end
330
+ result[:iptype] = config[:'ip-type'] if config[:'ip-type']
226
331
  if net = config["net"]
227
332
  result[:ip] = net.collect do |params|
228
333
  if params[:defrouter]
@@ -239,9 +344,9 @@ Puppet::Type.type(:zone).provide(:solaris) do
239
344
  end
240
345
 
241
346
  def zoneadm(*cmd)
242
- adm("-z", @resource[:name], *cmd)
347
+ adm("-z", @resource[:name], *cmd)
243
348
  rescue Puppet::ExecutionFailure => detail
244
- self.fail "Could not #{cmd[0]} zone: #{detail}"
349
+ self.fail "Could not #{cmd[0]} zone: #{detail}"
245
350
  end
246
351
 
247
352
  def zonecfg(*cmd)
@@ -48,8 +48,10 @@ Puppet::Type.type(:zpool).provide(:zpool) do
48
48
  end
49
49
 
50
50
  def get_pool_data
51
- #this is all voodoo dependent on the output from zpool
52
- zpool_data = %x{ zpool status #{@resource[:pool]}}.split("\n").select { |line| line.index("\t") == 0 }.collect { |l| l.strip.split("\s")[0] }
51
+ # http://docs.oracle.com/cd/E19082-01/817-2271/gbcve/index.html
52
+ # we could also use zpool iostat -v mypool for a (little bit) cleaner output
53
+ out = execute("zpool status #{@resource[:pool]}", :failonfail => false)
54
+ zpool_data = out.lines.select { |line| line.index("\t") == 0 }.collect { |l| l.strip.split("\s")[0] }
53
55
  zpool_data.shift
54
56
  zpool_data
55
57
  end
@@ -77,19 +79,14 @@ Puppet::Type.type(:zpool).provide(:zpool) do
77
79
  @resource[:raid_parity] ? @resource[:raid_parity] : "raidz1"
78
80
  end
79
81
 
80
- #handle mirror or raid
81
- def handle_multi_arrays(prefix, array)
82
- array.collect{ |a| [prefix] + a.split(' ') }.flatten
83
- end
84
-
85
82
  #builds up the vdevs for create command
86
83
  def build_vdevs
87
84
  if disk = @resource[:disk]
88
85
  disk.collect { |d| d.split(' ') }.flatten
89
86
  elsif mirror = @resource[:mirror]
90
- handle_multi_arrays("mirror", mirror)
87
+ ["mirror"] + mirror
91
88
  elsif raidz = @resource[:raidz]
92
- handle_multi_arrays(raidzarity, raidz)
89
+ [raidzarity] + raidz
93
90
  end
94
91
  end
95
92
 
@@ -115,7 +112,7 @@ Puppet::Type.type(:zpool).provide(:zpool) do
115
112
  end
116
113
 
117
114
  define_method(field.to_s + "=") do |should|
118
- Puppet.warning "NO CHANGES BEING MADE: zpool #{field} does not match, should be '#{should}' currently is '#{current_pool[field]}'"
115
+ self.fail "zpool #{field} can't be changed. should be #{should}, currently is #{current_pool[field]}"
119
116
  end
120
117
  end
121
118
 
@@ -9,6 +9,8 @@ require 'puppet/settings/file_setting'
9
9
  require 'puppet/settings/directory_setting'
10
10
  require 'puppet/settings/path_setting'
11
11
  require 'puppet/settings/boolean_setting'
12
+ require 'puppet/settings/terminus_setting'
13
+ require 'puppet/settings/duration_setting'
12
14
 
13
15
  # The class for handling configuration files.
14
16
  class Puppet::Settings
@@ -20,13 +22,11 @@ class Puppet::Settings
20
22
  attr_accessor :files
21
23
  attr_reader :timer
22
24
 
23
- READ_ONLY_SETTINGS = [:run_mode]
24
-
25
25
  # These are the settings that every app is required to specify; there are reasonable defaults defined in application.rb.
26
- REQUIRED_APP_SETTINGS = [:run_mode, :logdir, :confdir, :vardir]
26
+ REQUIRED_APP_SETTINGS = [:logdir, :confdir, :vardir]
27
27
 
28
28
  # This method is intended for puppet internal use only; it is a convenience method that
29
- # returns reasonable application default settings values for a given run_mode.
29
+ # returns reasonable application default settings values for a given run_mode.
30
30
  def self.app_defaults_for_run_mode(run_mode)
31
31
  {
32
32
  :name => run_mode.to_s,
@@ -139,22 +139,11 @@ class Puppet::Settings
139
139
  raise Puppet::DevError, "Attempting to initialize global default settings more than once!" if global_defaults_initialized?
140
140
 
141
141
  # The first two phases of the lifecycle of a puppet application are:
142
- # 1) To parse the command line options and handle any of them that are registered, defined "global" puppet
143
- # settings (mostly from defaults.rb).)
144
- # 2) To parse the puppet config file(s).
145
- #
146
- # These 2 steps are being handled explicitly here. If there ever arises a situation where they need to be
147
- # triggered from outside of this class, without triggering the rest of the lifecycle--we might want to move them
148
- # out into a separate method that we call from here. However, this seems to be sufficient for now.
149
- # --cprice 2012-03-16
142
+ # 1) Parse the command line options and handle any of them that are
143
+ # registered, defined "global" puppet settings (mostly from defaults.rb).
144
+ # 2) Parse the puppet config file(s).
150
145
 
151
- # Here's step 1.
152
146
  parse_global_options(args)
153
-
154
- # Here's step 2. NOTE: this is a change in behavior where we are now parsing the config file on every run;
155
- # before, there were several apps that specifically registered themselves as not requiring anything from
156
- # the config file. The fact that we're always parsing it now might be a small performance hit, but it was
157
- # necessary in order to make sure that we can resolve the libdir before we look for the available applications.
158
147
  parse_config_files
159
148
 
160
149
  @global_defaults_initialized = true
@@ -179,26 +168,22 @@ class Puppet::Settings
179
168
  end
180
169
  end
181
170
 
182
- option_parser.parse(args)
171
+ option_parser.on('--run_mode',
172
+ "The effective 'run mode' of the application: master, agent, or user.",
173
+ :REQUIRED) do |arg|
174
+ Puppet.settings.preferred_run_mode = arg
175
+
176
+ # remove this option from the arguments so that later parses don't think
177
+ # it is an unknown option
178
+ option_index = args.index '--run_mode'
179
+ args.delete_at option_index
180
+ args.delete_at option_index
181
+ end
183
182
 
183
+ option_parser.parse(args)
184
184
  end
185
185
  private :parse_global_options
186
186
 
187
-
188
- ## Private utility method; this is the callback that the OptionParser will use when it finds
189
- ## an option that was defined in Puppet.settings. All that this method does is a little bit
190
- ## of clanup to get the option into the exact format that Puppet.settings expects it to be in,
191
- ## and then passes it along to Puppet.settings.
192
- ##
193
- ## @param [String] opt the command-line option that was matched
194
- ## @param [String, TrueClass, FalseClass] the value for the setting (as determined by the OptionParser)
195
- #def handlearg(opt, val)
196
- # opt, val = self.class.clean_opt(opt, val)
197
- # Puppet.settings.handlearg(opt, val)
198
- #end
199
- #private :handlearg
200
-
201
-
202
187
  # A utility method (public, is used by application.rb and perhaps elsewhere) that munges a command-line
203
188
  # option string into the format that Puppet.settings expects. (This mostly has to deal with handling the
204
189
  # "no-" prefix on flag/boolean options).
@@ -227,7 +212,11 @@ class Puppet::Settings
227
212
  end
228
213
 
229
214
  app_defaults.each do |key, value|
230
- set_value(key, value, :application_defaults)
215
+ if key == :run_mode
216
+ self.preferred_run_mode = value
217
+ else
218
+ set_value(key, value, :application_defaults)
219
+ end
231
220
  end
232
221
  call_hooks_deferred_to_application_initialization
233
222
 
@@ -255,6 +244,8 @@ class Puppet::Settings
255
244
  varname = $2 || $1
256
245
  if varname == "environment" and environment
257
246
  environment
247
+ elsif varname == "run_mode"
248
+ preferred_run_mode
258
249
  elsif pval = self.value(varname, environment)
259
250
  pval
260
251
  else
@@ -439,18 +430,22 @@ class Puppet::Settings
439
430
  end
440
431
  end
441
432
 
442
- # Figure out the section name for the run_mode.
443
- def run_mode
444
- @run_mode || :user
433
+ # The currently configured run mode that is preferred for constructing the application configuration.
434
+ def preferred_run_mode
435
+ @preferred_run_mode_name || :user
445
436
  end
446
437
 
447
438
  # PRIVATE! This only exists because we need a hook to validate the run mode when it's being set, and
448
439
  # it should never, ever, ever, ever be called from outside of this file.
449
- def run_mode=(mode)
440
+ # This method is also called when --run_mode MODE is used on the command line to set the default
441
+ #
442
+ # @param mode [String|Symbol] the name of the mode to have in effect
443
+ # @api private
444
+ def preferred_run_mode=(mode)
445
+ mode = mode.to_s.downcase.intern
450
446
  raise ValidationError, "Invalid run mode '#{mode}'" unless [:master, :agent, :user].include?(mode)
451
- @run_mode = mode
447
+ @preferred_run_mode_name = mode
452
448
  end
453
- private :run_mode=
454
449
 
455
450
  # Return all of the parameters associated with a given section.
456
451
  def params(section = nil)
@@ -475,7 +470,7 @@ class Puppet::Settings
475
470
  # configuration model to the end user. It should also be noted we decided
476
471
  # to merge in the user puppet.conf with the system puppet.conf for a time
477
472
  # (e.g. load two configuration files) as a small part of #7749 but then
478
- # decided to reverse this decision in 15337 to return to a disjoint
473
+ # decided to reverse this decision in #15337 to return to a disjoint
479
474
  # configuration file model.
480
475
  config_files = [which_configuration_file]
481
476
 
@@ -483,22 +478,11 @@ class Puppet::Settings
483
478
  unsafe_parse(config_files)
484
479
  end
485
480
 
486
- # talking with cprice, Settings.parse will not be the final location for this. He's working on ticket
487
- # that, as a side effect, will create a more appropriate place for this. At that time, this will be
488
- # moved to the new location. --jeffweiss 24 apr 2012
489
481
  call_hooks_deferred_to_application_initialization :ignore_interpolation_dependency_errors => true
490
482
  end
491
483
  private :parse_config_files
492
484
 
493
485
  def main_config_file
494
- # the algorithm here is basically this:
495
- # * use the explicit config file location if one has been specified; this
496
- # can be affected by modifications to either the "confdir" or "config"
497
- # settings (most likely via CLI arguments).
498
- # * if no explicit config location has been specified, we fall back to
499
- # the default.
500
- #
501
- # return the default value.
502
486
  if explicit_config_file?
503
487
  return self[:config]
504
488
  else
@@ -512,12 +496,14 @@ class Puppet::Settings
512
496
  end
513
497
  private :user_config_file
514
498
 
515
- # This method is here to get around some life-cycle issues. We need to be able to determine the config file name
516
- # before the settings / defaults are fully loaded. However, we also need to respect any overrides of this value
499
+ # This method is here to get around some life-cycle issues. We need to be
500
+ # able to determine the config file name before the settings / defaults are
501
+ # fully loaded. However, we also need to respect any overrides of this value
517
502
  # that the user may have specified on the command line.
518
503
  #
519
- # The easiest way to do this is to attempt to read the setting, and if we catch an error (meaning that it hasn't been
520
- # set yet), we'll fall back to the default value.
504
+ # The easiest way to do this is to attempt to read the setting, and if we
505
+ # catch an error (meaning that it hasn't been set yet), we'll fall back to
506
+ # the default value.
521
507
  def config_file_name
522
508
  begin
523
509
  return self[:config_file_name] if self[:config_file_name]
@@ -598,7 +584,7 @@ class Puppet::Settings
598
584
  # because multiple sections could set the same value
599
585
  # and I'm too lazy to only set the metadata once.
600
586
  searchpath.reverse.each do |source|
601
- source = run_mode if source == :run_mode
587
+ source = preferred_run_mode if source == :run_mode
602
588
  source = @name if (@name && source == :name)
603
589
  if meta = metas[source]
604
590
  set_metadata(meta)
@@ -624,6 +610,8 @@ class Puppet::Settings
624
610
  :directory => DirectorySetting,
625
611
  :path => PathSetting,
626
612
  :boolean => BooleanSetting,
613
+ :terminus => TerminusSetting,
614
+ :duration => DurationSetting,
627
615
  } [type]
628
616
  raise ArgumentError, "Invalid setting type '#{type}'"
629
617
  end
@@ -738,7 +726,7 @@ class Puppet::Settings
738
726
  def set_value(param, value, type, options = {})
739
727
  param = param.to_sym
740
728
 
741
- unless setting = @config[param]
729
+ if !(setting = @config[param])
742
730
  if options[:ignore_bad_settings]
743
731
  return
744
732
  else
@@ -748,10 +736,6 @@ class Puppet::Settings
748
736
  end
749
737
 
750
738
  setting.handle(value) if setting.has_hook? and not options[:dont_trigger_handles]
751
- if read_only_settings.include? param and type != :application_defaults
752
- raise ArgumentError,
753
- "You're attempting to set configuration parameter $#{param}, which is read-only."
754
- end
755
739
 
756
740
  @sync.synchronize do # yay, thread-safe
757
741
 
@@ -768,19 +752,6 @@ class Puppet::Settings
768
752
  Puppet::Node::Environment.clear if defined?(Puppet::Node) and defined?(Puppet::Node::Environment)
769
753
  end
770
754
 
771
- # This is a hack. The run_mode should probably not be a "normal" setting, because the places
772
- # it is used tend to create lifecycle issues and cause other weird problems. In some places
773
- # we need for it to have a default value, in other places it may be preferable to be able to
774
- # determine that it has not yet been set. There used to be a global variable that some
775
- # code paths would access; as a first step towards cleaning it up, I've gotten rid of the global
776
- # variable and am instead using an instance variable in this class, but that means that if
777
- # someone modifies the value of the setting at a later point during execution, then the
778
- # instance variable needs to be updated as well... so that's what we're doing here.
779
- #
780
- # This code should be removed if we get a chance to remove run_mode from the defined settings.
781
- # --cprice 2012-03-19
782
- self.run_mode = value if param == :run_mode
783
-
784
755
  value
785
756
  end
786
757
 
@@ -889,12 +860,10 @@ Generated on #{Time.now}.
889
860
  }.gsub(/^/, "# ")
890
861
 
891
862
  # Add a section heading that matches our name.
892
- if @config.include?(:run_mode)
893
- str += "[#{self[:run_mode]}]\n"
894
- end
863
+ str += "[#{preferred_run_mode}]\n"
895
864
  eachsection do |section|
896
865
  persection(section) do |obj|
897
- str += obj.to_config + "\n" unless read_only_settings.include? obj.name or obj.name == :genconfig
866
+ str += obj.to_config + "\n" unless obj.name == :genconfig
898
867
  end
899
868
  end
900
869
 
@@ -1078,11 +1047,6 @@ if @config.include?(:run_mode)
1078
1047
 
1079
1048
  private
1080
1049
 
1081
- # This is just here to simplify testing. This method can be stubbed easily. Constants can't.
1082
- def read_only_settings()
1083
- READ_ONLY_SETTINGS
1084
- end
1085
-
1086
1050
  def get_config_file_default(default)
1087
1051
  obj = nil
1088
1052
  unless obj = @config[default]
@@ -1119,7 +1083,7 @@ if @config.include?(:run_mode)
1119
1083
  searchpath(environment).each do |source|
1120
1084
 
1121
1085
  # Modify the source as necessary.
1122
- source = self.run_mode if source == :run_mode
1086
+ source = self.preferred_run_mode if source == :run_mode
1123
1087
  yield source
1124
1088
  end
1125
1089
  end