diff --git a/CHANGELOG b/CHANGELOG index c3135031b..2885596e3 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5946 +1,6204 @@ +2.6.7rc1 +======== +852fb97 (#5073) Download plugins even if you're filtering on tags +4f34dbf Fix #5610: Prevent unnecessary RAL lookups +9781032 Revert "Merge branch 'ticket/2.6.x/5605' of git://github.com/stschulte/puppet into 2.6.next" +25926d1 (#6723) Fix withenv environment restoration bug +093f162 (#6689) Remove extraneous include of Puppet::Util in InventoryActiveRecord +4c19299 Remove extra trailing whitespace from lib/puppet/resource.rb +ff9e242 (#5428) More fully "stub" Puppet::Resource::Reference for use with storedconfigs +0262633 (#6707) Fix typo in rest_authconfig.rb +8858e40 (#6689) Make inventory_active_record terminus search quickly +285c4cc (#5392) Give a better error when realizing a non-existant resource +cd5deda (#2645) Adding a less-stubby test to verify the "system" attribute's behavior +531e258 maint: Remove serialization of InventoryFact values +3489412 maint: Rename InventoryHost to InventoryNode +4bd5493 Fixed #2645 - Added support for creating system users +a3f2357 maint: Remove spec run noise +7764412 maint:Refactor of mount provider integration tests +880d0c6 (#6338) Support searching on metadata in InventoryActiveRecord terminus +f836366 (#6338) Implement search for InventoryActiveRecord facts terminus +8ce30c8 (#6338) Add an InventoryActiveRecord terminus for Facts +1ef83cb Added integration tests for the mount provider +64440e5 (#6513) Propagate the environment when doing variable lookup in settings +92dffb2 (#6513) Adjust P::U::Settings test name to reflect what it tests +5ef1031 (#6632) Adding a new mount no longer causes error with umount +bd5517d Adjust Darwin mount provider tests to pass on Linux +9d2fceb Maint: Begin adding integration tests for the mount provider +23d1c03 Maint: Added the ability to replace the behavior of Puppet::Util.execute with an arbitrary code block for ease in spec testing. +455a891 (#5794) create reports directory when creating host specific directory +1b1e803 (5724) Prep for deprecation of DESTDIR +f4a0af1 Refactoring duplicate code and logic in prep for DESTDIR deprecation. +7a00d6b (#6606) Inline docs: Document all autorequire relationships +e3aec14 (#5148) Fix failing spec due to timezone +8bd80a9 (#5148) Add support for PSON to facts +c3baa28 (#6338) Remove inventory indirection, and move to facts indirection +6c53eb3 (#6445) Fix inline docs: puppet agent does not accept --mkusers +4e29f43 (#6541) maint: whitespace cleanup on the file integration spec +b907ba3 (#6541) Fix content with checksum truncation bug +422399b (#5466) Write specs for output of puppet resource +8cc390c (#5466) Monkey patch Symbol so that you can sort them +24eacb7 (#5466) Fixed puppet resource bug with trailing , +743e039 (#4922) Don't truncate remotely-sourced files on 404 +bb69011 (#6338) Remove unused version control tags +e2a5085 Maint: Align tabs in a code block in the Augeas type. +65a5496 (#6509) Inline docs: Fix erroneous code block in directoryservice provider for computer type +ea9f1f0 Maint: Rewrite comments about symlinks to reflect best practice. +94f8ead (#6509) Inline docs: Fix broken lists in Launchd provider. +c80a77d (#6509) Inline docs: Fix broken code blocks in zpool type +27863c3 (#6509) Inline docs: Fix code blocks in service type. +f4034f7 (#6509) Inline docs: fix broken code blocks in schedule.rb. +6f6c4b5 (#6509) Inline docs: Fix broken code block in file type (content attribute) +a949a83 Revert "(#6309) Ensure the correct device is mounted when managing mounts" +23a510a (#4914) Improved stubbing in mount/parsed_spec tests. +ac2262d (#3999) Allow disabling of default SELinux context detection for files +23eb77d (#6322) --noop should not suppress error codes +439115e (#6499) Make puppet respond identically to -h and --help +23b7119 Maint: Add an assertion mechanism to Puppet +e3dfe41 (#6418) Recursive files shouldn't be audited +0e9858f (#6407) Fix spec test hang with Mocha >= 0.9.11 in zlib testing +309b932 (#5552) Display help when no subcommand is given. +de6a205 (#5552) Clean up subcommand handling inside puppet cert. +bb31c3d (#6376) Add test case for facts find request +2ecf913 Revert "(#5935) Allow functions to accept negated values" +c57c508 (#4914) Improved parsed_spec for mount +ec33a09 (#4914) Remove mount specs +e854205 Remove pending tests from parsed mount provider +6cb365a (#6309) Ensure the correct device is mounted when managing mounts +d1f1858 (#6376) Add support and testing for _search GET requests +3b41d44 Clean up whitespace, and commented out code in parsed mount provider +a7cebf8 (#6337) Fix Ruby warning on 1.8.6 about "future compatibility" +8a48560 (#5150) Make fact REST terminus configurable to connect to inventory service +e6870f6 (#5166) Inventory service is now searchable by timestamp. +2d2f9ab Maint: backport timestamp accessor for facts from 2.7 branch +fa0ed63 Refactored Puppet::Node::Inventory::Yaml tests in preparation for adding freshness check +67f24e4 Refactor Puppet::Node::Inventory::Yaml in preparation for adding freshness +23fc4db (#5132) Provide a query REST interface for inventory +e3c59df (#5935) Allow functions to accept negated values +7cb884e (#6346) Move the trap calls onto Signal so they're easier to stub +b5bae9f (#6331) Remove final special :trac: link from the file content property +4d25d90 (#6331) Inline documentation: Fix rotted links pointing at the Trac wiki +b25d9e4 maint: make rspec exit with status 1 when there are failures +5c26f68 (#5516) Rebuild parser.rb after merge. +e512e3e (#5977) fix spec test failure when new applications are introduced. +b5b5923 misc: ast_context has two arguments, not one. +414e3a5 Fix #5516 - Hashes can't be used in selectors +c373b62 Fix #6269 - Hashes only work with two levels of access +9090507 Fix #6267 - puppetdoc embedded links to puppet entities are not hyperlinked +b4a171e Fix #5720 - puppetdoc misses some class comments +cfa0c32 Fix #6281 - Make sure puppetdoc analyzes all files +48bc7d0 Fix #6280 - puppetdoc crashing on string interpolation +0b7faa6 (#6270) Fix formatting in split function's doc string +637e139 (#6270) Fix formatting in regsubst function's doc string +e9ee621 (6130) Change header level on metaparameter reference +d6e4ffe (#4914) Specs for mounted? match new behaviour +f534470 (#4914) Add specs for modified mount provider +b753038 (#4914) Add specs for modified mount type +9f40608 (#4914) Update property blocks +fd111f2 (#4914) Query property_hash for mountstate +2884660 (#4914) Prefetch mountstate +ade951a (#4914) Join lines for better readability +8b98526 (#5662) Fixed tests that didnt stub key_attributes +02b3111 (#5605) Prefetch doesnt work with composite keys +2a0c970 (#5662) Parsedfile doesnt work with mult keyattr +35dd070 (#5661) Creating types dont work with >1 namevar + +2.6.6 +===== +d24e32a Update CHANGELOG and version for 2.6.6rc1 +7c2a980 (#6541) Fix content with checksum truncation bug +63e911f (#6418) Recursive files shouldn't be audited + +2.6.5 +===== +30fa41d Updated CHANGELOG for 2.6.5rc5 +b481321 (#6337) Fix Ruby warning on 1.8.6 about "future compatibility" +dcce45c (#6353) Restore the ability to store paths in the filebucket +0450197 (#6126) Puppet inspect now reports status after run completes. +960890f (#6364) Adjust mis-translated regex in mount provider for AIX +9e0f9c5 Updated CHANGELOG for 2.6.5rc4 +664ef67 (#3646) Fix the documentation fix for `puppet apply --apply` +4b6519a Updated CHANGELOG for 2.6.5rc3 +7ef2fbf Updated fix for #3646 - apply / compile documentation +193016d (#5977) fix spec test failure when new applications are introduced. +c08fc1b Updated CHANGELOG for 2.6.5rc2 +1f89906 (#6257) Speed up PUT and POST requests under rack +70a43c4 Updated CHANGELOG and version for 2.6.5rc1 +f108f03 (#6018) Nick F's --help text for puppet inspect. +04ea826 (#5823) document the not-an-API status of set_run_mode +4ff5769 (#5823) run mode can now be set dynamically... +bddfa1e (6114) Update the audit metaparameter for 2.6.5. +ac8d316 Fix for #5755 -- making zaml serialization robust over projected objects +c912a2a (#4139) hook log autoflush into global defaults +f9e2e2b Augmentation of tests for prior commit +392504a Fix to fix for #5755 -- backref serialization issues in zaml +a732a15 Fixed #5564 - Added some more fqdn_rand documentation +f279f2c Fixed #4968 - Updated list of options turned on by --test in documentation +ce5a2bf (#5061) - allow special hostclass/define variables to be evaluated as defaults. +fd73874 (#6107) Fix an error when auditing a file with empty content +530496b Remove already initialized constant warning from file_spec.rb tests +76788f8 (#5566) Treat source only File checksums as syntax errors when used with content +d657292 Rename variable used in File type validation to be more clear +3398139 Remove invalid "timestamp" and "time", and add missing "ctime" File checksum types. +6c93eb2 Remove order dependency when specifying source and checksum on File type +3a125d4 Bug #5755 -- ZAML generates extra newline in some hash backreferences. +50c12e5 bug #5681 -- code fix to handle AIX mount output +139760b Bug #5681 -- parse AIX mount command output. +2f74d83 Spec for #5681 to allow parsing of AIX mount output in mount provider +878f266 Fixed #6091 - Changed POSIX path matching to allow multiple leading slashes +eb97aa5 Bug #6091 -- test leading double-slash in filenames are allowed. +1bfc9a0 Fixed #6071 - Fixed typo and improved exec path error message +c50a48e Fixed #6061 - Allowed -1 as password min/max age +bf44e72 Bug #6061 -- verify that negative {min,max}_password_age are accepted. +af1c1fe Feature #5855 -- fix withenv call in freebsd package provider +d871641 Feature #5855 -- undefined method 'withenv' in FreeBSD package provider. +f1ab588 Fixed #6009 - nested member list vs directory service group provider +86a2a00 (#5944) Remove documentation of define() when used on nodes, as it is not a supported use of this function. +2b9f653 (#5944) Further edits of inline defined() documentation. +5d108e8 (#5944) Improve documentation of defined() function +7d38ab2 (#5594) Update documentation of exec resource type. +67e1bba (#5931) Prevent errors when calling insync? on audited properties +0f9d236 Maint: Removed dead code from resource harness. +0765afb Maint: Rename misleading insync? method in file provider +0084b08 (#5548) Specify return values of manual status commands in service type description. +dd332f6 Fixed #6002 - Added note about function execution +3cfbd07 (#5045) Cleaning up some tests and code +a2036ea (#5045) External node classifiers should be able to specify params for classes +18ca97b (#5045) Adds support to resource/type to also accept a param hash +70630b9 Fix #3165 Ralsh (bin/puppet resource) can't manage files +1fd3600 Fixed #3646 - Added documentation for compile and apply to man page +ae48634 Fixed #5914 Removed genconfig = true from genconfig output +7e7f342 Fixed #1657 - Added note about target file +069f29b Fixed #2096 - clarified option modification and tested it is working +66b442b Fixes #5916 - Cleanup of unused doc methods and documentation +9b74968 Modified rubydoc in lib/puppet/util/command_line/puppetca to fix inaccurate description of --clean. +e58f5dc Fixed #5742 - Removed legacy fqdn option from documentation +4d1b51f Fixed #5167 - misleading documentation in the defaults of [main] +c1b5c7f (#5913) Fix Puppet::Application.find constant lookup behavior +7b3b56e (5977) Puppet::Applications can be loaded from multiple paths. +f9bfb96 (#5900) Include ResourceStatus#failed in serialized reports +79b6332 (#5882) Added error-handling for bucketing files in puppet inspect +17843d5 (#5882) Added error-handling to puppet inspect when auditing +1a6fab2 (#5171) Made "puppet inspect" upload audited files to a file bucket +a7cd185 Prep for #5171: Added a missing require to inspect application. +71ac9cf Locked Puppet license to GPLv2 +abc6256 (#5838) Support paths as part of file bucket requests. +002f9f1 (#5838) Improve the quality of file bucket specs. +94d7179 (#5838) Make file bucket dipper efficient when saving a file that already exists +89f5692 (#5838) Implemented the "head" method for FileBucketFile::File terminus. +9cfd3d5 (#5838) Reworked file dipper spec to perform less stubbing. +c514c64 (#5838) Added support for HEAD requests to the indirector. +2b9b7a5 (#5838) Refactored error handling logic into find_in_cache. +08561b2 (#5838) Refactored Puppet::Network::Rights#fail_on_deny +87c5c30 (#5910) Improved logging when declared classes cannot be found: +4efc98a maint: Remove unused Rakefile in spec directory +a002231 (#5171) Made filebucket able to perform diffs +8f314f2 (#5710) Removed unnecessary calls to insync? +e270086 Prep for fixing #5710: Refactor stub provider in resource harness spec +c57a677 Maint: test partial resource failure +8aa8b9d (#5799) Simplify report dir creation +2d88844 maint: Add vim swap files to .gitignore +3d3baec maint: Remove rspec options from the Rakefile +df65304 maint: Inspect reports should have audited = true on events +4c9eca1 Maint: Added "skipped" to the YAML output for Puppet::Resource::Status +717670f (#5771): Fix spec failures associated with rspec upgrade +52760a4 (#5771) Upgrade rspec to version 2 +7603b05 maint: remove stray debug statement. +7661ba8 maint: Prune #inspect methods on various objects +80bfb54 (#5758) Verify that report events are correctly created +de85f8d Prep work for #5758: set audited=true on all audit events +e162da9 Prep work for #5758: clean up initializer for Puppet::Transaction::Event +06a8d1e Fix #5698 puppet inspect shouldn't report of attributes of deleted files +1f72c31 (#5715) Added attributes resource_type and title to Puppet::Resource::Status. +a6cd736 (#5715) Removed attribute source_description from the YAML representation of Puppet::Resource::Status. +98db2da (#5715) Removed unnecessary attributes from YAML of Puppet::Transaction::Event. +bd4a8a1 (#5715) Make certain report attributes always present. +716ee1c (#5715) Changed the type of metric names to always be strings. +037eac4 (#5715) Add status attribute to reports. +e4a2e04 (#5715) Made the report "calculate" methods strictly functional. +71db5be (#5715) Made the changes/total and events/total metrics always present +a4e40f4 (#5715) Refactor in preparation for adding a status attribute to reports. +15dda94 (#5715) Added total time to inspect reports and made inspect metrics more consistent. +d1bcdec (#5715) Removed Puppet::Transaction::Report#external_times from YAML output. +1550bbb (#5715) Added total time metric to apply reports. +4cc42cd (#5715) Removed redundant attribute Transaction::Event#version +1907650 (#5715) Removed redundant attribute Resource::Status#version +e596a57 (#5715) Removed Puppet::Util::Log#version. +908e0e0 (#5715) Removed the unused attribute Puppet::Transaction::Event#node +0e39ec5 (#5715) Removed Resource::Status#skipped_reason. It was never used. +b765f0e (#5715) Prep work: Fixed add_statuses in report_spec. +8631709 (#5723) Fix failing type/package specs +76fe2b3 Implement #5168 and #5169 ctime and mtime are properties +d11ae78 [3782] Test isolation problem in test/ral/providers/cron/crontab.rb +4d3030c Modified the behavior of Puppet::Resource::Status as follows: +7fff780 (#5408) Reworked ResourceHarness so that code is clearer and all behaviors are tested +d516f63 (#5493) Add report_format, puppet_version, and configuration_version to Reports +093c45f (#5375) Rework puppet apply to use configurer.run +e99a3ea Fix #5566 none, mtime, and ctime checksum types can write file contents +d74e8e1 maint: Fix ActiveRecord confine issue +6daeb16 maint: Fix a test that was missing a require +5db696b maint: Fix tests that don't run on their own +7f4e058 (#4487) Fix environment column in hosts table +3ac50fa maint: restore plugin handler safety +f38c36c (#5408) Attributes can be both audited and managed +54a1025 maint: missing stub +1d3192e maint: missing stub +1aa8157 maint: missing line and filename stubs +5e5ee97 maint: Fully stub partially stubbed test. +3d7c8d0 maint: remove Puppet.settings stubs +52fba89 maint: test was expecting Catalog.find too few times +8c134b6 maint: broken test not failing due to over-eager exception catching +3e59277 Fix #1757 Change file mode representation to octal +84bf02e Bug #5423: This moves the home directory property before the uid property, thus minimizing room for damage when usermod is in use. +1131ad7 (#4943) Add puppet inspect application +e005cc7 maint: Remove bogus mongrel test +c908fdb (#5261) Fix #5261 Don't escape Unicode characters in PSON +b27e9b4 [#5081] Revert "Fix #4349 - Parsing with ignoreimport=true was always loading site.pp" +af6e08c (#5304) Use internal_name rather than real_name for maillist provider + 2.6.4 ===== 76890a5 Revert "(#5304) Use internal_name rather than real_name for maillist provider" 19f3879 Disable remote ralsh by default eee1a9c (#5424) Ship auth.conf as part of installing from source 779fea8 (#5304) Use internal_name rather than real_name for maillist provider 83f878e Renamed Reductive to Puppet 2.6.3 ===== 53bb805 Incremented CHANGELOG for 2.6.3 184733c [#5322] (#5322) Remove spec file that adds little value and causes failures 178c2a6 Fix test failures that fixing #4726 exposed. 74b6c09 (#4726) Fix RRD legacy support 8662056 Fix for #4279 -- mount detection on HP-UX fbb096a Fix for #5055 -- adding to_sym to Puppet::Node::Environment b2ff6a5 Fix for #5298 -- Collections need to do type lookup 1ce00dc Step towards [5298] -- cleanup indentation, etc. in AST::Collection 722608b Fixed #5287 - Schedule documentation is incorrect c8b6fb5 Fixed #5296 - test warnings messages d221c05 (#5297) Fix schedule tests that were missing stubs for Time.now f2fd0d1 Fix for #5273 -- user resource constantly resetting password age 544dcf8 Fix #5289 -- Bad copy/paste changes message on test failure 2.6.3rc3 ======== 126681f Updated CHANGELOG for 2.6.3rc3 b15231d Fix for #4299 -- Don't require which ea435a4 Fix #5020 - Prefer finding node name from REST uri over certname a097b93 Fix for #4894 -- retry tests if port is in use ee61b4e Fix for #4955 -- Race condition & memory leak in Puppet::Util f57425d Fix #4921 - race condition in Parser Functions creation 9604f1c Fix #5252 - line number mis-attribution during parsing cc5224c Maint. fix for test broken by 00eedac5 5f7d0fb Fix for #2568 -- Add a dbconnections option to set AR pool size ba4d22b Maint. Removing code for which no CLA has been signed 4a3d5d7 Reimplementation of functionality removed by prior commit 235d641 Refactor for CLA 9ba0c8a Fix #4923 - close process race when truncating existing file cb16d3d Puppet-load: better and safer error reporting 1d26742 Fix #5023 - puppet-load multiple nodes support 00eedac capture stderr from exec resources 4cbceab (#4573) FreeBSD service provider now supports versions <7 and >8 06c8748 Fix #3808 - puppetdoc should use --force-update only if RDoc supports it 6e6712b [#4813] Remove dead code from puppet/rails/host.rb 956296a Fix #4911 - Do not generate doc for standard RDoc parser generated object 4fa24bb Fix #5127 - error when accessing array elements abb8c66 (#5242) Fix schedule specs that fail near daylight savings ec667fd Kludge for #5206 -- port of fix for #3536 to yaml 9a3b584 (#5062) Add envpuppet helper script to ext/ aad7008 [#5225] Fix spec failure that depended on time change 21db472 (#5233) Randomize tmp dir paths 2.6.3rc2 ======== 244213c Updated CHANGELOG for 2.6.3rc2 76ac1f8 Fixed #5112 - Launchd Service broke in 2.6.2 with OS X 10.4 Clients. 776ea2a Fixed #5137 - Removed no longer required TOC references 31118fe Kludge for #5048 -- serialization compatibility with 0.25.x 65ef24e (#4534/#4778) -- Normalize parameterized classes 3b53bfc Fix for #5022 -- Escaped newlines should be elided 2.6.3rc1 ======== e3fc5b9 Updated CHANGELOG and version for 2.6.3rc1 3c56705 Fix for #4832 -- Making PSON handle arbitrary binary data e232770 Minimal fix for #4975 -- only call chage when managing password age rules a090e86 Fix for #4963 -- Use correct commands for password expiry on solaris 2.6.2 ===== 295c3be Updated CHANGELOG for 2.6.2 1d719be Fix for #4945 -- explicitly check os to supress man page installation 55417bc Reversion of 021d534482dd8edb863cb77d668ac3525362a0a6 a6e2bea Fixed #4919 - added parenths to fix error message: 2.6.2rc1 ======== 917c520 Incremented version to 2.6.2 900eae4 Updated CHANGELOG for 2.6.2rc1 1b6094d Fixed documentation typo bdf12fe Fix for #4896 -- stray newline left over from removed diagnostic e7424c6 (#4772) Update SuSE .spec file 0aaa742 Fixes #4792 (Duplicate definition since 2.6.1 upgrade) ea49d13 Improvement to #4025: made spec tests work on all platforms 0b4ce08 Adds #3046 - support for password min/max age e9f9d26 [#4783] (#4783) Fix RRDGraph report generation 34f87cf Add user account expiry to the useradd type and provider a7fb9b1 Fixed #4025 (failure in launchd if certain plists are binary). 2573872 Fix for #4649 -- avoid unsupported features on non-posix systems eb9279c Fix for 4273 -- revert b7e2580ab49ecdb67fc9b522829c005fc3750fbe 53a2bea Fix for #4804 -- escaped backslashes in interpolated strings d12e477 Fixes #4863 (Missing "require 'webrick'" causes nondeterministic spec failures) 574812e (#4860) Add regression tests that would have caught bad params method 68947e7 (#4860) Fix wrong method name.. params seems to be renamed to parameters 021359b Fix for #4644: install.rb works properly on Windows d057b90 Fix #4726 Update puppet rrdtool metric code to support modern rrd ruby bindings 66cf3a9 Fix #4226 - Prepend 'Puppet CA: ' to fqdn for default root ca_name d54352a Port Puppet::SSLCertificates::CA test to rspec effc6b8 Fixes #4852 - error messages involving Whits now mention Classes instead 3f99bd7 Fix #4267 - Create a backup before dropping permissions 6468f4e (#4763) Don't call a method that was removed in Rails 3 activerecord 79d5fde Fixed #4763 - Hardcoded ActiveRecord version 4798df3 Fixes #4822 -- Puppet doc -o option broken 99c1019 [#4798] Puppet doc manifests documentation mode broken 8cd1540 [#4692] undefined variables cause :undef to be passed to functions 06bf566 [#4787] Missing require causing failure bba04e0 Fix for #4746 -- Newline goes at the _end_ of the line 9e17c25 Fix #4743: Allow the audit meta-parameter to accept both 'all', and :all f950061 [#4716] ResourceTypeAPI exposes implementation details that are likely to change 8ff4b9a Fixed #4819 - corrected cron documentation 2b50f30 [#4771] Import of manifests with the same name only happens once 7b8cb74 Fix for #4708 - tagmail should allow . in tagname 6f229ee Minimal fix for #4631 -- set implicit classes as in 0.25.x 021d534 Fixed #3707 - rpm, like dpkg-query exits 1 if the package is not installed. Returning nil in this provider had the effect that on every run, puppet would end up calling yum erase . Returning the correct data structure resolves this. 216f663 Fixed Puppet Doc TOC generation c3cb57c Fixed versioncmp function typo 898a170 Fixed Reductive references in LICENSE file 996f14e Documentation updates for Markdown conversion 2.6.1 ===== cad1e0f Updated CHANGELOG for 2.6.1 14f871d [#4756] addendum for #4756 9bdfe69 Fix for Bug #4756 - Providers no longer respect missing features Restored deleted lines from type.rb and reinstated unit tests 14b3340 Fix for #4736 -- preserve case of defined resources bd973a2 Fix for #4637 --use of namevar missed in refactor 2.6.1rc4 ======== efa834a Updated CHANGELOG for 2.6.1rc4 763e7cb Minimal fix for #4691 -- class name uppercased in $name 4a9c857 Fix for #4693 -- implicit stages should never be serialized fa4d32c Fix for #4646 -- Missing stub 4d55c6e Fix for tests broken by fix for #4489 -- stub standalone b397b69 Fix for #4489 -- apply was using the rest terminus e91a8cc [#4462] uncaught Timeout::Error 4d36a51 Fixed alias metaparam docs error b063635 Skip apt-listbugs and apt-listchanges when installing from puppet e860907 [#4660] Avoid passing rake and autotest args to puppet tests 419e007 Fixed #4706 - logcheck patterns f6c0265 Fixed queue require for #4555 07d0be4 [#4308] Remove puppettest from specs 9e69616 Fixed RSpec warning messages 8d24861 Fixed #4100 - Added http_caching to yumrepo type 8cd266e Added cost parameter to the yumrepo type 0056d41 Fixed extlookup documentation and spacing e783a16 Fix for #4506 -- too much data being serialized f59cfc8 Fixed terminus example documentation 690465e Fix #4615 - vim highlighting fails on slashes and colons. 078e4fd Updated man pages 7548c65 Updated Man page generation since move to Markdown 2.6.1rc3 ======== 8be1929 Updated CHANGELOG for 2.6.1rc3 81a2725 Fix for #4456 -- need to accept some mime-type aliases c318558 Fix for #4489 -- apply was using the rest terminus 491c31d Fix for #4542 -- included classes weren't assigned proper stages 302d657 Fix for #4501 -- reports not generated in standalone 1ea4ccf Start server before agent 4c28079 [#4555] puppet queue tries to call code it hasn't required d1150e0 fix #4528 - treat * as absent 20f4b90 Fix for #4518 -- classes not getting added to compiler.classes 57bb06b [#4545] Remove obsolete 'trac' specs 82b4f04 Maint. -- Fix test failures broken by previous commit 0c30754 Maint. Removing code at the request of the original author 3df0490 [#4298] Puppet apply prints an error if the file to apply doesn't exist 5d4f222 Fixed #4527 correctly for 2.6.1 1b3d782 Updated config.ru example for 2.6.1 2.6.1rc2 ======== 0aa27b5 Updated for 2.6.1rc2 252c9b8 Further RST to Markdown fixes for types, values, tests 1157e8d Updated all types to Markdown output fef8800 Updated reference output to generate valid Markdown 79e0a2e Reformatting documentation from RST to MarkDown (#4509) Signed-off-by: Jes Fraser 62435e5 Rewrote functions documentation to Markdown e4b2aa6 Removed legacy Trac code 8ddea2a Maint. Passenger fix broke a test f43e87b Fix for #4476 -- rails calling yaml internals a23d80a Fixes #4485 -- single quoted strings should not treat \n as new line 8e31b52 Passenger needs HTTP headers values to be string 037bb32 [#4404] Remove requirement for source on Parser::Resource::Param 0e4bc62 [#4364] Fix failing spec due to incorrect loglevel 3a6ca54 Fix #4458 - Do not dump the whole environment when instances can't be found d909827 Fix for #4465 -- earlier "feature" patch broke ldap 47005aa Maint -- tests need to respect RFC-952 6aac8f0 [#4467] Make Puppet Master respect facts_terminus settings 1cba9a7 added md5 support as requested in http://serverfault.com/questions/166199/puppet-md5-sum-of-string 1dfd2b6 [#4381] extlookup shouldn't trigger reparses of .pp files be2b1f3 [#4370] Fixes extlookup precedence getting overwritten between runs 03808fd Fixed #4364 - Reduced audit msg from info to debug 539b57c [#4347] run_mode was colliding with --mode for "puppet doc" 1faebdd [#4423] repair parameterized class instantiation 37568bd [#4423] class { shouldn't get stored on the namespace stack 449315a [#4397]+[#4344] Move type-name resolution out of Puppet::Resource into the AST resources. daa801b [#4344] Temporary fix to stop agent from importing modules 00ebf01 [#4344] Fix for failing templates when module name matches file in local dir. e32320e [#4336] "reportdir" was in the wrong section 0f9672a Fixed #4311 - Typo in defaults.rb f54d843 Fix #4461 - attempt to fix another performance issue 2c21fae Fix for #4300 Solaris svc files need new pid filenames 83c2419 [#4284] Fix failing specs run as root due to missing puppet group 8237f68 [#4242] Fixed (removed) a broken unit test d5ad0fb Removed eventual documentation line ... eventually came 871e6fd Fixed #4368 - Updated clean stored configs ext script for new config sections cb64477 Updated version to 2.6.1 2.6.1rc1 ======== ecf44e4 Updated CHANGELOG for 2.6.1rc1 bdfcac5 Update Red Hat spec file for 2.6.0 9f08e7c Feature: puppet-load - a tool to stress-test master compilation ef9a4a6 Fix #4245 - default insertion of ACL is not thread safe 4065e81 Fix race condition in rack autoloading of request/response 3163932 Fix #4244 - Cached Attributes is not thread safe 7d42f77 JRuby doesn't implement Process.maxgroups 760e418 Fix #4349 - Parsing with ignoreimport=true was always loading site.pp 67bdf89 Fix #4348 - Puppet doc single manifest broken 13c71b9 extlookup() is a builtin d38e522 [#4333] old optparse doesn't support default_argv= 86b0882 Fixed #4326 - Updated SUSE packaging 03313b8 Fix #4319 - source file url sent to the master is invalid ac3a0d2 vim: highlight default parameters in definition/classes be2141a vim: match collected resources. c047c8d vim: added elsif 9569136 Fix for 4314 -- Need to allow '-' in class name for refs 636079f Fixed #4304 - Changed logging level for auto import message 000fd1e Fix for #4303 -- reverting to old escaping in '-strings 1d494a3 Tweak to fix for #4302--dangling ref to known_resource_types 2383050 Fix #4302 - Compilation speed regression compared to 2.6 63ec207 Minimal fix for #4297, with notes for follow-up 7ad7eb1 Fix #4286 - rename puppetdoc global module to __site__ 28bb195 Fixed yumrepo type deprecation wanring ` 067a46d Temporary tweak to tests for #4242 9778f2a [#4242] Fixed recursion due to parents including their children 59a23d6 Fix for #3382 -- Empty classes as graph placeholders 865282a Fixed example config.ru a0a63c3 Fixed network and indirection reference 64386cf Fixed Indirection reference 2.6.0 ===== db0b30d Updated CHANGELOG for 2.6.0 42a475e Fixing #4268 - manifests always imported 06fc40c [#4269] Undef variables interpolate to empty string 1288f8c [#4270] Force inherited classes to load into the correct environment 539d716 [#4287] Fix the undefined evaluate_match error when comparing functions d2da1d4 Tweak to tweak to fix for #4233 -- ":" is valid in type names bbc07f2 Bandaid for #4285 -- :name vs 40e6f02 Tweak to fix for #4233 -- only accept word chars in types 2.6.0rc4 ======== d87a2e3 Updated CHANGELOG for 2.6.0RC4 cf597d7 [#4233] Ruby regexps are not multiline by default, but Resource titles can be multiline d6cbb21 Fix for #4234 -- ruby DSL fails on second resource 4822de3 Fix for #4236 -- Only interpolate $ if followed by a variable b509032 Fix #4238 - if should match undef as '' 8c8c146 Minimal fix for #4243 -- import isn't thread safe d319da4 [#4247] storeconfigs was calling Puppet::Parser::Resource.new with the wrong arguments 9f91540 [#4256] External nodes parameters can now be assigned to nodes 680dd1a Fix for #4257 -- problems resolving ::-prefixed classes 6e07a19 Fix #4262 - Puppetmaster used to log compilation time 5b68afe Fix for #4255 -- misleading diagnostic message dd03ac9 Partial fix for #4278 -- the performance aspects 4ce33fd Fixed #4249 - Updated SUSE packaging specifications 91185c6 New man pages for 2.6.0 1cda7c5 Fixes errant Trac references in documentation 2.6.0rc3 ======== f60b6a0 Updated CHANGELOG for 2.6.0rc3 9df87e9 [#4219] Install misses command_line dir, puppet $app --help fails 0422852 conf/redhat: Consistently pass pidfile option to daemon, killproc, and status 63bf037 conf/redhat: Update conf/init files for single binary f72741f conf/redhat: Rebase rundir-perms patch 793d7b7 [#4213] -o option for setting onetime now works properly 2edf7fe [#3656] Serializing arrays of references 27d5a47 [#4215] Have rundir depend on vardir 06cc552 Fix for #4220 -- modules not implicitly loading their init files 2.6.0rc2 ======== 8747479 Updated CHANGELOG for 2.6.0rc2 fa74020 [#4209] catalog.resources should return resources f5f9a38 Fix for #4210 -- missing require in CA 1c3e844 Minimal fix for #4205 -- incorrect Import loop messages 99d8323 Fix #4206 - import "path/*" tries to import files twice a2115af Alt fix for #4207 -- serialize environments as their names fe4dcd8 [#4208] Missing parameter breaks multithread compilation 2.6.0rc1 ======== e028310 Updated CHANGELOG for 2.6.0rc1 3180b9d Code smell: Two space indentation 5432259 Code smell: Avoid needless decorations 8f15707 Code smell: Don't restate results directly after assignment c3e2353 Code smell: Use &&= for dependent initialization 42a5390 Code smell: Use ||= for conditional initialization a07bbe2 Code smell: Omit needless checks on defined 07b15bf Code smell: Avoid unneeded blocks 8d1fbe4 Code smell: Avoid explicit returns 889158a Code smell: Booleans are first class values. 81e283b Code smell: Line modifiers are preferred to one-line blocks. e8cf063 Code smell: Use string interpolation eefccf2 Code smell: English names for special globals rather than line-noise 184132e Code smell: Use {} for % notation delimiters wherever practical 9ee56f2 Code smell: Inconsistent indentation and related formatting issues 051bd98 Code smell: Miscellaneous oddity removal 77f8599 Code smell: Win32 --> MS_windows 3fbc1d5 Updated GPG rake signing task for new Puppet Labs key 94fa5d5 [#4182] show_diff was broken for streamed file contents 7009704 Fix for #4117 "Storing newly-audited value" messages 9cf9788 Manifests with variables were broken when read from STDIN to puppet apply 835f73c Use the name in the search path for looking for metadata 5bab997 maint:rename resource_type to define in internal dsl 654b564 [#4198] Require 'fileutils' everywhere FileUtils is used a07af2b [#4196] Move the docs into the source directory structure 3c00591 Fix for #4178 - generalize autoloading to include .rb cea2e5b [#3582] Remove assumption that Puppet.settings would return values of a consistent type c58e420 [#4180] Support legacy module structure b4593f2 Update RDoc parser to reflect change of custom plugin and fact locations dda165a Fixed #4180 - Updated old module structure to match correct default 1715f3a [#2730] mount ensure present shouldn't unmount a282cc3 Fixed subscribe example 2353115 Fix for environments in startup script. - Dropped the forced --manifest switch in the suse startup script to allow for environments to re-define this. Otherwise, environments will not work as puppet override configuration with command line arguments. cfca62b Redmine: 2474 - Fix for mount fstype documentation 3ff38df Fix for #4137 -- Oracle needs text for strings > 255 62dbae5 Fix for #2807 Puppet settings available as variables a5fc364 [#4161] RDoc fails to parse some of our ruby syntax b7e2580 [#3169] Adds more debugging to SSL cert verification 70af43f Fix for #4167 -- overriding file permissions in conf file 2c88884 [#4114] Fixes test failures caused by previous 4114 fixes 4a6428b saving work for my unit tests. The redhat one still fails... 1e0d922 [4123] - allows self.instances to correctly report state of services. 8d3ced5 created init provider method self.get_services which accepts an array of filenames to exclude when processing defpath. cdd4382 [#4114] Fix failures in the unit tests e419293 [#4114] Added queueing to the log 4b00c6a [#4110] Wrap Type#retrieve calls for backwards compatibility 5f8a242 Fix for #4120 No namevar running puppet doc -r type 6ac36eb [#2370] Allow OpenBSD to add packages with versions and flavors 45a9f37 [#4108] Changed missing Application constant error a0ea74b [#4149] Don't create two Resource::TypeCollections 7978be5 [#3906] Fixed missing constant Puppet::Rails when using storeconfigs fb6f2aa [#4136] Specs should listen on localhost 6d4be90 [#3961] Part two: --destroy should also be local 0598f35 Fix for #4148 (2.6 is greater than 0.25.x) 5971898 Fix for #4142 stray use of JSON instead of PSON 74e5bdc [#3172] Fix the arguments to Application::Kick.new, which I had broken 4f06e9e Maint: Explicitly put test sqlite files in a temp directory 84a9412 maint: fix stub failure in report_spec.rb 1f48d68 maint: fix stub failures in report_spec.rb bee843a maint: fix stubbing in package_spec.rb 528b915 maint: fix stubs in transaction_spec.rb 37277a5 maint: fix stubbing in catalog_spec.rb ea55e83 Maint: Improve the speed of setting settings. 7c7f6da maint: file_spec heisenbugs d6d726b Heisenbug: settings as catalog trying to create directories e579aab maint: spec_helper should reset settings directories on *every* test 298a764 maint: Remove a heisentest that wasn't testing what it claimed b389392 maint: spec_helper should only get loaded once 3304068 maint: :mutable_defaults to improve spec consistency 08b49c6 [#4090] Fix the run_mode for certs and put tests on the applications to assert their run_mode e318db6 [#4059] fix the specs to correctly mock the Puppet::Resource.new call signature ab3d27c [#4059] Minor errors preventing ralsh from running 59bf5e4 [#2713] Enable ELSIF ebd0311 [#3172] puppet kick can take hostnames as bare arguments 697508d [#4108] Missing constants fail deliberately and with a message 2639a56 [#4092] Changed notify message to defined instead of changed 223157d Fix for #4091 -- require loop in executables 174e02a [#4090] Change how RunMode instances are created so that an object for each RunMode is only created once instead of every time it's called 62e3b61 [#4090] Fix last few tests and renames of mode to run_mode 2a25883 [#4090] Git rid of the idea that run_mode is a configurable option with defaults 75e0662 [#4090] Rename mode (:master, :agent, :user) to run_mode 3cd48d8 [#4089] Replace internal usage of :check with :audit e848d41 [#3961] puppet cert --generate implies ca_location = :local 255628e [#3961] Rename cert's @mode to @cert_mode to reduce confusion b2bd05d maint: Confine a test that depends on sqlite fdc8c35 [#3994-part 3] rename spec tests from *_spec_spec to *_spec.rb 9a94ee2 Fix for test ordering sporadic failure 9ceb454 [#3994-part 2] rename integration tests to *_spec.rb 06dffc1 maint: A test specified that a file wasn't writeable, but was writeable when run as root, which caused the test to fail. Changing the test so that a directory is in place of the writeable file so not even root can write to it. 2baf74e maint: Fixes some noisy specs 0aae5a7 maint: Fixing tests that fail when run as root 0fa10a6 Cleaning up various warnings in specs 2ab123f Removing obsolete nodescope concept 153d7cd Fix #3665 - part 2, node inheritance fixes dd4fa66 Fix failing tests in spec/unit/resources/type.rb 770a8ea Fix #3665 - main class shouldn't be a subscope of itself 76953d8 maint: Fixes broken order-dependent Tidy specs 9afc67a Fix for pre 1.8.7 compatibility in namvar patch d62a391 Breaking require-loop b4af238 Fix for #3985 typo causing warning 9169ef0 Fix: puppet apply trying to use XMLRPC constant af41beb Remove an old test that had been unintentionally reintroduced by a mistake in a conflict resolution 6a8e6fe Tweak an old test due to new error handling. 5f53bfa Restore error handling for value= e817ad1 Fix tests broken by level-violation fix e5478d4 Simplify the newattr method by removing a level violation 4ef40b8 maint: Rework testing of Reports http processor to be self contained edfcbf9 [#3139] Fixed a problem with the value method for parameters 61e978b [#3139] Fixed a broken integration spec in type tidy cf9bcad maint: Fixing test to reflect that host environment assignment now takes an object instead of a string c70c96b Fix some tests broken by changing the call to newattr a72fb14 Fixing oversensitive test 15004f3 maint: Fix failing test that needed more methods stubbed 60932e1 Fixed require warning documentation 6fcb87d Fixed mcx documentation error 15ae389 Documentation fixes f95169b [#4006] Fix test failures caused by reverting ticket 2890 b5572ae Bug 3731. Applied Fix suggested by Doug Warner to always flatten out the array 117e6b6 maint: Have 'rake spec' output in color a7e4fe8 [#3810] Do not create a reports settings block db44a32 Tweak for fix for #1175 to fix test failures 3bd6f11 maint: Fixing a test typo s/stub/stubs/ ebc3e78 maint: Fixing a failing spec by stubbing a method on a stubbed object that should have been stubbed. 3b4d33c remove tests for removed code c8089f1 [#2646] Fixes the change to onetime made in b96cd6c 4bf6950 [#3139] Make newattr idempotent 51b70c0 [#3994] rename the specs to have _spec.rb at the end 9958c80 [#4064] Modify the Rails spec to use the block form of confine af8bd77 [#4064] Modify confine to also allow a message and a block containing the test. 182c003 Fixing #3988 - adding support for watchr 3a44f0e Fix #3932 - Add --charset to puppetdoc for RDoc mode fb5c1d7 Fix #3907 - Hash couldn't be initialized with an empty hash 9592dd8 Fix #3871 - Add the 'in' operator 3696d95 [#3865] External subcommands 0fc41ae [#3802] Replace rug with zypper dc1a977 [#3766] Remove YAML fixups e0e6b64 Provides #3723. Add ability for execs to have several attempts at a successful execution and fix minor bug with logoutput and returns as an array.. c8ca19a [#3674] Make sure that failing to load a feature isn't fatal 2a73b5d [#3674] Part 2: Autoloader load method should propagate failures 7952af5 [#3674] Autoloader should propagate failures f35c59f Fix #3667 - Fix class namespace 938fbe9 Removing obsolete nodescope concept 49cf2f2 Fixing #3651 failing to pop comment stack for some constructs 0dd4201 Fixing #3072 - Resource generation is recursive b96cd6c Fixes #2646. Move onetime option from the agent to global defaults so we can specify it in the config file. 0a21e1b [#2522] authorized keys owner is verified 738802e Fixing #2337 - Adding 'freeze_main' setting 50a626d Fixing #1545 - Adding 'caller_module_name' variable 5d1934b Fixing #1545 - module_name is now a variable bba45f1 [#4055] Confine CouchDB-related specs to the couchdb feature 1c5b67d [#4055] Refactor of abstract Couch terminus, more specs 432db25 [#4055] Add CouchDB terminus for facts 35636e9 [#3921] Fix typo "fact_terminus" -> "facts_terminus" 45ca669 Targeted fix for #3851 c00285c [#3810] Add http reports processor and `reporturl` setting 1d49def [#3804] Fixed one failing spec for RackREST 1e89bff Fixes #3514 - CR/LF line ending in puppet.conf cause silent failure e6709da [#3409] fix test failures from ldap environment patch a7884b4 [#3409] environment is not checked when nodes are in ldap c75b219 Fixes #3395 - CR+LF line endings in manifests cause syntax error 8b127b1 [#3388] Setting host_aliases from [] to [] no longer results in any changes be7112a Fixing #3139 - all properties can now be audited 986298b Working #3139 - Adding Settings.clear Spec#after 32f6a9d Working #3139 - Removing Property#checkable 58cf8d9 Working #3139 - Catalogs default to host_config 8f3e8bb Working #3139 - ResourceHarness does caching d6407f4 Working #3139 - removing obsolete checking in Storage 0b95a85 Working #3139 - scheduling moved to resource harness 4627b8f Improving fix for #1175; tightening thread safety ccc869e Part 2 of fix for #1175 (functions in environments) 7c6b883 [#1621] Composite keys for resources 2396eba Use the 'root' feature rather than directly checking the uid 8128311 fix tests to reflect methods moved from type/file/owner to provider/file/posix 28702a4 variable name error in refactor 19c70b5 Remove over-eager error branch in a complicated If 09881cf Confine out a lib that puppet was failing to load on non-win32 d72fd9d Confine out tests that fail on unix d1b86ec Behavior change for //UNC_Paths broke an old test ba506c1 Resolving conflicts with jes5199:ticket/master/2935-settings-mode f15a324 Fix Exec type 86bd838 Move syslog into a feature fc92408 Adapt Util::Storage specs and avoid trying to lock on directories 58100ed Relax path qualification check on FileServing::Fileset 1c016a1 Implement quoting on the exec commands and repair specs 6a92894 Avoid trying to symlink() on windows 47c9dd1 Implement "forking" for Windows c59d864 Avoid non-win32 signals on win32 runtime bbba9f9 Avoid trying to set uid/gid on windows a90bcb0 Start extracting the owner managment for files into providers b51be28 Expand file type to be able to handle Win32 and UNC paths 17a9ad1 Updated version to 2.6.0 a2e809b Fixed RSpec deprecation notice in lexer tests f054d5b Make specs work on win32 54c4538 Delete tempfiles on win32 97c043f Fix path handling f80b4c7 Print stacktraces if requested 1d98e67 Adapt defaults to Win32 environment ea9bb49 More win32? feature def 1645d8e Define posix and win32 features b3aa3ec Improve error message d67f60f Fix ProviderDpkg specs to avoid any real executions e119b04 Avoid setting the timeout before we know which timeout we should set. d40e6d4 Bug: tidy specs need FileBucket::Dipper a6b52bb Avoid trying to lock on non-files 533ef68 Removing obsolete FCollection stub from Functions bc90df6 Functions are added to a module instead of Scope 17e40e7 Slightly restructuring "Functions" file 9d0a38e [#3921] Add facts_terminus setting to Puppet settings 2874729 [#3921] Remove unnecessary require 'puppet/resource' 58a3d27 Fix for #3949 and related b755f7f Fixed #3912 - Added client certificate name as an internal fact called "clientcert" b5f14c6 {#3866] Rename the method metaclass to singleton_class to avoid the deprecation warnings from Rails ActiveSupport 2b5bd49 Fixing #3822 - checksums will be loaded from filebuckets 94390de foo 3b7aac5 For #3822 - Reducing checksum code duplication ca7b166 Fixed unsupported perlstyle regex and few other minor bugs 85f2565 Signed-off-by: Ross West a4eb5d5 Signed-off-by: Ross West 970fd87 Fixing #3791 - client environment is used cce63d8 Bug #3748 LDAP group membership 4ba3dc2 Fixing #2655 - Adding default parameter values to resources 20a74bc Refactoring tests - replacing stubs with instances b5db33b Fix for 3664: interpolating qualified variables. 9ddee72 Fix #3664 - qualified variable parsing in string interpolation a32381e Feature #2935 remove misleading comment 5937af4 Feature #2935 Unify the codepaths for setting settings b7d387e Feature #2935 Puppet[:mode] and Puppet[:name] are read-only 342298c Bug: Broken codepath in util/settings 6d5566a Feature #2935 settings are in Mode sections instead of executable names 9536723 Feature #2935: method extract require_application c338fef Feature #2935: Test for if we're "puppet cert" cbb2802 Code cleanup: remove "self." from setdefaults 37a5530 Feature #2935 Modes: root? predicate ac7efc8 Feature #2935 Puppet::Mode#master? 5665e39 Feature #2276 Single Executable: Update docstrings fc29049 feature #2276 Single Executable: use new names for settings sections 631552c Feature #2935: Applications should declare modes 8f4d644 Feature #2935: lazify require graph for applications 6b26a7c Feature #2935: Puppet::Mode b65d1af Feature #2276 Single Executable: usage message 76304f8 feature #2276 Single Executable: move CommandLine methods e9627a0 Fixing #2658 - adding backward compatibility for 0.24 61a719f Adding #2658 - Adding support for run stages d13f8ac Fixing #3671 - --compile Catalogs are pretty-printed 89e8745 Fixing #2655 - Adding default parameter values to resources edcf429 Refactoring tests - replacing stubs with instances 3dfb762 Fixing Catalog conversion 0d4fd60 Fixing #1903 - metaparam inheritance is much faster 047ebfe Fixing Parser::Resource param validation 2fae0bd Fixes #1999 - Allows the 'apt' provider to downgrade packages. b10d35d Fixes #3745 Catch unhandled exception in ssh_authorized_key provider 584961a Fixed #3721 - Removed -u option from crontab on HP-UX a15a70c Fixing tests broken by conceptual merge conflicts 5988f76 Fixes #3663 - It should be possible to list signed hosts only 2c153b1 Fixing #448 - relationships have their own syntax 052f98f Fix #3408 - enable puppetd http compression 3eaf69c Fix for conflict between fileserving streams and none-checksums 2cf7222 Fix #3373 - Client side file streaming ee5d7f1 Add master side file content streaming 63c122f Fixing tests broken by Luke's CRL flag patch. 91e6022 Fixes incorrect line in partial CRL fix 379bda0 WIP - trying to fix #3460 3947574 Updated Template documentation link 5fd6e54 Change the main spec to an apply spec 009629f Feature #2276 Single Executable: usage message 5b64d3b feature #2276 Single Executable: optparser should get CommandLine#args instead of ARGV 5683fd9 Feature #2276 Single Executable: Pass a commandline object to the application d038a1d Refactor #3706 Reify eigenclasses of Applications 7656ba7 feature #2276 Single Executable: CommandLine can be instantiated 63e2e56 feature #2276 Single Executable: subcommand method b6e2ce6 feature #2276 Single Executable: help info b073722 feature #2276 Single Executable: help for apply bfad735 feature #2276 Single Executable: rdoc paths on ubuntu 7103378 feature #2276 Single Executable: legacy settings 54c1cc5 feature #2276 Single Executable: "puppet describe" c79b228 feature #2276 Single Executable: "puppet kick" 6bdda8c feature #2276 Single Executable: "puppet cert" f9783fc feature #2276 Single Executable: "puppet master" 1d8bd0d Fix #3552 single executable should display usage 722a27f Fixes #3702: the 'log' report now sends the host name as the log source again. ddd40bb Fix for #3690 failing to calculate error codes d61a69a Fixing #3668 - fixed autoloading classes from modules f66095d Fix #3656 JSON serialization of dependencies f0a0084 Fixes #3582 - Adds dbport configuration option for specifying database port 8b99367 Adding indirector support to Resource Types 748aed9 Fix #3552 single executable should display usage eafde5c Added support for flat packages in the pkgdmg package provider. Added a test in: ./spec/unit/provider/package/pkgdmg.rb c9e3d75 Fix: the rcvar name is not necessarily the same as the service name. (More and more I get the feeling that FreeBSD's rc system is totally unsuitable for Puppet. What about porting Upstart or SMF to FreeBSD ... ?) 861c177 Added proper status command 5f72eb9 Re-included old BSD service provider, made new one default for FreeBSD c3cd24b Rewrote FreeBSD service provider 1250f80 Fixed documentation issues exposed in #3772 211782f Updated CHANGELOG for 0.25.5rc3 7c59acf Renamed all references to Reductive Labs to Puppet Labs e82f5de Fix for #3107 Changing users on AIX 44f1465 Fixing #2864 Added support for AIX System Resource Controller (SRC) - service start stop 02ed8db Fixes #2836. Add hold support to dpkg provider 0f2d3ce Fixes #1223 Add Zypper support for SuSE machines a166d50 Fix for #3399 zone type should handle exclusive IP stacks af521fa Adding #3518 - basic dot format support 9b2b0ec Fix #3551 rake spec fails to run integration specs 6a66d5e Update Red Hat spec file for 0.25.5 46c72bb Updated CHANGELOG for 0.25.5rc2 ee0cc07 Fixing #3533 - Removing all transaction cleanup 11189fb Fix for #2910 -- Tidy/matches is too tricky to use 913b63c Bug #3451: Don't leak the terminus class setting from Puppet::Resource::Catalog's spec a228399 Fix to the fix for #3295 ae52005 Write ssh_authorized_keys as user 8c5e80e Fixing bad test 088c801 Fix for #3558 -- source file reading speedup cd06b87 Fix for #3556 Plussignment value melding 2de7da4 Fixed #3655 - Puppet doesn't find installed packages with portage provider d20d5de Fixed #3672 - Error message on duplicate fileserver mounts incorrect 6ae6821 conf/redhat: Add notifempty to logrotate config 7fc66d5 Fixed stored configuration documentation 14456b4 Fixes #3653 - Changed default factpath value to better reflect plugins in modules f3e466b Partial fix to #2837 - changed warning message to debug 686239f Fix #3555 - fix state of purged lists 6f8a1e9 Updated Rake tasks to no longer load puppet.rb 83a8c68 Fix #3540 - name methods correctly 3d395e8 Fixes #3295 - generate() now sets the working directory to the directory containing the specified command. 0f077c7 Added YARD task b49c60b Update man pages and partial doc fix to #3491 115f37d Fixed #3532 - Typo in lib/puppet/ssl/host.rb 784dd26 Updated version and CHANGELOG to 0.25.5rc1 4a6474c Modify SuSE spec file for 0.25.x and correct shebang lines for puppetd/puppetmasterd 385506f Fixes #3460 - Makes Puppet FHS compliant by moving /var/puppet to /var/lib/puppet b494427 Fix for #3101 (bug in MRI 1.8.7) 966b269 Fixes #3419. OS X 10.6 Ruby doesn't set supplementary groups 49be54e Revert the guts of #2890 e69b7db Fail gracefully on packages that don't have the HOMEPAGE variable set (e.g. dev-lang/php). 83ac6b8 Fixed #3443 - Typo in mount type dfe5c3a Fixes #3135 - darwin doesn't support 'mount -o remount' 2a60e1e Adding :catalog_terminus setting 626945b fixing obsolete comment in puppetd 9fbb69f Adding support for only using cached catalogs 7e1e76e Refactoring Configurer to enable the next feature b28e21a Fixed changelog Rake task e93eab8 Fix #3155 - prevent error when using two matching regex in cascade b883272 Fixed puppetlast typo 67bf142 Fixed README contents to reflect Puppet Labs and docs and wiki changes e35e142 Fixed link typo d40e24c Fixed #3384 - Updated broken link da00f68 Making a Puppet::Module test more resilient 9792915 Fixing yumrepo type to use 'flush' 9ee4c2d Only trying to retrieve passwords on OS X when root 8c31ebe Removing obsolete tests aee9c29 Fixing a warning in the aix package provider 232ad8f Removing tests for code that was removed in the REST refactor 94fddbc Fixing and porting Transaction Report tests 13d141a Fixing Property#change_to_s in rare case failures 66858ef Fix test in parser.rb due to API change 0f254be Fixing Hash functionality with non-constant keys 41aeba4 Removing vistigial method in ASTHash 1821187 Porting/removing group test/unit tests 03532e0 Porting a simple set of tests from test/unit 006e6af Removing obsolete test 1a6e08f Fixing Transaction integration test 410b71c Removing invalid File integration test effa719 Cleaning up content/source code 456447c Protecting spec_helper chmod from failure fa64774 Redeleting puppetmasterd integration test 797f412 Making SshAuthorizedKeys tests less brittle 622bb70 Markus's patch concerning string interpolation 23adec5 Fix tests that use or stub find_by_checksum, which I just changed the signature of. 4ac8e2c The pure-ruby YAML lib doesn't accept parameters e31fe8c Fix a failure in new FileBucket where it was impossible to read from a bucket with a non-default path. 3797c7a Update YAML dir test to match behavior 83d8bda Fix heisenbug in spec/unit/provider/mount/parsed.rb dde69c3 Remove test for old RDoc work-around c5ce824 Fixing various broken Resource::Type tests 6cd6c47 Renaming and fixing puppetrun tests. a27013a Fixing calls to "class_scope" in Scope tests 84d6892 Fixing all 'require' function tests b643413 Removing any mentions of :casesensitive setting fe140a2 Migrating "puppet" executable integration test edef647 Fixing 'puppet' to directly run manifests fff8d04 Fixing syntax warning 7c25317 Moving puppet back to bin a4d1ba0 Puppet::Parser::AST::Leaf#evaluate_match "insensitive" renamed to "sensitive" 404bdfa Repair validate_checksum codepath, even though it is disabled. e895494 Puppet::Parser::Resource.new parameters have changed 94651df Add stub to Puppet::Parser::Collector test to prevent runaway stub failures 40c1fb0 Resolving conflicts with ??? 1059370 Fixing a typo from a regex 3eeebf5 Fixing change printing for content/ensure 47c3ca1 Converted File[checksum] to a parameter not property 44cba9c Adding "checksum?" helper method to Checksums module d05d25c Refactoring File[source] tests somewhat aab2374 Resolving conflicts with luke:tickets/testing/2954 86cf226 Adding virtual and exported resource support to the DSL 9d5ba41 Cleaning up ResourceAPI tests 9060766 s/DSL::ResourceHelper/DSL::ResourceAPI/g 6d2a10b Adding simplistic pure ruby interface e515513 Adding environment support to parser resources 30f49bb Resolving conflicts with ??? b7015d7 Moving the string interpolation parsing to the parser/lexer 07cfdd0 Resolving conflicts with jesse:feature/master/3394 ad148d6 Resolving conflicts with luke:tickets/master/2759 922cf1a Resolving conflicts with ??? 0d70468 Finishing renaming :params to :parameters internally ad93d0e Forcing parent evaluation in resource types 6e4db82 Fixing type/title resource resolution aa659f2 Converging the Resource classes further 5401a7c Adding strictness checking to resources 9c867e6 Fixing most of the broken tests in test/ 274d1c5 Adding tmpfile cleanup to tests 7089446 Removing Resource::Reference classes 4871c90 Adding support for class parameters 4709e9b Removing :paramcheck and :typecheck settings 744295d Allowing Environment.new to take an environment 4f907c6 TypeCollection now supports namespace arrays 2fa0a48 Adding parameter validation to Puppet::Resource aff5992 Fixing failing Environment unit tests 61636e4 Tuning file load order 7a99a1d Removing obsolete Settings comments and require af9a920 Adding an environment helper c8e89cc Changing the interface of Puppet::Resource b7ea180 Partially fixing #2954 - Adding class parameters cbe2c49 Fixing test structure 4bff506 Indirector/FileBucketFile warnings 0917248 REST: Fix a state leak causing test failures 8f9fc30 REST FileBucket: REST barfs on relative paths 23ccefe REST: hide Request object d8e1b27 Feature #3394 REST runner, execution 1603f73 Feature #3394 REST Runner, preparation 16658a0 Feature #3383 Part 2: Remove RAL XMLRPC eda649b Feature #3383 RAL over REST 09b1412 Fix tests on #3347 e5a7800 Feature #3347 REST-ified FileBucket f838389 Fix a failing test in #3115 9acd0b2 Feature #3115 REST-ified status() b581c23 Fix #3229 - use original value in case/selector regex matching 490a03d Cleaning up a test. 576accd Removing unused Checksum::File terminus 58920a0 Converting File terminus to use formats. 37fd6ae Fixing datadir defaults to match new standards bf3359e Adding client and server data dirs b41d535 Adding filename extension support to formats. 7504f1e Resolving conflicts with ??? d0389f4 Renaming Parser::ResourceType to Resource::Type 67ef78d Removing Interpreter class b82b4ef All non-transient parser references are gone 644ad7e Fixing callers to Parser to only pass environment 9f8e0c0 Using the RTC helper to find the known resource types 1705366 Always warning if autoloading a file fails 7bef2e0 Adding helper module for finding known resource types 804105d Moving Rails initialization to Compiler terminus 26b272b Parser now uses Environment resource type collection cb16908 Adding 'known_resource_types' to Environment 201889b Renaming LoadedCode to ResourceTypeCollection 2c2b3c2 Storing per-environment LoadedCode instances 6bf1953 Removing old, never-used DSL code df2d392 Adding support for parsing ruby files b938edf Fixing test structure 847233f Adding []/[]= support to Parser::Resource 6e04fba Fix for #3366 - --tags '' treated as boolean 'true' 33b565a Fix for #3424 and tests to prove it. 4820a1b Fix for #2604 Pure Ruby yaml generation 1c5b3d7 Fixes #3113 - When importing a manifest puppet needs to chill e6a720b Fix for #3412 install.rb should not put "." first in the tmp_dirs b1b3bcf Resolving conflicts with testing ba2a3af Fix 2239 (step five): introduce new Puppet::Transaction#stop_processing? flag and associated check thereof within the resource evaluation code. This should allow for the transaction to bail out of its processing if it finds that a stop has been requested, based on the state of Puppet::Application.stop_requested?. 9cb6841 Fix 2239 (step four): Refactored Puppet::Daemon's stop/restart methods to set status flags appropriately in Puppet::Application, and removed call to now-deprecated @agent.configure_delayed_restart. This should get the restart and stop behavior for daemons and their agents working nicely with the new global process status interface of Puppet::Application. 82f852a Fix 2239 (step three): Refactored Puppet::Agent to base starting/restarting behaviors and predicates on new run-status interface of Puppet::Application. edbe9b6 Fix 2239 (step two): introduce Puppet::Application.controlled_run method to provide simple status-restricted execution of a passed in block; this can replace the process status checks and properly handle delayed restart behavior for Puppet::Agent. 2cf647c Fix 2239 (step one): introduce global settings represeting application run state with methods for setting the state and appropriately-named predicates for querying state, all in the Puppet::Application class itself. To be used by Puppet::Daemon and Puppet::Agent and Puppet::Transaction for better response to TERM, INT, HUP. ce944a5 Fix unit tests in file/target.rb 481ddb8 Name change of event in ral/type/exec.rb 1ebc91e Use a helper function to evaluate a resource since the API has changed bfb1fa5 Allow skipped resources to process events a18b05d Actually invoke the allow_changes? method in ResourceHarness bf2f088 Generated resources' events are actually bound to the resource that generated them. 50ed75b Remove test that tests internal class structures which have changed. 1779079 Remove stale set_trigger 9154aca Since the types stored in resource's @parameters have changed, we need to also change include? method to be more robust. 2a2ab75 Fix test failures due to name changes of event symbols 0a72a98 Remove rollback test, since rollback was removed. 010907b Mark resource/status as failed if they are associated with a failing event. 17bccb0 Restore noop non-behaviours 8465cd0 Resolving conflicts with reinh:feature/master/single_executable 0f768ed Removing now-obsolete user tests 7627441 Fixing most failing test/ tests. 9d9b20f Fixing Configurer interface to transaction report eb0a4b5 Fixing fingerprint tests to work with new log validation f4ef039 Changing REST report integration test to use new interface fdefb64 Fixing "require" function to use new class interface 266bc08 Removing now-obsolete "retrieve" method on package type 67a75db Fixing broken selinux tests 2777e1f Fixing feature validation when passed one item 5aa26d0 Changing method profile for other event queueing ec7ea27 Refactoring event queueing for performance 68ce086 Changing the method profile of EventManager#queue_event 9919b14 Moving Metric management to the reports a9fc134 Removing mention of @changes in Transaction a18769d Cleaning up the report tests a bit 386b3e5 Fixing #2759 - reports now have complete change info fbd5b0a ResourceHarness now doesn't check params with no 'should' 3f6c948 Changing Transaction to use the new ResourceHarness 6051599 Fixing log message when changes fail 149d5ef Fixing some compatibility and old tests c30494f Renaming some methods in Transaction::Change 8d5f052 Adding Transaction::ResourceHarness class 6651aa4 Adding first version of Resource::Status class 4bb35a7 Fixing File type indentation 796d882 Removing last event collection transaction code e838bcc Solidifying the RAL/Event integration. 977595b Refactoring the Change/Event/Property interface 5776fe4 Cleaning up the Log initialization code. 2292b76 Refactoring the RAL interface to logging d93d80a Using Logging module in main Puppet module c6dd180 Adding tests for "Logging" module 242209d Correcting comments and making report timestamp internal a4b77f6 Failing in app/puppet if facts are not found f925475 Fixing file content logs 73f57f2 removing extraneous comment 4be8601 Adding Transaction events to Transaction reports 2aa579b Removing a redundant method in Report 5a8b460 Removing unused code and adding a couple of tests 9a78bee Adding tests for the 'report' log destination f2ed655 Extracting event management into a separate class 329527f Changing SimpleGraph.matching_edges to expect one event f8d7c44 Moving event creation to the resource ee9cff9 Reorganizing Property class to match current style 4212f1c Cleaning up Event creation 8280987 Adding "type" instance method to enhance Demeterness ad90900 Random code cleanup 32d34e9 Moving Ensure property into separate file 3c86666 Moving Parameter utility classes into separate files 2cbd9e8 Switching transactions to callback-based events 6a450c5 removing never-used code 379ac8f Moving log destination code into separate files b2d1728 fixed a couple of typos 7ab29c4 Unit tests for path changes a8245d8 Handle path elements with ticks and spaces 98581ad Fix builtins glob in single executable b4b07f5 Fix failing specs e7bc19a Rename puppet application spec to main c014c29 Renaming the old puppet executable deff92d Find both bin and sbin usage docs, fail gracefully 3c8d012 Fix application name in bin/ralsh be0ecf8 Initial puppet single executable 7a32777 Renaming applications, mostly removing 'puppet' b19a044 Some tests were leaking state when the test failed 5b2802c Typo in method call in test. 6a148e2 Supressing warnings (not really failures) in test/unit 06deee7 Fix test using wrong Puppet util filesetting group 74f5167 Mock user in SUIDManager tests 000d37a Removing resources generate tests 11379c0 Removing old test for service/debian provider 2b8125c Replace test/unit file write test with spec 164f1ce Allow adding single key to hashes fd427a5 Raise an error when appending not a hash to a hash 75c32f9 Fix #2389 - Enhance Puppet DSL with Hashes 9122ac5 Fix #2929 - Allow checksum to be "none" 73c8d0d Fix #3186 - require function set relationship only on the last class c5a4de2 Fixing #3185 Rakefile is loading puppet.rb twice c694c4d Fix #3150 - require function doesn't like ::class syntax 075f3c8 Added time module to tagmail report dfb8082 Fixed the return types were valid, and removed the copy paste error with the exception logic 6e16ea1 Resolving conflicts with ??? bca7e2c Add AIX package management support (installp&nim) b2c9455 Fixing #3148 Settings#without_noop when run with no noop setting 8bafc37 Move scope parenting & class_scope from Compiler to Scope 7403c6e [#3392] Better Rakefile, remove puppetmasterd spec de94f68 Fixing tests in pkg provider 4b55fb0 bug #3407 Part 2 f891ba2 Fixing #3407 Failing tests in spec/unit/node/environment.rb af9c19a Bug #3406 augeas spec fails if there is not a default provider 718a87a Bug #3402 Stub returning invalid type for :noop 88d6cd5 Bug #3401 Spec failed due to missing manditory setting in mock d9920bc Bug #3400 Bad mocks causing failing tests c6f02f2 Fix #3167 Duplicate constant warnings in dpkg.rb 70c71c5 Fixed Rails database tests 46f9d00 Fix #3117 - cert fingerprinting uses a method not available in ruby <= 1.8.6 04842ef Fixed test error message. fcce222 First shot at the OpenSolaris pkg(5) provider 3e9677f Feature #2839 - fingerprint certificate 91c44b4 Fix a few puppetd specs tests d77c9ac Revert "Feature #2839 - fingerprint certificate" 58a81ba Fixing #1054 - transaction reports are always sent 282b4b3 Removing some unneeded validation code from Transaction.new 66a3e6a Removing unused configurer code 2044550 Fix #2894 - exclude .pp files under modules files directories d31ff7e Adapt to method name change since 8971d8 a9fb82b Feature #2839 - fingerprint certificate a967b93 Feature #2395 - revoke when cleaning a certificate with puppetca e26e831 Updated test series 53869e9 Fix #2818 - scope variable assigned with undef are not "undef" 4226e01 Fix for #2959 (calling exit status on a nil report) 8971d8b Fixing #2596 - Node, Class, Definition are not AST 39d4a93 Adding a context method to the Errors module 22c642d Extracting language doc support into a module adc211a Adding module metadata bf40f4f Upgrading rspec for tests to 1.2.9 61d1911 Fix 2841 - Puppetdoc/RDoc parses realize function e63d23e Added tickets/master/2596 to the testing branch 41da962 Feature 2827 Option to disable managing internal files c9f40be Fixed #2568 - Add database option 'dbconnections' 2d137e2 Fixing #1507 - Adding a :ca_name setting 089ac3e Fixing #2617 - using the searched-for REST name 28e1bc6 Always using the CA_name constant instead of "ca" 2d4b795 Fix #1934 - detailed-exitcodes for puppetd 0f61816 Fix #2649 Allow ssl dir creation in --noop mode 53be6f8 Fix #2796 - Fix puppetdoc rdoc selector parsing 391786f Fix #2795 - puppetdoc rdoc reports a better error message b832d81 Fix #2784 - puppetdoc/rdoc didn't parse mono-instruction class content b1deb89 Covers the RDoc Puppet Parser with specs ced5a78 Fix #2376 - Display class/node inheritance in puppetdoc 8d9fbbd Fix #2703 - add 'require' to puppetdoc 41b7c3c Adding an example yaml node script 66a44dd type augeas: add 'incl' and 'lens' parameters c61335f Patch to address feature #2571 to add Oracle support to Puppet 0.25.5 ====== d71bd68 Updated CHANGELOG for 0.25.5 d88b357 Fixes incorrect line in partial CRL fix dec84e5 Fixed documentation issues exposed in #3772 0.25.5rc3 ========= 4daf8c3 Updated CHANGELOG for 0.25.5rc3 9214400 WIP - trying to fix #3460 9d3e98b Minimal footprint fix for #3751 (serialization 0.25.5 <-> 0.24.8) d481340 Updated Template documentation link 5a1a45c Update Red Hat spec file for 0.25.5 0.25.5rc2 ========= 2257605 Updated CHANGELOG for 0.25.5rc2 5258a0a Fixing #3533 - Removing all transaction cleanup bcde541 Fix for #2910 -- Tidy/matches is too tricky to use 5abe571 Bug #3451: Don't leak the terminus class setting from Puppet::Resource::Catalog's spec ebd924c Fix to the fix for #3295 ce233aa Write ssh_authorized_keys as user 6739bab Fix for #3558 -- source file reading speedup b0e3c61 Fix for #3556 Plussignment value melding 8a30495 Fixed #3655 - Puppet doesn't find installed packages with portage provider e4130af Fixed #3672 - Error message on duplicate fileserver mounts incorrect 1275a47 conf/redhat: Add notifempty to logrotate config 134204d Fixed stored configuration documentation 1aa98a6 Fixes #3653 - Changed default factpath value to better reflect plugins in modules 44f6d64 Partial fix to #2837 - changed warning message to debug 3a1b178 Fix #3555 - fix state of purged lists f6046ab Fix for #3577 -- to_yaml parameter in 0.25.5rc1 f351e2d Renamed all references to Reductive Labs to Puppet Labs cf7e696 Updated Rake tasks to no longer load puppet.rb b93924e Fix #3540 - name methods correctly 9bc2f28 Fixes #3295 - generate() now sets the working directory to the directory containing the specified command. 3ee6834 Added YARD task 99818ef Update man pages and partial doc fix to #3491 f988af3 Fixed #3532 - Typo in lib/puppet/ssl/host.rb f0e12e5 Fix #3496 - suppress transaction debug message 0.25.5rc1 ========= 0eea2f5 Updated version and CHANGELOG to 0.25.5rc1 57ae381 Modify SuSE spec file for 0.25.x and correct shebang lines for puppetd/puppetmasterd d90ec79 Fixes #3460 - Makes Puppet FHS compliant by moving /var/puppet to /var/lib/puppet ae0b0bf Fix for #3101 (bug in MRI 1.8.7) 9db066b Fixes #3419. OS X 10.6 Ruby doesn't set supplementary groups 306d082 Revert the guts of #2890 4eea77a Fail gracefully on packages that don't have the HOMEPAGE variable set (e.g. dev-lang/php). f5b8494 Fixed #3443 - Typo in mount type b0ef2c6 Fixes #3135 - darwin doesn't support 'mount -o remount' 7018cf5 Adding :catalog_terminus setting 978ab8a fixing obsolete comment in puppetd 6d13d0d Adding support for only using cached catalogs bc28715 Refactoring Configurer to enable the next feature ba43d7b Fix for #3366 - --tags '' treated as boolean 'true' 5ab5e8a Supressing warnings (not really failures) in test/unit e4df0b0 Fix test using wrong Puppet util filesetting group eeb3d74 Mock user in SUIDManager tests 9ea27db Removing resources generate tests 218e3e9 Removing old test for service/debian provider 1556938 Replace test/unit file write test with spec 2defc00 Fix for #3424 and tests to prove it. 44798b9 Fixed changelog Rake task 5d10f65 Fix #3155 - prevent error when using two matching regex in cascade fbedb99 Fixing #3148 Settings#without_noop when run with no noop setting 389c77b Another trivial follow-up fix for #2604: invalid path to zaml.rb 56b5753 Fix inefficient SimpleGraph#matching_edge 4b2b9eb Fix #3229 - use original value in case/selector regex matching 19863c0 Fix #2929 - Allow checksum to be "none" fd76142 Fixed puppetlast typo 3b4e782 Follow up for #2604, debug msg left behind. e44430b Fix for #2604 Pure Ruby yaml generation 74cd55f Fixes #3113 - When importing a manifest puppet needs to chill 7ec50a7 Fixes #3387 - Handle path elements with ticks and spaces d561a98 Fix for #3412 install.rb should not put "." first in the tmp_dirs 751df45 Fix #3186 - require function set relationship only on the last class a1d216c Fixed the return types were valid, and removed the copy paste error with the exception logic d532e6d Fixing #3185 Rakefile is loading puppet.rb twice 5aa596c Fix #3150 - require function doesn't like ::class syntax 3457b87 Added time module to tagmail report 71653a7 Fixed #3162 - tidy does not remove empty files when "size => 0" is set efd0f76 Fixed #3128 - Updated man pages and moved puppet.conf.8 to puppet.conf.5 ad4f94a Add version number to puppetlast display. 0533cea Forgot fakedata called in spec 6416f91 Fixing #2669 puppetmasterd integration has leaky state 8a3a205 Fix for #2327, check the return types from augeas and fail where appropriate 2ae7516 2047: Add a not_include into match 55f6239 Minor unit test fixes b7b7a1c vim: Improve function matching when functions contain ')' b3c363c vim: puppetDefArguments is contained by puppetDefine f9e05a8 Fix for #3094 (libdir should take ":" delimited path) b473264 Fix #1842 Net::HTTP#enable_post_connection_check doesn't work anymore 9419c2b Fix for #3035 (redhat services use init for source) 10becce Fix for #3077 (unit tests broken in 0.25.1-->0.25.4) 49a7185 Fix for #3085 (user_role_add pulls from same source as useradd) 1f086c2 Fix for #3114 (ruby's arbitrary limit on process groups too low) 0.25.4 ====== c5eef04 Updated CHANGELOG for 0.25.4 0025e13 Partial reversion of patch for #3088 to fix #3104 (Exception misreported) bfc9e45 Updated CHANGELOG for 0.25.4rc3 0.25.4rc3 ========= a91c476 Fix for #3088 (catching Exception also traps SystemExit) 1a263e2 Fix for #3089 (timestamp may now be a time object, not a string) 75634b7 Fix for #3093 (also need to be able to call pkgget_with_cat on class) 94e269c Uncommeniting the fix for #3001 9636b93 Updated CHANGELOG for 0.24.5rc2 0.25.4rc2 ========= d4319a5 Minimal fix for #3001 (failing to fetch metadata on dangling symlink) cdcbdc7 Fixing #2914 - pre/post hooks now work for transactions 67216aa Fix for #3075 (sshkey host_aliases ignored) e4462c0 Updated version and CHANGELOG for 0.25.4 0.25.4rc1 ========= 441879f Revert "Fix #2845 Cron entries using "special" parameter lose their title when changed" f7e1435 Updated rake task to fix gem build issue 49013f0 Updated version and CHANGELOG for 0.25.3 0.25.3 ====== f8c1b08 Reversion of pipe IO patch for testing on #3025 7f25805 Fix #1464 Mount complains about missing fields c99f394 Fix #2845 Cron entries using "special" parameter lose their title when changed 0a7e212 Fix #2887 'service' tests paths too early dd22b71 Replaced ugly gem creation task with slightly less ugly task d0efcc6 Added tasks directory to Rakefile and gem task file lists 8a6d66e Added puppetpackages task description eada68a Updated CHANGELOG for 0.25.2 0.25.2 ====== 6111ba8 Fix for temporary file security whole e7d98cc Fix for #2999 (absent package handling on solaris) 87136b4 Fix typo in documentation: wheter vs. whether. cbc2ef0 Partial rollback of refinements to fix for #2994 fd631b9 Do not close stdout or stderr in execute. f878fe8 Update Red Hat spec file for 0.25.2 4394c48 Updated CHANGELOG for 0.25.2rc3 0.25.2rc3 ========= 13cbf04 ReFix 2675 ending slash in directory should get stripped off 5c6f07b Use a pipe instead of a temp file for command output. 7e64393 Additional fix for #2994 (followed symlinks do not have checksums) 7e2e12b Fix for #2995 (don't fail to load PSON when UTF-8 missing) c84186a Revert "Fix for #2731 (problem communicating with processes in SELinux)" 74d9693 Updated man pages for 0.25.2 7e2b1e9 Fix for #2995 (don't fail to load PSON when UTF-8 missing) d1ff4b3 Fix for #2994 (undefined method "_file" message) 4d81511 fix #2987 - check correct hash entry 0.25.2rc2 ========= 682000b Updated CHANGELOG for 0.25.2rc2 e4bb529 Fix for #2967 (RFC-1123 problem and regression on wildcarded domains) 776be7c Updated CHANGELOG 0.25.2rc1 ========= a73f799 Updated version 26e7486 Fixing failing tests 05e897e Fix for #2881 (ralsh doesn't find individual parsed resources) e04f9e4 Code smell reductions 24654a2 Making provider/host/parser.rb compatible with host_aliases 49530ad Fixing #2964 updated resources cannot be collected until they are exported twice 6ab2453 Fix for #2731 (problem communicating with processes in SELinux) 0e5d264 Fix for #2940 (propogating nil rather than reporting the error) d60ea0e A slide down the RFC-1123 slope towards MS Windows compatibility and chaos b185801 Fixing #2960 Test Failed: 'Puppet::Type::Mount::ProviderParsed when modifying the filesystem tab should write the mount to disk when :flush is called 5e5c8b5 Fixing tests 0cb5e7d Fix for #2943 (Make puppet --apply respect --preferred_serialization_format) 0884035 Fix #2970 spec/unit/provider/ssh_authorized_key/parsed.rb has order dependencies b86decc Fix #2816 MySQL server has gone away 854c065 Fix for #2813 (alias propety v. alias metapram) 813cb58 Fix for #2765 (--no-fqdn regression in puppetrun) e9a0cb7 Fix for #2657 (retain old setting if config has syntax error) 727ee72 Fix #2966 spec/unit/util/queue.rb can't be run twice 8c8e921 Fixing #2963 spec/unit/util/autoload.rb depends on global state ea90daa Fix for #2965 (Chatty SELinux message) fc221ff Fixed RSpec deprecation error 037b99a Fixing #2958 inconsistent errors in spec/integration/bin/puppetmasterd.rb d11c750 Fix for #2951 (SELinux test errors on OS X) 0dc2dba Fix for #2890 (the cached certificates that would not die) 03f37ac Fix for #2950 (parens needed warning) 61fd460 Fix #2924 Test Failed: Puppet::Indirector::FileContent::FileServer when finding files should find plugin file content in the environment specified in the request 2432b23 Fixed test typo f5960ce Closed #2937 - Migrated a number of requires to features 2d88926 Fix for #2869 (SELinux tests failing under some load orderings) 18c5165 Adds partial IPv6 support to authstore 857047d Fix for #2567 (Authstore does unintended/pointless DNS lookups) dddbd28 Enabling steps for #2567 (Authstore does unintended/pointless DNS lookups) ea0a43f Fix 2948 Failing rests in spec/unit/rails.rb b6f4291 Fix #2923 failing tests in spec/unit/ssl/host.rb bf7c108 Fix #2677 Proper OIDs on puppet.schema for LDAP e0488b2 Fix #2808 puppetqd doesn't give an error when no config is given 7b2e2ba Fixing 2851 spec/unit/network/rest_authconfig.rb test descriptions change 1c69af2 Fixing 2855 Inadvertent zlib dependency 3528a7b 2850 spec/unit/application/puppetd.rb generates warnings if run with certain other tests d343af0 2876 spec/unit/indirector/catalog/compiler.rb changes behaviour a7fae47 Fix 2936 Insufficient mocks for webrick in spec/unit/network/http/webrick.rb b96b757 Fix for #887 (safely setting pager to cat for blastwave) d685f44 2633 file and line info on bad params in type/file 4326eb2 Fix for #2817 (links created even when links property set to follow) 118adc1 2875 spurious test failure in spec/integration/file_serving/content.rb 0f63a54 2877 race condition in webrick 4895329 Fix for #2921 (test not checking for what it really wanted) f47fa40 Fix for #2925 (accept higher versions of rspec) c261721 Fix for #2911 (Allow capital letters in selinux contexts) bf7d650 Fix for #2900 (rug output parsing too specific) cccbca4 Fix for #2786 (failed trying to backup directory in recursive purge) 6dfac97 Fixing 2907 rspec crash when spec/unit/application/puppetrun.rb is run after spec/unit/util/ldap/connection.rb 1c8d272 Fixing 2870 Spurious failures in spec/integration/ssl/certificate_request.rb 979440f Fixing 2862 spec/integration/file_serving/metadata.rb fails unless run with other tests e04d299 Fixing 2858 spec/unit/application/puppetmasterd.rb fails if run twice 53a9805 Minimal fix for #2822 9ac1ed6 Fix for #2863 (calling each on uninitialized tag list) bd9e06f Feature 2827 Option to disable managing internal files 8b66998 Fixing 2849 puppet changes sshkey alias every run if it is blank 7136c85 Fixed spellquote function documentation de16fd3 Updated yumrepo type documentation d1fa7cf Fixed --no-ca option in Gentoo also 8b5b4b6 Fixed incorrect command line in Red Hat sysconfig file 623d9c7 Fixing 2886: Failing specs in format_handler feb021f Avoiding rspec bug which causes 'be_all' tests to always pass 228f105 Removed some extraneous files from ext 01c98f6 Fixed #2798 - Correct issue with crontab provider on AIX f7c5ceb Fixing 2725 Error message when permissions incorrect on file server directory 07b94b4 2842 Format debugging should be removed 3abcc89 Fix #2783, take2 - puppetdoc should use environment to get modulepath/manifestdir f5dd6c8 Fix #2831 - puppetdoc doesn't cope with regex node 4a06379 Fixing #2857 (quote nesting error) 9a41c35 Fixing #2791 fs_find should follow symlinks 5629092 Added additional documentation to file mode attribute. dc8812c Fixing 2792 selinux tries to set properties on unsupported filesystes 57632a0 fix #2854 - parse timestamps cb6bc27 fix regex for non-installed packages 9cfe390 Fixing 2812 authorized_keys without comments fail 53b3b86 Fix for ticket #2844 (file recursion generated vs. explicit prefix) 8129caa Fix for ticket #2700 -- check for @explicit_waitforcert in puppetd --test e32f980 Fixed #1806 - supplementary groups are not reset be7ff82 Fix 2768 maillist resource is broken 48beaba simplify and fix portage provider 0ac0ce9 Implement tasks for git-based workflow. bd5dc64 Possible workaround for #2824 (MRI GC bug) c1e47a4 Fixing #2789 puppetrun fails without --tag 106c9a9 Fixing 904 RDoc::usage incompatible with rubygems 5ed2e26 rack: SSL Env vars can only be in Request.env 7f2e5fc Fix #2671, preferred_serialization_format does not complain about invalid values f0eaf20 Fixing #2764 ActiveRecord 2.1 support eaab789 Fix failing tests introduced by #2797 55d8ffa Fix #2810 - adapt tidy to new FileSet api 236bacc conf/redhat: Prevent killproc from removing /usr/sbin/puppetmasterd 41f025c Fixed ldap typo again 6c2daa3 Fix #2783 - Puppetdoc rdoc should use environment to get modulepath/manifestdir 5648666 Add Environment#manifestdir and small refactoring 74a877e Minimal fix for #2821 ("rake spec" is needlessly slow) cd10e6d Added package signing task ca56aa7 Least kludgy patch for #2675 adc0a4e Fix for #2661 and related issues 65f601a Fixing 2806 Specifying multiple tags fails to apply any of them e2c675e Updated generate function documentation to make it clear it runs on the master 53f40bd Fix #2681 Incorrectly duplicating resources 3fdc8ef Ticket #2770 (deserializing Exec[...]s with "\n"s) b172287 Fixing #2767 invoke-rc.d warnings 4013560 Fix #2797 - tags are not inherited by recursed file sub child f05a04e Fix #2784 - puppetdoc/rdoc didn't parse mono-instruction class content 38ec9fc Fix #2796 - Fix puppetdoc rdoc selector parsing 5f7177e Fix #2795 - puppetdoc rdoc reports a better error message 136949d Fixing #2631 show_diff sometimes doesn't happen cb3e5e1 Fix #2787 - Storeconfig doesn't store/update node ip and environment anymore ff23b57 Fix for #2670, Puppet silently ignores catalog_format ee13efa Add docs to Mac OS X package creation script and clean out old docs in the preflight b8470b8 Fix #2757 & CSR 92 (symlinks in recursively managed dirs) 5b750c2 Fix #2769 - default schedule are not defined eca338c Fix for #2772 (webrick test failures) b1c57e9 Al Hoang's patch for #2781, removing obsolete when/: syntax 50e9c98 Follow-on for #2724 - Adding an external node classifier 0.25.1 ====== 2f0b1e5 Updated CHANGELOG 20e5222 Fixing #2689 - file owner warnings are reduced 09fb3f7 Fixing #2752 - "require" loads "include" 6846c32 Fixing some recently broken Scope tests 0043392 Fixed typo in lib/puppet/indirector/ldap.rb 6b254eb Fix #2753 - Do not "global allow" plugins/modules mount if some rules have been parsed ff3a7bc Re-fixed #2750 - Stop disabling the CRL or checking for a disabled CRL 594c774 Revised partial fix for #2661 and related issues 73d04c6 Bug #2534 Raise error if property appears twice 7517572 Bug #1908 cron environment should allow empty vals febe707 Bug #1742 Invalid params to --color outputs 'nil' d383ab8 Use notice() in the versioncmp() docs 9dff716 conf/redhat/*.init: Use -p option to killproc f47a70f Ticket #2665: Regexp exception on ++ in package names b6e4ef3 Fixed #2750 - Set :cacrl to nil instead of 'false' in puppetd 2b57e06 Fix #2691 - Collection AR request should not include params if querying with tags e8bce7a Workaround #2668 - Compress facts so that the request size limit triggers less often e2ce790 Fixed #2737 - The zone provider needs to get acquainted with OpenSolaris aea1e5f Update Red Hat spec file for 0.25.1 fbdded7 Ticket #2685 (Type error in ssh_authorized_keys) 4d9f76a Fix for #2745 fakedata tests not working b4bcfe9 Fix for #2736, target doesn't work for ssh_authorized_keys ae528f6 Ticket #2734 PSON/JSON not serializing classes of a catalog f59f805 Bug #1900 Parsing of quoted $ in stdin 6ba122f Fixing #2735 - node classes are immed. added to classlist 0.25.1rc2 ========= bca3b70 Bundling of pure ruby json lib as "pson" ce46be5 Proposed alternative solution for #2664 (REGEX / DIV lexing) b0518c3 Fix for #2681 (duplicate resource) 8a73082 Fix #2707 config_version fails more helpfully 54ded1b Fixes #1719, this avoids calling the external binary *which* everytime we are looking for a binary 4c3c279 Updated required Facter version in README fcce46a Fixed #2702 - Set :outputdir to "doc" if not specified 3940dfb Fixed #2674 - createpackage.sh: problem finding install.rb 3b548f4 Fix #2699 - Use --masterport for PUPPET_PORT variable a75bf50 This updates the portage provider in three ways: ad86e9e Fixes #2688. Macauthorization provider now handles booleans internally correctly. d891f7a Ticket #2676 (a typo) bfba2cd Fix #2672 - Make sure nodenames keep their underscores when used as classname db67e5f Added rcov exclusion to Rakefile 0.25.1rc1 ========= 6912a7e Incremented version to 0.25.1 fd322da Fixes #1538 - Fixes the yumrepo backtrace in noop mode. 6551e86 Fix #2664 - Mathematic expressions mis-lexed as Regex a595033 Fix for #2654 (error generating error message) a951163 Fix #2642 - Runit provider rework 96b5087 Fix for ticket #2639 (Puppet[:user]/Puppet[:group] vs. 'service') af57483 Fixing #2632 - 'require' works for 0.25 clients d42bda1 Fixing relationship metaparam backward compatibility d53bc16 Adding version information to the catalog for compat 5f25589 Ticket #2626 (unhelpfull error messages) a1d3b04 Fixing #2617 - use the cert name as specified 8987509 Refactored Puppet packaging and gem creation 5c2ba47 FIXES 2616: Remove sync.syncronize and Puppet.info a53a77c Renamed test branch to testing in rake task d054fd9 Fixing #2656 - puppet parseonly tests don't hang cde70cf Fixes #2648. Spurious macauthorization parameter changes dcf0d0d Fix #2652 - Fix SELinux syntax error ba269f2 Fixed #2651 - Corrected install permissions on man page directories. 361c502 Fix #2638 - Allow creating several nodes with matching names 2283605 Added automatically constructed test branch task and file fd2a190 Fix for #2621 (JSON serialization of exec) 577a45b Fix #2622 - Puppetdoc in single manifest to console is broken d2d7070 Fix #2640 - Daemontools and Runit were not creating the enable symlink d21b266 Fix #2627 - regex node name could lead to invalid tag cb90528 Merged fix for #2601 b1554a1 Updated changelog task and CHANGELOG to version aware f5a106d Fix for #2637 (Webrick accpting connections on dead sockets) 19e98f9 Fixed #2608 - install.rb will not run on ruby 1.9.1 due to ftools being deprecated 40cd6d4 Fix for #2605 by falling back to alternative solution to #1963 630407d Make regsubst() function operate on arrays (feature #2491). a45c435 Fix for #2600 (wrong number of arguments under older mongrel) f2bc8aa Fixed #2634 - Added servicegroup_name parameter to serviceescalation type 7404e31 Fixs #2620 authconf interpolation, #2570 0-9 in domain names 4344339 Fix for ticket #2618 (stubbing so redhat tests run under debian) c2e26b9 vim: match regexp language features 1494bd7 Require active_record/version to support ActiveRecord < 2.3 a5c56fc Fixed #2607 - Added Facter dependency for Puppet Gem 0.25.0 ====== b1eddbb Updated and created new CHANGELOG format 994d6e0 Adding tests for the #2599 fix 42ab73f Ticket #2525 don't fail find_manifest on invalid module names a0f0dcc Updated permissions on test files d45812b Refactoring tests to reduce code size, increase coverage, and make Luke happy. aba2f66 This further normalizes the handling of init-style services (including the redhat "service" wrapper script). Removes special case handling of non-zero exit code in redhat (base already did this) and centralizes scattered @resource[:has_____] checks. Tests that proper versions of each are called and one level of fallbacks. fb236a0 Combined fix for #2525, #2552 -- RedHat service issues d40b942 Fixed #2589 - Renamed zfs delete to destroy and added tests 4aa7fce Monkey patch to improve yaml compatibility between ruby versions 1f6c74d Fixed typo in parser test 2e9b706 Updated Red Hat spec file and RH patches for 0.25.0. 19815dd Fixing #2592 - you can escape slashes in regexes ea58478 Fixing #2590 - modulepath is not cached inappropriately 1a3d0c8 Fixed #2593: puppet init script status command not returning proper exit code 8dabc72 Update documentation string to reflect actual intent of Puppet::Node::Facts::Rest b30a3c7 Fixes #2581. Use new 10.6 global launchd overrides file for service status/enabled 7f05469 Fixed Naginator link e589cd3 Fixing #2582 - / no longer autorequires / 3342b73 Fixing #2577 - clarifying and demoting the deprecation notice d397f8d Fixing #2574 - autoloading finds plugins in modules 800a78b The first regex node now matches first 6750aeb Fixing #2563 - multiple regex nodes now work together b728b93 Fixes #724 - false is equivalent to 'ruby -W1' a9d5863 Fix parser error output ee4f6ba Fixing #2551 - fixing content changed logs c8f859e Fix for test isolation portion of Ticket #2511 6fa9271 Fixing #2549 - autoloading of top-level classes works again c752680 Fixing a heisenbug resulting from a race condition ea417d6 Fixing #2460 - puppetmasterd can now read the cert and key a49915a Not using the service user in settings when it's unavailable 14ec838 Explicitly loading all facts in the directory service provider 5ee6602 Adding an 'exists?' delegator from user type to provider 06fcece Switching the owner/group settings to use symbolic values 4eb325a Fixing the yamldir group to be a group instead of user 058514a Moving Setting classes into separate files b0f219a Removing chuser on darwin restriction 7f749cb Fixing a ruby warning in the authstore test c0da3bf Fixing #2558 - propagating recent fileserving changes ff39bc7 Fixes #2550 Handles case where metadata is nil 47dee83 Ticket 2559 -- parseonly ignored specified file a4f6896 Fixed #2562 - Recognize the usecacheonfailure option again Signed-off-by: John A. Barbuto e408d6c Refactoring the Module/Environment co-interface 796ba5c Fixing #1544 - plugins in modules now works again 6bd3627 Adding a global cleanup to the spec_helper 0ef5f22 Removed misguided case sensitivity tests c1967bb Fixes #2513. debian service provider now uses invoke-rc.d to determine enabled? status 7e09247 Fixing fact-missing problem when puppet.conf is reparsed a35e9bf Fix for #2531; adds tests to confirm problem and related cases, notes fixes specific issue by eliminating the specal case for opaque strings which caused them to be strings when everything else was arrays; adds nots and pending tests where FQDN support could be added but stops short of a full refactor. 299eadb Fixed #2530 - Fixed status setting in the SMF provider e6a7e82 Fixed spec typo 75c6e4a Fixes #2493 b62d966 conf/redhat/*.init: Fix condrestart/try-restart e9fbd4c conf/redhat/client.init: Fix #2123, status options on older RHEL 0461a02 Updates to Solaris smf files to reflect new binary locations 55a9cdb Fix #2517 - Stack overflow when CA cert missing 601a2e5 Fix #2516 - Fix format detection when content-type contains charset d86bc88 Fix #2507 - Add missing integration tests aad3b76 Fix #2507 - Exported resources were not correctly collected. 63cb1ad Fixes #2503 c129f2a Fixes #2360 - Removed annoying log message b1ffffa Fixed #2525 - Wrong method being overridden in Red Hat services a88fc4d Fixing more tests broken from missing libraries 9a356ab Fixing ActiveRecord Indirector tests to skip w/out Rails acc5a96 Fixing #2489 - queue integration tests are skipped w/out json 1a5c5b3 Fixing #2508 - removing mention of ActiveRecord 2.3 0cb9072 Fixing #2541 - file cache is more resilient to failure 23948d0 vim: Mark puppetFunction values as contained 79a4339 Add shellquote() function. 79d705f Fixes #2499. Allows execs to specify an array for the returns parameter b611c34 Updated fix for #2481 f385072 Revert "Fxied #2481 - Added status and restart overrides for Red Hat service provider." cc379b6 Fixed #2498 - logcheck update 85a3633 Removed extraneous debugging 0.25.0rc1 ========= bf94de9 Updated two more tests 5b87dba Logs now assume resource params have metadata 1410bed Adding metadata delegation from param to resource 3ab3a5c Removing unnecessary debug output 488e368 Adding integration tests for #2371 (backup refactor) f1406bf Adding many tests for #2371, and slightly refactoring 8f60f0c Fixes for Redmine 2371. cd224c6 Fixes #2464, #2457. Deprecate reportserver for report_server. Add report_port setting. Add tests. 401a9ec Fixing #2484 - "format missing" messages are better f6cc598 Fixes #2483 - Log only copies metadata from RAL objects 7c4c00f Fixed #2486 - Missing require 'monitor' in parser_support.rb ea34ee6 Added R.I.Pienaar's extlookup.rb to the ext directory 36d3f58 Added example conf/puppet-queue.conf 967eb9f Fxied #2481 - Added status and restart overrides for Red Hat service provider. c702f76 rack: SSL Env vars can be in Request.env or ENV ca17b3c rack: don't directly use the forbidden HTTP_CONTENT_TYPE env var (fixes rack specification conformance) a002e58 Removing old filebucket test d8de446 Cleaning up tests for #2469 266aafa default server in remote filebuckets 1f8ef60 Fixes #2444 - Various JSON test failures 11c0fb7 Fixed #2294 - Classes sometimes cannot be found 7e5b562 Adding #2477 - puppet can apply provided catalogs 97274ad Fixing problems my Feature refactor caused 6fb8bf6 Fixing ruby warning in definition test b3545fc Fixed global deprecation error in useradd Unit tests dc24472 Adding a test for the Exec type 58d9587 Speeding a test up through stubbing d4d8372 Fixing a small test by stubbing instead of mocking f7e1c36 Fixing a test broken by the regex features 54a225d Fixing tests broken by caching autoload results 1ce31b4 Migrating Handler base tests from test/ to spec/ cc3f56a Migrating Feature tests to spec 21d1d25 Fixing cron test to match new behaviour 849fa67 Migrating tests to spec and removing an obsolete test 6f458cc Logging the configuration version we're applying ac58e27 Configuration version information is now in logs 6ed0103 Adding support for an external catalog version 39320b8 Cleaning up duplication in another test file 25fae5f Removing duplication in the test structure 36c0662 Simplified Rakefile and moved tasks to tasks/rake directorya b45ccf8 Implement node matching with regexes 58a73b5 Make sure node are referenced by their names 3ebf148 Enhance selector and case statements to match with regexp ef68967 Fix #2033 - Allow regexp in if expression 17e62b1 Add AST::Regex, an AST leaf node representing a regex 4f9545f Add regexes and regex match operators to the parser 0ccd259 Add regex, match and not match token to the lexer 201ae59 Allow variable $0 to $9 to be interpolated, if ephemeral f357a91 Implement ephemeral scope variables d40ef29 Signed-off-by: Eric Sorenson 6d22afb Modifying the REST client error to make server errors more clear 21f477a Fixes #2472. Load Facter facts when ralsh is invoked, plus test. 2e41edb Update CHANGELOG.git ebb5a1f Fixed ci_spec task for RubyGems 1.3.5 b6b903e Fixes #2461. Provide new and old code paths for macosx_productversion_major with deprecation warning 26b0c70 Fixing typo in two tests which caused them to always pass 76fc2b1 Fixing #2440 - catalogs can now be compiled on demand 832b6ff Exiting from app failures instead of raising 4ea3f17 Minimal patch to fix #2290 (/tmp permissions) 08ff9e8 Fix #2467 - rack: suggest putting puppet/lib at beginning of RUBYLIB search path fb60f90 Fix #2465 - Default auth information is confusing with no auth.conf 0ca9b53 Fix #2459 - puppetdoc added namespace classes as RDoc modules instead of classes 18b5d61 Fix #2429 - vim: class/define/node should only be followed by whitespace da828a4 Fix #2448 - fix the broken runit provider and tests 3898436 Fixed #2405 - Mount parameter "dump" doesn't accept all valid values on FreeBSD 9825bec Fixes #2362. Do not validate users/groups when supplied with numeric uid/gids 450a19c Fix #2454 - Definition named after a module don't show in puppetdoc 8551ece Fix #2453 - puppetdoc mixes long class names that look alike e3ee594 Fix #2422 & #2433 - make sure puppetdoc transform AST::Leaf boolean correctly b3b76df Fixing #2296 - overlapping recursions work again 9120712 Fixing mocks to remove warnings eeec8e9 Fixing #2423 - no more strange dependency cycles 7d40f9e Fixing #2443: Adding debugging guidance to dep cycle errors b4facb0 Fixing a test broken by changing the default os x package type b418921 Fixing selinux tests broken in the fix for #1963 719e76b Fixing #2445 - fixing the mount test mock f13f08d Minor fix to URL for LDAP nodes documentation 7c859a7 Fixing #2399 - removing client-side rrd graphs f6d6145 Fixing #2421 - file renaming errors now propagate db82523 Fixes #2438, get major OS X version from Facter and replace Puppet::Error invocations with fail builtin 22145e7 Update install.rb to cope with all OS X versions, not just 10.5 935c463 Fixing #2403 - provider specificity is richer and better d95b687 Fix #2439 - let puppetdoc use loaded_code ef5c4ae Fixed #2436 - Changed ralsh to use Puppet::Type.new and avoid deprecation notice 0c18013 Fixes #2430 - Stock apache2.conf for passenger incorrect c383ceb Make pkgdmg default Darwin provider, make confines consistent on Darwin package providers. 98599c4 Convert to using sbindir for OS X packages, clean out previous executables in bindir c659743 Fix #2425 - make sure client can contact CA server with REST 17205bb Fix #2424 - take 2, make sure default mounts allow every clients f2c55cc Fix #2378 and #2391 tests 8bbd8b4 Fix #2424 - File server can't find module in environment effaf80 Fix small typo in the fix for #2394 a06094e Feature #2378 - Implement "thin_storeconfigs" b2a008e Fix #2391 - Exported resources never make to the storeconfigs db 8f82407 Fix #2261 - Make sure query string parameters are properly escaped c86d44e Fixed #579 - puppet should try to clear solaris 10 services in maintenance state 910a5e2 Fix #1963 - Failing to read /proc/mounts for selinux kills file downloads ba824e9 Fixing #2245 - provider lists are not lost on type reload eb40966 Ruby no longer clobbers puppet autoloading a42e878 deprecate NetInfo providers and examples, remove all NetInfo references and tests. 22f5632 Fixed #2410 - default acl logs as info instead of warn. 65b0137 Adding test for current auth config warning. 74f5ad4 Fixed #2394 - warn once on module mount deprecation. f46a52a Add test for current module mount deprec warning. 858d333 Fixes #2258,#2257,#2256. Maintain correct type for integers/booleans, allow correct values, and fix rule array handling 44f127f Added Markdown mode to puppetdoc to output Markdown. 8a8ce9d Excluded directories from rcov coverage report d152c5e Allow boolean value for boolean cli parameter 911b490 Fix #2364 - Associates the correct comment to the right statement faefd92 Make sure the parser sees the correct line number 869ec27 Fix #2366 - puppetdoc was parsing classes in the wrong order 4c659b7 Added rcov coverage to Spec tests 1fd98b1 Fixes #2367 - Mongrel::HTTPRequest returns a StringIO object 8b09b83 Fix #2082 - puppetca shouldn't list revoked certificates ea66cf6 Fix #2348 - Allow authstore (and REST auth) to match allow/deny against opaque strings 1e83aad Fix #2392 - use Content-Type for REST communication aaca17a Fixed #2293 - Added cron syntax X-Y/Z and '7' for sunday cddc365 Switching to LoadedCode from ASTSet fc1f8cd Adding a special class to handle loaded classes/defines/nodes 325b8e4 Fix #2383, an incompatibility with early ruby 1.8 versions 46112da Fixing #2238 In some cases blank? is not available on String. cdd1662 Fixing #2238 - Deal with nil hash keys from mongrel params 769c8aa Final fix to CI test rakes a6816ff Set ENV['PATH'] to an empty string if non-existent 64a4720 Fix to CI rake tasks 5680cd5 Fixing #2197 - daemontools tests now pass 603b9cf Change the diff default output to "unified" 9bc9b5c Added missing colon to suntab 0f2d70d Fixed #2087 and refactored the code that gets the smf service state 0.25.0beta2 =========== 3f070c1 Using the logging utilities to clean up module warnings feb7f89 Fixing #1064 - Deprecating module 'plugins' directories ccf4e69 Removing deprecated :pluginpath setting 4036de9 Fixing #2094 - filebucket failures are clearer now ed876e0 Refactoring part of the file/filebucket integration bd81c25 Adding tests for file/backup behaviour c45ebfa Fixed pi binary so --meta option works and updated documentation d2080a5 Fixing #2323 - Modules use environments correctly b9e632f Fixed #2102 - Rails feature update fixed for Debian and Ubuntu 1c4ef61 Fixed #2052 - Added -e option to puppet --help output d332333 Fix #2333 - Make sure lexer skip whitespace on non-token 5fbf63c Updated split function and add split function unit tests (courtesy of Thomas Bellman) a585bdd * provider/augeas: strip whitespace and ignore blank lines a94d2de Fixed pi tests 5f7455e Fixed #2222 - Cleanup pi binary options and --help output 134ae3e Fixing #2329 - puppetqd tests now pass de55e19 Cleaning up scope tests a bit e4ae870 Fixing #2336 - qualified variables only throw warnings 607b01e Fix #2246 - take2: make sure we run the rails tag query only when needed 06b919d Fix collector specs which were not working 2945f8d Make sure overriding a tag also produces a tag e142ca6 Removed a unit test which tested munging which is no longer done in the type d8ee6cf Clearn up a parsing error reported by the tests 446557f vim: several improvements + cleanup 9152678 Fixed #2229 - Red Hat init script error b5a8c4d Fix #1907 (or sort) - 'require' puppet function 74730df #2332: Remove trailing slashes from path commands in the plugin 1a89455 Changing the preferred serialization format to json 0de70b7 Switching Queueing to using JSON instead of YAML 7b33b6d Adding JSON support to Catalogs c0bd0aa Providing JSON support to the Resource class c16fd1b Adding a JSON utility module for providing Ruby compat f059c51 Adding JSON support to Puppet::Relationship 7f322b3 Adding a JSON format 7666597 Allowing formats to specify the individual method names to use d40068f Allowing formats to specify the methods they require 024ccf5 Adding a "json" feature c8b382d Fix some tests who were missing some actions f9516d4 Make sure virtual and rails query use tags when tag are searched b5855ec Make sure resources are tagged with the user tag on the server d69fffb Fix #2246 - Array tagged resources can't be collected or exported 6ce0d1e Partial fix for #2329 4f2c066 Removed extra whitespace from end of lines 97e6975 Changed indentation to be more consistent with style guide (4 spaces per level) 41ce18c Changed tabs to spaces without interfering with indentation or alignment f3b4092 Fix #2308 - Mongrel should use X-Forwarded-For 7b0413e Fixes Bug #2324 - Puppetd fails to start without rails 48d5e8c Enhance versioncmp documentation ef56ba5 * provider/augeas: minor spec test cleanup d322329 * provider/augeas: allow escaped whitespace and brackets in paths 9735c50 * provider/augeas: match comparison uses '==' and '!=' again dbfa61b * provider/augeas (process_match): no match results in empty array 386923e * provider/augeas: remove useless checks for nil 171669a * provider/augeas: simplify evaluation in process_get/match 51cc752 * provider/augeas (open_augeas): use Augeas flag names, not ints 4951cdf * provider/augeas: ensure Augeas connection is always closed 0d5a24d * provider/augeas: minor code cleanup cea7bb5 * provider/augeas (parse_commands): use split to split string into lines 95bd826 * provider/augeas: remove trailing whitespace (no functional change) 7c5125b Brought in lutters parse_commands patch and integrated it into the type. This includes reworking the get and match commands as well. This change introduces a few small changes. These are: 6ce8154 Removed --no-chain-reply-to in rake mail_patches task 4ef7bba Removing --no-thread from the mail_patches rake target 508934b Fixing a bunch of warnings fb0ed7a Fixing tests broken by a recent fix to Cacher 650029e Always providing a value for 'exported' on Rails resources f1dba91 Fixing #2230 - exported resources work again 5522eb8 Disabling the catalog cache, so puppetqd is compatible with storeconfigs abbb282 Fixing the rails feature to be compatible with 2.1+ 907b39b Using Message acknowledgement in queueing 42247f0 Fixing #2315 - ca --generate works again d7be033 Fix #2220 - Make sure stat is refreshed while managing Files e4d5966 Added puppet branding to format patch command 00d5139 vim: Remove another mention of 'site' from syntax 9067abd vim: Highlight parameters with 'plusignment' operator 736b0e4 vim: Highlight strings in single quotes ce01c95 vim: Clean up syntax spacing 3af2dbf JRuby OpenSSL implementation is more strict than real ruby one and requires certificate serial number to be strictly positive. 62534a1 Logging when a cached catalog is used. ff5c44f Changing Puppet::Cacher::Expirer#expired? method name e3d4c8e Fixing #2240 - external node failures now log output bc1445b Fixing #2237 - client_yaml dir is always created by puppetd e0c19f9 Fixing #2228 - --logdest works again in puppetd and puppetmasterd ab34cf6 Fixing puppetmasterd tests when missing rack 9d5d0a0 Fixing the Agent so puppetrun actually works server-side b0ef08b Fixing #2248 - --no-client correctly leaves off client b83b159 Fixing #2243 - puppetrun works again 3d2189f Fixed #2304 - Added naggen script to directly generate nagios configuration files from a StoreConfigs Rails database 700ad5b Sync conf/redhat/puppet.spec with Fedora/EPEL 3ec3f91 Fixed #2280 - Detailed exit codes fix f98d49f Fixing #2253 - pluginsync failures propagate correctly d860a2f Fixing a transaction test that had some broken plumbing a728757 Refactoring resource generation slightly 6e824d8 Adding a Spec lib directory and moving tmpfile to it 1d69dbf Extracting a method from eval_resource in Transaction 7650fb2 Not trying to load files that get removed in pluginsyncing 3995e70 Fix #2300 - Update ssh_authorized_key documentation cb4a4d3 Changed version to allow Rake to work. Minor edit to Rakefile 99f666f enable maillist on centos, redhat, fedora e13befa Fixing #2288 - fixing the tests broken by my attr_ttl code a406d58 Fix for #2234: test fails with old Rack version c189b46 Fixing #2273 - file purging works more intuitively 138f19f Caching whether named autoloaded files are missing 415553e Adding caching of file metadata to the autoloader d489a2b Adding modulepath caching to the Autoloader 5f1c228 Adding caching to the Environment class 047ab78 Adding TTL support to attribute caching 6a413d2 Fixed #2666 - Broken docstring formatting 469604f Deprecating factsync - pluginsync should be used instead d39c485 Added spec and unit tests to the Rakefile files list and fixed CI rake tasks e1a7f84 Added install.rb to Rakefile package task e180a91 Fixed #2271 - Fix to puppetd documentation 4bf2980 Protecting Stomp client against internal failures f4cb8f3 Adding some usability bits to puppetqd a18298a Refactoring the stomp client and tests a bit 2771918 Relying on threads rather than sleeping for puppetqd 07ff4be Fixing #2250 - Missing templates throw a helpful error 7ce42da Fixing #2273 - CA location is set correctly in puppetca e1779c7 RackXMLRPC: buffer request contents in memory, as a real string. fb957cc Modules now can find their own paths c608409 Moving file-searching code out of Puppet::Module 83ba0e5 Fixing #2234 - fixing all of the tests broken by my bindaddress fix 4f3a67f Fixing #2221 - pluginsignore should work again 2d580c2 Fix snippets tests failing because of activated storeconfigs 8c718c9 Fix failing test: file.close! and file.path ordering fix 17f2c7d Confine stomp tests to Stomp enabled systems 6a80b76 Fix some master failing tests 172422f Fix bug #2124 - ssh_authorized_key always changes target if target is not defined f945b66 Fixing #2265 - rack is loaded with features rather than manually 5aef915 Added .git to pluginsignore default list of ignores 6db5e8d Cleanup of the Puppet Rakefile and removal of the requirement for the Reductive Build Library 5cc4910 Fix #1409 once again, including test a6af5bf Added split function 0.25.0beta1 =========== 2dd55fc Fixing #2200 - puppetqd expects Daemon to be a class c016062 Removing unneeded test stubs 1a2e1bc Fixing #2195 - the Server class handles bindaddress df3a8f6 Minor fixes to function RST documentation 305fa80 Remove the old 0.24.x rack support, which is now useless cruft d85d73c puppetmasterd can now run as a standard Rack application (config.ru-style) d6be4e1 Add XMLRPC compatibility for Rack 6e01e7a Puppet as a Rack application cc09c1a Use FileCollection to store the pathname part of files d51d87e Add an unmunge capability to type parameters and properties a1c0ae0 Fix #2218 - Ruby YAML bug prevents reloading catalog in puppetd bf054e1 Fixes #2209 - Spec is failing due to a missing require 1c46205 Fix #2207 - type was doing its own tag management leading to subtile bugs 929130b Moved puppetqd binary 36d0418 Fixed #2188 - Added set require to simple_graph.rb 51af239 Fixed puppetqd require and tweaked stomp library error message dc0a997 Fixes #2196 - Add sharedscripts directive to logrotate 4d3b54e Added puppetqd binary to Rakefile 1fee506 Updated version to 0.25.0beta1 0fbff61 Updates to CI tasks aa6dcef Fixing #2183 - checksum buffer size is now 4096b c0b119a Fixing #2187 - Puppet::Resource is expected by Rails support 5ec4f66 Adding an 'Exported' attribute to Puppet::Resource adff2c5 Removing a non-functional and horrible test 606a689 Making sure the cert name is searched first f489c30 Removing an "inspect" method that often failed in testing 93c3892 Removing deprecated concurrency setting usage in rails 6f8900d Always making sure graph edges appear first 3f7cd18 Reverting part of the switch to sets in SimpleGraph bf46db7 Fixing rails feature test 5f6b5c0 Failing to enable storeconfigs if ActiveRecord isn't available 8ed7ae3 Fixing the Rails feature test to require 2.3.x a0c1ede Modifying the Settings#handlearg prototype 284cbeb Fixes #2172 - service provider for gentoo fails with ambiguous suffixes 68ba1f1 SMF import support working and documentation update f1f0a57 Fixes #2145 and #2146 ec478da Fix configurer to retrieve catalog with client certname e623f8a Unify auth/unauthenticated request authorization system 037a4ac Allow REST auth system to restrict an ACL to authenticated or unauthenticated request 3ad7960 Fill REST request node with reverse lookup of IP address c0c8245 Refactor rest authorization to raise exceptions deeper aac996e Add environment support in the REST authorization layer 72e28ae Fix some indirector failing tests dc1cd6f Fix #1875 - Add a REST authorization system 8523376 Enhance authconfig format to support uri paths and regex 22b82ab Add dynamic authorization to authstore 15abe17 Add RSpec unit tests for network rights 86c7977 Add RSpec unit tests for authconfig f04a938 Adding support for specifying a preferred serialization format 6a51f6f Fixing the FormatHandler test to use symbols for format names b249f87 Fixing #2149 - Facts are passed as part of the catalog request 1cde0ae Adding better logging when cached indirection resources are used 828b1ea Fixing #2182 - SimpleGraph#walk is now iterative 9f32172 Fixing #2181 - Using Sets instead of Arrays in SimpleGraph 7a98459 Removing code that was backported and is now not needed d06bd3e Finishing class renames b694b3c Fixing tests that apparently only worked sometimes 93246c0 Removing the old rails tests. 5cb0f76 Fixing some rails tests that sometimes failed bdbf9db Added class_name tags to has_many relationships 2e62507 Adding time debugging for catalog storage to active_record a705809 Adding defaults necessary for queueing 8a67a5c Adding daemonization to puppetqd fcd1390 Adding Queueing README 9b90f34 Using a setting for configuring queueing 444ae9f Adding puppetqd executable. 22ae661 Adding "rubygems" and "stomp" features efe6816 Removing unnecessary parser variables when yaml-dumping a3b1e8c Add queue indirection as an option for catalog storage. bccfcc9 Introduce abstract queue terminus within the indirection system. 7947f10 Introduce queue client "plugin" namespace and interface, with a Stomp client implementation. 80dc837 renaming a method f7ccaaa Adjusted parameter name and puppet tag classes to use new cache accumulator behavior for storeconfigs. 75f1923 Initial implementation of a "cache accumulator" behavior. bab45c4 Saving rails resources as I create them, which saves about 10% 7a91e1f Changing rails value serialization to deal with booleans c30ede5 Adding equality to ResourceReference 589f40f Adding some more fine-grained benchmarks to Rails support 042689e Adding a Rails-specific benchmarking module 89d9139 Adding simplistic param_name/puppet_tag caching ea4e3b2 Adding more time debugging to Rails code, and refactoring a bit 6314745 Refactoring the Rails integration be30a61 Adding a common Settings method for setting values 863c50b Switching to Indirected ActiveRecord a137146 Adding ActiveRecord terminus classes for Catalog b9c95eb Adding ActiveRecord terminus classes for Node and Facts. 8d0e997 Fixing #2180 - Catalogs yaml dump the resource table first 4e0de38 Partially fixing #1765 - node searching supports strict hostname checking c1f562d Removing unused Node code e6b4200 Fixing #1885 - Relationships metaparams do not cascade 50e0f3d Fix #2142 - Convert pkgdmg provider to use plists instead of string scanning for future proofing c1be887 Fixing #2171 - All certificate files are written with default perms e2201d6 Fix #2173 - fix running RSpec test by hand 424c87b Fix #2174 - Fix RSpec rake targets 7ab7d9f Fixing #2112 - Transactions handle conflicting generated resources 84e6c1b Adding another stacktrace for debugging 4793334 Fixing puppet -e; it got broken in the move to Application 7398fa1 Partially fixing #2029 - failed caches doesn't throw an exception 88ff9c6 Fixing #2111 - SimpleGraph only creates valid adjacencies 36594fe Switching to new() in the Puppet::Type.instances() class method edcbab5 Removing duplicate method definition from SimpleGraph d8eaca8 mini daemon to trigger puppetrun on clients without puppet listen mode d2c417e Fix #2113 - Make temp directory 173b5f0 Adding #2122 - you can specify the node to test with puppet-test a677e26 Fixing all tests that were apparently broken in the 0.24.x merge. e016307 Fixing Rakefile; apparently there was a rake or gem incompatibility 62dad7a Fix #2107 - flatten resource references arrays properly cbee426 Fix #2101 - Return to recurse=0 == no recursion behavior 3b4816b Fix #2101 - fix failing test f089e11 Fix #2101 - fix recurselimit == 0 bad behaviour 1b4eae7 Added rake ci:all task 3f61df8 Fixed #2110 - versioncmp broken 830e1b1 CHANGELOG updates 3e0a9cd Moved of puppetd, puppetca, puppetmasterd, puppetrun binary from bin to sbin 6ddebf4 Fixed #2086 - Fixes to make building tarballs easier 33d3624 Fix #1469 - Add an option to recurse only on remote side 77ade43 Forbidding REST clients to set the node or IP 0179e94 Fixing #1557 - Environments are now in REST URIs a497263 Adding explicit optional attribute to indirection requests 3e95499 Removing an unused source file 97975e1 Adding a model accessor to the Request class b6116fe Requests now use default environment when none is specified 15740fe Moving the REST API functions into a module ef4fa68 Using the Handler for the REST api on both sides of the connection 8b13390 Adding REST::Handler methods for converting between indirection and uris edf00db Adding environment support to the REST URI a064ed1 Moving the query_string method to Request ff9c3ca Adding tests for the REST query string usage 87ec08e Fixing #2108 - pi should work again af4455e Fix #1088 - part2 - Add rspec tests b15028f Fix #1088 - Collections overrides b24b9f5 Fixed #2071 - Updated LDAP schema 88aa1bc Fixing tests broken in previous commits f8dea98 Fixing #1949 - relationships now use attributes instead of a label d0fc2f5 Correctly handling numerical REST arguments 90afd48 Not passing file sources on to child files 858480b Correctly handling non-string checksums 27aa210 Removing unnecessary calls to expire() 5329b8a Passing checksums around instead of file contents 71e4919 Moving default fileserving mount creation to the Configuration class 09bee91 Fixing #2028 - Better failures when a cert is found with no key cf1cb14 Moving the clientyamldir setting into the puppetd section 5f73eb5 Fixed #1849 - Ruby 1.9 portability: `when' doesn't like colons, replace with semicolons e40aea3 Fixed metaparameter reference to return str 5df9bad Fixed #2016 - Split metaparameters from types in reference documentation 7e207a1 Fixed #2017 - incorrect require 417b5a5 Fixing #1904 - aliases are no longer inherited by child files c0d5037 Removing or fixing old tests 262937f Correctly handling URI escaping throughout the REST process b800bde Refactoring how the Settings file is parsed d7864be Relying on 'should_parse_config' in the 'puppet' application bd8d097 Providing better indirection authorization errors d3bc1e8 Adding pluginsyncing support to the Indirector 00726ba Moving Request and Fileset integration into Fileset. 058266f Switching the ModuleFiles Indirection terminus to the new Module/Env api 19b8534 Migrating the old FileServer to the new Module/Environment code 1be7c76 Using the Environments to handle a lot of Module searching 2b4469d Environments now use their own modulepath method. 94de526 The 'Environment' class can now calculate its modulepath. 2573ef1 Added support for finding modules from an environment 9c18d5a Adding support for finding all modules in a given path. 4b5ec82 reformatting the environment tests 458642b Supporting multiple paths for searching for files. eec1cad Adding support for merging multiple filesets. bdf3a80 Adding new methods to Puppet::Module. a7be174 Refactoring Puppet::Module a bit. 7ceb437 Only using the checksum cache when we're using a host_config catalog 5fd182d Fixing fileserving to support strings or symbols 7bc41ce Adding clarity to query string handling in REST calls 992231a Some small fixes to provide better debugging and load a library 0304a78 Providing better information when an exception is encountered during network communication 4a7cba3 Stubbing tests that were affecting other tests 3105b5b Fixing a warning in a test c854c59 Fixing a syntactically invalid application test 0f43fd6 Move --version handling to Puppet::Application 156fb81 Move puppetd to the Application Controller paradigm 0c71c5c Move puppetdoc to the Application Controller paradigm e317fa9 Move ralsh to the Application Controller paradigm 81f5438 Move puppetrun to Application Controller paradigm 3390d8d Move pi to the Application Controller paradigm 8265d6e Move puppetmasterd to Puppet::Application af219bf Move puppet to the Application Controller paradigm d51398c Move filebucket to the Application Controller paradigm 9b9e5e8 Move puppetca to the Application Controller paradigm 97e716a Introducing the Application Controller 495ad66 Fixing broken filetype tests resulting from the loss of Type[] 21a714a Fixing some tests that somehow broke in the merge to master 327ee17 Removing a test that was too dependant on order. 487b9b1 Failure to find node facts is now a failure. 610c838 Fixing #1527 - Failing Facter does not hurt Puppet a2eca6c Removing some unused code cb0a083 Using Puppet::Type.new instead of create 84bd528 Actualling syncing facts and plugins d5abdfb Fix #1933 - Inconsistent resource evaluation order in subsequent evaluation runs 9bac833 Adding README.rst file 916abc2 Changing how the Configurer interacts with the cache 5335788 Fixing tests broken during the #1405 fix. 08a5d49 Adding an Agent::Runner class. c7d178d The Agent now uses its lockfile to determine running state c0fcb21 Creating and using a new Puppet::Daemon class 700e823 Not using 'master' client for testing 4b7023e Fixing (and testing) the return of Indirection#save 8dc0005 Adding a 'close_all' method to the Log class. 37d1a7c Removing restart-handling from Configurer bf3c72e Adding temporary class EventManager fc14b81 Splitting the Agent class into Agent and Configurer e8be6dc Removing the Hash default proc from SimpleGraph. 6bb804f Removing the Catalog's @aliases hash default value 502e062 Removing an erroneous configuration call in puppetmasterd 337057a Removing obsolete code and tests for the agent. d53ad31 Converting the catalog as needed f38277f Adding REST support for facts and catalogs. c48525b Adding better error-handling to format rendering b93a642 Resetting SSL cache terminii to nil when only using the ca 212b3e3 Allowing the Indirection cache to be reset to nil 5a83531 Moving the Agent locking code to a module. b672790 Cleaning up SSL instances that can't be saved f78a565 Only caching saved resources when the main save works 5434459 Moving classfile-writing to the Catalog e65d7f1 Refactoring how the Facter integration works 6b4e5f4 Reformatting tests for facts 54faf78 Moving fact and plugin handling into modules 9d76b70 Removing the Agent code that added client-side facts a5c2d7a Adding Puppet client facts to Facter facts. b99c6b5 Clarifying how node names are used during catalog compilation 8b44d6f Reformatting Indirector catalog compiler tests e770e7a Removing ConfigStore code that was never actually used. 37692e5 Renmaing Puppet::Network::Client::Master to Puppet::Agent 15d8768 Revert "Adding the first bits of an Agent class." 63fb514 Revert "This is work that I've decided not to keep" 8f5cbc3 This is work that I've decided not to keep so I'm just applying it here so it continues to show up in the history in case I ever want to look at it again. 25b28c5 Adding a new Agent::Downloader class for downloading files. 1afb821 Adding the first bits of an Agent class. 2afff60 Adding support for skipping cached indirection instances. 361db45 Change the way the tags and params are handled in rails 62cdeaa Add methods to return hash instead of objects to params and tags 3acea41 Rails serialization module to help serialize/unserialize some Puppet Objects 10bf151 Fixing #1913 - 'undef' resource values do not get copied to the db 500ea20 Fixing #1914 - 'undef' relationship metaparameters do not stack 1407865 Revert "Fixed #1916 - Added environment option to puppetd" 8d0086b Fixed #1916 - Added environment option to puppetd a065aeb Fixed #1910 - Updated logcheck regex fa9dc73 Typo fix 7c8094c Fixed #1879 - Added to tidy documentation f40a6b1 Fixed #1881 - Added md5lite explanation 6af3179 Fixed #1877 - Tidy type reference update for use of 0 a5b0a75 Fix autotest on win32 234a035 Fix #1560 fb8f8cd In order for ReST formatting to work properly, newlines and indentation of doc strings must be retained. 69432d6 Fix Bug #1629 1f6dce5 Fix #1835 : Add whitespace/quote parsing to 8142981 Fix #1847 - Force re-examination of all files to generate correct indices d2d3de5 Fix #1829 - Add puppet function versioncmp to compare versions bdee116 Fix #1828 - Scope.number? wasn't strict enough and could produce wrong results d69abfe Fix #1807 - make Puppet::Util::Package.versioncmp a module function 34335b7 Fixed #1840 - Bug fixes and improvements for Emacs puppet-mode.el 3b8a77d Fix #1834 part2 - Fix tests when no rails b6e34b7 Fix #1834 part1 - Fix tempfile failing tests 566bf78 Fixing #1729 - puppetmasterd can now read certs at startup 0cf9dec Canonicalizing Setting section names to symbols. 0fc0674 Fixing all of the test/ tests I broke in previous dev. e4ba3db Deprecating the Puppet::Type.create. b6db545 Deprecating 'Puppet.type'; replacing all instances with Puppet::Type.type 89c25ad Finishing the work to use Puppet::Resource instead of TransObject 1c7f8f6 Adding name/namevar abstraction to Puppet::Resource. e601bab Supporting a nil expirer on cacher objects. f69ac9f Setting resource defaults immediately. 352d7be Refactoring the Settings class to use Puppet::Resource 91ff7c1 TransObject is nearly deprecated now. fae3075 Simplifying the initialization interface for References 14c3c54 Replacing TransObject usage with Puppet::Resource 60062e4 Renaming the "Catalog#to_type" method to "Catalog#to_ral" 6b14000 Using Puppet::Resource to convert parser resources to RAL resources e3b1590 Adding resource convertion to the parser resources c306a17 Adding equality testing to Puppet::Resource::Reference 48a9949 Correcting whitespace and nested describes in Puppet::Resource::Catalog d48fff6 Renaming Puppet::Node::Catalog to Puppet::Resource::Catalog c927ce0 Renaming Puppet::ResourceReference to Puppet::Resource::Reference e88746b Adding Trans{Object,Bucket} backward compatibility to Puppet::Resource 832198f Starting on #1808 - Added a base resource class. 820ff2e Removing the "clear" from the macauthorization tests 89e9ef7 Fix #1483 - protect report terminus_class when testing for REST 435f1e9 Fix #1483 - use REST to transmit reports over the wire 6b30171 Fixing all broken tests. Most of them were broken by fileserving changes. f73e13e Adding more file tests and fixing conflicting tests cc12970 Completely refactoring the tidy type. 720dcbe Cleaning up the tidy type a bit 053d7bf These changes are all about making sure file data is expired when appropriate. a8d9976 Catalogs always consider resource data to be expired if not mid-transaction. 8b08439 Properly cleaning up ssl ca configuration during testing 73fa397 Adding caching support to parameters, and using cached attributes for file source and metadata. 0ecbf79 Adding cached attribute support to resources. 29b9794 Allowing a nil expirer for caching classes. cd09d6b Refactoring the Cacher interface to always require attribute declaration. 14af971 Changing the Cacher.invalidate method to Cacher.expire. 99a0770 Fixing a critical bug in the Cacher module. fe0b818 Fixing tests broken by fileserving and other refactoring. eed37f7 Fixing a test broken by previous refactoring 45c6382 Finishing the refactoring of the resource generation interface. 0840719 Refactoring and clarifying the resource generation methods. cc04646 Refactoring Catalog#add_resource to correctly handle implicit resources. a73cad9 Adding SimpleGraph#leaves, which I apparently did not migrate from PGraph 2a685f9 Removing mention of obsolete edgelist_class from GRATR. 7e20f06 Changing the catalog's relationship graph into a normal graph. 2ba0336 Removing the PGraph class and subsuming it into SimpleGraph. e92c1cc Moving Catalog#write_graph to SimpleGraph, where it belongs. 0149e2e Converting the file 'source' property to a parameter. 35c623e Removing mid-transaction resources from the catalog. f4800e8 Adding a method to Checksums to extract the sum type 44fadd1 Aliasing "must_not" just like we alias "must" a9dbb5d Deduplicating slashes in the fileserving code bb6619a Fixing the augeas type tests to work when augeas is missing e728873 Reducing the number of calls to terminus() to reduce interference with caching aa8d091 Switched all value management in props/params to internal classes. e5b5033 Fixing #1677 - fixing the selinux tests in master. 77d73e0 Changing the meaning of the unused Puppet::Type#parameter method to return an instance rather than a value. 05e1325 Moving a file purging test to rspec 6f7ccff Fixing #1641 - file recursion now only passes original parameters to child resources. a4d4444 Removing obsolete methods and tests: Removing obsolete handleignore method Removing obsolete FileSource class Removing a now-obsolete test/unit test Removing a now-obsolete recursive filebucket test b4f4866 Making it so (once again) files with sources set can still be deleted (which I think is kinda stupid, but apparently people want it). caf15c2 Fixing and migrating more file tests. cccd838 Adding a starting point for spec tests for tidy. 255c9fb Setting puppetmasterd up to serve all indirected classes. 7fdf2bb Retrieving the CA certificate before the client certificate. a00c1f2 Handling the case where a symbol (e.g., :ca) is used for a certificate name. cf3a11c Fixing :bindaddress setting to work with the new server subsystem. a78c971 Fixing CertificateRequest#save to accept arguments. e70c1a0 Fixing forward-compatibility issues resulting from no global resources 4596d2d Fixing a test I broke when fixing a reporting bug 9742c26 Fixing resource aliasing to not use global resource aliasing. I'm not really sure why the 0.24.x-style code got merged in, since master's changes should be more recent. 1b517d2 Adding comments to Puppet::Util::Cacher 7a6d9b1 Removing obselete code from the file type. 1b512a9 Merged fsweetser's selinux patch against HEAD e31df2f Removing files that git wasn't smart enough to remote during a merge. ac5db5e Removing the old, obsolete recursion methods. a9b7f08 As far as I can tell, recursion is working entirely. b69c50c Removing insanely stupid default property behaviour. 45f465b Source recursion is nearly working. 93fc113 Files now use the Indirector to recurse locally. bd1163a Fixing filesets to allow nil ignore values. 5da2606 Recursion using REST seems to almost work. ee1a85d Mostly finishing refactoring file recursion to use REST. 7c68fdb Fixing FileServing::Base so that it can recurse on a single file. ac41987 Fixing the terminus helper so it correctly catches options passed from clients via REST. be4c0e7 The file source is now refactored and uses REST. 44c6a52 Removing mention of an obselete class. 8271424 One third done refactoring file[:source] -- retrieve() is done. 98ac24a Adding a "source" attribute to fileserving instances. 6e43c2d Aliasing RSpec's :should method to :must. 8b45d13 Adding automatic attribute collection to the new fileserving code. 6ed8dfa Adding the content writer to the content class. 92e144b Fixing a test in the module_files terminus 151a54f Causing format selection to fail intelligently if no suitable format can be picked. deda646 Removing the last vestiges of the 'puppetmounts' protocol marker. 30dea68 Adding a 'plural?' method to the Indirection::Request class. 40e76fb Fixing the rest backends for webrick and mongrel so the get the whole request key. 8ea25ef Refactoring how files in FileServing are named. 550e3d6 Finishing the rename of FileBase => Base. 90e7022 Adding weights to network formats, and sorting them based on the weight. 5a195e0 Renaming FileServing::FileBase to FileServing::Base. 3101ea2 Adding a hackish raw format. 89a3738 Adding suitability as a requirement for a format being supported. a0bda85 Removing the yaml conversion code from FileContent. 6335b14 Causing the Indirection to fail if a terminus selection hook does not return a value. 1104edb Correcting whitespace in a test 2f224c9 Spell-correcting a comment bcd40fb Cleaning up an exception. 0a05720 FileServing Configurations now expect unqualified files. 237b7b2 Fixing whitespace in docs of some tests. 91b8252 Fixing the fileserving terminus selection hook. f5ba99f Special-casing 'file' URIs in the indirection requests. a215aba Dividing server/port configuration responsibility between the REST terminus and the indirection request. d174605 Fixing a test that relied on hash ordering. 7034882 Adding parameter and URL support to the REST terminus. c819042 Fixing the String format (fixes #1522). 78bc32d Removing dead-end file work as promised. a5ab52c Adding files temporarily, since I've decided this work is a dead-end. 4f275b6 Fixing #1514 - format tests now work again. 025edc5 puppetd now uses the Indirected SSL. 62202bf Adding 'require' statements as necessary for Puppet::SSL to work. 86a7188 Fixing the SSL::Host#waitforcert method. a31c578 Adding logging when files are removed. 09ee814 Removing now-obsolete the wait-for-cert module. cd314fa Documenting a bit of a test 113d74a Certificates now work over REST. 2cad30a Caching the SSL store for the SSL Host. 93fd55f Enhancing formatting errors with class and format. 6c80e0f Making all certificates only support the plaintext format. c464bf2 Adding wait_for_cert functionality to the ssl host class. c854dbe Adding a plaintext network format. 818599d lazy load latest package definitions with yumhelper 2.2 8457856 Fixing a group test that failed after merging 0.24.x c2c8941 Correctly handling when REST searches return nothing. 186f3cd Removing an obsolete method from the rest indirector 29d704c The REST formats are now fully functional, with yaml and marshal support. c55acee Adding some support for case insensivity in format names. 8033bd4 Moving validation from FormatHandler to Format. 3405841 Moving functionality out of the FormatHandler into the Format class. 43a6911 Searching again works over REST, including full content-type translation. 1064b5b Fixing the format_handler tests so that they clean up after themselves. 167831e Fixing a test I broke while rebasing e78b1a6 Fixing a test to be order-independent. 352e2d0 Adding rudimentary support for directly managing formats. 55e2944 Adding support for rendering and converting multiple instances. 4632cfd All error and format handling works over REST except searching. e3350ca Drastically simplifying the REST implementation tests. b3914c3 Removing an apparently-obsolete hook from the handler 739a871 Adding explicit tests for the HTTP::Handler module. 0ce92f1 The REST terminus now uses the content-type and http result codes. a4170ba Removing a now-obsolete pending test. bf5b086 The REST terminus now provides an Accept header with supported formats. 1f15725 Using the FormatHandler in indirected classes automatically. 0e7e16d Adding a FormatHandler module for managing format conversions. 93eeff5 Fixing the user ldap provider tests 00b7da3 Fixing the new-form version of #1382. c542dc0 Fixing #1168 for REST -- all ssl classes downcase their names. This is a much cleaner fix than the xmlrpc version, thankfully. :) eaa6eab Fixing #1258 -- Removing a Rails idiom. eb5e422 Fixing #1256 -- CA tests now work with no ~/.puppet. 66c36f0 Fixing another failing test -- the new CA tests correctly clear the cache. 447507c Fixing #1245 -- ssh_authorized_keys tests work in master. 6f533d1 Fixing #1247 -- no more clear_cache failures. 3cb0d60 Fixing how the mongrel server sets up xmlrpc handlers. 6efe400 Using the new Cacher class for handling cached data. 68d8d0a Adding a module for handling caching information. e936ef2 Fixing some broken tests. 1cfb021 The CRL is now automatically used or ignored. 0365184 Removing obsolete tests 3303590 The master and client now successfully speak xmlrpc using the new system. 8fd68e3 Adding pidfile management and daemonization to the Server class. dd4d868 Fixing the HttpPool module to get rid of an infinite loop. 57c7534 Adding REST terminuses for the SSL-related indirections. d78b4ba Adding autosigning to the new CA. a822ef9 Moving the CA Interface class to a separate file. 38e2dcf The master is now functionally serving REST and xmlrpc. 6e0d6dd The REST infrastructure now correctly the SSL certificates. 51ce674 Fixing the webrick integration tests to use the newly-functional SSL code. 62f1f5e The Certificate Authority now automatically creates a CRL when appropriate. e57436f The Settings class now clears the 'used' sections when a value is changed. 137e29f Moving some http configuration values to the main defaults section, rather than the puppetd section. a3b8804 The http pool manager now uses new-style certificate management. e596bc5 Fixing some tests that were insufficiently mocking their configurations. 160f9d9 Fixing a critical problem in how CRLs were saved and moving SSL Store responsibilities to the SSL::Host class. ce6d578 The SSL::Host class now uses the CA to generate its certificate when appropriate. 67dc268 The CA now initializes itself. 6356c04 Switched puppetmasterd to use the new-style server plumbing. 4c590df Adding xmlrpc backward compatibility to the new Mongrel code. 31b79fa Adding xmlrpc support to webrick. 7a876ed Fixing some whitespace 7267341 Adding configuration support for XMLRPC handlers. 8c9b04d I think I've now got the Webrick SSL support working. Now I just need to get xmlrpc working alongside REST in both mongrel and webrick. 83519f4 Interim commit, since I want to work but have no network available. 58fb416 Changing the File certificate terminus so that it saves to the :localcacert instead of :cacert. 79ca444 Renaming the 'ca_file' ssl terminus type to 'ca'. a116d10 Temporarily disabling the revoke/verify test in the CA. d87e018 Fixing how the CRL is used for certificate verification. 6c539c0 Fixing puppetca so it uses the :local ca setting. ebdbe48 Added an Interface class to the CA to model puppetca's usage. 934fbba Making the SSL::Host's destroy method a class method, rather than an instance method. d4813f1 Adding the last functionality needed for puppetca to use the Indirector. 809fc77 Finishing the interface between the CA and the CRL. 16056a2 Adding inventory support to the new certificate authority. d498c4a Adding support within the inventory for real certs or Puppet cert wrappers. 67f9d69 Changing the Inventory class to rebuild when the first cert is added, so it's easier to test. 7cca669 Adding a comment to the inventory class. 98db985 Adding an SSl::Inventory class for managing the ssl inventory. 92a7d76 All SSL terminus classes now force the CA information into the right place. fb56dea Switching the SSL::Host class to return Puppet instances. f7e0990 Setting the expiration date of certificate objects to the expiry of the actual cert. 71db9b5 Adding integration tests for a lot of the SSL code. e5c4687 Moving the password file handling into the SSL::Key class. d8bb81e Moving all of the ca-specific settings to the ca_file terminus classes, rather than the normal :file classes. cbe5221 Adding SSL::Host-level support for managing the terminus and cache classes. Also, defaulting to the :file terminus for all of the SSL classes. c5f0eff Fixing the CA so it actually automatically generates its certificate. 3d24b12 The certificate authority now uses a Host instance named 'ca'. daa8cd5 Changing all of the SSL terminus classes to treat CA files specially. 7d2c05e The 'destroy' method for the ssl_file terminus base class now returns false on missing files, rather than failing. 7555af6 Marking a test as pending, because it's not ready yet. c19c9d4 Removing all the cases where the ssl host specifies a terminus. Also, getting rid of some metaprogramming that wasn't really helping. 054e4e4 Making the first pass at using requests instead of specifying the terminus class. The individual ssl classes now work, but the ssl host class doesn't yet. 6900f97 Adding a :to_text method that will convert the contained thing to readable human text. 174b9c9 Actually signing the certificates in the CA. 546ac97 Adding the first attempt at managing the certificate revocation list. c98ad25 Adding a :search method to the ssl_file terminus type and the SSL::Host class. d184b35 Fixing a failing test that had not been updated from previous coding b9d6479 We have a basically functional CA -- it can sign requests and return certificates. There's still plenty more work to do, but I'm probably not much more than a day away from redoing puppetca to use this code. 1efed03 Adding tests for the easy bits of the CertificateFactory. I probably am going to skip the tests for the rest, since the code is unlikely to ever change, and it's going to be a royal pain to test. ee07d0b Adding tests for the certificate serial numbers dc5c73b The certificate authority is now functional and tested. a776a12 refactoring the cert request test a bit 7641bd4 This is a first pass at the certificate authority. The tests are basically entirely absent still, but the structure is all there. 0f46815 It looks like all of the new ssl classes for managing keys, certificates, and requests now work, including talking to the certificate authority. Now we just need the authority itself, along with the necessary REST terminii. 00e35bc Adding he last of the indirection classes for the ssl classes, finally including the certificate requests. 8347b06 The certificate and key are now correctly interacting with the existing cert/key store. Certificate requests are not yet handled, nor are the ca-specific collections. 50f3c18 Removing obsolete indirection classes ec5bdf3 The basics for the certificate and certificate request indirection terminii are done. I need to move most of the test code to a shared behaviour now. bb87464 Fixing a couple of broken tests. b0811ad The new SSL classes basically work, but they're not functionally connected to any kind of indirection. 3970818 Finished the certificate request wrapper class. 4ca6fd3 First stage of cert refactoring: Private keys kind of work. ef7d914 Oops; final fix on the integration test failures resulting from my partial support for ssl in webrick. 0ca0ef6 Fixing whitespace problems. 4640a3d Fixing an integration test of the rest terminus; it was broken by my incomplete cert support in webrick. I just stubbed out the cert usage for now; once all the cert stuff is done we'll need to go back and unstub it. d738f31 Adding the necessary tests for webrick to have logging and ssl. The tests can't be completed until the certificate work is all done. b49fb68 Fixing the tests in test/ that were broken as a result of the move to no global resources. 5e78151 Fixing tests that were failing as a result of the merge, including removing some now-obsolete code and tests from the Settings class. bee9aba Environments are now available as variables in manifests, and specs can be directly executed again. b225e86 Fixing #1017 -- environment-specific modulepath is no longer ignored. 4ede432 Tidied the man page creation function and created "master" branch man pages f335dc3 Updated defaults.rb to fix foru error stopping man page creation - links are not as neat as before but puppet.conf.man file will create neatly now. c751058 Removed remaining elements of old_parse - closing Ticket #990 31e0850 Removed old configuration file behaviour and deprecation warning - closes ticket #990 4165eda More fixes to the testing. cfda651 Another round of test-fixes toward eliminating global resource references. This should have gotten rid of all of them, and now it's just a question of fixing a few hopefully unrelated failing tests. 488c437 Fixing automatic relationships. I was previously looking them up in the relationship graph, which only stores the vertices, not the resource table. d8991ab Updated install.rb to product puppet.conf.man page - updating ticket #198 5a0388f Disabled new man page creation support e5888af Added support for man page creation - requires rst2man.py and writer - closed ticket #198 5bef4a5 Another round of fixes toward making global resources work. 3cc3e0f Lots o' bug-fixes toward getting rid of global resources. We still have about 60 failing tests, but some of them are the failing directory service tests (probably 20 or so), and most are simple fixes to the tests themselves. b7b11bd Fixing a couple of failing tests aed51b4 Fixed puppet logcheck issues 7aa79e2 Revert "Fixed documentation for code option in defaults.rb" f2991a2 Revert "Fixed indentation error in pkgdmg.rb documentation" 754129e Revert "Fixed issue where permissions are incorrectly set on Debian for /var/puppet/run directory" 20628ea Added patch to ext/logcheck/puppet to fix ticket #978 badf977 Fixed indentation error in pkgdmg.rb documentation e6547f0 Fixed documentation for code option in defaults.rb 594a5a3 Fixed issue where permissions are incorrectly set on Debian for /var/puppet/run directory 9736b3c Updated for 0.24.0 99f9047 tweaking spec language; require Puppet::Network::HTTP class since it is referenced by Puppet::Network::Server b38f538 Moving $PUPPET/spec/lib/autotest up to $PUPPET/autotest as something has changed and it can't be found otherwise. e1abfac moving autotest directory to make it possible to run autotest again 0.24.9 ====== 0dee418 Fixed typo in util.rb df33cb0 Updated CHANGELOG a22a088 Updated version to 0.24.9 0aae57f Backport of tmpfile patch from 0.25.2 9a26421 Brought in lutters parse_commands patch and integrated it into the type. This includes reworking the get and match commands as well. This change introduces a few small changes. These are: 916dd60 Fixed rspec gem at version 1.2.2 57b37e5 Add @options to test run call, for compatibility with more recent rspec versions. 0863a79 Adding #2122 - you can specify the node to test with puppet-test a43137c More RST fixes 843cc6e Fixed RST for functions 6160aaf In order for ReST formatting to work properly, newlines and indentation of doc strings must be retained. d125937 Added rake ci:all task c62c193 Updated to version 0.24.8 aa00bde Fixing #1631 - adding /sbin and /usr/sbin to PATH 39deaf3 Fixed #2004 - ssh_authorized_key fails if no target is defined dcf2bf2 Changelog entries for #1629 and #2004 bbcda1d Fix Bug #1629 69a0f7d Fix #1807 - make Puppet::Util::Package.versioncmp a module function 081021a Fix #1829 - Add puppet function versioncmp to compare versions 2b33f80 Fixed install.rb typo 5ab63cd Updated lib install permissions to 0644 0.24.8 ====== 02a503f Updated to version 0.24.8 cbc46de Fixing #1631 - adding /sbin and /usr/sbin to PATH 9eb377a Fixed #2004 - ssh_authorized_key fails if no target is defined 1b3fe82 Changelog entries for #1629 and #2004 8a671e5 Fix Bug #1629 ff5b13a Fix #1807 - make Puppet::Util::Package.versioncmp a module function 991f82c Fix #1829 - Add puppet function versioncmp to compare versions d0bf26e Fixed install.rb typo 4cf7a89 Updated lib install permissions to 0644 2c7e189 Fixes incorrect detail variable in OS X version check, re-patches ralsh to work with Facter values and adds error check for missing password hash files. 73a0757 Fix #1828 - Scope.number? wasn't strict enough and could produce wrong results 0.24.8rc1 ========= 84d6637 Fixed #2000 - No default specified for checksum a3bb201 Fixing change printing when list properties are absent 67fc394 Fixed #2026 - Red Hat ignoring stop method cf64827 Bring in the documentation changes from the master branch 01bc88c Added a force option to ensure the change is always applied, and call augeas twice to reduce the chance that data is lost cedeb79 Backport the fix for #1835 cf48ec0 First cut at the not running if augeas does not change any of the underlieing files 9d36b58 Bug 1948: Added patch by jab to support the correct ins syntax. Updated the test cases as well 61661b1 Fixing #1991 - ldap booleans get converted to booleans d5850dc Refactored a method: extracted about five other methods 1c7c8fe dbfix - fix typo and close another possible inconsistency c55ac3f Fix #2010 - add protection code for some storeconfig corruption a790ee3 Further fix to #1910 9577d3a Fixing #2013 - prefetching had a mismatch between type and title 719a8df Fixed to rake tests for reductivelabs build ac87600 Fixed report reference page 0c16426 Fixing broken 0.24.x tests in test/. 23066c1 Fixing every failing test I can find on the build server. ec56ddf This script fixes the most common issues with inconsistent storeconfigs database (including duplicate resources record, duplicate param_values records, dangling records...). c052ff8 Make puppetd --waitforcert option behave as documented: e2b4062 Adding a performance optimization to the FileCollection. fa6494b Using the FileCollection where appropriate. 373d505 Adding a FileCollection and a lookup module for it. 0e46786 Fixed #1963 - Failing to read /proc/mounts for selinux kills file downloads 4170238 Fixed #2025 - gentoo service provider handle only default init level 8c010e0 Fixed #1910 - updated logcheck 7504b04 Updated useradd.rb managehome confine to include other RH-like distributions f07d928 Use Puppet.debug instead of own debug flag 25a3f59 Fixing #558 - File checksums no longer refer to 'nosum' d758f45 Fixing #1871 once and for all - contents are never printed c0f4943 Minor fix to launchd tests 24d48e6 Fix #1972 - ActiveRecord fixes resulted in broken tests 446989b Fix spec test for launchd service provider to work with new service status method and add two new status tests. 3ef5849 Fixing a test I broke in commit:"897539e857b0da9145f15648b6aa2ef124ec1a19". 72bd378 Removing a no-longer-valid test. 682dd8b Fixing password validation to support symbols. 44f97aa Only backing up within parsedfile when managing files 04af7b4 Fixing a syntax error in the up2date provider 1070b3c Fixing a test broken by a log demotion ab84756 Cleaned up variable names to be more sane, clarified error messages and fixed incorrect use of 'value' variable rather than 'member'. 7f41857 Provide dscl -url output support for OS X 10.4 clients using the directoryservice provider. 0bc3c07 Fix launchd service provider so it is backwards compatible with OS X 10.4 as well 2561c8e Updated Augeas type code 7d72186 Removed site from Puppet VIM syntax 1bc7404 Fixed #1831 - Added sprintf function 336b645 Fixed #1830 - Added regsubst function 2a85551 Bug 1948: Add logic and testing for the command parsing logic 2218611 Updated up2date and service confines to add support for Oracle EL and VM 39a8b28 Fixing #1964 - Facts get loaded from plugins 7cf085c Adding tests for Puppet::Indirector::Facts::Facter.loadfacts 70ea39a Adding a post-processor for Nagios names. 4dfa034 Revert "Refixing #1420 - _naginator_name is only used for services" d5a193a Fixing #1541 - ParsedFile only backs up files once per transaction 53f15b9 Removing the apparently obsolete netinfo filetype. 4e89156 Migrated FileType tests to spec, and fleshed them out a bit. cc4d658 Bug #1948: Added patch by jab to support the correct ins syntax. Updated the test cases as well 5e35166 Fixing #961 - closing the http connection after every xmlrpc call af3f3ae Refactoring the XMLRPC::Client error-handling f0ac3ae Fixed #1959 - Added column protection for environment schema migration 319822a Fixing #1869 - autoloaded files should never leak exceptions 6b0c1b9 Fixing #1543 - Nagios parse errors no longer kill Puppet 7fd5c7e Moving the transaction specs to the right path efb5cc5 Refixing #1420 - _naginator_name is only used for services 32c2be9 Fixed #1884 - exported defines are collected by the exporting host 0e49159 Cleaning up the AST::Resource code a bit b22d148 Fix #1691 - Realize fails with array of Resource References 6331bfc Fix #1682 - Resource titles are not flattened as they should 7e036eb Fix #1922 - Functions squash all arguments into a single hash 535fa89 Fixed #1538 - Yumrepo sets permissions wrongly on files in /etc/yum.repos.d f7b04df Fixed #1936 - Added /* */ support to the vim file 671d73c Prefetching, and thus purging, Nagios resources now works *only* if you use the default configuration file locations. 063871f Adding some basic tests for the Naginator provider base class 897539e Removing a redundant instance prefect call. 012efe3 Fixing #1912 - gid still works with no 'should' value. a9f34af Fixing the Rakefile to use 'git format-patch'. db05c00 Fixing #1920 - user passwords no longer allow ':' aa219e7 Adding README.rst file 1d3f117 Added Reductive Labs build library f01882d Change the way the tags and params are handled in rails b7ab54c Add methods to return hash instead of objects to params and tags 5c64435 Rails serialization module to help serialize/unserialize some Puppet Objects b27fccd Fixed #1852 - Correct behaviour when no SELinux bindings 7403330 Updated Red Hat spec file 0.24.7 0.24.7rc1 ========= 84d6637 Fixed #2000 - No default specified for checksum a3bb201 Fixing change printing when list properties are absent 67fc394 Fixed #2026 - Red Hat ignoring stop method cf64827 Bring in the documentation changes from the master branch 01bc88c Added a force option to ensure the change is always applied, and call augeas twice to reduce the chance that data is lost cedeb79 Backport the fix for #1835 cf48ec0 First cut at the not running if augeas does not change any of the underlieing files 9d36b58 Bug 1948: Added patch by jab to support the correct ins syntax. Updated the test cases as well 61661b1 Fixing #1991 - ldap booleans get converted to booleans d5850dc Refactored a method: extracted about five other methods 1c7c8fe dbfix - fix typo and close another possible inconsistency c55ac3f Fix #2010 - add protection code for some storeconfig corruption a790ee3 Further fix to #1910 9577d3a Fixing #2013 - prefetching had a mismatch between type and title 719a8df Fixed to rake tests for reductivelabs build ac87600 Fixed report reference page 0c16426 Fixing broken 0.24.x tests in test/. 23066c1 Fixing every failing test I can find on the build server. ec56ddf This script fixes the most common issues with inconsistent storeconfigs database (including duplicate resources record, duplicate param_values records, dangling records...). c052ff8 Make puppetd --waitforcert option behave as documented: e2b4062 Adding a performance optimization to the FileCollection. fa6494b Using the FileCollection where appropriate. 373d505 Adding a FileCollection and a lookup module for it. 0e46786 Fixed #1963 - Failing to read /proc/mounts for selinux kills file downloads 4170238 Fixed #2025 - gentoo service provider handle only default init level 8c010e0 Fixed #1910 - updated logcheck 7504b04 Updated useradd.rb managehome confine to include other RH-like distributions f07d928 Use Puppet.debug instead of own debug flag 25a3f59 Fixing #558 - File checksums no longer refer to 'nosum' d758f45 Fixing #1871 once and for all - contents are never printed c0f4943 Minor fix to launchd tests 24d48e6 Fix #1972 - ActiveRecord fixes resulted in broken tests 446989b Fix spec test for launchd service provider to work with new service status method and add two new status tests. 3ef5849 Fixing a test I broke in commit:"897539e857b0da9145f15648b6aa2ef124ec1a19". 72bd378 Removing a no-longer-valid test. 682dd8b Fixing password validation to support symbols. 44f97aa Only backing up within parsedfile when managing files 04af7b4 Fixing a syntax error in the up2date provider 1070b3c Fixing a test broken by a log demotion ab84756 Cleaned up variable names to be more sane, clarified error messages and fixed incorrect use of 'value' variable rather than 'member'. 7f41857 Provide dscl -url output support for OS X 10.4 clients using the directoryservice provider. 0bc3c07 Fix launchd service provider so it is backwards compatible with OS X 10.4 as well 2561c8e Updated Augeas type code 7d72186 Removed site from Puppet VIM syntax 1bc7404 Fixed #1831 - Added sprintf function 336b645 Fixed #1830 - Added regsubst function 2a85551 Bug 1948: Add logic and testing for the command parsing logic 2218611 Updated up2date and service confines to add support for Oracle EL and VM 39a8b28 Fixing #1964 - Facts get loaded from plugins 7cf085c Adding tests for Puppet::Indirector::Facts::Facter.loadfacts 70ea39a Adding a post-processor for Nagios names. 4dfa034 Revert "Refixing #1420 - _naginator_name is only used for services" d5a193a Fixing #1541 - ParsedFile only backs up files once per transaction 53f15b9 Removing the apparently obsolete netinfo filetype. 4e89156 Migrated FileType tests to spec, and fleshed them out a bit. cc4d658 Bug #1948: Added patch by jab to support the correct ins syntax. Updated the test cases as well 5e35166 Fixing #961 - closing the http connection after every xmlrpc call af3f3ae Refactoring the XMLRPC::Client error-handling f0ac3ae Fixed #1959 - Added column protection for environment schema migration 319822a Fixing #1869 - autoloaded files should never leak exceptions 6b0c1b9 Fixing #1543 - Nagios parse errors no longer kill Puppet 7fd5c7e Moving the transaction specs to the right path efb5cc5 Refixing #1420 - _naginator_name is only used for services 32c2be9 Fixed #1884 - exported defines are collected by the exporting host 0e49159 Cleaning up the AST::Resource code a bit b22d148 Fix #1691 - Realize fails with array of Resource References 6331bfc Fix #1682 - Resource titles are not flattened as they should 7e036eb Fix #1922 - Functions squash all arguments into a single hash 535fa89 Fixed #1538 - Yumrepo sets permissions wrongly on files in /etc/yum.repos.d f7b04df Fixed #1936 - Added /* */ support to the vim file 671d73c Prefetching, and thus purging, Nagios resources now works *only* if you use the default configuration file locations. 063871f Adding some basic tests for the Naginator provider base class 897539e Removing a redundant instance prefect call. 012efe3 Fixing #1912 - gid still works with no 'should' value. a9f34af Fixing the Rakefile to use 'git format-patch'. db05c00 Fixing #1920 - user passwords no longer allow ':' aa219e7 Adding README.rst file 1d3f117 Added Reductive Labs build library f01882d Change the way the tags and params are handled in rails b7ab54c Add methods to return hash instead of objects to params and tags 5c64435 Rails serialization module to help serialize/unserialize some Puppet Objects b27fccd Fixed #1852 - Correct behaviour when no SELinux bindings 7403330 Updated Red Hat spec file 0.24.7 8befc18 Updated to version 0.24.7 cf19bd8 Not using a temporary file when locking files for writing. b966ea0 Modifying the corruption-checking test. 1f34bca Issue 1804 VDev with the same devices should be in sync 6d5a129 Documentation fixes 45144a1 Fixing #1812 (hopefully) - adding read and write locks to yaml. 2385a78 Preparing to fix #1812 - Moving locking code to a module 2961b83 Fix #1815 - puppetdoc --all crash on resource override e5c36fd Fix ZFS autorequire test da71ad5 Add a unique name to objects so we can determine uniqueness when read back in 4418b34 Fix launchd service test on non-OSX platforms 4b2bdf9 Fix the spec tests to work on other platforms, do the confine around OS X versions more sanely 544a3e1 remove unnecessary mk_resource_methods call 50ac03a CHANGELOG updates a0a6d2c Add a unique name to objects so we can determine uniqueness when read back in 68ffd46 Bug #1803 Zfs should auto require the ancestor file systems 7e2da7e Refactor #1802 Use 'zfs get -H -o value' instead of parsing output for value 8616d74 Fixing #1800 - tidy now correctly ignores missing files and directories 6075d10 Fixing #1794 - returning sync when it is already initialized 18fe5c3 Fixing #1750 again - All of the properties and now :ensure check replace? b22303e Fix rake abort when there is a matching confine 0caa9c5 spec tests for type and provider and some code cleanup to adhere to DRY 0f2fc88 Finished work on rules creation and deletion ed49153 new better way of doing stdin 05e05bb finished rights flush, working on rules 1e37230 macauthorization type 4ed73ef reset macauthorization tree. Initial checkin of new type/provider 5d32cd9 add NetInfo deprecation notice to user and group providers, make the directoryservice user provider the default, remove default for darwin from NetInfo providers 99ab940 Warn that the NetInfo nameservice provider is deprecated. Use directoryservice instead c4412ec add some more sanity checks around stdin 7de82c3 add support for stdin to Puppet::Util.execute edef064 Make ralsh behave more sanely for non-existent objects and property values 9384a4a Added git changelog task c398db1 Bug #1780 Fixing meaningless test 278bfe8 Fixing mcx test failures (only happened sometimes). c4812b8 Need to stub out the defaultprovider call for non Mac platforms b444e43 remove extraneous comments 49d4d01 Trim down the after block clears to try to make the tests work for the build servers 65d6b49 Updated mcx type and provider with comprehensive spec tests. fd128d6 Fixing a package test to be *much* faster cdcbc5b Fixing splaytime tests 6a4c0d5 Removing debugging from the "resources" type 0c6a151 Fixing a test that fails depending on test execution order 968f5cc Relicense under GPLv2+ 9ab3afb Hopefully fixing #1703 - using a mutex around the sending of the tagmails 3fe9cc7 Fix #1741 - fix some failing tests on some ruby versions. 3570c71 Fix #1788 - allow rspec rake to run only some tests 1b3a7d8 Fixing the AST constant warnings, using a variable instead of a constant 091b8bf Fixing #1785 - selinux tests no longer break other tests c005dcf Ticket 1780 - Solaris RBAC roles should be autorequired 3eff225 Feature 1696 Add support for branded zones fa9820b Bug #1778 - Solaris RBAC profiles should maintain order f6fa4f7 Bug # 1680 Now you can set the hashed passwords on solaris 0a40668 Feature #1783 - Add ZFS support 047e5d0 Handle password when user is created 88edf66 == is not = a219c88 Solaris doesn't have a native tool to set hashed passwords 9329c95 type/mcx.rb Feature #1026 - MCX Type 83b3a1e Simplify launchd service provider and add tests 65a6074 Fixed #1695 - Solaris 10 zone provider doesn't properly handle unknown zone attributes in newer releases 0171e25 Fixing #1749 - Splay now hopefully behaves "better" for small values. 607958c Fix #1741 - Add inline_template function cc45c43 Fix #1741 - refactor TemplateWrapper, test for template function d8c741f Fix #1741 - Puppet::Parser::Functions rmfunctions and unit test 3c4efa7 Fixes #1773 - no longer check for absolute paths 3a39509 make sure only types that have passwords search for the password a45c6b1 fix bug with numeric uid/gid in directoryservice provider. doc string cleanups 1f52795 Documentation fix for runit provider 81a91a7 Documentation fix for daemontools provider 4f67a7c Fixed #1776 - Trivial fix for gentoo service provider 2764ab4 Rename migration so it's still applied 965c08d Slight denormalisation to store a host's environment as a first class object in the database Fixes: #1392 5742966 Fixing #1743 - defined types get catalogs too. 31ec3e6 Adjusted CI tasks exit codes 3421954 Fixing #1755 - handling fully qualified classes correctly. a1ac9a5 Added Rake :ci namespace and CI tasks d978668 Lots of DirectoryService work. New Computer Type. Users now use password hashes. Groups now support setting members as attributes of the group for OS X. 86ce934 launchd service provider 97a8177 Refactoring the thread-safety in Puppet::Util a bit. 78bced1 Fixing #1683 - accessing and changing settings is now thread-safe. 83cebb5 Partially fixing #1772 - fixing selinux tests broken by removal of extraneous 'stat' in :file. a839fe2 Partially fixing #1772 - fixing tidy code I broke. 5bd27c8 Partially fixing #1772 - broken 'resources' tests. a3140b2 Manually setting an env var to mark autotest enabled so we see color bbad983 Removing the included testing gems; you must now install them yourself. b415848 Fixing #1708 - user groups specified as names are now detected correctly. 9ed382d Fixed #1767 - Minor fix to emacs mode 27a750d Revert "Fixing #1755 - File modes (and other strange properties) will now display correctly" eb0d32a Fixing #1764 - a property's 'sync' method is never considered a no-op. e9f858a Refactoring the file/owner property to be simpler and cleaner. ed4c405 Fixing #1755 - File modes (and other strange properties) will now display correctly in ralsh and generated manifests. c65f2b5 Fixed #1668 - puppetca can't clean unsigned certs 1ad33cc Fix #1759 - Comparison operator was using string comparison for numbers c96d250 Fixed #1711 - fileserver test fails due to incorrect mocking 8523a48 Fixed #1751 - Mac OS X DirectoryService nameservice provider support for plist output and password hash fil d32d7f3 Fixed #1752 - Add an optional argument to Puppet::Util.execute to determine whether stderr and stdout are combined in the output 4396740 Fix the init service type to cope with an array for defpath and if defpath does not exist 3c870d8 Added versionable feature to the RPM provider f62d04d Fixing broken tests resulting from the fix to #1747 030c791 Moved RRD feature from util/metric.rb to feature/base.rb dc192b0 Manifest documentation generation 2c05a0a Move function existance test to parser evaluation 064fb00 Add a doc attribute to AST nodes and fill it with the last seen comments 724a6f6 RSpec tests for the doc system (covers AST.doc, lexer and parser) b8ed667 Fixed #1735 and #1747 - Fixes to confine system 6be5ac8 CHANGELOG updates 0ca5025 Fixed #1718 - Added preseed to apt uninstall and purge 01976ca Include spec directory in packages c98f7a5 Fixing the provider's confine subsystem so the logs are more useful. 6426a29 Removed extra 'end' from yum.rb 1e81739 Fix bug #1746: Sync SELinux file attributes after file contents created/modified cebadd9 Fix bug #1681: Add filesystem type check to test for per-file SELinux context support 60455e7 Quiet debug when no default SELinux context found for one of the components 71a9e60 Fixes relating to transition to native SELinux bindings 3a5dcab Refactoring of SELinux functions to use native Ruby SELinux interface d5e19f1 Fixed #1739 - Added uninstall functionality to yum provider bf5be00 Fix #1737 - part2 - Fix display of "options" e032034 Fix #1737 - ssh_authorized_keys should be able to parse options containing commas e33d087 Fix #1740 - Daemontools and Runit is not ReST compliant dfc0554 Fixed #1730 - Edited file/ensure.rb docs for clarity 6d7b5ef Fixes #1672 - unsafe crontab handling in Solaris Signed-off-by: Martin Englund 083077d Fixing the augeas type tests to work when augeas is missing 0a3d34d Fixes #1714 - yumhelper handling with yum 2.2.x is broken 7b70e85 Fixed #1721 - puppet.conf documentation incorrectly lists signals that affect the daemons 781a685 Fixing a test I broke when fixing a reporting bug f063517 Added unit tests for the augeas type and provider 2d37f09 Fix #1402 - Allow multiline comments 9f30306 Fix #857 - Multiple class of the same name don't append code 649a9e0 Fixed augeas examples in type 56f3be6 Fixed #1710 - Spurious output in test run 4806c51 Fixing #1669 - The dump parameter can now be changed on mounts. c7ccc4b Fix #1682 - ASTArray should flatten product of evaluation of its children c906afd Fixing #1667 - regex automatic value documentation is now readable. 9fd1756 Split Augeas up into a provider and a type. e542f8c Fixed #1692 - k5login fails to set mode when file is created 57e791b Fixing #1660 - Adding specifically supported values for tidy recursion. 42cac73 Fixing #1698 - all logs again show up in the report. 6ab4f1b Fixed #1661 - Type reference: tidy should specify manditory parameters 2459106 Removing all mention of EPM, RPM, or Sun packages. 9ecbd63 Fixed #1104 - Classes and nodes should set $name variables bc8cdb1 Beginning provider split, need help on the voodoo 6539f55 Updated Red Hat spec file for 0.24.6 and removed conf/debian directory. cacafeb Added augeas type and feature 0.24.6 ====== b2c1149 Updated to version 0.24.6 5ba54d2 Updated to version 0.24.6 22024bc Improve the inline documentation for SELinux types and parameters f216237 Fixes #1663 - added Symbol check and additional test 81c3b72 Fix SELinux test to succeed when Puppet debug mode is enabled f7516a7 Fix regression caused by switch to Puppet's execute() functions c09d0cc Solaris RBAC Attributes 6d05cbc Fix #936 - Allow trailing comma in array definition ec2b461 Fix #1115 - part2 - fix tests and add all_tags 356d8ca Fixed #1662 - Configuration Reference still references 'section' b53509b Fixed #1460 - enhance redhat puppetmaster init.d script to easy start puppetmaster as a mongrel cluster 8a4e2e9 Fixed #1663 - Regression relating to facter fact naming from 0.24.5 e6f99f9 Fix #636 - Allow extraneous comma in function argument list a74ec60 Fixing tests I broke when trying to fix the Providers reference. d4df361 Use fully qualified paths when calling binaries, adjust chcon call to use Puppet's execute() function. dedf0cd Setting SELinux contexts with chcon should not dereference symbolic links 7f5ded1 Fixed #1646 - service puppet status does not work as non-root on redhat system 00d5fe4 Fix #1115 - Allow checking tags/classes from ERb templates f5fb2d3 Fixed #1649 - OS X package creation script should be more selective about cleaning out prior versions b0fd2e0 Fixing #1647 - puppetdoc's 'providers' report works again. 157c0dd Fix 1642 (always warning) and improve unit tests to cover when to warn and not 65eafb7 lazy load latest package definitions with yumhelper 2.2 eff6ce0 Revert "Added last part of #1633 patch - update to util/metrics.rb" c5d1a4f Added last part of #1633 patch - update to util/metrics.rb 0fff7d7 Fixing some tests that were broken in 2fba85af 2afbd0d Fixing a test that was failing as a result of the fix to #1491 b0c01da Adding an additional option for the fix in ff36832e, skipping missing cert dirs aea5582 Removing a gid test for users, since it is a bad test and has mostly been replaced in rspec 65d3040 Fixing a test that was broken in ee579641 b08002e Fixing some tests that were broken in the fix for #1633 2bf0ba5 Fixing a test that was failing because i-have-no-idea 952ebb8 Fixing a test that was failing because of the change to retrieve() in ee579641 a5fe87f Fixing a file source test that was failing because missing sources is now a failure 53b7d42 Fixing the broken tests resulting from the fix for #1551. 5ec6b07 Adding warnings when example groups are skipped. 54abe70 Moving some test/ package tests to rspec integration tests and disabling a gem test that hangs forever for me. 85d3ae0 Cleanup selboolean and selmodule unit tests to pass on non-SELinux systems a562ce5 Add unit test coverage for Puppet::Util::SELinux and fix problems found by tests 2b4aa0c Fixed #1639 - uninitialized constant Puppet::Type::User::ProviderUseradd 4265825 Fix #1636 - part2 - correct some client errors. 9c31db9 Add failing test for plugin with file and recurse 2853447 Fix several small regressions in plugins mount 2153bae Fixing #1640 - file groups now no longer get set on every run (this was a regression caused by other work I did). 80e5c11 Incremented CHANGELOG to 0.24.6 996ac46 Fix scenario when SELinux support tools exist, but SELinux is disabled d803096 Add new set of unit tests for selmodule type a3f34f9 Removal of redundant lines from unit test 307260f Remove old selboolean unit tests and fix permissions on new tests 2ebd34e Rewrote seboolean unit tests to provide better coverage 4df51ea New and improved tests for file type SELinux contexts 253d4df Fix regression when templatedir doesn't exist. c7a6ef2 Fix #1202 - Collection attribute matching doesn't parse arrays 3281f2b Fixed #1633 - Added support for --detailed-exits to bin/puppet which causes puppet to produce different exit codes depending on whether there were changes or failures in the transaction. 0b1e60f Adding an array indexer method to Puppet::Util::Metric as requested in #1633. 765db30 Adding partial spec tests for Puppet::Util::Metric. fb14e91 Fixed #1473 - Rescue Timeout::Error in xmlrpc clients 7275d7c Fxied #1354 - yum provider problems with RHEL 3 0c297be Fix #1109 - allow empty if or else branches 5268487 Fixed documentation, typo and added CHANGELOG entry 990e8e3 Fix #1530: Correctly parse ssh type 1 keys 06edac4 Fixed additional environments tests 79bb1f2 Rspec Tests for #381. Moved part of the old resource reference tests to rspec. 750e9ab Fix #381 - Allow multiple resource overrides or references 782181e Minor test fix for #1614 614326a Fixing #1098 - Multiline strings now correctly increment the line count 1c6d57e Doing some simple refactorings on Puppet::Log a774443 Fixing #1089 - Log messages are now tagged with the log level, making it easier to match messages in the 'tagmail' report. db7f108 Adding rspec tests for the Puppet::Util::Log class. d2c8998 Fixed #981 - Removed 'Adding aliases' info message d098a90 Fix failing tests dependent on /etc/user_attr file existing 6bcfd9f Fixing #947 - pluginsync no longer fails poorly when no plugins exist 67136f1 Fixing the Node class to no longer validate environments since #1614 removed that validation. a4110a3 Add SELinux context reset after file writes in Puppet::Util::FileType 250239e Add new support for :selrange SELinux file property c831482 Add detected defaults for existing SELinux file properties 772e9b2 Refactor SELinux commands to utility module 8153181 Clean up of SELinux rspec tests so all pass e77ddc1 Merged fsweetser's selinux patch against HEAD 7272d49 Fixed #1613 - The client environment will be substituted when looking up settings. 1a9b567 Fixing #1614 - Environments no longer have to be listed out. 397c841 Fixed #1628 - Changed node search to use certname rather than Facter hostname 9d174c4 Updated puppet binary documentation 6a0b334 Fixed error message typo 655f378 Adding a rake task for sending emails to the dev list d39bab9 Fixing package provider tests to use the new Transaction::Change interface e32256a Migrating the apt and dpkg tests to rspec. ddda80a Update change log with RBAC roles d1abb86 Add role support to user type and an implemention 2fba85a Some small clarifying refactors and change to objectadd to allow subclasses of with a uid not need to be a single class us use modify 4a863c3 Adding user_attr util to parse attributes on solaris 93f952a Fixed #1586 - Specifying "fully qualified" package names in Gentoo 8620775 Fixed #791 - You should now be able to create and find a user/group in one transaction. 63ad845 Refactoring and adding tests to the file group property. 7da4152 Modified the group and zone resource types to no longer call 'currentpropvalues' as a means of setting all values to absent. There should be no behaviour change from this change. ee57964 Modified the behaviour of resource-level 'retrieve' -- it only calls 'retrieve' on each property if the resource exists. 0fb4693 Updating changelog for #1622 2afc4f5 Adding tests for the user retrieve method 679fede Removing commented code from the user type from about 2005 2480654 The Netinfo and DirectoryService providers can now create user and group simultaneously. 4c998fe Fixing #1622 - The user type only looks up groups when necessary. 6bc56ae Aliasing the rspec 'should' method to 'must' so it does not conflict with the RAL 'should' method. b9c75cd Rewriting the user tests, in preparation for enhancing them 99de920 Fixed #1620 - Add 'sles' to Puppet confines when 'suse' is used 4cf9710 Add parser for arbitrary expressions cfa230a Add arithmetic operators to AST 850e0ba Add not operator to AST 9cdecfe Add comparison operators (< > == != <= >=) to AST 8372dc4 Add boolean operators to AST e6698c2 Add warning and forcibly set to :md5 fixing #1564 af8c706 Fix metadata class for cases when checksum_type set 860bdb1 Fixed #1603 - Added support for running Puppet inside a Rack application b2f0d87 Fix ticket 1596 in new fileset code, use tmpdir in fileserver tests. a30ecf2 Make fileserver use fileset for recursion and handle dangling links by ignoring them fixing #1544 3b80763 Add tests for FileServer::Mount list for #1544 3749267 Fixed #1610 - Raise "Filebucketed" messages to Notice priority f792b64 Added a number of confines to package providers 074abd4 Fixed #1609 - Added confines for the Gentoo, FreeBSD and SMF (Solaris) service providers 2da6d19 Fixed #1608 - Added ubuntu to defaultfor for apt provider aa629ec Fixed #1607 - Added ubuntu to defaultfor for Debian service provider 774c0f9 Fixed #1588 - Fixed puppetca --clean --all 98e79f8 Fixed #1472 -- defined, exported resources in the current compile now get expanded correctly. 0040bc8 Fixed #1045 - Multiple metaparams all get added to resources. 8d5ded0 Removing some code in Parameter that is unnecessary. 5fbdc49 Fixed #1595 - Internally, Property#retrieve is no longer called when no 'should' value is available for a resource. c16a5ae Only apply splay the first run 27f0c7d fix failing hpux user specs 7a3a38f Add rspec unit test for the append operator 16793d2 Add an append (+=) variable operator: 7f8abbd Bug #1550 - Rework to avoid regressing rspec tests, add new rspec tests for templatedir as a path 0905734 Allow a templatedir to be colon separated. 11b0848 Fixed #1500 - puppetrun host regression 3b1d6e2 Fixed #1579 and #1580 - errors in the Puppet RPM spec file 77f4fb6 Fixed #1521 -- ldap user and group are now used with the default connection when available. a1a670b Fixed #1572 -- file purging now fails if remote sources do not exist. dd4f654 Fixing #1576 - moving all of the Puppet::Type code back into type.rb. 923fd89 Fixed issues with file descriptors leaking into subprocesses cab5d85 Fixed #1571 - Puppet::Util::binary returns incorrect results a7306e1 Fixed #1553 - Puppet and Facter cannot both install the plist module into two different locations 758505b Fixed #1568 - createpackage.sh 7ce902d Adjusted hpuxuseradd user provider to confine to HP-UX and fixed HP-UX user provider path regression 8f1336f Fixed #1566 - changed password property of the user type d4d3213 Fixed debug messages in package type - thanks to Todd Zullinger for this fix b88df5a Sync with latest Fedora/EPEL specfile 0705dfb Fixes #1455 - Adds HP-UX support for user type e15d316 Fixes #1551 puppetmaster.freshness xmlrpc call returns incorrect type 8fe0338 Fixes #1554 - Fix exception for undefined hostname 81cc9bf Fixed #1533 - changed permissions for man directory 41dc1fa Runit service provider aae0793 Daemontools service provider 29ae879 Fixes tests broken by 95aa085 b50e718 Fixed #1488 - Moved individual functions out of functions.rb into the lib/puppet/parser/functions directory. New functions should be created in this directory. 5fb5091 Fixed #1457 - case insensitive match for error ded94f7 Removed spec color option for buildbot 415663b Added simple rake task for running unit tests 557be9d Added spec Rake task 0d118a5 Fix leaking LoadedFile when adding templates to be watched 67387e2 Fixed #1506 - Removed storeconfig duplicate indexes 7accb89 id column is autogenerated by rails as a primary key, there is no need to create an additional index on this column. This changeset contains the new schema and a migration. c5fb092 Removed reference to namespaces from --genconfig documentation 1729de1 Updates to ext/puppetlast to support multiple hosts b6609ee Fixed #1508 - Add HP-UX package provider. 3e482a2 Updating the authors list for the gem spec 2ec4e29 Fix #1502 - abysmal storeconfig performance - part2 9272df4 Fix #1052 - abysmal storeconfig performance - part1 f48a0ae Fix #1510 - storeconfig fails with rails 2.1 b1ad596 Add the -P/--ping option to puppetrun, fixes #1501 6676b6b Fixes #1274 - allow class names to start with numbers d02f95c Fixed #1394 - Added stored configuration clearing script to /ext fb8cc53 Fixed #1442 - replaced use of Facter for report titling with certname 18dda20 Fixed $1456 - add proxy configuration to yum repo ab4cb6a Fixing #1447 -- Replacing Puppet::PackageError with Puppet::Error. 8a0cb16 Added tests for TemplateWrapper's use of Scope#to_hash. 3ae7eca Fixing an ldap connectivity test d3393b4 Added CHANEGLOG entry for removal of interface type bfcdfe8 fix terrible error with overwriting permissions 0147570 Fixed #1457 - removed confine warning fecdfbc A working script to create an OS X pkg out of the Puppet repository 6a2e71d Fixed #1441 - Updated console colours 404450a Add testing for the changes to resolve redmine #1427, where Kernel methods shadow variables that the puppet template should otherwise see. Specific changes: 03c76de Expose all puppet variables as instance member variables of the template wrapper. This helps resolve redmine #1427, by providing a safe mechanism to access variables. 13069ec Ensure that we consistently use either string #{} interpolation or String.% interpolation, not both, to avoid issues where a #{} interpolated value contains a % character. 469c5fe Feature #1476: Allow specification of --bindir --sbindir --sitelibdir --mandir --destdir in install.rb 2a3d195 Specs for yaml indirector .search - I'm still learning! c97389d Made puppetlast work on 0.24.5 by using the YAML indirector 5c53617 Added a search method to the YAML indirector. 482489a Revert "Fixing puppetlast to make it work with 0.24.5 / 0.25." 0bbac8d Fixes #1417 - whitespace in ssh_auth_key provider a772110 Sync with latest Fedora/EPEL specfile 97987a7 Feature #1241 : Improve performance of group lookups fe99828 Bug #1448: Puppet CA incorrectly writes out all certs to inventory .txt on each certificate signing 971af69 Fixing puppetlast to make it work with 0.24.5 / 0.25. d91d806 Updating the authors list for the gem spec 0.24.5 ====== ce964ec Updated to version 0.24.5 a7df4eb Updated to version 0.24.5 4dffaf3 Reverting the version so my release process works aac7dd1 Incremented versions bfcd626 Fixes #1445 and #1426 8f5800f Fixes #1445 and #1426 ff36832 Fixing the renaming code to skip missing directories. 8c2478b Fixing puppet_module -- it needed the same node interface change. d9aa5ab Fixing a cert test to pass on Darwin. 686ba4d Revert "Merging fsweetser's selinux patch against 0.24.4" f16da42 Merging fsweetser's selinux patch against 0.24.4 a47fed4 'Fix' broken tests related to missing source raising Issue 1437 In two cases, I removed the assertion that caused the failure. In one case, I changed the assertion to expect an exception. 238b8d7 Fixing #1438 -- mongrel and module tests now pass. ebb219e Fixed all of the fileserving termini so they use indirection requests. d8937ac You can now select the encoding format when transferring the catalog, with 'yaml' still being the default but 'marshal' being an option. This is because testing has shown drastic performance differences between the two, with up to 70% of compile time being spent in YAML code. Use the 'catalog_format' setting to choose your format, and the setting must be set on the client. a0fa09f Revert "Fixed #1201 - all external node attributes are converted to strings." 8f8ce60 Fixed #1431 - Provider confines must now specify similar tests in one call. 7fa7251 The mongrel-related tests now run without mongrel. bdbd992 Updated /spec/unit/rails.rb test de6aec6 Fix Ticket 1426 - services on redhat are restarted again 0a0fcaf Fixed #1414 - Return code from waitpid now right shifted 8 bits 61b9bcd Added Changelog entry for new auth_key type 65b9869 Further moves from the examples directory and ext directory 4ce7159 Fail instead of log when rescuing remote file connections 4c5293b Fix #1409, Move path expansion from the type into the provider 8043655 Fixing #1408 - --loadclasses works again. 605d760 Moved debian to conf and updated examples directory d25c2b2 Fixed #1407 - allowdupe is now a boolean group parameter. 9eb9aff Fixed #1368 - updated Red Hat init scripts c7dc73f Fixing the user ldap provider tests edf99c5 Added message referencing ReductveLabs build library 6ff9246 Fixed #1396 - Added sha1 function from DavidS to core 19b76c7 Fixing #1401 - integration tests now work regardless of the yamldir. 667fac1 Fixed #1226 - Gems can now specify source repositories. 21d4957 Correct whitespace 4762b52 Moving the gem test to the non-ral directory 71f4b02 Importing Sam Quigley's work to enhance gem support for sources. c751e4e Fixed #1272 - ldap group names will be converted to GIDs. 0922c3b Fixed #1399 - the ldap user provider knows it can manage passwords. 196494a Fixed #1231 - Exceptions during startup should now be clear. 9d69b3f Testing and simplifying the Transaction::Change#backward method. 61ec332 Removing the Transaction::Change#transaction accessor. 2863df2 Refactoring the Transaction::Event class. a37a784 Adding tests for the Transaction::Event class 31ffeab Adding tests to the Transaction::Change class. 8865bdf file object creation should fail if source is not present 73c06c0 Renaming Puppet::Event to Puppet::Transaction::Event 84b5665 Updated test/ral/type/sshkey.rb test 5ef8979 Removed debugging from lib/puppet/util/ldap/connection.rb 6124c69 Renaming the Puppet::PropertyChange class to Puppet::Transaction::Change. ba12d30 Fixed #1232 - the rundir no longer specifies a user/group, and there are now client- and server-specific yaml directories. be169da Removing all of the code related to the interface type. 04ecb74 Doing what I can to fix #1128, but just in preparation for removing 'interface'. 2279acd Adding changes to config print that were missed in fix for 1183 a87885a Fixing the "describe" in the redhat interface specs bd3f8e3 Fixed 1240 - puppet will function more like puppetd if graphing or reporting are enabled. 7a6ae29 Add a missing test for exercising the last untested line of lib/puppet/type/ssh_authorized_key.rb 731d0f2 Minor documentation updates for ssh_authorized_key type c825c99 Fixing the ldap node terminus to merge facts with the right name. 4b6b22e Adding logging when a node's facts can't be found daf0d9d Backporting a test that was failing in master, and fixing it 38540d5 Fixing the ldap node integration test so it cleans up e03c1be Fixing #1382 - existing uppercase certs, keys, et al will be renamed. 5156230 Use generate instead of autorequire in the ssh_authorized_key type based on Luke's comments d3a8125 Fixed #1006 - puppetrun --class works again. I added the class membership testing to the Ldap node terminus, and added tests, c1e010f Fixing the Node::Ldap.search method to use an indirection request. 4d22a95 Switching the ldap terminus to use Util::Ldap::Connection. b47d4e1 Added a 'search' method to the ldap node terminus. a1d1abd Adding an 'instance' class method to ldap connections. ee9d002 Fixed #1114 - Facts in plugin directories should now be autoloaded, as long as you're using Facter 1.5. f1d5903 Fixing #1388 - the package test no longer uses 'require'. 8c5c949 ssh_authorized_key: autorequire, default permissions and cleanup 5a283d6 Fixing #1374 - Using Puppet::Type.type() in tests 17afb8a Fixes #1195 - Updated Gentoo init scripts 00182ff Fixed #707 - special '@reboot'-style cron jobs work again. c83b23d Updated CHANGELOG for two missed commits 2380fcd Fixed #1012 - templates in the templatedir are preferred to module templates. 4d95364 Fixed #1221 - aliases to titles now work for resources. 24ca81f Fixed #1360 -- allowdupe works with groups again. 955a8ff Removed test/util/loadedfile.rb tests which fixes #1370 9c1ab14 Fixed #1371 - Updated bin/puppet to use Node.find aedfa2b Fixed #1369 - the init service provider now supports HP-UX. 422dea0 issue 1183 d3a4d9a Updated Rakefile fixes #1367 5f600dd Fixing #1168 (for 0.24.x) -- automatically downcasing the fqdn. Also requiring that passed in certnames be downcased; the setting system isn't currently flexible enough to automatically downcase it for the user. ac7f596 Fixed #1201 - all external node attributes are converted to strings. 6658463 Updating the changelog for the changes to node lookups. 1f19453 Removing the Node.find_by_name method. 51e1ba8 The LDAP Node terminus now searches for the fqdn, short name, and default. fb4e843 Refactoring the 'find' method a bit in the LDAP Node terminus. 317af36 Removing the now-obsolete Node.node_facts method. b7bd427 Converting the Node.node_names class method into an instance method. 75c94e3 Removing an obsolete, unimplemented test 98e38a6 Adds support for keepconfig for the dpkg provider fixes #234 4d70449 Fix bug in test, add more specs and small refactor 86f8ff4 Removed the unless condition in query, because the issue is a stale cached value and added comments that query will now always do so. 4539b1c Issue 1215 7b2c310 Adding another note about the save_object stub. d816614 Fixing #1362 -- I had previously removed a stub point needed for testing. 9b1301c Removing a duplicate call left over from debugging 087480b Replacing all two-space indents with four-space 3980323 Adding ruby interpreter lines to the tests missing them. 9fe2b03 Adding execute bits to every test currently missing them. fb5f09b Fixing how the Indirector::Request sets its options. 4b29a5e Fixing how the indirection tests for whether the request has node info. 6764af3 Change description of spec to make baby jesus happy 946081b Try again bdc578a Applying the fixes recommended by David Schmitt to the inline documentation of the ResourceTemplate class. 886c984 Updating the docs for ResourceTemplate. 29c840a Adding a class for using templates directly within resources (i.e., client-side templates). This would really only be used for composite resources that pass the results of the template on to generated resources. 1205881 The mongrel and webrick REST handlers now extract certificate information. e8044f9 Adding to the indirection request support for authentication information. dbd9b40 Updated fix for ticket #1271 cf3b98e Applied patch for ticket #1271 9943da6 Further Emacs puppet-mode fixes 3c2e69f Fixed Rakefile to install non-.rb files to fix #1266 ad3803f Fixes for install.rb running of tests that fixes #1267 65c1889 Fixing #1242 -- lack of storeconfigs only produces warning, not exception. 8a22b59 Fixing #1265 -- the ca/client tests now all pass again. 02411f5 Always using the cert name to store yaml files, which fixes #1178. 89100c4 Moving the majority of the pkgdmg docs to the wiki, fixing #1264. 9decf35 Put function in ticket #311 in correct location 6c3e7e1 Reverted function - "Added cron random function fixing ticket #311" c173264 Refactoring warnings.rb for tests. e6837a4 Fixing an inaccurate test so the tests will run correctly in all branches. 054a811 Removing extra debugging bdcf5db Fixing tests that are broken when running as root under OSX 10.5 d55a755 Added warnings test and cleaning up trailing whitespace. c0f78b4 Fixed a bug in my tests which caused them to fail when run against the master branch. d54338f Added cron random function fixing ticket #311 6ea494f Pushed patch fixing #1235 c370104 Fixing the node/catalog so that it can convert from parser catalogs to RAL catalogs. bd51a53 Fixing transaction support for prefetching generated resources. 4434072 The ldap user/group providers now work when no users/groups are in ldap yet. 419f244 Adding support for settings within the existing Facter provider confines. 3e13bd5 Intermediate commit so I can move on to other things. ee4be4f Removing an unused file. Closes #1229. b8ce6a1 Mocking Facter in an integration test, so it works with no networking 77ee4ec Refactoring how the provider confine tests work, again. 0820819 Minor cosmetic changes to cleanup some style elements and get rid of some cruft. 6a6a1d9 Another refactor based on feedback from Luke. This includes adding an accessor for @@state to make testing a bit cleaner. ee04129 Refactored tests based on feedback from Luke. d7f25ff Rewritten tests for Puppet::Util::Storage. c5da401 Add unit tests for Puppet::Util::Storage 8008bbc Modified the 'factpath' setting to automatically configure Facter to load facts there if a new enough version of Facter is used. a02c6bb Fixing a mock in the redhat interface test. 390db80 Updated puppetd documentation which fixes ticket #1227 2d6a914 Fix for latest method in rpm provider (fixes #1224) 38545d9 Crontab provider: fix a parse error when a line begins with a space character a1409d7 Moving all confine code out of the Provider class, and fixing #1197. 995991d Switching the Provider class to use the new Confiner class. c9757a6 Moving the 'confine' handling to separate classes. ac79a79 Duh, fixing all of the paths being loaded for spec in the moved tests. d02334f Moving all tests that are in 'ral' up a level. e7bef08 Fixing the user test. 158d3df Added the ability to add arbitrary attributes to ldap. 83ef1b0 Fix for #1219 b500689 adding more autotest docs c61fc02 Adding autotest info to the ext/ directory. 59b9958 Correcting whitespace in the templatewrapper code. 49dde11 Adding has_variable? support, fixing ticket #1177 d8cc1c5 adding execute bits to tests 5e2a4b5 updating the changelog for the ldap providers 17e8158 Adding ldap providers for the user and group type. c56e9a6 Fixing another test that wrote to ~ 954aad4 Fix Emacs mode indentation of multiple nested blocks f52e343 Enhancements to syntax highlighting and indentation for Emacs 9bf21a6 Use our own count-matches for Emacs 21 compatibility 20e60b1 Applying patch by martin to fix #1207. 270c007 Clarifying the exception when there's a syntax error but a valid parser. f3fa589 Fixing a test that wrote to ~. ae842ea Fix for urpmi provider that fixes #1217 da4cdd2 Fix for ticket #1218 - changed to appropriate variable name 88ec3d8 Cosmetic fix 67dc261 Removed "none" as a valid type attribute value, it was useless anyway db8a46c New native ssh_authorized_key type 2b185af Add values for dump parameter for the mount type closing #1212 69fc802 Update to man pages, fix to ralsh help text and fix for #1211 c57e194 Fixing an error message to be more clear 5a2bbad fix bindir/sbindir defaults on OS X 10.5 fff6ad9 Fix for ticket #1209 b2a3db9 Fixed #1196 - added /sbin/service support for the redhat service provider + some doco fixes 62ca726 Fixed some tests broken by #1176 82b9f61 Added puppetlast script to ext directory a35450b Pushed patch for #1176 - configtimeout fix 57fd88b Pushed patch for ticket #1191 - adding globbing support to ports provider b5640a1 Pushed patch for ticket #1187 - freebsd pkg_add support 0a5d8a6 Fixed #1195 - support for gentoo openrc 4599791 Pushed schema patch for #1193 eac14f6 Fixed #1189 and added support for --all to puppetca --clean d9846fc Fixishing some pending tests, including filling in the connection information. cb617f2 Making the changes necessary to get the REST support to work with the current state of the indirection work, including using a request object and an expiration date. a6a397b The 'destroy' method in the indirection now returns the results of destroying, so they can return true or false. 04aba52 fill out specs for network_* methods; refactor lowest-level network hooks a0804ae adding rest_connection_details helper to Indirector::REST -- will need to be overridden to lookup the real connection details aed1375 make sure unit indirector specs are working with #save; fill out network_put pending specs 75bf05d removed a debugging helper from the Indirector::Rest#save method 9187a34 updating mongrel/webrick unit tests to match integration-tested version of REST save functionality 93bc1a9 adding REST save support, with integration tests. A handful of unit tests in that area now need to be updated. 99b295b disabling caching for Puppet::Indirector::Indirection as it was causing hella problems with testing save without caching; judging my luke's blog this is going to be rewritten somehow anyway 1befd1d work-in-progress; playing with refactoring network_* methods inside Indirector::REST f28f20b Added support for destroy/DELETE over REST (including units & integrations on both webrick & mongrel). 0797440 updating search integration specs to include webrick e8caf13 making search work over REST, w/ unit & integration specs b750482 unit specs and implementation for Indirector::REST#search method a7f2dd4 placeholders for integration specs on final REST methods cebb677 ensure that we only run the mongrel specs when mongrel is available as a feature dab9deb bringing Indirector::REST specs to mongrel-land as well. 1e0f19b Make mongrel happy like WEBrick. d24c03c exceptions on remote end now properly passed to local end via REST and re-raised (integration-tested) 7a73434 Much larger commit than I would like to land at once. This is all REST-related code. Two specs are failing related to how Mongrel is initialized for REST; will fix those shortly. a1c4579 a trivial integration test to test whether the RESTful indirection terminus has a remote shot at working; will need to be upgraded to actually be useful 7d51146 fixing Puppet::Node::REST class name to work with autoloader inflection (Puppet::Node::Rest), so we can do Puppet::Node.terminus_class = :rest e86fde2 This is the first version where mongrel and webrick are reliably startable and stoppable via Puppet::Network::Server. c2f8c69 the indirector will not serve xmlrpc (this is the responsibility of the legacy networking code; it was a mistake to include stubbed support for it in the new code); removing 13c40e9 removing obsolete TODO comment 2cdd0f8 puppet-compliant indentation b49fd49 Resources now return the 'should' value for properties from the [] accessor method (they previously threw an exception when this method was used with properties). This shouldn't have any affect functionally; it just makes the method equivalent to 'should' for properties, but it works for all attribute types now. 4aaad26 Modified the 'master' handler to use the Catalog class to compile node configurations, rather than using the Configuration handler, which was never used directly. I removed the Configuration handler as a result. 2925ad1 Fixed #1184 -- definitions now autoload correctly all of the time. 376628d Removed the code from the client that tries to avoid recompiling the catalog. The client will now always recompile, assuming it can reach the server. It will still use the cached config if there's a failure. 3718b64 Fixing #1173 -- classes and definitions can now have the same name as a directory with no failures. d91b6d8 Fixing #1173 -- classes and definitions can now have the same name as a directory with no failures. 738889b Fixing the expire method (it wasn't using a request internally), and fixing the Facts class so it auto-expires any associated cached nodes when facts are saved. f285f1a Moved the request creation into the Indirection class instead of the Indirector module. Also, added an 'expire' method to the indirector, so there's an easy way to expire cached instances. d420701 Making the log messages around caching better. d82ac98 Fixing the executables to use the new indirection api. 7774d9c Ported the rest of the indirection terminuses over to expecting requests instead of having a random interface. bf728d2 Intermediate commit. 644d6ba Fixing some tests that were failing because new base types were added to Naginator, but no new related resource types were added. 768315b Adding the ability for indirection requests to be created with instances instead of just keys. 38f0f48 Fixing an errant comment 69a321f Fixing the tests that were failing because of the use of the indirection request object. f9881ed Adding a Request class to the Indirection layer. This class is currently only used internally by the Indirection instances, but I expect that I will soon be pushing it to all of the terminus types. 4032a27 Fixing the integration tests related to the destroy fix. Yay. 0bd5799 Fixing one other test that was failing because of the change to Indirection#destroy. 941177a Changing how destroy works, just a bit -- it now accepts the name of the instance to be destroyed, rather than the instance itself. c6729d1 Reworking the caching layer to use TTLs instead of versions based on timestamps. This just modifies the indirection class itself, there is still some work to do to remove version code from other classes. 8e1e06f Removing unused code from the file_serving/metadata class. 1458123 Adding an envelope module to handle indirected instance expiration. bd858df Changing the default environment to production. 80f8b80 Adding validation to the user type to confirm that the group list does not contain any commas. This seems to be a common problem. 92765ea Making a test executable 7295626 Used stubs to decouple our code behavior from the behavior of the underlying filesystem, as well as removing the need to sleep (which caused the tests to take a long time). 911c7fb Additional fix for emacs syntax for ticket #1160 c13486e Revert "Additional fix to emacs for ticket #1160" bb65226 Additional fix to emacs for ticket #1160 6f1c469 Extend workaround from 56aad69f8cdf8b0b08fdb7985014986223fa4455 to not only fix UIDs but also GIDs e621985 Changed some non-standard Ruby locations to env ruby shebangs 2036d22 Fixes debian service enabled/disable issue as detailed in #1161. 1c02749 Committed patch from #1160 335972e Pushed patch to fix #1174 6f32e95 Adding the report reference back; I don't really know why I removed it, since the information in it isn't anywhere else. f927b97 Updates to rrdgraph documentation e51d05c Better fix for #1020 4a39d64 Revert "Added updated fix for #1020" 2cac600 Fixed duplicate oid for parentnode and environment in schema - addresses #1170 eae5cee Fixing a duplicate word in the mount docs 4f8df98 Added updated fix for #1020 aa830b9 Adding 0.24.4 header to the changelog 4c63b69 Add a bunch of directives, allows a full parse of stanford's huge nagios config Also reformatted a bit 9d30b26 Fixes #1148 - replaces #!/usr/bin/ruby with #!/usr/bin/env ruby. 874a02f Added check_puppet.rb Nagios check plugin (See #1162) 491a696 I think this will include the man pages in the build but overall the Rakefile needs a rewrite 9cf7150 Added some more tests for loadedfile, based off the old unit tests. 077312a Added rspec tests for loadedfile 0.24.4 ====== 3a8053a Updated to version 0.24.4 d3e4ed7 Updated to version 0.24.4 55a9009 Pass source to pkg_add via the PKG_PATH environment variable if 6a53519 Fixing #571 -- provider suitability is now checked at resource evaluation time, rather than resource instantiation time. This means that you don't catch your "errors" as early, but it also means you should be able to realistically configure a whole host in one run. 528bbf1 Fixing a couple of tests. 017f673 Moved the configuration of the Node cache to the puppetmasterd executable, since it otherwise causes caches to be used in all cases, which we don't want (e.g., bin/puppet was using them). bd3f6ec Disabled man page creation by default and updated CHANGELOG 4bfc4ef Modifying the way ensure is handled so that it supports having it be a parameter. This is only useful if you want a composite resource that just generates other resources and passes the value on. d93e1b4 Fixing #1138 -- the yamldir is automatically created by the server now that it's in the :puppetmasterd section rather than a separate :yaml section. 273c7ec Disabling http keep-alive as a means of preventing #1010. There is now a constant in Puppet::Network::HttpPool that will disable or enable this feature, but note that we determined that it can cause corruption, especially in file serving (but it's client-side corruption). 6aa6fdb Applying patch by Ryan McBride to fix OpenBSD package matching. The actual problem was caused by the fix to #1001. 5a31959 Added man pages and man page creation logic to install.rb e5b16b2 Ported #198 man page creation functionality to 0.24.x branch 18320b8 Found all instances of methods where split() is used without any local variables and added a local variable -- see http://snurl.com/21zf8. My own testing showed that this caused memory growth to level off at a reasonable level. Note that the link above says the problem is only with class methods, but my own testing showed that it's any method that meets these criteria. This is not a functional change, but should hopefully be the last nail in the coffin of #1131. f6325dc Found an array that leaked pretty quickly between reparsing files, thanks to work by Adam Jacob and Arjuna Christenson (the finding, not the leak). I'm going to act like this fixes #1131, at least for now, but I doubt it does, since that shows general memory growth over time, whereas the leak here should go away as soon as files are reparsed (because the parser is holding the reference to the leaking array). 25b81b3 Fixing a test I broke with my fix to #1147 4f400d4 Fixed #1147: Cached nodes are correctly considered out of date if the node facts have been updated (thus causing node facts to again be available in manifests, for those cases where they were not). 54bedb2 tweak the (already applied) patch in 388cf7c3df7ce26e953949ed6fe63d76cbbb3691 to resolve #1137; also, add tests which detect the problem. a240969 Applying patch by wyvern to fix #1142. e00065a * puppet/ext/emacs/puppet-mode.el (puppet-indent-line): Clean up the code somewhat after commit 738d275f41f3eaf015800021dd2dfe6c42a1ae79, as promised. 5f3ed8d * puppet/ext/emacs/puppet-mode.el (puppet-indent-line): Be more sophisticated about what we do at the beginning of the buffer, so that the first expression after an block-opening statement that happens to begin at the beginning of the buffer gets indented correctly. This may need some cleanup, but I wanted to get the correct behavior committed first. d1d408c Fix bug mentioned in commit f814e23eab140ad01df4a4a3b187fcbf20da02be: 7514057 * ext/emacs/puppet-mode.el (puppet-comment-line-p, puppet-in-array): New helper functions. (puppet-indent-line): Rewrite to handle three more situations: indent elements in an array, indent single-line blocks, and ignore previous comment content when indenting non-comment lines. 40a389a * ext/emacs/puppet-mode.el: Untabify, in preparation for substantive changes. 0c45a5a Adding another commit for #1136 -- Consolidated the setting of the loglevel and destination to just one call, rather than the multiple calls that remained. 4ce1d37 Fixed ports documentation error c75cc42 Added more detail about the requirement for ruby-libshadow for useradd password management 1dc6dc2 Final fix to #1136 - further changes to --test setting e714156 Second fix to #1136 - fixed --test problem 2155fe1 Fix for ticket #1136 --verbose cancels out --debug 4cc18ed Applied patch in #1134 2795ba4 fixing another failing test a40e9b7 Fixing some tests that only failed under certain circumstances (mostly, when loaded with other files, or when loaded from rake or autotest rather than separately). 7d35ae8 Refactoring how the catalog creation handles errors. Previously, if there were an error creating a resource, the error would propagate leaving any previously created resources still in memory. 1b3c85b Removing extra debugging 2d90468 Fixing a unit test for node integration e81fc58 Settings now (again?) do not use a section more than once, which should make the system a bit more efficient. fca467d Removing explicit requires of types and providers, because they were conflicting with Puppet's autoloading. This is clearly a sign that our autoloading is silly, if Ruby's own loading easily makes it unhappy. 34129d9 Removing obsolete code from the fileserving handler. This was obsoleted in 0.24.2. f62eec8 updating resource references in the docs d0554db Hopefully *finally* fixed the "already being managed" problem (#1036). The problem only cropped up if there was a failure when trying to manage the system -- this would cause the setting-based resources not to get cleaned up. 13c6de3 Adding a rake taks for updating the trac docs 0.24.3 ====== 0e26a07 Updated to version 0.24.3 990638c Updated to version 0.24.3 18ed28b Updating changelog for 0.24.3 ab72048 Removing a Settings.use that is unnecessary bba0b43 Downgrading the "Using cache" message from the indirection to debug 1dc0e24 Modified the ldap node terminus to also use the facts version as the version for a node, which should similarly encourage the use of the yaml cache. (Related to #1130) 4a45a1d Caching node information in yaml (I figured caching in memory will cause ever-larger memory growth), and changing the external node terminus to use the version of the facts as their version. This will usually result in the cached node information being used, instead of always hitting the external node app during file serving. Note that if the facts aren't changed by the client, then this will result in the cached node being used, but at this point, the client always updates its facts. (#1130) f3a304c Modifying the yaml terminus base class to use the timestamp of the yaml file as the version of the object. 8b29368 Adding a filebucket test to puppet-test da77cb6 Adding a test for local compiling 405802e Using the indirected facts rather than master.getfacts, so no factsync is used 388cf7c Regression in :node_name functionality 872ced7 Flat file now does writing to a tempfile. 4956323 Fixing #1132 -- host names can now have dashes anywhere. (Patch by freiheit.) ecb873d Fixing #1118 -- downloading plugins and facts now ignores noop. Note that this changes the behaviour a bit -- the resource's noop setting always beats the global setting (previously, whichever was true would win). e2370b3 Fixing the service-stop on debian, using the patch provided by DavidS e8029cc Fixing the "tidy" type to use an option hash for specifying its parent class c955f61 updating changelog for already-closed tickets eecc22c Cache the same type we check for, hopefully fixes #1116 f1216f8 Revert "Cache the same type we check for, hopefully fixes #1116" ca0b62a Cache the same type we check for, hopefully fixes #1116 35214eb Fixing the rest of #1113: External node commands can specify an environment and Puppet will now use it. 2261032 Partially fixing #1113: LDAP nodes now support environments, and the schema has been updated accordingly. 4c0f6c8 Fix for 1094 647f5b4 Always duplicating resource defaults in the parser, so that stacked metaparameter values do not result in all resources that receive a given default also getting those stacked values. ee8fac6 Changed name of method for clarity per code review 8192475 Ticket #1041 The CA serial file was getting owned by root because it was using a different method to write to file 4c47656 Applies patches from #1111 and #1112 443db20 Fix tests depending on the Puppet[:localcert] file existing using stubs 8627139 Updating version number 3b5daf7 Revert "Fixes #1099 - use of -m option with -d option for home directories" 0ae58a9 Fixes #1099 - use of -m option with -d option for home directories 0.24.2 ====== f019cac Updated to version 0.24.2 bfdac69 Updated to version 0.24.2 6faed12 updating changelog for 0.24.2 ee88c58 Applying patch by DavidS to fix #1083. a7339ec Fixing a few tests e008b02 Fixing #1110 -- transactions now always make sure their tags are arrays. 65b7267 Fixing the fact that resources that model defined resources were getting finished multiple times, which meant they got multiple copies of metaparams. 4c3fa78 Fixing a few more loading order issues. 857814a Fixing tests that did not work with Rails 2. 7ca0ad6 Fixing a test that changed the environment for all later tests, thus breaking some of them. 9b07758 * Tweaks for puppetshow UI cleanup 0139889 * Add migration for "created_at" (hobo expects it) * Tweaks for puppetshow interface cleanup * Delete unused tagging lib and puppet_class model 43aea83 renaming ral/types to ral/type in the tests 879ee22 Fixing #1062 by moving the yamldir setting to its own yaml section. This should keep the yamldir from being created on clients. fd1573f Fixed #1047 -- Puppet's parser no longer changes the order in which statements are evaluated, which means that case statements can now set variables that are used by other variables. 9d6e926 Fixed #1063 -- the master correctly logs syntax errors when reparsing during a single run. abd688e Fixing #1092 by no longer using the resource reference to look resources up, which means there's no concern about not finding the resource, which is where the nil was coming from. We now just iterate over the vertices. 29aafb4 Fixing an integration test so it cleans up after itself 82b02b9 Fixing #1101 -- puppetrun works again. dd17d4c Fixing #1093 -- 0.23.2 clients are again compatible with 0.24.x servers. :ignore links is now equivalent to :manage links. c0b5352 testing automatic commit emails 614ab9f Adding a 'control' parameter to services, for those service types that need a control variable to enable/disable. bb8051b Removed the loglevels from the valid values for 'logoutput' in the Exec resource type -- the log levels are specified using the 'loglevel' parameter, not 'logoutput'. This never worked, or at least hasn't for ages, and now the docs are just correct. ff4f65a replacing tabs with spaces in the redhat interface provider f3db79e Fixing a typo in the mailalias resource type 4e55999 Removing the validation on package sources, since some platforms (e.g., hpux) do not have a well-formed requirement for the source. 42bfdf2 Fixing #1085, I think -- I was not returning a resource if the class had already been evaluated, but this was only being run into in corner cases -- mostly where one class included another class, I assume. 1258512 Fixing #1084 -- the node catalog asks the individual resources whether they're isomorphic, and they in turn ask the resource types (or default to true for defined resource types). 9a33487 adding a comment to the namespaceauth.conf file 04892ee Adding an example namespaceauth.conf f0975df Trac #1038: not a fix, just an attempt at improving the situation. c8b320e Corrected #1040 fix - this should now be right - trace was after raise 07cd482 Making a couple of other small fixes, requiring classes that were not being required in the right order. ff97059 Somewhat refactored fileserving so that it no longer caches any objects, nor does it use Puppet's RAL resources. In the process, I fixed #894 (you can now copy links) and refactored other classes as necessary. Mostly it was fixing tests. 939c952 Fixes ticket #1080 f184228 Fixes ticket #1079 - added . support for tags 9b6e501 Fixing a test that was failing when a user-specific fileserver.conf actually exists. 5d35bc5 Fixes #1078 and includes new test 7976015 Removing a test I never migrated from test/unit. 279a0c5 Fixing a test that was actually reading in keys from the filesystem and failed when those keys were unreadable. 098a69c updating checksum for #1010 fix b06767e Quashed commit of my fixes for #1010. 5e18b8d Hasstatus in the init service provider; it was just doing a boolean check, rather than comparing to :true. 60f18c2 Fixed minor documentation error 39a6756 Fixed #1073 - moved show_diff and other logic post config parse f006e17 Fixed test for #1040 1f0ea5a Second attempt fix address ticket #1040 39f9818 Removing some extraneous debugging from a test. d82bfd8 Attempt to fix #1040 - catching errors in compilation e830f28 Fixed #1018 -- resources now have their namevars added as aliases in the resource catalog, just like they were added in the resource classes. 60dd569 Fixed #1037 -- remote unreadable files no longer have the permission denied exceptions caught, thus forbidding them from being replaced with 'nil'. 2de4654 converting parser ast node specs from setup/teardown to before/after 9927efb converting parser ast host class specs from setup/teardown to before/after c86c1da converting node catalog specs from setup/teardown to before/after 61cdc2b converting indirector yaml specs from setup/teardown to before/after f702096 converting facter indirector specs from setup/teardown to before/after 516e5b6 converting indirector checksum file specs from setup/teardown to before/after d260b7e converting parser compilerspecs from setup/teardown to before/after 1913134 converting mount provider specs from setup/teardown to before/after 6781e10 converting indirector terminus specs from setup/teardown to before/after dba64dd converting file serving configuration specs from setup/teardown to before/after b4c8f99 converting indirector ldap node specs from setup/teardown to before/after 3cb1118 converting indirector direct file server specs from setup/teardown to before/after 9e632bc converting parsed mount provider specs from setup/teardown to before/after becafab converting mount type specs from setup/teardown to before/after 034336b converting indirector file specs from setup/teardown to before/after 12f139c converting package type specs from setup/teardown to before/after b8d5ce0 converting fileserving/configuration/parser specs from setup/teardown to before/after eb0bdcb converting indirector/module_files specs from setup/teardown to before/after 22d6f9f converting ral/types/schedule specs away from setup/teardown d04567a converting indirection specs away from setup/teardown to rspec compatible before/after usage aa14ce7 moving setup() methods to before :each, so that the tests will run with rspec, as opposed to just rake (which calls them directly with ruby, as opposed to any spec binary) f9f32c4 reordering spec binaries to prefer the local vendor/gems/rspec/bin/spec option d11cd39 Fixing a failing test that resulted from a change in how checksums are created. 62d7616 Fixing the directory service provider's behaviour when there's no value for a given attribute. f087df0 Fixed ticket #1072 - Debian directory updates 0eede76 Fixed Ticket 1009 - problem with plist xml parser. We do not need the plist parser for pkgdmg. 458cb23 Fixed ticket #1070 - puppetrun configuration parse problem 2e41803 Fixed ticket #1069 - removed remaining references to multiple configuration files 10d4d0e Fixed ticket #1065 - Solaris SMF manifests 8fa4120 Fixed ticket #1068 - Minor documentation fix 30128bd Really minor change to user creation in Leopard. 6013b25 Refactoring the incremental checksum generation slightly based on the code in type/file/checksum.rb. aebd303 Enhancing the stand-alone checksums utility module with the rest of the checksums we're likely to use, and adding tests, which I somehow missed when I wrote this file. df3fbc7 Fixed #1060 - Debian service removal and addition 5ef8a3e Changing portage to use Puppet::Error instead of Puppet::PackageError, fixing #1059. c4f7c51 Fixing comment -- ticket #1027 instead of #1064 8920557 Fixing #1064 -- providers et al are now autoloaded from modules even when Autoload#loadall is used. 4829711 removing "lib" deprecation notice from autoloader f8afe13 Fixed #1043 -- autoloading now searches the plugins directory in each module, in addition to the lib directory. The 'lib' directory is also deprecated, but supported for now to give people a chance to convert. fe02591 Fixed #1003 -- Applying DavidS's patch to fix searching for tags in sql. 9b1bfc1 Fixed #992 -- Puppet is now compatible with gems 1.0.1. 0cfa1d2 Fixed #968 again, this time with tests -- parseonly works, including not compiling the configurations, and also storeconfigs is no longer required during parse-testing. 8367fdf Renaming the 'pfile' and 'pfilebucket' files to plain 'file' and 'filebucket'. This should have been done years ago. a42c3ae Fixed #1021 -- the problem was that my method of determining the in-degree sometimes resulted in a lower number than the number of in-edges. d406353 Removing the last vestiges of GRATR from the PGraph class 068b61e Removing obsolete references (they're in the indirection reference), and adding error handling to puppetdoc. 98dbfa2 Loading the mocha gem from the puppettest.rb file. 12fa0fa Fixing the Rakefile so all tests run in one task instead of multiple. cb5def4 'rake' within the spec dir works now, anyway, which is a good start. Autotest still doesn't work, though. eb74033 Fixing the puppet_rspec autotest plugin to use the modern interface 1b90f7f Trying to upgrade rspec, but not having much luck. bcb9b56 Copying over Rick's work from the master branch supporting autotest and cleaning up the rspec support. 3af6827 Adding an inflection util class. 7e45553 Fixed #997 -- virtual defined types are no longer evaluated. NOTE: This introduces a behaviour change, in that you previously could realize a resource within a virtual defined resource, and now you must realize the entire defined resource, rather than just the contained resource. c8da318 Moving the ast node tests to rspec (which I could have *sworn* I did this weekend). In the process, I fixed a couple of bugs related to differentiating between nodes and classes, and then cleaned up quite a few error messages. 8b2fae0 Removing the last remaining vestiges of GRATR -- removing the bangs from 'add_vertex!' and 'add_edge!'. cf21ade Switching the Node catalog to use the Tagging module instead of its own tag methods. 744cd45 Added a 'tagged?' method to the Tagging module. d21416b Switching the Node Catalog to using a separate method for validating that a given resource is unique within the catalog. This no longer allows any duplication, even with Execs. fd0c5cb Changing the name of the Compile class to Compiler, since it's stupid to have a class named after a verb. 5ebaa89 Refactoring the interface between the Compile class and the AST::Node class to match that to the definitions and AST classes. e247b56 Changing some methods in the Compile class to be more internally consistent (switched store_resource to add_resource, and store_override to add_override). 6a4cf6c Fixed #1030 - class and definition evaluation has been significantly refactored, fixing this problem and making the whole interplay between the classes, definitions, and nodes, and the Compile class much cleaner. 3b740ff Converting the Compile class to use a Node::Catalog instance as its resource container, instead of having its own behaviour around resource uniqueness. 194e730 Moving all of the tests for Puppet::Parser::Compile to rspec, so I can refactor the class to more heavily rely on a Node::Catalog instead of doing its own resource container management. fb4bdc0 More AST refactoring -- each of the code wrapping classes just returns a resource from its evaluate() method, and all of the work is done in the evaluate_code method. This makes the code cleaner, because it means 1) evaluate() has the same prototype as all of the other AST classes, 2) evaluate() is no longer called indirectly through the Parser Resource class, and 3) the classes themselves are responsible for creating the resources, rather than it being done in the Compile class. 5a0e34b Refactoring the AST classes just a bit. I realized that all of the evaluate() methods only ever accepted a scope, and sometimes one other option, so I switched them all to use named arguments instead of a hash. 82720d5 Removing some obsolete code from the AST base class dbaffae Ceasing autoloading ast files; loading them manually instead 7c500da Stubbing Facter during the snippet tests, so they are faster and work with no network 084d0fb Adding more information to dependencies that do not resolve b293763 Applying patch by Jay to fix #989 -- missing crl files are correctly ignored, and you now use 'false' instead of 'none' to explicitly ignore them. 2931723 Fixing the Settings class so that it correctly handles file values that are false. f7b0ca9 Fixed #1052 - fixed gentoo service management b3f67ec Fix ticket 974. My original "fix" wasn't. This actually fixes the problem by using a regular expression that matches only up to the first square bracket. 8f0d87d Added :env parameter for backwards-compatibility, with warning about deprecation. :env parameter sets new :environment parameter. Changed instances of :env to :environment for consistency with other types. Added tests for new parameters. This cimmit fixes ticket 1007. 139ff33 Fujin's patch for ticket #1007 - consistent use of 'environment' instead of 'env' aedd59c fix bug 974 - filenames with opening bracket characters generate exceptions b8036a9 Updating the docs for the cron type 28a8577 Added hostname test for hosts type 16df87c Updated fix for ticket #151 and added a test ed0c745 Fixing #1017 -- environment-specific modulepath is no longer ignored. (Cherry-picked from master.) ade9f3c Store a resource before adding relations to it otherwise activerecord will complain. This fixes #933 047ec54 Fixed tickt #1034 - doco typo 6ff9423 Significantly refactoring the lexer, including adding Token and TokenList classes for managing how the tokens work. 11799b3 Fixed #1001 348aa3e Fixed #1028 - examples incorrect for 0.24.x 974fcdb Removed womble-specific Debian build section 321b8fd Fixed #1006 - changed ldapnodes to node_terminus ee6ddc9 Removing tons of unnecessary calls to "nil?" from the lexer. 7a4935f Fixing a couple of tests, one related to recent tagging changes and one that somehow slipped through when I removed the GRATR code. 9a290bb Second attempt to fix ticket #151 - host type now validates IP addresses and hostnames/FQDNs 4a7fcfc Revert "Fixes ticket #151 - host type now validates IP addresses and hostnames/FQDNs - the regex for the latter is quite complex but I have found it bullet-proof in the past" b561ae6 Fix bug #997, only evaluate non-virtual definitions 1ccc9c3 Fixes ticket #151 - host type now validates IP addresses and hostnames/FQDNs - the regex for the latter is quite complex but I have found it bullet-proof in the past d7a89b4 Fixed #1019 - made libshadow available for non-Linux users 8a649ff I think I've finally fixed #959, by having the Settings class skip any resources that are already in memory. 52eba77 Fixing #794 -- consolidating the gentoo configuration files. f43be56 Removing the line that marked fink as the default package manager on darwin. f98be4a Fixing #976 -- both the full name of qualified classes and the class parts are now added as tags. I've also created a Tagging module that we should push throughout the rest of the system that uses tags. 2cbab2c Fixing #1008 -- Puppet no longer throws an exception when you've pointed a file at a source that doesn't exist and you specify 'ensure'. f5674cd Fixing #995 -- puppetd no longer dies at startup if the server is not running. 7a9aae8 Wrapping the Resolv call in the mongrel server so if it fails it doesn't kill the server. 9161ae8 Applying a fix for #998 -- I used a patch equivalent to bartv's, although I could not use his commit because it was against the 'master' branch instead of 0.24.x. 046a326 Fixing #977 -- rundir is again set to 1777. 4618140 Updating docs for ssh. 7ee4746 Adding a parse test to puppet-test. 35145f3 Fixed ticket #1005 - added additional logcheck lines b24ac77 Fixes ticket #1004 - documentation fixes for ralsh and puppetrun 1ff9d65 Updated documentation for builtin cron type; added information about range and step syntaxes. f15696c Updated tagmail documentation fixing ticket #996 e3d4ea8 Fixes ticket #993 - tagmail with smtpserver specified does not add To/From/Subject header 40addcd Fixing #982 -- I have completely removed the GRATR graph library from the system, and implemented my own topsort method. 927dff4 Fixing #971 -- classes can once again be included multiple times. 117926c Fixing the unit tests for nagios_maker; I could swear I'd already done this but I must not have committed it. a7bca7e Removing the requirement in the parsed mount provider that the fstab file exist. 1bdf3f8 Fixed #984 - Added Debian to reponsefile doco b1f13af Fixed #980 - minor wiki formatting error in nagios_maker.rb 2f9c13b Fixed ticket #979 - code configuration option doco 039dc8d Fixed ticket #979 - pkgdmg.rb documentation 1154c42 Fixed ticket #978 - logcheck/puppet 33e319a Added builtin support for all Nagios resource types. I use Naginator to parse and generate the files, with ParsedFile to handle record management and the like. 68cde4f Removing the one-off naginator provider for nagios_command. 348f257 Adding the metaprogramming to create the Nagios types and Naginator providers. This is basically all of the code that's necessary to create all of the needed Nagios types. 4e8bc40 Fixing the inability to manage '/' directly. It was a result of stripping extra and trailing slashes. 9b1d036 Adding the first round of Nagios code. There are no tests here, but at least a single Nagios type is functional. Now I need to do some metaprogramming so this works for all nagios types, and add tests for the whole thing. 20367c6 Updated for 0.24.1 20d430d Adding 0.24.1 tag to the changelog. 0.24.1 ====== 4fa6546 Updated to version 0.24.1 d17fb7a Updated to version 0.24.1 40439da Updating an exception message a bit. e2fc425 Attempting to fix #952 -- catching any exceptions thrown during a run. c59ff62 Further fixes toward #965. Turned out that the previous fix caused other problems. 4d28b10 Updating the failure when the CRL is missing, so it's clear how to solve the problem. e4446b6 Fixing parseonly with a modified version of jay's patch from #968. bc0616e Updating filetype detection for vim, and changing the filestructure for vim files. (#900 and #963) 927cb24 Fixing #967 -- default resources no longer conflict with managed resources. c998a25 Adding a --print option to puppetca that just prints the full-text version of a certificate, and --verify, which uses the external openssl command to verify the cert against the CA cert (I could not find an option to the builtin Ruby libraries to do this). 9c32c9c Removing the ability to disable http-keep alive, since it didn't work and is now unnecessary. 553b2ad Entirely refactoring http keep-alive. There's now a central module responsible for managing the http pool (Puppet::Network::HttpPool), and it also handles setting certificate information. This gets rid of what were otherwise long chains of method calls, and it makes the code paths much clearer. 92b0ebc Fixing #967 -- relationships now work when running 0.23.x clients against 0.24.0 servers. 1ada24d Fixing some tests that were failing with the recent ruby that has ssl issues. c22a584 Uninstalling packages through 'ensure => absent' works again for the rpm and yum providers. 8f5989a Updated for 0.24.0-2 cc2d532 Updated for 0.24.0 933b1df Fixing #961 -- closing existing, open connections when a new connection is requested, and closing all connections at the end of each run. e0dab9a Updating changelog to reflect the fact that we no longer warn about explicit plugin mounts. 4d3a368 Remove the warning about an explicit plugins mount. 178093f Fixing the Rakefile to include the yumhelper.py file in the file list. 0.24.0 ====== 6b02bd5 Updated to version 0.24.0 e92f1cc Updated to version 0.24.0 22daebe Adding changelog update for misspiggy/0.24.0 e0f5444 Fixing the webrick test to provide a correct host name so the stupid ssl checks pass during the test. 106f319 Changing the statefile to only being managed by clients, not by puppetmasterd. 4ebb8d0 Hopefully finally fixing #959. Loading the stored cache resulted in the resource duplication, based on how the settings are used, so I added a test to only use those settings if the directories do not exist. 690e287 This should be the last fix for exported resources. Hosts were keeping the export bit on all resources, even when they'd collected another host's resources, which caused a duplicate copy that was still exported. f1169ee Not using the main section when running the store report, since it is unneeded and can cause conflicts within puppetmasterd ce5cab1 Removing extraneous debugging from the schedule resource type. cb0c4ee Renaming 'configuration' to 'catalog', fixing #954. 7ac3bd7 Renaming the 'null' terminus type to 'plain', as requested in #960. a21ee00 Copying the fact-loading code from the network client to the Facter terminus until I have a better solution. This problem was discovered becomes of #958. 1bbaf18 Applying patch by whaymond to fix #955. d9200a0 Adding what is hopefully the last commit for #896. Here's the changelog: 74db777 Removing the 'addpath' commands from the freebsd service provider, since it's no longer needed or even valid. b19a0c9 Removing the recently-commited paludis provider, because it breaks autoloading as indicated in #956. 02b64ab Applying patch by josb in #884 to provide pattern matching in the tidy type. 584127c Applying patch by raj in #881. 4ee5ab8 Applying patch for portage package support from thansen in #895. ed642ac Replacing freebsd service provider with the one provided by raj in #880. 117f005 Adding paludis package support as provided by KillerFox in #741. 3248c93 Fixing #937 -- I had not ported the dot methods at all, and I had to make a few small changes to make them work. a8bf74b Fixing #946. b70f00a Fixing some further failing tests resulting from the fix for 862d1f7 Adding an Indirection reference, along with the work necessary to support it. da77e4a Updating the changelog with external node info. f127d04 Fixing #951 -- external nodes work again, but you have to set the 'node_terminus' setting to 'exec'. 7a4ae08 Fixing the rest of #948. My previous work was sufficient, except that I was not passing the interpolated value in to the hook, which meant the libdir was set to something like $vardir/lib. 3790ce1 Fixing part of #948 -- per-setting hooks are now called when the configuration file is parsed. The bug is still there, but I'm getting closer. b852c2f Fixing #941 -- calling pkg_info instead of info in the openbsd package provider. ae33e57 Fixing #923 (again). The host storage method was not correctly searching for the host, so it was creating a new host on each run, which is what was causing the conflict. 9ad7d1a Adding basic unit tests for type/user by DavidS from #948. 038b9c8 Fixing #923. Resources that are collected on the local host are no longer marked as not exported. 5886d37 Applying patch by whaymond_home to further fix part of #896. 072b03e simplify PluginsMount a012849 Updated tests for http_enable_post_connection_check configuration setting. 4d4abd3 Better test to match the behavior of the code. 24cacdb Fixed test case for http_enable_post_connection_check f94d6d3 As per lutter; augmented fix for #896 to be configurable and defaulting to validate the server certificate, honoring CVE-2007-5162. 8eecbe5 Fixing another failing test I somehow missed in my last big commit 88304cc Renaming @model to @resource in a provider 75647ee Fixing a couple of tests that were failing on a different platform or with a different version of ruby 811fefa Fixing #892 -- filesystem mounts are no longer remounted. dedc56a Fixing #527 (rewrote service tests), #766 (services only restart when they are running), and #918 (service tests fail when hddtemp is not installed). 421b3fc Another backward compatibility patch, this time helping with a new server and old client bbf8a8b Making a few changes to the transportable class to enhance backward compatibility 11ae473 Theoretically, this patch is to fix #917 (which it does), but there were enough problems fixing it that I decided something more drastic needed to be done. 8127397 Fixing puppetca so it passes its tests, duh. Apparently wyvern's patch broke things a bit and I was stupid enough not to run the tess right before accepting. 2282046 Adding a top-level ResourceReference class that everything else can use to canonize how we refer to resources. Finally. c6d1746 Fixing the first half of #917 -- the ResourcReference AST code now correctly finds the resource. It's getting lost in the configuration translation, though, so I need to fix that, too. 6c1d8d3 Applying fix to xmlrpc client tests by Matt Palmer 6b2c0d8 Fixing the error message as requested in #893. 1b2142b Applying patches from #823 by wyvern c7cd7ec Fixing the markup on the pkgdmg provider so it is a bit better 1e6ba6f Fixing #781, from what I can tell. I'm leaving it with no tests for now, since it's a very small chunk of code and it's *insanely* difficult to test this kind problem. 5d30ea9 Fixing #810 -- I catch the error and prefix it with something a bit more useful. 4e52ffc Fixing #796 -- the fileserver can now start with no configuration file (it creates both default mount points if it does) and puppetmasterd no longer requires the configuration file to exist. 168fa5f Fixing the asuser method in Puppet::Util::SUIDManager so that it correctly just yields if you're not root. It also no longer tries to set :uid or :gid; just :euid and :egid, and it once again sets :egid before it sets :euid, which is important because you usually can't change your group after you've changed your user id. 0ef6b95 Fixing #931 by keeping track in configurations of what transportable resources get converted to, so different names don't throw it off. a38b415 Fixing #927 -- rewriting the test to actually test what it's supposed to be doing and to skip the whole network connect thing. 7ff8ea5 Fixing the persistent and periodic schedule test failures by rewriting the schedule tests entirely. 18b4c3a Fixing #924 -- clearing the configuration cache before and after the test. 2cb1199 Fixing the breakage that I caused when I added the 'declared_feature?' method to provider features. 2d19ee2 Fixing #920 -- I have replaced the existing mount test with an rspec version. It's not perfect, in that it only tests the :ensure state, but that's where 90% of the behaviour is. c3dde68 Fixing #919 -- installed packages used for testing are just ignored, rather than throwing a failure. 47890f9 Fixing a test that was erroneously testing for the wrong feature 12ebbe2 Rewriting the tests for the package resource type, fixing #930. fc7f1b4 Fixing #921, mostly by just deleting the existing test. I had already migrated all of the tests into rspec but forgot about these tests -- they were only in the rails/ subdir because people kept not running the parser/ tests after modifying the Rails code. 9311bdd Applying patch by trombik from #756. b575d15 Integrating Matt Palmer's patch to provide a 'plugins' mount, fixing #891. The patch was ported to the current code by David Schmitt, I applied the rest of Matt's patches, and I then fixed all of the code so that the tests passed. 36c947e Fix #896 - Always disable DNS checking of certificate when making https connections. 3fb8e2e Applying the rest of Matt Palmer's patches related to providing a plugin mount. 7eb09ab Implementing the test for setting the Rails log level. 676efa7 Incorporating patch 20071030034736-6856b-6004090b3968cdbf7d366a03ee1c44e2160a3fe0.patch from womble, and rewriting and significantly enhancing the unit tests for the Puppet::Parser::Collector class; it should have full coverage now. There are no integration tests for it, so there's still no guarantee that it works at all, but hey, we're a lot better off than we were. 7f1b2d6 change up rails specs again with Luke's help 8de1412 Integrating most of Matt Palmer's from http://theshed.hezmatt.org/mattshacks/puppet/_patches/puppet-0.23.2/. a88891a Fixed #906 - Augmented Cert DN regexp check to work with Pound and Apache. c19d08a mock all use of Puppet[] in Puppet::Rails.database_arguments e69e0c3 fix spacing b435f04 fix socket argument to AR and add rails spec e53693e Hopefully fixing #698 -- fixing the markup for the pkgdmg package provider 7c36ae9 Adding patch 20071030035457-6856b-bd1c45ed5ecd753b2cb4f05347061f7245cc175a.patch from womble -- Force removal of directories during pluginsync 880a8e2 Adding patch 20071020020745-6856b-dbc63ff3f137a4039fb997b9978202d52f621e8c.patch from womble -- Fix some residual instances of /var/run fever 696f1fb Adding patch 20071020015958-6856b-69efa7868cf3df3f2a2da6fcfc3b794bbb532c7f.patch from womble -- Remove rundir from puppet.conf, and add a NEWS entry to document these changes 7a95017 Adding part of patch 20071020011907-6856b-05b59120fdb90ab4a5842f91613247b07206a4ba.patch from womble -- Fix for Debian#447314, by fiddling with /var/run/puppet. This does not accept the whole patch, because the change needs to be tested around other platforms. 38b970a Adding patch 20070927050018-6856b-7fa134180aceb9cee2e667630345f5f8467a9d0c.patch from womble -- Catch more retryable errors in the XMLRPC call wrapper 276034f Adding patch 20070927042000-6856b-38a0c82fd0a0d950937e7fe5a38b9901743402b3.patch from womble -- Recycle the connection more aggressively, to stop problems with clients that are newly requesting certificates 3bf7031 Adding patch 20070926235454-6856b-079fc12a9b63d59afd59aa205bc8bfeb350b097a.patch from womble -- Recycle the connection if we're presented with an EPIPE 0ebd99e Adding patch 20070926214630-6856b-edd313b08555033710c90a94d9d8beaf889d6cf4.patch from womble -- Fix spelling mistake in debian control files 7ed1c17 Adding patch 20070913032650-6856b-b1cca1c249415c6076ffcecb9df1525a728457c7.patch from womble -- Fix annoying database deletion error for ParamValue objects. 28430c4 Adding patch 20070913032546-6856b-0de200e8450920e7f712c54bf287ae43c7fda8af.patch from womble -- Only set dbuser if explicitly asked for d7b381b Adding patch 20070913011122-6856b-98bf03f09c8e19679390d73fdddc2e4d1273f698.patch from womble -- Add changelog entries for the pulled pgsql patches a7d75d3 Adding patch 20070913010926-6856b-eb64be3b5169b7af674388124b406a1db7470880.patch from womble -- More restrictive permissions on some puppet-related directories 407734f Adding patch 20070913005414-6856b-db5ea77e10ec6869ad01a4bd6483912c337f3a70.patch from womble -- NEWS for the ssldir transition 1486d39 Applying patch 20070913004017-6856b-cdbbba99de0b33b64874205a27833b5114fcc6b9.patch by womble -- Allow empty config settings 03c8ffd Adding patch 20070913003810-6856b-cdc8b2e8c6c46eb8d6d073f86291a0fc5a59f429.patch from womble -- Only set the hostname and password if we want them; this allows pgsql ident auth to work it's magic 035fa38 Adding patch 20070905004837-6856b-2e7b8d8595ee0883537620c46424a4bf6174dc6a.patch from womble -- Add an attr_accessor for @http#ca_file, since older versions of libopenssl-ruby only provides ca_file=, not ca_file 63b205a Adding patch 20070831053637-6856b-dd0fddab681485ce7cea0b57336d0c48fa33f7f8.patch from womble; updates changelog 72c0e7b Adding the debian directory via patch 20070831052721-6856b-b90bb56a4ed37ea420f10352a0a366068cddc7e4.patch from womble 7efe24f Fixing #882 -- I just added a quick hook to the Master handler again; we need a better long-term solution, though. 56aad69 Patching a bit for #804 by making the maximum much higher UID and making it tunable, but it has not gone away yet. a525ab5 Fixing a couple of tests that were failing because of the environment changes. 6d74ddd Accepting a modified form of the patch from #885 by immerda. b745f04 Fixing #886 -- the problem was the I had changed the base class for Parameter, which apparently lost the 'nodoc' method for that class. dbe70a1 Added calls to endgrent/endpwent in util/posix.rb to fix #791. 7f504b0 Applying patch from #896 by whaymond_home, adding more certname aliases. 1cb40ec Obviating targets in interfaces; they now just generate a warning. eee9f5e Adding more tests to the redhat interface provider. It no longer uses the :target parameter (which I'll be removing in the next commit). 1a4e4fb Rewriting the sunos interface provider to manually parse and generate, rather than using ParsedFile. This should fix #777, and has from what I can tell. 8cbe8bd Adding unit tests for the sunos interface provider. 3d2e1a5 Adding some unit tests for the interface type before i go messing around with it cca613d Fixing the first part of #787. Not all collections were being evaluated on the first pass because they were being deleted from the collections list during evaluation, which caused some to get skipped. This commit fixes that problem, which helps in the trivial cases where the collections are in the same scope. I expect it's still broken for more complicated usages. 96b3cde Applying patch from #834, apparently fixing a problem with bringing up alias interfaces. 9472eef Removing the bootproto and broadcast attributes from the redhat interface provider, since they are not needed a7a46af fixing the path to the spec helper in the exec test 3d31dc8 Fixing #762. The main problem was that I accepted the patch in #744 which broke the templates. In the process, I also added test code for the redhat interface provider and rewrote how parsing worked to make it more testable. 8ecdfc2 Moving the exec test into the types/ directory 94e63ad Fixing the last failing test relating to the environment changes 7fe5bfc Fixing the exec spec so it works when non-root and is a bit cleaner 8cc07ad Using the Environment class to determine the default environment, rather than plenty of different places having the logic of how to determine the default environment. 53008e5 The Puppet settings instance now validates environments when you set an environment. 9e5fc76 Fixing #911 and #912 -- there's a default environment (development) and you have to specify the valid environments for your site. cc88441 Removing the manual ssldir setting by David in 59626cb3907d36e4fd762277daa76f523faf0908 1bf3999 Fixing a failing test from my fix for #446 -- I had changed the behaviour of Resource#override_parameter unintentionally. I've corrected the comments so it's clear why the original behaviour was there. 3f0b250 Fixing a few test suites that passed when run as part of the suite, but failed when run individually. The problem was that I changed lib/puppettest/support/utils to have a separate module and I didn't test the individual files. 4bd7b6f Fixing #896 by applying DerekW's patches, with slight modifications to fit coding style. 8ad2732 Fixing #446. I ended up largely not using porridge's patch, but only because the code (and my coding style, to some extent) has changed so much in the last few months. Also, added specs. 1b78f57 Add Exec{ logoutput=> on_failure } 2b14f62 Reverting the changes I'd made toward removing the global resources. These are commits: 9cf477b Applying fix by Jeff McCune from #905 edc4b1d Fixing a SimpleGraph unit test so it doesn't depend on hashing. c19835c Fixed most failing tests, but there are still over thirty failing. 4afbaa6 fix #903: add patch from hrvojehr 32d9afc tests for #903: fail when no logoutput is generated on failure 9290cc8 Modifying how default resources are created; they are now added to the configuration by the master client, rather than by the creating types. ffb4c2d This commit is the first run at removing all global references to resources. It deprecates the class-level [] and []= methods, used for so long to provide closure behaviour but now unnecessary with the node configuration's ability to function as a resource container. b65fb83 Fixing a parser test -- really, just removing tests that belong with the AST classes rather than in the parser. 72510bf Fixing #800 by refactoring how configurations are retrieved from the server. The real problem was getting all of the validation done before any caching, which required a good bit more refactoring than I expected. dd7caa7 Moving some compile tests to the spec/ directory, and switching the node scope to no longer be lazy evaluation, just like I switched 'main'. When I made all of these classes and nodes lazy evaluated, I should have decoupled my real goal (using resources to evaluate them) from the idea of lazy-evaluating them, and this basically does that. 47a2605 Changing the 'main' class to no longer be lazy-evaluated. It was getting evaluated after node classes, which caused even stranger ordering issues. a4e8f1c Adding a memory terminus for facts, which is really only used for testing 3851415 fix dependency on $HOME, which causes massive failures when running without environment 59626cb fix failing CA test, when testing with incomplete setup (no ssldir, no DNS) a6ad326 fix the underlying dependency on the environment in the cron type d48ee3e fix crontests depending on ENV[USER] by using Etc.getpwuid(Process.uid) instead 8fe892d fix a testfailure when running spec tests as root 445c29c fix #872: improve property(:content).insync? 5726412 tests for #872: check interaction between "replace" and "content" 61ef289 fix #815: add :main to all use() for :reporting and :metrics 418bc21 remove obsolete runners variable a535cbb Commenting out the time debugging I was using 3f583dc Adding unit tests for the module that handles the logic around mounting and unmounting. This includes a fix for bug #761, which required a different regex for Solaris. 8f04446 Fixing the 'mount' tests so that they no longer modify the local system and they run fine as non-root users. ba19989 Switching the class resource evaluation to only happen when using :include, not (for example) when evaluating node classes. cf75168 Classes once again get evaluated immediately when the 'include' function is used, instead of being lazy-evaluated. 4441052 fix #891: create a plugins mount which collects all modules' plugins/ subdirs dfe774f Switching the base class for the Relationship class. It was previously using the GRATR::Edge class, which had wonky overrides that dramatically slowed down sorting (its hash mechanism hashed the source and target so that edges with the same source/target got the same hash, which we actually don't want any more). 4194526 fix #760: property_fix has to be called after creating a symlink b250416 fix #731: add exported=true to collect_exported 1ffcce0 Splitting the puppetd tests into two tests. It is still not a very good test, but I do not know of a good way to test this, really. 065a1d0 Switching the graph base class from GRATR::Digraph to Puppet::SimpleGraph, which should dramatically enhance performance. It should be largely functionally equivalent, with the only difference being that edges are no longer deduplicated. 3f21e93 Adding a new graphing base class, because the GRATR stuff is just too slow. This class has just about no iteration, and vertex deletation is dramatically (as in, 1000x) faster). Here are the results of some very simplistic graph operations: ef99495 Caching the 'parent' value, which resulted in a drastic performance increase. 826efe8 The configurations should now be functional again -- file recursion was previously not working, because the relationship graph was setting itself as a resource's primary configuration, which caused it to try creating its own relationship graph. db293cf Fixing a bit of indentation and commenting in the xmlrpc/client file 956daa5 This won't be perfect by any stretch, but put in a moderately reasonable autotest config file. c7b36b7 One significant step closer to getting autotest running properly on the Puppet specs. Created a spec/lib/monkey_patches/ directory for holding patches to RSpec functionality. Extraced 'confine' and 'runnable?' support from the local copy of RSpec (spec/lib/spec/) and now load them from the monkey_patches/ directory. Fixed a bad include in one of the specs. Made it possible for the gem-installed spec binary (which autotest calls) to be used with Puppet. Imported the Autotest::Rspec class, created a PuppetRspec autotest class, added a discovery.rb file for autotest to pick these up. 6585835 Adding patch from #879 by tim d03f68e Changing the test/ classes so that they work from the main test/ dir or from their own working dir, like the specs do. This was just a question of changing how their libraries are loaded. c0a07ac File serving should work now, both recursive and single files, across modules, local file system, and the traditional file server. 54fc80d Exceptions on requests are now captured, exceptions are serialized, and exception text is passed back via REST. e7bfe0b Finish serializing successful results (via calls to to_yaml, etc.) for REST handlers. Refactor request building in REST handler specs. d28a904 REST handlers now properly returning 200 status on success. 1746751 Adding post- hooks for :find and :search in the indirection class. 09f9c3c Adding the calls to the authorization hooks in the Indirection. b874751 Renaming the FileServing TerminusSelector module to IndirectionHooks, because I'm going to add some hooks for transforming returned objects. de5d91e Renaming the :local termini for metadata and content to :file. 7fa99b0 Link handling is now in the file serving classes. This was done by putting all of the functionality in the Content and Metadata class (actually, in a new base class for them). 688fcdf Adding searchability to the fileserving termini, using the new Fileset class. 393a3e8 Adding a Fileset class for managing sets of files. This is the new server-side for file recursion, and I'll next be hooking it to the fileserving 'search' methods. This is basically a mechanism for abstracting that search functionality into a single class. b2b8f75 Adding authorization hooks to the file_server and module_files indirection terminus types. Both hooks use the fileserver configuration, but the module_files hook only uses the 'modules' mount. 8f827ff Renaming the 'mounts' terminus to 'file_server', and renaming tests accordingly. 08099b7 File serving now works. I've tested a couple of ways to use it, and added integration tests at the most important hook points. 264331b Partial work done for ssl certificates. ec39672 Adding this test stub that's been sitting around in my repository for a while. fc60751 I've now split the file-serving termini into two separate types (in addition to Rest): A local terminus that just uses direct file paths, and a mounts terminus that uses the file server to figure out what the path should be. 64c6700 Fixing all of the classes that I just renamed, and adding the TerminusSelector module to the File Metadata indirection. 56b83fe Renaming the file serving indirection termini to match the standards I set in the TerminusSelector. 33d7dc0 I'm working on making file serving work in the indirector now, so I added two abilities to the indirections: Models can specify a module to extend the indirection instance with, and indirections will use a :select_terminus method, if it's available, to select the terminus to use for finding. (It's currently only used for finding, not destroying or saving.) 8156185 Renaming the file_serving/{content,metadata} indirections so that they make more sense in the REST API, and creating stub tests for the indirection termini. Now it's on to create the rest of the tests for them. 2718b63 This is the first mostly functional commit of the new file serving structure. The next step is to hook it up to the indirection so we can start writing integration tests to see if we can actually serve up files. e1dd5dd Adding spec stubs for authorization in the indirection e69a50a Fix test which is conditional on mongrel installation. 8bf5196 Oops, forgot this file in my last commit. d0bd48c Adding the first pass at modifying file serving to work with indirection. I've split the fileserver handler into four pieces: Mount (which so far I've just copied wholesale), Configuration (responsible for reading the configuration file and determining what's allowed), Metadata (retrieves information about the files), and Content (retrieves the actual file content). d2b891f More specs, fleshing out the returns from REST e5921c5 getting more fine-grained with the response specs -- the target is always moving. 705f76f Argument passing now supported on {webrick,mongrel}+REST. ce34968 Make the actual runtime be more robust when mongrel is not installed. 6cd0f37 Make it possible to run all tests even if mongrel isn't installed. Shouldn't "confine" produce some output when running spec? Who knows. 216dd8c Refactoring, argument processing for model methods. abbc824 Tweak to move model lookup functionality into the Handler base class where it belongs. Robustifying the request sanitization a bit more. 2a497ff Refactored to use a Handler base class for server+protocol handlers. Finally eliminated dependency on Puppet.start, etc., from WEBrick HTTP server class. {webrick,mongrel}+REST now support request handling uniformly; need encode/decode next. 6ab78f6 Inlined the controller, eliminating a class. Mongrel+REST has the right bits for request handling prior to the encode/decode/exception-handling bits. Refactored to make the common logic extractable to a base class. b8c877c Registration now built for {webrick,mongrel} REST handlers. 3c370b3 Going back to each server+protocol object being responsible for only one indirection, as the REST vs. XMLRPC models are different enough that the object must register itself on initialization and handle the request when it comes in. c06edda First pass through initializers of {mongrel, webrick} REST handlers; hooks into Indirection to look up models from indirected names. ab4c7fa Minor tweaks to make the ::Server initialization a bit more robust. Fail on unknown HTTP Server types; fail fast. 099c546 Finish front end of delegation to server+protocol helper classes ("handlers"). b1d6223 Bringing in initial handlers for server+protocol pairs. a815f78 Reorganizing the file structure for indirection terminus types. ba95202 Partial support for building Handlers for all handler-protocol pairs. ef8ebe0 Implementing address & port support for new webrick server. c34efbc Hooking up address/port support for the various servers w/ specs. Still need to start up a webrick server w/ address + port (this is far too incestuous with Puppet lib & Puppet.start at the moment). 9a179ec trivial: WEBRick -> WEBrick, to be more consistent with how the WEBrick ruby classes are named. e56406f Implementing listening state tracking for webrick and mongrel. ec71e05 More unit specs for mongrel and webrick; more code to make them work, yo. 31384fe Pushing functionality down to webrick/mongrel classes now; cleanup in the base server / http server classes + specs. 694f98b Fixing failing tests, including making the debian service provider test work on non-Debian platforms. 29feac0 Translating the report handler to an indirected model. I've provided backward compatibility with the old handler. 74d77f7 Adding version handling through most of the indirection work. This counts as the first commit where configuration compiling actually uses the caching correctly according to the application model. e90191a more stuff for the interim commit 10039b9 interim checkin of network stuffs 512096a Fixing some small spec failures resulting from test fixes. The problem was in how TransObjects were converted to RAL resources. (Committed while flying over Arkansas.) d24c1cc All tests should now pass again. ec58355 Fixed #819. Applied patch provided by matsuu. 7ac7872 Fixed #822. Applied patch provided by DavidS. fc9c850 Adding support for versions and freshness-checking to the indirection layers. This should hopefully enable the different application models we need in our different executables. 1befcc4 Homing in on a clean separation of concerns for a low-coupling, high-cohesion "server" model that will handle REST and/or XMLRPC on webrick and/or mongrel. 5c32c8e Somewhat better documentation of the :absent field feature in fileparsing. d055cbc Make it apparent that absent fields in a record have a value of :absent, which is different from what appears in a line. b6dc1ae Trivial tweak on HTTPServer module file a7d220b Moving the webrick/mongrel "servers" over to HTTPServer module instead of Server. Using Server as the master class for client connections. Server (former RESTServer) will instantiate the appropriate subclass based upon Puppet configurator setting. There are now tests broken in the network section which I can't seem to figure out yet. Not a happy place to be. cdaad28 Fixing error thrown when the end of the file is encountered unexpectedly 7d7e428 Removing obsolete comment f084d83 Another round of test-fixing around the changes I made to the configuration system. 'puppet' itself still works, even with -e, but I expect that puppetd and puppetmasterd are broken, and there are still quite a few broken tests because the default fact store can't write but that's the default behaviour for a networked configuration master. 9c58c47 Adding a :code setting for specifying code to run instead of a manifest, and removing all of the ambiguity around whether an interpreter gets its own file specified or uses the central setting. d35cd94 Making "null" the default node source, so nodes are at least created easily 0e336bf This commit is focused on getting the 'puppet' executable to work. As a result, it involves a lot of integration-level testing, and a lot of small design changes to make the code actually work. 1fa5912 Adding the integration tests to the Rakefile for spec, fixing the integration tests, and extending the Classmethods for the indirector so that indirected classes can set the terminus class and cache class. a93db87 Adding another test to the ldap node source -- we make sure we throw an appropriate exception if a parent is specified but we cannot find it. 9984a35 Fixing some terminology so some ldap tests are easier to read. 6acde71 Switching the indirection from using settings for configuration to requiring explicit configuration. This means that if you as an application developer want to use a different indirection terminus then you have to specify it; something like: 8ba3a70 Fixed #838. Applied patch provided by DavidS to add more robust update functionality to the dpkg provider. f41c843 Fixed #837. Added freebsd service provider by trombik. 533ce4b Fixed #855, but I didn't add any tests. 19ad238 Fixed #827. Applied a form of the patch provided by porridge and wrote a test. 29accba Minor tweaks. 2412199 Allow for multiple REST servers to be active; some terminology changes in spec; fleshing out more behavior, implementing. 102ad23 Added .listening to REST server, handle listen states and transitions. 187d910 Spec'd a reset() method for clearing out known routes. Uses the unregister method so that any hooks there will be run. Probably a violation of YAGNI, but I'm willing to suffer it :-) fd841b3 Updating first portion of the Network RESTServer spec with example code, getting the added examples to pass. 9236179 Attempting to reproduce and fix #829 by applying patch by Paul. I could not get a test to show the exception, nor could I figure out how the coding bug could have actually had an impact, but it's an innocent-enough fix, so I'm fine applying it. e5c623e Fixing tests for the Configuration object, since I added the any_failed? test to Transactions. 938f051 Fixing #817, mostly using the patch by DavidS. I could not directly use the patch because I have refactored too much. fd11603 Removing the Id tags from all of the files bb3b3ce I finally tracked down the problem that was causing providers to sometimes suddenly disappear and thus tests to fail -- Kernel.require was not loading the normal ruby path (e.g., 'puppet/type/cron'), so if someone else loaded that then it would replace the in-memory type with a new one, but that new one couldn't load its own providers, because the Kernel would ignore the providers, thinking they were already loaded. 782bc4d Fixing the yaml path so that it is correctly created for puppetmasterd. 7c8fc8b Fixed #854. d4afe39 Fixing #813 -- empty configurations again work. 5d50ca7 Fixing #814 -- when files are missing, the exceptions should now be more reasonable. 1be1db9 Updated CHANGELOG. 0b8893b Fixed #832. Added the '--no-daemonize' option to puppetd and puppetmasterd. The default behavior of 'verbose' and 'debug' no longer cause puppetd and puppetmasterd to not daemonize. b45a7ca Adding more behaviours to the Puppet::Module spec, and fixing some bugs in the process. 3f90ddb Interpreting "hidden" class from spec drafts as a REST Controller. This name, functionality, and/or location in the tree is subject to change, but it's down now somewhere so we can move forward on it. 861c21d Added partial spec for the serving of REST information, as well as some client-side REST terminus behavior. 8722e43 Use external helper script to talk to yum; should avoid any more trouble with "yum list". Fixes trac #836 1174d99 Fixed a failing test where we presumed that non-string Fact values would have type preserved across a P::N::Client.master.facts call, which is not true. 7fe18e3 Fixed a test which was secretly sneaking off and pulling certs from ~ if they were there: Added set_mygroup method, removed duplicate setme method. Included PuppetTest in the XMLRPC servlect test. fa643e6 Adding more indirection termini, mostly focused on caching information in yaml. 938b918 Adding cache support to indirection. If you have a '_cache' setting, then the indirection will use the value there as the name of the cache. 06ad6a3 Updated the configuration doc to more clearly explain where puppet.conf is expected to be by default. c8d02bd Fixing ralsh to use a configuration instead of a component ffaa8ce Demoting the "file does not exist" log to debug from notice c3c3e51 Fixing a small problem with the mailman type f8ab62b Renamed princs to principals in the k5login type. 6079348 Added k5login type written by Digant Kasundra. This is for ticket #759. 2e33061 I changed the Terminus class to switch camelcase to underscore-separated words, e.g., FactStore becomes fact_store. d6fd60c Removing obsolete fact stores and node sources. The functionality has been moved into the indirector. cdc8ea6 Taking a first stab at moving configuration compiling into the indirection system. There are still quite a few unanswered questions, the two most notable being embodied in unimplemented tests in the Configuration Code terminus. c40da33 Adding a "memory" node terminus, which will be used by 'puppet' and the Cfengine 'module_puppet', since they need to set up the node specially with classes and other weird things. 1e7c648 Fixing the spec for the checksum terminus to match the changed design in the previous commit. 048464f Adding my first integration test, verifying that checksum interaction behaves as I expect when interacting with the file terminus. 84146d0 Adding the first version of checksum support, which will acquire the behaviour of FileBuckets. 3a18348 Renaming the 'Puppet::Util::Config' class to 'Puppet::Util::Settings'. This is to clear up confusion caused by the fact that we now have a 'Configuration' class to model host configurations, or any set of resources as a "configuration". e552c83 Adding the base file terminus. This will, at the least, be used as the back end for filebuckets and the certificate authority. 86dde63 All tests now pass in this configuration branch, which means it's time to merge it back into the indirection branch. 60cd6a7 The structure for handling resource generation is now in place, which means I'm over the hump in developing this branch. a666995 Adding the last tests for the ldap node terminus. I managed to forget the tests around the main find() method. ebe7290 All indirections are working, and they have all been migrated over to the new organization. Where we would have previously had an 'ldap' node terminus at puppet/indirector/node/ldap.rb, we would not have it at puppet/indirector/ldap/node.rb, and it would be a subclass of puppet/indirector/ldap.rb. b9dc6cb It looks like the new indirection setup is complete. 02275f0 Adding automatic association between terminus subclasses and the indirection they're working with. It looks like I'll be moving terminus registration to the indirection rather than the top-level Indirector. da0555d Adding the first top-level terminus (yaml). It works and is tested, so now it is time to migrate the Facts YAML Terminus to use the / file structure instead of /. 0a48e5f Moving the Puppet::Indirector::Terminus class into its own file and adding a spec for it. 7e2ff4b Adding a couple more tests to the indirector, talking about terminus registration. I am about to change how loading is handled, so that individual termini are declared as normal Ruby classes. 7740cd4 The indirector specs now all pass. I think I need to add a few more specs, though. 4e8b671 The unit tests for the newly-resurrected indirection class now work; all we need do is fix the indirector module tests. 8212f88 Fixing all existing spec tests so that they now pass given the redesign that Rick implemented. This was mostly a question of fixing the method names and the mocks. 944cd0e Whitespace and comment commit. 46d6906 An intermediate commit so I can start working on a different branch. The file recursion code actually works for the first time in a painful while, but there are still some quirks and design issues to resolve, particularly around creating implicit resources that then fail (i.e., the behaviour of the create_implicit_resource method in Configuration). e90a51f More spec and indirector updates. 129cce8 Finally, some progress. Closing the loops and delegating registered class calls out to the actual Terminus. a6c4041 Reworking the Indirector code. Continuing to fight the classgen and instance_loader "utilities". 9fa2628 This is basically another intermediate commit. I feel like I've gone too far down the rabbit hole to turn back now, but the code is clearly getting more centralized around the Configuration class, which is the goal. 19e0493 Updates to indirection stuffs. Making a better spec and migrating to it. b3c8cdb Configurations now set a "configuration" instance variable in resources that are inside a configuration, so the resources can interact with the configuration to get things like relationships. f17f19d The whole system now uses Configuration objects instead of ever converting the Transportable objects into a tree of components and then converting that into a graph. This is a significant step, and drastically simplifies the model of how to use a configuration. The old code might have looked something like this: f014d73 Partial fix for #772. The SIGHUP now produces a EOPNOTSUPP instead of NameError. 3ccf483 Removing the completely obsolete passwd2puppet and the obsolete component.rb 3632926 Moving the resource container behaviour to the Configuration object, rather than the base PGraph class. I expect I will just do away with PGraph, but for now, I am at least going to keep configuration-related code in that class. 43f22a2 Adding a to_graph method to TransBuckets, so that the buckets can directly generate a graph, rather than having to first convert to RAL types and then have them convert to a graph. This allows us to make it so components do not need a @children array at all. This was all done because I am having the "already a parent of" problem again, and I have gotten far enough that it is relatively easy to just make this problem go away once and for all. a6fe700 Another intermediate commit. The node and fact classes are now functional and are used instead of the network handlers, which have been removed. There are some failing tests as a result, but I want to get this code committed before I massage the rest of the system to make it work again. 1459c50 Adding setup/teardown hooks to rspec, so we can use test/unit methods 3b3065b Refactoring the feature support so it loads libraries when a feature is asked about, rather than when it is defined. 65c1501 The Node handler is now obsolete. Node searching is handled through the indirector. I have not yet added the tests for the node handlers themselves, which is next. 1638089 Fixed #797. Removed the warning message about specifying 'enable' or 'ensure' when initializing a service. 6f9a444 Fixed #784 by applying patch by vvidic. 5aa4440 Doing an intermediate commit so rick can look at the work I have done so far. bb69a1f Renaming the instance loader method to "instance_load". It was previously autoload, which could class with Kernel.autoload. 6a105c4 Fixed hdiutil syntax for ticket 812 19a748b Removed TYPE token, replacing it with CLASSREF token, in the grammar and lexer. Updated CLASSREF token regex in the lexer. ca9c48d Removing extraneous logging from the node handler 041393d Fixed #774, which fixed fully qualified collection statements 6700adc *Finally* fixing the tests that were failing around users and groups. The problem was that the autoload tests were somehow clearing all loaded classes, including the providers. This is fixed now. 9af79f1 Fixing some failed tests. Mostly cleanup. Next is to make all of the user tests pass again, dammit. 50874b2 Fixing a path test. I have now made the path stuff a lot cleaner, but it apparently broke this test. ca57c79 Fixing #801 -- resources that have changes when running in noop mode do not record that they were checked, so that they will be scheduled on the next run. This is a somewhat murky solution, but considering that no one had submitted this bug before, I expect it will not hit many people. caad11a Fixing some broken tests in the master client, and adding a test for #800 but it is unfortunately disabled because we cannot realistically fix it using the current design. It will be easy after the REST refactor, though. 7abc78a Fixing #795 -- configuration elements now make sure all file paths are fully qualified by prepending the wd to unqualified path names. 4212f9c Fixing #802 -- tags are now applied before parent classes are evaluated, so parent classes can use tagged() to test if a node is a member of a subclass. 4104bd3 Fixing #807. The exception handling should more closely resemble how it used to be done. b7f4244 Renaming some ast resource classes and files so they make a lot more sense. 653c151 Fixing #806. Resources correctly look up their fully qualified definition type, just like resource references do, which causes the resource and reference to again agree on the full name of a given defined type. 40e3b37 A small change to the indirector, moving it to a module instead of a class. I still do not really know how i will use it, though. a5539cd Adding my indirector class before i rewrite it. I am probably not going to keep any of this, but i wanted to store a copy before i got much further. b0a9475 Flipped the switch so that compiles now return a Configuration instance instead of pre-extracting the configuration. 11b127b Successfully modified all tests and code so that all language tests pass again. This is the majority of the work necessary to make the separate "configuration" object work. 3b2efd2 We now have a real configuration object, as a subclass of GRATR::Digraph, that has a resource graph including resources for the container objects like classes and nodes. It is apparently functional, but I have not gone through all of the other tests to fix them yet. That is next. 0faf76e More refactoring. I have removed a few more extraneous methods from Scope, mostly just pointing directly to the compile, and I have begun (but commented out) the move to having resources to model each of the classes and nodes, in addition to the definitions. This will, again, enable a real Configuration object, and it will enable class versioning and similar features. 9d70b97 Removing the Scope#setresource method, since it was essentially redundant. The work is done in either AST::ResourceDef#evaluate or Compile#store_resource. b021587 Doing a small amount of refactoring, toward being able to use Parser resources to evaluate classes and nodes, not just definitions. This will hopefully simplify some of the parsing work, and it will enable the use of a Configuration object that more completely models a configuration. 25f6d7c Deleting old documentation that somehow made it back into the tree in the switch to git, and refactoring the evaluate_classes method on the compile object so I can use resources as intermediaries, thus making classes do late-binding evaluation. 62806bb Renaming the file containing all of the configuration defaults to "defaults.rb", since I am going to create a separate "configuration" top-level directory to contain all of the classes related to managing the configuration for a given node. 6832a4b Fixing some failing unit tests. 2625eb1 Making a couple of small bugfixes in the configuration subsystem 1de5ae0 Adding support for providing a diff when files are being changed. Currently uses a local diff binary, but could easily be changed to use the ruby diff/lcs library. Modified puppet and puppetd to automatically show file diffs when in noop mode, but can otherwise be enabled using --show_diff. This only works when running interactively, because the diffs are printed on stdout. 11081ce Multiple environment support now works, and I have even tested it in real life. This commit is mostly a bug-fix commit, resulting from the difference between real-life testing and unit testing. 9ea8e6c The fileserver now uses an environment-specific module path. I also made various bug fixes around the network tree. 51ff72c Adding a bit of testing for node names. 4e9c631 Moving the node tests to rspec, and cleaning up the spec of the node, especially WRT the environment. a8f2a33 Moving the node tests to rspec, and cleaning up the spec of the node, especially WRT the environment. 9df4fd1 And we have multiple environment support in the parser. The only remaining piece to make this complete is to add multiple environment support to the fileserver. I also renamed Configuration.rb to Compile.rb (that is, I fixed all the classes that used to know it as a configuration). ba3a861 Removing this test for now; I do not have time to port it from test/unit to rspec 37f0eed Renaming the "configuration" object to "compile", because it is only a transitional object and I want the real "configuration" object to be the thing that I pass from the server to the client; it will be a subclass of GRATR::Digraph. deb0107 Oops, created a test directory in the main spec dir, rather than in the unit/ subdir 3030d3e Modules are now tested with spec, and they now can handle environment-specific module paths. ab54183 The config class now has support for add an environment to its search path. Now I just need to go through the whole system and use the search path in addition to the parameter name itself. c6e201c I have added basic support for a search path, altho not yet with any ability to manipulate it. All config tests pass in both the old tests and the new ones, so it is time to add the hooks for manipulating the search path. 520aaaf Adding some rspec tests for Config.rb, because I am planning on significantly changing its internals and the current tests, I think, will be harder to migrate than just writing rspec tests from scratch. 724fef1 Everything up to the parser (and the Modules) is ready to support multiple environments, including the parser having an environment setting. I have also created my first spec-based tests, for the interpreter (and deleted the old test/unit tests). 3d68ed6 Oops, left out the spec rake file from the main spec commit 58494cc Building a stand-alone spec directory for creating the new spec-based tests. d59315a Adding the second half of the rspec upgrade -- apparently the "git add" thing I used did not remove the old files, only add the new ones. 5601ecf Upgrading rspec to version 1.0.8. This only includes the contents of the lib directory, and even then only the spec-related stuff, not the autotest stuff. 7c4d39e Adding environment information to the client fact list. The environment is retrieved from the normal Puppet configuration, so it is set via puppet.conf or the cli, rather than being a normal fact. b599862 Fixing the integration test between interpreter and configuration -- the interpreter was not passing on that the config should use ast nodes a54fa7e Sync to latest specfile in Fedora 8b3361a The last commits before I actually start on the multi-environment support. There are still failing tests, but apparently only those that are also failing in trunk. f1727f1 Adding the topscope metadata to the configuration being returned to the client, just like it expects, and fixing how the resource handler calls the master type. efcd1e8 Fixed CA race condition (#693) 4eb87ed A round of bugfixing. Many more tests now pass -- I think we are largely down to tests that (yay!) fail in trunk. 2a4e101 All language tests now pass. I expect there are other failures elsewhere, but I want to commit this before delving into them. My method for fixing the tests was to do as little as possible, keeping the tests as bad or as good as they were before I started. Mostly this was about changing references to the interpreter into references to the parser (since that is where the new* methods are now for ast containers) and then dealing with the new config object and its relationship to scopes. 6467c21 The first pass where at least all of the snippet tests pass. I have unfortunately had to stop being so assiduous in my rewriting of tests, but I am in too much of a time crunch to do this "right". The basic structure is definitely in place, though, and from here it is a question of making the rest of the tests work and hopefully writing some sufficient new tests, rather than making the code itself work. a846ea9 The new parser configuration object works now, but the rest of the compiling process is hosed (although the parser itself should still be fine). 282ec89 Fixing the spec library so it correctly can see its version 1527f4a Adding node caching, so that node sources are not spammed during file serving and such a953954 Keeping the node names in the node object, so that they are available to the interpreter 297dabb Refactoring a small part of the interface between the configuration handler and the interpreter. 901ae68 Requiring mocha in all cases in the test tree 70dffdd The new configuration handler looks to be ready for usage. Now I just need to convert the interpreter to use SimpleNode objects, then continue with the Configuration object. aabad8e Adding the necessary name/ip fields to the node methods 65559af Adding a "none" node source, which will be the default node source and will just return an empty node. 2ff15c0 Added shortname support to config.rb and refactored addargs 90a9d09 Finalizing the node handler. It now correctly uses the different node sources and knows how to retrieve data from those sources. Now I just need to fix the language stuff to use this handler instead of the existing node stuff. ec50484 Fixing documentation string on the file "ensure" property to remove the confusing mention of "exists" 58e3855 Added optional per-module lib directory. aab419b An intermediate commit in the work towards adding multi-environment support. 40491eb Merge /opt/rl/git/puppet b59d396 Revert "Updating more milestone names" 3e9ac59 Updating more milestone names ab42534 Applying patch by Adam Jacob to make external node tools able to handle command-line arguments 24e7b4d Revert "Updating more milestone names" 61a747f Updating more milestone names b5aefd4 Adding milestone names to changelog 7e4f270 Actually honour :namevar => true on newparam calls 01b21ae Removing extraneous debugging from crontab 6ab30eb Fix for setting global exit code ($?) in SUIDManager tests 0195893 Broaden assert_absent so that it thinks that :purged is equivalent to :absent 6a78648 Change the service name so that it is less likely to trip on a common word and spuriously fail e143cae trac #763: Make redhat provider default for CentOS (patch by jtimberman) d2f2bc0 Trivial mock cleanups ada960b Constants in provider/interface/redhat.rb are getting redifined as they are dynamically assigned, changing them to instance variables 8f05951 Changes to lib/ corresponding to test refactoring from r2759, was unaware that subversion only commited in the CWD 13f358d Highlight what I think is a problem in the test suite that I just can't solve 3de4829 Refactor SUIDManager tests to run without root, change SUIDManager's behavior to not silently fail when it's not root and fix all other tests that broke as a result. 5a25701 Upgrade mocha to 0.5.1, which gives much better error messages 5e8d71d Fix the ral:providers:host:parsed tests so they run successfully 9530df1 Updated to version 0.23.2 0d312a1 Updated to version 0.23.2 b84015a The last set of bug-fixes before the next release. This commit just fixes a couple of problems that resulted when I changed the Provider#initialize method to not duplicate its argument, which was necessary for ParsedFile. aaf5959 Adding test support for the other mongrel configuration header db0ffc7 Copying the "commands" and "confine" statements to the actual dscl providers, since they need to be there to determine where the providers are suitable. Otherwise base classes could unnecessarily affect how subclasses work. 5e419cf Fixing #749 -- environment settings no longer accumulate. Significantly adding to the cron tests at the same time, such that hopefully we will no longer have these recurring bugs. I now do every combinatorial of multi-line cron jobs, including doing them all in one file. There are, unfortunately, still edge cases, but maybe we will have some peace in cron space for a while, anyway. d121b1f Removing the code from #745 until it can pass some basic tests 1e6c2ba Adding syslog support by devdas (#745). 22e7b39 Fixing #751 -- the interface providers now have basic tests, at least to verify that prefetching and listing works. I think these resource types need to be largely rewritten, though, and they currently have no relationship to ifconfig, which seems strange. 7bda32e Fixing #731 - we are now correctly only collecting exported resources 3d629bb Fixing #730 -- mounts now call flush() before trying to mount a8bf96a Adding a file that should have been in a commit from yesterda 40e4d6f Fixing #735 -- gen_config now uses a single heading, matching the name of the process 97cd057 Fixing #314 and #729; here's the changelog: 72f2ac3 Apply fix for typo provided by Toshio Kuratomi (bz250870) 2a37c73 Removed stray debugger method. 5a5d241 DirectoryService provider for users and groups. Alternative to netinfo, as apple has indicated NetInfo may go away at some point in the future. It might happen in October. 08d8945 Fixing #734. The problem was that when I switched how the configs were parsed, I managed to lose the ability to keep values set on the cli from being overridden by values set in config files. 5eacd19 Renaming the linux interface provider to redhat 6841397 Applying patch by stick to the linux interface provider 877282e Undo previous commit, which was an error 81d690a Do not set any options if they aren't set in /etc/sysconfig/puppetmaster - otherwise we clobber settings from puppet.conf 36a3e4a Changes for 0.23.1 52e9fa0 Adding interface implementations, as written by Paul Rose 7547baf Adding a test for rails 1e11a1a Removing test that ended up being redundant 4b25750 Applying patch my emerose to fix #652. 87da172 Adding the requirement that the cert dn have /CN= in it, thus hopefully catching clients without certs 530d290 Applying a modification of the patch from Marcin Owsiany, allowing Mongrel to be a CA 64fba48 Updated to version 0.23.1 d3988cc Updated to version 0.23.1 2229dc1 Fixing #726 -- mounts can now correctly handle mounted but absent filesystems. 47b7058 Adding some code in an attempt to fix #728, but it is all commented out since I could not get it fixed in time for beaker 2e14ea4 Attempting to clean up the mount documentation as in #727. 7401ada Caching whether a given file or module has been loaded, because the loading was greedy and was causing files to get loaded every time a class or module was asked for 3f1b957 Fixing the mail aliases generated by the mailman list provider; it was generating capitalized list names 3f1c865 Fixing #725. I was apparently not deleting the alias I was creating to the components. 55014a2 Hopefully fixing #720 -- I added tests and a lame back-off system to give the child process time to write eacb06c Converting mount test to use mount everywhere instead of df 501e8c8 Adding the ability to specify relationships to classes, using Class[name] resource references. b9dd7ee The first round of bug-fixes in preparation for beaker 5d7c5c9 Adding documentation to the "test" script 4f34fb0 Removing the chdir from util.rb, I forgot that the directory often matters f2a1a10 Hopefully fixing #640, and maybe some warnings at the same time. I added a call to Process.setsid after the fork, and I chdir'd to /. fdd2d49 Fix #696. (patch by Jason Kohles) 90c8b8c Fixing #716 -- the package type was considering anything that was not "absent" to be installed, but that included "purged", thus the problem 0316bed Applying patch by DavidS to fix #711. 48755b1 Fixing #702, hopefully. As suggested, I switched to "mount" instead of "df" to determine whether an fs is mounted. f59ce4e Fixing #695 -- resource references will correctly serialize and unserialize in the db 53a469c Fixing #703, mostly. You still cannot do multi-condition queries, but you can at least query against any parameter, and matching any value is sufficient for a match, so the tags work fine. d5569bc Fixing #719 -- the filebucket docs now only mention filebucket, not pbucket d9a30a6 Trying to get rid of the warning from #724 e618065 Applying a slightly modified patch by Dean Wilson -- puppetca now exits with a non-zero code when it cannot find certs to clean. 49d8ef2 Guard the rpm command suitability confine better so we hopefully stop seeing all of the 'Command not available' errors f104dc5 Updating the docs to mention that you can use the file server with no server name cf25b25 Fixing some logging in cron 60ef578 Fixing the rest of #705, except for the env stuff, which I was not able to reproduce. 53c2f0a Fixing #691 -- I added "refreshable" features to the types that can restart, although exec does not have providers (yet), so I just made the docs a bit clearer 4c1a70c Reordering some of the type docs e0237d1 Removing notice about "import loop", which was happening constantly when autoloading module files 1d261bf Fixing error message when a parameter is getting redefined 554c23c Adding rpm as a specific command to :rug 54a5f77 Fixing #589 2c13d53 Fixing #468 -- fully qualified resources can now be specified as dependencies e88d694 Applying patch from #714 -- aptrpm now loads on RHEL c3290a0 Fixing the mailman provider so it correctly matches case. Apparently mailman helpfully autocapitalizes list names. 2086e07 Removing extraneous debugging 6ddbec3 Fixing the interpreter autoloading so that it correctly loads classes even when being loaded from a namespace f217fbf Fixing the instances method. It now works when there are already managed resources. edb1be2 Fixing the :check metaparam so it does not try to check unsupported parameters f1462cb removing the test for a method I removed yesterday e98edac Applying docs patch by David Schmitt from #713 7580657 Applying a version of the diff to the defined() docs from David Schmitt a4b94cf Fixing the first half of #705 -- matching no longer fails. I think this also fixes #648. d104d4b Having FileType instances automatically back their contents up to a filebucket, so it is much harder to lose content. This does not yet back up crontab contents, though. 17a830d Fixing transactions so that they do not flush resources that are in noop f570a5f Adding a maillist type, with support for mailman. It is not as flexible as I would like, partially because of how mailman is implemented (the "mailman" command is never in the search path), but at least it is working for mailman on debian. 2d3c920 Adding support for a "mailalias" type, with /etc/aliases support initially. I have not yet figured out how to best rebuild the aliases file when necessary. fdfe0a3 Adding line/file info to parsing errors in ParsedFile 9f685e6 Adding support in Property for declarating whether a given property type will match all @should values or just the first. c8801b7 Always setting a to_s value in authstore, so we do not get dumped objects e79828f Cleaning up a log message in the transaction 20b9060 Adding benchmark info to fact retrieval in the config client 7a71db8 Adding patch by Valentin Vidic to add the "+>" syntax for adding values to parameters e662c86 Fixing #621 -- plugins are now downloaded directly into the $libdir, and autoload looks for them there. You can now easily download any reloadable file to your clients. 7befe1b Changing some of the internals of autoloading so that there is a class-level method to query whether a given file has been loaded. eabe0d1 Fixing #710 -- you can now specify the rails_loglevel d36d0cf Fixing a typo in a log message 8807ac2 Changing "element" to "resource" in the documentation, which just aligns with a terminology change we made almost a year ago. f5f8949 Changing the log message when a resource type cannot be found 773f187 Ignore the pkg directory if it exists, and fix up a couple of tests that were erroring out, which also will help the confinement of package types a bit more. 1bcca31 Fixing #687. 8a7fe9f Applying patch by David Schmitt from #701. 4080077 The parser now throws an error when a resource reference is created for an unknown type. Also, resource references look up defined types and translate their type accordingly. 07f0519 Making sure that #686 is fixed -- I specifically included the Daemon module in the Puppet mongrel server, and I call daemonize on the Puppet class, rather than the Mongrel http server e8217ab Hopefully fixing #685 -- I added a wrapper around the call to getconfig(), so any timeouts will just throw an error and skip the run, rather than failing and killing the daemon. This is not the best approach, since really, each method should be wrapped, but it is sufficient. 60e5e10 Applying further tests to double-quoted hostnames by Valentin Vidic 266d37d Applying patch by DavidS from #697 to allow host names to be double quoted aa74135 Fixing #596 -- classes in modules now autoload d0680c8 Fixing the dpkg querying so that it works for packages that are in "config-files" state rather than just missing entirely. Also fixing logging so that the package version is visible, instead of a dumped object 8b14ef8 Fixing logging of module mounts; it was using the module as the name, rather than the module name 32e5bff Removing extraneous debugging 3ae3a4e Fixing #689, although I have not added unit tests. The problem was that a tag name was being removed, rather than the tag object itself. 19e180f Fixed #680 puppet should handle internet enabled image files correctly. c22e667 Applying patch by daikinee from #690. I was not able to reproduce the problems, but it did not seem to hurt anything, either. 50b8f96 Fixing #704 -- Puppet was not failing correctly when schedules were missing, I think c762c19 Removing the long-obsolete Element base class. The Parameter and Type classes no longer have the same base class. 0ff7827 Fixing #620 - class names and node names now throw an error when they conflict a627f46 Adding a reference to the LDAPNodes wiki page in the ldapnodes config item 0f4de4f Fix trac #684 - set exit code for status properly (patch by abnormaliti) 6b7d3aa Create the right puppet.conf; make sure old config files get preserved and stay functional ac36ddd Fix name of main section ec2d469 Rename puppet.conf to puppetd.conf 8013e96 Get rid of using silly macros in %install dc2a0bf Use single config file 3aafa84 Updating reference docs 55a512c Updating trac location for laeg 044968f Updating build files to support laeg ada4355 Updated to version 0.23.0 d8f4c53 Updated to version 0.23.0 049faf8 Updated to version 0.23.0 8844fca Changing the paths to match laeg, instead of culain. d79a788 Modified the fileserver to cache file information, so that each file isn't being read on every connection. Also, added londo's patch from #678 to avoid reading entire files into memory. 944e1f4 More updates to puppet-test 4bb0228 Updating puppet-test with clearer options around describe and retrieve fd15de7 Removing extra debugging from the interpreter 5043ade Updating error message during test failure. e5a9e24 More test fixes. I seem to be getting very close. bd444d8 Refactoring puppet-test -- it now supports specifying a fork level (so you can get multiple tests running in parallel from one host), and tests are modeled explicitly, so it will be easier to add new tests. a57e39d Added documentation for pkgdmg provider in the provider desc accessor as per request in #641 It stil might not be crystal clear, but should be better than the one liner it replaces. 01420ac Adding tracing to prefetch failures, and Fixing the environment support in the cron type (#669). fa39488 The other half of fixing the versionable stuff -- removing "latest" as a requirement. 0b1dbbb Applying patch in #572 by trombik 611e783 Fixing my stupid fix of Matt's work. I conflated :versionable and :upgradeable. I have now added back all of the "has_feature :versionable" lines. 4cb30eb Adding fink package provider. 099bf6c Fixing some failing tests. f96ec6d Updating the has_version work that Matt did -- the only thing he missed was that the :versionable feature depends on the :latest method, and when that is present we can safely assume that a package is versionable. Also, created the :latest method on the dpkg provider, as requested in #647. 3f6c413 Applying patch by trombik to fix #628. eb2326d Applying patch by trombik from #624. 2d07334 Modifying the CA server so that it will not send back a cert whose public key does not match the csr. We have been getting a lot of instances of this, so this should cut down that problem. 6e16d9f Fixing #578 -- Invalid certs are no longer written to disk. bf5d5d5 Fix #657: allow puppet URL's with no server; 'puppet' looks those up on hte local modulepath, whereas 'puppetd' goes to the default server 52f3f83 fixing the appdmg provider to load the package provider base class, and trying to clean up the log-file opening in rails 12adea8 Adding puppetrun as an executable in the gem, along with ralsh (#313). 2ed10d8 updating changelog for #641 bfb3852 Adding appdmg package provider from #641. f05464e Adding the output_file.close, as wyvern recommended 30ebbc9 Applying the patch by wyvern from #662. This should hopefully kill the client hanging problems. ac05442 Updating rrdgraph documentation with a pointer to the new rrd package. 029a191 Reverting the change I just made to the config handler; it was only there for testing. 2b1d478 Adding puppet-test, which is useful for performance testing afc3563 Adding patch by Ghislain from #670, with slight modifications. f6838f5 Fixing #548, and making functions support other rvalues, too, including other functions. f842cef Fixing #643 -- replacing the get_posix_field method with a more degenerate version that works even on broken systems 46252b5 All rails and language tests now pass again. All of the rails tests should now be in the rails/ directory, and I have modified resource translation so that it always converts single-member arrays to singe values, which means the rails collection does not need to worry about it. 6084e1a Fixing #673, but I have not written a test case for it. I moved all rails-related unit tests into the rails/ dir, because they keep getting missed. e8c6cd9 Fixing the yum provider, and fixing the unit tests so the failures people were experiencing will result in failed tests. This fixes #672. 4f7c650 Moving puppetd and puppetmasterd back to bin. Damn. Reverting the fix to #323. 23f986c Move ralsh and filebucket into /usr/bin 659792f Adding ralsh and filebucket to the rpm and the rakefile, and changing the url in the rpm 6be8b21 Modifying the check metaparam so that it just silently ignores metaparams and parameters, since they're uncheckable, and only tries to check properties e039f7b Fixing the type/title index for mysql 9ba878a Removing erroneous debug message b5523ff Trying to load ruby gems, in case needed libraries are installed that way, and fixing a warning in the provider f84ac7d Significantly reworking both external_nodes and ldapnodes support (see changelog). fc9a798 Fixing error about non-puppet protos 45f76c5 Significantly optimizing the database queries -- I am getting about 40% better times now. See http://www.madstop.com/optimizing_the_activerecord_integration.html. e32a1bd adjusting the rrd color stack as requested by thijs 469d999 Updated the CHANGELOG. 51b9fc1 Fixing (hopefully) the last two providers that had "resource.is" calls 77934f4 Fixing sun package provider 270cea8 Fixing #644 -- the install.rb file works again 8003320 Applying metrics patch from #659 by thijs 4910301 Fixing a typo in the docs c67e016 A few small fixes here and there, and the rest of the zones commit 399c37b Fixing #655 -- Solaris zones are again fully functional, from what I can tell 9bc236b Adding indexes for the rails tables 7c53aab Removing the indexes migration, since the indexes are now in the main db schema ef2698c Updating ralsh with more functionality: You can now perform work on the command line, with commands like "sudo ralsh file /etc/passwd ensure=absent". This makes ralsh a bit more interactive. cb5bccc Added to_s to the values to ensure the check versus the database will be consistent and booleans and references will check correctly. d78a7a5 documentation fix 3a2f3d5 Fixing mongrel test so it does not try to load the mongrel server class on machines without mongrel 6aa5d76 Applying patch from #666 by Rainhead and monachus ea190c1 Changed the host to "eager fetch" all the resources and their associated tables. Also removed some unecessary lines from resource.rb that were causng it to re-read information it already loaded from the db. 3003aad Added the teardown of the database back to the tests. 4442a31 Revert unintentional change. 68e37a9 Major rework of the rails feature. Changed the relationship between host and facts (now many-to-many with fact_name through fact_values). Also changed the relationship between resource and params (similarly many-to-many with param_names through param_values). c26f678 Fixing #550 -- I had to list pass and dump as optional fields. f0b5090 Fixing #112 - mounts now default to 0 for dump and pass d396fd5 Fixing #637 -- defined resources can now correctly be virtual or exported ad9c9ce Removing old line from the fix for #660 -- I had strangely just commented it out, rather than removing it ffb7ae0 Fixing #660 by applying patch by freiheit. Looks like this is another problem with yaml on 1.8.1. 79b604d Oops; I forgot to add the base class for package providers. Also, cleaning up the package provider code a touch c826be9 Adding a simple unit test for mongrel, and adding the ability to select the header used to store the client SSL dn. b50c85d Fixing error when commands fail -- the error code is now printed, instead of the inspection of it 3479387 Adding (slightly modified) urpmi support from #592 by Devin 73502a7 Finishing off the type/provider interface work, including adding package prefetch for all packages. The only not-done one is yum -- prefetch is set up for rpm, but not yum. We need to modify prefetching so that it also prefetches latest information, to avoid having to run yum so many times. bf82d51 Fixing the "Server is not a class" problem with mongrel 992636a Applying patches from Valentin Vidic to fix open file discriptor and open port problems 1867d0e Fixing the few test failures that resulted from the changes to provider listing c35d07b Significantly reworked the type => provider interface with respect to listing existing provider instances. The class method on both class heirarchies has been renamed to 'instances', to start. Providers are now expected to return provider instances, instead of creating resources, and the resource's 'instances' method is expected to find the matching resource, if any, and set the resource's provider appropriately. This *significantly* reduces the reliance on effectively global state (resource references in the resource classes). This global state will go away soon. a7b057d Adding a "source" attribute to providers, so eventually types will be able to avoid duplication during listing by only listing one provider for each source (e.g., dpkg and aptitude should not both be listed). 0cfd28e this is a spurious commit to test the trac site e8aef1e Change pi to list properties instead of states f2c524d Add protect and priority properties; patch provided by Matt Hyclak 0a2b438 Fix trac #601: wrong location for client pidfile d467e18 Fixing #532 -- reparsing config files no longer throws an exception. The problem only occurred when reparsing a configuration file that was also being managed (which was common) and only whent the manifest was up to date (the combination was uncommon). Reparsing would find the existing file object and use it to check permissions and such, then it would remove all of the internal data in the object, for cleanup; the problem is, the client still had a reference to the object, so when it went to run its configuration, this broken reference was used. e8097a2 Changing --show-available to --showall, as requisted by Jeremy Dreese on the list e0fbd41 Switch the package type to use a :versionable feature, and convert all providers to use the feature. Hope it doesn't break anything. 37a221c Add a grammatically correct 'has_feature' alias, and switch to using it where appropriate in existing code 0a605e8 Clean up a really hairy code construct in the useradd provider 58be1fd Fixing up2date name matching, as mentioned by Jeremy Dreese on the list 464e688 Changing the resource title to be text instead of a string, because some title are > 255 chars 48ec137 Mark all package providers that don't currently report themselves as being versionable as not supporting versioning; this way we get a more sensible error message when people try to specify a package version. See #647 for some discussion. a9ea3c8 Correct a problem with the dpkg provider's handling of the :purged state, and expand the package type's understanding of what purged actually means. Fixes #644 d1458bd Adding a warning for when no properties are specified on services 1883b8f Adding a debug statement describing why restarts are skipped on services ca255b9 fixing the method to check for hostdir writability in the rrdgraph report ac686e8 Changing the location of the classes.txt to the state dir 25d5ebd Adding more detail to the per-host reports dirs, since it was not setting mode or ownership. 62a4d4c Adding better error reporting on unmatched brackets -- you will now get notification of what was expected in most cases 2b372df Updating the exec docs to specify that the timeout is in seconds 4aef0ba Fixing #323 -- puppetd and puppetmasterd are now in sbin; packages still need to be fixed 6f83d4d Fixing #501 -- there is now a splay option, disabled by default and when running under --test 7d1f760 Adding the execute bit to install.rb and fixing #473 -- there was a /win/ regex that matched darwin but was just supposed to match windows 611f88a fixing a documentation bug df6f41a Changing the notify type so that it always uses the loglevel for logging ef1a4af Fixing #568 e8d560e Fixing #566 -- definitions, tags, and classes can now be single characters eed85f4 Adding #629 -- an undef keyword now exists 8410c4d Fixing #507 (behaviour in cycles) by changing the topsort algorithm. 67ee251 Using the method for retrieving the dipper class, in case it has not been loaded e3b7a54 Making sure there is an editor set for ralsh e95734b Redoing autoload a bit in preparation for adding a plugindir dbedcd7 A round of fixes so unit tests pass; most of the failures were from the merging of the transaction-refactor branch 28f7d6c Fixing #569 - I have added a dynamic facts option to choose which facts will be ignored. d9f6f41 Fixing the "is" related problems in yum and rpm support, but there are still some package providers that use the "is" method (grep for "\.is[^_a-zA-Z]" in the package providers), and the util/posix.rb module has a call to obj.is. I will fix those soon. 1934f2b Removing obsolete parsedtype 61784ed Attempting to fix the fact that the yum package provider calls [] on the ensure property, and making the resulting error more readable 85fef63 fixing some problems with the config timeout -- I am not sure it ever actually worked 27cabf2 Fixing a weird bug that occurred because I was changing @parentclass in the AST stuff the first time it was called, from a string to a the actual instance of the parent. This worked fine as long as the parentclass was only called when parsing was complete, such as during evaluation, but if anything resulted in it being called earlier (e.g., attempting to add to the class during parsing), then things behaved, um, badly. This commit fixes the method so that the variable is not modified; there is now @parentclass and @parentobj. 613c413 Fixing a path problem that resulted from the changes I made to internal variable names -- the pathbuilder method in file referred to @resource instead of @parent aed12c3 Use @http in store, add filterhost 19af1cb First try at the REST config_store 12e5656 Initial configuration storage abstraction layer stuff. 426330c Updated the CHANGELOG with changes for retrieve and acts_as_taggable. 24b11b5 Removed acts_as_taggable from the rails stuff. I haven't removed the tables from the schema nor the indexes yet. ca2b9e6 Not parsing old versions of puppet.conf -- otherwise, puppet parses the whole configuration. eca5510 Fixing the to_trans method and ralsh a bit so ralsh now works with the new lack of "is" method 55666a5 correcting some of the function reference docs 1d23013 Fixing #605 -- providers now refer to @resource or @resource_type. de21226 Fixing #607 -- parameters and properties now refer to a @resource rather than a @parent. The @parent parameter is still set for now, for backward compatibility. 3e7d44e Fixing #606 -- now only components mention @children. 13c7f2f Allow Darwin to remount rather than unmount / mount, as per puppet-users discussion "mount type and ensure => present on OS X" (Message-Id: ) 7f8a903 Getting rid of the last vestiges of the logger tests bfc0c35 The TODO file has never really meant anything, and it hasn't been modified in 2.5 years cdd0dd3 Adding default provider info to the providers report 2fa529e Fixing the ability to fail correctly in the fileserver -- a constant was not defined correctly for it fbfaa0f Removed FIXARB's from the pfile stuff. These have been resolved. 93cbe77 Removed FIXARB's from a file that will be going away. a966606 Removed override of change_to_s since it is the same as the overridden method in EnsureProperty. 8bad074 Removed override of change_to_s since it is the same as the overridden method in EnsureProperty. b0374d8 Removed calls to is. 5b44159 Removed the testing method: checknewinsync. c164360 Merging of refactor-transacton to the trunk. This work removes the :is attribute from properties and relies on the provider to cache or return the current value of the property. 8f18746 Hopefully final version of the providers reference c99e99d Intermediate commit of more reference work, including making provider suitable more introspectable. I am about to significantly change the output format of the providers reference, so i want to get this committed before that change. 73df973 The result of .compact.join("\n") isn't assigned to anything. Fix. 568db0b Fixing configprint so it fails correctly when an invalid parameter is provided, rather than throwing a stack trace 40b3834 Sorting the network handlers in the network reference 7835d29 Adding a dynamic? option for references, so those are not stored in trac 1decfa3 Lots of work related to generating more reference. Moving all of the individual references out of puppetdoc and into an external "reference" class, which itself can autoload, so it is now easy to add new types of references. Also adding a network reference, along with an unfinished provider reference. 69cb721 Removing the obsolete logger network interface a040bd4 First run at moving references to lib/puppet instead of puppetdoc f42a755 Adding a module to abstract using Autoload to load and manage instances 53f1612 Fixing the time-cleaning in the rrdgraph report 494675b Fixing #206 and #422. Executables will still look for the deprecated config files and load them using the old parse method, but they now prefer a single configuration file, and files can set parameters (owner, mode, group) in brackets on the same line. 1f8de9d Consolidating all of the configuration parameter declarations into configuration, at least partially just because then the docs for each parameter have to be a bit better. Also, I have gotten rid of the "puppet" section, replacing it with "main", and changed, added, or removed a couple of other sections. In general, we should now prefer more sections, rather than fewer. f783859 Correcting function reference markup e864eab Applying patch to puppetrun docs from JosB e1438a5 adding --summarize option to the changelog 28254b5 Adding a --summarize option, to get a transaction summary 0c07125 Fixing #615 (subclasses with similar names) by getting rid of the class "type" and "fqname", and instead using "classname" everywhere. You should no longer see unqualified class/definition names anywhere. Also, rewriting how snippet tests work, to avoid creating all of the files, since the point was the parsing tests, not functional tests. 8d7ec14 Adding a fact handler, along with an abstract interface for fact stores and a simple yaml fact store, towards the Node Classification work. 79dcd33 Set LANG/LC_ALL/LC_MESSAGES/LANGUAGE to 'C' whenever we execute things, so that the output that comes back is more easily parsed, without needing to understand all sorts of foreign languages a1d4f35 Update to latest shipped for Fedora/RHEL 4022968 Committing all the work that josb did, plus a couple of small changes bf37676 Applying patch to puppetd from Jos Backus 8d11bb8 Fixing class name for Handler in puppetd 1ccdff5 Adding --serve back in as an option to puppetd, and failing when a handler is specified but missing fb4f04d updating changelog with version number 0f02a54 Updated to version 0.22.4 e049999 Updated to version 0.22.4 4f2b903 Updated to version 0.22.4 3e895b5 Changing the remount stuff back to not repeating the mount options. 6438270 Adding a "supports_parameter?" method to test whether a given provider supports the features required by a given parameter. This is used during attribute instance creation, but its creation was necessicated by test code. c9de332 Fixing the fileserver naming tests after the change to allow "-" in fileserver module names. 80ec494 Fixing #430 (I hope) -- execs now autorequire the specified user 483c25e Switching the simpler features to a single file, so it is easier to add new features c369c6a Fixing cron to correctly match blank lines, fixing #602 f69dcda Working a little bit on rails failures, with no real progress e05392e Fixing a bug in the tests introduced a while back when I switched to using "generate_report" 7fb7146 Updating the changelog for #594 3aafd81 Fixing #594 -- Files on the local machine but not remote machine now purge. Note that this introduces a difference in behaviour between recursing locally and recursing remotely. c2bc848 Adding purge => true to downloading of facts and plugins, and removing some extraneous logging from the provider base class 7e97143 Allowing "-" in fileserver module names, #617 4dbcc5d Changing the resource handler to return the whole object, rather than just type and title 8b60d20 Not stripping domain info from the ldap node, as requested 63e907c Switching the mount command to always add the mount options, so that the parsed provider can be used even in cases where /etc/fstab is ignored, like it is on OS X. dad9373 Fixing the tests for the aptrpm provider. 89ac6d7 Adding "rug" package provider from #609 4296e4e I managed to put those provider tests in the wrong file -- the file meant to test the resource type interactions with providers, rather than the provider file. Fixing that, and the failed test resulting from that silly mistake. 21eab22 Okay, one last try -- the Util#binary command was not returning a path in all true cases, and the provider tests were poorly written and missed it. 94bd3b2 Apparently I messed up providers a bit; binaries were not having their full paths returned, which made most providers suddenly unsuitable. This fixes that, and adds tests to verify behaviour. 96eed99 Closing #585 -- providers can now have optional commands, which only differ from normal commands in that they do not affect a provider's suitability 0a46bb2 Fixing #603 -- I had to add a special case for escaped carriage returns. I am not entirely sure this is the right solution, but so be it. 9a1a88c Fixing #574; puppetmasterd now exits with non-zero error code when there is a failure 3169bfa Adding extra info to the "Parameter already set" error, as requested in #573 86c206b Possibly adding the ability to manage passwords on os x. I expect it does not work, since there is probably no way to set up an encrypted password, but at least it now creates a user that can not log in by default. 0aeda97 Adding the ability to manage passwords with the useradd provider 7fbd3ff Adding the ability for parameters to declare that they require a given feature, and resources will not instantiate that parameter if required features are missing. This is mostly useful for properties. 4aaae62 Adding a note to the references indicating that they are autogenerated. 0681cfa Refactoring puppetdoc so it is a bit cleaner and is actually object-oriented. PDF output still fails miserably (there has to be some kind of markup problem, but I have no idea what), but other output now successfully varies on the pages. 0ff3772 Last modifications to rst conversion before bedtime 1d036bb All conversions to RST are done, but I did not quite succeed at making puppetdoc able to generate a single PDF with all of the references in them. 9526e53 Mostly done with the conversion to restructured text, but there are still some tweaks to perform on the typedocs output. 8d3673d Adding a :block_eval option to FileRecords in FileParsing, so ParsedFile providers can have records just define a bunch of methods at once, rather than using lots of hooks. This is cleaner when custom parse and generate methods are used. a478ed2 Translating all of the docs except the type docs to RST 70ec0cc Removing the naming restrictions on cron names 5afa587 Fixing #588 - the parser correctly ignores directories in globbing now 3c5ba06 Fixing #587 -- just defaulting to root when there is no USER set in the environment. e1b0444 Fixing #591 -- puppetd now correctly restarts itself when it receives a HUP 37ffb63 Removing the stubs for nodevar; I did not mean to commit them 7cc3a2f adding note about the class variables in the change log 5436f96 Enhancing the docs a bit for the apple package provider. 775c72b Adding support for aptrpm from #227 as added by Ian Burrell, the rest of the commit be68411 Adding support for aptrpm from #227 as added by Ian Burrell f1f4c42 Adding patch by apowers from #545. df0cd95 Adding init script by apowerrs from #546. 9828b25 Fixing fileserver doc links f8a0e99 Adding the functionality requested in http://mail.madstop.com/pipermail/puppet-users/2007-April/002398.html . You can now retrieve qualified variables by specifying the full class path. 9946249 Only caching the configuration when it has been successfully turned into Puppet objects b6d0d27 Adding a --version argument to puppetca da4d252 Changing the test package for debian b8b14d3 Forgot to change Puppet::Util::SUIDManager#run_and_capture arguments to execute efe9a83 Fix for #565: Final merge of changes from source:branches/execute-refactor into source:trunk Generated with svn merge -r 2378:HEAD https://reductivelabs.com/svn/puppet/branches/execute-refactor trunk 8ab2722 Hah! Finally fixing the problem where mount tests would fail when run as part of the whole suite. The real problem was that I was changing the filetype of the provider without setting it to change back after the test, but the key change that made it straightforward to fix this problem was that my test loader was not exiting with a non-zero code when there was a failure, which mean that the ./test script never thought anything failed. I fixed the former, then fixed the test script to work fine with -n method_name stuff, and quickly found the problem. *whew* f9d89b5 Changing the date that certs are valid to start one day before the cert is created, so clocks that are off by a little bit can still be used. 4615e3a Fixing Client.read_cert so that it automatically adds the certificate information to the driver when the certificate is correctly read. This makes sure the Net::Http instance has the cert all set up. ca5d068 Updating the docs for the sourceselect parameter 295b357 Renaming some methods so that we can generate a report on a transaction and then retrieve it later 1e8e7ee Fixing #567. I overrode the propertychanges method to only return changes if the file exists or if the file has a property that could create the file. 4863012 Enhancing the report docs a bit 0ecb775 Adding last bits to the change log for 0.22.3 a999752 Updated to version 0.22.3 24ad5ab Updated to version 0.22.3 9ce7c79 Updated to version 0.22.3 e154589 Fixing puppetdoc with the recent changes to the networking code 801d0f7 Fixing a bug I apparently introduced in the testing that would have made user management not work with netinfo. In the process, I am enabling validation on the nameservice subclasses. 2544f75 Fixing the documentation to match reality, as reported in #548. 4358e85 Trying to fix the problem that occurs when noop somehow manages to be nil when downloading files 2ad9469 Changing gems to automatically include dependencies 858cb81 Updating changelog and adding filebucket to the exluded file list in the Rakefile d54b645 Updating changelog and adding filebucket to the exluded file list in the Rakefile fa26552 Fixing #562; I had to fix how the client class was loaded 142d0fa Applying patch by Ian Burrell from #559 2c3abbe Refactoring some of the rails code. The speed is now pretty good, but the tagging stuff does not seem to be working and is certainly working very ineffficiently. Blake says he is going to take a look at that. 33f4a66 Renaming pbucket to filebucket 52df47e Finalizing the filebucket client, with test code. def15e3 Adding filebucket client app c5e1a44 Fixing the "readcert" method after getting the signed cert; the method got refactored, and essentially renamed in the process 60d36e2 Moving the authconfig setting to configuration.rb instead of network/authconfig.rb, as mentioned by Koen Vereeken 5bd0e8c Rails is now significantly faster. I refactored all of the queries; they are mostly reduced to three queries, each of which is relatively fast, although there are still a ton of file- and tag-related queries that I cannot find the source of. Note that this speedup requires indexes, which will only get added if you start puppetmasterd with --dbmigrate (although you cannot always start with that, as there is an error in the init code). I expect that the indexes will not help unless you forcibly reindex your database, but after that you should see significant speed improvements. 4c357d8 Adding a migration to create indexes 5ad9bf4 Fixing #553; -M is no longer added when home directories are managed 804c0f4 Fixing the same bug as the Metric stuff, but for logs this time. 46152c1 Fixing the Metric class old clients can still refer to the Puppet::Metric class. 36feb29 Fixing a small bug in testing whether instance methods are already defined. 45904ca Updated to version 0.22.2 0452878 Updated to version 0.22.2 474b86c Hopefully the last batch of commits before I release 0.22.2. Mostly just get tests to pass. 90d8b2d Remove no-lockdir patch. Clean changelog a68a7c2 Change puppet's homedir to /var/lib/puppet 145c39c Don't clobber an explicitly given waitforcert 41e1285 Reverting changeset [2243]; this apparently causes chkconfig not to work bcc937a Absolutely guaranteeing that the provider is always created before anything else. Previously, it could get created later if it were using a default. 60ea7d2 Fixing #432 - you can now manage home dirs with users. You cannot yet purge home directories, because there is still controversy over how that should be done. Also, allowdupe is now handled like a feature, which is, um, better. 3d17685 Adding a "has_feature" method, so a provider can just declare that it has a given feature 290ad14 Finally fixing #504, I think; I even have tests to prove it. It was a little thing, in the end. 32662cb cleaning up an error message a bit 9b5833a Clarifying the errors a bit when nodes come from external sources. 1f8b768 Apply patch from Ian Burrel (trac #479) 3e2510f Adding the "ralsh" executable (formerly known as x2puppet). 531136e Updating the config generation stuff a bit, mostly just cleanup, but also changing the servername fact to be the fqdn of the server. 0153a06 Changing the config cache location to the state dir f046067 Adding context to the warning message about unknown escapes 0040edf Changing execution to reopen stdin to /dev/null b804573 Changing notify to default to its message being its name e2c5dbb Another round of bug-fixes, prompted by test logs from David Schmitt 92bad78 Fixing the spelling of David Schmitt's name and giving credit to Chris McEniry in the changelog. 547fb64 Adding a provider feature table to the provider feature docs 5b2ffbc Adding provider features. Woot! 80dac92 Following Russ Allbery's advice and using the Candidate field in the apt-cache output. Apparently I'm blind. 3606482 Updating changelog for #487 4dc7233 Fixing #487. I know use "apt-cache policy", instead of apt-cache showpkg, because it clearly shows which version will be installed. This is basically impossible to test well, so I just added a test that verifies we always get a value back, although I cannot really test that it is the "right" value. Also, I modified the logging of packages so if there is a latest version, you will get the new version number, along with the old, in the log. 973f9d0 Taking another crack at #504 -- I was using Pidlock incorrectly. I should have been using "locked?" but was using "lock". cef41c2 A slight fix for #507. This should at least provide better information if this problem crops up, although I cannot reproduce it. 1778883 Changing the "found a bug" message to something a bit more informative. 184266d Fixing #447 - filebuckets now use deeply nested paths b436002 Oops. Fixing the other tests to now past the facts to "fresh?", as required by the fact checking. 61b3490 Fixing the fact caching so that facts are only downloaded and retrieved once, rather than once during fresh checking and once during config compile. 5f7ae35 Fixing #519. The facts are now cached in the state file and changes to them force a recompile. a2a9d93 Fixing #544 -- there is now an --ignoreimport option for commit hooks. a212ea7 Adding #539. Definitions can now have titles, and both $title and $name are guaranteed to be set within any definition. 90bdc33 Adding test to make sure ensure does not conflict with any of the creating types. e952029 Adding #541. There is now a "generate" function. 6654661 Fixing #538. There is now a simple file() function to read in file contents. 5ecfd39 Looks like I already accidentally committed the switch from using system() to exec(). I am hoping this will fix the many problems people are having with processes hanging around (e.g., #509). This change just removes the attempts at closing TCPServer instances, which should now be fixed from using exec instead of system. 6b85962 The first round of fixes for failing tests. 8eddd4b More work on #542 -- services in noop now produce noop events so that they can themselves trigger further changes 2fe9998 Removing bogus log message in file parsing 3b8dc6a Removing the cycle checks from the splice! method in pgraph, which *considerably* speeds up splicing of very large graphs. adedab1 Getting rid of a warning in the rpm provider 40eeadb Adding example cron tab from #492 and making the read/write tests ignore whitespace. This cron now parses successfully, as I thought it would with the move to providers. 2a3f56c Fixing #529 -- specified targets keep their values. The problem was that I was using model[:target] instead of model.should(:target) and model.is(:target). The real problem was that my tests were using a parameter for tests but all of the real code uses properties. fe2f0d9 Fixing #533 -- puppetd now exits in onetime mode. 5257837 Fixing #491 -- the client correctly realizes when the cache file is missing and only considers the config to be in sync if that is not the case. a76afb7 Trying to clean up the error message from #490. It looks like the problem is just a failure in one of the types, and it has nothing to do with the state file. 4a6d705 Fixing #542. Transactions now cause services to warn when they would have gotten restarted by a noop resource. Also fixing #549 -- transactions now only refuse to delete required resources if they are being purged. All other resources can be deleted just fine. 8387d48 Fixing #540. I modified Puppet::Network::Client::Master so that it disables noop during its run, so that facts and plugins will always be downloaded. 86c63ce Fixing cron support (I hope). It now uses providers, and seems to work, at least on my os x box. ba23a5a Adding spec libs, so we can use them some day 8ea6ada Clarifying that the ruby RRD support is provided by a binary library df4595e Significantly reworking the internals of the fileparsing code. It now passes around an instance of a FileRecord, rather than just a hash, which I think makes it much easier to understand. b05ae2a Don't blow up when PUPPETLIB isn't set 0fa3c43 Search manifests first within modules, and if no module is found, search in the directory the current manifest is in. 38975de Introduces a new implicit 'modules' fileserver module, whose allow/deny can be set from the fileserver.conf, but whose path is ignored and can therefore not be used directly in puppet:// URL's. ebcb6b6 The template function now tries to first find a template within a module (if the template path looks like it belongs to a module) and only when that fails looks for it in templatedir ba6257c The basic plumbing for modules: a modulepath config parameter, and a new class Puppet::Module that will contain the module-related functionality. The modulepath can be extended by setting the environment variable PUPPETLIB 10d6891 Adding support for a prefetch hook on individual providers, rather than only supporting it for the whole class. 4fa8008 Fixing a few of the log messages so file content changes always include the md5 sum 6ad8998 Adding a bit more testing to the config stuff 3489bd8 One last try at getting the config and mode stuff working. The tests were passing because "mode" is a valid config option in the tests, but not in the real configuration. So, now the Config class correctly only tries to set the meta params if they are valid options, otherwise they get skipped. b36f9c9 Fixing the config path to use Puppet[:name] rather than Puppet.name 6b92c04 Oops, forgot a file in the commit f59cade Fixing a bug related to link recursion that caused link directories to always be considered out of sync. b6df336 Looks like [2265] was not a complete solution -- it resulted in failures when the config set modes via integers. Everything is working now, and tested more completely. 0925fb0 Adding some more testing on the @should values for :groups on users, and fixing a bug that often made :groups think it was out of sync. 333842b Putting the final touches on #144, most of which I had provided in the mongrel work. fa253b5 Fixing #489. I was unnecessarily converting to octal in config.rb 69338da Adding some changelog info for the next release, which is still a ways away, probably. 205bbb9 Flushing out the ability to have a stand-alone CA server, specified using ca_server and ca_port. This is just a final unit test, since the code was done and lutter fixed the rest in [2261]. 185a003 Fixing #531 and #414. This includes pretty much a complete redesign of the AuthStore class, with (hopefully) all of the edge cases removed, the code is now much cleaner, the tests are (I think) complete, and everything is just generally better. fde8b28 Fix typo in default config and add simple test to check default config sanity 7e41d43 Turning a failure into an error when, for some reason, pfiles do not have paths set. 46d344b Merging the webserver_portability branch from version 2182 to version 2258. 6823370 Sync with latest Fedora specfile 4a73da3 Don't include bin/pi in distributed tarball (and hence fix trac #471) 1808c50 Apparently the include function was not failing when it could not find asked-for classes. Now it does. 521606b Allowing trailing commas in selectors 9080686 Committing patch by Dennis Jacobfeuerborn to only use the domain name if it is set. 17c59f8 Adding "ignorecache" option to always force a recompile of the configuration ebc4dd2 Fixing #464 and #515. ff9ec47 Applying patch in #528 by ask. cc26026 Fixing #467. It is a hackish solution, because I just reordered the definition of the params, but it works for now, anyway. d229d49 Fixing at least part of #514. This does not get rid of all errors, but at least it fixes the spurious warning be8dfd9 Fixing a problem with the splice! method on the graphing. The problem was another issue with hash ordering, where it would usually work but sometimes start failing. The solution was to splice the containers in topological-sort order. 4df0738 Applying a modified form of the patch by cstorey from #523. The modifications were mostly around the fact that Strscan does not set $1 and its ilk. 0f16bf3 Fixing #526. Implemented as a period of "never", rather than adding a new parameter. 07fce23 Fixing #477. setvar() can now accept the file and line info from callers. d5444e0 Fixing #199 and moving service tests (which are completely atrocious) around. 7d965ae Applying patch by cstorey from #521 36ae6a2 Making the package provider tests able to be executed separately, and using "clear" instead of resetting @objects in the types. b7a0fb4 Make up2date the default for RHEL <= 4, and confine it to RHEL; make yum the default for RHEL >= 5. Fixes trac #478 672e281 Fixing #142. As expected, trivial. 87f100a Applying patch by DavidS from #522, along with test code and a small bit of code cleanup. a3f3674 Redoing some aspects of the graphing in hopes of helping hte performance a bit. 1a7d8b6 Fixing file backup defaults to correctly use the puppet filebucket by default. d833c3e Changing the log messages for source and content properties to mention the md5 sum of the new content 789b786 More code related to #517. Oops. 4c885b7 Fixing #517 and more. Classes now support more than one namespace in their search path, parent classes automatically have their namespaces added to subclass namespaces, and (huzzah) there is a "search" function that can be used to add new namespaces into their search path. aad5123 Fixing #524. Functions, both statements and rvalues, now support no arguments as long as you use parens. 3e13e36 Actually commit the changes to lib/puppet that were supposed to be part of [2223] (Fuck svn and it's partial-repository-by-default behaviour) 1d711dc Partially complete #241. Add a 'purged' value for Package.ensure, and add a handler for all of the Debian providers. Also wrote sensible test cases, and so we've now got Mocha running around in our source tree. a752eb2 Fix #516, 'Cached manifests get unescaped twice' db8a23e Print stacktrace in debug mode when catchign a signal - useful for understanding client hangs fa02d67 Fixing #472. Apparently this has been broken since I did the parser redesign. I had to fix the scope trees so that subclass scopes are subscopes of the parent scopes, which used to be the case but was far more complicated. d145aae Fixing #505, #508, and #513. 774415b Allow 'key=' to be the only thing on a line (livna uses this) 4d02823 I believe this fixes the issues in ticket #469 My testing on mysql shows connections being reaped. 7a9e28a Applying patch from #495. 6fbd5fd Removing extraneous debugging 90b1058 Fixing a problem in collecting exported resources. Virtual resources worked fine, but exported resources resulted in an essentially infinite loop. deab3a0 Fixing the default dbadapter back to sqlite3 3d093ae Applying patch from #510 by curzonj. Note that the right solution to this problem is to use the ruby API, but it does not appear to be stable yet. 65599af Re-add the files beb7873 Undo the param_name param_value merge f4f555d Renamed Puppet.name to Puppet.execname so rails 1.2 doesn't freak out 9a672ec Undo the param_names param_values changes 8b18fdf Undo the params & facts stuff 9fe8905 Changing date to datetime in the database 964c805 Trying to fix problem of locks lying around 2418e4a Adding hook to update timestamp when a report is run 0aa3b66 Change Puppet.name to Puppet.execname so rails 1.2 won't freak out. 6555dad Update relationships Remove dynamic class generation for now. Include the fact class 328e576 Revamping collections to get what is hopefully more reasonable behaviour when they are used in combination with defined resource types. You should now be able to combine them in just about any way and get "correct" behaviour, which in this case means that you can have virtual definitions or definitions wrapping virtual resources and the resources will still all get realized. 69d4bfe This works for me. Probably not the most universal fix. 9de665c Apparently using "gem" requires an environment we don't have. 91991f1 Merge fact_names & fact_values, and param_names & param_values. 0b5600a Fixing features to use the new feature location 17a5f4c Applying patch from #502 by Jose 6216ae5 Applying patch from #497 by Jose Gonzalez 258651c Applying patch by Jeff McCune from #496 9cd2636 Applying patch from #474 by David Schmitt. 4effff4 Fixing #482. c3b6232 Fixing #493. 81ae397 Applying doc patch from #494. 1756bec Fixing #484. Moving unit tests at the same time. a216df2 Okay, last file moves for the night. The test code has been moved to match the lib directory, and I have moved a couple of things into network/ instead of network/server, since they did not belong as much. 7e07e3d Moving all of the client and server code into a single network/ directory. In other words, more code structure cleanup. 6d8068e Moving some of the stand-alone classes into the util/ subdirectory, to clean up the top-level namespace a bit. This is a lot of file modifications, but most of them just change class names and file paths. 1626023 Adding a libdir setting for puppet, so you can store your modifications to puppet in a separate directory. This probably will still be somewhat limited because it will always depend somewhat on load order. For instance, if you add a new provider, it might not be available when you expect, since providers are all loaded as soon as a type is loaded, which might happen before the libdir is set. It should always work fine if you do not override it, but if you do override it, things might behave a bit strange. 99c8a54 Adding a parameter to allow you to override how an exec refreshes itself. dd71a51 Changing exec so that the checks apply to whether an exec is refreshed. 31c9a6f Disabling the netinfo mount provider ad359f3 Reorganizing some of the tests. d403131 Merging the state-rename branch. This includes the diff from version 2156 to 2168. All states should now be properties, with backward compatibility for the types that restricted themselves to the methods. f6f72f2 fixing the cookbook link fix 3a024d7 Removing the default value for :ensure on mounts. 71346e9 changing the cookbook link f80bd5e Fixing exec so it actually works when path is specified as an array d117aa8 Updated to version 0.22.1 1e90209 Updated to version 0.22.1 463d3a8 Updated to version 0.22.1 1d059b0 Fixing #470, I think. I basically just threw away the validation and let suidmanager do it all when running commands. 69a07b1 The resolve functionality in "test" is almost working... 42d15fe Adding note about removing mounts netinfo provider 2c79bbf Oops, that last commit seems to have broken the rakefile. Works again. 3836201 Trying to get the functionality I had in previous tests. Mostly I want to be able to load many files but run just a couple of methods, which test/unit supports via -n, selectively enabling -d. I now can do this with the Rakefile, using 'TESTOPTS="-n -d" rake , although I find that a bit kludgy (certainly more so than 'rake -n -d '). fd2982f Fixing executable tests to take new rundir into account a62fd3e Filenames for test must _end_ with '.rb' 12bf816 Fix to make running tests work in ruby 1.8.5 18eebaf Fixing selector tests to get rid of a lame hash ordering bug in the tests. a3a85d8 fixing rails test to take into account the fact that resources now do not always return arrays f1deaa8 Fixing autogen so it passes on non-Darwin systems. 173f5cc Fixing a purging bug introduced by [2138]. I had to move the purge check to the recurse method, rather than the localrecurse method, because the purge check needs to happen after sourcerecurse. 62ab873 Deleting the file even if a source is specified, as mentioned by Robert Nickel. c8f38b7 Renaming "pelement" to "resource". The old name is a holdover from before we had settled on "resource" as a term. ea73cdb Fixing Files to work with the Resource server. Basically I just remove the "target" value if it is a nullop, so that it does not cause a conflict with "contents" on the far side. d7fde42 Adding explicit umasks to these tests. a4de59c Fixing rundir so that it is only set to be in /var if the process is named puppetd or puppetmasterd. Otherwise the unit tests set it to /var/run/puppet, which has the chance to cause hangs. 9dc6cf6 Removing all remnants of the old symlink type 7889b0b Revert 2125, and instead change the way the 'latest' version is selected from the sorted list of versions 97583b4 Updating changelog for 0.22.1, although I am not quite ready to commit yet. 8d90e56 Puppet can now read files on stdin. This means you can put "#!/usr/bin/env puppet" in the first line of a puppet manifest and then execute the manifest normally. Yay! 8821300 Providing a partial fix for #428. Resources can now be deleted as long as all of their dependencies are also being deleted. This, combined with the fix to #433, means that you can now explicitly specify the order of deletion, and everything will work as long as all required objects are being removed, too. 0a62369 Partially fixing #460, take 3 -- fully-qualified classes can now be included. 788a74e Partially fixing #460, take 2 -- fully-qualified definitions can now be used. a7bd786 Partially fixing #460 -- fully-qualified class names can be used as parent classes. c9e7699 Fixing #462. The package sort order was always resulting in the lowest-version package being first, rather than highest, so I inverted the sort order. add6e5d Applying patch in #465. 1f9ede2 fixing #427. Facts now timeout, both in loading and downloading 049d79c splitting the tagmail report into multiple methods and adding test code 727672f Not creating the listening server at all if --onetime is enabled. af3863e Fixing #440, albeit with a slightly hackish fix. 01ec5ba Moving code from external sources into an external/ directory 1374e4e Moving the switch that disables the certificate authority into the main library, so they can be disabled in the configuration file. dc580cf Fixing #433. I basically just added checks to all the places where I add edges, to make sure automatic relationships lose out to explicit ones. e418691 Fixing the warning message related to namespaceauth.conf d3fc49d Fixing a problem that occurs when puppetd starts with an up-to-date configuration -- the default schedules and filebucket were not being created. 6c61f0c Fixing #463. I redid all the autogen stuff so it can handle autogenerating string values for stupid os x. 8198e7e pointing documentation to the wiki now 54c458c Fixing #438. 04017b3 Fixing #444. I was losing the list of sources when creating new children. b7560d5 A couple small bug-fixes 3aff4a0 Doing more work on #113. Mostly, just making sure remounts do not happen spuriously very often. They will still have extra remounts when changing the value of "ensure", but that is not currently avoidable (similar to #199). 1cc8ecb Fixing info around newtype options dd502db Fixing #113. I added support in the transaction for self-refreshing, which just creates a special trigger for resources that have self-refreshing enabled. Logging is a bit different for them, so it is clear why they are refreshing. I still need to verify the remount methods work in the providers. bf46e7d Adding a "self_refresh" option, so resources can refresh themselves if they have changed in the current transaction. 1f41c35 Fixing #454. c07494f Fixing #441. 9924244 Fixing #431. Collection was always returning an array, even when only a single value was passed. 0a9c8da Changing how transactions check whether a resource is being deleted. This is a small step towards fixing #428. f6a3d94 Fixing #455. A simple fix, fortunately. 81025d1 hoo e29ef5c Updating reference docs af4f7d7 Fixing documentation references to refer to the wiki 37acfb9 Fixing #442. You can now do: defined(File[...]) to see if a resource is defined. 2db6878 Fixing #434. 6475487 Fixing #423. Configurations now default to timing out after 30 seconds (tunable with configtimeout). This only happens for remote configurations, not local configs compiled using puppet. a081d41 Fixing #418. The problem was that multiple objects might include Daemon, which means that Daemon#shutdown can be called multiple times. c33d5e4 Using Time instead of Time.to_i for compile time, because some versions of ruby have trouble converting Bignum to yaml 6d791f5 adding client name to processing line 7670df2 Fixing #445. Nodes can now inherit from default. afe77b6 changing selector error message aab3214 reworking the selector case-insensitivity test 9f8a3b1 Removing an extraneous debug message, and fixing the case where the server compile fails in --test mode -- it resulted in an extra warning message. ca1e36b Applying patch from #457, as submitted by Jeff McCune. 81ae09e making yum the default packager for centos 5735d48 Wrapping the resource generation methods in begin/rescue blocks so that failures cannot kill the transaction. e8f3806 Fixing error-catching in resources.rb a3041cd Updating changelog for 0.22, which fixes #429. bda74bc Fixing #415. Configuration parsing now removes trailing whitespace. f8115a7 Fixing #424. The configuration compile time is now cached in the yaml cache file. 53f3b8c Fixing rundir so that it does not throw an error when not running as root c285d7a Fixing #437. Transactions now check whether graphs are cyclic, with a somewhat-useful error message if they are. 9720a97 Fixing #436. Also finally renamed pfile/uid.rb to match the state name. db5494f Fixing #421 by changing the rundir to /var/puppet/run. bfb5506 Fixing #416. There is now an option (downcasefacts) that determines whether facts are downcased by the client. 53c3f5a Make rpm operations much faster by suppressing unneeded verification bcd81bc updating docs with new location for reference info f069418 Moving the reference docs to the top level c03a8c9 updates 42b78a0 Use a specific ActiveRecord subclass to check for the proper existence of AR in the Rails feature test, so that we don't kill everything if the machine has Rails installed, but it's an old version that doesn't support polymorphic associations e64e64d Make the version string optional in the dpkg-query output parsing regex (Fixes: #425) 32bbb3a Clear existing yumrepo instances befoer listing - assumes list should only return "is" instances 3dea961 Enclose values in single, not double quotes; otherwise if values have $ in them, the manifest will be incorrect 5836c23 Allow listing of yumrepos a676e08 Sync with latest in Fedora repo 965a82d Minor cleanup, leave cursor at beginning of indented line, not its end c35b441 Add indentation written by Mario Martelli f7d8350 Updating docs for 0.22.0 4ee6c97 Updated to version 0.22.0 98ed0ae Updated to version 0.22.0 38cfa67 Updated to version 0.22.0 3446dd6 Last round of fixes before the next release 954a285 Fixing puppet test task for older ruby versions 7afa69c Fixing rake test so it works with the new puppet loader 54c387f Adding #408. d0ecc0e Messing around a bit with how tests work 2728f50 Adding a bit more comments to the :template function 704bd76 Fixing a few testing bugs that have crept in, and fixing a self-reference problem when configuring, graphing, and setting graphdir manually. e756711 Fixing #411. 48bbd0b Further work on #407. I forgot to actually connect it to the interpreter internals. f6beef5 Fixing #407. You can use external_node to specify a command to retrieve your node information. f8f7c57 Don't rely on the type to store the actual NVR of the package; breaks in the provider tests since they call the provider slightly differntly 42c13e2 Adding a timeout to execs. This is not really a sufficient solution, since it needs to be added throughout the system, but this is a good start. The default timeout is 5 minutes. 6e10004 Using Puppet.settraps in puppet executable, instead of old ad-hoc code. 903b40b Applying patch by mccune from #409. 5e470b3 Regressing to always creating files/directories as root, rather than trying to do it as the right user. bb72a08 Throwing warnings instead of exceptions when dpkg-query produces info we cannot understand 08a56cb Fixing module_puppet to use the usage? feature. 239727c Re-enabling the dirchmod test and fixing its syntax 2195b76 Trying to fix #364. Somewhat used the patch provided by nslm. 8fd9765 fixing filebuckets so that only the client bucket is created on clients d5651f8 Fixing tests so they now include descriptions with all config options, which is now required. a454dfb Creating two filebuckets by default, one for the client and one for the server 9c1a446 Fixing #403. 2b271f8 #398 is already fixed, but this will fix things so it cannot happen again f4b2e13 Fixing #391. Keeping track of times of compile and freshness checks. 098081d Setting up specific allowed types for sshkey 5292e4e Handle continuation lines in inifiles properly; stick a little closer to how python's ConfigParser parses 2366c95 Explicitly require puppet/filetype; otherwise, tests for this module fail cbd20f0 Simple script to produce type info 3b6bf05 Fix yum update breakage - query should not change the name the user gave us; instead, the fully versioned pacakge name is now stored in the instance parameter 587deea Tone down the debug spewage from yum 9115fef Adding extra connection statements and enabling concurrency support in rails, hopefully fixing #399. 0ef8971 Fixing #394. LoadedFile was not checking to see if files went missing. f58bda2 The package name must match at the beginning of a line; otherwise we might get fooled by other yum spewage caabe9b Not saving tags right away. This seems to cause postgres to explode. 9271142 Adding a check to the rakefile to throw a warning if the test task is missing 651640c Fixing #401. Transactions were trying to trigger every resource, even those that did not respond to the specified callback. c140037 Not setting the graphdir to the puppet user, since it is only used by puppetd 127f0df Using text for parameter values, instead of string, so the fields support larger amounts of text 86e434e Adding postgres as a dbadapter option 2d25816 Fix trac #354, and some other oddities around installing multiple versions of the same package. 50965c7 Changing "sourcematch" to "sourceselect" 373f177 Adding sourcematch parameter to file. cc05e8d Fixing the error thrown when a dependency cannot be retrieved, WRT to #395. 57d0933 Fixing #396. Using the provider command instead of a direct exec, which automatically captures stderr. 0887fcd Modifying the "Resource#set" method to simplifying adding new parameters 56619d5 A couple of small fixes to pass existing tests. 4482691 Fixing some failing tests on fedora. 3e933cc Enabling debugging except when running under rake. 3b2521b Fixing graphing tests, and correctly only using storeconfigs in tests where rails is available 54a838e Fixing #369. I was not flushing changes to disk when ensure was out of sync. This is going to become a common problem, and should probably be addressed by the framework rather than by individual types, but for now, it works. b8f798f Fixing #390. You can now add --graph to produce dot files, and you can then produce pngs or whatever from those. 0a1dd1a Use Puppet::Util.sync instead of MonitorMixin to ensure that only one thread runs the executor at once 23b75e2 Fix a syntax error in lib/puppet/daemon.rb (That'll teach me to not run the test suite before committing) 38244fb Create rundir in a test that needs it 27c1b49 Switch puppet/daemon.rb to use Pidlock 16f7980 Switch the run-lock to use Pidlock instead of the ad-hoc code e4843f1 Make Pidlock#lock return true if we currently hold the lock e252505 Add a Puppet::Util::Pidlock class, for use by locks and PID files c1035cc Add system library directories directly in puppettest.rb, so you don't have to do it by hand in every single underlying directory; also change the debug check slightly so that we actually put debug stuff only when we really want it a333539 Applying patch by rainhead from #392. 7e62bb0 Add updated_at for all tables make sure it's removed from the resource hash that gets returned 6d8b3f3 Removing debugging da3e9d4 Hopefully fixing tagging problem 280f0b4 Still trying to track down the tagging problem 79e9b46 adding a bit better error reporting when tags are bad 419cdf0 exiting sleeper after no more than two minutes fa538bc Moving the tagging stuff to an "external" directory, instead of "lib". 0166004 Adding carriage returns to output of puppetrun f52e2d0 Trying to clean up how rails is loaded 3a313ad Supporting arrays for the backup parameter 17306c0 Features now load dynamically using method_missing, so that undefined features never throw errors. 96f91f6 Adding a bit more testing to mounts, and pulling a bit of the transaction into a separate method to shorten the apply() method. a2b0ee6 Finally writing unit tests for Transaction#trigger, and drastically simplifying the method in the process. 9ff80c0 *whew* Okay, simplified the splice method a bit, and I am actually somewhat confident that the stronger testing is correct. I have had a lot of problems with tests usually passing but sometimes failing, mostly because of ordering problems related to multiple edges. bb9c813 Did a short-cut on the graphing, since we currently only support one type of subscription. This solution still will not scale to all that many edges, but it works, although it will fail if we need to support different types of subcriptions. 7ae62a5 A couple of small bug fixes c4c3d77 Some tweaks to graph splicing, although I do not think it will be enough to handle some of the edge cases. d07570b Looks like providers work again on Solaris. 6529822 I have not yet finished testing, but most of the providers now successfully pass arrays to execute() instead of strings, which means that the vast majority of execution problems are now gone. I will finish testing tomorrow, hopefully, and will also hopefully be able to verify that the execution-related bugs are fixed. 038d6a6 Fixing #387, hopefully. a5cf056 Fixing #388. Paths now look a lot cleaner. 883c64a A couple of small bug-fixes 65e76e8 Fixing #353. It was as simple as exiting with a different error code depending on the results of the call. d3a7c28 Fixing #386. 1d05739 Switching files to use a filebucket named "puppet" by default. Also, set up MasterClient to create that default filebucket. 92ff712 Fixing #365. I am not sure what the problem was in previous versions, because the new graphing stuff changed the solution to this problem, but it all works now. 8ff7e0c Closing #362. Case-insensitivity is handled by downcasing all host names. f1dc103 Hopefully fixing #355. I could not actually reproduce the specific problem, but I found a couple of issues around the problem and they are all gone now. a3ce917 Fixing #348. Overrides now support an extra end-comma. 5e58273 Loading the rails lib early on, so that the rails configuration parameters are accepted on the CLI, as noted in #357. 2742995 Fixing #343. Collections and definition evaluation both now happen on every iterative evaluation, with collections being evaluated first. This way collections can find resources that either are inside defined types or are the types themselves. 85b19c4 Fixing #349. Doing some hackery so defined types can now (again) be used as dependencies. 311aba9 Fixing #66. The "defined" function previously checked for definitions and types, but since types and classes can't have the same name anyway, the function now works for classes. 9bb5c50 Not downcasing facts any longer, closing #210 (although not using the patch from mpalmer, since I had not noticed the patch was there). Also, making all nodes, classes, and definitions case insensitive, closing #344. Finally, I added case insensitivity to the language in general, which should preserve backwards compatibility and probably makes the most sense in the long run anyway. be711d3 Allow execution of bare strings as long as there's no attempt to change uid/gid c616572 Fixing test to work with new style of graphing. 2c2177c *whew* Fixing the vast majority of the graph-related performance problems. I found a simple solution to handling events produced by generated resources, and that basically fixed all of the performance problems. Transaction tests still fail, but I wanted to get the fix in now so I do not forget it. 299bdc1 Fixing #380. The problem was that a method was sometimes returning :absent when I expected it to return nil when the group was not found. All fixed, yay. e605c4a Adding some defaults to users, mostly for darwin because it is kinda stupid when it comes to this info 41562cc Adding test for the fix to #361 a9dd641 Fixing #361, I think. It appears to be a problem with missing a setting for realname. 1bdf379 Applying patch from #384, by jgonzalez 253376a Fixing #385. Puppetca correctly exits with non-zero exit code if there are no certs to sign. 36e8d65 Fixing #372 and #374. All is not perfect, since OS X still cannot set UID, but it is much better. There is still plenty of bug-fixing to do on other platforms, I expect. 115ec09 Re-add support for tags and file/lines f851ca6 Adding :replace aliases, as requested in #366. 9f48706 All rails *and* language tests now pass, with the exception of a language/resource test that passes by itself but fails when run as part of the whole suite. Also, I added deletion where appropriate, so that unspecified resources, parameters, and facts are now deleted, as one would expect. dc5f4dc Fixing most of the rails stuff. I think everything basically works now, and now I am just going through and making sure things get deleted when they are supposed (i.e., you remove a resource and it gets deleted from the host's config). 5a52855 Fix up a problem with initialising an sqlite3 data store, presumably only with older versions of Rails 3c93400 Adding daily snapshot tasks, altho they only work at my site 10dbb17 Some more graph optimizations; I think I am now close enough that I am basically just going to spend a bit more time making sure the modeling is right in the transactions, and then walk away for now. b01ffe6 Adding a simpler and *much* faster tree_from_vertex method, and using it instead of the default one a481f9b Requiring puppet/rails in the interpreter before Rails.init 9df9e4b Getting rid of the db init stdout and reindenting 02cfc44 Simplifying the splitpath method a bit, altho it is still strangely slow 9fa7794 Simplifying the the Puppet::Type[] method 0dbe96d Redoing the benchmarking a little bit f622e18 Go back to restype and remove STI classes, they were more trouble than they were worth. 9ad62d2 Modifying rails test 0dac4ec Changing some of the error output. This gets rid of the duplicated information that occurred when definitions or nodes were duplicately defined, and it tightens the error output a bit. 0f78282 Adding unit test for #364. It passes on OS X. dc96f98 Adding some selectability to host creation for testing. Using find_or_create_by results in lots of saves instead of one big one at the end, which causes initial saving to be much slower. To switch between them, just modify the value of "create" at the top of Host.store. 6b5d001 I like to checkin one-liners a lot. I'm cool. set the type when we create the object, might be a bit faster 7173c1f Don't use find_or_create_by_title since titles aren't unique. e28c604 Remove old files, don't require pp anymore 3d070f7 These are the same versions from changeset 1837 0cd5799 Some rails modifications 6d9ae0c Don't dump out debugging stuff. 342a4a6 Don't symbolize the param names 56098ca Rename some stuff I missed when it was reverted b5fd822 acts_as_taggable plugin 98ebb87 Moving the mount provider tests into a subdir, and fixing the basedir calculation in tests so it does not matter where the test is called from 8714e14 New rails stuff redux. 026ec4f Small changes to the test rakefile. This rakefile still is not completely satisfactory, as I cannot use it to load all libs but only run on test method, which is often important when trying to track down a bug that only occurs when multiple files are loaded. 8be0d33 Fix service.list, in particular for the redhat provider 29ded01 Fixing painfully difficult to find bug in defining exported resources 72f8b32 Reworking the package tests. Now providers are tested individually f5e7915 Rewriting the test rakefile so test directories can be more than one directory deep. This will be particularly useful for providers. 40c0905 Fix up the filelist for gems, so that all of lib/puppet gets put into the gem, not just the top-level .rb files c35988a Another round of bug fixing. Now everything passes except mounts, at least on OS X. ab60452 Fixing the next round of bugs, mostly little things but I had to modify transactions so they are willing to delete implicit resources even if they have dependencies, else we would often not be able to purge files at all. 3937aa3 Never default to rpm provider; use up2date on RedHat. This also works on RHEL5, which does not have up2date, the provider properly fails over to using yum c763346 You can now use the "resources" type to purge resources. I still need to modify transactions so they do not purge resources that have relationships. Also, apparently the noop metaparam was never actually working; now it is, and there is a test for it. 64d96e9 adding a note about facter to the faq e96049f Change the filelist slightly so that the externally-included lib/rake doesn't end up in the gem 8829aa7 Adding a metatype to manage resources of a specified type. For now, this metatype just supports purging unmanaged resources. Also, fixed a few tests here and there 4abbdc1 Working some on the export/collect problem. It actually works now, but there are not yet sufficient tests for it, so I will leave the bug open until we have got the new work in place. I also added a "rails" feature, so I do not have to keep testing whether ActiveRecord is defined. 8fee538 Adding a short note on variable interpolation 8accd80 Adding a bit of clarity about file locations dd1c4b9 Add a task to build Debian packages more-or-less 'directly' out of SVN. 01fecb1 Add external Rake task file as an svn:external, and modify the Rakefile to add lib to the load path b3eb9f1 All tests should now pass, with the possible exception of some tests that might fail when all tests are run in one process. e287d1e Almost all tests now pass. I have basically reached the point where I was before I integrated graphing, except that all of the relationship handling is now inside the transaction, and any kind of recursion (including file) is *tons* easier to model and manage. 37a059b Most tests now pass in the whole system, but there are still about 8 cases that do not work. I am working on those now. 374c830 Removing the explicit load for most types in type.rb 8aebdfc Removing the reference to the symlink type 2d43580 Most of the graph handling is now done, and all of the recursive types (basically just file, tidy, and component) now correctly use the generation mechanisms in the transactions, instead of sticking them in their @children array. Now I just need to go through the rest of the tests and make sure everything passes. d3b76d6 Removing the symlink type finally. cdd1e6e Another intermediate commit. Most of the graphing work itself is now done, but I am in the middle of converting files to use the graphs and at the same time am writing some actually decent tests for the file recursion stuff. 01e5b69 adding note about --no-client 8ff90ef Fix bug in example code: all resources now must have names f3a0c48 Most of the graphing work is now done. I have also added the generator work in transactions, but I need to migrate files to using it. Until that migration is done, files will not work correctly for many cases. a7354d0 Fixing link to fsconfig reference ccd7b58 Intermediate commit -- I am ready to start pushing the graph stuff into the types and transactions, which will break everything for a little while. c301b1b Make spec file work for Fedora < 5 and RHEL < 5 3e3f70e Adding GRATR and the beginnings of graph integration. 34c89b0 fixing typo b3c3de2 Fixing #342. Classes needed to have their namespaces set to their fully qualified names, so that contained code and definitions looked for definitions starting with that fq name. 4076101 Fixing mount tests after fixing the backward compatibility 185ba8c Fixing backwards compatibility in mounts -- they were not correctly copying the path over to the name 5f5417a Fixing #347 (I hope). Doing a provisional require of rubygems. c369e40 Fixing #346 -- on some scripts I accidentally used "feature" instead of "features" c3c5851 Fixing configuration storage -- there was a check being done that caused false values to get converted to nil values, which failed in the database 25d563b updating syntax matcher to highlight dollar signs in prototypes 60af8e2 Updated to version 0.20.1 e313a26 Updated to version 0.20.1 68d9e78 Updated to version 0.20.1 7d46167 Updating changelog for 0.20.1 7fa96cb Another small fix, just for solaris db5d9d4 Another testing fix 0efa969 Fixing more tests 5d2f954 Fixes to the test system, and a couple of small fixes to the main code. Also, disabled the "port" type, because I cannot seem to model it correctly. f8b9e86 Fixing a small syntax error in the port provider 35de0e3 Temporarily reverting all of the recent rails work so that I can release 0.20.1 26b32b9 adding svn keyword to notify type and reindenting e936fcc Removing the caveat so that the log message is always provided during a run. b2e98b1 Fixing #339 for real this time -- fixing the log message 1bf97cd Fixing #339, and the bigger problem it concealed. Metaparams are now only added to resources that do not explicitly set them. 50d28ef Applying patch from #335 0a35c34 Removing some debugging, and trying to track down a bug where symlinks get recreated for now reason ff06a8d Ported sshkey over, yay. 4e96031 Adding a NetInfo provider for hosts. Yay! 064ddbc Hosts now work again, and it should be straightforward to create a netinfo provider, too. bb80c1b Ports are still broken, but I need to work on something else while I am thinking about how to fix them. Stupid /etc/services. 25b575f adding a comment to namespaceauth.conf b2a49c9 adding up-to-date example configs 4d5f70f Trying to get a netinfo provider for mounts working, but i give up. I am leaving it in place but marked as highly experimental. bd169b4 Mounts work again, at least with the parsedfile provider. I still need to create a netinfo provider, but it should be short and easy. And, painfully, I still need to port the other six or so subclasses to this new provider. 138150d Doing some refactoring in how state values are set. The primary motivation was to provide the ability for the "newvalue" method to specify whether the provider should still be called, and if so, in what order (e.g., before or after). 5685013 Fixing the state class so that blocks are optional for values. This is useful for cases where you want to specify values for validation but you want a method called on the provider instead. 0643113 An intermediate commit. All of the classes that use parsedfile are assuredly broken, since I have basically completely rewritten it. These classes have been a thorn in my side almost since I created them, yet they have been significantly less functional that I wanted. So, I decided to do the rewrite I have been putting off, just to spend all of the maintenance time now so I do not spend 3 days on them every release. 7c8614b Adding module for parsing files. This module is only included into the parsedfile provider base class, but it is cleaner to have it broken out like this. f9d6213 Fix silly regexp mistake where lines with values containing '=' were parsed improperly. b44ebe2 Fixing some warnings 9f8849e Mostly small changes toward 0.20.1 10634d6 Fixing #324. Mkusers was not specifically ignoring the root user, and it is now. 349e2aa Updating docs with correct links for the doc restructuring, as mentioned in #322. 5a4f807 Fixing #326 -- parseonly now just creates a simple Master without opening a port cbb4578 fixing #327; debian packages now correctly register their "latest" status 87fd075 Adding a simple report that just duplicates client logs onto the server 10c860f Slightly more doc updates 114cd8a More doc updates -- I moved the doc headers into separate files, rather than having them in the code b14982a Small fixes here and there. The rails changes needs to be pushed through the collection code, so I am committing so Blake can take a look at that. aa2da58 Updating docs f438bab Refactoring the doc generator a big 1f548f9 Updating documentation 87aea8b Fixing rrdgraph report (as marked in #334); also, expanding the docs on all of the existing reports. 51882d9 The new rails files. cf166c2 Rails stuff part 1 28c283c Fixing some sticky problems with checksums when just using the "check" metaparam. 744ded3 Merging the code over from the oscar branch. I will now be doing all development in the trunk again, except for larger changes, which will still get their own branch. This is a merge of the changes from revision 1826 to revision 1834. dc4d980 Syncing up with FE repo specfile (only mandatory changelog entries) 033de88 Making some documentation changes e741b7b Fixing some Class.to_s handling 0930b5e Mostly rewrote intro doc 71924ad Updated to version 0.20.0 a488dd9 Updated to version 0.20.0 4688d93 Updated to version 0.20.0 f9f939e Updating changelog for 0.20 e3b4f23 Another round of bugfixing, including finding out that the tagmail report was leaving zombie processes lying around 07f616b A round of bug-fixing on OS X ed38ba4 Doing some work on the DSL. It behaves a little more like the real language now, although overrides use the same syntax as normal resources, and there is no facility for specifying defaults 7b34e25 Another round of bug-fixes in preparation for 0.20.0 ead49c6 Applying patch from #318. 7261cbb Applying patch from #319. 3a6683e Changing the realize() function to be just syntactic sugar for a collection -- it literally creates a collector object now. The benefit of this is that it is late-binding, so file order does not affect whether a resource is available. 05080ff adding docs for virtual resources a05b8f5 Adding a "realize" function that can be used to make one or more resource non-virtual. It is just syntactic sugar for a collection by title. 8a4bf1b Hacking cron so that it works even though I have changed ParsedType. The whole stupid thing needs to be rewritten from scratch, but this is the best i can do for 0.20. d77d6d4 Adding prefetch of providers to transactions. Nothing is using it yet. I wrote it for cron jobs, but it is too much work to fix this for cron jobs right now. f1ebef0 Fixing virtual object collection. I apparently broke it when I added rails collection back, and I never created any end-to-end tests. 52105c6 Fixing doc generation for objects w/out their own docs 1d35f28 Fixing a bug that only occurred if a defined resource was already defined in memory. ada7777 sshkey now uses a provider 95f2fe7 Ported mount over to using providers 86dae84 Fixing ports to now use a provider 7e488b2 Working on migrating the parsedtypes to using providers for the parsing aspects. This just converts the hosts; I will convert the others next. This is all work from the sync-retrieve-refactor branch, modified to work with trunk. ce4c494 Fixing puppetmodule to use env to find ruby 0472b24 First batch of fixes from running tests. 5ddbc36 Fixing sbindir path, thus fixing #302. 29ff4f3 Switching from calling "up" on the migration directly to using the "migrate" method. It is still not checking versions or allowing external forcing of migration, but it is a start. b4ebe76 Rewriting nearly all of the tests for the tidy type, and redoing the internals of the testing. 9e5ea8c Fixing the test scripts so that the library path is modified in ruby instead of in the env line 72688e3 Fixing gennode; it was not actually adding the class code to the generated node. 816c5ce Adding a ruby header to all of the tests so that they can now be executed as normal ruby scripts. Using multiple commits because I am having some svn problems. 1d56ca6 Adding a ruby header to all of the tests so that they can now be executed as normal ruby scripts. Using multiple commits because I am having some svn problems. 624eddf Adding a ruby header to all of the tests so that they can now be executed as normal ruby scripts. Using multiple commits because I am having some svn problems. 67704e7 Adding a ruby header to all of the tests so that they can now be executed as normal ruby scripts. Using multiple commits because I am having some svn problems. 0859da9 Adding a ruby header to all of the tests so that they can now be executed as normal ruby scripts. 1020c04 Making all test suites executable, adding some tests for handling changing files from one type to another, and fixing #304. The problem with #304 was only occurring when backing up to a filebucket (I can only think the example code was wrong) dad596e Fixing #291 -- the problem was that instead of throwing an error on a missing server, puppet was just exiting. 9a8636c Moving all of the configuration parameters out of puppet.rb into puppet/configuration.rb, and adding a PATH setting as requested in #307, although it does not include a default. 86b3386 Adding the ability to have hooks for configuration parameters. This will simplify things like setting the shell path. 32deb3f correcting warning about spaces before parens c48f68c Adding patch from Jeff McCune, #317 9bd5593 adding explicit load of ast/branch to its subclasses b9ed053 Format tweak for fact tutorial. 5403a91 Adding a summary of using facter and using imported facter facts with puppet. 90e4c7b Adding some documentation to the programmer's documentation introducing the concept of providers. f545350 Adding some documentation to the programmer's documentation introducing the concept of providers. 7b75590 New documentation hierarchy: fixing indexes. db24e17 New documentation hierarchy: fixing indexes. 628f6c9 New documentation hierarchy: fixing indexes. 9c01560 New documentation hierarchy: adding indexes. ba33249 New documentation hierarchy. da7cb9f New documentation hierarchy. 7b0e528 I was stupidly creating an error but not raising it. 29cce30 Moving methods around so they are alphabetical ed89572 Committing the metatype branch -- this is just splitting the type.rb code into multiple files for readability b4fd8d1 Catching missing ldap correctly in puppetrun b5344f2 Fixing the problem reported by Adnet Ghislain where facts do not load on later runs. 8f9264b Fixing code from [1754] -- I stupidly did not even do a parse check, and I had to refactor the patch because parameters do not have code associated with their values. 94484df Applying patch from #234 from David Schmitt. This is also untested, and the patch is slightly modified. 4a8c5dc Adding modified patch from #256 -- apt now uses "responsefile" for the preseed file. This is untested, though, since I do not know how to test it. a7c88e8 Adding patch from #308. 08900a4 Fixing #298 - refreshonly now correctly deals with specified false values 133c17f Fixing #305 -- logs now reopen when Puppet restarts, and there is also now an autoflush mechanism available so logs will flush to disk immediately. I also now trap USR2 and reopen logs when it is sent, so if you just want to reopen logs you do not have to restart the whole process. c3cc162 Fixing #309 -- files now correctly replace any number of slashes with a single slash. Also, trailing slashes are removed, since that is how Puppet expects to find files internally. c8ea361 Fixing #301 -- s/logfile/logdest/g 1c6cb60 Fixing #310 -- users no longer autorequire their homedirs, and files now autorequire their owner and group. 34f8337 Refactoring reporting. Reports are now modules instead of simple methods. 5b6ee8c Adding a "genmodule" equivalent to classgen, which we will use for reporting 1cdbe52 Added a section about testing. 96aabac adding id tag to tags.page d532ea8 Documentation edit addfe16 Adding a document to outline the use of tags 0716c83 Expanded documentation for rrdgraph report. 675495c Many, many, many performance improvements in the compiler (I hope). I did not change functionality anywhere, but I did some profiling and significantly reduced the runtime of many methods, and especially focused on some key methods that run many times. ab0141a More specific configuration and argument documentation. c7a7381 Documented signals the puppet daemons accept Documented host type to make it clear ipv6 is supported aea6eaf adding id tag to reports 8f058a0 Fixing the rrdgraph report so that it creates a separate rrd directory for each host b892093 Fixing weird case where the default node is in one node source and the real node is in a different one 06a7d34 Fixing ldap nodes -- they were always returning true because i was returning an empty array for missing nodes. 2489764 Changed document priority. c1afdec Another minor formatting fix. c9f6113 Missing tick. d72c970 Adding some documentation on reports. 8a8191f updating install docs with new suse pkgs 1213d60 Removing some left-over debugging 28cee40 Merging the changes from the override-refactor branch. This is a significant rewrite of the parser, but it has little affect on the rest of the code tree. e0e2913 Renaming logfacility to syslogfacility as recommended by lutter. 30fa686 Adding configurability to the syslog facility, using the "logfacility" parameter. da0c862 Do restart as stop + start, since sending HUP to puppetmaster doesn't work (see trac #289) ee76231 adding links to the real deb pkgs dc6d426 Comment out the setting of PUPPET_LOG, so that puppetd uses its default 6e6cb8f Messages will now be at current loglevel, regardless of whether the object path is displayed. 30f9fa3 Added parameter 'withpath' to toggle printing of the object path. 8cc3c8a adding a note about single-quoting node names 5da80db - New type Notify for sending client-side log messages f53b9b0 - New type Notify for sending client-side log messages 04c0c14 Changing warnonce to Puppet::Util::Warnings.warnonce. 8214c48 Fixing suidmanager so it uses warnonce instead of using a variable that only existed in Util de304e5 Rephrased a short section about finalizing the object dependence hierarchy. fee5116 Fixing reported problem of crons rewriting every time when the environment is set 244a11d Fixing what I hope are the last batch of problems caused by the addition of the suidmanager module. Also fixing a couple of other small issues that somehow cropped up. All tests should now pass again. 674841c Just fixed some RCS/CVS id tags. 98028ce Adding flush functionality as requested by Scott Seago fd9b2f6 File types were dying silently on OS X when the group specified in the manifest was not a valid group. db7d784 Fixing SUIDManager#asuser so that it only resets egid and euid if they were changed dfef7e1 Adding a note about another error d888d9e Added some documentation to the security page to offer some example invocations useful for generating/signing certificates for clients and servers. ab225aa regenning configref with the fixed spacing b4970a9 Expanded documentation of command-line arguments for the puppet executables. (Tweak) cc08e2f Expanded documentation of command-line arguments for the puppet executables. 008a138 Expanded documentation of command-line arguments for the puppet executables. f2ac4dc Updating changelog for 0.19.3, and merging the version changes over. 68016a9 ! rename file because rake_test_loader is dumb. 287b18c + New assertion: assert_uid_gid will check that the UID and GID have been changed to the proper values. This uses a fork and a FIFO to achieve it's checking. ! nonrootuser and nonrootgroup now only return users/groups that are less than 255, due to the "Darwin debacle" ! many, many, many fixes for suidmanager. This is rather embarassing. 55f2873 Merging the fix to server/master.rb 3aac2e1 Some small housekeeping things that I saw while doing other bug hunting 48082a1 adding note about the irc channel 515f3cc Harded-coded pathname to OSX's ssh_known_hosts as a work-around until the ssh pathnames are user-configurable. 7b5604b Adding some test reports 6f11dee + Puppet::SUIDManager - This replaces all calls to the built-in ruby 'Process' library for uid/gid/euid/egid operations, including (not surprisingly) Puppet::Util#asuser and a method to run commands and capture output. This is due to many inconsistencies (through bugfixes) between ruby versions in the 1.8.x branch. This is included in the core puppet library and can be used by all puppet types and providers. ! Modified Puppet::Util#uid to check (and warn) if passed a nil value. ! Changes to use Puppet::SUIDManager instead of Process and relevant Puppet::Util calls. ! Removed Puppet::Util#asuser. 320ac38 Updating CHANGELOG for 0.19.2 8f9dcb5 Updated to version 0.19.2 595d5ba Updated to version 0.19.2 6902f2d Updated to version 0.19.2 164c18f As requested by Christian Warden, triggering an object now results in an event, which can result in further triggers. 98004b2 Adding some error handling for when a non-existent report is asked for, and adding a bit more testing. a1e27bc Adding trace information to autoload.rb 0bd3055 Switching Autoload#loadall from using "load" to using "require", so it will not reload already-loaded files. Also updating the checksum docs a bit. eecc7cc Fixing error in tagmail when there are no messages to report a468c15 Disabling a test on solaris, since apparently sh on solaris is different than everywhere else 64a3392 Small test fixes in preparation for 0.19.2 d35d04e Adding class list method to group. Also added a test to verify every type responds to "list", but it does not pass right now so it is disabled. 9afdf1f Adding an Autoload instance to Type.rb so that I can load all known types for documentation purposes. And, of course, loading all types in puppetdoc. Also updating zone.rb to fix markdown's stupidity in trying to interpret the ERB template, and adding some timeouts to puppettest.rb 1ae4344 more fixes to the zone examples c8c3ee9 doc updates 2e17e4a Doc updates 9bd69c4 Typo: As stood had "remove" for "remote" fcf16f7 Fixing #245, opened by marthag. 1ad76d1 Fixing #278, opened by Digant, with patch. 5faa45d Fixing #274. I just set :ensure to be :link when :target is set. 62abbd5 Fixing #283, opened by luke. ea4b9c8 Fixing #285, opened by ericb. c99843a Fixing #288. 2b27289 Fixing #293, I think. The problem was that the groups state was not correctly passing strings in all cases, which caused some very strange problems internally. 0870c5c Fixed a minor typo dc8fb0a Fixing #292 (A bug in tagmail that causes any tag other than 'all' to fail) and #277 (tagmail report missing To: header). afed9a1 adding an extra make target for debugging, rather than defaulting to always creating the debug file e88bf77 Rake::TestTasks were running the test suite inadvertantly against the installed tree instead of the development tree due to a botched "libs" setting. bc15e04 Fixing provider commands and Util#execute so they always include the command output when possible, as mentioned on the list f0a9345 Regenerating docs, and correcting some markup mistakes 62917fc Small update to the fileserver tests; it was apparently not making some test dirs correctly 3891f48 Converting to using the Rakefile for testing. The old 'test' script is now deprecated, and I'll send an email to the dev list and update the docs to reflect that. dcab464 Reworking test/lib structure a bit, and renaming all of the files so that their file names match their module names abe1d3c Fix trac #282 (Change URL to configref, mention --genconfig) 7030aca Small modification so i can make more changes 6a1b43a updating changes from the trunk 6747b6a going through all of the other providers and making sure any reference to a state uses the :should value, not the :is value. 69d4083 Fixing case of silly states on os x, where files are owned by "nobody" and File.stat returns a huge number. I thought i had already fixed this, but apparently not. I added a test, and it is definitely fixed now. 8cbe19f Fixing the same bug in the netinfo provider -- it was retrieving the "is" value instead of the "should" value 6137812 Fixing #280; added a warning and exiting if no hosts are specified to clean 533a022 applying patch from #275. aptitude -q works fine on my testing release, but apparently stable does not support it 94f5865 Removing the no-longer-necessary type/nameservice info -- it is all in the provider tree now 94762e1 Trying to fix a bug where files other than site.pp do not get noticed for reparsing 176d483 Add config option 'node_name' to control what puppetmaster considers the proper name of a client (name in the SSL cert or name uploaded with facter) Default to name from the cert fd4ef3c Better documentation around certificate revocation and mgmt c8a6df0 Updated to version 0.19.1 ee8b8c7 Updated to version 0.19.1 6f85511 Updated to version 0.19.1 0e58f65 Updating changelog for 0.19.1 4a3c8d1 Adding testing for the default? method, and fixing it to support arrays and returning false when no defaults are specified 48992d7 Using the "trace" configuration parameter to determine whether a stack trace should be printed, rather than just using "debug". I added the param a little while ago and was using it internally in Puppet::DevError, but I just now went through the whole configuration and switched to using it. cda7253 Adding patch from #235 5219205 Fixing docs, as mentioned in #271. c04cb13 Reverting the work done in [1605] and [1606]. I have added it as a patch in #271. 08499b1 Adding the feature from #259. I had to rework the Scope#lookupvar a bit, but everything now works as expected when variables are either undefined or set to empty strings. 26bf373 Applying patch in #160. e46d007 Fixing #262. I somehow lost the line that only added a given user's jobs to each tab. 0af8ad7 Removing a test in the parser that is no longer necessary because of how imports work now, and fixing a snippet not to interfere with a local fact 5669d1b This commit adds two important features (but which probably were not worth the priority I suddenly placed on them). fbdd6c4 Specifically rescuing Exception, since apparently the default does not rescue LoadErrors and everything else 349bddd collecting output from blastlist, for later use 4cd37ad Merged test framework into trunk - still not ready until tests are converted to use it. 4897995 Fixing the "Adding aliases" message, so it is clear when an alias with spaces in it is used 6bb4814 Fixing #267. The problem was that the user provider was retrieving the @is value instead of the @should value, because it was using [] instead of the should method. I fixed the FakeModel to behave a bit more like real types, so that it keeps track of the is/should values, and also to keep track of which attributes are valid, since I immediately ran into another problem stemming from the use of the fakemodel. e5aa761 Updating changelog for 0.19.0 2c57173 Raising element creation errors up outside the "create" method, so that tests can more easily tell when an object is invalid. 16d9d6f Fixing spelling of retrieve, to fix ##268 3b8c9ff Fixing #269. I was aliasing every case where the title and name were different, where I should only have been aliasing isomorphic types, which does not include exec bf5d0bc Catching all errors encountered during loading, not just LoadError, to fix ongoing problems with rdoc/usage. 64eb1e8 Let puppetd listen (when given --listen) without a CRL 5e2091b Brute force fix for trac #266 37c9633 Fix test_host_specific to not depend on the path of the test directory and reenable it aa56185 Expanding the Fedora/RHEL instructions some 47dc290 adding note about david's yum repo 8ff418c Fixing the problem with fileserver expansions, and doing a bit of refactoring to make things clearer cf5291a Fixing the interpreter to nodesearch across all listed names, just like is done in the manifests. Also fixing a comment in type.rb ca6ac62 fixing typo 0527426 adding gentoo notes 3e1b6bc Adding a :trace config option that prints stack traces of DevErrors, and using that in DevError instead of :debug 95269bf Adding test code for providers that makes sure the default and confine mechanisms work internally. 09f264a Add config parameter ca_ttl and deprecate ca_days; ca_ttl makes it possible to generate certs that are valid for < 1 day 130b245 Use Pupet.warning instead of nonexistant 'warning' a5f4f53 Fixing #261. Applied patch, with small modifications. 0c0936b Adding a module for helping with warnings, starting only with the "warnonce" method af1de89 Sync with FE repo c651b19 Disable the sample fileserver module by default, otherwise users get spurious warnings about nonexisting directories 65bb635 Updated to version 0.19.0 61e42e7 Updated to version 0.19.0 12b219e Updated to version 0.19.0 e309b76 Modifying the provider base class so that it defines a method for every used command (e.g., you call "commands :rpm => 'rpm'", and it defines an "rpm" method. I then pushed this throughout the package providers, which are the heaviest users of commands. c5ce953 Adding aptitude support, including a new util::package module that provides a method for package version sorting, and a couple of smaller bug fixes. This fixes #237. 2113eed Adding hasrestart parameter to services fcc5bae Adding an "env" parameter to exec, for providing extra environment settings, as requested in #236. 8310c9d Adding a "withenv" execution util method, and using it in :exec for path handling. Next will be other env handling. f8254c6 Fixing #230. If the first line in the cron tab, before the header, starts with TZ= then the header will be inserted after the TZ line. fa16a92 Fixing small bug in cron where removed fields are not deleted from the file e28250d Adding further gentoo support -- finalized portage support, plus conf and init info for puppetd 41c9081 Adding the Daemon module back into the Client class, which fixes #247. 46fbf95 Adding an "ignoretags" attribute to transaction, and setting it for downloading plugins or facts, and for creating config directories b303e8d Adding the ability to download facts from the central server. This allows facts to be available before the configuration is compiled. b36df18 A small fix to the install/update aspects of packaging. 47c86e5 Fixing the package type so that :ensure is always used for version specification, rather than :version, which is now deprecated. This provides much more consistency. I have not tested on all platforms yet, but I want to enable testing on Gentoo, also. 19992f7 updating documentation for how to specify versions 7eed92e Applying a patch from Jose Gonzalez Gomez; apparently this makes package updating work 40b2ed6 Adding portage support again, since it was added in the branch i reverted 617fe58 Removing all of the changes I made towards refactoring in the last couple of days. They have all been moved into the sync-retrieve-refactor branch. This branch will soon become 0.19.0, and will not include that refactoring. 8f39318 Committing a small amount of work in cron. I have decided that this is too last-minute, and not important enough to hold up the release. I want to get this refactoring done, but it is clearly not the 4 hour job I hoped it was. It will have to be in another release, I think. b43b489 Committing functional mount support. All that's left in this chunk of work is cron. 639ed3d Adding first version of the portage provider, as contributed by Jose Gonzalez Gomez 655881c Ports now work with a provider daa79e2 Intermediate commit; ports are not working yet b657850 Fixing SSHKey support. 270f444 Beginning the process of moving parsedtypes to a provider. Each parsed type will have a parsedfile provider, which will be responsible for all of the file parsing and generation. This should allow us to create a useful DSL for file handling, but it also *drastically* simplifies these types. b9b3384 This is the initial commit of the changes to sync and retrieve. The structure itself is now in place, and a few of the types (the most complicated ones -- file, user, group, plus exec since it was my easy first test) have been converted. 3733034 Renaming parsedfile to loadedfile, which makes much more sense and reduces some naming conflicts a887993 Adding Gentoo support from #224. c626796 Adding eat-last-line support in ERB a115050 Adding pre- and post-hooks, as requested in #233. f797487 Fixing #239 -- missing checks now throw an ArgumentError. This will break if any command purposefully returns 127, but that would be a bug anyway, I suppose. ff18e55 Adding support for file purging, as requested in #250. Any unmanaged files in a purge-enabled directory will be removed. 18320ee Adding a "force" parameter in files to fix #242. Currently only used when replacing directories with links, but should probably be used in other places. 7fd5b6f Specifying true/false allowed values for file[:replace]. 8cbe1d3 Adding logcheck script from #244. 2cb2e03 Applying patch from #251, and switching "confine" to "commands", so we can document the command requirements. 712e157 Adding SuSE files from #252. 42812f8 Applying the patch from #253 plus tests. fd86428 Updating templating docs with more about usage, and adding installation notes about ruby segfaults on Debian f587d88 Adding note about configprint, indicating what versions include it 989716e Adding zone patches 96350b2 Fixing #257, where host aliases were not being retained. The problem was that the "should" method was returning an empty array if it was not set, and it should instead return nil. 114debd batch of small bug fixes 2802b70 Making sure that the svn bin directory is at the beginning of PATH, rather that at the end, so the svn-versions of the exes are being tested. b086280 Removing type/provider references on type removal 053f37c adding notes about the libruby deb package 77783e5 disabling reporting until i can find a way to make reporting only work with puppetd, not puppet -- clearly puppet should not try to report 199f5b0 Fixing the state so it tries to call provider methods and only checks for errors, rather than checking with respond_to? b6b9d0b Setting both "report" to true by default; I am going to enable pluginsync by default once I have plugins well-documented 02b8b13 Fixing array printing in to_manifest 29edb14 Fixing service refreshing -- there was a problem persisting from the provider work 14d64dd downgrading the template interpolation message fa0446b Adding back in the code to change the euid. I removed this yesterday because I thought it was redundant. It is absolutely clear that I need to add tests for running as separate users. 6f175ce Adding automatic stacktrace printing to deverror. I need to go through and remove the redundant puts in the rest of the code, but I need this now for some client debugging a46a620 disabling chuser on os x, since it is broken with < ruby 1.8.5 a53d840 fixing provider commands; I broke them when making them easier to document 0f231b8 Skipping blank lines and comments in autosign.conf 9381d5f Fixing report lookup so it looks up by name, not method 948c96a Changing autosign mode to 644 762599b Fixing tagmail config processing so it fails when appropriate 0674c9a Fixing reports error reporting a6c38b5 Fixing location of ca cert 04b2557 Fixing report autoloading; I was calling the wrong method, and they were never getting loaded 47dbf82 Upgrading Triggering line from info to notice d45d22b Adding a module specifically for making doc generation easier, and adding defaults info to provider docs. e1aff4c Last commit of puppet docs for the night b9ad604 Modifying providers so that docs generate better 9b526ba Adding provider docs for required binaries 6aaeb05 Updating generated docs 5395e23 Adding pointer to templating docs into the file[content] documentation 8dbca3d adding notice that "$" is now required in definition prototypes 333c229 adding first draft of templating doc 628896b Adding a "configprint" option for printing out the local config state 9f7621b Adding a little more validation to the schedule, and documenting the source search-path stuff in files ad32b71 Tracking down some weird bugs that managed to creep into the parser. I expect that the main ones were a result of the If support. db0be8e Committing some changes to the %h expansion in fileserving. This change makes the expansion entirely isolated in the Mount class, which makes it much easier to test. Also, switched the fileserver config to use ParsedFile, which makes it a bit easier to understand and handle reparsing. a44b1dd Committing the other half of the fix for #231; oops ed15471 Fixing #231. 55d3fb8 Support for %h and %H replacement in the path of fileserver modules. 2540cdf Demoting the xmlrpc access logs to debug from info 38a184e Changing permissions on the cert file and the ca cert file, since it is no problem for them to be readable and sometimes it is required b612a15 Try this; seems to work for machines with both ActiveSupport installed and not. MissingSourceFile is an AS thing, though it subclasses LoadError. 8fcec23 Adding up2date support, as submitted by Kostas Georgiou (with some modifications to support providers). 9576d1d Certificate revocation through puppetca. Keep a simple text inventory of all certificates ever issued. 4151fd5 Committing definition inheritance. I have not yet written tests yet, but my last commit pretty seriously broke some things without me realizing it, so I wanted to get this in. 1b2ee4b Adding "if/else" constructs. No operators, no elsif, but it is a good start, anyway. ea32a38 Function autoloading now works as requested in #214. bba972f Adding warnings and error throwing for #218 -- metaparams in prototypes are treated specially. a1d71d9 adding faq item about ipv6 support 6e4d4c9 Accepting patch from #220, thus fixing the bug. e322161 Fixing #225. Normal file copying worked with spaces, but recursive file copying did not. I modified one of the support methods so it works now. bf43c76 Fixing #228. The real problem was that "present" should match any type of file existence, whereas it was just matching files. If the file was a directory, as in this case, Puppet considered it to be out of sync. Now, "present" matches files, links, or directories, but still creates an empty file if the path is missing. aee1c6a adding cookbook into to the docs index page 7ade561 Support for certificate revocation and checking connections on the server against the CRL c6fc6c5 Adding a link to the cookbook b2031aa Making some of the metaprogramming a bit more explicit and a bit easier to manage. In the process, I have created multiple Util modules, only one of which is used for this current commit. beba3e4 Finishing changes to support titles instead of two types of names. This is basically a bug-fix commit. 607d7c6 A first pass of changing one of the types of names to titles. I still have to fix a lot of tests, but the core itself is now working. 12452ee Merging r1468 from the implementations branch with r1438 from when the branch was first created. 4d6120a Committing changes that require dollar signs in prototypes abaeb86 removing classing example, since it involves parameterized classes e684cd3 Adding some documentation for the cfengine module 1eaf1bc Fix problem when --fqdn is used e6aa4ab documentation updates, pointing to the suse yum repository and specifically mentioning package locations 0e862a3 Fix shebang lines in executables 450b495 Added comments to stay in sync with the spec file checked into Fedora Extras CVS d6fc1b7 more ordering info 89b4dfd adding ordering information 7957ce0 fixing puppetdoc to add ordering info f974ffc Fixing the master server so that it always uses the Facter hostname, not the cert or IP hostname. eb8c687 updating links after a link validator 257fb78 fixing faq links 3ef4663 adding DSL class. Sorry, not much in the way of docs. 31b1d0b fixing more doc links b2f1aa0 doc updates b8bf113 Updated to version 0.18.4 94cc68b Updated to version 0.18.4 ce95ee3 Updated to version 0.18.4 f13c451 updating changelog for 0.18.4 cdeccab Another batch of bug fixes, this time focused on OS X patches. Looks like I did not test on os x last time. b42eaee First round of bugfixes in preparation for 0.18.4 9e61510 Fixing #77. As I feared, this was a pretty complicated fix; I had to add a lot of infrastructure to both ParsedFile and Config. All config files now have a timer created for them, and by default they check for file changes every 15 seconds. If there is a change, they get rid of values set by the file (but not set on the cli) and set the new values, then the re-use all of the sections, so that any changed directories or whatever get recreated. 310b3a1 Adding timeout functionality to the ParsedFile class, in preparation to adding config reloading to the Config class. c8537a5 Apparently objects were legal rvalues, which does not make any sense. Fixed this, and added a test verify. 21ae8fb Fixing #185. Added a check for cdrom sources, and added an override parameter. 039abd6 Fixing #176. You can now do duplicate UIDs (or GIDs on most platforms) with :allowdupe. 2091edd Fixing #200. I basically just moved the daemonize statement before most other code. This makes things a little less nice when starting puppetd manually, since it might still fail and the user would not know without checking logs, but it is the only real option at this point. 76aec7c Fixing #202. Just bumped the log level to notice and changed the wording slightly 3cc3f66 Applied patch in #203 7228413 Fixing #201; users now autorequire extra groups ebd28e8 moving plugin evaluation into a begin/rescue block 8e25115 Fixing puppetdoc's output 041c07b adding all mailing lists to index 19e411b removing message about the statefile not existing 09e0792 more doc modifications c9640a7 Updating some docs, and renaming configuration reference page 40e2db3 All docs moved over now, and the real index page exists again 813d1c9 committing docs before i move all of them into a separate subdirectory f02f6f7 Adding Solaris SMF manifests and methods 0b90333 Fixing #191. I was only testing for parsed cron instances, not for created ones. aba3d65 Fixing bug in scope/interpreter where nodes found in ldap must have parent nodes. The problem was that the the scope was using the presence of a parent node to determine whether a node was found. Instead I added a flag in the arguments to "Scope#evaluate" to mark nodes as found. 01c8808 Adding a unit test for plain "nodesearch" 08650c1 fixing html markup e74b8af fixing html markup 8273f21 fixing index page in the docs b23b797 Updated to version 0.18.3 fe8ce26 Updated to version 0.18.3 a984a90 Updated to version 0.18.3 8063ab1 Fixing filebucket server so that paths are not added multiple times 1ab4594 Adding tests for previous config bugfixes, and updating changelog a6cc3e4 Fixing reports so that multiple host report directories can be created. There was a config conflict before. 73556a8 Fixing templating so it immediately fails when a variable is not found, as opposed to passing up the method_missing heirarchy, which was causing a nasty memory leak and some kind of weird, long-running search 1ec1b99 Fixing weird case involving interpolating config params in a URL 8f28c6f Fixing weird cases where configs might think non-files could be files b116ac7 adding sysidcfg param to zones a3849d7 Fixing templating bug that can result in what looks like an infinite loop, and changing default timeout to 2 minutes instead of 30 seconds 86a92de Reducing log level of missing file 7139901 Fixing error when template does not exist 3fbd06a Fixing misstated error name ExecutionError in blastwave packaging support 829c754 Fixing reports server so it refers to the main server 0acebb1 Default the passno to 2, defaulting to 0 is a bad idea since it disables fsck 44c54fc changing plugin owner to root 9be1e0b changing default plugin host to be $server a4a04fe adding rake targets 0c96fc6 Doc change: explain what the values for ensure do 67dab0e adding another state that is equivalent to "stopped" for smf services 8a10b08 Adding the newly generated docs e57f6e7 More documentation updates. I think this is sufficient for replacement of the plone site. 9b7f428 Fixing rakefile so it generates docs from markdown, and adding big-picture.page to the menu 70877fb removing faq.rst file fefe1c5 Updates; remove mention of patches from specfile completely f42666c updating changelog for 0.18.2 eff8d6e Accepting the patch from #190. 6b281ed removing cf2puppet from rpm bd9fd8d Updated to version 0.18.2 71036e7 Updated to version 0.18.2 aa87963 Updated to version 0.18.2 afe84ec small fixes towards 0.18.2 e17f4ed adding host information to reports and tagmail report 1503b42 renaming tagmail config file c3a8d45 Redoing reporting a bit, so that reports are now defined as methods. If they are not methods, then they cannot use return, which makes things a bit uglier. 3c22bc9 fixing some smallish bugs in preparation for 0.18.2 73569d0 fixing a small but important typo, and adding sunfreeware as a dupe of blastwave packages 87ce8ed Adding blastwave packaging, and doing some fixes on gem and sun packaging 2e78526 Some updates resulting from trying to track down a segfault introduced when I upgraded to 1.8.4-5 in Debian. I never found the segfault and had ot downgrade to 1.8.4-1. I expect it will not be encountered in real life, only in testing. e57c513 Adding Ruby Gem support to packaging 25cf31b Adding minimal update checking for templates. It will only check the templates that have been parsed in this process, but it is better than nothing. c899e23 documentation updates c1e0bc6 More report and metrics manipulations. This should be the last of it. 34e779f Significantly redoing metrics. There are now no class variables for metrics, nor no class methods for it. 24f07e0 committing tests for previous changes dea7e24 oops; adding transaction report class 70143d2 Trying to merge metrics and reports. There is now a separate transaction report class, and it works throughout the previously existing system. I will next go through trying to make a metric report that graphs the metrics in rrd. 795ec70 adding a "thinmark" method, which does a simple benchmark with no logging 19b5d30 Accepting patch #189, although I am just putting the environment statement in the main part of the class, since there are two apt commands ff6562f Fixing #133. Added a "notify" and a "before" metaparam; notify is the opposite of subscribe, and before is the opposite of require. 9bb9e10 Fix a small bug in mount where parsing fails if dump and pass are missing (they are optional on Linux) Revamp the tests slightly so that they parse fstabs provided in svn rather than relying on the fstab on the system the test is running on. f792a02 Moving the template handling into a simple wrapper object so templates don't have full access to the scope object without some real hacking. 8b60619 adding some tests for the template function a6dc7f2 Adding initial template support. It is just a function, and a method_missing method on Scope. e47a987 First commit of complete reporting support. The only existing report at this point is the tagmail report. I expect reporting to get significantly modified from here, but it is a good start. ea91896 changing the #!ruby lines to #!env ruby 1677594 Adding reporting client, server, and tests. At this point, the server just stores the report in a file as YAML. 56a2845 Adding report collection to both statechange and transaction. d275489 Updated to version 0.18.1 35ef37b Updated to version 0.18.1 427831c Updated to version 0.18.1 7adafc6 For each type, adding a "new" method to Puppet::Type, so instead of typing Puppet::Type.type(:file).create(...) you can now type Puppet::Type.newfile(...). e8c57ae Cleaning up plugin handling a bit -- they can now be colon-separated paths, and I added a separate "plugindest" setting for determining where plugins are synchronized to. The major feature I added, though, is that Puppet::Type now knows how to load plugins, and treats :pluginpath as a search path for plugins. d98ab11 Fixing zone tests 4985d8f adding message about retrieving plugins dec4053 updating CHANGELOG for 0.18.1 5471211 Moving the timer monitoring to after the services are created (because they actually create the timers), and adding a sleep statement to give the threads enough time to create the timers. ad1396d Fixing backgrounding in puppetrun; I had the bit flipped between the client and the server, such that setting --foreground caused the clients to go into the background. 5be3c10 Converting Parameter#proxymethods from using eval to using define_method b2304f1 Making sure fail function converts everything to strings c363af0 Adding "fail" function, which will raise a ParseError if it is encountered. 57a5a71 Catching errors thrown during object evaluation and marking the objects as failed. 506269f adding hooks for ignoring files in the plugins directory, and defaulting to ignoring cvs and svn files 7685957 removing that info message, duh; it produces a lot of spurious output during parsing c886194 Adding info messages about errors loading plugins 772ea91 Adding support for special freebsd @schedule crap. Also making sure that cron listing works as expected. 08f113c switching puts to print, so the carriage returns are always included in the messages bdd1761 Largely refactored how log destinations are handled, although it is not exposed externally. Most of this work is related to handling a large number of small problems related to threading. 73a4bcc Changes to make puppet package more LSB compliant. Update specfile for very latest Fedora ruby packaging guidelines. lsb-config.patch only checked in for documentation purposes, since changes are part of this checkin. 0411f74 Fixing some more small problems in puppetrun 31c17e4 Adding more docs to puppetrun, and fixing bug that can cause hosts to get skipped faab17b adding - to HUP in init scripts bb5366f Updating init scripts to use HUP for restarting 3c5b10d Adding a "latest" test for rpms, since I have been told this is not working. It seems to be working fine, but the test cannot hurt. 5cf2a4d Adding HUP and USR1 hooks 4a71706 Fixing #178. I just added URI escaping and unescaping to file names. f9a4d7a Fixing #175. The setpidfile setting was being ignored. d812840 Fixing #182. Added a retry section to try reconnecting to ldap. Only one reconnect is attempted in a given search, and LDAP produces bad enough error messages that we reconnect regardless of the error thrown. 46824cd Setting pluginsync default to false, and (hopefully) fixing autosign problem when the file exists and autosign is set to true (#180). The problem was that the puppetmasterd script was redundantly setting autosign in the CA, when the CA already knows how to deal with autosigning, which meant that autosign was being set before the config was parsed. Thus, there was no bug when autosign was set on the command line but there was when it was set in the config. 15905bd Fixing broken symlink behaviour mentioned on the list 0a1e847 Adding plugins and plugin management. The Master Client will now automatically download plugins if pluginsync is enabled, and they will be automatically sourced. edabf9e documentation updates 4df2583 More documentation changes. 8ad2008 adding id tags to all of the docs 58826ca further work on converting from rst to markdown b6a52b7 further work on converting from rst to markdown 3772aaf further work on converting from rst to markdown e891ffb updating some docs and puppetdoc in preparation for a move to webgen instead of plone 90e8ad8 removing the old rst index file 644fd4e updating docs to work with webgen f090760 Fixing my autorequire fix; oops 084a31d fixing autorequire message to include the object type bdb9110b Delete entries from the config file if their should is 'absent' 883921c Test that setting a state to 'absent' really deletes it from the config e841d8f Adding test and fix for empty execs being ignored 6ef3d88 fixing interpreter to initialize ldap in the nodesearch_ldap method, which really only matters for testing (since it is already being inited in the nodesearch method 662fcaf making links even if the target does not exist 0ab461b Updated to version 0.18.0 daac8cf Updated to version 0.18.0 8779dbe Updated to version 0.18.0 ae3dba9 updating changelog for 0.18.0 ead6b17 updating documentation for sshkey 20b0a6d fixing transaction tests to just warn when the user is not in more than one group, rather than failing. be92c44 Setting options and the facility for syslog 9a1b9ec Fixing some logging issues with puppetmasterd when daemonized with verbose mode on, and fixing ldap support when daemonizing c1dd0a1 Changing statechange noop message so it's a bit clearer 603a53c Just logging host failures, not exiting c1f0fb7 Adding fqdn, an --all flag, and --test mode to puppetrun f86357d adding namespaceauth and --listen docs to puppetrun 97c7342 Adding fixes for solaris zones 02d397c abstracting out ldap connections so that there is a single method responsible for all of them and a single connection can be shared in all classes if necessary 076e888 adding ssl usage to puppetrun 15da00c Fixing ldap usage when ldap libs are not available 4a5b886 removing extraneous debugging 7ed5560 Fixing installer; it somehow got broken with recent DESTDIR fixes fd8e080 Fixing #173. At this point, I am just calling both "--add" and "on", or "--del" and "off". This should probably be broken up into other states, but.... ef163ba fixing parallelization to match the docs 1dfd554 Fixing packaging to deal with the fact that yum exits with 0 exit code even when it is told to install a non-existent package. df340d6 Correcting puppetrun docs and fixing a test so it works with older versions of facter b4b3c27 Adding support for default nodes as requested in #136. ba4071c changing puppetclient schema to descend from top instead of iphost 07e0d59 Fixing #169. Tags are ignored during config. c380bfe Fixing the main bug reported on the list today relating to file sourcing truncating linked-to files. 90762c5 adding noop marker as requested ec0609d A round of bug-fixing in preparation for the next release. 9af5d69 adding nothing test to zone tests a6122e8 Fixing ldap node lookup. The test was set up badly, in that it did not actually provide a way to enable ldap node support, even though there was a config option that should have worked. All works now. 360a405 turning on output flushing edfaf6e Adding support for following referrals 555e1b8 Fixing #135. I was setting the object to the result of an include? test, instead of just "obj = ary[val]", so all but the first bucket-backed files were getting errors. 8ceb1f3 Found a bug where single-value selectors can fail on a second compile. Fixed it, and am now compiling all snippets twice. 4ca7ece modifying rakefile to specify the package hosts; they were previously hard-coded in the build library 09d2cd0 Fixing #168. Reworked the regex to allow matching TLDs. 1fc4ec3 Fixing #167. Started with the submitted patch and made a few more modifications, and added a regression test. c90d0b1 Fixing #157. Objects are no longer allowed to be their own parents, and there are checks in both directions to stop this. 7c358df Fixing #166. Function names are no longer reserved words. e73f2d4 Fixing #158. I did not add a force option, since I always back files up before I replace them. 4266f64 adding faq to docs d6d05d4 Fixing #154. Basically just accepted the patch that fixes master.rb and added a test case for it. 1cef8f5 Applied patch from #153. 2257d6f Fixing #155. It is now valid to have arrays with no values, although you will still likely get erratic behaviour elsewhere in the system, depending on what you do with this. 0e52409 Fixing #159 -- packages now have a default value for ensure (:installed). 3758bdb adding rakefile for the docs 1a93e6d copying all documentation from the plone site d84827e Committing largely complete Solaris zone support. I still need to add static filesystem support, but everything else should work. 73c5c58 removing one of the stack traces from error output 95f273e Fixing #163. Strings can now correctly escape dollar signs. a3ed629 Intermediate commit; most of the core zone functions now work, and some of the configuration functions work. 81ce66a Fixing node tests to handle comma separation 011e811 temporary commit so i can transfer my testing to a faster, sparc box add6b80 Fixing #160. Fixing the error in Puppet::Type#[]= and scope.newobject 76ff83d Fixing #161. Basically, AST::ObjectDef now catches when users specify a name as a parameter instead of the name before the colon and modify the results accordingly. This catches this kind of problem, and the normal name handling picks up everything else. b08816b Fixing #162. Node names must now be comma-separated. 2fcbc7f Adding an "execute" method to Puppet::Util, and including the module in element.rb 354b945 adding zone management stub; switching to my home vm for testing 98ad43a fixing destdir in installer, and adding solaris conf stuff 4cd3019 Did some work on making sure object removal actually works, thus stopping some potential memory leaks. Also explicitly removed objects in more places, again hopefully forestalling memory leaks. 45a9edb Reworking cron; adding many unit tests, and making it much more like a ParsedType (although still not quite the same). Too many of my tests were invalid; I think those are all fixed now, and it appears to work as desired. 3ab4a89 Small fix to include puppetrun in /usr/bin 62a0ff0 adding puppetrun to the red hat spec file fda013a Updated to version 0.17.2 3c15a28 updating changelog for 0.17.2 a08ca93 Fixing #138, all of it, I think. Environment settings are now allowed, although all bets are off in terms of parsing existing environment settings in crontabs. 69cf2fe Adding a small fix to cron tabs; they will at least parse tabs that have env settings in them, although you still cannot, at this point, set them. 0381cc1 slight ldap fixes in puppetrun d55adda First version of puppetrun. It seems to mostly work, but I need to test it with greater parallelization. 5671ce8 Added the last of the tests for the runner, along with the necessary work in puppetd to be able to start it. b3ea53c Adding a lot of structure to puppet.rb to make it easier to manage multiple objects in a single process, including making it easy to add threads. Added some testing for all of that. 93771b7 fixing user[:groups] management when the user is absent 738698c Updated to version 0.17.1 ed9adf5 updating changelog for 0.17.1 and 0.17.0 9b5de11 Allowing empty files 5382118 Fixing #146. I think I mostly just fixed the error message; I do not think there was another bug there. 89ce72f fixing stupid debian rails mistake dc3a6d5 Making sure file recursion works for all valid inputs 373afa3 updating version on spec file 4296b02 Updated to version 0.17.0 3be0f95 Wrapping the host storage into a transaction. It might have a slight performance improvement, but, ah, unlikely. 9d6166e adding a test to make sure that defaults get taken up by components a0bcf5a Adding code to try for the rails gem if the library cannot be found normally, and adding some protections in case there are problems 122e2bc only performing collection tests if activerecord is available 8f14c3f failing more intelligently in init if ActiveRecord is missing def5175 Making sure yum fails on unknown packages 2e9f1c4 removing extraneous logging d9fdd8e I believe I have finalized export/collection support. I still want to go through all of the code and s/collectable/exported/g (thanks to womble for that term). ba57dff I had to redo how the scopes handled collectable objects (which I will soon change to being called "exported objects"). All seems to work now, though. 22e70f0 Made a *huge* performance difference in storing hosts -- down from about 25 seconds per host to about 5 seconds on my machine. I will almost definitely still use forking or something to make this not affect the clients 637cc71 I appear to have object collection working, incredibly. This commit does the collection from the database up to adding the objects to the current scope, which is what sends it to the client. 9e9ef1a The "collectable" syntax now works end-to-end -- the parser correctly recognizes it, the AST objects retain the settings, the scopes do the right conversion, the interpreter stores them all in the database, and then it strips the collectable objects out before sending the object list to the client 8ed666a adding a few more fields to the host table 5863a03 Adding initial rails support. One can now store host configurations using ActiveRecord into a database (I have only tested sqlite3). Tomorrow will be the grammars used to retrieve those records for object collection. 0819e35 Adding some small changes towards fixing #140 and #83, but this work needs to take a back seat to object collection, so i will come back to it later. 678e142 Fixing #141. It was a problem related to the recent parser changes I made. 578cf7e removing some extraneous logging a2a4dd5 Updating doc system to add the list of valid values to the doc string, and tweaking a few docs. 710bf0d Slight modifications to package parsing on *bsd. It should be better about catching the version number, and unparseable lines are now just warnings, not errors. 9e77e7a It is just a snippet test, and thus a functional test but not a coverage test, but definition overrides officially work. This was important because it enables definitions to be collectable, which was not possible without the mechanism that enables this. 513b87a Preliminary commit of the first phase of the parser redesign. The biggest difference is that overrides should now work for definitions (although i do not yet have a test case -- i will add one on the next commit). The way this is implemented is by having scopes translate themselves at eval time, but in two phases -- the first phase does the overrides, and the second phase does the evaluation of definitions and classes. fe16f83 making a test to verify that the functionality womble is looking for now works bb60cab Making trigger logs much clearer -- you now get info logs indicating how many dependencies changed, and debug logs indicating what those dependencies are 88c3f7c Changing how events work. Events are now responded to inline, while an object is being applied. 7b7ac18 Changing default for pattern to include the binary if it is included f0aeaec require the very latest facter to avoid problems because facter changed iphostnumber to ipaddress e06c661 Small bug fixes 58cfd1e Fixing the problem that lutter ran into; the issue seems to be that Facter could not find the ipaddress on the server. 18de804 fixing log messages a7fadbe fixing log messages 43fdd89 Updated to version 0.16.5 64a58e4 updating changelog for 0.16.5 44f1579 Fixing a stupid bug i managed to introduce in 0.16.2 (probably) involving importing files with classes in them. This is a better solution than what I had before the bug, anyway. Also, some documentation fixes. a9df49d Fixing some naming problems with crons, and adding appropriate tests e8c912d Allowing dashes in class names, although grammar rules restrict it from working anywhere except node names or in tag(). They are valid in host names, and many companies have them in the host names; in fact, this fix is for a company with this exact problem -- they cannot use puppet with their nodes because all their hosts have dashes in the host names. 37d2850 Switching to just using "preserve" for file copying in file#handlebackups 8b0481c Updated to version 0.16.4 4b84ca9 updating changelog for 0.16.4 b67a19b Fixing #132, which involved creating a separate CA client and using it to retrieve the certificates. There was more work to do because of the weird client/daemon/server heirarchy. a435d07 Updated to version 0.16.3 3f08155 updating changelog 2faa447 Bug fixes from OS X for 0.16.3 5e246ab Hopefully final bug fixes in preparation for 0.16.3 cc5ce34 Fixing tests looking for pmap a1574a5 Fixing TransObject#to_type so that it does not modify the object being converted 7825f49 Changing test for service paths; only testing if it is a directory if it is present. 65f6656 Added some code that could be used later to make sure the user and mode are also copied on backups. 0ad65e9 Adding a check to make sure the mode is copied over. 84db91e Fixing the docs a bit for the executables, adding a --daemonize option to puppetd and puppetmasterd so they can still be daemonized with debugging or verbosity enabled, and causing puppetd to fail to start if a PID file exists (and not setting a pid file if running with --onetime enabled). 12c122c Puppetd now has an option for listening -- just run the --listen option, and it will start up with a pelement server. It will fail to start if the authconfig file (defaulting to /etc/puppet/namespaceauth.conf) is missing, since it defaults to access at this point. 047e63f Making file copying significantly faster -- i found an extra call to "describe" in file sources and an extra read/checksumming of the dest file 94caa8a Fixing #128. md5lite was being used instead of full md5. At this point, md5lite cannot be used for source copies. bcfc469 Adding in all of the patches necessary to make a prototype rails interface to puppet nodes work. The biggest change is that there is now a separate NetworkClient class for every Client subclass, because otherwise you get namespace collisions. Most everything other change is a relatively minor patch. 9539dbb Adding in all of the patches necessary to make a prototype rails interface to puppet nodes work. The biggest change is that there is now a separate NetworkClient class for every Client subclass, because otherwise you get namespace collisions. Most everything other change is a relatively minor patch. 9b627cd Trying to track down the bugs reported this morning, so I added some more test cases. I did find a bug in the filebuckets, fixed it, and added a test case. 003e897 updating changelog for 0.16.1 and 0.16.2 a78bf1e adding "clean" mode to puppetca bda8e52 This should have been in 0.16.1. Moving the "setclass" statements around so that classes are set before a given class's code is evaluated, so it can be tested within the code, within node defs, components, or classes. bff9463 Adding sum type to the retrieved sum if it is not already there. This provides backwards compatibility for existing cache files. feff317 removing unnecessary debugging baa412c Adding "defined" functino to puppet, so you can now test whether a given class or definition is defined. 46ce36b Creating a simplistic, generic function framework in the parser, so it is now very easy to add new functions. There is a pretty crappy, hardwired distinction between functions that return values and those that do not, but I do not see a good way around it right now. Functions are also currently responsible for handling their own arity, although I have plans for fixing that. ccc4d95 Modifying non-existent-package test to make sure syncing fails, and modified ports package type to check the error output instead of the return code, because the portinstall command returns 0 even on failure. e64bd22 Fix ownership on server files (trac #122) Change ownership on /var/puppet 9fe0b37 removing patch from red hat spec file a0b4553 Final commit before 0.16.0 63cdc6c making corrections to pass tests on freebsd d9fd002 Go some work started on developing authorization, but I have made little progress. I might wait on this for the next point release. 4a029d9 pelement listing now works d91b7df Added a list class method to just about all types, and it seems to actually work for everyone. Now just to add a list method to the pelement server. a9b67cc Adding a "list" class method to most types, and using it in the tests for the pelement server to verify that objects can be copied using it. I expect that most package types other than apt/dpkg are not yet working with these tests. e24a299 A simple first version of an object (called "pelement") server is now in place. There is not yet a client, and the tests are pretty simple so far -- only files have been tested yet. I had to make a significant number of modifications to the file object in order to get this all to work, and one of the big changes I made is to the internals of the checksum state. ac04981 Actually adding the ports file that provides freebsd port support 3f9e918 Adding freebsd ports support c83bc91 fixing test to know that i skipped alerts 538bc0c Fixing service stopping; I had the %x{} command quoted 6f66011 Fixin #102. The syslog name is now either the name if the process (if that name includes "puppet" in it) or "puppet-" and the name of the process. Also removing the "alert" test messages, since they result in a wall. d2634ba Fixing #118; the hash is now always 8 hex characters, 0-padded. Also changed the CA cert name to the FQDN of the host serving the CA, rather than "CAcert". 449f662 Fix handling of run files so services can't be started twice (reported with patch by soul916 at gmail.com) 21584a9 Don't create empty log files in %post (based on report by soul916 at gmail.com) a564e49 Changing the log level of the "defaulting to base service type" message d56870c Fixing a bunch of small bugs, mostly found by testing on solaris, and added a check to the test system that points out memory growth 0478f78 changing set to tag in the tests 26f18a2 Fixing puppetca so it does not call chuser; instead, it is configured to create all of the files with the correct permissions and ownership (using Config#write and Config#writesub). c3961ae Adding doc generation for exe arguments 133ad87 Oops, typo in client/master.rb 689dbf4 Adding --test option to puppetd (it enables --onetime, --no-usecacheonfailure, and --verbose), and modifying the docs a bit. cd9ea80 Adding locking to the master client, so that only one copy of puppetd will be running. This should make it safe to run puppetd manually while it is also running normally. 71793fb Changing "set" to "tag" f522a7e Adding the host name as a tag (stripped of the domain name) 373fb3b Modifying "setclass" on scope to check the validity of class names, now that "set" can be used to set them manually, and added a test for it. 8df349c Fixing the language side of #109. Added a "set" keyword. de0d1dd Adding a few informative facts on the server side: serverversion, servername, serverip. And only printing the parse time in the interpreter if it is not a local connection. bca4f5e Adding the puppet client version to the fact list as "clientversion" 9f92a3d Adding the puppet client version to the fact list as "clientversion" 4d75041 Adding a "tag" metaparam 201aa02 Adding simple benchmarking, and using it in a few of the more obvious places. Also, fixed a bug in Scope#gennode. 0507486 Fixing #117. If only one value was provided, then it was not placed in an array, yet AST::Selector expected an array. The grammar needs to have some abstraction added or something, because I seem to have encountered this bug for every ast type that supports arrays internally. ae4b12e Revamp the yumrepo type to deal with repositories defined anywhere in yum's config files. Adds a generic module Puppet::IniConfig for parsing ini-style files 8df6e84 another small mount fix; this time, for stupid os x 88dd992 committing version changes d10a638 Committing an important fix to mounts; since i am sure no one has downloaded 0.15.3, i am just going to rerelease 0.15.3 with this fix in it 83d5236 updating changelog for 0.15.3; I need these exec fixes for my client e5be7d3 Adding autoloading for types and service types, also. fcce820 Okay, last one, hopefully. Modifying checks to support arrays. 37a4a55 And, one more time. My test for the last bug did not actually retrieve, so it did not enounter the problem, and i had also forgotten to add the "check" boolean to the checks. Hopefully this will be the end of exec bugs for the day. 4ab74ce Fixing checks so that they can run even if the set cwd does not exist 50ffa7f adding a bit of debugging 1e4abae moving cwd existence check into "sync" instead of "validate" 7dae24f Fixing a small bug in type.rb that ignored false values (instead of nil values), another small bug in value setting that resulted in the file and line appearing twice in errors, and added validation to all of the checks in :exec (along with testing for all of it). b0edb35 removing patch from spec file 122cf58 updating changelog in preparation for 0.15.2 013cfd2 Adding darwinport type. 9697354 differentiating openbsd from freebsd, adding freebsd, and autoloading package types instead of manually loading them f540ec8 fixing a couple small bugs in doc generation 668342e fixing Config#mkdir test to not check gid on any BSD, since they appear to ignore egid when making directories or files 572648e adding deprecation notice 84693d6 adding some docs 2b27545 renaming; i hate bsd ee65279 Fixing #103. There are now no such things as node scopes; the entire tree is evaluated on every node connection, and node facts are set at the top-level scope. This includes,um, the code; the last commit was accidentally just test changes. c3c413e Fixing #103. There are now no such things as node scopes; the entire tree is evaluated on every node connection, and node facts are set at the top-level scope. a0728c0 removing the parser dir 8db837a getting rid of the parser tree, and moving everything into the language dir d4a5b48 loading yumrepo in the test, since it is not being loaded in the main code e8c0471 Fixing a couple of bugs in preparation for 0.15.2; mostly they were in the testing system and resulted from changing :File to :Manifest in server/master 9230289 Disable yumrepo type since it won't work with the FC5 repo files b5c759b Fixing #108 d8b4b0d adding -e ability to puppet executable c0a9e5f Change how names for nodes are specified: the 'node' keyword can be followed by a NAME or by single quoted text, i.e. fully qualified names for nodes must be enclosed in single quotes 5d42cd5 Fixing the class file to actually store class names, not object ids. Also added tests to make sure it all stays that way. c8be52b Finally! We now have mount support in OS X. Ouch. 3327dc8 Adding netinfo type and some tests 97d5ab6 eliminating some debugging, and removing a small redundancy bug in nameserver.rb 35e65de Fixing authstore to use an array for ordering, rather than a hash, duh. c3b7d62 Bugfixes for OS X. I had to do some shenanigans on type/file/ensure.rb -- it was testing whether the parent dir was writeable on object creation, and if not it was not setting ownership and such, so i added some post-creation checks that will fix ownership if it was not set correctly at creation time. caaa331 changing ssldir perms to 771, so non-root users can write to subdirs if they have permissions a791d98 Fixing a logging bug that apparently resulted from logging changes a while ago. 4daf2c1 Adding apple package support, but it is very limited -- packages can only be installed, not upgraded or removed. f37154e making a small change to the test, so failures are more informative 7c7c223 Added a test for Type#remove, and fixed the method so it actually works. I was missing every other object, because i was iterating over the array being modified. This caused the Config stuff to often fail, because objects were not correctly being removed. All fixed now, though. 72774bb adding mkdir equivalent of Config#write e6f9163 Adding a "write" method to config objects, so that files can be easily written with the correct owner, group, and modes 0f15e8c fixing a bug that appeared somehow in port.rb, and adding mount and sshkey to the types being autoloaded 0eae739 renaming filesystem to mount 48d7fd6 Adding filesystem support, and modifying parsedtypes a bit to fix a bug where non-instance lines were being duplicated c7ae839 Manifests can now specify node names with fully qualified domain names, too. 9b1e8d5 Accept a single file as a test to run in addition to a directory bdc819b Remove unused should method; add more yum parameters to the type a9fdf9d Disbale running puppetmaster as puppet until we've sorted out which files need what ownership (there's trouble with /etc/puppet/ssl right now when puppetmaster runs as non-root) 1365103 New yumrepo type for basic management of the yum configuration of one repo. 6d4e46c Adding os x group management support 791e4da Committing support for group membership management. Currently only works on Linuxes and other OSes that use "useradd" that support -G. 932fd03 commiting package test fix that i thought i committed ages ago 28602a6 Simplified as yum install can be used for both install and update 95b762b updating changelog for 0.15.1 fc98ab0 Fixing #100. I just added a bit of a hack to configuration parsing -- if a group is specified in a section that matches the name of the process, then it is assumed to be the group that the process should run as. The problem is that we are reusing the term "group" here for both the run-group and the file-group. Oh well. 5dcf303 Using differents commands with yum depending on whether the package is currently installed or not. 7e908a5 Removing ruby as a dependency, since too many packaging systems will have installed it differently 73d051f Fixing service enable/disable on solaris 10, and fixing some problems with the tests 5e86634 Converted everything over for Puppet. The Rakefile is, um, a *lot* shorter. :) 8416f21 This version appears to work well with epm stuff fc68910 removing dos EOL chars 086050d Minor changes from Fedora Extras review 72f1e8a Don't mark puppetmaster for start by default; makes rpmlint happier 6006a5a Add little snippet on passing an additional option during system boot, but leave it commented out 6af21e5 adding sbin directory c74fd81 Committing the EPM support. I am in the process of moving this to a common library that all of my projects can use. 271a8d2 Adding EPM package building. 805b32b Updated to version 0.15.0 92e3c1e Updating changelog for 0.15.0. ec7d46e fixing small bug in the test code when there are no packages to test f851be7 Adding upgrade ability to sun packages. Currently it removes the old package and installs the new one. 4d1c221 Changing the way the hosttest output is handled 29ec706 adding some extra info to the ldap test 76474ed Fixing fileserver tests; apparently they were still broken from when i changed the fileserving interface to handle links. d7a75c5 Fixing small bug in symlink recursion f2c8218 Fixing #94. When "ensure" is synced, it syncs the "enable" state at the same time. aed1f11 Ooops, did not save the docs before committing. 5a47afd Fixing #98. Filebuckets now work throughout the system, and the puppetmasterd creates one by default. I have also updated the :backup docs, adding an example. 1b11697 reducing the log level for checksum warning about symlinks, really this time 454247f reducing the log level for checksum warning about symlinks 08b36cc Adding enhancement #92. Unfortunately, I was not able to write test code to consistently verify that this works, because there is too much caching internally. I verified it personally using my own configurations, but that is as good as I could do. This indicates that caching should probably be rethought, so that there is some kind of global "do not cache anything" mechanism. 97913d4 Fixing bug related to recursion testing c6230dd Fixing rpms so they will automatically upgrade when you point Puppet to a new package file caa3d43 fixing broken test from my previous change fa9aab6 Fixing #82. You can now specify comma-separated tags to get run in puppet or puppetd: puppetd --onetime --tags "enhost, facter" -v. You cannot specify classes explicitly, but tags map well to classes and have the benefit of being more generic. 414d364 Supporting rpm installs when a package source is specified 8728920 Using undefined variables is no longer an exception, it just returns an empty string. 4ee395b Fixing small bug when autorequire returns an object instead of a string 2cd67ad There was a critical design flaw in the link recursion work I did previously, and fixing it required a decently large reorganization. Everything is much, much cleaner now. 02f91fc Merging symlinks back into files. Symlinks still exist but with a warning about deprecation. Fixes #93. Also the first time I have run any tests on OS X, so there are some bug fixes related to that. b336e7e Parameters and states can now register regexes as allowed values. Also, there are (finally) tests associated with params and states, although they should be much more comprehensive. b6d829b Fixing #95. I had to redesign how events were triggered; the transaction now individually triggers each subscription, so that it has control in how to respond to failures. Eventually, this will lead the way to error handling within puppet, but for now, it just allows us to trigger every appropriate subscription, whether some have failed or not. 782f85a Creating a single, constistent method for writing files, instead of having :ensure, :content, and :source each have a slightly different mechanism. This method also makes sure that the owner, group, and mode are always set on file creation, so extra runs are not necessary to make it work. 2dbd7e1 Fixing #96. Defaults are now set when the object is passed out by the scope, rather than when the object is created. This is nice because it also moves awareness of the scope internals out of the AST object and back into the scope. 7756f9a Fixing #97. I was wrong about the object type I had, so I was calling "type" with no arguments, which was causing the bug. 2faff5d lowering the log output for nonexistent files eb68633 Updated to version 0.14.1 cee0882 updating changelog for 0.14.1 2351cd7 making case statements not create a new scope 54fcdbd fixing some more logging issues 0549d03 Making some logging changes, and fixing a small bug in group management on missing files 72d747b Updated to version 0.14.0 b76004a Fixing yum listing bug, and caching the "latest" value so it is not asked for so many times; this fixes #90. 3c07deb Committing the last changes, for now, to handling links. You still cannot copy remote links, but you can either ignore or follow them. I do not think we will be able to copy remote links until I have merged symlinks and files to be the same object type again. e9e88b0 Adding "links" parameter to files, and adding support for following or ignoring links to all of the states it can matter to. I still need to modify "source" so that it behaves correctly when managing links. 1099c4a removing group ownership of the state file; I realized that the server does not ever actually write to it. 5cca870 Switching from using "evaluate" to using "retrieve" when getting checksum values, since retrieval is sufficient, and evaluate keeps printing messages about changes. 17d4b23 Fixing logging in the fileserver so it is always obvious where the logs are originating, and fixing a bit of debugging elsewhere. df74b62 fixing deprecation notice about services using "ensure" instead of "running" 8c0a07a removing extraneous debugging be4d3fd fixing the mode of the yaml file f2ea9b7 Supporting variables as the test value in both case statements and selectors. 1a3de8a renaming 549bc5f Only setting group or owner on config files when running as root 7ea739d logging config changes at debug, instead of the normal log level aae9b2a Definitions now always create their own context, which means that they cannot override elements in the containing scopes. 451ba6d upgrading to warning the message about using a cached copy faffd69 Updated to version 0.13.6 caa7f48 updating changelog for 0.13.6 343dd08 Fixing tests so they do not chmod /dev/null to 640 (stupid tests). 1a93c82 Fixing #68. After tons and tons and tons of work, everything successfully configures itself, and the --genmanifest argument should actually work. User and group creation will not necessarily work everywhere (in particular, Puppet uses dependencies to create the group first, but Fedora complains on user creation if the group already exists), but file and directory creation should. The only downside is that there is a decent amount of extra information printed on daemon startup, as the daemon checks its config; this could maybe be seen as a bonus, though, I guess. 95856ea Okay, Puppet is now almost entirely capable of configuring itself. I have not yet added the extra tests to puppetmasterd to make sure it can start as a normal user, and the executables still fail some simple tests because they are producing output when they start (I will get rid of the output), but overall things look pretty good. ff1df8e Remove hte fedora-usermgmt stuff. As it turns out, it's not a Fedora Extras requirement to use it; so we'll just have useradd/groupadd allocate id's dynamically 2db2317 Adding metadata to defaults 179779d Changing the setdefaults input format somewhat. It is always a hash of some kind now. 4574928 Intermediate commit; setdefaults now accepts both hashes and arrays 6d8a1dc Fixing user and group management in the config handling. 65ed766 adding a connect log to the master server 32cbc59 Fixing #70. We now have user and group management on FreeBSD. 8b5f709 Fixing bug #60. Converting nodes to use types everywhere instead of names, and adding a localobjectable to keep track of what parameters have been defined locally. eda9d95 Fixing #64; multiple class definitions in the same scope is now an error, although using the same class name in different scopes is not an error. 56116c2 Fixing bug #73; node names now appear only once in the path c894eb2 Fixing bug #75, providing support for unnecessary end commas. 020499c Removing all of the autoname code 8c821c0 Mostly, this is a refactoring commit. There is one significant new feature, though: overrides now only work within a class heirarchy, which is to say that a subclass can override an element in a base class, but a child scope cannot otherwise override an element in a base scope. 37c10d1 Switching setclass to use object_ids instead of class names, and adding some comments. c5d8680 Fixing scopes and AST so that definitions and classes are looked for in the scopes, instead of in a global list ee818a9 Adding some debugging to list the states being changed when in debug mode 63afa37 Fixing nodes so that their paths are printed correctly 5056054 Removing timestamp debugging b119a72 Fixing output when user/group are not found 772c7c8 Adding TERM to the signals being trapped 503ad38 Fixing bug #72, where trailing slashes break file sourcing 043fc33 adding commas to each line d06cd3f removing the initial syslog dest setting f6ca82b Updated to version 0.13.5 85e4d31 adding changelog for 0.13.5 2dffbee Adding redhat service type, to support enabling and disabling a service 7e5cc76 Fixing package types so you can specify the package type manually in a manifest 7806618 removing extra error statement 6e26a73 adding passwd converter 3aff15e Updated to version 0.13.4 1f05ad0 updating changelog for 0.13.4 cfb0e36 updates 89856ec Adding a bit more logging 82e02eb Fixing bug when creating containers with parents 31df227 Generate an error if the pattern for an import statement matches no file. beef01c Properly figure out when updates are available. Previously, packages would neverbe updated because 'yum list foo' first prints the currently installed package. Now we use 'yum list updates foo' 3ac5cd9 Incorporate initial feedback from FE review 68aa302 Fix failure of test_importglobbing in test/parser/parser.rb 70d2379 Enable passing --parseonly from the command line 1ebb416 Adding single-quote syntactical element 1fdb962 Changing transactions to be one-stage instead of two, and changing most of the type classes to use "obj[:name]" instead of "obj.name" where appropriate, because "obj.name" might be a symbolic name (e.g., File.unlink(file.name) will not do what you want if file.name == "sshdconfig" but file[:path] == "/etc/ssh/sshd_config") 5f8d615 Removed some of the autorequire stuff from :exec because it created untenable require loops, and created a test case for some complicated exec + file recursion. The test case fails, and I want to have a clean committed repository before i mess much more in trying to fix it, which might actually not be possible. 6cc8157 Duh, removing some debugging 5f4335f Adding logoutput parameter to :exec 89702d8 Fixing symbolic naming bug where symbolic names were being ignored in some cases 7d15fe1 Updated to version 0.13.2 037b7ac Changed the parsedtype definition of exists(), and fixed a few smaller bugs. Last code commit before 0.13.2 6fe01ce Tracked down a few other bugs; everything now passes on debian in preparation for 0.13.2 8602932 Changing "answerfile" to "adminfile", adding "responsefile", and autorequiring both. d1cd443 Fixing users so that they can use a group created by Puppet, and they also now autorequire that group. To do so, I modified Puppet::Util.gid, which required that I fix Puppet::Type#merge to support merging managed and umanaged objects, which required fixing a bug in Puppet::Type#managed?, and I also changed the ensure state to only default to a value, when the object is managed, which required that I change the defaults system to support default procs that do not return a value. In other words, lots of fixes for a smallish problem, but we are much better off now. 4df3468 Fixing the order of arguments when using admin files with sun packages 20b65e7 Some important bug fixes in the parsedtypes types; this all started from the submitted bug today, but I added :absent support to most params. 6cfee76 Committing the initial ldap support -- puppet can now look up node configurations in ldap. The test scripts currently only work on my home network. 1994263 Adding --enable/--disable locking for puppetd. You can now disable puppetd from running by creating a lock file, which is useful if you are testing a configuration and want puppetd not to run for a bit. 798b3be Adding a general "check" mechanism to :exec, so it is now terribly easy to define a new check to perform, converted :creates and :refreshonly to use that mechanism, and then added :onlyif and :unless as new checks. Also added any files they mention as autorequire files. 376725e Adding --loadclasses option to puppet f098485 Correcting some path problems with symlink, and changing "target" state to "ensure" 3f15cb8 Fixing :target reference in pfile.rb 9508bd0 Correcting some path problems with symlink, and changing "target" state to "ensure" 64eafa8 Updated to version 0.13.1 a456c4d updating alias docs to pass ReST checks 1a05ed2 updating changelog and docs for :alias 89d37f6 Fixing some problems with cron tab management, and creating Puppet::Util.{u,g}id methods. 96388cb Fixing locking. It apparently was not working on OS X, and I was not syncronizing access in threads -- i assumed locks themselves were a sufficient sync point. 2be25d5 Making the language name a real alias. Now all objects in Puppet support specifying both the name and the namevar, or just a name and having the namevar set. 7f7b5c6 Change in how logging is defaulted: by default logs go to :syslog, unless the user explicitly gives at least one --logdest argument, in which case logs only go to the destinations the user gave. b13b5ed Set the Release tag in the spec file to 1 when the version is changed 8c02ffd Adapt specfile to the fact that puppetmaster now automatically runs as user puppet. Add default config files that send logs to /var/log/puppet. d629a80 Fix version in last changelog entry (makes rpmlint happy) 44071d0 Updated to version 0.13.0 2cb5cb3 Updating changelog for 0.13.0 387db24 Adding answerfile support to sun pkgs. 2ce061a adding some documentation cd7a637 removing errant warning ccd0121 Fixing small problem where checksum retrieving did not look in the cache; this was only ever a problem in cases where checksums have no "should" value set, which is generally only the case on the fileserver, but it caused the fileserver to replace checksum values on every retrieval. 8eab733 Fixing the conflict between ensure and source. Ironically I had already made sure there was no conflict with "content", but I had forgotten "source". adda8f0 Checksums now get correctly updated for both the ensure and content state when those states are used 8e4cf22 first bug fixed, where sources were not updating the checksum 58db0ef adding keyword b03635b adding keyword 01072a8 replacing all occurences of "is_a?" in the parser with "instance_of?" 7ca3d3d Fixing bug that occurs with only one argument 195f2e9 wrapping all work in a single rescue clause 59992b5 adding initial ldap schema 0ba9d16 adding vim syntax stuff a5d2404 Simple emacs mode for editing manifests; only does pretty colors right now b98e65f There is now full support for configuration files, and the entire system has been modified to expect their new behaviour. I have not yet run the test across all test hosts, though. f1ffc34 Configuration parameters now require (and have) descriptions, and a set of configuration parameters can be converted to a configuration file, a manifest, or a component. All I have to do now is integrate them into the executables. 6affe22 Committing both the finalization of the config code, plus all of the code necessary to get basic isomorphism from code to transportables and back. Mostly keyword and autoname stuff. 59c7b02 Fix snippet_componentmetaparams test 39d33ca Temporary commit; configs now can be converted to manifests 4ecfa7b Config files now seem to work, so I am ready to start incorporating them. 9114cbe committing test code for bug lutter found d0436f1 Changes in lie with Fedora Extras requirements 56bf12b Fix processname tag 7d711c0 Allow passing of options with 'once'; fix processname tag, add config tag. 5590e3e a couple small changes; the most significant is the addition of a class-level "eachattr" method, to avoid all of the calls to attrclass and attrtype 30bf65f Fixing a significant performance bug in file recursion, and trying to help performance a bit in attribute handling on types d5af359 Rewrote client init script since puppetd is now a proper demon. 6637bb6 Install bin/puppet into /usr/bin/puppet, not /usr/sbin/puppet, since normal users are supposed to be able to run it 931c159 Fix rpm packaging; include conf/ in tar ball, use conf files from tarball in spec file 4ada6af Fixing class storage -- it was not working for nodescopes 8db35ec Caching Time objects instead of numbers, since Bignum does not seem to be YAMLable 96b761b Fixing waitforcert so that the client can actually add the certs once it receives them c7f9942 Adding release tag REL_0_12_0 cf82cfa Updated to version 0.12.0 282cfcf Updated to version 0.12.0 1186069 Small mods to the packaging stuff 87904d3 RPM release is almost entirely there, it just needs to be integrated into release management 9b2afcb Fixing some logging issues ae2575b Adding the event-loop stuff to the repository and switching to using it. Also, breaking many classes out into their own class files. 18e8e74 Committing most of the scheduling stuff. There is still a bit of work to do in terms of how puppetd interacts with scheduling, but the bulk of the work is done. 258114d Modifying docs, and adding scheduling hooks 0cb51f3 Fixing a small checksumming bug, reorganizing the client stuff a bit, and adding freshness checking for the configuration, so the config is recompiled every time nor is it downloaded unless it has been recompiled f49b103 Updated to version 0.11.2 c372a7d modding changelog for 0.11.2 6bab167 Made lots of small changes, mostly to help usability but also fixed a couple of key bugs ed39be9 Fixing most types to allow no statements 3d458ef Updated to version 0.11.1 c3df525 modifying changelog for 0.11.1 060b8bd Adding openbsd packaging support ada3aee Fixing problems where objects were passing @parameters[:param] objects, instead of specifically retrieving the value f36c7d1 Updated to version 0.11.0 3700b37 Adding an "ensure" state where appropriate, and significantly reworking the builtin docs. 92a780a Added "ensure" state to some classes, and added infrastructure for it to work elsewhere. 83906a2 Adding sshkey class plus tests, and adding "aggregatable" methods to type.rb c67fb7b Adding another host to the test lists, adding some test data, and modifying how hosts parse ad9d365 Adding a bit better logging and checking to file access 87b3bb1 Moving ast classes into separate files 1d4638a Added "finish" method, using it in Type.finalize, and moved autorequire and setdefaults to it. a6e367e Changing host and port aliases to also create Puppet aliases. This involved futzing around with the attr* methods in Type.rb, to make sure states are always checked first. c8b6401 Fixing up the parsedtypes, fixing Type.eachtype to ignore structure types bbf2c54 Adding /etc/services support 0c17149 finalizing cron and host management, hopefully df6ff9e Abstracting host support so it should easily support other types 5309479 Abstracting host support so it should easily support other types 3f15e38 Adding initial host support. I can promise that this will soon (hopefully almost immediately) be abstracted to make it easy to add new file types. f420135 Converting transport format to YAML instead of Marshal, and caching the file in a YAML format, also. This required a significant rework of both Transportable classes. Lastly, I am also now caching the list of classes in a class file in /etc/puppet. 8aa331d Adding further notes about openssl 4092a78 Fixed a couple of warnings, fixed a critical bug having to do with case statements (where there is only one listed option), and did a couple of other cleanups. c5782df Adding "content" state to files, and string interpolation handles escaped whitespace characters. b0ea70d Adding 0.10.2 stuff 6b6c49b Updated to version 0.10.2 1cf05ff Services now work at least somewhat on solaris 10, and service testing is pretty different. 4c4f530 Fixing dependencies to not depend on file order. Added Puppet::Type.{finalize,mkdepends,builddepends} 21410a2 Fixing documentation generation, and fixing aliasing so that objects can safely be aliased to themselves 29b00fb Adding "alias" metaparam; you can now create as many aliases as you want for any of your objects. 411ab22 Adding autorequire to files, and added the cwd to the list of files to be required for exec. Also, exec catches inline files and autorequires them. 97fb6c9 Adding generic autorequire mechanism, and thus removing it from exec 11b5463 Adding a requires? method to types, fixed the bug where exec fail when Puppet is downloading the script to execute, and modified "exec" to autorequire any managed scripts 932b783 Updated to version 0.10.1 854f16b modifying changelog for 0.10.1 89d0050 Adding Sun support and fixing the last remaining bugs related to the daemon changes i just made 45ac512 Supporting puppetmasterd running as a non-root user, and doing some basic message cleanup 45c91e3 Adding some extra feedback 7616289 Fixing init path default e5ac196 Adding some consistencies to the executable tests. All exe tests now pass on OpenBSD, although the only real problem was that ruby was in /usr/local/bin. dccafc7 Updating Puppet to work with the new Facter b7974b5 Updated to version 0.10.0 48031dd Describing 0.10.0 changes 48ba030 Modifying hosttest f00a7db All tests pass now, although the lack of service support on os x means that i have now disabled services on it 4275227 updates cbf10c5 Merging changes from the head of the rework1 branch, r 784 23f982e Undoing the merge that happened in 785 1d73973 Merging in refactoring from version 774 into version 784 3ba696d updates cb51688 converting waitforcert to an int cedefab adding ftools require statement to install.rb 7594411 Adding a host test task 86cc467 renaming the module, so it behaves better with people's svn clients 2994cbc fixing rakefile 3b9c9be Updated to version 0.9.4 6af79cc Removing tests from the list of tasks e611f2c adding some better readme stuff b532a30 adding things to the change log, and modifying the order of the steps 584652c Disabling most documentation generation except for the API docs, and wrapping the StatusServer in the xmlrpc check 0e0fdac Updated to version 0.9.3 e2e2fb3 some updates to the typegen stuff, even though i may still not use it 5302921 Fixing two reported bugs in cron jobs. Cron jobs correctly change when fields other than the command are updated, and they do not continually refresh when the command has trailing spaces 592c24d adding some comments f9f84bf removing "host" as a keyword; it was an alias for "node" 4eaf13a converting storage from Marshal to YAML 3c14db1 adding Util.lock, and switching storage to using it 5ce5b95 removing any direct references to /tmp in tests 84bf289 fixing files being put directly into tmp a03b03f removing ruby shebang at the top of all of the files 2a5bbd0 final updates for 0.9.2 58ef35d updates dd727ef removing marks 9f942b0 fixing tests to work from any CWD 58c0df1 fixing incredibly annoying bug where os x returns stupidly large uid when uid is below 0 42c077f updates from os x f815654 updates 5082132 adding cfengine module, which required passing the cfengine classes all the way through the stack to the scope c205bf6 fixing filesources so that the first found file is copied, and adding a test case 6960034 fixing puppet to default to using the console for output d5bd1bc Mostly fixing exec so it either captures stderr or runs as a user; Process.euid was not working correctly a4562bf Lots of refactoring, and added the capture_stderr method 42a9d9a Adding "isomorphic?" method to classes, and testing for isomorphism before throwing a conflict 300a163 Further progress towards the next release. Lots of small bugs fixed, the paths look much better now, and Transportable is much cleaner. 14d8186 Making paths work a little more intelligently 0335743 adding config file stuff, but not using it yet. I have decided to release the next version without them. ba76eb2 Cleaning up tests resulting from the changes to the parser e605a5c The language now verifies some resemblance to closurehood. I now only need to fix the library to expect this behaviour. 526deef Fixed merging of state values, but I have not yet solved merging of parameter or metaparam values, since they are quite different. 9e1c63a Protecting from bug in Syslog, and fixing some more log messages 76176a9 central logging is fully functional now, but it is painfully slow, so it is disabled by default b6c63f6 Central logging now works, although there appear to be a few kinks to work out. 0ae5e33 Adding logging methods to all Puppet::Element instances, and converting all instance log statements to use those methods. Additionally modified logging to take advantage of this by including the path of the logging object in the output. Logs will still need some cleanup to avoid duplicate information. 0d3db79 adding tags and path accessors a8645a4 Further small bug fixes towards running puppet on my network df8dbba fixing sources so that they always have a corresponding checksum state e8912d5 files and directories are now created as the correct user and group if they are set 1b74e8e The Puppet::Util.asuser function now works; had to slightly modify user.rb to make checking work. In addition, exec.rb now takes advantage of it. I also decided to make a small change to type.rb -- validstates now only returns state names, not names and states. 32d89ba fixing certmgr tests f732880 Getting rid of the tc_ prefix to test cases 8fe558c general cleanup, as i move towards running it locally 5ab12f9 fixing path to facter f036778 Apt-cache was showing more information that I thought, so I had to redo how I was collecting the most recent package version a232e5c Made tweaks here and there to get it running better on my local network. I am inches away from that happening. All tests pass. a6d0292 adding better docs to packages 3cd8ee9 "latest" is now a valid value for packages, and yum support is also included 66db3d8 making service changes; it is still basically non-functional except in the degenerate case of using "init" 194dab3 Adding some semantic tagging. It is not exactly full-featured yet, and it is not used at all, but it was sufficient for some proof-of-concept stuff in preparation for the conference 55d7bbd adding tag support to scopes and the transportable class e563189 switching test classes back to modules -- making them classes causes too many empty tests to run every time 9d3aaad removing the redundant pfile from the pfile state file names ed42371 Switched @should to an array, so all objects can now handle that. I have not yet gone through and done the other cool things that can result, but that will have to wait until tomorrow. Also, I moved all of the pfile states into separate files, since the file was getting unweildy. 6af0e0e added overrides ability 0d6241c switching all relationships to be centrally maintained and to use symbolic references, rather than literal ones; also going through and making all tests pass again after mucking with services a96bdac Okay, services are now managed, um, entirely differently. I have the beginnings of a system for supporting different service management frameworks, although I currently only support and init scripts 47ba186 adding a test for includes 9464224 moving specific packaging support into separate files f48f14a fixing behaviour when files are missing 5bb8c4a fixing output in noop abcac81 Rearranging the packaging support a bit -- it is now more clear and significantly easier to understand, maintain, and enhance. 8211df0 Many, many changes toward a completely functional system. The only current problems with my home config are that apache's stupid init script does not do status and that packages are not working as non-root users (which makes sense). d20ac8e Hoping this will get rid of the directory being printed 4c13c10 Nodes now support inheritance, for better or for worse. 781c69b The new "include" syntax works now. 400b103 fixing "ignore" documentation to parse RST correctly. 5590148 Okay, all tests pass again. The work done on nodes will take a little while to clarify and such, but it should work pretty well. f7d9b83 I am still somewhat in mid-change, but I have made the biggest changes to making nodes work correctly. The core code works, but I still need to fix my various test cases 03f5733 adding a ParsedFile class to handle figuring out whether a file has changed f757556 converting tc_relationships.rb to the test base class 5dc3cb0 Okay, significant change -- classes no longer accept arguments (which makes things simpler but encourages the user of global variables, which is bad), and classes are finally singletons, meaning they will only ever be evaluated for each node a single time. I still need to make nodes work correctly, but that is going to involve modifying the parsing system and a bit more 0747b4c adding stinkloads of comments to ast.rb (I am trying to go through and better comment my code over time), refactoring some of the AST classes, and working towards a more sensible class/definition/node distinction d6982d5 adding some new language tests 48155b8 added log, metaloglevel and @metaparams to support setting loglevels 041ca4b switching log.rb to raise Puppet::DevError events 16c9f83 My cfengine2puppet config now entirely parses. The biggest problem I ran into is that my glob-based parsing was only returning the results of the last parsed file, instead of collecting all of the results. 23d3c93 adding --noop to puppet executable, and removing some extraneous comments a345931 Successfully parsed my entire converted cfengine configuration; these are all fixes for bugs i found as a result. I have not tried to execute the configuration yet. a8bdada Users and groups now work on OS X. I had to make some key changes to how transactions and state changes work -- the most important is that it is no longer an error to try to sync a state that is already in sync. I could not find another way to handle all user states being out of sync but the first state actually syncs everything. 6654c4c fixing users on normal machines 106d397 Users and groups now nearly work on normal machines and on os x, and I think I have a decent platform for expansion to some of the other important elements like hosts (probably most important after users and groups). Some tests are still failing on os x, because netinfo sucks, but I will hopefully be able to figure out a solution soon. Stupid OS X and NetInfo. 42deabb all tests for users and groups pass again on fedora, debian, and solaris e0d1d31 temporary commit so i can move to my workstation; groups and users are way b0rked 29c291a Creating a "change_to_s" method on State, so individual states can override and and determine how they get printed 80a2808 Cron is now fully functional and tested on 3 platforms. In order to make it work, I had to do some modifications to TransObject#to_type and Type.create, but all tests pass now. Type.create is now handling errors on creating objects, so if you try to create an invalid object you will just get nil returned, rather than receiving an error. e25e8c6 adding keywords aebfef0 adding keywords 11d3d24 cron is working, but i want to write quite a few more test cases 036ba7a small fixing to merge(), and changing output of statechange 093963e finishing up merge method ac0454a making "Type.new" private, and switching to "Type.create", so that i can merge new objects with existing objects and such; converted all files, and tested them f7116e5 switching FileTesting to a class, and modifying test suites as appropriate 7861269 removed directory output bf701dc adding extra checks to make sure networking is secure, and refactoring a heckuva lot of test 0c97bb1 fixed problem using arrays 897de46 cleaning up tests a bit; mostly just making sure tests clean up after themselves, but also doing some rearrangement and fixing a list() call 6767dd2 debugged ignore in fileserver, added tests to ignore tc and fixed server.list in tc for filesources and fileserver 39aaa99 fixing some tests 6c6ff03 moving some testing and debugging around 192c07b fixing non-netinfo group 9ebb767 fixing non-netinfo group 669ae38 modifications to eliminate code duplication in state creation, mostly to support cron ae00500 preparations for supporting netinfo in users 610f95c switching groups back to having namevar be a parameter instead of a state 2a6710b fileserver still has a bug ec66034 added ignore to fileserver and pfile 3d5f5a1 adding cron stuff; it does not work at all yet 0d3024f adding globbing to import 5438eff removed comp.sync and replaced system mkdir -p 79961e1 added test case for ignore 157953a added ignore to pfile 51948bd adding example configs d43dc86 tracked down some sticky bugs related to having false values and empty strings; all fixed now, and all tests pass again, including the new tests that cover the bugs i found aca4cf8 fixing error handling so that failed objects are completely destroyed; they were receiving events even though they were supposed to be gone 0a4e392 fixing component flattening and sorting; it was not working for cases where objects inside of components had dependencies from other components 58ca9d1 adding snippet test to verify correct behaviour with missing exec path; also, adding "creates" parameter to exec f9df523 intermediate commit so cron is not loaded 4dd1dd8 adding more comments from talking to andy 3306cc7 incorporating comments from talking to andrew 29fa170 incorporating comments from talking to andrew d0eb566 some small fixes ee1eba2 small updates f69abc9 adding cfengine to puppet parser, but it is not even remotely close to functional yet 8f7b191 fixing groups again after getting them to work with netinfo da6590d group management now works on os x, although it is six shades of really nasty. Netinfo is a nightmare. 3726cee adding debug setting to the top-level test class 99db7bc reverting changes in the reverse order of what i executed them 8f0ef3f removing debugging 2213430 making states capable of being the namevar 923226e all tests now pass on solaris 10x86; i had to do some stupid hacking with base64 for it to work, and i am working getting a much better base class for all test classes edc392d adding a break if randomization takes too long 4cc12a8 finishing up user and group support for now 9e4ed0c rearranging some documentation 24b1c67 adding scopetest b77d295 adding user and group classes (although user class is not yet functional), and added "is(state)" and "should(state)" methods for retrieving the respective values on a specified state 4f2812a changing rollback() to do event handling also 72638e6 adding simple newcomp() method to base test class 795a5a0 adding all of the work necessary for tidying f7a5f87 removing DEFAULTPORT stuff 21244f4 fixing small bug in setting default port c0c958b changing some documentation methods around 3fb6f49 rearranging puppetdoc to not separate states and parameters, and to allow undocumented states 75ec054 committing initial tidy stuff, so i can move to the laptop 0d01770 cleaning up obviated methods 747c3f6 defining $name in each component scope, and adding test case f49ffa3 defining configstatted 750b880 removing if-related keywords 008cea5 fixing error calls e1bf0e1 fixing bug where remote server name is ignored e1de002 Fixed small bug that caused the config files to be parsed on every connection 5c0fb02 fixing documentation for file source state 6a96fcc adding file reread to master, although it is plenty hackish cff3a5b fileserver config file now reloads when it is more than 60 seconds out of date 998b415 correcting documentation on autosign in puppetmasterd, and switching the autosign.conf file to use the same authstore as fileserver.conf 7f274a4 catching a potential security problem -- requiring that "path" always be set for a fileserver mount 8a99636 adding a "--noop" option along with a test case for it f65563d changing default hostname to "puppet", and adding --parseonly option along with a test case for it 0629065 fixing puppet to use correct method and adding a real test case for it 82ac86e changing default manifest location to /etc/puppet/manifests/site.pp 3087f85 changing version number for beta e28e11b removing need for zip in rakefile fc20167 UPdated rakefile 914764b As Christian requested, I am no longer downcasing facts I receive from Facter. Also, removing some outdated files eab7314 bumping up the default log level for changes from info to notice cc48367 I did not have good puppetd tests, so I missed the fact that I was calling the wrong class in puppetd. Fixed. 65d1375 disabling print of library warnings, since webrick and openssl have far too many warnings for comfort cdfaa5e adding RDoc::usage documentation to all executables f279535 This should be the commit that brings us to Beta 1. All tests pass, although I get some (gracefully handled) failures in tc_metrics.rb, and there is now a config file for the fileserver module, including authorization specification for it. I have also reworked error handling in the xmlrpc client and server so errors should propagate more correctly. 28be88c Adding authorization store, initially just used for file serving but eventually for all authorization, most likely 814a9b0 adding config file parsing 9ec321e recompiling parser after removing extraneous debugging 773be96 Added GPL license 48a2e0f making array-as-name work in the language, and adding some more test snippets 66b3355 Certificates now verify! 386ebee replacing if statements with case statement, and adding defaults for both selectors and case statements 583a9c6 remote filecopying now works 5b20c92 Have done a significant reorganization of how clients work, also, along with some interesting trouble shooting on components ba51e70 fixing checksum generation -- i was causing some weird bugs by using the same indicator in different cases, and i added a test for invalid checksum types fb3cff7 small comment change dde841f Created a Handler base class for all of the server handlers, which allows a lot of the manual work to now be automatic 49e3e37 splitting normal file tests and source tests into different files a8fff85 ignoring remote file owner when not running as root f68fe00 moving all server handlers into a specific server subdirectory 129dad7 removing obsolete file 51294a0 moving rake file to the trunk dir 6029ef7 Moving all files into a consolidated trunk. All tests pass except the known-failing certificate test, but there appear to be some errors that are incorrectly not resulting in failurs. I will track those down ASAP. e87eb58 adding test to verify require does not kick off an event 4741eef Execution order is now based on dependency relationships, and those relationships correctly propagate up and descend into components. There is also an event test suite now, along with a (currently simple) component test suite. 63309c3 fixing test base class f026884 just fixed an incredibly ugly bug where @parent meant both parent array and parent class 78939cc passing file and line to all objects 51ffd6f trying to create a testing base class 54e5eb4 moving 4f0750b adding 9f84742 all tests pass except a certificate test i do not know how to fix 163db7c a basic first test of puppetmasterd now passes a3e03e2 all non-executable tests pass now d49a98e further progress towards passing tests 2be10b5 all tests pass except those related to puppetd; i am going to significantly reorganize how serving is done 6eac358 updated version number to allow gem install 8d71cd9 Added rake for Puppet, '--version' to puppet and test case for Puppet.version cfaee58 more progress towards a functional daemon 3cb04cb setting up http to log to a separate file adc10d8 setting up http to log to a separate file c7380c9 renaming cb1956d adding daemon helper module bb4b5a5 done a lot of work on certificates; all tests except one puppetca test pass e2e2474 removing obsolete files 0f7d185 fact.rb is obsolete af1b979 function.rb is obsolete fc0ba4b fixing directory mode creation 5bcae96 renaming again 2687652 renaming openssl to certauthority aacd780 removing comments and making @csr a class attribute 4b5c5bf fixing error output c0b0975 adding creation rollback f654f2d returning transaction from client.config() a6a1148 all tests now pass on os x f3c1487 adding better error handling for missing paths 77e1cf0 fixing verbose output to be better and easier to manage 9c7c71c passing state, so more info can be extracted afcb2ee adding a bit more output bc3a433 committing recent changes for testing 7b14e39 a bit of refactoring, and a bit more functionality 0fce775 okay, switch all cert management to the library, instead of using the openssl binary a1d206a moving 6ba0e10 certificate management; yay de4e5bf oops; removing errant notice msg 223cc9f cleaning up the defaults system even more 74dac8f adding some consistency and tests to the whole puppet defaults system 8bf85e2 adding tests for puppet defaults d14e1b4 uh 4af2559 renaming to avoid name conflicts 5fa0c20 all tests pass again edc2842 local filebuckets are now tested with files e041c8a basic filebucketing is now working cf37c06 Moved documentation to project website. 9f2aaac more changes to documentation 952a76c working on documentation 54895da Updated README, moved the old one to documentation/ 2d1e643 Updated doc/big-picture doc/structures, Added rst formating to puppetdoc, and added doc strings for types, states, params, and metaparams. 700b965 dpkg/apt package installation and removal now works e685ddb fixing statefile creation 01666f6 fixing lib loading test 075ffd7 making changes necessary to pass tests on all available platforms b5f6a54 fixing solaris packaging ffe318c fixing packaging to work with rpm, too 64b55c1 creating FileTesting module in puppettest.rb, and getting recursion working with symlinks 9d8f754 adding some attributes to errors dcbbef7 adding symlink back as a separate object e078329 adding symlink back as a separate object 60965c5 removing silly message f624cd5 making the console output slightly less redundant 848df27 okay, last try on sources hopefully -- no failures, and basic functionality all seems to be working cc67845 fixing package listing 326b4ad fixing exec tests to work with new event stuff fa6569d okay, sources seem to be much more understandable here -- only the recursion function is recursive 5351eb9 adding some error checking 60e02de not dump/loading for local client/server 8ec8c8d sources now pass all tests a33d5d4 everything seems to actually be working now, including getting the correct file list back 2d34f8e Ha! finally got recursion and sourcing working together bc38169 redoing how arguments are handled in type.rb -- it is much cleaner now 973385f first versions c577e57 reducing debugging 99eedb3 reducing debugging 8f718da recursive file copying now works even with some limited number of errors aa59473 okay, file sourcing actually seems to work now 9a5477b checkpoint commit 0e94644 moving setpath to parampath=, as a param method 3a67efa adding "=" to metaparam methods, and allowing types to use methods for params de91dbd temp commit before i change the whole way that i am doing source + recursion 9ba72f5 removing, since pfile now has link functionality 311218b removing, since pfile now has link functionality 6f4f821 downcasing the values of all facts b1f3fb8 switching facts to be auto-provided by the client 357afbb removed type.method() syntax, and replaced it with Type { default => value} syntax -- i still need to add test cases f38bdef changing path stuff to be service-specific 84f721d modifying failer stuff 3d725d9 adding more validation methods f2b6762 reducing to one statefile definition ad9913b converting debug() back to Puppet.debug() 13945c5 converting debug() back to Puppet.debug() 668b9de converting debug() back to Puppet.debug() c04b337 converting debug() back to Puppet.debug() 3c4181c adding methods callable from language 88071eb making rpm the default package manager for all linuxes, with exceptions allowed ca87010 defaulting to rpm for everyone i don't know anything about ebe779f adding rpm as the default type for Fedora fbafa84 updates b9c064e Updated install script to include all bin files. 96c37e3 using old name method, since it is required to make names unique given how classes currently work e97e2d9 fully qualifying warning method, because it is not being imported for some reason a984d66 disabling metrics tests on machines missing RRD 78bcfdc adding path stuff everywhere, although i had to keep component names kind of funky 99a9f4b adding link functionality d6e2102 toying with some doc stuff 3f9bb25 removing an obsolete VERBOSE setting 5ff4b02 removing some debugging bf09132 lots of refactoring cc78949 in the middle of a bunch of refactoring; committing so that others can try to replicate the segfault i am seeing 1f2c866 doing some refactoring e19ca97 converting to "include Puppet" and not qualifing output methods 8177700 hopefully, finally resolving recursive file creation problems 01a9905 moving namevar translation to a method fffc09c swapping console colors 2062aac changing comments 75e27cf cleaning up bugs in the tests, and adding more error checking around the bugs 0417fb5 adding refreshonly parameter 6e9975c found a bunch of bugs in Puppet::Storage, plus some bugs in how file recursion was being tested and thus some real bugs in the system 256b84e adding a to_s method d14dc32 fixing storage class; it was not actually correctly retrieving state from disk 96f3980 adding Puppet#recmkdir utility function, and making sure Log and Storage create their own files and directories as necessary 649d59a adding some more tests for recursion plus checksumming, because they are somewhat incompatible for directories cb95dc7 ok, verbose => info 459287c duh, somehow added Blink calls in there... 600f272 adding cwd parameter to exec 4157fa0 exec stuff all works now, end to end 2c1f637 fixing some nasty bugs related to parameter checking 05d59fd fixing a nasty bug related to recursion and nonexistent files 5b7fd63 fixing some nasty bugs related to parameter checking 9e0ab28 adding string vs. symbol testing 8f1da62 adding logdest config cf817e7 changing Log.destination to Log.destination=() d36b4c0 disabling debug by default 420062d changing Log.destination to Log.destination=() c718044 adding the exec stuff 3441b82 finishing rename of file class f250d92 renaming to remove naming conflicts 26bc12b further output cleanup, and fixed the problem with tc_server.rb leaving sleeper processes lying around bb7e283 fixing debugging to severely reduce output but allow it when debugging a specific service c16ca53 changing warnings to debug 00343e3 basic rpm stuff now works 2b2975f fixing metrics tests to work with everything else 0ac91ef correctly returning events 0c4254a metric testing and graphing now works in the library, although nothing has been done in the language 573d301 adding some more tests for loglevel stuff 0ba9d71 adding rpm as RedHat package manager b6b1f5a logging now exactly supports the list of levels that syslog supports, and multiple destinations (syslog, files, and console) are now supported e3c3283 renaming message.rb to log.rb 2b3b15e temporary changes to prepare for a rename 8395639 puppetest.rb should probably be puppettest.rb cd48af7 renaming blink to puppet 60783f0 renaming blink to puppet 8f95084 renaming blink to puppet 6f07413 you can now at least test for whether a package is installed, although you still cannot do anything if it is not -- the barrier is knowing how to get the package 65c2a69 adding validparam() to Blink::Type 500a135 fixing file.rb so it works on Darwin, also 90b9b2d updates 3f0687b updates 5324062 adding new classes and tests 0dad57a md5 summing now works, all the way through! d1f2187 checksums now work, but not all the way through yet 18d755a Rahh! component dependencies now work! 922994e everything passes all of the tests, but i do not think the component-level metaparams are working cdfdfb9 adding some more tests for Blink::Type d42efbe done some more work on making components act like normal objects, but now i need to figure out how to spread events up the tree, rather than just point to point 0ab9685 dependencies now work, although you cannot yet specify them for components 2b97b47 there are now explicit tests for transactions, including rollback, and more tests involving querying b46135f adding simple query syntax stuff 7fecad3 i now have basic events: you can only specify simple object types as requirements, but hey, it works -- refresh() gets called 02f1185 renaming events to event d70229b update before rename c0d86a4 intermediate; no extra functionality yet, but moving away from discussing namevars outside of a given class d86e479 All tests pass again, and i have added Type.allclear to remove all existing type instances, thus making it much easier to run all of the parser and lexer and then server tests; i have also added remove server tests ebc02a8 okay, everything works again, although it still might be a touch fragile 5477f36 i am giving up on fileparsing for now; it does not work yet 576a031 okay, bin/blinker works again, and i have modified both client and server to be a bit easier to use non-networked 03741b4 we now have networking it is very basic right now: the server gets passed a file name, and the client gets passed the server to which to connect. The client gets its config, evaluates it, and exits 4a4438d okay, implicit iteration now occurs at least at object definition time 4a9c1a2 enabling mucking with debug and noop f91451d yep, arrays are always passed d0d8df9 final fixes on passing methods through to types 3a07a4d typesettings now correctly pass all the way through and can only run specified methods, using "allowedmethods" 12418e1 the tree transformations work throughout the whole system now f9a223c transformations from the client through to the transactional execution now works! 00a620d unmoving 135134c updates 4da3b51 moving 259692c moving 3b33738 switched to just passing scopes around, instead of passing the interpreter object around 529b9a7 file recursion now works 4e03ed1 i can now execute simple scripts manually! ec88acf i can basically actually do work now 42dadad moving 817f571 adding lots of verbosity, and starting to actually make sure things execute -- tests are failing, tho 2cce619 basic components now work 49da910 we now have nested scopes, and we've got the beginnings of components, although many tests are currently failing 7689d19 simplifying argument parsing in Blink#message 08d4260 initializing @noop in element.rb 865dffe dealing with having moved the examples to the language area a1a7ae4 moving to the language tree 85b9f91 everything works again, including components 9ea0c30 making components work 1f95fe2 moving component.rb to type/ 7df572b removing most functionality, since type.rb already has it 565554f finishing reorganization of base classes and such; there is now a clear tree heirarchy, with parents and children -- all tests pass on the types, but there are still some issues with client/server stuff 9843da6 cleaning up object tree and adding a simple virtual base class for both types and states d0c6b0c adding transactions 89d2381 moving event info out of type.rb 3c6c0f7 removing elements.rb e452f00 preparing to remove elements.rb cf08be1 renaming statetree to elements b6d0f0c first version of finalized base classes f984192 noop seems to basically be working, but i need to reorganize the whole type/state structure -- that is starting after this commit c01bc81 using the example syslog.conf instead of the one in /etc 57194eb adding some example debian configs 6cd71f8 filetypes now support multiple record types, and newlines can be escaped 7378765 completed the first step to enabling multiple record types in filetypes 490854a the client now executes "evaluate", which might not be a good thing -- i am getting failures if files do not exist, for instance 6127e43 filerecord.rb: duh, fixing a small debug string printing bug 371235b reorganizing the FileType/FileRecord into a base class (TypeGenerator) and basing them off it 7deba97 adding typegenerator baseclass b18d071 fact.rb is no longer a subclass of Blink::Type 43a63db fixing filetype and component to take into account changes type interface.rb and type.rb a16493d type.rb: adding methods to simplify type initialization, and adding eachtype() to simplify testing 69a1276 adding some tests on the interface methods in Blink::Type de360c9 renaming objects to types, since they are just subclasses of Blink::Type b872b72 renaming types to type everywhere; all tests now pass a50d461 changing types to type internally c0bc63f moving types to type b85ac7b renaming types.rb to type.rb 9d163d0 changing Types to Type 68409ef adding cb5f54c deprecating interface.rb 974969d final changes before deprecating f8b08b2 adding an fqpath method to state.rb ae13f00 adding name information and a FileRecordState class a489639 moving some methods around 14c2308 adding markers a1bd01d changing type[param] to return the state instead of the value 41b7fbd renaming oparse to filetype 98374bc renaming oparse to filetype 8ab03d0 renaming oparse to filetype c2e83c5 renaming oparse to filetype 2360201 adding some comments 3904d2e fixing most of the function call stuff 13f16b6 the client is now successfully creating objects from the hashes passed by the server 6140bee making fact a real type d94d7a3 moving state.rb to types/ e86cf4c renaming "value" to "is" d8e8b7b renaming state, and adding modification class c0c1f1a renaming attributes to states 6dce8fc renaming objects to types a90af49 renaming objects to types 5e19d7d renaming objects to types afd4349 updates 67fae6d updates b4bb680 removing link when done c6755f5 adding class collection and naming stuff e5676ab testing keyword f3d1118 removing some excess libs from blink.rb 585c4fc cleaning up the start script 61f8434 cleaning up a bit 52fe914 removing evaluate test 69651dd removing bogus output 8fd8d62 removing output, and fixing path so it is not hardcoded 9da1485 temporarily removing inclusion of time in output 4d7bbaa creating extra message methods 0187bf7 removing execute bit 6a82d07 adding readme 3824817 copy test script 67b7b34 okay, all tests pass again 35f742c adding client stuff to the library tree 02ed7d3 reorganizing tests 8bc935e adding comments a0d0fa8 adding 11b0374 moving client.rb to the library tree cb785bd moving client.rb to the library tree 8788552 fixing [] method in function.rb c86a770 adding operatingsystemrelease 21ca565 renaming tc_functions.rb, and adding to ts_other.rb 1aab204 functions mostly work c45c5c4 renaming 06734a9 updates so i can rename 9bf82b6 adding package source, initially including only files as a source e40d5f2 returning value instead of fact 9fa899d reorganizing 4642515 reorganizing 5807dce reorganizing 6ee8b4e reorganizing 5416017 reorganizing 54e9b5e adding structure diff --git a/README.queueing b/README.queueing index 8c4a18029..83a8e19c0 100644 --- a/README.queueing +++ b/README.queueing @@ -1,126 +1,126 @@ *PUPPET QUEUEING Puppet Queueing is a feature which is designed to take some load off of the PuppetMaster by transferring the task of updating the database to a separate program which is named puppetqd (Puppet Queue Daemon). Currently this is only supported for "Storeconfigs" which is documented at: -http://reductivelabs.com/trac/puppet/wiki/UsingStoredConfiguration +http://projects.puppetlabs.com/projects/1/wiki/Using_Stored_Configuration In the future this feature can be extended to any new puppet data which involves storage in a database. *OPERATION In a nutshell: puppetmasterd -> stomp -> service -> stomp -> puppetqd -> database At the moment the only messaging protocol supported is "stomp". Although others could be implemented, stomp is considered by many as the default queueing mechanism for Ruby and Rails applications. It is distributed as a Ruby gem and is easily installed. (The queueing code inside Puppet has been written so that when other interfaces and protocols are implemented they will be easy to use by changing settings in puppet.conf). The "service" in the diagram above is any queueing service that supports the Stomp API. For details refer to: http://xircles.codehaus.org/projects/stomp Both puppetmasterd and puppetqd subscribe to the same queueing service using the stomp interface. As puppetmasterd posts data to the queue, puppetqd receives it and stores it. The details of how to connect to the service and the name of the queue to use are set in puppet.conf: [main] queue_type = stomp queue_source = stomp://localhost:61613 [puppetmasterd] async_storeconfigs = true Note: since puppetmasterd needs to recover the data being stored at a later time, both puppetmasterd and puppetqd need to work with the same database as defined in the STORECONFIGS setup. *QUEUEING SERVICES As mentioned previously any queueing service that supports the Stomp protocol can be used. Which one you use depends on your needs. We have tested with two of the most popular services - StompServer and ActiveMQ. + StompServer http://rubyforge.org/projects/stompserver/ StompServer is a lightweight queueing service written in Ruby which is suitable for testing or low volume puppet usage. Works well when both puppetmasterd and puppetd are running on the same machine that it's running on but we encountered some problems when using it from multiple machines. Just install the stompserver gem and run 'stompserver'. + Apache ActiveMQ http://activemq.apache.org Considered by many to be the most popular message service in use today, ActiveMQ has hundreds of features for scaling, persistence and so on. Although installation is fairly simple, the configuration can seem quite intimidating, but for our use a one line change to the standard configuration is all that is required and is explained at: http://activemq.apache.org/stomp.html Other customization of the internal workings of ActiveMQ, if any, will depend on your needs and deployment. A quick skimming of the ActiveMQ documentation will give you enough info to decide. Others We have looked at but not tried some other queuing services which are compatible with the Stomp API: + POE Component Message Queue + JBoss Messaging (with 3rd party support for Stomp) *SCALING For StoreConfigs you basically need to have the catalog for a node stored in the database before the next time the node connects and asks for a new catalog. If the puppetd on your nodes is set to check every 30 minutes, then it would seem that there is no problem. However if you have 3000 nodes you have a LOT of catalogs to store and it is possible you will not get a catalog saved in time. Running puppetmaster, your queueing service and puppetqd on the same machine means that they are all competing for the same CPU cycles. Bumping up the power of the server they are running on may be enough to handle even fairly large deployments. However since most queueing services (even StompServer) are designed to deliver messages from a "queue" to whoever asks for the next message you can split things up between machines: puppetmaster1 --\ /-- puppetqd1 -\ puppetmaster2 ----> ActiveMQ ---> puppetqd2 ---> database puppetmaster3 --/ \-- puppetqd33 -/ \- puppetqd4-/ This is, of course a totally contrived example, but it gets the point across. As long as the data gets to the database, it doesn't matter which machines or services it goes through. Although for StoreConfigs absolute reliability is not a requirement as a new catalog will be sent the next time a node connects, some amount of persistence should some process crash may be desirable. Both ActiveMQ and MySQL (and other databases) have these kind of features built in which can be activated as needed. diff --git a/Rakefile b/Rakefile index 38cfec6ce..e59d20ade 100644 --- a/Rakefile +++ b/Rakefile @@ -1,53 +1,53 @@ # Rakefile for Puppet -*- ruby -*- $LOAD_PATH << File.join(File.dirname(__FILE__), 'tasks') require 'rake' require 'rake/packagetask' require 'rake/gempackagetask' require 'rspec' require "rspec/core/rake_task" module Puppet PUPPETVERSION = File.read('lib/puppet.rb')[/PUPPETVERSION *= *'(.*)'/,1] or fail "Couldn't find PUPPETVERSION" end Dir['tasks/**/*.rake'].each { |t| load t } FILES = FileList[ '[A-Z]*', 'install.rb', 'bin/**/*', 'sbin/**/*', 'lib/**/*', 'conf/**/*', 'man/**/*', 'examples/**/*', 'ext/**/*', 'tasks/**/*', 'test/**/*', 'spec/**/*' ] Rake::PackageTask.new("puppet", Puppet::PUPPETVERSION) do |pkg| pkg.package_dir = 'pkg' pkg.need_tar_gz = true pkg.package_files = FILES.to_a end task :default do sh %{rake -T} end desc "Create the tarball and the gem - use when releasing" task :puppetpackages => [:create_gem, :package] RSpec::Core::RakeTask.new do |t| t.pattern ='spec/{unit,integration}/**/*.rb' - t.fail_on_error = false + t.fail_on_error = true end desc "Run the unit tests" task :unit do - sh "cd test; rake" + Dir.chdir("test") { sh "rake" } end diff --git a/conf/solaris/smf/svc-puppetd b/conf/solaris/smf/svc-puppetd index b6cf05736..8acc19cfa 100755 --- a/conf/solaris/smf/svc-puppetd +++ b/conf/solaris/smf/svc-puppetd @@ -1,66 +1,64 @@ #!/bin/sh # This is the /etc/init.d file for puppetd # Modified for CSW # # description: puppetd - Puppet Automation Client # . /lib/svc/share/smf_include.sh prefix=/opt/csw exec_prefix=/opt/csw sysconfdir=/opt/csw/etc sbindir=/opt/csw/sbin pidfile=/var/lib/puppet/run/agent.pid case "$1" in start) cd / # Start daemons. printf "Starting Puppet client services:" /opt/csw/sbin/puppetd printf " puppetd" echo "" ;; stop) printf "Stopping Puppet client services:" kill `cat $pidfile` printf " puppetd" echo "" ;; restart) printf "Restarting Puppet client services:" kill -HUP `cat $pidfile` printf " puppetd" echo "" ;; reload) printf "Reloading Puppet client services:" kill -HUP `cat $pidfile` printf " puppetd" echo "" ;; status) if [ -f $pidfile ]; then pid=`cat $pidfile` curpid=`pgrep puppetd` if [ "$pid" -eq "$curpid" ]; then exit 0 else exit 1 fi else exit 1 fi esac exit 0 - -# $Id$ diff --git a/conf/solaris/smf/svc-puppetmasterd b/conf/solaris/smf/svc-puppetmasterd index 80e3d464a..683324dec 100755 --- a/conf/solaris/smf/svc-puppetmasterd +++ b/conf/solaris/smf/svc-puppetmasterd @@ -1,62 +1,60 @@ #!/bin/sh # . /lib/svc/share/smf_include.sh prefix=/opt/csw exec_prefix=/opt/csw sysconfdir=/opt/csw/etc sbindir=/opt/csw/sbin pidfile=/var/lib/puppet/run/master.pid case "$1" in start) cd / # Start daemons. printf "Starting Puppet server services:" /opt/csw/sbin/puppetmasterd printf " puppetmaster" echo "" ;; stop) printf "Stopping Puppet server services:" kill `cat $pidfile` printf " puppetmasterd" echo "" ;; restart) printf "Restarting Puppet server services:" kill -HUP `cat $pidfile` printf " puppetmasterd" echo "" ;; reload) printf "Reloading Puppet server services:" kill -HUP `cat $pidfile` printf " puppetmasterd" echo "" ;; status) if [ -f $pidfile ]; then pid=`cat $pidfile` curpid=`pgrep puppetmasterd` if [ "$pid" -eq "$curpid" ]; then exit 0 else exit 1 fi else exit 1 fi esac exit 0 - -# $Id$ diff --git a/examples/etc/init.d/sleeper b/examples/etc/init.d/sleeper index 63f7e9c2e..c60a5555c 100755 --- a/examples/etc/init.d/sleeper +++ b/examples/etc/init.d/sleeper @@ -1,72 +1,70 @@ #!/bin/bash -# $Id$ - script=$0 path=`echo $script | sed 's/etc..*/bin/'` PATH=$PATH:$path ps=`facter ps` if [ -z "$ps" ]; then ps="ps -ef" fi function start { cd $path ./sleeper } function stop { #if [ -n `which pgrep` ]; then # pid=`pgrep sleeper` #else pid=`$ps | grep -v grep | grep sleeper | grep ruby | awk '{print $2}'` #fi if [ -n "$pid" ]; then kill $pid fi } function restart { stop start } function status { #if [ -n `which pgrep` ]; then # cmd="pgrep sleeper" #else #cmd="$ps | grep -v grep | grep sleeper | grep ruby | awk '{print $2}'" #fi #$cmd $ps | grep -v grep | grep sleeper | grep ruby } case "$1" in start) start ;; stop) stop ;; restart) stop; start ;; status) output=`status` #status exit $? ;; *) echo "Usage: $N {start|stop|restart|force-reload}" >&2 exit 1 ;; esac exit 0 diff --git a/examples/modules/sample-module/README.txt b/examples/modules/sample-module/README.txt index cd35c83a1..233e54b8d 100644 --- a/examples/modules/sample-module/README.txt +++ b/examples/modules/sample-module/README.txt @@ -1,17 +1,17 @@ Jeff McCune 2007-08-14 This small, sample module demonstrates how to extend the puppet language with a new parser function. See: manifests/init.pp lib/puppet/parser/functions/hostname_to_dn.rb templates/sample.erb Note the consistent naming of files for Puppet::Util::Autoload Reference Documents: -http://reductivelabs.com/trac/puppet/wiki/ModuleOrganisation +http://docs.puppetlabs.com/guides/modules.html http://docs.puppetlabs.com/guides/custom_functions.html -http://reductivelabs.com/trac/puppet/wiki/FunctionReference +http://docs.puppetlabs.com/references/latest/function.html diff --git a/ext/puppetstoredconfigclean.rb b/ext/puppetstoredconfigclean.rb index 16f39efa1..dcbefa816 100644 --- a/ext/puppetstoredconfigclean.rb +++ b/ext/puppetstoredconfigclean.rb @@ -1,91 +1,91 @@ #!/usr/bin/env ruby # Script to clean up stored configs for (a) given host(s) # # Credits: -# Script was taken from http://reductivelabs.com/trac/puppet/attachment/wiki/UsingStoredConfiguration/kill_node_in_storedconfigs_db.rb +# Script was taken from http://reductivelabs.com/trac/puppet/attachment/wiki/UsingStoredConfiguration/kill_node_in_storedconfigs_db.rb (link no longer valid), # which haven been initially posted by James Turnbull # duritong adapted and improved the script a bit. require 'getoptlong' config = '/etc/puppet/puppet.conf' def printusage(error_code) puts "Usage: #{$0} [ list of hostnames as stored in hosts table ]" puts "\n Options:" puts "--config " exit(error_code) end opts = GetoptLong.new( [ "--config", "-c", GetoptLong::REQUIRED_ARGUMENT ], [ "--help", "-h", GetoptLong::NO_ARGUMENT ], [ "--usage", "-u", GetoptLong::NO_ARGUMENT ], [ "--version", "-v", GetoptLong::NO_ARGUMENT ] ) begin opts.each do |opt, arg| case opt when "--config" config = arg when "--help" printusage(0) when "--usage" printusage(0) when "--version" puts "#{Puppet.version}" exit end end rescue GetoptLong::InvalidOption => detail $stderr.puts "Try '#{$0} --help'" exit(1) end printusage(1) unless ARGV.size > 0 require 'puppet/rails' Puppet[:config] = config Puppet.parse_config pm_conf = Puppet.settings.instance_variable_get(:@values)[:master] adapter = pm_conf[:dbadapter] args = {:adapter => adapter, :log_level => pm_conf[:rails_loglevel]} case adapter when "sqlite3" args[:dbfile] = pm_conf[:dblocation] when "mysql", "postgresql" args[:host] = pm_conf[:dbserver] unless pm_conf[:dbserver].to_s.empty? args[:username] = pm_conf[:dbuser] unless pm_conf[:dbuser].to_s.empty? args[:password] = pm_conf[:dbpassword] unless pm_conf[:dbpassword].to_s.empty? args[:database] = pm_conf[:dbname] unless pm_conf[:dbname].to_s.empty? args[:port] = pm_conf[:dbport] unless pm_conf[:dbport].to_s.empty? socket = pm_conf[:dbsocket] args[:socket] = socket unless socket.to_s.empty? else raise ArgumentError, "Invalid db adapter #{adapter}" end args[:database] = "puppet" unless not args[:database].to_s.empty? ActiveRecord::Base.establish_connection(args) ARGV.each { |hostname| if @host = Puppet::Rails::Host.find_by_name(hostname.strip) print "Killing #{hostname}..." $stdout.flush @host.destroy puts "done." else puts "Can't find host #{hostname}." end } exit 0 diff --git a/install.rb b/install.rb index 7627a8d11..6854363ca 100755 --- a/install.rb +++ b/install.rb @@ -1,496 +1,438 @@ #! /usr/bin/env ruby #-- # Copyright 2004 Austin Ziegler # Install utility. Based on the original installation script for rdoc by the # Pragmatic Programmers. # # This program is free software. It may be redistributed and/or modified under # the terms of the GPL version 2 (or later) or the Ruby licence. # # Usage # ----- # In most cases, if you have a typical project layout, you will need to do # absolutely nothing to make this work for you. This layout is: # # bin/ # executable files -- "commands" # lib/ # the source of the library # tests/ # unit tests # # The default behaviour: # 1) Run all unit test files (ending in .rb) found in all directories under # tests/. # 2) Build Rdoc documentation from all files in bin/ (excluding .bat and .cmd), # all .rb files in lib/, ./README, ./ChangeLog, and ./Install. # 3) Build ri documentation from all files in bin/ (excluding .bat and .cmd), # and all .rb files in lib/. This is disabled by default on Microsoft Windows. # 4) Install commands from bin/ into the Ruby bin directory. On Windows, if a # if a corresponding batch file (.bat or .cmd) exists in the bin directory, # it will be copied over as well. Otherwise, a batch file (always .bat) will # be created to run the specified command. # 5) Install all library files ending in .rb from lib/ into Ruby's # site_lib/version directory. # #++ require 'rbconfig' require 'find' require 'fileutils' begin require 'ftools' # apparently on some system ftools doesn't get loaded $haveftools = true rescue LoadError puts "ftools not found. Using FileUtils instead.." $haveftools = false end require 'optparse' require 'ostruct' begin require 'rdoc/rdoc' $haverdoc = true rescue LoadError puts "Missing rdoc; skipping documentation" $haverdoc = false end -begin - if $haverdoc - ronn = %x{which ronn} - $haveman = true - else - $haveman = false - end -rescue - puts "Missing ronn; skipping man page creation" - $haveman = false -end - PREREQS = %w{openssl facter xmlrpc/client xmlrpc/server cgi} MIN_FACTER_VERSION = 1.5 InstallOptions = OpenStruct.new def glob(list) g = list.map { |i| Dir.glob(i) } g.flatten! g.compact! g.reject! { |e| e =~ /\.svn/ } g end # Set these values to what you want installed. configs = glob(%w{conf/auth.conf}) sbins = glob(%w{sbin/*}) bins = glob(%w{bin/*}) rdoc = glob(%w{bin/* sbin/* lib/**/*.rb README README-library CHANGELOG TODO Install}).reject { |e| e=~ /\.(bat|cmd)$/ } ri = glob(%w{bin/*.rb sbin/* lib/**/*.rb}).reject { |e| e=~ /\.(bat|cmd)$/ } man = glob(%w{man/man[0-9]/*}) libs = glob(%w{lib/**/*.rb lib/**/*.py lib/puppet/util/command_line/*}) tests = glob(%w{test/**/*.rb}) def do_configs(configs, target, strip = 'conf/') Dir.mkdir(target) unless File.directory? target configs.each do |cf| ocf = File.join(InstallOptions.config_dir, cf.gsub(/#{strip}/, '')) File.install(cf, ocf, 0644, true) end end def do_bins(bins, target, strip = 's?bin/') Dir.mkdir(target) unless File.directory? target bins.each do |bf| obf = bf.gsub(/#{strip}/, '') install_binfile(bf, obf, target) end end def do_libs(libs, strip = 'lib/') libs.each do |lf| olf = File.join(InstallOptions.site_dir, lf.gsub(/#{strip}/, '')) op = File.dirname(olf) if $haveftools File.makedirs(op, true) File.chmod(0755, op) File.install(lf, olf, 0644, true) else FileUtils.makedirs(op, {:mode => 0755, :verbose => true}) FileUtils.chmod(0755, op) FileUtils.install(lf, olf, {:mode => 0644, :verbose => true}) end end end def do_man(man, strip = 'man/') man.each do |mf| omf = File.join(InstallOptions.man_dir, mf.gsub(/#{strip}/, '')) om = File.dirname(omf) if $haveftools File.makedirs(om, true) File.chmod(0755, om) File.install(mf, omf, 0644, true) else FileUtils.makedirs(om, {:mode => 0755, :verbose => true}) FileUtils.chmod(0755, om) FileUtils.install(mf, omf, {:mode => 0644, :verbose => true}) end gzip = %x{which gzip} gzip.chomp! %x{#{gzip} -f #{omf}} end end # Verify that all of the prereqs are installed def check_prereqs PREREQS.each { |pre| begin require pre if pre == "facter" # to_f isn't quite exact for strings like "1.5.1" but is good # enough for this purpose. facter_version = Facter.version.to_f if facter_version < MIN_FACTER_VERSION puts "Facter version: #{facter_version}; minimum required: #{MIN_FACTER_VERSION}; cannot install" exit -1 end end rescue LoadError puts "Could not load #{pre}; cannot install" exit -1 end } end ## # Prepare the file installation. # def prepare_installation $operatingsystem = Facter["operatingsystem"].value InstallOptions.configs = true # Only try to do docs if we're sure they have rdoc if $haverdoc InstallOptions.rdoc = true InstallOptions.ri = $operatingsystem != "windows" else InstallOptions.rdoc = false InstallOptions.ri = false end - if $haveman - InstallOptions.man = true - if $operatingsystem == "windows" - InstallOptions.man = false - end - else - InstallOptions.man = false - end - InstallOptions.tests = true ARGV.options do |opts| opts.banner = "Usage: #{File.basename($0)} [options]" opts.separator "" opts.on('--[no-]rdoc', 'Prevents the creation of RDoc output.', 'Default on.') do |onrdoc| InstallOptions.rdoc = onrdoc end opts.on('--[no-]ri', 'Prevents the creation of RI output.', 'Default off on mswin32.') do |onri| InstallOptions.ri = onri end - opts.on('--[no-]man', 'Prevents the creation of man pages.', 'Default on.') do |onman| - InstallOptions.man = onman - end opts.on('--[no-]tests', 'Prevents the execution of unit tests.', 'Default on.') do |ontest| InstallOptions.tests = ontest end opts.on('--[no-]configs', 'Prevents the installation of config files', 'Default off.') do |ontest| InstallOptions.configs = ontest end opts.on('--destdir[=OPTIONAL]', 'Installation prefix for all targets', 'Default essentially /') do |destdir| InstallOptions.destdir = destdir end opts.on('--configdir[=OPTIONAL]', 'Installation directory for config files', 'Default /etc/puppet') do |configdir| InstallOptions.configdir = configdir end opts.on('--bindir[=OPTIONAL]', 'Installation directory for binaries', 'overrides Config::CONFIG["bindir"]') do |bindir| InstallOptions.bindir = bindir end opts.on('--sbindir[=OPTIONAL]', 'Installation directory for system binaries', 'overrides Config::CONFIG["sbindir"]') do |sbindir| InstallOptions.sbindir = sbindir end opts.on('--sitelibdir[=OPTIONAL]', 'Installation directory for libraries', 'overrides Config::CONFIG["sitelibdir"]') do |sitelibdir| InstallOptions.sitelibdir = sitelibdir end opts.on('--mandir[=OPTIONAL]', 'Installation directory for man pages', 'overrides Config::CONFIG["mandir"]') do |mandir| InstallOptions.mandir = mandir end opts.on('--quick', 'Performs a quick installation. Only the', 'installation is done.') do |quick| InstallOptions.rdoc = false InstallOptions.ri = false InstallOptions.tests = false InstallOptions.configs = true end opts.on('--full', 'Performs a full installation. All', 'optional installation steps are run.') do |full| InstallOptions.rdoc = true - InstallOptions.man = true InstallOptions.ri = true InstallOptions.tests = true InstallOptions.configs = true end opts.separator("") opts.on_tail('--help', "Shows this help text.") do $stderr.puts opts exit end opts.parse! end tmpdirs = [ENV['TMP'], ENV['TEMP'], "/tmp", "/var/tmp", "."] version = [Config::CONFIG["MAJOR"], Config::CONFIG["MINOR"]].join(".") libdir = File.join(Config::CONFIG["libdir"], "ruby", version) # Mac OS X 10.5 and higher declare bindir and sbindir as # /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin # /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/sbin # which is not generally where people expect executables to be installed # These settings are appropriate defaults for all OS X versions. if RUBY_PLATFORM =~ /^universal-darwin[\d\.]+$/ Config::CONFIG['bindir'] = "/usr/bin" Config::CONFIG['sbindir'] = "/usr/sbin" end if not InstallOptions.configdir.nil? configdir = InstallOptions.configdir else configdir = "/etc/puppet" end if not InstallOptions.bindir.nil? bindir = InstallOptions.bindir else bindir = Config::CONFIG['bindir'] end if not InstallOptions.sbindir.nil? sbindir = InstallOptions.sbindir else sbindir = Config::CONFIG['sbindir'] end if not InstallOptions.sitelibdir.nil? sitelibdir = InstallOptions.sitelibdir else sitelibdir = Config::CONFIG["sitelibdir"] if sitelibdir.nil? sitelibdir = $LOAD_PATH.find { |x| x =~ /site_ruby/ } if sitelibdir.nil? sitelibdir = File.join(libdir, "site_ruby") elsif sitelibdir !~ Regexp.quote(version) sitelibdir = File.join(sitelibdir, version) end end end if not InstallOptions.mandir.nil? mandir = InstallOptions.mandir else mandir = Config::CONFIG['mandir'] end - # To be deprecated once people move over to using --destdir option - if (destdir = ENV['DESTDIR']) - configdir = "#{destdir}#{configdir}" - bindir = "#{destdir}#{bindir}" - sbindir = "#{destdir}#{sbindir}" - mandir = "#{destdir}#{mandir}" - sitelibdir = "#{destdir}#{sitelibdir}" - - FileUtils.makedirs(configdir) if InstallOptions.configs - FileUtils.makedirs(bindir) - FileUtils.makedirs(sbindir) - FileUtils.makedirs(mandir) - FileUtils.makedirs(sitelibdir) # This is the new way forward - elsif (destdir = InstallOptions.destdir) - configdir = "#{destdir}#{configdir}" - bindir = "#{destdir}#{bindir}" - sbindir = "#{destdir}#{sbindir}" - mandir = "#{destdir}#{mandir}" - sitelibdir = "#{destdir}#{sitelibdir}" - - FileUtils.makedirs(configdir) if InstallOptions.configs - FileUtils.makedirs(bindir) - FileUtils.makedirs(sbindir) - FileUtils.makedirs(mandir) - FileUtils.makedirs(sitelibdir) + if not InstallOptions.destdir.nil? + destdir = InstallOptions.destdir + # To be deprecated once people move over to using --destdir option + elsif ENV['DESTDIR'] != nil? + destdir = ENV['DESTDIR'] + warn "DESTDIR is deprecated. Use --destdir instead." + else + destdir = '' end + configdir = "#{destdir}#{configdir}" + bindir = "#{destdir}#{bindir}" + sbindir = "#{destdir}#{sbindir}" + mandir = "#{destdir}#{mandir}" + sitelibdir = "#{destdir}#{sitelibdir}" + + FileUtils.makedirs(configdir) if InstallOptions.configs + FileUtils.makedirs(bindir) + FileUtils.makedirs(sbindir) + FileUtils.makedirs(mandir) + FileUtils.makedirs(sitelibdir) + tmpdirs << bindir InstallOptions.tmp_dirs = tmpdirs.compact InstallOptions.site_dir = sitelibdir InstallOptions.config_dir = configdir InstallOptions.bin_dir = bindir InstallOptions.sbin_dir = sbindir InstallOptions.lib_dir = libdir InstallOptions.man_dir = mandir end ## # Build the rdoc documentation. Also, try to build the RI documentation. # def build_rdoc(files) return unless $haverdoc begin r = RDoc::RDoc.new r.document(["--main", "README", "--title", "Puppet -- Site Configuration Management", "--line-numbers"] + files) rescue RDoc::RDocError => e $stderr.puts e.message rescue Exception => e $stderr.puts "Couldn't build RDoc documentation\n#{e.message}" end end def build_ri(files) return unless $haverdoc begin ri = RDoc::RDoc.new #ri.document(["--ri-site", "--merge"] + files) ri.document(["--ri-site"] + files) rescue RDoc::RDocError => e $stderr.puts e.message rescue Exception => e $stderr.puts "Couldn't build Ri documentation\n#{e.message}" $stderr.puts "Continuing with install..." end end -def build_man(bins, sbins) - return unless $haveman - begin - # Locate ronn - ronn = %x{which ronn} - ronn.chomp! - # Create puppet.conf.5 man page - %x{bin/puppetdoc --reference configuration > ./man/man5/puppetconf.5.ronn} - %x{#{ronn} -r ./man/man5/puppetconf.5.ronn} - File.move("./man/man5/puppetconf.5", "./man/man5/puppet.conf.5") - File.unlink("./man/man5/puppetconf.5.ronn") - - # Create binary man pages - binary = bins + sbins - binary.each do |bin| - b = bin.gsub( /(bin|sbin)\//, "") - %x{#{bin} --help > ./man/man8/#{b}.8.ronn} - %x{#{ronn} -r ./man/man8/#{b}.8.ronn} - File.unlink("./man/man8/#{b}.8.ronn") - end - -rescue SystemCallError - $stderr.puts "Couldn't build man pages: " + $ERROR_INFO - $stderr.puts "Continuing with install..." - end -end - def run_tests(test_list) require 'test/unit/ui/console/testrunner' $LOAD_PATH.unshift "lib" test_list.each do |test| next if File.directory?(test) require test end tests = [] ObjectSpace.each_object { |o| tests << o if o.kind_of?(Class) } tests.delete_if { |o| !o.ancestors.include?(Test::Unit::TestCase) } tests.delete_if { |o| o == Test::Unit::TestCase } tests.each { |test| Test::Unit::UI::Console::TestRunner.run(test) } $LOAD_PATH.shift rescue LoadError puts "Missing testrunner library; skipping tests" end ## # Install file(s) from ./bin to Config::CONFIG['bindir']. Patch it on the way # to insert a #! line; on a Unix install, the command is named as expected # (e.g., bin/rdoc becomes rdoc); the shebang line handles running it. Under # windows, we add an '.rb' extension and let file associations do their stuff. def install_binfile(from, op_file, target) tmp_dir = nil InstallOptions.tmp_dirs.each do |t| if File.directory?(t) and File.writable?(t) tmp_dir = t break end end fail "Cannot find a temporary directory" unless tmp_dir tmp_file = File.join(tmp_dir, '_tmp') ruby = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name']) File.open(from) do |ip| File.open(tmp_file, "w") do |op| ruby = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name']) op.puts "#!#{ruby}" contents = ip.readlines contents.shift if contents[0] =~ /^#!/ op.write contents.join end end if $operatingsystem == "windows" installed_wrapper = false if File.exists?("#{from}.bat") FileUtils.install("#{from}.bat", File.join(target, "#{op_file}.bat"), :mode => 0755, :verbose => true) installed_wrapper = true end if File.exists?("#{from}.cmd") FileUtils.install("#{from}.cmd", File.join(target, "#{op_file}.cmd"), :mode => 0755, :verbose => true) installed_wrapper = true end if not installed_wrapper tmp_file2 = File.join(tmp_dir, '_tmp_wrapper') cwn = File.join(Config::CONFIG['bindir'], op_file) cwv = CMD_WRAPPER.gsub('', ruby.gsub(%r{/}) { "\\" }).gsub!('', cwn.gsub(%r{/}) { "\\" } ) File.open(tmp_file2, "wb") { |cw| cw.puts cwv } FileUtils.install(tmp_file2, File.join(target, "#{op_file}.bat"), :mode => 0755, :verbose => true) File.unlink(tmp_file2) installed_wrapper = true end end FileUtils.install(tmp_file, File.join(target, op_file), :mode => 0755, :verbose => true) File.unlink(tmp_file) end CMD_WRAPPER = <<-EOS @echo off if "%OS%"=="Windows_NT" goto WinNT -x "" %1 %2 %3 %4 %5 %6 %7 %8 %9 goto done :WinNT -x "" %* goto done :done EOS check_prereqs prepare_installation #run_tests(tests) if InstallOptions.tests #build_rdoc(rdoc) if InstallOptions.rdoc #build_ri(ri) if InstallOptions.ri -#build_man(bins, sbins) if InstallOptions.man do_configs(configs, InstallOptions.config_dir) if InstallOptions.configs do_bins(sbins, InstallOptions.sbin_dir) do_bins(bins, InstallOptions.bin_dir) do_libs(libs) do_man(man) unless $operatingsystem == "windows" diff --git a/lib/puppet.rb b/lib/puppet.rb index a58d3c801..ef5fb7f06 100644 --- a/lib/puppet.rb +++ b/lib/puppet.rb @@ -1,165 +1,165 @@ # Try to load rubygems. Hey rubygems, I hate you. begin require 'rubygems' rescue LoadError end # see the bottom of the file for further inclusions require 'singleton' require 'facter' require 'puppet/error' require 'puppet/util' require 'puppet/util/autoload' require 'puppet/util/settings' require 'puppet/util/feature' require 'puppet/util/suidmanager' require 'puppet/util/run_mode' #------------------------------------------------------------ # the top-level module # # all this really does is dictate how the whole system behaves, through # preferences for things like debugging # # it's also a place to find top-level commands like 'debug' module Puppet - PUPPETVERSION = '2.6.4' + PUPPETVERSION = '2.6.7' def Puppet.version PUPPETVERSION end class << self include Puppet::Util attr_reader :features attr_writer :name end # the hash that determines how our system behaves @@settings = Puppet::Util::Settings.new # The services running in this process. @services ||= [] require 'puppet/util/logging' extend Puppet::Util::Logging # The feature collection @features = Puppet::Util::Feature.new('puppet/feature') # Load the base features. require 'puppet/feature/base' # Store a new default value. def self.setdefaults(section, hash) @@settings.setdefaults(section, hash) end # configuration parameter access and stuff def self.[](param) case param when :debug return Puppet::Util::Log.level == :debug else return @@settings[param] end end # configuration parameter access and stuff def self.[]=(param,value) @@settings[param] = value end def self.clear @@settings.clear end def self.debug=(value) if value Puppet::Util::Log.level=(:debug) else Puppet::Util::Log.level=(:notice) end end def self.settings @@settings end def self.run_mode $puppet_application_mode || Puppet::Util::RunMode[:user] end def self.application_name $puppet_application_name ||= "apply" end # Load all of the configuration parameters. require 'puppet/defaults' def self.genmanifest if Puppet[:genmanifest] puts Puppet.settings.to_manifest exit(0) end end # Parse the config file for this process. def self.parse_config Puppet.settings.parse end # XXX this should all be done using puppet objects, not using # normal mkdir def self.recmkdir(dir,mode = 0755) if FileTest.exist?(dir) return false else tmp = dir.sub(/^\//,'') path = [File::SEPARATOR] tmp.split(File::SEPARATOR).each { |dir| path.push dir if ! FileTest.exist?(File.join(path)) begin Dir.mkdir(File.join(path), mode) rescue Errno::EACCES => detail Puppet.err detail.to_s return false rescue => detail Puppet.err "Could not create #{path}: #{detail}" return false end elsif FileTest.directory?(File.join(path)) next else FileTest.exist?(File.join(path)) raise Puppet::Error, "Cannot create #{dir}: basedir #{File.join(path)} is a file" end } return true end end # Create a new type. Just proxy to the Type class. def self.newtype(name, options = {}, &block) Puppet::Type.newtype(name, options, &block) end # Retrieve a type by name. Just proxy to the Type class. def self.type(name) # LAK:DEP Deprecation notice added 12/17/2008 Puppet.warning "Puppet.type is deprecated; use Puppet::Type.type" Puppet::Type.type(name) end end require 'puppet/type' require 'puppet/parser' require 'puppet/resource' require 'puppet/network' require 'puppet/ssl' require 'puppet/module' require 'puppet/util/storage' require 'puppet/status' require 'puppet/file_bucket/file' diff --git a/lib/puppet/application.rb b/lib/puppet/application.rb index 17ad69cee..7ef71bc81 100644 --- a/lib/puppet/application.rb +++ b/lib/puppet/application.rb @@ -1,407 +1,402 @@ require 'optparse' # This class handles all the aspects of a Puppet application/executable # * setting up options # * setting up logs # * choosing what to run # * representing execution status # # === Usage # An application is a subclass of Puppet::Application. # # For legacy compatibility, # Puppet::Application[:example].run # is equivalent to # Puppet::Application::Example.new.run # # # class Puppet::Application::Example << Puppet::Application # # def preinit # # perform some pre initialization # @all = false # end # # # run_command is called to actually run the specified command # def run_command # send Puppet::Util::CommandLine.new.args.shift # end # # # option uses metaprogramming to create a method # # and also tells the option parser how to invoke that method # option("--arg ARGUMENT") do |v| # @args << v # end # # option("--debug", "-d") do |v| # @debug = v # end # # option("--all", "-a:) do |v| # @all = v # end # # def handle_unknown(opt,arg) # # last chance to manage an option # ... # # let's say to the framework we finally handle this option # true # end # # def read # # read action # end # # def write # # writeaction # end # # end # # === Preinit # The preinit block is the first code to be called in your application, before option parsing, # setup or command execution. # # === Options # Puppet::Application uses +OptionParser+ to manage the application options. # Options are defined with the +option+ method to which are passed various # arguments, including the long option, the short option, a description... # Refer to +OptionParser+ documentation for the exact format. # * If the option method is given a block, this one will be called whenever # the option is encountered in the command-line argument. # * If the option method has no block, a default functionnality will be used, that # stores the argument (or true/false if the option doesn't require an argument) in # the global (to the application) options array. # * If a given option was not defined by a the +option+ method, but it exists as a Puppet settings: # * if +unknown+ was used with a block, it will be called with the option name and argument # * if +unknown+ wasn't used, then the option/argument is handed to Puppet.settings.handlearg for # a default behavior # # --help is managed directly by the Puppet::Application class, but can be overriden. # # === Setup # Applications can use the setup block to perform any initialization. # The defaul +setup+ behaviour is to: read Puppet configuration and manage log level and destination # # === What and how to run # If the +dispatch+ block is defined it is called. This block should return the name of the registered command # to be run. # If it doesn't exist, it defaults to execute the +main+ command if defined. # # === Execution state # The class attributes/methods of Puppet::Application serve as a global place to set and query the execution # status of the application: stopping, restarting, etc. The setting of the application status does not directly # aftect its running status; it's assumed that the various components within the application will consult these # settings appropriately and affect their own processing accordingly. Control operations (signal handlers and # the like) should set the status appropriately to indicate to the overall system that it's the process of # stopping or restarting (or just running as usual). # # So, if something in your application needs to stop the process, for some reason, you might consider: # # def stop_me! # # indicate that we're stopping # Puppet::Application.stop! # # ...do stuff... # end # # And, if you have some component that involves a long-running process, you might want to consider: # # def my_long_process(giant_list_to_munge) # giant_list_to_munge.collect do |member| # # bail if we're stopping # return if Puppet::Application.stop_requested? # process_member(member) # end # end module Puppet class Application require 'puppet/util' include Puppet::Util DOCPATTERN = File.expand_path(File.dirname(__FILE__) + "/util/command_line/*" ) class << self include Puppet::Util attr_accessor :run_status def clear! self.run_status = nil end def stop! self.run_status = :stop_requested end def restart! self.run_status = :restart_requested end # Indicates that Puppet::Application.restart! has been invoked and components should # do what is necessary to facilitate a restart. def restart_requested? :restart_requested == run_status end # Indicates that Puppet::Application.stop! has been invoked and components should do what is necessary # for a clean stop. def stop_requested? :stop_requested == run_status end # Indicates that one of stop! or start! was invoked on Puppet::Application, and some kind of process # shutdown/short-circuit may be necessary. def interrupted? [:restart_requested, :stop_requested].include? run_status end # Indicates that Puppet::Application believes that it's in usual running run_mode (no stop/restart request # currently active). def clear? run_status.nil? end # Only executes the given block if the run status of Puppet::Application is clear (no restarts, stops, # etc. requested). # Upon block execution, checks the run status again; if a restart has been requested during the block's # execution, then controlled_run will send a new HUP signal to the current process. # Thus, long-running background processes can potentially finish their work before a restart. def controlled_run(&block) return unless clear? result = block.call Process.kill(:HUP, $PID) if restart_requested? result end def should_parse_config @parse_config = true end def should_not_parse_config @parse_config = false end def should_parse_config? @parse_config = true if ! defined?(@parse_config) @parse_config end # used to declare code that handle an option def option(*options, &block) long = options.find { |opt| opt =~ /^--/ }.gsub(/^--(?:\[no-\])?([^ =]+).*$/, '\1' ).gsub('-','_') fname = symbolize("handle_#{long}") if (block_given?) define_method(fname, &block) else define_method(fname) do |value| self.options["#{long}".to_sym] = value end end self.option_parser_commands << [options, fname] end def banner(banner = nil) @banner ||= banner end def option_parser_commands @option_parser_commands ||= ( superclass.respond_to?(:option_parser_commands) ? superclass.option_parser_commands.dup : [] ) @option_parser_commands end def find(name) klass = name.to_s.capitalize # const_defined? is used before const_get since const_defined? will only # check within our namespace, whereas const_get will check ancestor # trees as well, resulting in unexpected behaviour. if !self.const_defined?(klass) puts "Unable to find application '#{name.to_s}'." Kernel::exit(1) end self.const_get(klass) end def [](name) find(name).new end # Sets or gets the run_mode name. Sets the run_mode name if a mode_name is # passed. Otherwise, gets the run_mode or a default run_mode # def run_mode( mode_name = nil) return @run_mode if @run_mode and not mode_name require 'puppet/util/run_mode' @run_mode = Puppet::Util::RunMode[ mode_name || :user ] end end attr_reader :options, :command_line # Every app responds to --version option("--version", "-V") do |arg| puts "#{Puppet.version}" exit end # Every app responds to --help option("--help", "-h") do |v| - help + puts help + exit end def should_parse_config? self.class.should_parse_config? end # override to execute code before running anything else def preinit end def initialize(command_line = nil) require 'puppet/util/command_line' @command_line = command_line || Puppet::Util::CommandLine.new - @run_mode = self.class.run_mode + set_run_mode self.class.run_mode @options = {} + require 'puppet' + end + + # WARNING: This is a totally scary, frightening, and nasty internal API. We + # strongly advise that you do not use this, and if you insist, we will + # politely allow you to keep both pieces of your broken code. + # + # We plan to provide a supported, long-term API to deliver this in a way + # that you can use. Please make sure that you let us know if you do require + # this, and this message is still present in the code. --daniel 2011-02-03 + def set_run_mode(mode) + @run_mode = mode $puppet_application_mode = @run_mode $puppet_application_name = name if Puppet.respond_to? :settings # This is to reduce the amount of confusion in rspec # because it might have loaded defaults.rb before the globals were set # and thus have the wrong defaults for the current application Puppet.settings.set_value(:confdir, Puppet.run_mode.conf_dir, :mutable_defaults) Puppet.settings.set_value(:vardir, Puppet.run_mode.var_dir, :mutable_defaults) Puppet.settings.set_value(:name, Puppet.application_name.to_s, :mutable_defaults) Puppet.settings.set_value(:logdir, Puppet.run_mode.logopts, :mutable_defaults) Puppet.settings.set_value(:rundir, Puppet.run_mode.run_dir, :mutable_defaults) Puppet.settings.set_value(:run_mode, Puppet.run_mode.name.to_s, :mutable_defaults) end - - require 'puppet' end # This is the main application entry point def run exit_on_fail("initialize") { preinit } exit_on_fail("parse options") { parse_options } exit_on_fail("parse configuration file") { Puppet.settings.parse } if should_parse_config? exit_on_fail("prepare for execution") { setup } exit_on_fail("run") { run_command } end def main raise NotImplementedError, "No valid command or main" end def run_command main end def setup # Handle the logging settings if options[:debug] or options[:verbose] Puppet::Util::Log.newdestination(:console) if options[:debug] Puppet::Util::Log.level = :debug else Puppet::Util::Log.level = :info end end Puppet::Util::Log.newdestination(:syslog) unless options[:setdest] end def parse_options # Create an option parser option_parser = OptionParser.new(self.class.banner) # Add all global options to it. Puppet.settings.optparse_addargs([]).each do |option| option_parser.on(*option) do |arg| handlearg(option[0], arg) end end # Add options that are local to this application, which were # created using the "option()" metaprogramming method. If there # are any conflicts, this application's options will be favored. self.class.option_parser_commands.each do |options, fname| option_parser.on(*options) do |value| # Call the method that "option()" created. self.send(fname, value) end end # scan command line. begin option_parser.parse!(self.command_line.args) rescue OptionParser::ParseError => detail $stderr.puts detail $stderr.puts "Try 'puppet #{command_line.subcommand_name} --help'" exit(1) end end def handlearg(opt, arg) # rewrite --[no-]option to --no-option if that's what was given if opt =~ /\[no-\]/ and !arg opt = opt.gsub(/\[no-\]/,'no-') end # otherwise remove the [no-] prefix to not confuse everybody opt = opt.gsub(/\[no-\]/, '') unless respond_to?(:handle_unknown) and send(:handle_unknown, opt, arg) # Puppet.settings.handlearg doesn't handle direct true/false :-) if arg.is_a?(FalseClass) arg = "false" elsif arg.is_a?(TrueClass) arg = "true" end Puppet.settings.handlearg(opt, arg) end end # this is used for testing def self.exit(code) exit(code) end def name self.class.to_s.sub(/.*::/,"").downcase.to_sym end def help - if Puppet.features.usage? - # RH:FIXME: My goodness, this is ugly. - ::RDoc.const_set("PuppetSourceFile", name) - #:stopdoc: # Issue #4161 - def (::RDoc).caller - docfile = `grep -l 'Puppet::Application\\[:#{::RDoc::PuppetSourceFile}\\]' #{DOCPATTERN}`.chomp - super << "#{docfile}:0" - end - #:startdoc: - ::RDoc::usage && exit - else - puts "No help available unless you have RDoc::usage installed" - exit - end - rescue Errno::ENOENT - puts "No help available for puppet #{name}" - exit + "No help available for puppet #{name}" end private def exit_on_fail(message, code = 1) yield rescue RuntimeError, NotImplementedError => detail puts detail.backtrace if Puppet[:trace] $stderr.puts "Could not #{message}: #{detail}" exit(code) end end end diff --git a/lib/puppet/application/agent.rb b/lib/puppet/application/agent.rb index 96f33296f..2ee40227e 100644 --- a/lib/puppet/application/agent.rb +++ b/lib/puppet/application/agent.rb @@ -1,271 +1,482 @@ require 'puppet/application' class Puppet::Application::Agent < Puppet::Application should_parse_config run_mode :agent attr_accessor :args, :agent, :daemon, :host def preinit # Do an initial trap, so that cancels don't get a stack trace. - trap(:INT) do + Signal.trap(:INT) do $stderr.puts "Cancelling startup" exit(0) end { :waitforcert => nil, :detailed_exitcodes => false, :verbose => false, :debug => false, :centrallogs => false, :setdest => false, :enable => false, :disable => false, :client => true, :fqdn => nil, :serve => [], :digest => :MD5, :fingerprint => false, }.each do |opt,val| options[opt] = val end @args = {} require 'puppet/daemon' @daemon = Puppet::Daemon.new @daemon.argv = ARGV.dup end option("--centrallogging") option("--disable") option("--enable") option("--debug","-d") option("--fqdn FQDN","-f") option("--test","-t") option("--verbose","-v") option("--fingerprint") option("--digest DIGEST") option("--serve HANDLER", "-s") do |arg| if Puppet::Network::Handler.handler(arg) options[:serve] << arg.to_sym else raise "Could not find handler for #{arg}" end end option("--no-client") do |arg| options[:client] = false end option("--detailed-exitcodes") do |arg| options[:detailed_exitcodes] = true end option("--logdest DEST", "-l DEST") do |arg| begin Puppet::Util::Log.newdestination(arg) options[:setdest] = true rescue => detail puts detail.backtrace if Puppet[:debug] $stderr.puts detail.to_s end end option("--waitforcert WAITFORCERT", "-w") do |arg| options[:waitforcert] = arg.to_i end option("--port PORT","-p") do |arg| @args[:Port] = arg end + def help + <<-HELP + +puppet-agent(8) -- The puppet agent daemon +======== + +SYNOPSIS +-------- +Retrieves the client configuration from the puppet master and applies it to +the local host. + +This service may be run as a daemon, run periodically using cron (or something +similar), or run interactively for testing purposes. + + +USAGE +----- +puppet agent [-D|--daemonize|--no-daemonize] [-d|--debug] + [--detailed-exitcodes] [--disable] [--enable] [-h|--help] + [--certname ] [-l|--logdest syslog||console] + [-o|--onetime] [--serve ] [-t|--test] [--noop] + [--digest ] [--fingerprint] [-V|--version] + [-v|--verbose] [-w|--waitforcert ] + + +DESCRIPTION +----------- +This is the main puppet client. Its job is to retrieve the local +machine's configuration from a remote server and apply it. In order to +successfully communicate with the remote server, the client must have a +certificate signed by a certificate authority that the server trusts; +the recommended method for this, at the moment, is to run a certificate +authority as part of the puppet server (which is the default). The +client will connect and request a signed certificate, and will continue +connecting until it receives one. + +Once the client has a signed certificate, it will retrieve its +configuration and apply it. + + +USAGE NOTES +----------- +'puppet agent' does its best to find a compromise between interactive +use and daemon use. Run with no arguments and no configuration, it will +go into the background, attempt to get a signed certificate, and retrieve +and apply its configuration every 30 minutes. + +Some flags are meant specifically for interactive use -- in particular, +'test', 'tags' or 'fingerprint' are useful. 'test' enables verbose +logging, causes the daemon to stay in the foreground, exits if the +server's configuration is invalid (this happens if, for instance, you've +left a syntax error on the server), and exits after running the +configuration once (rather than hanging around as a long-running +process). + +'tags' allows you to specify what portions of a configuration you want +to apply. Puppet elements are tagged with all of the class or definition +names that contain them, and you can use the 'tags' flag to specify one +of these names, causing only configuration elements contained within +that class or definition to be applied. This is very useful when you are +testing new configurations -- for instance, if you are just starting to +manage 'ntpd', you would put all of the new elements into an 'ntpd' +class, and call puppet with '--tags ntpd', which would only apply that +small portion of the configuration during your testing, rather than +applying the whole thing. + +'fingerprint' is a one-time flag. In this mode 'puppet agent' will run +once and display on the console (and in the log) the current certificate +(or certificate request) fingerprint. Providing the '--digest' option +allows to use a different digest algorithm to generate the fingerprint. +The main use is to verify that before signing a certificate request on +the master, the certificate request the master received is the same as +the one the client sent (to prevent against man-in-the-middle attacks +when signing certificates). + + +OPTIONS +------- +Note that any configuration parameter that's valid in the configuration +file is also a valid long argument. For example, 'server' is a valid +configuration parameter, so you can specify '--server ' as +an argument. + +See the configuration file documentation at +http://docs.puppetlabs.com/references/stable/configuration.html for the +full list of acceptable parameters. A commented list of all +configuration options can also be generated by running puppet agent with +'--genconfig'. + +* --daemonize: + Send the process into the background. This is the default. + +* --no-daemonize: + Do not send the process into the background. + +* --debug: + Enable full debugging. + +* --digest: + Change the certificate fingerprinting digest algorithm. The default is + MD5. Valid values depends on the version of OpenSSL installed, but + should always at least contain MD5, MD2, SHA1 and SHA256. + +* --detailed-exitcodes: + Provide transaction information via exit codes. If this is enabled, an + exit code of '2' means there were changes, and an exit code of '4' + means that there were failures during the transaction. This option + only makes sense in conjunction with --onetime. + +* --disable: + Disable working on the local system. This puts a lock file in place, + causing 'puppet agent' not to work on the system until the lock file + is removed. This is useful if you are testing a configuration and do + not want the central configuration to override the local state until + everything is tested and committed. + + 'puppet agent' uses the same lock file while it is running, so no more + than one 'puppet agent' process is working at a time. + + 'puppet agent' exits after executing this. + +* --enable: + Enable working on the local system. This removes any lock file, + causing 'puppet agent' to start managing the local system again + (although it will continue to use its normal scheduling, so it might + not start for another half hour). + + 'puppet agent' exits after executing this. + +* --certname: + Set the certname (unique ID) of the client. The master reads this + unique identifying string, which is usually set to the node's + fully-qualified domain name, to determine which configurations the + node will receive. Use this option to debug setup problems or + implement unusual node identification schemes. + +* --help: + Print this help message + +* --logdest: + Where to send messages. Choose between syslog, the console, and a log + file. Defaults to sending messages to syslog, or the console if + debugging or verbosity is enabled. + +* --no-client: + Do not create a config client. This will cause the daemon to run + without ever checking for its configuration automatically, and only + makes sense + +* --onetime: + Run the configuration once. Runs a single (normally daemonized) Puppet + run. Useful for interactively running puppet agent when used in + conjunction with the --no-daemonize option. + +* --fingerprint: + Display the current certificate or certificate signing request + fingerprint and then exit. Use the '--digest' option to change the + digest algorithm used. + +* --serve: + Start another type of server. By default, 'puppet agent' will start a + service handler that allows authenticated and authorized remote nodes + to trigger the configuration to be pulled down and applied. You can + specify any handler here that does not require configuration, e.g., + filebucket, ca, or resource. The handlers are in + 'lib/puppet/network/handler', and the names must match exactly, both + in the call to 'serve' and in 'namespaceauth.conf'. + +* --test: + Enable the most common options used for testing. These are 'onetime', + 'verbose', 'ignorecache', 'no-daemonize', 'no-usecacheonfailure', + 'detailed-exit-codes', 'no-splay', and 'show_diff'. + +* --noop: + Use 'noop' mode where the daemon runs in a no-op or dry-run mode. This + is useful for seeing what changes Puppet will make without actually + executing the changes. + +* --verbose: + Turn on verbose reporting. + +* --version: + Print the puppet version number and exit. + +* --waitforcert: + This option only matters for daemons that do not yet have certificates + and it is enabled by default, with a value of 120 (seconds). This + causes 'puppet agent' to connect to the server every 2 minutes and ask + it to sign a certificate request. This is useful for the initial setup + of a puppet client. You can turn off waiting for certificates by + specifying a time of 0. + + +EXAMPLE +------- + $ puppet agent --server puppet.domain.com + + +AUTHOR +------ +Luke Kanies + + +COPYRIGHT +--------- +Copyright (c) 2005, 2006 Puppet Labs, LLC Licensed under the GNU Public +License + + HELP + end + def run_command return fingerprint if options[:fingerprint] return onetime if Puppet[:onetime] main end def fingerprint unless cert = host.certificate || host.certificate_request $stderr.puts "Fingerprint asked but no certificate nor certificate request have yet been issued" exit(1) return end unless fingerprint = cert.fingerprint(options[:digest]) raise ArgumentError, "Could not get fingerprint for digest '#{options[:digest]}'" end Puppet.notice fingerprint end def onetime unless options[:client] $stderr.puts "onetime is specified but there is no client" exit(43) return end @daemon.set_signal_traps begin report = @agent.run rescue => detail puts detail.backtrace if Puppet[:trace] Puppet.err detail.to_s end if not report exit(1) - elsif not Puppet[:noop] and options[:detailed_exitcodes] then + elsif options[:detailed_exitcodes] then exit(report.exit_status) else exit(0) end end def main Puppet.notice "Starting Puppet client version #{Puppet.version}" @daemon.start end # Enable all of the most common test options. def setup_test Puppet.settings.handlearg("--ignorecache") Puppet.settings.handlearg("--no-usecacheonfailure") Puppet.settings.handlearg("--no-splay") Puppet.settings.handlearg("--show_diff") Puppet.settings.handlearg("--no-daemonize") options[:verbose] = true Puppet[:onetime] = true options[:detailed_exitcodes] = true end # Handle the logging settings. def setup_logs if options[:debug] or options[:verbose] Puppet::Util::Log.newdestination(:console) if options[:debug] Puppet::Util::Log.level = :debug else Puppet::Util::Log.level = :info end end Puppet::Util::Log.newdestination(:syslog) unless options[:setdest] end def enable_disable_client(agent) if options[:enable] agent.enable elsif options[:disable] agent.disable end exit(0) end def setup_listen unless FileTest.exists?(Puppet[:authconfig]) Puppet.err "Will not start without authorization file #{Puppet[:authconfig]}" exit(14) end handlers = nil if options[:serve].empty? handlers = [:Runner] else handlers = options[:serve] end require 'puppet/network/server' # No REST handlers yet. server = Puppet::Network::Server.new(:xmlrpc_handlers => handlers, :port => Puppet[:puppetport]) @daemon.server = server end def setup_host @host = Puppet::SSL::Host.new waitforcert = options[:waitforcert] || (Puppet[:onetime] ? 0 : 120) cert = @host.wait_for_cert(waitforcert) unless options[:fingerprint] end def setup setup_test if options[:test] setup_logs exit(Puppet.settings.print_configs ? 0 : 1) if Puppet.settings.print_configs? # If noop is set, then also enable diffs Puppet[:show_diff] = true if Puppet[:noop] args[:Server] = Puppet[:server] if options[:fqdn] args[:FQDN] = options[:fqdn] Puppet[:certname] = options[:fqdn] end if options[:centrallogs] logdest = args[:Server] logdest += ":" + args[:Port] if args.include?(:Port) Puppet::Util::Log.newdestination(logdest) end Puppet.settings.use :main, :agent, :ssl # Always ignoreimport for agent. It really shouldn't even try to import, # but this is just a temporary band-aid. Puppet[:ignoreimport] = true # We need to specify a ca location for all of the SSL-related i # indirected classes to work; in fingerprint mode we just need # access to the local files and we don't need a ca. Puppet::SSL::Host.ca_location = options[:fingerprint] ? :none : :remote Puppet::Transaction::Report.indirection.terminus_class = :rest # we want the last report to be persisted locally Puppet::Transaction::Report.indirection.cache_class = :yaml # Override the default; puppetd needs this, usually. # You can still override this on the command-line with, e.g., :compiler. Puppet[:catalog_terminus] = :rest # Override the default. Puppet[:facts_terminus] = :facter Puppet::Resource::Catalog.indirection.cache_class = :yaml # We need tomake the client either way, we just don't start it # if --no-client is set. require 'puppet/agent' require 'puppet/configurer' @agent = Puppet::Agent.new(Puppet::Configurer) enable_disable_client(@agent) if options[:enable] or options[:disable] @daemon.agent = agent if options[:client] # It'd be nice to daemonize later, but we have to daemonize before the # waitforcert happens. @daemon.daemonize if Puppet[:daemonize] setup_host @objects = [] # This has to go after the certs are dealt with. if Puppet[:listen] unless Puppet[:onetime] setup_listen else Puppet.notice "Ignoring --listen on onetime run" end end end end diff --git a/lib/puppet/application/apply.rb b/lib/puppet/application/apply.rb index e5b4bb5b7..2b7c9f8fb 100644 --- a/lib/puppet/application/apply.rb +++ b/lib/puppet/application/apply.rb @@ -1,160 +1,257 @@ require 'puppet/application' class Puppet::Application::Apply < Puppet::Application should_parse_config option("--debug","-d") option("--execute EXECUTE","-e") do |arg| options[:code] = arg end option("--loadclasses","-L") option("--verbose","-v") option("--use-nodes") option("--detailed-exitcodes") option("--apply catalog", "-a catalog") do |arg| options[:catalog] = arg end option("--logdest LOGDEST", "-l") do |arg| begin Puppet::Util::Log.newdestination(arg) options[:logset] = true rescue => detail $stderr.puts detail.to_s end end + def help + <<-HELP + +puppet-apply(8) -- Apply Puppet manifests locally +======== + +SYNOPSIS +-------- +Applies a standalone Puppet manifest to the local system. + + +USAGE +----- +puppet apply [-h|--help] [-V|--version] [-d|--debug] [-v|--verbose] + [-e|--execute] [--detailed-exitcodes] [-l|--logdest ] + [--apply ] + + +DESCRIPTION +----------- +This is the standalone puppet execution tool; use it to apply +individual manifests. + +When provided with a modulepath, via command line or config file, puppet +apply can effectively mimic the catalog that would be served by puppet +master with access to the same modules, although there are some subtle +differences. When combined with scheduling and an automated system for +pushing manifests, this can be used to implement a serverless Puppet +site. + +Most users should use 'puppet agent' and 'puppet master' for site-wide +manifests. + + +OPTIONS +------- +Note that any configuration parameter that's valid in the configuration +file is also a valid long argument. For example, 'modulepath' is a +valid configuration parameter, so you can specify '--tags ,' +as an argument. + +See the configuration file documentation at +http://docs.puppetlabs.com/references/stable/configuration.html for the +full list of acceptable parameters. A commented list of all +configuration options can also be generated by running puppet with +'--genconfig'. + +* --debug: + Enable full debugging. + +* --detailed-exitcodes: + Provide transaction information via exit codes. If this is enabled, an + exit code of '2' means there were changes, and an exit code of '4' + means that there were failures during the transaction. + +* --help: + Print this help message + +* --loadclasses: + Load any stored classes. 'puppet agent' caches configured classes + (usually at /etc/puppet/classes.txt), and setting this option causes + all of those classes to be set in your puppet manifest. + +* --logdest: + Where to send messages. Choose between syslog, the console, and a log + file. Defaults to sending messages to the console. + +* --execute: + Execute a specific piece of Puppet code + +* --verbose: + Print extra information. + +* --apply: + Apply a JSON catalog (such as one generated with 'puppet master --compile'). You can + either specify a JSON file or pipe in JSON from standard input. + + +EXAMPLE +------- + $ puppet apply -l /tmp/manifest.log manifest.pp + $ puppet apply --modulepath=/root/dev/modules -e "include ntpd::server" + + +AUTHOR +------ +Luke Kanies + + +COPYRIGHT +--------- +Copyright (c) 2005 Puppet Labs, LLC Licensed under the GNU Public +License + + HELP + end + def run_command if options[:catalog] apply elsif Puppet[:parseonly] parseonly else main end end def apply if options[:catalog] == "-" text = $stdin.read else text = File.read(options[:catalog]) end begin catalog = Puppet::Resource::Catalog.convert_from(Puppet::Resource::Catalog.default_format,text) catalog = Puppet::Resource::Catalog.pson_create(catalog) unless catalog.is_a?(Puppet::Resource::Catalog) rescue => detail raise Puppet::Error, "Could not deserialize catalog from pson: #{detail}" end catalog = catalog.to_ral require 'puppet/configurer' configurer = Puppet::Configurer.new configurer.run :catalog => catalog end def parseonly # Set our code or file to use. if options[:code] or command_line.args.length == 0 Puppet[:code] = options[:code] || STDIN.read else Puppet[:manifest] = command_line.args.shift end begin Puppet::Node::Environment.new(Puppet[:environment]).known_resource_types rescue => detail Puppet.err detail exit 1 end exit 0 end def main # Set our code or file to use. if options[:code] or command_line.args.length == 0 Puppet[:code] = options[:code] || STDIN.read else manifest = command_line.args.shift raise "Could not find file #{manifest}" unless File.exist?(manifest) Puppet.warning("Only one file can be applied per run. Skipping #{command_line.args.join(', ')}") if command_line.args.size > 0 Puppet[:manifest] = manifest end # Collect our facts. unless facts = Puppet::Node::Facts.indirection.find(Puppet[:certname]) raise "Could not find facts for #{Puppet[:certname]}" end # Find our Node unless node = Puppet::Node.indirection.find(Puppet[:certname]) raise "Could not find node #{Puppet[:certname]}" end # Merge in the facts. node.merge(facts.values) # Allow users to load the classes that puppet agent creates. if options[:loadclasses] file = Puppet[:classfile] if FileTest.exists?(file) unless FileTest.readable?(file) $stderr.puts "#{file} is not readable" exit(63) end node.classes = File.read(file).split(/[\s\n]+/) end end begin # Compile our catalog starttime = Time.now catalog = Puppet::Resource::Catalog.indirection.find(node.name, :use_node => node) # Translate it to a RAL catalog catalog = catalog.to_ral catalog.finalize catalog.retrieval_duration = Time.now - starttime require 'puppet/configurer' configurer = Puppet::Configurer.new report = configurer.run(:skip_plugin_download => true, :catalog => catalog) - exit( Puppet[:noop] ? 0 : options[:detailed_exitcodes] ? report.exit_status : 0 ) + exit( options[:detailed_exitcodes] ? report.exit_status : 0 ) rescue => detail puts detail.backtrace if Puppet[:trace] $stderr.puts detail.message exit(1) end end def setup exit(Puppet.settings.print_configs ? 0 : 1) if Puppet.settings.print_configs? # If noop is set, then also enable diffs Puppet[:show_diff] = true if Puppet[:noop] Puppet::Util::Log.newdestination(:console) unless options[:logset] client = nil server = nil - trap(:INT) do + Signal.trap(:INT) do $stderr.puts "Exiting" exit(1) end # we want the last report to be persisted locally Puppet::Transaction::Report.indirection.cache_class = :yaml if options[:debug] Puppet::Util::Log.level = :debug elsif options[:verbose] Puppet::Util::Log.level = :info end end end diff --git a/lib/puppet/application/cert.rb b/lib/puppet/application/cert.rb index 467b0c859..f02fc893c 100644 --- a/lib/puppet/application/cert.rb +++ b/lib/puppet/application/cert.rb @@ -1,85 +1,224 @@ require 'puppet/application' class Puppet::Application::Cert < Puppet::Application should_parse_config run_mode :master - attr_accessor :cert_mode, :all, :ca, :digest, :signed + attr_accessor :all, :ca, :digest, :signed - def find_mode(opt) - require 'puppet/ssl/certificate_authority' - modes = Puppet::SSL::CertificateAuthority::Interface::INTERFACE_METHODS - tmp = opt.sub("--", '').to_sym - @cert_mode = modes.include?(tmp) ? tmp : nil + def subcommand + @subcommand + end + def subcommand=(name) + # Handle the nasty, legacy mapping of "clean" to "destroy". + sub = name.to_sym + @subcommand = (sub == :clean ? :destroy : sub) end option("--clean", "-c") do - @cert_mode = :destroy + self.subcommand = "destroy" end option("--all", "-a") do @all = true end option("--digest DIGEST") do |arg| @digest = arg end option("--signed", "-s") do @signed = true end option("--debug", "-d") do |arg| Puppet::Util::Log.level = :debug end require 'puppet/ssl/certificate_authority/interface' Puppet::SSL::CertificateAuthority::Interface::INTERFACE_METHODS.reject {|m| m == :destroy }.each do |method| option("--#{method}", "-#{method.to_s[0,1]}") do - find_mode("--#{method}") + self.subcommand = method end end option("--verbose", "-v") do Puppet::Util::Log.level = :info end + def help + puts <<-HELP + +puppet-cert(8) -- Manage certificates and requests +======== + +SYNOPSIS +-------- +Standalone certificate authority. Capable of generating certificates, +but mostly used for signing certificate requests from puppet clients. + + +USAGE +----- +puppet cert [-h|--help] [-V|--version] [-d|--debug] [-v|--verbose] + [-g|--generate] [-l|--list] [-s|--sign] [-r|--revoke] [-p|--print] + [-c|--clean] [--verify] [--digest ] [--fingerprint] [host] + + +DESCRIPTION +----------- +Because the puppet master service defaults to not signing client +certificate requests, this script is available for signing outstanding +requests. It can be used to list outstanding requests and then either +sign them individually or sign all of them. + + +OPTIONS +------- +Note that any configuration parameter that's valid in the configuration +file is also a valid long argument. For example, 'ssldir' is a valid +configuration parameter, so you can specify '--ssldir ' as an +argument. + +See the configuration file documentation at +http://docs.puppetlabs.com/references/stable/configuration.html for the +full list of acceptable parameters. A commented list of all +configuration options can also be generated by running puppet cert with +'--genconfig'. + +* --all: + Operate on all items. Currently only makes sense with '--sign', + '--clean', or '--list'. + +* --digest: + Set the digest for fingerprinting (defaults to md5). Valid values + depends on your openssl and openssl ruby extension version, but should + contain at least md5, sha1, md2, sha256. + +* --clean: + Remove all files related to a host from puppet cert's storage. This is + useful when rebuilding hosts, since new certificate signing requests + will only be honored if puppet cert does not have a copy of a signed + certificate for that host. The certificate of the host is also + revoked. If '--all' is specified then all host certificates, both + signed and unsigned, will be removed. + +* --debug: + Enable full debugging. + +* --generate: + Generate a certificate for a named client. A certificate/keypair will + be generated for each client named on the command line. + +* --help: + Print this help message + +* --list: + List outstanding certificate requests. If '--all' is specified, signed + certificates are also listed, prefixed by '+', and revoked or invalid + certificates are prefixed by '-' (the verification outcome is printed + in parenthesis). + +* --print: + Print the full-text version of a host's certificate. + +* --fingerprint: + Print the DIGEST (defaults to md5) fingerprint of a host's + certificate. + +* --revoke: + Revoke the certificate of a client. The certificate can be specified + either by its serial number, given as a decimal number or a + hexadecimal number prefixed by '0x', or by its hostname. The + certificate is revoked by adding it to the Certificate Revocation List + given by the 'cacrl' config parameter. Note that the puppetmasterd + needs to be restarted after revoking certificates. + +* --sign: + Sign an outstanding certificate request. Unless '--all' is specified, + hosts must be listed after all flags. + +* --verbose: + Enable verbosity. + +* --version: + Print the puppet version number and exit. + +* --verify: + Verify the named certificate against the local CA certificate. + + +EXAMPLE +------- + $ puppet cert -l + culain.madstop.com + $ puppet cert -s culain.madstop.com + + +AUTHOR +------ +Luke Kanies + + +COPYRIGHT +--------- +Copyright (c) 2005 Puppet Labs, LLC Licensed under the GNU Public +License + + HELP + exit + end + def main if @all hosts = :all elsif @signed hosts = :signed else hosts = command_line.args.collect { |h| h.downcase } end begin - @ca.apply(:revoke, :to => hosts) if @cert_mode == :destroy - @ca.apply(@cert_mode, :to => hosts, :digest => @digest) + @ca.apply(:revoke, :to => hosts) if subcommand == :destroy + @ca.apply(subcommand, :to => hosts, :digest => @digest) rescue => detail puts detail.backtrace if Puppet[:trace] puts detail.to_s exit(24) end end def setup + require 'puppet/ssl/certificate_authority' exit(Puppet.settings.print_configs ? 0 : 1) if Puppet.settings.print_configs? Puppet::Util::Log.newdestination :console - if [:generate, :destroy].include? @cert_mode + if [:generate, :destroy].include? subcommand Puppet::SSL::Host.ca_location = :local else Puppet::SSL::Host.ca_location = :only end begin @ca = Puppet::SSL::CertificateAuthority.new rescue => detail puts detail.backtrace if Puppet[:trace] puts detail.to_s exit(23) end end + + def parse_options + # handle the bareword subcommand pattern. + result = super + unless self.subcommand then + if sub = self.command_line.args.shift then + self.subcommand = sub + else + help + end + end + result + end end diff --git a/lib/puppet/application/describe.rb b/lib/puppet/application/describe.rb index e76b347f6..79643159e 100644 --- a/lib/puppet/application/describe.rb +++ b/lib/puppet/application/describe.rb @@ -1,203 +1,257 @@ require 'puppet/application' class Formatter def initialize(width) @width = width end def wrap(txt, opts) return "" unless txt && !txt.empty? work = (opts[:scrub] ? scrub(txt) : txt) indent = (opts[:indent] ? opts[:indent] : 0) textLen = @width - indent patt = Regexp.new("^(.{0,#{textLen}})[ \n]") prefix = " " * indent res = [] while work.length > textLen if work =~ patt res << $1 work.slice!(0, $MATCH.length) else res << work.slice!(0, textLen) end end res << work if work.length.nonzero? prefix + res.join("\n#{prefix}") end def header(txt, sep = "-") "\n#{txt}\n" + sep * txt.size end private def scrub(text) # For text with no carriage returns, there's nothing to do. return text if text !~ /\n/ indent = nil # If we can match an indentation, then just remove that same level of # indent from every line. if text =~ /^(\s+)/ indent = $1 return text.gsub(/^#{indent}/,'') else return text end end end class TypeDoc def initialize @format = Formatter.new(76) @types = {} Puppet::Type.loadall Puppet::Type.eachtype { |type| next if type.name == :component @types[type.name] = type } end def list_types puts "These are the types known to puppet:\n" @types.keys.sort { |a, b| a.to_s <=> b.to_s }.each do |name| type = @types[name] s = type.doc.gsub(/\s+/, " ") n = s.index(".") if n.nil? s = ".. no documentation .." elsif n > 45 s = s[0, 45] + " ..." else s = s[0, n] end printf "%-15s - %s\n", name, s end end def format_type(name, opts) name = name.to_sym unless @types.has_key?(name) puts "Unknown type #{name}" return end type = @types[name] puts @format.header(name.to_s, "=") puts @format.wrap(type.doc, :indent => 0, :scrub => true) + "\n\n" puts @format.header("Parameters") if opts[:parameters] format_attrs(type, [:property, :param]) else list_attrs(type, [:property, :param]) end if opts[:meta] puts @format.header("Meta Parameters") if opts[:parameters] format_attrs(type, [:meta]) else list_attrs(type, [:meta]) end end if type.providers.size > 0 puts @format.header("Providers") if opts[:providers] format_providers(type) else list_providers(type) end end end # List details about attributes def format_attrs(type, attrs) docs = {} type.allattrs.each do |name| kind = type.attrtype(name) docs[name] = type.attrclass(name).doc if attrs.include?(kind) && name != :provider end docs.sort { |a,b| a[0].to_s <=> b[0].to_s }.each { |name, doc| print "\n- **#{name}**" if type.key_attributes.include?(name) and name != :name puts " (*namevar*)" else puts "" end puts @format.wrap(doc, :indent => 4, :scrub => true) } end # List the names of attributes def list_attrs(type, attrs) params = [] type.allattrs.each do |name| kind = type.attrtype(name) params << name.to_s if attrs.include?(kind) && name != :provider end puts @format.wrap(params.sort.join(", "), :indent => 4) end def format_providers(type) type.providers.sort { |a,b| a.to_s <=> b.to_s }.each { |prov| puts "\n- **#{prov}**" puts @format.wrap(type.provider(prov).doc, :indent => 4, :scrub => true) } end def list_providers(type) list = type.providers.sort { |a,b| a.to_s <=> b.to_s }.join(", ") puts @format.wrap(list, :indent => 4) end end class Puppet::Application::Describe < Puppet::Application banner "puppet describe [options] [type]" should_not_parse_config option("--short", "-s", "Only list parameters without detail") do |arg| options[:parameters] = false end option("--providers","-p") option("--list", "-l") option("--meta","-m") + def help + <<-HELP + +puppet-describe(8) -- Display help about resource types +======== + +SYNOPSIS +-------- +Prints help about Puppet resource types, providers, and metaparameters. + + +USAGE +----- +puppet describe [-h|--help] [-s|--short] [-p|--providers] [-l|--list] [-m|--meta] + + +OPTIONS +------- +* --help: + Print this help text + +* --providers: + Describe providers in detail for each type + +* --list: + List all types + +* --meta: + List all metaparameters + +* --short: + List only parameters without detail + + +EXAMPLE +------- + $ puppet describe --list + $ puppet describe file --providers + $ puppet describe user -s -m + + +AUTHOR +------ +David Lutterkort + + +COPYRIGHT +--------- +Copyright (c) 2005 Puppet Labs, LLC Licensed under the GNU Public +License + + HELP + end + def preinit options[:parameters] = true end def main doc = TypeDoc.new if options[:list] doc.list_types else options[:types].each { |name| doc.format_type(name, options) } end end def setup options[:types] = command_line.args.dup handle_help(nil) unless options[:list] || options[:types].size > 0 $stderr.puts "Warning: ignoring types when listing all types" if options[:list] && options[:types].size > 0 end end diff --git a/lib/puppet/application/doc.rb b/lib/puppet/application/doc.rb index aaefd6e75..74811919e 100644 --- a/lib/puppet/application/doc.rb +++ b/lib/puppet/application/doc.rb @@ -1,178 +1,265 @@ require 'puppet/application' class Puppet::Application::Doc < Puppet::Application - should_not_parse_config run_mode :master attr_accessor :unknown_args, :manifest def preinit {:references => [], :mode => :text, :format => :to_markdown }.each do |name,value| options[name] = value end @unknown_args = [] @manifest = false end option("--all","-a") option("--outputdir OUTPUTDIR","-o") option("--verbose","-v") option("--debug","-d") option("--charset CHARSET") option("--format FORMAT", "-f") do |arg| method = "to_#{arg}" require 'puppet/util/reference' if Puppet::Util::Reference.method_defined?(method) options[:format] = method else raise "Invalid output format #{arg}" end end option("--mode MODE", "-m") do |arg| require 'puppet/util/reference' if Puppet::Util::Reference.modes.include?(arg) or arg.intern==:rdoc options[:mode] = arg.intern else raise "Invalid output mode #{arg}" end end option("--list", "-l") do |arg| require 'puppet/util/reference' puts Puppet::Util::Reference.references.collect { |r| Puppet::Util::Reference.reference(r).doc }.join("\n") exit(0) end option("--reference REFERENCE", "-r") do |arg| options[:references] << arg.intern end + def help + <<-HELP + +puppet-doc(8) -- Generate Puppet documentation and references +======== + +SYNOPSIS +-------- +Generates a reference for all Puppet types. Largely meant for internal +Puppet Labs use. + + +USAGE +----- +puppet doc [-a|--all] [-h|--help] [-o|--outputdir ] + [-m|--mode text|pdf|rdoc] [-r|--reference ] + [--charset ] [] + + +DESCRIPTION +----------- +If mode is not 'rdoc', then this command generates a Markdown document +describing all installed Puppet types or all allowable arguments to +puppet executables. It is largely meant for internal use and is used to +generate the reference document available on the Puppet Labs web site. + +In 'rdoc' mode, this command generates an html RDoc hierarchy describing +the manifests that are in 'manifestdir' and 'modulepath' configuration +directives. The generated documentation directory is doc by default but +can be changed with the 'outputdir' option. + +If the command is run with the name of a manifest file as an argument, +puppet doc will output a single manifest's documentation on stdout. + + +OPTIONS +------- +* --all: + Output the docs for all of the reference types. In 'rdoc' + modes, this also outputs documentation for all resources + +* --help: + Print this help message + +* --outputdir: + Specifies the directory where to output the rdoc + documentation in 'rdoc' mode. + +* --mode: + Determine the output mode. Valid modes are 'text', 'pdf' and + 'rdoc'. The 'pdf' mode creates PDF formatted files in the + /tmp directory. The default mode is 'text'. In 'rdoc' mode + you must provide 'manifests-path' + +* --reference: + Build a particular reference. Get a list of references by + running 'puppet doc --list'. + +* --charset: + Used only in 'rdoc' mode. It sets the charset used in the + html files produced. + + +EXAMPLE +------- + $ puppet doc -r type > /tmp/type_reference.markdown + +or + + $ puppet doc --outputdir /tmp/rdoc --mode rdoc /path/to/manifests + +or + + $ puppet doc /etc/puppet/manifests/site.pp + +or + + $ puppet doc -m pdf -r configuration + + +AUTHOR +------ +Luke Kanies + + +COPYRIGHT +--------- +Copyright (c) 2005-2007 Puppet Labs, LLC Licensed under the GNU Public +License + +HELP + end + def handle_unknown( opt, arg ) @unknown_args << {:opt => opt, :arg => arg } true end def run_command return[:rdoc].include?(options[:mode]) ? send(options[:mode]) : other end def rdoc exit_code = 0 files = [] unless @manifest env = Puppet::Node::Environment.new files += env.modulepath files << File.dirname(env[:manifest]) end files += command_line.args Puppet.info "scanning: #{files.inspect}" - Puppet.settings.setdefaults( - "puppetdoc", - - "document_all" => [false, "Document all resources"] - ) Puppet.settings[:document_all] = options[:all] || false begin require 'puppet/util/rdoc' if @manifest Puppet::Util::RDoc.manifestdoc(files) else options[:outputdir] = "doc" unless options[:outputdir] Puppet::Util::RDoc.rdoc(options[:outputdir], files, options[:charset]) end rescue => detail puts detail.backtrace if Puppet[:trace] $stderr.puts "Could not generate documentation: #{detail}" exit_code = 1 end exit exit_code end def other text = "" with_contents = options[:references].length <= 1 exit_code = 0 require 'puppet/util/reference' options[:references].sort { |a,b| a.to_s <=> b.to_s }.each do |name| raise "Could not find reference #{name}" unless section = Puppet::Util::Reference.reference(name) begin # Add the per-section text, but with no ToC text += section.send(options[:format], with_contents) rescue => detail puts detail.backtrace $stderr.puts "Could not generate reference #{name}: #{detail}" exit_code = 1 next end end text += Puppet::Util::Reference.footer unless with_contents # We've only got one reference if options[:mode] == :pdf Puppet::Util::Reference.pdf(text) else puts text end exit exit_code end def setup # sole manifest documentation if command_line.args.size > 0 options[:mode] = :rdoc @manifest = true end if options[:mode] == :rdoc setup_rdoc else setup_reference end end def setup_reference if options[:all] # Don't add dynamic references to the "all" list. require 'puppet/util/reference' options[:references] = Puppet::Util::Reference.references.reject do |ref| Puppet::Util::Reference.reference(ref).dynamic? end end options[:references] << :type if options[:references].empty? end def setup_rdoc(dummy_argument=:work_arround_for_ruby_GC_bug) # consume the unknown options # and feed them as settings if @unknown_args.size > 0 @unknown_args.each do |option| # force absolute path for modulepath when passed on commandline if option[:opt]=="--modulepath" or option[:opt] == "--manifestdir" option[:arg] = option[:arg].split(':').collect { |p| File.expand_path(p) }.join(':') end Puppet.settings.handlearg(option[:opt], option[:arg]) end end # Now parse the config Puppet.parse_config # Handle the logging settings. if options[:debug] or options[:verbose] if options[:debug] Puppet::Util::Log.level = :debug else Puppet::Util::Log.level = :info end Puppet::Util::Log.newdestination(:console) end end end diff --git a/lib/puppet/application/filebucket.rb b/lib/puppet/application/filebucket.rb index 9c3c79bc3..063d97db8 100644 --- a/lib/puppet/application/filebucket.rb +++ b/lib/puppet/application/filebucket.rb @@ -1,87 +1,190 @@ require 'puppet/application' class Puppet::Application::Filebucket < Puppet::Application should_not_parse_config option("--bucket BUCKET","-b") option("--debug","-d") option("--local","-l") option("--remote","-r") option("--verbose","-v") attr :args + def help + <<-HELP + +puppet-filebucket(8) -- Store and retrieve files in a filebucket +======== + +SYNOPSIS +-------- +A stand-alone Puppet filebucket client. + + +USAGE +----- +puppet filebucket [-h|--help] [-V|--version] [-d|--debug] + [-v|--verbose] [-l|--local] [-r|--remote] [-s|--server ] + [-b|--bucket ] ... + +Puppet filebucket can operate in three modes, with only one mode per call: + +backup: + Send one or more files to the specified file bucket. Each sent file is + printed with its resulting md5 sum. + +get: + Return the text associated with an md5 sum. The text is printed to + stdout, and only one file can be retrieved at a time. + +restore: + Given a file path and an md5 sum, store the content associated with + the sum into the specified file path. You can specify an entirely new + path to this argument; you are not restricted to restoring the content + to its original location. + + +DESCRIPTION +----------- +This is a stand-alone filebucket client for sending files to a local or +central filebucket. + +Note that 'filebucket' defaults to using a network-based filebucket +available on the server named 'puppet'. To use this, you'll have to be +running as a user with valid Puppet certificates. Alternatively, you can +use your local file bucket by specifying '--local'. + + +OPTIONS +------- +Note that any configuration parameter that's valid in the configuration +file is also a valid long argument. For example, 'ssldir' is a valid +configuration parameter, so you can specify '--ssldir ' as an +argument. + +See the configuration file documentation at +http://docs.puppetlabs.com/references/stable/configuration.html for the +full list of acceptable parameters. A commented list of all +configuration options can also be generated by running puppet with +'--genconfig'. + +* --debug: + Enable full debugging. + +* --help: + Print this help message + +* --local: + Use the local filebucket. This will use the default configuration + information. + +* --remote: + Use a remote filebucket. This will use the default configuration + information. + +* --server: + The server to send the file to, instead of locally. + +* --verbose: + Print extra information. + +* --version: + Print version information. + + +EXAMPLE +------- + $ puppet filebucket backup /etc/passwd + /etc/passwd: 429b225650b912a2ee067b0a4cf1e949 + $ puppet filebucket restore /tmp/passwd 429b225650b912a2ee067b0a4cf1e949 + + +AUTHOR +------ +Luke Kanies + + +COPYRIGHT +--------- +Copyright (c) 2005 Puppet Labs, LLC Licensed under the GNU Public +License + + HELP + end + + def run_command @args = command_line.args command = args.shift return send(command) if %w{get backup restore}.include? command help end def get md5 = args.shift out = @client.getfile(md5) print out end def backup args.each do |file| unless FileTest.exists?(file) $stderr.puts "#{file}: no such file" next end unless FileTest.readable?(file) $stderr.puts "#{file}: cannot read file" next end md5 = @client.backup(file) puts "#{file}: #{md5}" end end def restore file = args.shift md5 = args.shift @client.restore(file, md5) end def setup Puppet::Log.newdestination(:console) @client = nil @server = nil - trap(:INT) do + Signal.trap(:INT) do $stderr.puts "Cancelling" exit(1) end if options[:debug] Puppet::Log.level = :debug elsif options[:verbose] Puppet::Log.level = :info end # Now parse the config Puppet.parse_config exit(Puppet.settings.print_configs ? 0 : 1) if Puppet.settings.print_configs? require 'puppet/file_bucket/dipper' begin if options[:local] or options[:bucket] path = options[:bucket] || Puppet[:bucketdir] @client = Puppet::FileBucket::Dipper.new(:Path => path) else @client = Puppet::FileBucket::Dipper.new(:Server => Puppet[:server]) end rescue => detail $stderr.puts detail puts detail.backtrace if Puppet[:trace] exit(1) end end end diff --git a/lib/puppet/application/inspect.rb b/lib/puppet/application/inspect.rb index 19324e285..e448cb9e8 100644 --- a/lib/puppet/application/inspect.rb +++ b/lib/puppet/application/inspect.rb @@ -1,123 +1,181 @@ require 'puppet' require 'puppet/application' require 'puppet/file_bucket/dipper' class Puppet::Application::Inspect < Puppet::Application should_parse_config run_mode :agent option("--debug","-d") option("--verbose","-v") option("--logdest LOGDEST", "-l") do |arg| begin Puppet::Util::Log.newdestination(arg) options[:logset] = true rescue => detail $stderr.puts detail.to_s end end + def help + <<-HELP + +puppet-inspect(8) -- Send an inspection report +======== + +SYNOPSIS +-------- + +Prepares and submits an inspection report to the puppet master. + + +USAGE +----- +puppet inspect + + +DESCRIPTION +----------- + +This command uses the cached catalog from the previous run of 'puppet +agent' to determine which attributes of which resources have been +marked as auditable with the 'audit' metaparameter. It then examines +the current state of the system, writes the state of the specified +resource attributes to a report, and submits the report to the puppet +master. + +Puppet inspect does not run as a daemon, and must be run manually or +from cron. + + +OPTIONS +------- + +Any configuration setting which is valid in the configuration file is +also a valid long argument, e.g. '--server=master.domain.com'. See the +configuration file documentation at +http://docs.puppetlabs.com/references/latest/configuration.html for +the full list of acceptable settings. + + +AUTHOR +------ + +Puppet Labs + + +COPYRIGHT +--------- + +Copyright (c) 2011 Puppet Labs, LLC +Licensed under the GNU General Public License version 2 + + HELP + end + def setup exit(Puppet.settings.print_configs ? 0 : 1) if Puppet.settings.print_configs? raise "Inspect requires reporting to be enabled. Set report=true in puppet.conf to enable reporting." unless Puppet[:report] @report = Puppet::Transaction::Report.new("inspect") Puppet::Util::Log.newdestination(@report) Puppet::Util::Log.newdestination(:console) unless options[:logset] - trap(:INT) do + Signal.trap(:INT) do $stderr.puts "Exiting" exit(1) end if options[:debug] Puppet::Util::Log.level = :debug elsif options[:verbose] Puppet::Util::Log.level = :info end Puppet::Transaction::Report.indirection.terminus_class = :rest Puppet::Resource::Catalog.indirection.terminus_class = :yaml end def run_command - retrieval_starttime = Time.now + benchmark(:notice, "Finished inspection") do + retrieval_starttime = Time.now - unless catalog = Puppet::Resource::Catalog.indirection.find(Puppet[:certname]) - raise "Could not find catalog for #{Puppet[:certname]}" - end + unless catalog = Puppet::Resource::Catalog.indirection.find(Puppet[:certname]) + raise "Could not find catalog for #{Puppet[:certname]}" + end - @report.configuration_version = catalog.version + @report.configuration_version = catalog.version - inspect_starttime = Time.now - @report.add_times("config_retrieval", inspect_starttime - retrieval_starttime) + inspect_starttime = Time.now + @report.add_times("config_retrieval", inspect_starttime - retrieval_starttime) - if Puppet[:archive_files] - dipper = Puppet::FileBucket::Dipper.new(:Server => Puppet[:archive_file_server]) - end + if Puppet[:archive_files] + dipper = Puppet::FileBucket::Dipper.new(:Server => Puppet[:archive_file_server]) + end - catalog.to_ral.resources.each do |ral_resource| - audited_attributes = ral_resource[:audit] - next unless audited_attributes + catalog.to_ral.resources.each do |ral_resource| + audited_attributes = ral_resource[:audit] + next unless audited_attributes - status = Puppet::Resource::Status.new(ral_resource) + status = Puppet::Resource::Status.new(ral_resource) - begin - audited_resource = ral_resource.to_resource - rescue StandardError => detail - puts detail.backtrace if Puppet[:trace] - ral_resource.err "Could not inspect #{ral_resource}; skipping: #{detail}" - audited_attributes.each do |name| - event = ral_resource.event( - :property => name, - :status => "failure", - :audited => true, - :message => "failed to inspect #{name}" - ) - status.add_event(event) - end - else - audited_attributes.each do |name| - next if audited_resource[name].nil? - # Skip :absent properties of :absent resources. Really, it would be nicer if the RAL returned nil for those, but it doesn't. ~JW - if name == :ensure or audited_resource[:ensure] != :absent or audited_resource[name] != :absent + begin + audited_resource = ral_resource.to_resource + rescue StandardError => detail + puts detail.backtrace if Puppet[:trace] + ral_resource.err "Could not inspect #{ral_resource}; skipping: #{detail}" + audited_attributes.each do |name| event = ral_resource.event( - :previous_value => audited_resource[name], - :property => name, - :status => "audit", - :audited => true, - :message => "inspected value is #{audited_resource[name].inspect}" - ) + :property => name, + :status => "failure", + :audited => true, + :message => "failed to inspect #{name}" + ) status.add_event(event) end + else + audited_attributes.each do |name| + next if audited_resource[name].nil? + # Skip :absent properties of :absent resources. Really, it would be nicer if the RAL returned nil for those, but it doesn't. ~JW + if name == :ensure or audited_resource[:ensure] != :absent or audited_resource[name] != :absent + event = ral_resource.event( + :previous_value => audited_resource[name], + :property => name, + :status => "audit", + :audited => true, + :message => "inspected value is #{audited_resource[name].inspect}" + ) + status.add_event(event) + end + end end - end - if Puppet[:archive_files] and ral_resource.type == :file and audited_attributes.include?(:content) - path = ral_resource[:path] - if File.readable?(path) - begin - dipper.backup(path) - rescue StandardError => detail - Puppet.warning detail + if Puppet[:archive_files] and ral_resource.type == :file and audited_attributes.include?(:content) + path = ral_resource[:path] + if File.readable?(path) + begin + dipper.backup(path) + rescue StandardError => detail + Puppet.warning detail + end end end + @report.add_resource_status(status) end - @report.add_resource_status(status) - end - finishtime = Time.now - @report.add_times("inspect", finishtime - inspect_starttime) - @report.finalize_report + finishtime = Time.now + @report.add_times("inspect", finishtime - inspect_starttime) + @report.finalize_report - begin - Puppet::Transaction::Report.indirection.save(@report) - rescue => detail - puts detail.backtrace if Puppet[:trace] - Puppet.err "Could not send report: #{detail}" + begin + Puppet::Transaction::Report.indirection.save(@report) + rescue => detail + puts detail.backtrace if Puppet[:trace] + Puppet.err "Could not send report: #{detail}" + end end end end diff --git a/lib/puppet/application/kick.rb b/lib/puppet/application/kick.rb index 12dad653a..604132818 100644 --- a/lib/puppet/application/kick.rb +++ b/lib/puppet/application/kick.rb @@ -1,212 +1,353 @@ require 'puppet/application' class Puppet::Application::Kick < Puppet::Application should_not_parse_config attr_accessor :hosts, :tags, :classes option("--all","-a") option("--foreground","-f") option("--debug","-d") option("--ping","-P") option("--test") option("--host HOST") do |arg| @hosts << arg end option("--tag TAG", "-t") do |arg| @tags << arg end option("--class CLASS", "-c") do |arg| @classes << arg end option("--no-fqdn", "-n") do |arg| options[:fqdn] = false end option("--parallel PARALLEL", "-p") do |arg| begin options[:parallel] = Integer(arg) rescue $stderr.puts "Could not convert #{arg.inspect} to an integer" exit(23) end end + def help + <<-HELP + +puppet-kick(8) -- Remotely control puppet agent +======== + +SYNOPSIS +-------- +Trigger a puppet agent run on a set of hosts. + + +USAGE +----- +puppet kick [-a|--all] [-c|--class ] [-d|--debug] [-f|--foreground] + [-h|--help] [--host ] [--no-fqdn] [--ignoreschedules] + [-t|--tag ] [--test] [-p|--ping] [ [...]] + + +DESCRIPTION +----------- +This script can be used to connect to a set of machines running 'puppet +agent' and trigger them to run their configurations. The most common +usage would be to specify a class of hosts and a set of tags, and +'puppet kick' would look up in LDAP all of the hosts matching that +class, then connect to each host and trigger a run of all of the objects +with the specified tags. + +If you are not storing your host configurations in LDAP, you can specify +hosts manually. + +You will most likely have to run 'puppet kick' as root to get access to +the SSL certificates. + +'puppet kick' reads 'puppet master''s configuration file, so that it can +copy things like LDAP settings. + + +USAGE NOTES +----------- +'puppet kick' is useless unless 'puppet agent' is listening. See its +documentation for more information, but the gist is that you must enable +'listen' on the 'puppet agent' daemon, either using '--listen' on the +command line or adding 'listen = true' in its config file. In addition, +you need to set the daemons up to specifically allow connections by +creating the 'namespaceauth' file, normally at +'/etc/puppet/namespaceauth.conf'. This file specifies who has access to +each namespace; if you create the file you must add every namespace you +want any Puppet daemon to allow -- it is currently global to all Puppet +daemons. + +An example file looks like this: + + [fileserver] + allow *.madstop.com + + [puppetmaster] + allow *.madstop.com + + [puppetrunner] + allow culain.madstop.com + +This is what you would install on your Puppet master; non-master hosts +could leave off the 'fileserver' and 'puppetmaster' namespaces. + + +OPTIONS +------- +Note that any configuration parameter that's valid in the configuration +file is also a valid long argument. For example, 'ssldir' is a valid +configuration parameter, so you can specify '--ssldir ' as an +argument. + +See the configuration file documentation at +http://docs.puppetlabs.com/references/latest/configuration.html for +the full list of acceptable parameters. A commented list of all +configuration options can also be generated by running puppet master +with '--genconfig'. + +* --all: + Connect to all available hosts. Requires LDAP support at this point. + +* --class: + Specify a class of machines to which to connect. This only works if + you have LDAP configured, at the moment. + +* --debug: + Enable full debugging. + +* --foreground: + Run each configuration in the foreground; that is, when connecting to + a host, do not return until the host has finished its run. The default + is false. + +* --help: + Print this help message + +* --host: + A specific host to which to connect. This flag can be specified more + than once. + +* --ignoreschedules: + Whether the client should ignore schedules when running its + configuration. This can be used to force the client to perform work it + would not normally perform so soon. The default is false. + +* --parallel: + How parallel to make the connections. Parallelization is provided by + forking for each client to which to connect. The default is 1, meaning + serial execution. + +* --tag: + Specify a tag for selecting the objects to apply. Does not work with + the --test option. + +* --test: + Print the hosts you would connect to but do not actually connect. This + option requires LDAP support at this point. + +* --ping: + Do a ICMP echo against the target host. Skip hosts that don't respond + to ping. + + +EXAMPLE +------- + $ sudo puppet kick -p 10 -t remotefile -t webserver host1 host2 + + +AUTHOR +------ +Luke Kanies + + +COPYRIGHT +--------- +Copyright (c) 2005 Puppet Labs, LLC Licensed under the GNU Public +License + + HELP + end + def run_command @hosts += command_line.args options[:test] ? test : main end def test puts "Skipping execution in test mode" exit(0) end def main require 'puppet/network/client' Puppet.warning "Failed to load ruby LDAP library. LDAP functionality will not be available" unless Puppet.features.ldap? require 'puppet/util/ldap/connection' todo = @hosts.dup failures = [] # Now do the actual work go = true while go # If we don't have enough children in process and we still have hosts left to # do, then do the next host. if @children.length < options[:parallel] and ! todo.empty? host = todo.shift pid = fork do run_for_host(host) end @children[pid] = host else # Else, see if we can reap a process. begin pid = Process.wait if host = @children[pid] # Remove our host from the list of children, so the parallelization # continues working. @children.delete(pid) failures << host if $CHILD_STATUS.exitstatus != 0 print "#{host} finished with exit code #{$CHILD_STATUS.exitstatus}\n" else $stderr.puts "Could not find host for PID #{pid} with status #{$CHILD_STATUS.exitstatus}" end rescue Errno::ECHILD # There are no children left, so just exit unless there are still # children left to do. next unless todo.empty? if failures.empty? puts "Finished" exit(0) else puts "Failed: #{failures.join(", ")}" exit(3) end end end end end def run_for_host(host) if options[:ping] out = %x{ping -c 1 #{host}} unless $CHILD_STATUS == 0 $stderr.print "Could not contact #{host}\n" next end end require 'puppet/run' Puppet::Run.indirection.terminus_class = :rest port = Puppet[:puppetport] url = ["https://#{host}:#{port}", "production", "run", host].join('/') print "Triggering #{host}\n" begin run_options = { :tags => @tags, :background => ! options[:foreground], :ignoreschedules => options[:ignoreschedules] } run = Puppet::Run.indirection.save(Puppet::Run.new( run_options ), url) puts "Getting status" result = run.status puts "status is #{result}" rescue => detail puts detail.backtrace if Puppet[:trace] $stderr.puts "Host #{host} failed: #{detail}\n" exit(2) end case result when "success"; exit(0) when "running" $stderr.puts "Host #{host} is already running" exit(3) else $stderr.puts "Host #{host} returned unknown answer '#{result}'" exit(12) end end def initialize(*args) super @hosts = [] @classes = [] @tags = [] end def preinit [:INT, :TERM].each do |signal| - trap(signal) do + Signal.trap(signal) do $stderr.puts "Cancelling" exit(1) end end options[:parallel] = 1 options[:verbose] = true options[:fqdn] = true options[:ignoreschedules] = false options[:foreground] = false end def setup if options[:debug] Puppet::Util::Log.level = :debug else Puppet::Util::Log.level = :info end # Now parse the config Puppet.parse_config if Puppet[:node_terminus] == "ldap" and (options[:all] or @classes) if options[:all] @hosts = Puppet::Node.indirection.search("whatever", :fqdn => options[:fqdn]).collect { |node| node.name } puts "all: #{@hosts.join(", ")}" else @hosts = [] @classes.each do |klass| list = Puppet::Node.indirection.search("whatever", :fqdn => options[:fqdn], :class => klass).collect { |node| node.name } puts "#{klass}: #{list.join(", ")}" @hosts += list end end elsif ! @classes.empty? $stderr.puts "You must be using LDAP to specify host classes" exit(24) end @children = {} # If we get a signal, then kill all of our children and get out. [:INT, :TERM].each do |signal| - trap(signal) do + Signal.trap(signal) do Puppet.notice "Caught #{signal}; shutting down" @children.each do |pid, host| Process.kill("INT", pid) end waitall exit(1) end end end end diff --git a/lib/puppet/application/master.rb b/lib/puppet/application/master.rb index 879b66c67..3bfad89f4 100644 --- a/lib/puppet/application/master.rb +++ b/lib/puppet/application/master.rb @@ -1,153 +1,239 @@ require 'puppet/application' class Puppet::Application::Master < Puppet::Application should_parse_config run_mode :master option("--debug", "-d") option("--verbose", "-v") # internal option, only to be used by ext/rack/config.ru option("--rack") option("--compile host", "-c host") do |arg| options[:node] = arg end option("--logdest DEST", "-l DEST") do |arg| begin Puppet::Util::Log.newdestination(arg) options[:setdest] = true rescue => detail puts detail.backtrace if Puppet[:debug] $stderr.puts detail.to_s end end + def help + <<-HELP + +puppet-master(8) -- The puppet master daemon +======== + +SYNOPSIS +-------- +The central puppet server. Functions as a certificate authority by +default. + + +USAGE +----- +puppet master [-D|--daemonize|--no-daemonize] [-d|--debug] [-h|--help] + [-l|--logdest |console|syslog] [-v|--verbose] [-V|--version] + [--compile ] + + +DESCRIPTION +----------- +This command starts an instance of puppet master, running as a daemon +and using Ruby's built-in Webrick webserver. Puppet master can also be +managed by other application servers; when this is the case, this +executable is not used. + + +OPTIONS +------- +Note that any configuration parameter that's valid in the configuration +file is also a valid long argument. For example, 'ssldir' is a valid +configuration parameter, so you can specify '--ssldir ' as an +argument. + +See the configuration file documentation at +http://docs.puppetlabs.com/references/stable/configuration.html for the +full list of acceptable parameters. A commented list of all +configuration options can also be generated by running puppet master +with '--genconfig'. + +* --daemonize: + Send the process into the background. This is the default. + +* --no-daemonize: + Do not send the process into the background. + +* --debug: + Enable full debugging. + +* --help: + Print this help message. + +* --logdest: + Where to send messages. Choose between syslog, the console, and a log + file. Defaults to sending messages to syslog, or the console if + debugging or verbosity is enabled. + +* --verbose: + Enable verbosity. + +* --version: + Print the puppet version number and exit. + +* --compile: + Compile a catalogue and output it in JSON from the puppet master. Uses + facts contained in the $vardir/yaml/ directory to compile the catalog. + + +EXAMPLE +------- + puppet master + + +AUTHOR +------ +Luke Kanies + + +COPYRIGHT +--------- +Copyright (c) 2005 Puppet Labs, LLC Licensed under the GNU Public +License + + HELP + end + def preinit - trap(:INT) do + Signal.trap(:INT) do $stderr.puts "Cancelling startup" exit(0) end # Create this first-off, so we have ARGV require 'puppet/daemon' @daemon = Puppet::Daemon.new @daemon.argv = ARGV.dup end def run_command if options[:node] compile elsif Puppet[:parseonly] parseonly else main end end def compile Puppet::Util::Log.newdestination :console raise ArgumentError, "Cannot render compiled catalogs without pson support" unless Puppet.features.pson? begin unless catalog = Puppet::Resource::Catalog.indirection.find(options[:node]) raise "Could not compile catalog for #{options[:node]}" end jj catalog.to_resource rescue => detail $stderr.puts detail exit(30) end exit(0) end def parseonly begin Puppet::Node::Environment.new(Puppet[:environment]).known_resource_types rescue => detail Puppet.err detail exit 1 end exit(0) end def main require 'etc' require 'puppet/file_serving/content' require 'puppet/file_serving/metadata' xmlrpc_handlers = [:Status, :FileServer, :Master, :Report, :Filebucket] xmlrpc_handlers << :CA if Puppet[:ca] # Make sure we've got a localhost ssl cert Puppet::SSL::Host.localhost # And now configure our server to *only* hit the CA for data, because that's # all it will have write access to. Puppet::SSL::Host.ca_location = :only if Puppet::SSL::CertificateAuthority.ca? if Puppet.features.root? begin Puppet::Util.chuser rescue => detail puts detail.backtrace if Puppet[:trace] $stderr.puts "Could not change user to #{Puppet[:user]}: #{detail}" exit(39) end end unless options[:rack] require 'puppet/network/server' @daemon.server = Puppet::Network::Server.new(:xmlrpc_handlers => xmlrpc_handlers) @daemon.daemonize if Puppet[:daemonize] else require 'puppet/network/http/rack' @app = Puppet::Network::HTTP::Rack.new(:xmlrpc_handlers => xmlrpc_handlers, :protocols => [:rest, :xmlrpc]) end Puppet.notice "Starting Puppet master version #{Puppet.version}" unless options[:rack] @daemon.start else return @app end end def setup # Handle the logging settings. if options[:debug] or options[:verbose] if options[:debug] Puppet::Util::Log.level = :debug else Puppet::Util::Log.level = :info end unless Puppet[:daemonize] or options[:rack] Puppet::Util::Log.newdestination(:console) options[:setdest] = true end end Puppet::Util::Log.newdestination(:syslog) unless options[:setdest] exit(Puppet.settings.print_configs ? 0 : 1) if Puppet.settings.print_configs? Puppet.settings.use :main, :master, :ssl # Cache our nodes in yaml. Currently not configurable. Puppet::Node.indirection.cache_class = :yaml # Configure all of the SSL stuff. if Puppet::SSL::CertificateAuthority.ca? Puppet::SSL::Host.ca_location = :local Puppet.settings.use :ca Puppet::SSL::CertificateAuthority.instance else Puppet::SSL::Host.ca_location = :none end end end diff --git a/lib/puppet/application/queue.rb b/lib/puppet/application/queue.rb index b9e8ca4ca..de8aea32a 100644 --- a/lib/puppet/application/queue.rb +++ b/lib/puppet/application/queue.rb @@ -1,92 +1,165 @@ require 'puppet/application' require 'puppet/util' class Puppet::Application::Queue < Puppet::Application should_parse_config attr_accessor :daemon def preinit require 'puppet/daemon' @daemon = Puppet::Daemon.new @daemon.argv = ARGV.dup Puppet::Util::Log.newdestination(:console) # Do an initial trap, so that cancels don't get a stack trace. # This exits with exit code 1 - trap(:INT) do + Signal.trap(:INT) do $stderr.puts "Caught SIGINT; shutting down" exit(1) end # This is a normal shutdown, so code 0 - trap(:TERM) do + Signal.trap(:TERM) do $stderr.puts "Caught SIGTERM; shutting down" exit(0) end { :verbose => false, :debug => false }.each do |opt,val| options[opt] = val end end option("--debug","-d") option("--verbose","-v") + def help + <<-HELP + +puppet-queue(8) -- Queuing daemon for asynchronous storeconfigs +======== + +SYNOPSIS +-------- +Retrieves serialized storeconfigs records from a queue and processes +them in order. + + +USAGE +----- +puppet queue [-d|--debug] [-v|--verbose] + + +DESCRIPTION +----------- +This application runs as a daemon and processes storeconfigs data, +retrieving the data from a stomp server message queue and writing it to +a database. + +For more information, including instructions for properly setting up +your puppet master and message queue, see the documentation on setting +up asynchronous storeconfigs at: +http://projects.puppetlabs.com/projects/1/wiki/Using_Stored_Configuration + + +OPTIONS +------- +Note that any configuration parameter that's valid in the configuration +file is also a valid long argument. For example, 'server' is a valid +configuration parameter, so you can specify '--server ' as +an argument. + +See the configuration file documentation at +http://docs.puppetlabs.com/references/stable/configuration.html for the +full list of acceptable parameters. A commented list of all +configuration options can also be generated by running puppet queue with +'--genconfig'. + +* --debug: + Enable full debugging. + +* --help: + Print this help message + +* --verbose: + Turn on verbose reporting. + +* --version: + Print the puppet version number and exit. + + +EXAMPLE +------- + $ puppet queue + + +AUTHOR +------ +Luke Kanies + + +COPYRIGHT +--------- +Copyright (c) 2009 Puppet Labs, LLC Licensed under the GNU Public +License + + HELP + end + def main require 'puppet/indirector/catalog/queue' # provides Puppet::Indirector::Queue.subscribe Puppet.notice "Starting puppetqd #{Puppet.version}" Puppet::Resource::Catalog::Queue.subscribe do |catalog| # Once you have a Puppet::Resource::Catalog instance, passing it to save should suffice # to put it through to the database via its active_record indirector (which is determined # by the terminus_class = :active_record setting above) Puppet::Util.benchmark(:notice, "Processing queued catalog for #{catalog.name}") do begin Puppet::Resource::Catalog.indirection.save(catalog) rescue => detail puts detail.backtrace if Puppet[:trace] Puppet.err "Could not save queued catalog for #{catalog.name}: #{detail}" end end end Thread.list.each { |thread| thread.join } end # Handle the logging settings. def setup_logs if options[:debug] or options[:verbose] Puppet::Util::Log.newdestination(:console) if options[:debug] Puppet::Util::Log.level = :debug else Puppet::Util::Log.level = :info end end end def setup unless Puppet.features.stomp? raise ArgumentError, "Could not load the 'stomp' library, which must be present for queueing to work. You must install the required library." end setup_logs exit(Puppet.settings.print_configs ? 0 : 1) if Puppet.settings.print_configs? require 'puppet/resource/catalog' Puppet::Resource::Catalog.indirection.terminus_class = :active_record daemon.daemonize if Puppet[:daemonize] # We want to make sure that we don't have a cache # class set up, because if storeconfigs is enabled, # we'll get a loop of continually caching the catalog # for storage again. Puppet::Resource::Catalog.indirection.cache_class = nil end end diff --git a/lib/puppet/application/resource.rb b/lib/puppet/application/resource.rb index c7c1c28be..3995c285b 100644 --- a/lib/puppet/application/resource.rb +++ b/lib/puppet/application/resource.rb @@ -1,118 +1,221 @@ require 'puppet/application' class Puppet::Application::Resource < Puppet::Application should_not_parse_config attr_accessor :host, :extra_params def preinit @extra_params = [] @host = nil Facter.loadfacts end option("--debug","-d") option("--verbose","-v") option("--edit","-e") option("--host HOST","-H") do |arg| @host = arg end option("--types", "-t") do |arg| types = [] Puppet::Type.loadall Puppet::Type.eachtype do |t| next if t.name == :component types << t.name.to_s end puts types.sort exit end option("--param PARAM", "-p") do |arg| @extra_params << arg.to_sym end + def help + <<-HELP + +puppet-resource(8) -- The resource abstraction layer shell +======== + +SYNOPSIS +-------- +Uses the Puppet RAL to directly interact with the system. + + +USAGE +----- +puppet resource [-h|--help] [-d|--debug] [-v|--verbose] [-e|--edit] + [-H|--host ] [-p|--param ] [-t|--types] + [] [= ...] + + +DESCRIPTION +----------- +This command provides simple facilities for converting current system +state into Puppet code, along with some ability to modify the current +state using Puppet's RAL. + +By default, you must at least provide a type to list, in which case +puppet resource will tell you everything it knows about all resources of +that type. You can optionally specify an instance name, and puppet +resource will only describe that single instance. + +If given a type, a name, and a series of = pairs, +puppet resource will modify the state of the specified resource. +Alternately, if given a type, a name, and the '--edit' flag, puppet +resource will write its output to a file, open that file in an editor, +and then apply the saved file as a Puppet transaction. + + +OPTIONS +------- +Note that any configuration parameter that's valid in the configuration +file is also a valid long argument. For example, 'ssldir' is a valid +configuration parameter, so you can specify '--ssldir ' as an +argument. + +See the configuration file documentation at +http://docs.puppetlabs.com/references/stable/configuration.html for the +full list of acceptable parameters. A commented list of all +configuration options can also be generated by running puppet with +'--genconfig'. + +* --debug: + Enable full debugging. + +* --edit: + Write the results of the query to a file, open the file in an editor, + and read the file back in as an executable Puppet manifest. + +* --host: + When specified, connect to the resource server on the named host + and retrieve the list of resouces of the type specified. + +* --help: + Print this help message. + +* --param: + Add more parameters to be outputted from queries. + +* --types: + List all available types. + +* --verbose: + Print extra information. + + +EXAMPLE +------- +This example uses `puppet resource` to return a Puppet configuration for +the user `luke`: + + $ puppet resource user luke + user { 'luke': + home => '/home/luke', + uid => '100', + ensure => 'present', + comment => 'Luke Kanies,,,', + gid => '1000', + shell => '/bin/bash', + groups => ['sysadmin','audio','video','puppet'] + } + + +AUTHOR +------ +Luke Kanies + + +COPYRIGHT +--------- +Copyright (c) 2005-2007 Puppet Labs, LLC Licensed under the GNU Public +License + + HELP + end + def main args = command_line.args type = args.shift or raise "You must specify the type to display" typeobj = Puppet::Type.type(type) or raise "Could not find type #{type}" name = args.shift params = {} args.each do |setting| if setting =~ /^(\w+)=(.+)$/ params[$1] = $2 else raise "Invalid parameter setting #{setting}" end end raise "You cannot edit a remote host" if options[:edit] and @host properties = typeobj.properties.collect { |s| s.name } format = proc {|trans| trans.dup.collect do |param, value| if value.nil? or value.to_s.empty? trans.delete(param) elsif value.to_s == "absent" and param.to_s != "ensure" trans.delete(param) end trans.delete(param) unless properties.include?(param) or @extra_params.include?(param) end trans.to_manifest } if @host Puppet::Resource.indirection.terminus_class = :rest port = Puppet[:puppetport] key = ["https://#{host}:#{port}", "production", "resources", type, name].join('/') else key = [type, name].join('/') end text = if name if params.empty? [ Puppet::Resource.indirection.find( key ) ] else [ Puppet::Resource.indirection.save(Puppet::Resource.new( type, name, :parameters => params ), key) ] end else Puppet::Resource.indirection.search( key, {} ) end.map(&format).join("\n") if options[:edit] file = "/tmp/x2puppet-#{Process.pid}.pp" begin File.open(file, "w") do |f| f.puts text end ENV["EDITOR"] ||= "vi" system(ENV["EDITOR"], file) system("puppet -v #{file}") ensure #if FileTest.exists? file # File.unlink(file) #end end else puts text end end def setup Puppet::Util::Log.newdestination(:console) # Now parse the config Puppet.parse_config if options[:debug] Puppet::Util::Log.level = :debug elsif options[:verbose] Puppet::Util::Log.level = :info end end end diff --git a/lib/puppet/configurer/downloader.rb b/lib/puppet/configurer/downloader.rb index 1b587ed4b..b3696201a 100644 --- a/lib/puppet/configurer/downloader.rb +++ b/lib/puppet/configurer/downloader.rb @@ -1,79 +1,80 @@ require 'puppet/configurer' require 'puppet/resource/catalog' class Puppet::Configurer::Downloader attr_reader :name, :path, :source, :ignore # Determine the timeout value to use. def self.timeout timeout = Puppet[:configtimeout] case timeout when String if timeout =~ /^\d+$/ timeout = Integer(timeout) else raise ArgumentError, "Configuration timeout must be an integer" end when Integer # nothing else raise ArgumentError, "Configuration timeout must be an integer" end timeout end # Evaluate our download, returning the list of changed values. def evaluate Puppet.info "Retrieving #{name}" files = [] begin Timeout.timeout(self.class.timeout) do catalog.apply do |trans| trans.changed?.find_all do |resource| yield resource if block_given? files << resource[:path] end end end rescue Puppet::Error, Timeout::Error => detail puts detail.backtrace if Puppet[:debug] Puppet.err "Could not retrieve #{name}: #{detail}" end files end def initialize(name, path, source, ignore = nil) @name, @path, @source, @ignore = name, path, source, ignore end def catalog catalog = Puppet::Resource::Catalog.new + catalog.host_config = false catalog.add_resource(file) catalog end def file args = default_arguments.merge(:path => path, :source => source) args[:ignore] = ignore.split if ignore Puppet::Type.type(:file).new(args) end private def default_arguments { :path => path, :recurse => true, :source => source, :tag => name, :owner => Process.uid, :group => Process.gid, :purge => true, :force => true, :backup => false, :noop => false } end end diff --git a/lib/puppet/configurer/plugin_handler.rb b/lib/puppet/configurer/plugin_handler.rb index cfc6b5a0b..ae088f26f 100644 --- a/lib/puppet/configurer/plugin_handler.rb +++ b/lib/puppet/configurer/plugin_handler.rb @@ -1,26 +1,33 @@ # Break out the code related to plugins. This module is # just included into the agent, but having it here makes it # easier to test. module Puppet::Configurer::PluginHandler def download_plugins? Puppet[:pluginsync] end # Retrieve facts from the central server. def download_plugins return nil unless download_plugins? - Puppet::Configurer::Downloader.new("plugin", Puppet[:plugindest], Puppet[:pluginsource], Puppet[:pluginsignore]).evaluate.each { |file| load_plugin(file) } + plugin_downloader = Puppet::Configurer::Downloader.new( + "plugin", + Puppet[:plugindest], + Puppet[:pluginsource], + Puppet[:pluginsignore] + ) + + plugin_downloader.evaluate.each { |file| load_plugin(file) } end def load_plugin(file) return unless FileTest.exist?(file) return if FileTest.directory?(file) begin Puppet.info "Loading downloaded plugin #{file}" load file rescue Exception => detail Puppet.err "Could not load downloaded file #{file}: #{detail}" end end end diff --git a/lib/puppet/daemon.rb b/lib/puppet/daemon.rb index c76d63a54..22630ffb8 100755 --- a/lib/puppet/daemon.rb +++ b/lib/puppet/daemon.rb @@ -1,130 +1,130 @@ require 'puppet' require 'puppet/util/pidlock' require 'puppet/external/event-loop' require 'puppet/application' # A module that handles operations common to all daemons. This is included # into the Server and Client base classes. class Puppet::Daemon attr_accessor :agent, :server, :argv def daemonname Puppet[:name] end # Put the daemon into the background. def daemonize if pid = fork Process.detach(pid) exit(0) end create_pidfile # Get rid of console logging Puppet::Util::Log.close(:console) Process.setsid Dir.chdir("/") begin $stdin.reopen "/dev/null" $stdout.reopen "/dev/null", "a" $stderr.reopen $stdout Puppet::Util::Log.reopen rescue => detail Puppet.err "Could not start #{Puppet[:name]}: #{detail}" Puppet::Util::secure_open("/tmp/daemonout", "w") { |f| f.puts "Could not start #{Puppet[:name]}: #{detail}" } exit(12) end end # Create a pidfile for our daemon, so we can be stopped and others # don't try to start. def create_pidfile Puppet::Util.synchronize_on(Puppet[:name],Sync::EX) do raise "Could not create PID file: #{pidfile}" unless Puppet::Util::Pidlock.new(pidfile).lock end end # Provide the path to our pidfile. def pidfile Puppet[:pidfile] end def reexec raise Puppet::DevError, "Cannot reexec unless ARGV arguments are set" unless argv command = $0 + " " + argv.join(" ") Puppet.notice "Restarting with '#{command}'" stop(:exit => false) exec(command) end def reload return unless agent if agent.running? Puppet.notice "Not triggering already-running agent" return end agent.run end # Remove the pid file for our daemon. def remove_pidfile Puppet::Util.synchronize_on(Puppet[:name],Sync::EX) do locker = Puppet::Util::Pidlock.new(pidfile) locker.unlock or Puppet.err "Could not remove PID file #{pidfile}" if locker.locked? end end def restart Puppet::Application.restart! reexec unless agent and agent.running? end def reopen_logs Puppet::Util::Log.reopen end # Trap a couple of the main signals. This should probably be handled # in a way that anyone else can register callbacks for traps, but, eh. def set_signal_traps signals = {:INT => :stop, :TERM => :stop } # extended signals not supported under windows signals.update({:HUP => :restart, :USR1 => :reload, :USR2 => :reopen_logs }) unless Puppet.features.microsoft_windows? signals.each do |signal, method| - trap(signal) do + Signal.trap(signal) do Puppet.notice "Caught #{signal}; calling #{method}" send(method) end end end # Stop everything def stop(args = {:exit => true}) Puppet::Application.stop! server.stop if server remove_pidfile Puppet::Util::Log.close_all exit if args[:exit] end def start set_signal_traps create_pidfile raise Puppet::DevError, "Daemons must have an agent, server, or both" unless agent or server server.start if server agent.start if agent EventLoop.current.run end end diff --git a/lib/puppet/defaults.rb b/lib/puppet/defaults.rb index e3b86bca4..f308d4476 100644 --- a/lib/puppet/defaults.rb +++ b/lib/puppet/defaults.rb @@ -1,821 +1,829 @@ # The majority of the system configuration parameters are set in this file. module Puppet setdefaults(:main, :confdir => [Puppet.run_mode.conf_dir, "The main Puppet configuration directory. The default for this parameter is calculated based on the user. If the process is running as root or the user that Puppet is supposed to run as, it defaults to a system directory, but if it's running as any other user, it defaults to being in the user's home directory."], :vardir => [Puppet.run_mode.var_dir, "Where Puppet stores dynamic and growing data. The default for this parameter is calculated specially, like `confdir`_."], :name => [Puppet.application_name.to_s, "The name of the application, if we are running as one. The default is essentially $0 without the path or `.rb`."], :run_mode => [Puppet.run_mode.name.to_s, "The effective 'run mode' of the application: master, agent, or user."] ) setdefaults(:main, :logdir => Puppet.run_mode.logopts) setdefaults(:main, :trace => [false, "Whether to print stack traces on some errors"], - :autoflush => [false, "Whether log files should always flush to disk."], + :autoflush => { + :default => false, + :desc => "Whether log files should always flush to disk.", + :hook => proc { |value| Log.autoflush = value } + }, :syslogfacility => ["daemon", "What syslog facility to use when logging to syslog. Syslog has a fixed list of valid facilities, and you must choose one of those; you cannot just make one up."], :statedir => { :default => "$vardir/state", :mode => 01755, :desc => "The directory where Puppet state is stored. Generally, this directory can be removed without causing harm (although it might result in spurious service restarts)." }, :rundir => { :default => Puppet.run_mode.run_dir, :mode => 01777, :desc => "Where Puppet PID files are kept." }, :genconfig => [false, "Whether to just print a configuration to stdout and exit. Only makes sense when used interactively. Takes into account arguments specified on the CLI."], :genmanifest => [false, "Whether to just print a manifest to stdout and exit. Only makes sense when used interactively. Takes into account arguments specified on the CLI."], :configprint => ["", "Print the value of a specific configuration parameter. If a parameter is provided for this, then the value is printed and puppet exits. Comma-separate multiple values. For a list of all values, specify 'all'. This feature is only available in Puppet versions higher than 0.18.4."], :color => ["ansi", "Whether to use colors when logging to the console. Valid values are `ansi` (equivalent to `true`), `html` (mostly used during testing with TextMate), and `false`, which produces no color."], :mkusers => [false, "Whether to create the necessary user and group that puppet agent will run as."], :manage_internal_file_permissions => [true, "Whether Puppet should manage the owner, group, and mode of files it uses internally" ], :onetime => {:default => false, :desc => "Run the configuration once, rather than as a long-running daemon. This is useful for interactively running puppetd.", :short => 'o' }, :path => {:default => "none", :desc => "The shell search path. Defaults to whatever is inherited from the parent process.", :call_on_define => true, # Call our hook with the default value, so we always get the libdir set. :hook => proc do |value| ENV["PATH"] = "" if ENV["PATH"].nil? ENV["PATH"] = value unless value == "none" paths = ENV["PATH"].split(File::PATH_SEPARATOR) %w{/usr/sbin /sbin}.each do |path| ENV["PATH"] += File::PATH_SEPARATOR + path unless paths.include?(path) end value end }, :libdir => {:default => "$vardir/lib", :desc => "An extra search path for Puppet. This is only useful for those files that Puppet will load on demand, and is only guaranteed to work for those cases. In fact, the autoload mechanism is responsible for making sure this directory is in Ruby's search path", :call_on_define => true, # Call our hook with the default value, so we always get the libdir set. :hook => proc do |value| $LOAD_PATH.delete(@oldlibdir) if defined?(@oldlibdir) and $LOAD_PATH.include?(@oldlibdir) @oldlibdir = value $LOAD_PATH << value end }, :ignoreimport => [false, "A parameter that can be used in commit hooks, since it enables you to parse-check a single file rather than requiring that all files exist."], :authconfig => [ "$confdir/namespaceauth.conf", "The configuration file that defines the rights to the different namespaces and methods. This can be used as a coarse-grained authorization system for both `puppet agent` and `puppet master`." ], :environment => {:default => "production", :desc => "The environment Puppet is running in. For clients (e.g., `puppet agent`) this determines the environment itself, which is used to find modules and much more. For servers (i.e., `puppet master`) this provides the default environment for nodes we know nothing about." }, :diff_args => ["-u", "Which arguments to pass to the diff command when printing differences between files."], :diff => ["diff", "Which diff command to use when printing differences between files."], :show_diff => [false, "Whether to print a contextual diff when files are being replaced. The diff is printed on stdout, so this option is meaningless unless you are running Puppet interactively. This feature currently requires the `diff/lcs` Ruby library."], :daemonize => { :default => true, :desc => "Send the process into the background. This is the default.", :short => "D" }, :maximum_uid => [4294967290, "The maximum allowed UID. Some platforms use negative UIDs but then ship with tools that do not know how to handle signed ints, so the UIDs show up as huge numbers that can then not be fed back into the system. This is a hackish way to fail in a slightly more useful way when that happens."], :node_terminus => ["plain", "Where to find information about nodes."], :catalog_terminus => ["compiler", "Where to get node catalogs. This is useful to change if, for instance, you'd like to pre-compile catalogs and store them in memcached or some other easily-accessed store."], :facts_terminus => { :default => Puppet.application_name.to_s == "master" ? 'yaml' : 'facter', :desc => "The node facts terminus.", :hook => proc do |value| require 'puppet/node/facts' if value.to_s == "rest" Puppet::Node::Facts.indirection.cache_class = :yaml end end }, :inventory_terminus => [ "$facts_terminus", "Should usually be the same as the facts terminus" ], :httplog => { :default => "$logdir/http.log", :owner => "root", :mode => 0640, :desc => "Where the puppet agent web server logs." }, :http_proxy_host => ["none", "The HTTP proxy host to use for outgoing connections. Note: You may need to use a FQDN for the server hostname when using a proxy."], :http_proxy_port => [3128, "The HTTP proxy port to use for outgoing connections"], :filetimeout => [ 15, "The minimum time to wait (in seconds) between checking for updates in configuration files. This timeout determines how quickly Puppet checks whether a file (such as manifests or templates) has changed on disk." ], :queue_type => ["stomp", "Which type of queue to use for asynchronous processing."], :queue_type => ["stomp", "Which type of queue to use for asynchronous processing."], :queue_source => ["stomp://localhost:61613/", "Which type of queue to use for asynchronous processing. If your stomp server requires authentication, you can include it in the URI as long as your stomp client library is at least 1.1.1"], :async_storeconfigs => {:default => false, :desc => "Whether to use a queueing system to provide asynchronous database integration. Requires that `puppetqd` be running and that 'PSON' support for ruby be installed.", :hook => proc do |value| if value # This reconfigures the terminii for Node, Facts, and Catalog Puppet.settings[:storeconfigs] = true # But then we modify the configuration Puppet::Resource::Catalog.indirection.cache_class = :queue else raise "Cannot disable asynchronous storeconfigs in a running process" end end }, :thin_storeconfigs => {:default => false, :desc => "Boolean; wether storeconfigs store in the database only the facts and exported resources. If true, then storeconfigs performance will be higher and still allow exported/collected resources, but other usage external to Puppet might not work", :hook => proc do |value| Puppet.settings[:storeconfigs] = true if value end }, :config_version => ["", "How to determine the configuration version. By default, it will be the time that the configuration is parsed, but you can provide a shell script to override how the version is determined. The output of this script will be added to every log message in the reports, allowing you to correlate changes on your hosts to the source version on the server."], :zlib => [true, "Boolean; whether to use the zlib library", ], :prerun_command => ["", "A command to run before every agent run. If this command returns a non-zero return code, the entire Puppet run will fail."], :postrun_command => ["", "A command to run after every agent run. If this command returns a non-zero return code, the entire Puppet run will be considered to have failed, even though it might have performed work during the normal run."], :freeze_main => [false, "Freezes the 'main' class, disallowing any code to be added to it. This essentially means that you can't have any code outside of a node, class, or definition other than in the site manifest."] ) hostname = Facter["hostname"].value domain = Facter["domain"].value if domain and domain != "" fqdn = [hostname, domain].join(".") else fqdn = hostname end Puppet.setdefaults( :main, # We have to downcase the fqdn, because the current ssl stuff (as oppsed to in master) doesn't have good facilities for # manipulating naming. :certname => {:default => fqdn.downcase, :desc => "The name to use when handling certificates. Defaults to the fully qualified domain name.", :call_on_define => true, # Call our hook with the default value, so we're always downcased :hook => proc { |value| raise(ArgumentError, "Certificate names must be lower case; see #1168") unless value == value.downcase }}, :certdnsnames => ['', "The DNS names on the Server certificate as a colon-separated list. If it's anything other than an empty string, it will be used as an alias in the created certificate. By default, only the server gets an alias set up, and only for 'puppet'."], :certdir => { :default => "$ssldir/certs", :owner => "service", :desc => "The certificate directory." }, :ssldir => { :default => "$confdir/ssl", :mode => 0771, :owner => "service", :desc => "Where SSL certificates are kept." }, :publickeydir => { :default => "$ssldir/public_keys", :owner => "service", :desc => "The public key directory." }, :requestdir => { :default => "$ssldir/certificate_requests", :owner => "service", :desc => "Where host certificate requests are stored." }, :privatekeydir => { :default => "$ssldir/private_keys", :mode => 0750, :owner => "service", :desc => "The private key directory." }, :privatedir => { :default => "$ssldir/private", :mode => 0750, :owner => "service", :desc => "Where the client stores private certificate information." }, :passfile => { :default => "$privatedir/password", :mode => 0640, :owner => "service", :desc => "Where puppet agent stores the password for its private key. Generally unused." }, :hostcsr => { :default => "$ssldir/csr_$certname.pem", :mode => 0644, :owner => "service", :desc => "Where individual hosts store and look for their certificate requests." }, :hostcert => { :default => "$certdir/$certname.pem", :mode => 0644, :owner => "service", :desc => "Where individual hosts store and look for their certificates." }, :hostprivkey => { :default => "$privatekeydir/$certname.pem", :mode => 0600, :owner => "service", :desc => "Where individual hosts store and look for their private key." }, :hostpubkey => { :default => "$publickeydir/$certname.pem", :mode => 0644, :owner => "service", :desc => "Where individual hosts store and look for their public key." }, :localcacert => { :default => "$certdir/ca.pem", :mode => 0644, :owner => "service", :desc => "Where each client stores the CA certificate." }, :hostcrl => { :default => "$ssldir/crl.pem", :mode => 0644, :owner => "service", :desc => "Where the host's certificate revocation list can be found. This is distinct from the certificate authority's CRL." }, :certificate_revocation => [true, "Whether certificate revocation should be supported by downloading a Certificate Revocation List (CRL) to all clients. If enabled, CA chaining will almost definitely not work."] ) setdefaults( :ca, :ca_name => ["Puppet CA: $certname", "The name to use the Certificate Authority certificate."], :cadir => { :default => "$ssldir/ca", :owner => "service", :group => "service", :mode => 0770, :desc => "The root directory for the certificate authority." }, :cacert => { :default => "$cadir/ca_crt.pem", :owner => "service", :group => "service", :mode => 0660, :desc => "The CA certificate." }, :cakey => { :default => "$cadir/ca_key.pem", :owner => "service", :group => "service", :mode => 0660, :desc => "The CA private key." }, :capub => { :default => "$cadir/ca_pub.pem", :owner => "service", :group => "service", :desc => "The CA public key." }, :cacrl => { :default => "$cadir/ca_crl.pem", :owner => "service", :group => "service", :mode => 0664, :desc => "The certificate revocation list (CRL) for the CA. Will be used if present but otherwise ignored.", :hook => proc do |value| if value == 'false' Puppet.warning "Setting the :cacrl to 'false' is deprecated; Puppet will just ignore the crl if yours is missing" end end }, :caprivatedir => { :default => "$cadir/private", :owner => "service", :group => "service", :mode => 0770, :desc => "Where the CA stores private certificate information." }, :csrdir => { :default => "$cadir/requests", :owner => "service", :group => "service", :desc => "Where the CA stores certificate requests" }, :signeddir => { :default => "$cadir/signed", :owner => "service", :group => "service", :mode => 0770, :desc => "Where the CA stores signed certificates." }, :capass => { :default => "$caprivatedir/ca.pass", :owner => "service", :group => "service", :mode => 0660, :desc => "Where the CA stores the password for the private key" }, :serial => { :default => "$cadir/serial", :owner => "service", :group => "service", :mode => 0644, :desc => "Where the serial number for certificates is stored." }, :autosign => { :default => "$confdir/autosign.conf", :mode => 0644, :desc => "Whether to enable autosign. Valid values are true (which autosigns any key request, and is a very bad idea), false (which never autosigns any key request), and the path to a file, which uses that configuration file to determine which keys to sign."}, :ca_days => ["", "How long a certificate should be valid. This parameter is deprecated, use ca_ttl instead"], :ca_ttl => ["5y", "The default TTL for new certificates; valid values must be an integer, optionally followed by one of the units 'y' (years of 365 days), 'd' (days), 'h' (hours), or 's' (seconds). The unit defaults to seconds. If this parameter is set, ca_days is ignored. Examples are '3600' (one hour) and '1825d', which is the same as '5y' (5 years) "], :ca_md => ["md5", "The type of hash used in certificates."], :req_bits => [2048, "The bit length of the certificates."], :keylength => [1024, "The bit length of keys."], :cert_inventory => { :default => "$cadir/inventory.txt", :mode => 0644, :owner => "service", :group => "service", :desc => "A Complete listing of all certificates" } ) # Define the config default. setdefaults( Puppet.settings[:name], :config => ["$confdir/puppet.conf", "The configuration file for #{Puppet[:name]}."], :pidfile => ["$rundir/$name.pid", "The pid file"], :bindaddress => ["", "The address a listening server should bind to. Mongrel servers default to 127.0.0.1 and WEBrick defaults to 0.0.0.0."], :servertype => {:default => "webrick", :desc => "The type of server to use. Currently supported options are webrick and mongrel. If you use mongrel, you will need a proxy in front of the process or processes, since Mongrel cannot speak SSL.", :call_on_define => true, # Call our hook with the default value, so we always get the correct bind address set. :hook => proc { |value| value == "webrick" ? Puppet.settings[:bindaddress] = "0.0.0.0" : Puppet.settings[:bindaddress] = "127.0.0.1" if Puppet.settings[:bindaddress] == "" } } ) setdefaults(:master, :user => ["puppet", "The user puppet master should run as."], :group => ["puppet", "The group puppet master should run as."], :manifestdir => ["$confdir/manifests", "Where puppet master looks for its manifests."], :manifest => ["$manifestdir/site.pp", "The entry-point manifest for puppet master."], :code => ["", "Code to parse directly. This is essentially only used by `puppet`, and should only be set if you're writing your own Puppet executable"], :masterlog => { :default => "$logdir/puppetmaster.log", :owner => "service", :group => "service", :mode => 0660, :desc => "Where puppet master logs. This is generally not used, since syslog is the default log destination." }, :masterhttplog => { :default => "$logdir/masterhttp.log", :owner => "service", :group => "service", :mode => 0660, :create => true, :desc => "Where the puppet master web server logs." }, :masterport => [8140, "Which port puppet master listens on."], :parseonly => [false, "Just check the syntax of the manifests."], :node_name => ["cert", "How the puppetmaster determines the client's identity and sets the 'hostname', 'fqdn' and 'domain' facts for use in the manifest, in particular for determining which 'node' statement applies to the client. Possible values are 'cert' (use the subject's CN in the client's certificate) and 'facter' (use the hostname that the client reported in its facts)"], :bucketdir => { :default => "$vardir/bucket", :mode => 0750, :owner => "service", :group => "service", :desc => "Where FileBucket files are stored." }, :rest_authconfig => [ "$confdir/auth.conf", "The configuration file that defines the rights to the different rest indirections. This can be used as a fine-grained authorization system for `puppet master`." ], :ca => [true, "Wether the master should function as a certificate authority."], :modulepath => {:default => "$confdir/modules:/usr/share/puppet/modules", :desc => "The search path for modules as a colon-separated list of directories.", :type => :setting }, # We don't want this to be considered a file, since it's multiple files. :ssl_client_header => ["HTTP_X_CLIENT_DN", "The header containing an authenticated client's SSL DN. Only used with Mongrel. This header must be set by the proxy to the authenticated client's SSL DN (e.g., `/CN=puppet.puppetlabs.com`). See http://projects.puppetlabs.com/projects/puppet/wiki/Using_Mongrel for more information."], :ssl_client_verify_header => ["HTTP_X_CLIENT_VERIFY", "The header containing the status message of the client verification. Only used with Mongrel. This header must be set by the proxy to 'SUCCESS' if the client successfully authenticated, and anything else otherwise. See http://projects.puppetlabs.com/projects/puppet/wiki/Using_Mongrel for more information."], # To make sure this directory is created before we try to use it on the server, we need # it to be in the server section (#1138). :yamldir => {:default => "$vardir/yaml", :owner => "service", :group => "service", :mode => "750", :desc => "The directory in which YAML data is stored, usually in a subdirectory."}, :server_datadir => {:default => "$vardir/server_data", :owner => "service", :group => "service", :mode => "750", :desc => "The directory in which serialized data is stored, usually in a subdirectory."}, :reports => ["store", "The list of reports to generate. All reports are looked for in `puppet/reports/name.rb`, and multiple report names should be comma-separated (whitespace is okay)." ], :reportdir => {:default => "$vardir/reports", :mode => 0750, :owner => "service", :group => "service", :desc => "The directory in which to store reports received from the client. Each client gets a separate subdirectory."}, :reporturl => ["http://localhost:3000/reports", "The URL used by the http reports processor to send reports"], :fileserverconfig => ["$confdir/fileserver.conf", "Where the fileserver configuration is stored."], :strict_hostname_checking => [false, "Whether to only search for the complete hostname as it is in the certificate when searching for node information in the catalogs."] ) setdefaults(:metrics, :rrddir => {:default => "$vardir/rrd", :owner => "service", :group => "service", :desc => "The directory where RRD database files are stored. Directories for each reporting host will be created under this directory." }, :rrdinterval => ["$runinterval", "How often RRD should expect data. This should match how often the hosts report back to the server."] ) setdefaults(:agent, :localconfig => { :default => "$statedir/localconfig", :owner => "root", :mode => 0660, :desc => "Where puppet agent caches the local configuration. An extension indicating the cache format is added automatically."}, :statefile => { :default => "$statedir/state.yaml", :mode => 0660, :desc => "Where puppet agent and puppet master store state associated with the running configuration. In the case of puppet master, this file reflects the state discovered through interacting with clients." }, :clientyamldir => {:default => "$vardir/client_yaml", :mode => "750", :desc => "The directory in which client-side YAML data is stored."}, :client_datadir => {:default => "$vardir/client_data", :mode => "750", :desc => "The directory in which serialized data is stored on the client."}, :classfile => { :default => "$statedir/classes.txt", :owner => "root", :mode => 0644, :desc => "The file in which puppet agent stores a list of the classes associated with the retrieved configuration. Can be loaded in the separate `puppet` executable using the `--loadclasses` option."}, :puppetdlog => { :default => "$logdir/puppetd.log", :owner => "root", :mode => 0640, :desc => "The log file for puppet agent. This is generally not used." }, :server => ["puppet", "The server to which server puppet agent should connect"], :ignoreschedules => [false, "Boolean; whether puppet agent should ignore schedules. This is useful for initial puppet agent runs."], :puppetport => [8139, "Which port puppet agent listens on."], :noop => [false, "Whether puppet agent should be run in noop mode."], :runinterval => [1800, # 30 minutes "How often puppet agent applies the client configuration; in seconds."], :listen => [false, "Whether puppet agent should listen for connections. If this is true, then by default only the `runner` server is started, which allows remote authorized and authenticated nodes to connect and trigger `puppet agent` runs."], :ca_server => ["$server", "The server to use for certificate authority requests. It's a separate server because it cannot and does not need to horizontally scale."], :ca_port => ["$masterport", "The port to use for the certificate authority."], :catalog_format => { :default => "", :desc => "(Deprecated for 'preferred_serialization_format') What format to use to dump the catalog. Only supports 'marshal' and 'yaml'. Only matters on the client, since it asks the server for a specific format.", :hook => proc { |value| if value Puppet.warning "Setting 'catalog_format' is deprecated; use 'preferred_serialization_format' instead." Puppet.settings[:preferred_serialization_format] = value end } }, :preferred_serialization_format => ["pson", "The preferred means of serializing ruby instances for passing over the wire. This won't guarantee that all instances will be serialized using this method, since not all classes can be guaranteed to support this format, but it will be used for all classes that support it."], :puppetdlockfile => [ "$statedir/puppetdlock", "A lock file to temporarily stop puppet agent from doing anything."], :usecacheonfailure => [true, "Whether to use the cached configuration when the remote configuration will not compile. This option is useful for testing new configurations, where you want to fix the broken configuration rather than reverting to a known-good one." ], :use_cached_catalog => [false, "Whether to only use the cached catalog rather than compiling a new catalog on every run. Puppet can be run with this enabled by default and then selectively disabled when a recompile is desired."], :ignorecache => [false, "Ignore cache and always recompile the configuration. This is useful for testing new configurations, where the local cache may in fact be stale even if the timestamps are up to date - if the facts change or if the server changes." ], :downcasefacts => [false, "Whether facts should be made all lowercase when sent to the server."], :dynamicfacts => ["memorysize,memoryfree,swapsize,swapfree", "Facts that are dynamic; these facts will be ignored when deciding whether changed facts should result in a recompile. Multiple facts should be comma-separated."], :splaylimit => ["$runinterval", "The maximum time to delay before runs. Defaults to being the same as the run interval."], :splay => [false, "Whether to sleep for a pseudo-random (but consistent) amount of time before a run."], :clientbucketdir => { :default => "$vardir/clientbucket", :mode => 0750, :desc => "Where FileBucket files are stored locally." }, :configtimeout => [120, "How long the client should wait for the configuration to be retrieved before considering it a failure. This can help reduce flapping if too many clients contact the server at one time." ], :reportserver => { :default => "$server", :call_on_define => false, :desc => "(Deprecated for 'report_server') The server to which to send transaction reports.", :hook => proc do |value| Puppet.settings[:report_server] = value if value end }, :report_server => ["$server", "The server to send transaction reports to." ], :report_port => ["$masterport", "The port to communicate with the report_server." ], :inventory_server => ["$server", "The server to send facts to." ], :inventory_port => ["$masterport", "The port to communicate with the inventory_server." ], :report => [true, "Whether to send reports after every transaction." ], :lastrunfile => { :default => "$statedir/last_run_summary.yaml", :mode => 0660, :desc => "Where puppet agent stores the last run report summary in yaml format." }, :lastrunreport => { :default => "$statedir/last_run_report.yaml", :mode => 0660, :desc => "Where puppet agent stores the last run report in yaml format." }, :graph => [false, "Whether to create dot graph files for the different configuration graphs. These dot files can be interpreted by tools like OmniGraffle or dot (which is part of ImageMagick)."], :graphdir => ["$statedir/graphs", "Where to store dot-outputted graphs."], :http_compression => [false, "Allow http compression in REST communication with the master. This setting might improve performance for agent -> master communications over slow WANs. Your puppetmaster needs to support compression (usually by activating some settings in a reverse-proxy in front of the puppetmaster, which rules out webrick). It is harmless to activate this settings if your master doesn't support compression, but if it supports it, this setting might reduce performance on high-speed LANs."] ) setdefaults(:inspect, :archive_files => [false, "During an inspect run, whether to archive files whose contents are audited to a file bucket."], :archive_file_server => ["$server", "During an inspect run, the file bucket server to archive files to if archive_files is set."] ) # Plugin information. setdefaults( :main, :plugindest => ["$libdir", "Where Puppet should store plugins that it pulls down from the central server."], :pluginsource => ["puppet://$server/plugins", "From where to retrieve plugins. The standard Puppet `file` type is used for retrieval, so anything that is a valid file source can be used here."], :pluginsync => [false, "Whether plugins should be synced with the central server."], :pluginsignore => [".svn CVS .git", "What files to ignore when pulling down plugins."] ) # Central fact information. setdefaults( :main, :factpath => {:default => "$vardir/lib/facter:$vardir/facts", :desc => "Where Puppet should look for facts. Multiple directories should be colon-separated, like normal PATH variables.", :call_on_define => true, # Call our hook with the default value, so we always get the value added to facter. :type => :setting, # Don't consider it a file, because it could be multiple colon-separated files :hook => proc { |value| Facter.search(value) if Facter.respond_to?(:search) }}, :factdest => ["$vardir/facts/", "Where Puppet should store facts that it pulls down from the central server."], :factsource => ["puppet://$server/facts/", "From where to retrieve facts. The standard Puppet `file` type is used for retrieval, so anything that is a valid file source can be used here."], :factsync => [false, "Whether facts should be synced with the central server."], :factsignore => [".svn CVS", "What files to ignore when pulling down facts."] ) setdefaults( :tagmail, :tagmap => ["$confdir/tagmail.conf", "The mapping between reporting tags and email addresses."], :sendmail => [which('sendmail') || '', "Where to find the sendmail binary with which to send email."], :reportfrom => ["report@" + [Facter["hostname"].value, Facter["domain"].value].join("."), "The 'from' email address for the reports."], :smtpserver => ["none", "The server through which to send email reports."] ) setdefaults( :rails, :dblocation => { :default => "$statedir/clientconfigs.sqlite3", :mode => 0660, :owner => "service", :group => "service", :desc => "The database cache for client configurations. Used for querying within the language." }, :dbadapter => [ "sqlite3", "The type of database to use." ], :dbmigrate => [ false, "Whether to automatically migrate the database." ], :dbname => [ "puppet", "The name of the database to use." ], :dbserver => [ "localhost", "The database server for caching. Only used when networked databases are used."], :dbport => [ "", "The database password for caching. Only used when networked databases are used."], :dbuser => [ "puppet", "The database user for caching. Only used when networked databases are used."], :dbpassword => [ "puppet", "The database password for caching. Only used when networked databases are used."], :dbconnections => [ '', "The number of database connections for networked databases. Will be ignored unless the value is a positive integer."], :dbsocket => [ "", "The database socket location. Only used when networked databases are used. Will be ignored if the value is an empty string."], :railslog => {:default => "$logdir/rails.log", :mode => 0600, :owner => "service", :group => "service", :desc => "Where Rails-specific logs are sent" }, :rails_loglevel => ["info", "The log level for Rails connections. The value must be a valid log level within Rails. Production environments normally use `info` and other environments normally use `debug`."] ) setdefaults( :couchdb, :couchdb_url => ["http://127.0.0.1:5984/puppet", "The url where the puppet couchdb database will be created"] ) setdefaults( :transaction, :tags => ["", "Tags to use to find resources. If this is set, then only resources tagged with the specified tags will be applied. Values must be comma-separated."], :evaltrace => [false, "Whether each resource should log when it is being evaluated. This allows you to interactively see exactly what is being done."], :summarize => [false, "Whether to print a transaction summary." ] ) setdefaults( :main, :external_nodes => ["none", "An external command that can produce node information. The output must be a YAML dump of a hash, and that hash must have one or both of `classes` and `parameters`, where `classes` is an array and `parameters` is a hash. For unknown nodes, the commands should exit with a non-zero exit code. This command makes it straightforward to store your node mapping information in other data sources like databases."]) setdefaults( :ldap, :ldapnodes => [false, "Whether to search for node configurations in LDAP. See http://projects.puppetlabs.com/projects/puppet/wiki/LDAP_Nodes for more information."], :ldapssl => [false, "Whether SSL should be used when searching for nodes. Defaults to false because SSL usually requires certificates to be set up on the client side."], :ldaptls => [false, "Whether TLS should be used when searching for nodes. Defaults to false because TLS usually requires certificates to be set up on the client side."], :ldapserver => ["ldap", "The LDAP server. Only used if `ldapnodes` is enabled."], :ldapport => [389, "The LDAP port. Only used if `ldapnodes` is enabled."], :ldapstring => ["(&(objectclass=puppetClient)(cn=%s))", "The search string used to find an LDAP node."], :ldapclassattrs => ["puppetclass", "The LDAP attributes to use to define Puppet classes. Values should be comma-separated."], :ldapstackedattrs => ["puppetvar", "The LDAP attributes that should be stacked to arrays by adding the values in all hierarchy elements of the tree. Values should be comma-separated."], :ldapattrs => ["all", "The LDAP attributes to include when querying LDAP for nodes. All returned attributes are set as variables in the top-level scope. Multiple values should be comma-separated. The value 'all' returns all attributes."], :ldapparentattr => ["parentnode", "The attribute to use to define the parent node."], :ldapuser => ["", "The user to use to connect to LDAP. Must be specified as a full DN."], :ldappassword => ["", "The password to use to connect to LDAP."], :ldapbase => ["", "The search base for LDAP searches. It's impossible to provide a meaningful default here, although the LDAP libraries might have one already set. Generally, it should be the 'ou=Hosts' branch under your main directory."] ) setdefaults(:master, :storeconfigs => {:default => false, :desc => "Whether to store each client's configuration. This requires ActiveRecord from Ruby on Rails.", :call_on_define => true, # Call our hook with the default value, so we always get the libdir set. :hook => proc do |value| require 'puppet/node' require 'puppet/node/facts' if value require 'puppet/rails' raise "StoreConfigs not supported without ActiveRecord 2.1 or higher" unless Puppet.features.rails? Puppet::Resource::Catalog.indirection.cache_class = :active_record unless Puppet.settings[:async_storeconfigs] Puppet::Node::Facts.indirection.cache_class = :active_record Puppet::Node.indirection.cache_class = :active_record end end } ) # This doesn't actually work right now. setdefaults( :parser, :lexical => [false, "Whether to use lexical scoping (vs. dynamic)."], :templatedir => ["$vardir/templates", "Where Puppet looks for template files. Can be a list of colon-seperated directories." ] ) + setdefaults( + :puppetdoc, + :document_all => [false, "Document all resources"] + ) end diff --git a/lib/puppet/external/nagios.rb b/lib/puppet/external/nagios.rb index 6b8852ee5..2ed829198 100755 --- a/lib/puppet/external/nagios.rb +++ b/lib/puppet/external/nagios.rb @@ -1,50 +1,48 @@ #!/usr/bin/env ruby -w #-------------------- # A script to retrieve hosts from ldap and create an importable # cfservd file from them -# -# $Id: nagios.rb,v 1.3 2004/06/09 20:32:46 luke Exp $ require 'digest/md5' #require 'ldap' require 'puppet/external/nagios/parser.rb' require 'puppet/external/nagios/base.rb' module Nagios NAGIOSVERSION = '1.1' # yay colors PINK = "" GREEN = "" YELLOW = "" SLATE = "" ORANGE = "" BLUE = "" NOCOLOR = "" RESET = "" def self.version NAGIOSVERSION end class Config def Config.import(config) text = String.new File.open(config) { |file| file.each { |line| text += line } } parser = Nagios::Parser.new parser.parse(text) end def Config.each Nagios::Object.objects.each { |object| yield object } end end end diff --git a/lib/puppet/external/nagios/base.rb b/lib/puppet/external/nagios/base.rb index ac1d25e2e..e98760e01 100755 --- a/lib/puppet/external/nagios/base.rb +++ b/lib/puppet/external/nagios/base.rb @@ -1,474 +1,472 @@ # The base class for all of our Nagios object types. Everything else # is mostly just data. class Nagios::Base class UnknownNagiosType < RuntimeError # When an unknown type is asked for by name. end include Enumerable class << self attr_accessor :parameters, :derivatives, :ocs, :name, :att attr_accessor :ldapbase attr_writer :namevar attr_reader :superior end # Attach one class to another. def self.attach(hash) @attach ||= {} hash.each do |n, v| @attach[n] = v end end # Convert a parameter to camelcase def self.camelcase(param) param.gsub(/_./) do |match| match.sub(/_/,'').capitalize end end # Uncamelcase a parameter. def self.decamelcase(param) param.gsub(/[A-Z]/) do |match| "_#{match.downcase}" end end # Create a new instance of a given class. def self.create(name, args = {}) name = name.intern if name.is_a? String if @types.include?(name) @types[name].new(args) else raise UnknownNagiosType, "Unknown type #{name}" end end # Yield each type in turn. def self.eachtype @types.each do |name, type| yield [name, type] end end # Create a mapping. def self.map(hash) @map ||= {} hash.each do |n, v| @map[n] = v end end # Return a mapping (or nil) for a param def self.mapping(name) name = name.intern if name.is_a? String if defined?(@map) @map[name] else nil end end # Return the namevar for the canonical name. def self.namevar if defined?(@namevar) return @namevar else if parameter?(:name) return :name elsif tmp = (self.name.to_s + "_name").intern and parameter?(tmp) @namevar = tmp return @namevar else raise "Type #{self.name} has no name var" end end end # Create a new type. def self.newtype(name, &block) name = name.intern if name.is_a? String @types ||= {} # Create the class, with the correct name. t = Class.new(self) t.name = name # Everyone gets this. There should probably be a better way, and I # should probably hack the attribute system to look things up based on # this "use" setting, but, eh. t.parameters = [:use] const_set(name.to_s.capitalize,t) # Evaluate the passed block. This should usually define all of the work. t.class_eval(&block) @types[name] = t end # Define both the normal case and camelcase method for a parameter def self.paramattr(name) camel = camelcase(name) param = name [name, camel].each do |method| define_method(method) do @parameters[param] end define_method(method.to_s + "=") do |value| @parameters[param] = value end end end # Is the specified name a valid parameter? def self.parameter?(name) name = name.intern if name.is_a? String @parameters.include?(name) end # Manually set the namevar def self.setnamevar(name) name = name.intern if name.is_a? String @namevar = name end # Set the valid parameters for this class def self.setparameters(*array) @parameters += array end # Set the superior ldap object class. Seems silly to include this # in this class, but, eh. def self.setsuperior(name) @superior = name end # Parameters to suppress in output. def self.suppress(name) @suppress ||= [] @suppress << name end # Whether a given parameter is suppressed. def self.suppress?(name) defined?(@suppress) and @suppress.include?(name) end # Return our name as the string. def self.to_s self.name.to_s end # Return a type by name. def self.type(name) name = name.intern if name.is_a? String @types[name] end # Convenience methods. def [](param) send(param) end # Convenience methods. def []=(param,value) send(param.to_s + "=", value) end # Iterate across all ofour set parameters. def each @parameters.each { |param,value| yield(param,value) } end # Initialize our object, optionally with a list of parameters. def initialize(args = {}) @parameters = {} args.each { |param,value| self[param] = value } if @namevar == :_naginator_name self['_naginator_name'] = self['name'] end end # Handle parameters like attributes. def method_missing(mname, *args) pname = mname.to_s pname.sub!(/=/, '') if self.class.parameter?(pname) if pname =~ /A-Z/ pname = self.class.decamelcase(pname) end self.class.paramattr(pname) # Now access the parameters directly, to make it at least less # likely we'll end up in an infinite recursion. if mname.to_s =~ /=$/ @parameters[pname] = *args else return @parameters[mname] end else super end end # Retrieve our name, through a bit of redirection. def name send(self.class.namevar) end # This is probably a bad idea. def name=(value) unless self.class.namevar.to_s == "name" send(self.class.namevar.to_s + "=", value) end end def namevar (self.type + "_name").intern end def parammap(param) unless defined?(@map) map = { self.namevar => "cn" } map.update(self.class.map) if self.class.map end if map.include?(param) return map[param] else return "nagios-" + param.id2name.gsub(/_/,'-') end end def parent unless defined?(self.class.attached) puts "Duh, you called parent on an unattached class" return end klass,param = self.class.attached unless @parameters.include?(param) puts "Huh, no attachment param" return end klass[@parameters[param]] end # okay, this sucks # how do i get my list of ocs? def to_ldif base = self.class.ldapbase str = self.dn + "\n" ocs = Array.new if self.class.ocs # i'm storing an array, so i have to flatten it and stuff kocs = self.class.ocs ocs.push(*kocs) end ocs.push "top" oc = self.class.to_s oc.sub!(/Nagios/,'nagios') oc.sub!(/::/,'') ocs.push oc ocs.each { |oc| str += "objectclass: #{oc}\n" } @parameters.each { |name,value| next if self.class.suppress.include?(name) ldapname = self.parammap(name) str += ldapname + ": #{value}\n" } str += "\n" end def to_s str = "define #{self.type} {\n" self.each { |param,value| str += %{\t%-30s %s\n} % [ param, if value.is_a? Array value.join(",") else value end ] } str += "}\n" str end # The type of object we are. def type self.class.name end # object types newtype :host do setparameters :host_name, :alias, :display_name, :address, :parents, :hostgroups, :check_command, :initial_state, :max_check_attempts, :check_interval, :retry_interval, :active_checks_enabled, :passive_checks_enabled, :check_period, :obsess_over_host, :check_freshness, :freshness_threshold, :event_handler, :event_handler_enabled, :low_flap_threshold, :high_flap_threshold, :flap_detection_enabled, :flap_detection_options, :failure_prediction_enabled, :process_perf_data, :retain_status_information, :retain_nonstatus_information, :contacts, :contact_groups, :notification_interval, :first_notification_delay, :notification_period, :notification_options, :notifications_enabled, :stalking_options, :notes, :notes_url, :action_url, :icon_image, :icon_image_alt, :vrml_image, :statusmap_image, "2d_coords".intern, "3d_coords".intern, :register, :use setsuperior "person" map :address => "ipHostNumber" end newtype :hostgroup do setparameters :hostgroup_name, :alias, :members, :hostgroup_members, :notes, :notes_url, :action_url, :register, :use end newtype :service do attach :host => :host_name setparameters :host_name, :hostgroup_name, :service_description, :display_name, :servicegroups, :is_volatile, :check_command, :initial_state, :max_check_attempts, :check_interval, :retry_interval, :normal_check_interval, :retry_check_interval, :active_checks_enabled, :passive_checks_enabled, :parallelize_check, :check_period, :obsess_over_service, :check_freshness, :freshness_threshold, :event_handler, :event_handler_enabled, :low_flap_threshold, :high_flap_threshold, :flap_detection_enabled,:flap_detection_options, :process_perf_data, :failure_prediction_enabled, :retain_status_information, :retain_nonstatus_information, :notification_interval, :first_notification_delay, :notification_period, :notification_options, :notifications_enabled, :contacts, :contact_groups, :stalking_options, :notes, :notes_url, :action_url, :icon_image, :icon_image_alt, :register, :use, :_naginator_name suppress :host_name setnamevar :_naginator_name end newtype :servicegroup do setparameters :servicegroup_name, :alias, :members, :servicegroup_members, :notes, :notes_url, :action_url, :register, :use end newtype :contact do setparameters :contact_name, :alias, :contactgroups, :host_notifications_enabled, :service_notifications_enabled, :host_notification_period, :service_notification_period, :host_notification_options, :service_notification_options, :host_notification_commands, :service_notification_commands, :email, :pager, :address1, :address2, :address3, :address4, :address5, :address6, :can_submit_commands, :retain_status_information, :retain_nonstatus_information, :register, :use setsuperior "person" end newtype :contactgroup do setparameters :contactgroup_name, :alias, :members, :contactgroup_members, :register, :use end # TODO - We should support generic time periods here eg "day 1 - 15" newtype :timeperiod do setparameters :timeperiod_name, :alias, :sunday, :monday, :tuesday, :wednesday, :thursday, :friday, :saturday, :exclude, :register, :use end newtype :command do setparameters :command_name, :command_line end newtype :servicedependency do auxiliary = true setparameters :dependent_host_name, :dependent_hostgroup_name, :dependent_service_description, :host_name, :hostgroup_name, :service_description, :inherits_parent, :execution_failure_criteria, :notification_failure_criteria, :dependency_period, :register, :use, :_naginator_name setnamevar :_naginator_name end newtype :serviceescalation do setparameters :host_name, :hostgroup_name, :servicegroup_name, :service_description, :contacts, :contact_groups, :first_notification, :last_notification, :notification_interval, :escalation_period, :escalation_options, :register, :use, :_naginator_name setnamevar :_naginator_name end newtype :hostdependency do auxiliary = true setparameters :dependent_host_name, :dependent_hostgroup_name, :host_name, :hostgroup_name, :inherits_parent, :execution_failure_criteria, :notification_failure_criteria, :dependency_period, :register, :use, :_naginator_name setnamevar :_naginator_name end newtype :hostescalation do setparameters :host_name, :hostgroup_name, :contacts, :contact_groups, :first_notification, :last_notification, :notification_interval, :escalation_period, :escalation_options, :register, :use, :_naginator_name setnamevar :_naginator_name end newtype :hostextinfo do auxiliary = true setparameters :host_name, :notes, :notes_url, :icon_image, :icon_image_alt, :vrml_image, :statusmap_image, "2d_coords".intern, "3d_coords".intern, :register, :use setnamevar :host_name end newtype :serviceextinfo do auxiliary = true setparameters :host_name, :service_description, :notes, :notes_url, :action_url, :icon_image, :icon_image_alt, :register, :use, :_naginator_name setnamevar :_naginator_name end end - -# $Id$ diff --git a/lib/puppet/file_bucket/dipper.rb b/lib/puppet/file_bucket/dipper.rb index be487d83f..d6f6a3747 100644 --- a/lib/puppet/file_bucket/dipper.rb +++ b/lib/puppet/file_bucket/dipper.rb @@ -1,104 +1,105 @@ require 'puppet/file_bucket' require 'puppet/file_bucket/file' require 'puppet/indirector/request' class Puppet::FileBucket::Dipper # This is a transitional implementation that uses REST # to access remote filebucket files. attr_accessor :name # Create our bucket client def initialize(hash = {}) # Emulate the XMLRPC client server = hash[:Server] port = hash[:Port] || Puppet[:masterport] environment = Puppet[:environment] if hash.include?(:Path) @local_path = hash[:Path] @rest_path = nil else @local_path = nil @rest_path = "https://#{server}:#{port}/#{environment}/file_bucket_file/" end end def local? !! @local_path end # Back up a file to our bucket def backup(file) raise(ArgumentError, "File #{file} does not exist") unless ::File.exist?(file) contents = ::File.read(file) begin file_bucket_file = Puppet::FileBucket::File.new(contents, :bucket_path => @local_path) - dest_path = "#{@rest_path}#{file_bucket_file.name}" + files_original_path = absolutize_path(file) + dest_path = "#{@rest_path}#{file_bucket_file.name}#{files_original_path}" # Make a HEAD request for the file so that we don't waste time # uploading it if it already exists in the bucket. - unless Puppet::FileBucket::File.indirection.head("#{@rest_path}#{file_bucket_file.checksum_type}/#{file_bucket_file.checksum_data}") + unless Puppet::FileBucket::File.indirection.head("#{@rest_path}#{file_bucket_file.checksum_type}/#{file_bucket_file.checksum_data}#{files_original_path}") Puppet::FileBucket::File.indirection.save(file_bucket_file, dest_path) end return file_bucket_file.checksum_data rescue => detail puts detail.backtrace if Puppet[:trace] raise Puppet::Error, "Could not back up #{file}: #{detail}" end end # Retrieve a file by sum. def getfile(sum) source_path = "#{@rest_path}md5/#{sum}" file_bucket_file = Puppet::FileBucket::File.indirection.find(source_path, :bucket_path => @local_path) raise Puppet::Error, "File not found" unless file_bucket_file file_bucket_file.to_s end # Restore the file def restore(file,sum) restore = true if FileTest.exists?(file) cursum = Digest::MD5.hexdigest(::File.read(file)) # if the checksum has changed... # this might be extra effort if cursum == sum restore = false end end if restore if newcontents = getfile(sum) tmp = "" newsum = Digest::MD5.hexdigest(newcontents) changed = nil if FileTest.exists?(file) and ! FileTest.writable?(file) changed = ::File.stat(file).mode ::File.chmod(changed | 0200, file) end ::File.open(file, ::File::WRONLY|::File::TRUNC|::File::CREAT) { |of| of.print(newcontents) } ::File.chmod(changed, file) if changed else Puppet.err "Could not find file with checksum #{sum}" return nil end return newsum else return nil end end private def absolutize_path( path ) require 'pathname' Pathname.new(path).realpath end end diff --git a/lib/puppet/indirector/facts/inventory_active_record.rb b/lib/puppet/indirector/facts/inventory_active_record.rb new file mode 100644 index 000000000..db4c63f00 --- /dev/null +++ b/lib/puppet/indirector/facts/inventory_active_record.rb @@ -0,0 +1,97 @@ +require 'puppet/rails' +require 'puppet/rails/inventory_node' +require 'puppet/rails/inventory_fact' +require 'puppet/indirector/active_record' + +class Puppet::Node::Facts::InventoryActiveRecord < Puppet::Indirector::ActiveRecord + def find(request) + node = Puppet::Rails::InventoryNode.find_by_name(request.key) + return nil unless node + facts = Puppet::Node::Facts.new(node.name, node.facts_to_hash) + facts.timestamp = node.timestamp + facts + end + + def save(request) + facts = request.instance + node = Puppet::Rails::InventoryNode.find_by_name(request.key) || Puppet::Rails::InventoryNode.create(:name => request.key, :timestamp => facts.timestamp) + node.timestamp = facts.timestamp + + ActiveRecord::Base.transaction do + Puppet::Rails::InventoryFact.delete_all(:node_id => node.id) + # We don't want to save internal values as facts, because those are + # metadata that belong on the node + facts.values.each do |name,value| + next if name.to_s =~ /^_/ + node.facts.build(:name => name, :value => value) + end + node.save + end + end + + def search(request) + return [] unless request.options + matching_nodes = [] + fact_names = [] + fact_filters = Hash.new {|h,k| h[k] = []} + meta_filters = Hash.new {|h,k| h[k] = []} + request.options.each do |key,value| + type, name, operator = key.to_s.split(".") + operator ||= "eq" + if type == "facts" + fact_filters[operator] << [name,value] + elsif type == "meta" and name == "timestamp" + meta_filters[operator] << [name,value] + end + end + + matching_nodes = nodes_matching_fact_filters(fact_filters) + nodes_matching_meta_filters(meta_filters) + + # to_a because [].inject == nil + matching_nodes.inject {|nodes,this_set| nodes & this_set}.to_a.sort + end + + private + + def nodes_matching_fact_filters(fact_filters) + node_sets = [] + fact_filters['eq'].each do |name,value| + node_sets << Puppet::Rails::InventoryNode.has_fact_with_value(name,value).map {|node| node.name} + end + fact_filters['ne'].each do |name,value| + node_sets << Puppet::Rails::InventoryNode.has_fact_without_value(name,value).map {|node| node.name} + end + { + 'gt' => '>', + 'lt' => '<', + 'ge' => '>=', + 'le' => '<=' + }.each do |operator_name,operator| + fact_filters[operator_name].each do |name,value| + facts = Puppet::Rails::InventoryFact.find_by_sql(["SELECT inventory_facts.value, inventory_nodes.name AS node_name + FROM inventory_facts INNER JOIN inventory_nodes + ON inventory_facts.node_id = inventory_nodes.id + WHERE inventory_facts.name = ?", name]) + node_sets << facts.select {|fact| fact.value.to_f.send(operator, value.to_f)}.map {|fact| fact.node_name} + end + end + node_sets + end + + def nodes_matching_meta_filters(meta_filters) + node_sets = [] + { + 'eq' => '=', + 'ne' => '!=', + 'gt' => '>', + 'lt' => '<', + 'ge' => '>=', + 'le' => '<=' + }.each do |operator_name,operator| + meta_filters[operator_name].each do |name,value| + node_sets << Puppet::Rails::InventoryNode.find(:all, :select => "name", :conditions => ["timestamp #{operator} ?", value]).map {|node| node.name} + end + end + node_sets + end +end diff --git a/lib/puppet/indirector/facts/yaml.rb b/lib/puppet/indirector/facts/yaml.rb index 89feaf2ab..65bd78354 100644 --- a/lib/puppet/indirector/facts/yaml.rb +++ b/lib/puppet/indirector/facts/yaml.rb @@ -1,7 +1,82 @@ require 'puppet/node/facts' require 'puppet/indirector/yaml' class Puppet::Node::Facts::Yaml < Puppet::Indirector::Yaml desc "Store client facts as flat files, serialized using YAML, or return deserialized facts from disk." + + def search(request) + node_names = [] + Dir.glob(yaml_dir_path).each do |file| + facts = YAML.load_file(file) + node_names << facts.name if node_matches?(facts, request.options) + end + node_names + end + + private + + # Return the path to a given node's file. + def yaml_dir_path + base = Puppet.run_mode.master? ? Puppet[:yamldir] : Puppet[:clientyamldir] + File.join(base, 'facts', '*.yaml') + end + + def node_matches?(facts, options) + options.each do |key, value| + type, name, operator = key.to_s.split(".") + operator ||= 'eq' + + return false unless node_matches_option?(type, name, operator, value, facts) + end + return true + end + + def node_matches_option?(type, name, operator, value, facts) + case type + when "meta" + case name + when "timestamp" + compare_timestamp(operator, facts.timestamp, Time.parse(value)) + end + when "facts" + compare_facts(operator, facts.values[name], value) + end + end + + def compare_facts(operator, value1, value2) + return false unless value1 + + case operator + when "eq" + value1.to_s == value2.to_s + when "le" + value1.to_f <= value2.to_f + when "ge" + value1.to_f >= value2.to_f + when "lt" + value1.to_f < value2.to_f + when "gt" + value1.to_f > value2.to_f + when "ne" + value1.to_s != value2.to_s + end + end + + def compare_timestamp(operator, value1, value2) + case operator + when "eq" + value1 == value2 + when "le" + value1 <= value2 + when "ge" + value1 >= value2 + when "lt" + value1 < value2 + when "gt" + value1 > value2 + when "ne" + value1 != value2 + end + end end diff --git a/lib/puppet/indirector/file_bucket_file/file.rb b/lib/puppet/indirector/file_bucket_file/file.rb index 8bea2d767..0fd8a914f 100644 --- a/lib/puppet/indirector/file_bucket_file/file.rb +++ b/lib/puppet/indirector/file_bucket_file/file.rb @@ -1,106 +1,135 @@ require 'puppet/indirector/code' require 'puppet/file_bucket/file' require 'puppet/util/checksums' require 'fileutils' module Puppet::FileBucketFile class File < Puppet::Indirector::Code include Puppet::Util::Checksums desc "Store files in a directory set based on their checksums." def initialize Puppet.settings.use(:filebucket) end def find( request ) - checksum = request_to_checksum( request ) - file_path = path_for(request.options[:bucket_path], checksum, 'contents') + checksum, files_original_path = request_to_checksum_and_path( request ) + dir_path = path_for(request.options[:bucket_path], checksum) + file_path = ::File.join(dir_path, 'contents') return nil unless ::File.exists?(file_path) + return nil unless path_match(dir_path, files_original_path) if request.options[:diff_with] hash_protocol = sumtype(checksum) file2_path = path_for(request.options[:bucket_path], request.options[:diff_with], 'contents') raise "could not find diff_with #{request.options[:diff_with]}" unless ::File.exists?(file2_path) return `diff #{file_path.inspect} #{file2_path.inspect}` else contents = ::File.read file_path Puppet.info "FileBucket read #{checksum}" model.new(contents) end end def head(request) - checksum = request_to_checksum(request) - file_path = path_for(request.options[:bucket_path], checksum, 'contents') - ::File.exists?(file_path) + checksum, files_original_path = request_to_checksum_and_path(request) + dir_path = path_for(request.options[:bucket_path], checksum) + + ::File.exists?(::File.join(dir_path, 'contents')) and path_match(dir_path, files_original_path) end def save( request ) instance = request.instance + checksum, files_original_path = request_to_checksum_and_path(request) - save_to_disk(instance) + save_to_disk(instance, files_original_path) instance.to_s end private - def save_to_disk( bucket_file ) + def path_match(dir_path, files_original_path) + return true unless files_original_path # if no path was provided, it's a match + paths_path = ::File.join(dir_path, 'paths') + return false unless ::File.exists?(paths_path) + ::File.open(paths_path) do |f| + f.each do |line| + return true if line.chomp == files_original_path + end + end + return false + end + + def save_to_disk( bucket_file, files_original_path ) filename = path_for(bucket_file.bucket_path, bucket_file.checksum_data, 'contents') - dirname = path_for(bucket_file.bucket_path, bucket_file.checksum_data) + dir_path = path_for(bucket_file.bucket_path, bucket_file.checksum_data) + paths_path = ::File.join(dir_path, 'paths') # If the file already exists, do nothing. if ::File.exist?(filename) verify_identical_file!(bucket_file) else # Make the directories if necessary. - unless ::File.directory?(dirname) + unless ::File.directory?(dir_path) Puppet::Util.withumask(0007) do - ::FileUtils.mkdir_p(dirname) + ::FileUtils.mkdir_p(dir_path) end end Puppet.info "FileBucket adding #{bucket_file.checksum}" # Write the file to disk. Puppet::Util.withumask(0007) do ::File.open(filename, ::File::WRONLY|::File::CREAT, 0440) do |of| of.print bucket_file.contents end + ::File.open(paths_path, ::File::WRONLY|::File::CREAT, 0640) do |of| + # path will be written below + end + end + end + + unless path_match(dir_path, files_original_path) + ::File.open(paths_path, 'a') do |f| + f.puts(files_original_path) end end end - def request_to_checksum( request ) - checksum_type, checksum, path = request.key.split(/\//, 3) # Note: we ignore path if present. + def request_to_checksum_and_path( request ) + checksum_type, checksum, path = request.key.split(/\//, 3) + if path == '' # Treat "md5//" like "md5/" + path = nil + end raise "Unsupported checksum type #{checksum_type.inspect}" if checksum_type != 'md5' raise "Invalid checksum #{checksum.inspect}" if checksum !~ /^[0-9a-f]{32}$/ - checksum + [checksum, path] end def path_for(bucket_path, digest, subfile = nil) bucket_path ||= Puppet[:bucketdir] dir = ::File.join(digest[0..7].split("")) basedir = ::File.join(bucket_path, dir, digest) return basedir unless subfile ::File.join(basedir, subfile) end # If conflict_check is enabled, verify that the passed text is # the same as the text in our file. def verify_identical_file!(bucket_file) disk_contents = ::File.read(path_for(bucket_file.bucket_path, bucket_file.checksum_data, 'contents')) # If the contents don't match, then we've found a conflict. # Unlikely, but quite bad. if disk_contents != bucket_file.contents raise Puppet::FileBucket::BucketError, "Got passed new contents for sum #{bucket_file.checksum}" else Puppet.info "FileBucket got a duplicate file #{bucket_file.checksum}" end end end end diff --git a/lib/puppet/module.rb b/lib/puppet/module.rb index 8da19c2ce..43266b2b5 100644 --- a/lib/puppet/module.rb +++ b/lib/puppet/module.rb @@ -1,204 +1,204 @@ require 'puppet/util/logging' # Support for modules class Puppet::Module class Error < Puppet::Error; end class MissingModule < Error; end class IncompatibleModule < Error; end class UnsupportedPlatform < Error; end class IncompatiblePlatform < Error; end class MissingMetadata < Error; end class InvalidName < Error; end include Puppet::Util::Logging TEMPLATES = "templates" FILES = "files" MANIFESTS = "manifests" PLUGINS = "plugins" FILETYPES = [MANIFESTS, FILES, TEMPLATES, PLUGINS] # Return an array of paths by splitting the +modulepath+ config # parameter. Only consider paths that are absolute and existing # directories def self.modulepath(environment = nil) Puppet::Node::Environment.new(environment).modulepath end # Find and return the +module+ that +path+ belongs to. If +path+ is # absolute, or if there is no module whose name is the first component # of +path+, return +nil+ def self.find(modname, environment = nil) return nil unless modname Puppet::Node::Environment.new(environment).module(modname) end attr_reader :name, :environment attr_writer :environment attr_accessor :source, :author, :version, :license, :puppetversion, :summary, :description, :project_page def has_metadata? return false unless metadata_file FileTest.exist?(metadata_file) end def initialize(name, environment = nil) @name = name assert_validity if environment.is_a?(Puppet::Node::Environment) @environment = environment else @environment = Puppet::Node::Environment.new(environment) end load_metadata if has_metadata? validate_puppet_version validate_dependencies end FILETYPES.each do |type| # A boolean method to let external callers determine if # we have files of a given type. define_method(type +'?') do return false unless path return false unless FileTest.exist?(subpath(type)) return true end # A method for returning a given file of a given type. # e.g., file = mod.manifest("my/manifest.pp") # # If the file name is nil, then the base directory for the # file type is passed; this is used for fileserving. define_method(type.to_s.sub(/s$/, '')) do |file| return nil unless path # If 'file' is nil then they're asking for the base path. # This is used for things like fileserving. if file full_path = File.join(subpath(type), file) else full_path = subpath(type) end return nil unless FileTest.exist?(full_path) return full_path end end def exist? ! path.nil? end # Find the first 'files' directory. This is used by the XMLRPC fileserver. def file_directory subpath("files") end def license_file return @license_file if defined?(@license_file) return @license_file = nil unless path @license_file = File.join(path, "License") end def load_metadata data = PSON.parse File.read(metadata_file) [:source, :author, :version, :license, :puppetversion].each do |attr| unless value = data[attr.to_s] unless attr == :puppetversion raise MissingMetadata, "No #{attr} module metadata provided for #{self.name}" end end send(attr.to_s + "=", value) end end # Return the list of manifests matching the given glob pattern, # defaulting to 'init.{pp,rb}' for empty modules. def match_manifests(rest) pat = File.join(path, MANIFESTS, rest || 'init') [manifest("init.pp"),manifest("init.rb")].compact + Dir. glob(pat + (File.extname(pat).empty? ? '.{pp,rb}' : '')). reject { |f| FileTest.directory?(f) } end def metadata_file return @metadata_file if defined?(@metadata_file) return @metadata_file = nil unless path @metadata_file = File.join(path, "metadata.json") end # Find this module in the modulepath. def path environment.modulepath.collect { |path| File.join(path, name) }.find { |d| FileTest.exist?(d) } end # Find all plugin directories. This is used by the Plugins fileserving mount. def plugin_directory subpath("plugins") end def requires(name, version = nil) @requires ||= [] @requires << [name, version] end def supports(name, version = nil) @supports ||= [] @supports << [name, version] end def to_s result = "Module #{name}" result += "(#{path})" if path result end def validate_dependencies return unless defined?(@requires) @requires.each do |name, version| unless mod = environment.module(name) raise MissingModule, "Missing module #{name} required by #{self.name}" end if version and mod.version != version raise IncompatibleModule, "Required module #{name} is version #{mod.version} but #{self.name} requires #{version}" end end end def validate_puppet_version return unless puppetversion and puppetversion != Puppet.version raise IncompatibleModule, "Module #{self.name} is only compatible with Puppet version #{puppetversion}, not #{Puppet.version}" end private def subpath(type) return File.join(path, type) unless type.to_s == "plugins" backward_compatible_plugins_dir end def backward_compatible_plugins_dir if dir = File.join(path, "plugins") and FileTest.exist?(dir) - warning "using the deprecated 'plugins' directory for ruby extensions; please move to 'lib'" + Puppet.warning "using the deprecated 'plugins' directory for ruby extensions; please move to 'lib'" return dir else return File.join(path, "lib") end end def assert_validity raise InvalidName, "Invalid module name; module names must be alphanumeric (plus '-'), not '#{name}'" unless name =~ /^[-\w]+$/ end end diff --git a/lib/puppet/network/http/api/v1.rb b/lib/puppet/network/http/api/v1.rb index 4b7c15a36..dcb0e0a22 100644 --- a/lib/puppet/network/http/api/v1.rb +++ b/lib/puppet/network/http/api/v1.rb @@ -1,72 +1,72 @@ require 'puppet/network/http/api' module Puppet::Network::HTTP::API::V1 # How we map http methods and the indirection name in the URI # to an indirection method. METHOD_MAP = { "GET" => { :plural => :search, :singular => :find }, "PUT" => { :singular => :save }, "DELETE" => { :singular => :destroy }, "HEAD" => { :singular => :head } } def uri2indirection(http_method, uri, params) environment, indirection, key = uri.split("/", 4)[1..-1] # the first field is always nil because of the leading slash raise ArgumentError, "The environment must be purely alphanumeric, not '#{environment}'" unless environment =~ /^\w+$/ raise ArgumentError, "The indirection name must be purely alphanumeric, not '#{indirection}'" unless indirection =~ /^\w+$/ method = indirection_method(http_method, indirection) params[:environment] = environment raise ArgumentError, "No request key specified in #{uri}" if key == "" or key.nil? key = URI.unescape(key) [indirection, method, key, params] end def indirection2uri(request) indirection = request.method == :search ? pluralize(request.indirection_name.to_s) : request.indirection_name.to_s "/#{request.environment.to_s}/#{indirection}/#{request.escaped_key}#{request.query_string}" end def indirection_method(http_method, indirection) raise ArgumentError, "No support for http method #{http_method}" unless METHOD_MAP[http_method] unless method = METHOD_MAP[http_method][plurality(indirection)] raise ArgumentError, "No support for plural #{http_method} operations" end method end def pluralize(indirection) return(indirection == "status" ? "statuses" : indirection + "s") end def plurality(indirection) # NOTE This specific hook for facts is ridiculous, but it's a *many*-line # fix to not need this, and our goal is to move away from the complication # that leads to the fix being too long. return :singular if indirection == "facts" return :singular if indirection == "status" return :plural if indirection == "inventory" - result = (indirection =~ /s$/) ? :plural : :singular + result = (indirection =~ /s$|_search$/) ? :plural : :singular - indirection.sub!(/s$/, '') if result + indirection.sub!(/s$|_search$|es$/, '') result end end diff --git a/lib/puppet/network/http/compression.rb b/lib/puppet/network/http/compression.rb index d9b56f184..c8d001169 100644 --- a/lib/puppet/network/http/compression.rb +++ b/lib/puppet/network/http/compression.rb @@ -1,111 +1,114 @@ require 'puppet/network/http' module Puppet::Network::HTTP::Compression # this module function allows to use the right underlying # methods depending on zlib presence def module return(Puppet.features.zlib? ? Active : None) end module_function :module module Active require 'zlib' require 'stringio' # return an uncompressed body if the response has been # compressed def uncompress_body(response) case response['content-encoding'] when 'gzip' return Zlib::GzipReader.new(StringIO.new(response.body)).read when 'deflate' return Zlib::Inflate.new.inflate(response.body) when nil, 'identity' return response.body else raise Net::HTTPError.new("Unknown content encoding - #{response['content-encoding']}", response) end end def uncompress(response) raise Net::HTTPError.new("No block passed") unless block_given? case response['content-encoding'] when 'gzip','deflate' uncompressor = ZlibAdapter.new when nil, 'identity' uncompressor = IdentityAdapter.new else raise Net::HTTPError.new("Unknown content encoding - #{response['content-encoding']}", response) end yield uncompressor uncompressor.close end def add_accept_encoding(headers={}) headers['accept-encoding'] = 'gzip; q=1.0, deflate; q=1.0; identity' if Puppet.settings[:http_compression] headers end # This adapters knows how to uncompress both 'zlib' stream (the deflate algorithm from Content-Encoding) # and GZip streams. class ZlibAdapter def initialize # Create an inflater that knows to parse GZip streams and zlib streams. # This uses a property of the C Zlib library, documented as follow: # windowBits can also be greater than 15 for optional gzip decoding. Add # 32 to windowBits to enable zlib and gzip decoding with automatic header # detection, or add 16 to decode only the gzip format (the zlib format will # return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is # a crc32 instead of an adler32. @uncompressor = Zlib::Inflate.new(15 + 32) @first = true end def uncompress(chunk) out = @uncompressor.inflate(chunk) @first = false return out rescue Zlib::DataError => z # it can happen that we receive a raw deflate stream # which might make our inflate throw a data error. # in this case, we try with a verbatim (no header) # deflater. @uncompressor = Zlib::Inflate.new - retry if @first + if @first then + @first = false + retry + end raise end def close @uncompressor.finish @uncompressor.close end end end module None def uncompress_body(response) response.body end def add_accept_encoding(headers) headers end def uncompress(response) yield IdentityAdapter.new end end class IdentityAdapter def uncompress(chunk) chunk end def close end end end diff --git a/lib/puppet/network/http/rack/rest.rb b/lib/puppet/network/http/rack/rest.rb index b7e1d9709..602927a78 100644 --- a/lib/puppet/network/http/rack/rest.rb +++ b/lib/puppet/network/http/rack/rest.rb @@ -1,102 +1,100 @@ require 'puppet/network/http/handler' require 'puppet/network/http/rack/httphandler' class Puppet::Network::HTTP::RackREST < Puppet::Network::HTTP::RackHttpHandler include Puppet::Network::HTTP::Handler HEADER_ACCEPT = 'HTTP_ACCEPT'.freeze ContentType = 'Content-Type'.freeze CHUNK_SIZE = 8192 class RackFile def initialize(file) @file = file end def each while chunk = @file.read(CHUNK_SIZE) yield chunk end end def close @file.close end end def initialize(args={}) super() initialize_for_puppet(args) end def set_content_type(response, format) response[ContentType] = format_to_mime(format) end # produce the body of the response def set_response(response, result, status = 200) response.status = status unless result.is_a?(File) response.write result else response["Content-Length"] = result.stat.size.to_s response.body = RackFile.new(result) end end # Retrieve the accept header from the http request. def accept_header(request) request.env[HEADER_ACCEPT] end # Retrieve the accept header from the http request. def content_type_header(request) request.content_type end # Return which HTTP verb was used in this request. def http_method(request) request.request_method end # Return the query params for this request. def params(request) result = decode_params(request.params) result.merge(extract_client_info(request)) end # what path was requested? (this is, without any query parameters) def path(request) request.path end # return the request body # request.body has some limitiations, so we need to concat it back # into a regular string, which is something puppet can use. def body(request) - body = '' - request.body.each { |part| body += part } - body + request.body.read end def extract_client_info(request) result = {} result[:ip] = request.ip # if we find SSL info in the headers, use them to get a hostname. # try this with :ssl_client_header, which defaults should work for # Apache with StdEnvVars. if dn = request.env[Puppet[:ssl_client_header]] and dn_matchdata = dn.match(/^.*?CN\s*=\s*(.*)/) result[:node] = dn_matchdata[1].to_str result[:authenticated] = (request.env[Puppet[:ssl_client_verify_header]] == 'SUCCESS') else result[:node] = resolve_node(result) result[:authenticated] = false end result end end diff --git a/lib/puppet/network/rest_authconfig.rb b/lib/puppet/network/rest_authconfig.rb index 9e3632499..cf76978fe 100644 --- a/lib/puppet/network/rest_authconfig.rb +++ b/lib/puppet/network/rest_authconfig.rb @@ -1,88 +1,88 @@ require 'puppet/network/authconfig' module Puppet class Network::RestAuthConfig < Network::AuthConfig extend MonitorMixin attr_accessor :rights DEFAULT_ACL = [ { :acl => "~ ^\/catalog\/([^\/]+)$", :method => :find, :allow => '$1', :authenticated => true }, # this one will allow all file access, and thus delegate # to fileserver.conf { :acl => "/file" }, { :acl => "/certificate_revocation_list/ca", :method => :find, :authenticated => true }, { :acl => "/report", :method => :save, :authenticated => true }, { :acl => "/certificate/ca", :method => :find, :authenticated => false }, { :acl => "/certificate/", :method => :find, :authenticated => false }, { :acl => "/certificate_request", :method => [:find, :save], :authenticated => false }, { :acl => "/status", :method => [:find], :authenticated => true }, ] def self.main synchronize do add_acl = @main.nil? super @main.insert_default_acl if add_acl and !@main.exists? end @main end # check wether this request is allowed in our ACL # raise an Puppet::Network::AuthorizedError if the request # is denied. def allowed?(indirection, method, key, params) read # we're splitting the request in part because # fail_on_deny could as well be called in the XMLRPC context # with a ClientRequest. if authorization_failure_exception = @rights.is_request_forbidden_and_why?(indirection, method, key, params) Puppet.warning("Denying access: #{authorization_failure_exception}") raise authorization_failure_exception end end def initialize(file = nil, parsenow = true) super(file || Puppet[:rest_authconfig], parsenow) # if we didn't read a file (ie it doesn't exist) # make sure we can create some default rights @rights ||= Puppet::Network::Rights.new end def parse super() insert_default_acl end # force regular ACLs to be present def insert_default_acl DEFAULT_ACL.each do |acl| unless rights[acl[:acl]] - Puppet.info "Inserting default '#{acl[:acl]}'(#{acl[:authenticated] ? "auth" : "non-auth"}) acl because #{( !exists? ? "#{Puppet[:rest_authconfig]} doesn't exist" : "none where found in '#{@file}'")}" + Puppet.info "Inserting default '#{acl[:acl]}'(#{acl[:authenticated] ? "auth" : "non-auth"}) ACL because #{( !exists? ? "#{Puppet[:rest_authconfig]} doesn't exist" : "none were found in '#{@file}'")}" mk_acl(acl) end end # queue an empty (ie deny all) right for every other path # actually this is not strictly necessary as the rights system # denies not explicitely allowed paths unless rights["/"] rights.newright("/") rights.restrict_authenticated("/", :any) end end def mk_acl(acl) @rights.newright(acl[:acl]) @rights.allow(acl[:acl], acl[:allow] || "*") if method = acl[:method] method = [method] unless method.is_a?(Array) method.each { |m| @rights.restrict_method(acl[:acl], m) } end @rights.restrict_authenticated(acl[:acl], acl[:authenticated]) unless acl[:authenticated].nil? end end end diff --git a/lib/puppet/network/rights.rb b/lib/puppet/network/rights.rb index 56af53983..6fde181c9 100755 --- a/lib/puppet/network/rights.rb +++ b/lib/puppet/network/rights.rb @@ -1,276 +1,276 @@ require 'puppet/network/authstore' require 'puppet/error' module Puppet::Network # this exception is thrown when a request is not authenticated class AuthorizationError < Puppet::Error; end # Define a set of rights and who has access to them. # There are two types of rights: # * named rights (ie a common string) # * path based rights (which are matched on a longest prefix basis) class Rights # We basically just proxy directly to our rights. Each Right stores # its own auth abilities. [:allow, :deny, :restrict_method, :restrict_environment, :restrict_authenticated].each do |method| define_method(method) do |name, *args| if obj = self[name] obj.send(method, *args) else raise ArgumentError, "Unknown right '#{name}'" end end end # Check that name is allowed or not def allowed?(name, *args) !is_forbidden_and_why?(name, :node => args[0], :ip => args[1]) end def is_request_forbidden_and_why?(indirection, method, key, params) methods_to_check = if method == :head # :head is ok if either :find or :save is ok. [:find, :save] else [method] end authorization_failure_exceptions = methods_to_check.map do |method| is_forbidden_and_why?("/#{indirection}/#{key}", params.merge({:method => method})) end if authorization_failure_exceptions.include? nil # One of the methods we checked is ok, therefore this request is ok. nil else # Just need to return any of the failure exceptions. authorization_failure_exceptions.first end end def is_forbidden_and_why?(name, args = {}) res = :nomatch right = @rights.find do |acl| found = false # an acl can return :dunno, which means "I'm not qualified to answer your question, # please ask someone else". This is used when for instance an acl matches, but not for the # current rest method, where we might think some other acl might be more specific. if match = acl.match?(name) args[:match] = match if (res = acl.allowed?(args[:node], args[:ip], args)) != :dunno # return early if we're allowed return nil if res # we matched, select this acl found = true end end found end # if we end here, then that means we either didn't match # or failed, in any case will throw an error to the outside world if name =~ /^\// or right # we're a patch ACL, let's fail msg = "#{(args[:node].nil? ? args[:ip] : "#{args[:node]}(#{args[:ip]})")} access to #{name} [#{args[:method]}]" msg += " authenticated " if args[:authenticated] error = AuthorizationError.new("Forbidden request: #{msg}") if right error.file = right.file error.line = right.line end else # there were no rights allowing/denying name # if name is not a path, let's throw - raise ArgumentError.new "Unknown namespace right '#{name}'" + raise ArgumentError, "Unknown namespace right '#{name}'" end error end def initialize @rights = [] end def [](name) @rights.find { |acl| acl == name } end def include?(name) @rights.include?(name) end def each @rights.each { |r| yield r.name,r } end # Define a new right to which access can be provided. def newright(name, line=nil, file=nil) add_right( Right.new(name, line, file) ) end private def add_right(right) if right.acl_type == :name and include?(right.key) raise ArgumentError, "Right '%s' already exists" end @rights << right sort_rights right end def sort_rights @rights.sort! end # Retrieve a right by name. def right(name) self[name] end # A right. class Right < Puppet::Network::AuthStore include Puppet::FileCollection::Lookup attr_accessor :name, :key, :acl_type attr_accessor :methods, :environment, :authentication ALL = [:save, :destroy, :find, :search] Puppet::Util.logmethods(self, true) def initialize(name, line, file) @methods = [] @environment = [] @authentication = true # defaults to authenticated @name = name @line = line || 0 @file = file case name when Symbol @acl_type = :name @key = name when /^\[(.+)\]$/ @acl_type = :name @key = $1.intern if name.is_a?(String) when /^\// @acl_type = :regex @key = Regexp.new("^" + Regexp.escape(name)) @methods = ALL when /^~/ # this is a regex @acl_type = :regex @name = name.gsub(/^~\s+/,'') @key = Regexp.new(@name) @methods = ALL else raise ArgumentError, "Unknown right type '#{name}'" end super() end def to_s "access[#{@name}]" end # There's no real check to do at this point def valid? true end def regex? acl_type == :regex end # does this right is allowed for this triplet? # if this right is too restrictive (ie we don't match this access method) # then return :dunno so that upper layers have a chance to try another right # tailored to the given method def allowed?(name, ip, args = {}) return :dunno if acl_type == :regex and not @methods.include?(args[:method]) return :dunno if acl_type == :regex and @environment.size > 0 and not @environment.include?(args[:environment]) return :dunno if acl_type == :regex and not @authentication.nil? and args[:authenticated] != @authentication begin # make sure any capture are replaced if needed interpolate(args[:match]) if acl_type == :regex and args[:match] res = super(name,ip) ensure reset_interpolation if acl_type == :regex end res end # restrict this right to some method only def restrict_method(m) m = m.intern if m.is_a?(String) raise ArgumentError, "'#{m}' is not an allowed value for method directive" unless ALL.include?(m) # if we were allowing all methods, then starts from scratch if @methods === ALL @methods = [] end raise ArgumentError, "'#{m}' is already in the '#{name}' ACL" if @methods.include?(m) @methods << m end def restrict_environment(env) env = Puppet::Node::Environment.new(env) raise ArgumentError, "'#{env}' is already in the '#{name}' ACL" if @environment.include?(env) @environment << env end def restrict_authenticated(authentication) case authentication when "yes", "on", "true", true authentication = true when "no", "off", "false", false authentication = false when "all","any", :all, :any authentication = nil else raise ArgumentError, "'#{name}' incorrect authenticated value: #{authentication}" end @authentication = authentication end def match?(key) # if we are a namespace compare directly return self.key == namespace_to_key(key) if acl_type == :name # otherwise match with the regex self.key.match(key) end def namespace_to_key(key) key = key.intern if key.is_a?(String) key end # this is where all the magic happens. # we're sorting the rights array with this scheme: # * namespace rights are all in front # * regex path rights are then all queued in file order def <=>(rhs) # move namespace rights at front return self.acl_type == :name ? -1 : 1 if self.acl_type != rhs.acl_type # sort by creation order (ie first match appearing in the file will win) # that is don't sort, in which case the sort algorithm will order in the # natural array order (ie the creation order) 0 end def ==(name) return(acl_type == :name ? self.key == namespace_to_key(name) : self.name == name.gsub(/^~\s+/,'')) end end end end diff --git a/lib/puppet/node/facts.rb b/lib/puppet/node/facts.rb index 451813f7d..577b62b62 100755 --- a/lib/puppet/node/facts.rb +++ b/lib/puppet/node/facts.rb @@ -1,99 +1,99 @@ require 'time' require 'puppet/node' require 'puppet/indirector' require 'puppet/util/pson' # Manage a given node's facts. This either accepts facts and stores them, or # returns facts for a given node. class Puppet::Node::Facts # Set up indirection, so that nodes can be looked for in # the node sources. extend Puppet::Indirector extend Puppet::Util::Pson # We want to expire any cached nodes if the facts are saved. module NodeExpirer def save(instance, key = nil) Puppet::Node.indirection.expire(instance.name) super end end indirects :facts, :terminus_setting => :facts_terminus, :extend => NodeExpirer attr_accessor :name, :values def add_local_facts values["clientcert"] = Puppet.settings[:certname] values["clientversion"] = Puppet.version.to_s values["environment"] ||= Puppet.settings[:environment] end def initialize(name, values = {}) @name = name @values = values add_timestamp end def downcase_if_necessary return unless Puppet.settings[:downcasefacts] Puppet.warning "DEPRECATION NOTICE: Fact downcasing is deprecated; please disable (20080122)" values.each do |fact, value| values[fact] = value.downcase if value.is_a?(String) end end # Convert all fact values into strings. def stringify values.each do |fact, value| values[fact] = value.to_s end end def ==(other) return false unless self.name == other.name strip_internal == other.send(:strip_internal) end def self.from_pson(data) result = new(data['name'], data['values']) - result.values[:_timestamp] = Time.parse(data['timestamp']) + result.timestamp = Time.parse(data['timestamp']) result.expiration = Time.parse(data['expiration']) result end def to_pson(*args) { 'expiration' => expiration, 'name' => name, - 'timestamp' => values[:_timestamp], - 'values' => values.reject {|k,v| k == :_timestamp}, + 'timestamp' => timestamp, + 'values' => strip_internal, }.to_pson(*args) end # Add internal data to the facts for storage. def add_timestamp self.timestamp = Time.now end def timestamp=(time) self.values[:_timestamp] = time end def timestamp self.values[:_timestamp] end private # Strip out that internal data. def strip_internal newvals = values.dup newvals.find_all { |name, value| name.to_s =~ /^_/ }.each { |name, value| newvals.delete(name) } newvals end end diff --git a/lib/puppet/parser/ast/collection.rb b/lib/puppet/parser/ast/collection.rb index ef36b7143..565b83195 100644 --- a/lib/puppet/parser/ast/collection.rb +++ b/lib/puppet/parser/ast/collection.rb @@ -1,48 +1,49 @@ require 'puppet' require 'puppet/parser/ast/branch' require 'puppet/parser/collector' # An object that collects stored objects from the central cache and returns # them to the current host, yo. class Puppet::Parser::AST class Collection < AST::Branch attr_accessor :type, :query, :form attr_reader :override associates_doc # We return an object that does a late-binding evaluation. def evaluate(scope) str, code = query && query.safeevaluate(scope) resource_type = scope.find_resource_type(@type) + fail "Resource type #{@type} doesn't exist" unless resource_type newcoll = Puppet::Parser::Collector.new(scope, resource_type.name, str, code, self.form) scope.compiler.add_collection(newcoll) # overrides if any # Evaluate all of the specified params. if @override params = @override.collect { |param| param.safeevaluate(scope) } newcoll.add_override( :parameters => params, - :file => @file, - :line => @line, - :source => scope.source, - :scope => scope + :file => @file, + :line => @line, + :source => scope.source, + :scope => scope ) end newcoll end # Handle our parameter ourselves def override=(override) @override = if override.is_a?(AST::ASTArray) override else AST::ASTArray.new(:line => override.line,:file => override.file,:children => [override]) end end end end diff --git a/lib/puppet/parser/ast/leaf.rb b/lib/puppet/parser/ast/leaf.rb index fcdd219d7..77617e992 100644 --- a/lib/puppet/parser/ast/leaf.rb +++ b/lib/puppet/parser/ast/leaf.rb @@ -1,221 +1,221 @@ class Puppet::Parser::AST # The base class for all of the leaves of the parse trees. These # basically just have types and values. Both of these parameters # are simple values, not AST objects. class Leaf < AST attr_accessor :value, :type # Return our value. def evaluate(scope) @value end def match(value) @value == value end def to_s @value.to_s unless @value.nil? end end # The boolean class. True or false. Converts the string it receives # to a Ruby boolean. class Boolean < AST::Leaf # Use the parent method, but then convert to a real boolean. def initialize(hash) super unless @value == true or @value == false raise Puppet::DevError, "'#{@value}' is not a boolean" end @value end def to_s @value ? "true" : "false" end end # The base string class. class String < AST::Leaf def evaluate(scope) @value.dup end def to_s "\"#{@value}\"" end end # An uninterpreted string. class FlatString < AST::Leaf def evaluate(scope) @value end def to_s "\"#{@value}\"" end end class Concat < AST::Leaf def evaluate(scope) @value.collect { |x| x.evaluate(scope) }.collect{ |x| x == :undef ? '' : x }.join end def to_s - "concat(#{@value.join(',')})" + "#{@value.map { |s| s.to_s.gsub(/^"(.*)"$/, '\1') }.join}" end end # The 'default' option on case statements and selectors. class Default < AST::Leaf; end # Capitalized words; used mostly for type-defaults, but also # get returned by the lexer any other time an unquoted capitalized # word is found. class Type < AST::Leaf; end # Lower-case words. class Name < AST::Leaf; end # double-colon separated class names class ClassName < AST::Leaf; end # undef values; equiv to nil class Undef < AST::Leaf; end # Host names, either fully qualified or just the short name, or even a regex class HostName < AST::Leaf def initialize(hash) super # Note that this is an AST::Regex, not a Regexp @value = @value.to_s.downcase unless @value.is_a?(Regex) if @value =~ /[^-\w.]/ raise Puppet::DevError, "'#{@value}' is not a valid hostname" end end # implementing eql? and hash so that when an HostName is stored # in a hash it has the same hashing properties as the underlying value def eql?(value) value = value.value if value.is_a?(HostName) @value.eql?(value) end def hash @value.hash end def to_s @value.to_s end end # A simple variable. This object is only used during interpolation; # the VarDef class is used for assignment. class Variable < Name # Looks up the value of the object in the scope tree (does # not include syntactical constructs, like '$' and '{}'). def evaluate(scope) parsewrap do if (var = scope.lookupvar(@value, false)) == :undefined var = :undef end var end end def to_s "\$#{value}" end end class HashOrArrayAccess < AST::Leaf attr_accessor :variable, :key def evaluate_container(scope) container = variable.respond_to?(:evaluate) ? variable.safeevaluate(scope) : variable (container.is_a?(Hash) or container.is_a?(Array)) ? container : scope.lookupvar(container) end def evaluate_key(scope) key.respond_to?(:evaluate) ? key.safeevaluate(scope) : key end def array_index_or_key(object, key) if object.is_a?(Array) raise Puppet::ParserError, "#{key} is not an integer, but is used as an index of an array" unless key = Puppet::Parser::Scope.number?(key) end key end def evaluate(scope) object = evaluate_container(scope) accesskey = evaluate_key(scope) raise Puppet::ParseError, "#{variable} is not an hash or array when accessing it with #{accesskey}" unless object.is_a?(Hash) or object.is_a?(Array) object[array_index_or_key(object, accesskey)] end # Assign value to this hashkey or array index def assign(scope, value) object = evaluate_container(scope) accesskey = evaluate_key(scope) if object.is_a?(Hash) and object.include?(accesskey) raise Puppet::ParseError, "Assigning to the hash '#{variable}' with an existing key '#{accesskey}' is forbidden" end # assign to hash or array object[array_index_or_key(object, accesskey)] = value end def to_s "\$#{variable.to_s}[#{key.to_s}]" end end class Regex < AST::Leaf def initialize(hash) super @value = Regexp.new(@value) unless @value.is_a?(Regexp) end # we're returning self here to wrap the regexp and to be used in places # where a string would have been used, without modifying any client code. # For instance, in many places we have the following code snippet: # val = @val.safeevaluate(@scope) # if val.match(otherval) # ... # end # this way, we don't have to modify this test specifically for handling # regexes. def evaluate(scope) self end def evaluate_match(value, scope, options = {}) value = value.is_a?(String) ? value : value.to_s if matched = @value.match(value) scope.ephemeral_from(matched, options[:file], options[:line]) end matched end def match(value) @value.match(value) end def to_s "/#{@value.source}/" end end end diff --git a/lib/puppet/parser/functions/regsubst.rb b/lib/puppet/parser/functions/regsubst.rb index f655db7b3..b6bb5afcf 100644 --- a/lib/puppet/parser/functions/regsubst.rb +++ b/lib/puppet/parser/functions/regsubst.rb @@ -1,100 +1,93 @@ module Puppet::Parser::Functions newfunction( :regsubst, :type => :rvalue, :doc => " - Perform regexp replacement on a string or array of strings. +Perform regexp replacement on a string or array of strings. * *Parameters* (in order): - - _target_ The string or array of strings to operate on. If an array, the replacement will be performed on each of the elements in the array, and the return value will be an array. - - _regexp_ The regular expression matching the target string. If you want it anchored at the start and or end of the string, you must do that with ^ and $ yourself. - - _replacement_ Replacement string. Can contain back references to what was matched using \\0, \\1, and so on. - - _flags_ Optional. String of single letter flags for how the regexp is interpreted: - + * _target_ The string or array of strings to operate on. If an array, the replacement will be performed on each of the elements in the array, and the return value will be an array. + * _regexp_ The regular expression matching the target string. If you want it anchored at the start and or end of the string, you must do that with ^ and $ yourself. + * _replacement_ Replacement string. Can contain backreferences to what was matched using \\0 (whole match), \\1 (first set of parentheses), and so on. + * _flags_ Optional. String of single letter flags for how the regexp is interpreted: - *E* Extended regexps - *I* Ignore case in regexps - *M* Multiline regexps - *G* Global replacement; all occurrences of the regexp in each target string will be replaced. Without this, only the first occurrence will be replaced. - - _lang_ Optional. How to handle multibyte characters. A single-character string with the following values: - + * _encoding_ Optional. How to handle multibyte characters. A single-character string with the following values: - *N* None - *E* EUC - *S* SJIS - *U* UTF-8 * *Examples* Get the third octet from the node's IP address: - $i3 = regsubst($ipaddress,'^([0-9]+)[.]([0-9]+)[.]([0-9]+)[.]([0-9]+)$','\\3') + $i3 = regsubst($ipaddress,'^(\\d+)\\.(\\d+)\\.(\\d+)\\.(\\d+)$','\\3') Put angle brackets around each octet in the node's IP address: $x = regsubst($ipaddress, '([0-9]+)', '<\\1>', 'G') ") \ do |args| unless args.length.between?(3, 5) raise( Puppet::ParseError, "regsubst(): got #{args.length} arguments, expected 3 to 5") end target, regexp, replacement, flags, lang = args reflags = 0 operation = :sub if flags == nil flags = [] elsif flags.respond_to?(:split) flags = flags.split('') else raise( Puppet::ParseError, "regsubst(): bad flags parameter #{flags.class}:`#{flags}'") end flags.each do |f| case f when 'G' then operation = :gsub when 'E' then reflags |= Regexp::EXTENDED when 'I' then reflags |= Regexp::IGNORECASE when 'M' then reflags |= Regexp::MULTILINE else raise(Puppet::ParseError, "regsubst(): bad flag `#{f}'") end end begin re = Regexp.compile(regexp, reflags, lang) rescue RegexpError, TypeError raise( Puppet::ParseError, "regsubst(): Bad regular expression `#{regexp}'") end if target.respond_to?(operation) # String parameter -> string result result = target.send(operation, re, replacement) elsif target.respond_to?(:collect) and target.respond_to?(:all?) and target.all? { |e| e.respond_to?(operation) } # Array parameter -> array result result = target.collect { |e| e.send(operation, re, replacement) } else raise( Puppet::ParseError, "regsubst(): bad target #{target.class}:`#{target}'") end return result end end diff --git a/lib/puppet/parser/functions/split.rb b/lib/puppet/parser/functions/split.rb index 52394095a..ad027865b 100644 --- a/lib/puppet/parser/functions/split.rb +++ b/lib/puppet/parser/functions/split.rb @@ -1,29 +1,29 @@ module Puppet::Parser::Functions newfunction( :split, :type => :rvalue, :doc => "\ Split a string variable into an array using the specified split regexp. - Usage: +*Example:* $string = 'v1.v2:v3.v4' $array_var1 = split($string, ':') $array_var2 = split($string, '[.]') $array_var3 = split($string, '[.:]') -$array_var1 now holds the result ['v1.v2', 'v3.v4'], -while $array_var2 holds ['v1', 'v2:v3', 'v4'], and -$array_var3 holds ['v1', 'v2', 'v3', 'v4']. +`$array_var1` now holds the result `['v1.v2', 'v3.v4']`, +while `$array_var2` holds `['v1', 'v2:v3', 'v4']`, and +`$array_var3` holds `['v1', 'v2', 'v3', 'v4']`. -Note that in the second example, we split on a string that contains -a regexp meta-character (.), and that needs protection. A simple +Note that in the second example, we split on a literal string that contains +a regexp meta-character (.), which must be escaped. A simple way to do that for a single character is to enclose it in square -brackets.") do |args| +brackets; a backslash will also escape a single character.") do |args| raise Puppet::ParseError, ("split(): wrong number of arguments (#{args.length}; must be 2)") if args.length != 2 return args[0].split(Regexp.compile(args[1])) end end diff --git a/lib/puppet/parser/grammar.ra b/lib/puppet/parser/grammar.ra index ecb27f363..8339c51b7 100644 --- a/lib/puppet/parser/grammar.ra +++ b/lib/puppet/parser/grammar.ra @@ -1,798 +1,796 @@ # vim: syntax=ruby # the parser class Puppet::Parser::Parser token STRING DQPRE DQMID DQPOST token LBRACK RBRACK LBRACE RBRACE SYMBOL FARROW COMMA TRUE token FALSE EQUALS APPENDS LESSEQUAL NOTEQUAL DOT COLON LLCOLLECT RRCOLLECT token QMARK LPAREN RPAREN ISEQUAL GREATEREQUAL GREATERTHAN LESSTHAN token IF ELSE IMPORT DEFINE ELSIF VARIABLE CLASS INHERITS NODE BOOLEAN token NAME SEMIC CASE DEFAULT AT LCOLLECT RCOLLECT CLASSNAME CLASSREF token NOT OR AND UNDEF PARROW PLUS MINUS TIMES DIV LSHIFT RSHIFT UMINUS token MATCH NOMATCH REGEX IN_EDGE OUT_EDGE IN_EDGE_SUB OUT_EDGE_SUB token IN prechigh right NOT nonassoc UMINUS left IN MATCH NOMATCH left TIMES DIV left MINUS PLUS left LSHIFT RSHIFT left NOTEQUAL ISEQUAL left GREATEREQUAL GREATERTHAN LESSTHAN LESSEQUAL left AND left OR preclow rule program: statements_and_declarations | nil statements_and_declarations: statement_or_declaration { result = ast AST::ASTArray, :children => (val[0] ? [val[0]] : []) } | statements_and_declarations statement_or_declaration { if val[1] val[0].push(val[1]) end result = val[0] } # statements is like statements_and_declarations, but it doesn't allow # nested definitions, classes, or nodes. statements: statements_and_declarations { val[0].each do |stmt| if stmt.is_a?(AST::TopLevelConstruct) error "Classes, definitions, and nodes may only appear at toplevel or inside other classes", \ :line => stmt.context[:line], :file => stmt.context[:file] end end result = val[0] } # The main list of valid statements statement_or_declaration: resource | virtualresource | collection | assignment | casestatement | ifstatement_begin | import | fstatement | definition | hostclass | nodedef | resourceoverride | append | relationship relationship: relationship_side edge relationship_side { result = AST::Relationship.new(val[0], val[2], val[1][:value], ast_context) } | relationship edge relationship_side { result = AST::Relationship.new(val[0], val[2], val[1][:value], ast_context) } relationship_side: resource | resourceref | collection edge: IN_EDGE | OUT_EDGE | IN_EDGE_SUB | OUT_EDGE_SUB fstatement: NAME LPAREN funcvalues RPAREN { result = ast AST::Function, :name => val[0][:value], :line => val[0][:line], :arguments => val[2], :ftype => :statement } | NAME LPAREN funcvalues COMMA RPAREN { result = ast AST::Function, :name => val[0][:value], :line => val[0][:line], :arguments => val[2], :ftype => :statement } | NAME LPAREN RPAREN { result = ast AST::Function, :name => val[0][:value], :line => val[0][:line], :arguments => AST::ASTArray.new({}), :ftype => :statement } | NAME funcvalues { result = ast AST::Function, :name => val[0][:value], :line => val[0][:line], :arguments => val[1], :ftype => :statement } funcvalues: namestring { result = aryfy(val[0]) } | resourceref { result = aryfy(val[0]) } | funcvalues COMMA namestring { val[0].push(val[2]) result = val[0] } | funcvalues COMMA resourceref { val[0].push(val[2]) result = val[0] } # This is *almost* an rvalue, but I couldn't get a full # rvalue to work without scads of shift/reduce conflicts. namestring: name | variable | type | boolean | funcrvalue | selector | quotedtext | hasharrayaccesses | CLASSNAME { result = ast AST::Name, :value => val[0][:value] } resource: classname LBRACE resourceinstances endsemi RBRACE { @lexer.commentpop result = ast(AST::Resource, :type => val[0], :instances => val[2]) } | classname LBRACE params endcomma RBRACE { # This is a deprecated syntax. error "All resource specifications require names" } | classref LBRACE params endcomma RBRACE { # a defaults setting for a type @lexer.commentpop result = ast(AST::ResourceDefaults, :type => val[0], :parameters => val[2]) } # Override a value set elsewhere in the configuration. resourceoverride: resourceref LBRACE anyparams endcomma RBRACE { @lexer.commentpop result = ast AST::ResourceOverride, :object => val[0], :parameters => val[2] } # Exported and virtual resources; these don't get sent to the client # unless they get collected elsewhere in the db. virtualresource: at resource { type = val[0] if (type == :exported and ! Puppet[:storeconfigs]) and ! Puppet[:parseonly] Puppet.warning addcontext("You cannot collect without storeconfigs being set") end error "Defaults are not virtualizable" if val[1].is_a? AST::ResourceDefaults method = type.to_s + "=" # Just mark our resource as exported and pass it through. val[1].send(method, true) result = val[1] } at: AT { result = :virtual } | AT AT { result = :exported } # A collection statement. Currently supports no arguments at all, but eventually # will, I assume. collection: classref collectrhand LBRACE anyparams endcomma RBRACE { @lexer.commentpop Puppet.warning addcontext("Collection names must now be capitalized") if val[0] =~ /^[a-z]/ type = val[0].downcase args = {:type => type} if val[1].is_a?(AST::CollExpr) args[:query] = val[1] args[:query].type = type args[:form] = args[:query].form else args[:form] = val[1] end if args[:form] == :exported and ! Puppet[:storeconfigs] and ! Puppet[:parseonly] Puppet.warning addcontext("You cannot collect exported resources without storeconfigs being set; the collection will be ignored") end args[:override] = val[3] result = ast AST::Collection, args } | classref collectrhand { if val[0] =~ /^[a-z]/ Puppet.warning addcontext("Collection names must now be capitalized") end type = val[0].downcase args = {:type => type } if val[1].is_a?(AST::CollExpr) args[:query] = val[1] args[:query].type = type args[:form] = args[:query].form else args[:form] = val[1] end if args[:form] == :exported and ! Puppet[:storeconfigs] and ! Puppet[:parseonly] Puppet.warning addcontext("You cannot collect exported resources without storeconfigs being set; the collection will be ignored") end result = ast AST::Collection, args } collectrhand: LCOLLECT collstatements RCOLLECT { if val[1] result = val[1] result.form = :virtual else result = :virtual end } | LLCOLLECT collstatements RRCOLLECT { if val[1] result = val[1] result.form = :exported else result = :exported end } # A mini-language for handling collection comparisons. This is organized # to avoid the need for precedence indications. collstatements: nil | collstatement | collstatements colljoin collstatement { result = ast AST::CollExpr, :test1 => val[0], :oper => val[1], :test2 => val[2] } collstatement: collexpr | LPAREN collstatements RPAREN { result = val[1] result.parens = true } colljoin: AND { result=val[0][:value] } | OR { result=val[0][:value] } collexpr: colllval ISEQUAL simplervalue { result = ast AST::CollExpr, :test1 => val[0], :oper => val[1][:value], :test2 => val[2] #result = ast AST::CollExpr #result.push *val } | colllval NOTEQUAL simplervalue { result = ast AST::CollExpr, :test1 => val[0], :oper => val[1][:value], :test2 => val[2] #result = ast AST::CollExpr #result.push *val } colllval: variable | name resourceinst: resourcename COLON params endcomma { result = ast AST::ResourceInstance, :title => val[0], :parameters => val[2] } resourceinstances: resourceinst { result = aryfy(val[0]) } | resourceinstances SEMIC resourceinst { val[0].push val[2] result = val[0] } endsemi: # nothing | SEMIC undef: UNDEF { result = ast AST::Undef, :value => :undef } name: NAME { result = ast AST::Name, :value => val[0][:value], :line => val[0][:line] } type: CLASSREF { result = ast AST::Type, :value => val[0][:value], :line => val[0][:line] } resourcename: quotedtext | name | type | selector | variable | array | hasharrayaccesses assignment: VARIABLE EQUALS expression { raise Puppet::ParseError, "Cannot assign to variables in other namespaces" if val[0][:value] =~ /::/ # this is distinct from referencing a variable variable = ast AST::Name, :value => val[0][:value], :line => val[0][:line] result = ast AST::VarDef, :name => variable, :value => val[2], :line => val[0][:line] } | hasharrayaccess EQUALS expression { result = ast AST::VarDef, :name => val[0], :value => val[2] } append: VARIABLE APPENDS expression { variable = ast AST::Name, :value => val[0][:value], :line => val[0][:line] result = ast AST::VarDef, :name => variable, :value => val[2], :append => true, :line => val[0][:line] } params: # nothing { result = ast AST::ASTArray } | param { result = aryfy(val[0]) } | params COMMA param { val[0].push(val[2]) result = val[0] } param: NAME FARROW rvalue { result = ast AST::ResourceParam, :param => val[0][:value], :line => val[0][:line], :value => val[2] } addparam: NAME PARROW rvalue { result = ast AST::ResourceParam, :param => val[0][:value], :line => val[0][:line], :value => val[2], :add => true } anyparam: param | addparam anyparams: # nothing { result = ast AST::ASTArray } | anyparam { result = aryfy(val[0]) } | anyparams COMMA anyparam { val[0].push(val[2]) result = val[0] } rvalues: rvalue { result = aryfy(val[0]) } | rvalues comma rvalue { result = val[0].push(val[2]) } simplervalue: quotedtext | name | type | boolean | selector | variable rvalue: quotedtext | name | type | boolean | selector | variable | array | hash | hasharrayaccesses | resourceref | funcrvalue | undef # We currently require arguments in these functions. funcrvalue: NAME LPAREN funcvalues RPAREN { result = ast AST::Function, :name => val[0][:value], :line => val[0][:line], :arguments => val[2], :ftype => :rvalue } | NAME LPAREN RPAREN { result = ast AST::Function, :name => val[0][:value], :line => val[0][:line], :arguments => AST::ASTArray.new({}), :ftype => :rvalue } quotedtext: STRING { result = ast AST::String, :value => val[0][:value], :line => val[0][:line] } | DQPRE dqrval { result = ast AST::Concat, :value => [ast(AST::String,val[0])]+val[1], :line => val[0][:line] } dqrval: expression dqtail { result = [val[0]] + val[1] } dqtail: DQPOST { result = [ast(AST::String,val[0])] } | DQMID dqrval { result = [ast(AST::String,val[0])] + val[1] } boolean: BOOLEAN { result = ast AST::Boolean, :value => val[0][:value], :line => val[0][:line] } resourceref: NAME LBRACK rvalues RBRACK { Puppet.warning addcontext("Deprecation notice: Resource references should now be capitalized") result = ast AST::ResourceReference, :type => val[0][:value], :line => val[0][:line], :title => val[2] } | classref LBRACK rvalues RBRACK { result = ast AST::ResourceReference, :type => val[0], :title => val[2] } ifstatement_begin: IF ifstatement { result = val[1] } ifstatement: expression LBRACE statements RBRACE else { @lexer.commentpop args = { :test => val[0], :statements => val[2] } args[:else] = val[4] if val[4] result = ast AST::IfStatement, args } | expression LBRACE RBRACE else { @lexer.commentpop args = { :test => val[0], :statements => ast(AST::Nop) } args[:else] = val[3] if val[3] result = ast AST::IfStatement, args } else: # nothing | ELSIF ifstatement { result = ast AST::Else, :statements => val[1] } | ELSE LBRACE statements RBRACE { @lexer.commentpop result = ast AST::Else, :statements => val[2] } | ELSE LBRACE RBRACE { @lexer.commentpop result = ast AST::Else, :statements => ast(AST::Nop) } # Unlike yacc/bison, it seems racc # gives tons of shift/reduce warnings # with the following syntax: # # expression: ... # | expression arithop expressio { ... } # # arithop: PLUS | MINUS | DIVIDE | TIMES ... # # So I had to develop the expression by adding one rule # per operator :-( expression: rvalue | expression IN rvalue { result = ast AST::InOperator, :lval => val[0], :rval => val[2] } | expression MATCH regex { result = ast AST::MatchOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2] } | expression NOMATCH regex { result = ast AST::MatchOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2] } | expression PLUS expression { result = ast AST::ArithmeticOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2] } | expression MINUS expression { result = ast AST::ArithmeticOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2] } | expression DIV expression { result = ast AST::ArithmeticOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2] } | expression TIMES expression { result = ast AST::ArithmeticOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2] } | expression LSHIFT expression { result = ast AST::ArithmeticOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2] } | expression RSHIFT expression { result = ast AST::ArithmeticOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2] } | MINUS expression =UMINUS { result = ast AST::Minus, :value => val[1] } | expression NOTEQUAL expression { result = ast AST::ComparisonOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2] } | expression ISEQUAL expression { result = ast AST::ComparisonOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2] } | expression GREATERTHAN expression { result = ast AST::ComparisonOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2] } | expression GREATEREQUAL expression { result = ast AST::ComparisonOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2] } | expression LESSTHAN expression { result = ast AST::ComparisonOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2] } | expression LESSEQUAL expression { result = ast AST::ComparisonOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2] } | NOT expression { result = ast AST::Not, :value => val[1] } | expression AND expression { result = ast AST::BooleanOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2] } | expression OR expression { result = ast AST::BooleanOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2] } | LPAREN expression RPAREN { result = val[1] } casestatement: CASE rvalue LBRACE caseopts RBRACE { @lexer.commentpop result = ast AST::CaseStatement, :test => val[1], :options => val[3] } caseopts: caseopt { result = aryfy(val[0]) } | caseopts caseopt { val[0].push val[1] result = val[0] } caseopt: casevalues COLON LBRACE statements RBRACE { @lexer.commentpop result = ast AST::CaseOpt, :value => val[0], :statements => val[3] } | casevalues COLON LBRACE RBRACE { @lexer.commentpop result = ast( AST::CaseOpt, :value => val[0], :statements => ast(AST::ASTArray) ) } casevalues: selectlhand { result = aryfy(val[0]) } | casevalues COMMA selectlhand { val[0].push(val[2]) result = val[0] } selector: selectlhand QMARK svalues { result = ast AST::Selector, :param => val[0], :values => val[2] } svalues: selectval | LBRACE sintvalues endcomma RBRACE { @lexer.commentpop result = val[1] } sintvalues: selectval | sintvalues comma selectval { if val[0].instance_of?(AST::ASTArray) val[0].push(val[2]) result = val[0] else result = ast AST::ASTArray, :children => [val[0],val[2]] end } selectval: selectlhand FARROW rvalue { result = ast AST::ResourceParam, :param => val[0], :value => val[2] } selectlhand: name | type | quotedtext | variable | funcrvalue | boolean | undef + | hasharrayaccess | DEFAULT { result = ast AST::Default, :value => val[0][:value], :line => val[0][:line] } | regex # These are only used for importing, and we don't interpolate there. string: STRING { result = [val[0][:value]] } strings: string | strings COMMA string { result = val[0] += val[2] } import: IMPORT strings { val[1].each do |file| import(file) end result = nil } # Disable definition inheritance for now. 8/27/06, luke #definition: DEFINE NAME argumentlist parent LBRACE statements RBRACE { definition: DEFINE classname argumentlist LBRACE statements RBRACE { @lexer.commentpop result = Puppet::Parser::AST::Definition.new(classname(val[1]), ast_context(true).merge(:arguments => val[2], :code => val[4], :line => val[0][:line])) @lexer.indefine = false #} | DEFINE NAME argumentlist parent LBRACE RBRACE { } | DEFINE classname argumentlist LBRACE RBRACE { @lexer.commentpop result = Puppet::Parser::AST::Definition.new(classname(val[1]), ast_context(true).merge(:arguments => val[2], :line => val[0][:line])) @lexer.indefine = false } #hostclass: CLASS NAME argumentlist parent LBRACE statements RBRACE { hostclass: CLASS classname argumentlist classparent LBRACE statements_and_declarations RBRACE { @lexer.commentpop # Our class gets defined in the parent namespace, not our own. @lexer.namepop result = Puppet::Parser::AST::Hostclass.new(classname(val[1]), ast_context(true).merge(:arguments => val[2], :parent => val[3], :code => val[5], :line => val[0][:line])) } | CLASS classname argumentlist classparent LBRACE RBRACE { @lexer.commentpop # Our class gets defined in the parent namespace, not our own. @lexer.namepop result = Puppet::Parser::AST::Hostclass.new(classname(val[1]), ast_context(true).merge(:arguments => val[2], :parent => val[3], :line => val[0][:line])) } nodedef: NODE hostnames nodeparent LBRACE statements RBRACE { @lexer.commentpop result = Puppet::Parser::AST::Node.new(val[1], ast_context(true).merge(:parent => val[2], :code => val[4], :line => val[0][:line])) } | NODE hostnames nodeparent LBRACE RBRACE { @lexer.commentpop result = Puppet::Parser::AST::Node.new(val[1], ast_context(true).merge(:parent => val[2], :line => val[0][:line])) } classref: CLASSREF { result = val[0][:value] } classname: NAME { result = val[0][:value] } | CLASSNAME { result = val[0][:value] } | CLASS { result = "class" } # Multiple hostnames, as used for node names. These are all literal # strings, not AST objects. hostnames: nodename { result = [result] } | hostnames COMMA nodename { result = val[0] result << val[2] } nodename: hostname { result = ast AST::HostName, :value => val[0] } hostname: NAME { result = val[0][:value] } | STRING { result = val[0][:value] } | DEFAULT { result = val[0][:value] } | regex nil: { result = nil } nothing: { result = ast AST::ASTArray, :children => [] } argumentlist: nil | LPAREN nothing RPAREN { result = nil } | LPAREN arguments RPAREN { result = val[1] result = [result] unless result[0].is_a?(Array) } arguments: argument | arguments COMMA argument { result = val[0] result = [result] unless result[0].is_a?(Array) result << val[2] } argument: NAME EQUALS rvalue { Puppet.warning addcontext("Deprecation notice: must now include '$' in prototype") result = [val[0][:value], val[2]] } | NAME { Puppet.warning addcontext("Deprecation notice: must now include '$' in prototype") result = [val[0][:value]] } | VARIABLE EQUALS rvalue { result = [val[0][:value], val[2]] } | VARIABLE { result = [val[0][:value]] } nodeparent: nil | INHERITS hostname { result = val[1] } classparent: nil | INHERITS classnameordefault { result = val[1] } classnameordefault: classname | DEFAULT variable: VARIABLE { result = ast AST::Variable, :value => val[0][:value], :line => val[0][:line] } array: LBRACK rvalues RBRACK { result = val[1] } | LBRACK rvalues COMMA RBRACK { result = val[1] } | LBRACK RBRACK { result = ast AST::ASTArray } comma: FARROW | COMMA endcomma: # nothing | COMMA { result = nil } regex: REGEX { result = ast AST::Regex, :value => val[0][:value] } hash: LBRACE hashpairs RBRACE { if val[1].instance_of?(AST::ASTHash) result = val[1] else result = ast AST::ASTHash, { :value => val[1] } end } | LBRACE hashpairs COMMA RBRACE { if val[1].instance_of?(AST::ASTHash) result = val[1] else result = ast AST::ASTHash, { :value => val[1] } end } | LBRACE RBRACE { result = ast AST::ASTHash } hashpairs: hashpair | hashpairs COMMA hashpair { if val[0].instance_of?(AST::ASTHash) result = val[0].merge(val[2]) else result = ast AST::ASTHash, :value => val[0] result.merge(val[2]) end } hashpair: key FARROW rvalue { result = ast AST::ASTHash, { :value => { val[0] => val[2] } } } key: NAME { result = val[0][:value] } | quotedtext { result = val[0] } hasharrayaccess: VARIABLE LBRACK rvalue RBRACK { result = ast AST::HashOrArrayAccess, :variable => val[0][:value], :key => val[2] } hasharrayaccesses: hasharrayaccess - | hasharrayaccess LBRACK rvalue RBRACK { + | hasharrayaccesses LBRACK rvalue RBRACK { result = ast AST::HashOrArrayAccess, :variable => val[0], :key => val[2] } end ---- header ---- require 'puppet' require 'puppet/util/loadedfile' require 'puppet/parser/lexer' require 'puppet/parser/ast' module Puppet class ParseError < Puppet::Error; end class ImportError < Racc::ParseError; end class AlreadyImportedError < ImportError; end end ---- inner ---- # It got too annoying having code in a file that needs to be compiled. require 'puppet/parser/parser_support' # Make emacs happy # Local Variables: # mode: ruby # End: - -# $Id$ - diff --git a/lib/puppet/parser/lexer.rb b/lib/puppet/parser/lexer.rb index 31d39ae2f..9a25263f6 100644 --- a/lib/puppet/parser/lexer.rb +++ b/lib/puppet/parser/lexer.rb @@ -1,579 +1,582 @@ # the scanner/lexer require 'strscan' require 'puppet' module Puppet class LexError < RuntimeError; end end module Puppet::Parser; end class Puppet::Parser::Lexer attr_reader :last, :file, :lexing_context, :token_queue attr_accessor :line, :indefine def lex_error msg raise Puppet::LexError.new(msg) end class Token attr_accessor :regex, :name, :string, :skip, :incr_line, :skip_text, :accumulate def initialize(regex, name) if regex.is_a?(String) @name, @string = name, regex @regex = Regexp.new(Regexp.escape(@string)) else @name, @regex = name, regex end end # MQR: Why not just alias? %w{skip accumulate}.each do |method| define_method(method+"?") do self.send(method) end end def to_s if self.string @string else @name.to_s end end def acceptable?(context={}) # By default tokens are aceeptable in any context true end end # Maintain a list of tokens. class TokenList attr_reader :regex_tokens, :string_tokens def [](name) @tokens[name] end # Create a new token. def add_token(name, regex, options = {}, &block) token = Token.new(regex, name) raise(ArgumentError, "Token #{name} already exists") if @tokens.include?(name) @tokens[token.name] = token if token.string @string_tokens << token @tokens_by_string[token.string] = token else @regex_tokens << token end options.each do |name, option| token.send(name.to_s + "=", option) end token.meta_def(:convert, &block) if block_given? token end def initialize @tokens = {} @regex_tokens = [] @string_tokens = [] @tokens_by_string = {} end # Look up a token by its value, rather than name. def lookup(string) @tokens_by_string[string] end # Define more tokens. def add_tokens(hash) hash.each do |regex, name| add_token(name, regex) end end # Sort our tokens by length, so we know once we match, we're done. # This helps us avoid the O(n^2) nature of token matching. def sort_tokens @string_tokens.sort! { |a, b| b.string.length <=> a.string.length } end end TOKENS = TokenList.new TOKENS.add_tokens( '[' => :LBRACK, ']' => :RBRACK, '{' => :LBRACE, '}' => :RBRACE, '(' => :LPAREN, ')' => :RPAREN, '=' => :EQUALS, '+=' => :APPENDS, '==' => :ISEQUAL, '>=' => :GREATEREQUAL, '>' => :GREATERTHAN, '<' => :LESSTHAN, '<=' => :LESSEQUAL, '!=' => :NOTEQUAL, '!' => :NOT, ',' => :COMMA, '.' => :DOT, ':' => :COLON, '@' => :AT, '<<|' => :LLCOLLECT, '->' => :IN_EDGE, '<-' => :OUT_EDGE, '~>' => :IN_EDGE_SUB, '<~' => :OUT_EDGE_SUB, '|>>' => :RRCOLLECT, '<|' => :LCOLLECT, '|>' => :RCOLLECT, ';' => :SEMIC, '?' => :QMARK, '\\' => :BACKSLASH, '=>' => :FARROW, '+>' => :PARROW, '+' => :PLUS, '-' => :MINUS, '/' => :DIV, '*' => :TIMES, '<<' => :LSHIFT, '>>' => :RSHIFT, '=~' => :MATCH, '!~' => :NOMATCH, %r{([a-z][-\w]*)?(::[a-z][-\w]*)+} => :CLASSNAME, # Require '::' in the class name, else we'd compete with NAME %r{((::){0,1}[A-Z][-\w]*)+} => :CLASSREF, "" => :STRING, "" => :DQPRE, "" => :DQMID, "" => :DQPOST, "" => :BOOLEAN ) TOKENS.add_token :NUMBER, %r{\b(?:0[xX][0-9A-Fa-f]+|0?\d+(?:\.\d+)?(?:[eE]-?\d+)?)\b} do |lexer, value| [TOKENS[:NAME], value] end #:stopdoc: # Issue #4161 def (TOKENS[:NUMBER]).acceptable?(context={}) ![:DQPRE,:DQMID].include? context[:after] end #:startdoc: TOKENS.add_token :NAME, %r{[a-z0-9][-\w]*} do |lexer, value| string_token = self # we're looking for keywords here if tmp = KEYWORDS.lookup(value) string_token = tmp if [:TRUE, :FALSE].include?(string_token.name) value = eval(value) string_token = TOKENS[:BOOLEAN] end end [string_token, value] end [:NAME,:CLASSNAME,:CLASSREF].each { |name_token| #:stopdoc: # Issue #4161 def (TOKENS[name_token]).acceptable?(context={}) ![:DQPRE,:DQMID].include? context[:after] end #:startdoc: } TOKENS.add_token :COMMENT, %r{#.*}, :accumulate => true, :skip => true do |lexer,value| value.sub!(/# ?/,'') [self, value] end TOKENS.add_token :MLCOMMENT, %r{/\*(.*?)\*/}m, :accumulate => true, :skip => true do |lexer, value| lexer.line += value.count("\n") value.sub!(/^\/\* ?/,'') value.sub!(/ ?\*\/$/,'') [self,value] end TOKENS.add_token :REGEX, %r{/[^/\n]*/} do |lexer, value| # Make sure we haven't matched an escaped / while value[-2..-2] == '\\' other = lexer.scan_until(%r{/}) value += other end regex = value.sub(%r{\A/}, "").sub(%r{/\Z}, '').gsub("\\/", "/") [self, Regexp.new(regex)] end #:stopdoc: # Issue #4161 def (TOKENS[:REGEX]).acceptable?(context={}) [:NODE,:LBRACE,:RBRACE,:MATCH,:NOMATCH,:COMMA].include? context[:after] end #:startdoc: TOKENS.add_token :RETURN, "\n", :skip => true, :incr_line => true, :skip_text => true TOKENS.add_token :SQUOTE, "'" do |lexer, value| [TOKENS[:STRING], lexer.slurpstring(value,["'"],:ignore_invalid_escapes).first ] end DQ_initial_token_types = {'$' => :DQPRE,'"' => :STRING} DQ_continuation_token_types = {'$' => :DQMID,'"' => :DQPOST} TOKENS.add_token :DQUOTE, /"/ do |lexer, value| lexer.tokenize_interpolated_string(DQ_initial_token_types) end TOKENS.add_token :DQCONT, /\}/ do |lexer, value| lexer.tokenize_interpolated_string(DQ_continuation_token_types) end #:stopdoc: # Issue #4161 def (TOKENS[:DQCONT]).acceptable?(context={}) context[:string_interpolation_depth] > 0 end #:startdoc: TOKENS.add_token :DOLLAR_VAR, %r{\$(\w*::)*\w+} do |lexer, value| [TOKENS[:VARIABLE],value[1..-1]] end TOKENS.add_token :VARIABLE, %r{(\w*::)*\w+} #:stopdoc: # Issue #4161 def (TOKENS[:VARIABLE]).acceptable?(context={}) [:DQPRE,:DQMID].include? context[:after] end #:startdoc: TOKENS.sort_tokens @@pairs = { "{" => "}", "(" => ")", "[" => "]", "<|" => "|>", "<<|" => "|>>" } KEYWORDS = TokenList.new KEYWORDS.add_tokens( "case" => :CASE, "class" => :CLASS, "default" => :DEFAULT, "define" => :DEFINE, "import" => :IMPORT, "if" => :IF, "elsif" => :ELSIF, "else" => :ELSE, "inherits" => :INHERITS, "node" => :NODE, "and" => :AND, "or" => :OR, "undef" => :UNDEF, "false" => :FALSE, "true" => :TRUE, "in" => :IN ) def clear initvars end def expected return nil if @expected.empty? name = @expected[-1] TOKENS.lookup(name) or lex_error "Could not find expected token #{name}" end # scan the whole file # basically just used for testing def fullscan array = [] self.scan { |token, str| # Ignore any definition nesting problems @indefine = false array.push([token,str]) } array end def file=(file) @file = file @line = 1 @scanner = StringScanner.new(File.read(file)) end def shift_token @token_queue.shift end def find_string_token # We know our longest string token is three chars, so try each size in turn # until we either match or run out of chars. This way our worst-case is three # tries, where it is otherwise the number of string token we have. Also, # the lookups are optimized hash lookups, instead of regex scans. # s = @scanner.peek(3) token = TOKENS.lookup(s[0,3]) || TOKENS.lookup(s[0,2]) || TOKENS.lookup(s[0,1]) [ token, token && @scanner.scan(token.regex) ] end # Find the next token that matches a regex. We look for these first. def find_regex_token @regex += 1 best_token = nil best_length = 0 # I tried optimizing based on the first char, but it had # a slightly negative affect and was a good bit more complicated. TOKENS.regex_tokens.each do |token| if length = @scanner.match?(token.regex) and token.acceptable?(lexing_context) # We've found a longer match if length > best_length best_length = length best_token = token end end end return best_token, @scanner.scan(best_token.regex) if best_token end # Find the next token, returning the string and the token. def find_token @find += 1 shift_token || find_regex_token || find_string_token end def indefine? if defined?(@indefine) @indefine else false end end def initialize @find = 0 @regex = 0 initvars end def initvars @line = 1 @previous_token = nil @scanner = nil @file = nil # AAARRGGGG! okay, regexes in ruby are bloody annoying # no one else has "\n" =~ /\s/ @skip = %r{[ \t\r]+} @namestack = [] @token_queue = [] @indefine = false @expected = [] @commentstack = [ ['', @line] ] @lexing_context = { :after => nil, :start_of_line => true, :string_interpolation_depth => 0 } end # Make any necessary changes to the token and/or value. def munge_token(token, value) @line += 1 if token.incr_line skip if token.skip_text return if token.skip and not token.accumulate? token, value = token.convert(self, value) if token.respond_to?(:convert) return unless token if token.accumulate? comment = @commentstack.pop comment[0] << value + "\n" @commentstack.push(comment) end return if token.skip return token, { :value => value, :line => @line } end # Go up one in the namespace. def namepop @namestack.pop end # Collect the current namespace. def namespace @namestack.join("::") end # This value might have :: in it, but we don't care -- it'll be # handled normally when joining, and when popping we want to pop # this full value, however long the namespace is. def namestack(value) @namestack << value end def rest @scanner.rest end # this is the heart of the lexer def scan #Puppet.debug("entering scan") lex_error "Invalid or empty string" unless @scanner # Skip any initial whitespace. skip until token_queue.empty? and @scanner.eos? do yielded = false matched_token, value = find_token # error out if we didn't match anything at all lex_error "Could not match #{@scanner.rest[/^(\S+|\s+|.*)/]}" unless matched_token newline = matched_token.name == :RETURN # this matches a blank line; eat the previously accumulated comments getcomment if lexing_context[:start_of_line] and newline lexing_context[:start_of_line] = newline final_token, token_value = munge_token(matched_token, value) unless final_token skip next end lexing_context[:after] = final_token.name unless newline lexing_context[:string_interpolation_depth] += 1 if final_token.name == :DQPRE lexing_context[:string_interpolation_depth] -= 1 if final_token.name == :DQPOST value = token_value[:value] if match = @@pairs[value] and final_token.name != :DQUOTE and final_token.name != :SQUOTE @expected << match elsif exp = @expected[-1] and exp == value and final_token.name != :DQUOTE and final_token.name != :SQUOTE @expected.pop end - if final_token.name == :LBRACE + if final_token.name == :LBRACE or final_token.name == :LPAREN commentpush end + if final_token.name == :RPAREN + commentpop + end yield [final_token.name, token_value] if @previous_token namestack(value) if @previous_token.name == :CLASS and value != '{' if @previous_token.name == :DEFINE if indefine? msg = "Cannot nest definition #{value} inside #{@indefine}" self.indefine = false raise Puppet::ParseError, msg end @indefine = value end end @previous_token = final_token skip end @scanner = nil # This indicates that we're done parsing. yield [false,false] end # Skip any skipchars in our remaining string. def skip @scanner.skip(@skip) end # Provide some limited access to the scanner, for those # tokens that need it. def scan_until(regex) @scanner.scan_until(regex) end # we've encountered the start of a string... # slurp in the rest of the string and return it def slurpstring(terminators,escapes=%w{ \\ $ ' " n t s }+["\n"],ignore_invalid_escapes=false) # we search for the next quote that isn't preceded by a # backslash; the caret is there to match empty strings str = @scanner.scan_until(/([^\\]|^|[^\\])([\\]{2})*[#{terminators}]/) or lex_error "Unclosed quote after '#{last}' in '#{rest}'" @line += str.count("\n") # literal carriage returns add to the line count. str.gsub!(/\\(.)/m) { ch = $1 if escapes.include? ch case ch when 'n'; "\n" when 't'; "\t" when 's'; " " when "\n": '' else ch end else Puppet.warning "Unrecognised escape sequence '\\#{ch}'#{file && " in file #{file}"}#{line && " at line #{line}"}" unless ignore_invalid_escapes "\\#{ch}" end } [ str[0..-2],str[-1,1] ] end def tokenize_interpolated_string(token_type,preamble='') value,terminator = slurpstring('"$') token_queue << [TOKENS[token_type[terminator]],preamble+value] if terminator != '$' or @scanner.scan(/\{/) token_queue.shift elsif var_name = @scanner.scan(%r{(\w*::)*\w+|[0-9]}) token_queue << [TOKENS[:VARIABLE],var_name] tokenize_interpolated_string(DQ_continuation_token_types) else tokenize_interpolated_string(token_type,token_queue.pop.last + terminator) end end # just parse a string, not a whole file def string=(string) @scanner = StringScanner.new(string) end # returns the content of the currently accumulated content cache def commentpop @commentstack.pop[0] end def getcomment(line = nil) comment = @commentstack.last if line.nil? or comment[1] <= line @commentstack.pop @commentstack.push(['', @line]) return comment[0] end '' end def commentpush @commentstack.push(['', @line]) end end diff --git a/lib/puppet/parser/parser.rb b/lib/puppet/parser/parser.rb index 60b272e76..300ddddd6 100644 --- a/lib/puppet/parser/parser.rb +++ b/lib/puppet/parser/parser.rb @@ -1,2513 +1,2616 @@ # # DO NOT MODIFY!!!! -# This file is automatically generated by racc 1.4.5 -# from racc grammer file "grammar.ra". +# This file is automatically generated by Racc 1.4.6 +# from Racc grammer file "". # -require 'racc/parser' - +require 'racc/parser.rb' require 'puppet' require 'puppet/util/loadedfile' require 'puppet/parser/lexer' require 'puppet/parser/ast' module Puppet class ParseError < Puppet::Error; end class ImportError < Racc::ParseError; end class AlreadyImportedError < ImportError; end end - module Puppet - module Parser - class Parser < Racc::Parser -module_eval <<'..end grammar.ra modeval..id6362f948d9', 'grammar.ra', 788 +module_eval(<<'...end grammar.ra/module_eval...', 'grammar.ra', 789) # It got too annoying having code in a file that needs to be compiled. require 'puppet/parser/parser_support' # Make emacs happy # Local Variables: # mode: ruby # End: - -# $Id$ - -..end grammar.ra modeval..id6362f948d9 - -##### racc 1.4.5 generates ### - -racc_reduce_table = [ - 0, 0, :racc_error, - 1, 70, :_reduce_none, - 1, 70, :_reduce_none, - 1, 71, :_reduce_3, - 2, 71, :_reduce_4, - 1, 74, :_reduce_5, - 1, 73, :_reduce_none, - 1, 73, :_reduce_none, - 1, 73, :_reduce_none, - 1, 73, :_reduce_none, - 1, 73, :_reduce_none, - 1, 73, :_reduce_none, - 1, 73, :_reduce_none, - 1, 73, :_reduce_none, - 1, 73, :_reduce_none, - 1, 73, :_reduce_none, - 1, 73, :_reduce_none, - 1, 73, :_reduce_none, - 1, 73, :_reduce_none, - 1, 73, :_reduce_none, - 3, 88, :_reduce_20, - 3, 88, :_reduce_21, - 1, 89, :_reduce_none, - 1, 89, :_reduce_none, - 1, 89, :_reduce_none, - 1, 90, :_reduce_none, - 1, 90, :_reduce_none, - 1, 90, :_reduce_none, - 1, 90, :_reduce_none, - 4, 82, :_reduce_29, - 5, 82, :_reduce_30, - 3, 82, :_reduce_31, - 2, 82, :_reduce_32, - 1, 92, :_reduce_33, - 1, 92, :_reduce_34, - 3, 92, :_reduce_35, - 3, 92, :_reduce_36, - 1, 93, :_reduce_none, - 1, 93, :_reduce_none, - 1, 93, :_reduce_none, - 1, 93, :_reduce_none, - 1, 93, :_reduce_none, - 1, 93, :_reduce_none, - 1, 93, :_reduce_none, - 1, 93, :_reduce_none, - 1, 93, :_reduce_45, - 5, 75, :_reduce_46, - 5, 75, :_reduce_47, - 5, 75, :_reduce_48, - 5, 86, :_reduce_49, - 2, 76, :_reduce_50, - 1, 109, :_reduce_51, - 2, 109, :_reduce_52, - 6, 77, :_reduce_53, - 2, 77, :_reduce_54, - 3, 110, :_reduce_55, - 3, 110, :_reduce_56, - 1, 111, :_reduce_none, - 1, 111, :_reduce_none, - 3, 111, :_reduce_59, - 1, 112, :_reduce_none, - 3, 112, :_reduce_61, - 1, 113, :_reduce_62, - 1, 113, :_reduce_63, - 3, 114, :_reduce_64, - 3, 114, :_reduce_65, - 1, 115, :_reduce_none, - 1, 115, :_reduce_none, - 4, 117, :_reduce_68, - 1, 103, :_reduce_69, - 3, 103, :_reduce_70, - 0, 104, :_reduce_none, - 1, 104, :_reduce_none, - 1, 119, :_reduce_73, - 1, 94, :_reduce_74, - 1, 96, :_reduce_75, - 1, 118, :_reduce_none, - 1, 118, :_reduce_none, - 1, 118, :_reduce_none, - 1, 118, :_reduce_none, - 1, 118, :_reduce_none, - 1, 118, :_reduce_none, - 1, 118, :_reduce_none, - 3, 78, :_reduce_83, - 3, 78, :_reduce_84, - 3, 87, :_reduce_85, - 0, 105, :_reduce_86, - 1, 105, :_reduce_87, - 3, 105, :_reduce_88, - 3, 123, :_reduce_89, - 3, 125, :_reduce_90, - 1, 126, :_reduce_none, - 1, 126, :_reduce_none, - 0, 108, :_reduce_93, - 1, 108, :_reduce_94, - 3, 108, :_reduce_95, - 1, 127, :_reduce_96, - 3, 127, :_reduce_97, - 1, 116, :_reduce_none, - 1, 116, :_reduce_none, - 1, 116, :_reduce_none, - 1, 116, :_reduce_none, - 1, 116, :_reduce_none, - 1, 116, :_reduce_none, - 1, 124, :_reduce_none, - 1, 124, :_reduce_none, - 1, 124, :_reduce_none, - 1, 124, :_reduce_none, - 1, 124, :_reduce_none, - 1, 124, :_reduce_none, - 1, 124, :_reduce_none, - 1, 124, :_reduce_none, - 1, 124, :_reduce_none, - 1, 124, :_reduce_none, - 1, 124, :_reduce_none, - 1, 124, :_reduce_none, - 4, 98, :_reduce_116, - 3, 98, :_reduce_117, - 1, 100, :_reduce_118, - 2, 100, :_reduce_119, - 2, 130, :_reduce_120, - 1, 131, :_reduce_121, - 2, 131, :_reduce_122, - 1, 97, :_reduce_123, - 4, 91, :_reduce_124, - 4, 91, :_reduce_125, - 2, 80, :_reduce_126, - 5, 132, :_reduce_127, - 4, 132, :_reduce_128, - 0, 133, :_reduce_none, - 2, 133, :_reduce_130, - 4, 133, :_reduce_131, - 3, 133, :_reduce_132, - 1, 121, :_reduce_none, - 3, 121, :_reduce_134, - 3, 121, :_reduce_135, - 3, 121, :_reduce_136, - 3, 121, :_reduce_137, - 3, 121, :_reduce_138, - 3, 121, :_reduce_139, - 3, 121, :_reduce_140, - 3, 121, :_reduce_141, - 3, 121, :_reduce_142, - 2, 121, :_reduce_143, - 3, 121, :_reduce_144, - 3, 121, :_reduce_145, - 3, 121, :_reduce_146, - 3, 121, :_reduce_147, - 3, 121, :_reduce_148, - 3, 121, :_reduce_149, - 2, 121, :_reduce_150, - 3, 121, :_reduce_151, - 3, 121, :_reduce_152, - 3, 121, :_reduce_153, - 5, 79, :_reduce_154, - 1, 135, :_reduce_155, - 2, 135, :_reduce_156, - 5, 136, :_reduce_157, - 4, 136, :_reduce_158, - 1, 137, :_reduce_159, - 3, 137, :_reduce_160, - 3, 99, :_reduce_161, - 1, 139, :_reduce_none, - 4, 139, :_reduce_163, - 1, 141, :_reduce_none, - 3, 141, :_reduce_165, - 3, 140, :_reduce_166, - 1, 138, :_reduce_none, - 1, 138, :_reduce_none, - 1, 138, :_reduce_none, - 1, 138, :_reduce_none, - 1, 138, :_reduce_none, - 1, 138, :_reduce_none, - 1, 138, :_reduce_none, - 1, 138, :_reduce_174, - 1, 138, :_reduce_none, - 1, 142, :_reduce_176, - 1, 143, :_reduce_none, - 3, 143, :_reduce_178, - 2, 81, :_reduce_179, - 6, 83, :_reduce_180, - 5, 83, :_reduce_181, - 7, 84, :_reduce_182, - 6, 84, :_reduce_183, - 6, 85, :_reduce_184, - 5, 85, :_reduce_185, - 1, 107, :_reduce_186, - 1, 102, :_reduce_187, - 1, 102, :_reduce_188, - 1, 102, :_reduce_189, - 1, 146, :_reduce_190, - 3, 146, :_reduce_191, - 1, 148, :_reduce_192, - 1, 149, :_reduce_193, - 1, 149, :_reduce_194, - 1, 149, :_reduce_195, - 1, 149, :_reduce_none, - 0, 72, :_reduce_197, - 0, 150, :_reduce_198, - 1, 144, :_reduce_none, - 3, 144, :_reduce_200, - 3, 144, :_reduce_201, - 1, 151, :_reduce_none, - 3, 151, :_reduce_203, - 3, 152, :_reduce_204, - 1, 152, :_reduce_205, - 3, 152, :_reduce_206, - 1, 152, :_reduce_207, - 1, 147, :_reduce_none, - 2, 147, :_reduce_209, - 1, 145, :_reduce_none, - 2, 145, :_reduce_211, - 1, 153, :_reduce_none, - 1, 153, :_reduce_none, - 1, 95, :_reduce_214, - 3, 120, :_reduce_215, - 4, 120, :_reduce_216, - 2, 120, :_reduce_217, - 1, 128, :_reduce_none, - 1, 128, :_reduce_none, - 0, 106, :_reduce_none, - 1, 106, :_reduce_221, - 1, 134, :_reduce_222, - 3, 129, :_reduce_223, - 4, 129, :_reduce_224, - 2, 129, :_reduce_225, - 1, 154, :_reduce_none, - 3, 154, :_reduce_227, - 3, 155, :_reduce_228, - 1, 156, :_reduce_229, - 1, 156, :_reduce_230, - 4, 122, :_reduce_231, - 1, 101, :_reduce_none, - 4, 101, :_reduce_233 ] - -racc_reduce_n = 234 - -racc_shift_n = 385 +...end grammar.ra/module_eval... +##### State transition tables begin ### racc_action_table = [ - 242, 243, 55, 231, 356, 112, 157, 113, 78, 298, - 68, 71, 357, 181, 186, 326, 344, 340, 55, 295, - 114, 231, 177, 179, 182, 185, 170, 294, 68, 71, - 286, 158, 100, 285, 103, 68, 71, 291, 292, 55, - 59, 291, 292, 61, 111, 233, 180, 184, 198, 231, - 189, 172, 173, 174, 176, 178, 59, 183, 187, 61, - -168, 66, 170, 60, 175, 79, 81, 186, 202, 88, - 112, 166, 79, 252, 74, 177, 88, 59, 84, 60, - 61, 139, 68, 71, 333, 84, 100, 117, 103, 60, - 36, -170, 68, 71, 38, 306, 60, 307, 203, 240, - 60, 10, 203, 189, 172, 173, 174, 176, 178, 202, - 183, 187, 241, 202, 209, 66, 218, 175, 209, 79, - 81, 219, 284, 88, 309, 202, 256, 283, 74, 79, - 252, 308, 84, 88, 203, 68, 71, 310, 139, 100, - 203, 103, 84, 60, 218, 202, 256, 367, 36, 219, - 209, 202, 38, 60, 68, 71, 209, 95, 100, 10, - 103, 68, 71, 68, 71, 100, 337, 103, 66, 335, - 199, 154, 79, 81, 173, 174, 88, 183, 187, 183, - 187, 74, 99, 95, 175, 84, 175, 66, 90, 311, - 337, 79, 81, 335, 66, 88, 60, 287, 79, 81, - 74, 198, 88, 315, 84, 68, 71, 74, 99, -172, - 213, 84, 68, 71, 90, 60, 100, 36, 103, 68, - 71, 38, 60, 100, 318, 103, 68, 71, 10, 15, - 36, -167, 213, 355, 38, 167, 36, 313, 202, 154, - 127, 10, 79, 252, 323, 66, 88, 10, 15, 79, - 81, 139, 66, 88, 166, 84, 79, 81, 74, 202, - 88, 229, 84, 79, 252, 74, 60, 88, 49, 84, - 68, 71, 139, 60, 78, -186, 84, 47, 48, 49, - 60, 329, 36, 170, 183, 187, 127, 60, -169, 68, - 71, 175, 70, 10, 15, 68, 71, 161, -171, 100, - 289, 103, -169, 66, 291, 292, 60, 79, 81, 258, - -167, 88, -170, 256, 257, 72, 74, 95, -168, 60, - 84, 156, 66, 154, 68, 71, 79, 81, 66, 122, - 88, 60, 79, 81, 72, 74, 88, -170, -173, 84, - -172, 74, 99, 68, 71, 84, -171, 100, 90, 103, - 60, 200, 334, 68, 71, 213, 60, 202, 215, 254, - 338, 79, 252, 173, 174, 88, 122, 296, 183, 187, - 139, 256, 257, 216, 84, 175, 66, 234, 68, 71, - 79, 81, 113, 117, 88, 60, 202, 217, 78, 74, - 79, 252, 353, 84, 88, 53, 68, 71, 223, 139, - 100, 260, 103, 84, 60, 43, 44, 40, 41, 358, - 52, 66, 51, 225, 60, 79, 81, -169, 229, 88, - 365, 68, 71, 72, 74, 100, 238, 103, 84, 66, - 228, -167, 234, 79, 81, 372, 373, 88, -169, 60, - -167, -170, 74, 95, -168, -172, 84, 68, 71, 45, - 375, 100, 229, 103, 66, -221, 232, 60, 79, 81, - 378, 39, 88, -24, -24, -24, -24, 74, 99, 95, - -168, 84, 383, 384, 90, nil, nil, 68, 71, nil, - 66, 100, 60, 103, 79, 81, nil, nil, 88, -22, - -22, -22, -22, 74, 99, nil, nil, 84, nil, 95, - 90, nil, nil, 68, 71, nil, nil, 100, 60, 103, - 66, nil, nil, nil, 79, 81, nil, nil, 88, 43, - 44, 40, 41, 74, 99, 95, nil, 84, nil, nil, - 90, nil, nil, 68, 71, nil, 66, 100, 60, 103, - 79, 81, nil, nil, 88, nil, nil, nil, nil, 74, - 99, nil, nil, 84, nil, 95, 90, nil, nil, 68, - 71, nil, nil, 100, 60, 103, 66, nil, nil, nil, - 79, 81, nil, nil, 88, nil, nil, 68, 71, 74, - 99, 100, nil, 84, 68, 71, 90, nil, 100, nil, - 103, nil, 66, nil, 60, nil, 79, 81, nil, nil, - 88, nil, nil, nil, nil, 74, 95, nil, nil, 84, - 66, nil, nil, nil, 79, 144, nil, 66, 88, nil, - 60, 79, 81, 139, nil, 88, nil, 84, nil, nil, - 74, 99, nil, nil, 84, 68, 71, 90, 60, 100, - nil, 103, nil, nil, nil, 60, nil, nil, nil, nil, - nil, nil, nil, nil, 68, 71, nil, 95, 100, nil, - 103, 68, 71, nil, nil, 100, nil, 103, 66, nil, - nil, nil, 79, 81, nil, nil, 88, nil, nil, 68, - 71, 74, 99, nil, nil, 84, nil, 66, 90, nil, - nil, 79, 81, nil, 66, 88, 60, nil, 79, 81, - 74, nil, 88, nil, 84, 68, 71, 74, nil, nil, - nil, 84, 202, nil, nil, 60, 79, 252, nil, nil, - 88, nil, 60, nil, nil, 139, 68, 71, 162, 84, - 100, nil, 103, nil, nil, nil, nil, nil, 66, nil, - 60, nil, 79, 81, nil, nil, 88, nil, 95, nil, - 72, 74, 68, 71, nil, 84, 100, nil, 103, 66, - nil, nil, nil, 79, 81, nil, 60, 88, nil, nil, - nil, nil, 74, 99, 95, nil, 84, 68, 71, 90, - nil, nil, nil, nil, nil, 66, nil, 60, nil, 79, + 242, 243, 55, 68, 71, 299, 157, 55, 78, 117, + 199, 68, 71, 181, 186, -169, 36, 112, 341, 113, + 38, 55, 177, 179, 182, 185, 170, 10, 68, 71, + 231, 158, 114, 292, 293, 356, 257, 368, 68, 71, + 59, 198, 100, 61, 103, 59, 180, 184, 61, 198, + 189, 172, 173, 174, 176, 178, 111, 183, 187, 59, + 95, 66, 61, 60, 175, 79, 253, 154, 60, 88, + 345, 66, 233, 229, 139, 79, 81, 231, 84, 88, + 68, 71, 60, 225, 74, 99, 68, 71, 84, 60, + 100, 90, 103, 203, 203, 292, 293, 223, 296, 60, + 203, 117, 231, 78, 202, 202, 295, 240, 95, 209, + 209, 202, 166, 66, 186, 170, 209, 79, 253, 66, + 241, 88, 177, 79, 81, 334, 139, 88, 68, 71, + 84, 310, 74, 99, 68, 71, 84, 357, 100, 90, + 103, 60, 183, 187, 311, 358, 307, 60, 308, 175, + 189, 172, 173, 174, 176, 178, 95, 183, 187, 36, + 309, 66, 288, 38, 175, 79, 253, 66, 218, 88, + 10, 79, 81, 219, 139, 88, 338, 312, 84, 336, + 74, 99, 68, 71, 84, 218, 100, 90, 103, 60, + 219, 173, 174, 217, 285, 60, 183, 187, 257, 284, + 203, 68, 71, 175, 95, 100, 36, 103, 68, 71, + 127, 202, 100, 316, 103, 66, 209, 10, 15, 79, + 81, 173, 174, 88, 183, 187, 183, 187, 74, 99, + 95, 175, 84, 175, 66, 90, 113, 338, 79, 81, + 336, 66, 88, 60, 213, 79, 81, 74, 319, 88, + 216, 84, 68, 71, 74, 99, 213, 49, 84, 68, + 71, 90, 60, 100, 215, 103, 47, 48, 287, 60, + 154, 286, 189, 172, 173, 174, 324, 68, 71, 183, + 187, 100, 213, 103, 36, 66, 175, 327, 38, 79, + 253, 314, 66, 88, 200, 10, 79, 81, 139, 95, + 88, -171, 84, 68, 71, 74, 330, 78, 170, 84, + 66, -172, 259, 60, 79, 81, 257, 258, 88, -173, + 60, -168, -170, 74, 99, 70, 228, 84, 68, 71, + 90, 36, 100, -167, 103, 127, 66, -167, 60, 161, + 79, 81, 10, 15, 88, -169, -171, 297, 72, 74, + 95, 257, 258, 84, 68, 71, 36, -172, 100, -168, + 38, 66, 112, -170, 60, 79, 81, 10, 15, 88, + -22, -22, -22, -22, 74, 99, 68, 71, 84, 290, + 100, 90, 103, 292, 293, -167, 167, 66, 166, 60, + 335, 79, 253, 229, -187, 88, 339, 68, 71, 161, + 139, 100, 49, 103, 84, 43, 44, 40, 41, 66, + 234, -169, -174, 79, 81, 60, 156, 88, 154, 68, + 71, 354, 74, 100, 122, 103, 84, 122, 359, 161, + 66, 60, -170, 53, 79, 81, 229, 60, 88, 366, + 68, 71, 52, 74, 100, -168, 103, 84, 43, 44, + 40, 41, 66, 232, 51, 373, 79, 81, 60, 374, + 88, -169, 95, -167, -170, 74, 68, 71, -168, 84, + 100, -172, 103, 66, 60, 376, 45, 79, 81, -222, + 60, 88, -24, -24, -24, -24, 74, 99, 95, 234, + 84, 379, 238, 90, 39, 384, 68, 71, 385, 66, + 100, 60, 103, 79, 81, nil, nil, 88, nil, nil, + nil, nil, 74, 99, nil, nil, 84, nil, 95, 90, + nil, nil, 68, 71, nil, nil, 100, 60, 103, 66, + nil, nil, nil, 79, 81, nil, nil, 88, nil, nil, + nil, nil, 74, 99, 95, nil, 84, nil, nil, 90, + nil, nil, 68, 71, nil, 66, 100, 60, 103, 79, + 81, nil, nil, 88, nil, nil, nil, nil, 74, 99, + nil, nil, 84, nil, 95, 90, nil, nil, 68, 71, + nil, nil, 100, 60, 103, 66, nil, nil, nil, 79, 81, nil, nil, 88, nil, nil, nil, nil, 74, 99, - 327, nil, 84, 68, 71, 90, nil, 100, nil, 103, - 66, nil, nil, 60, 79, 81, nil, nil, 88, nil, - nil, nil, 72, 74, nil, 95, nil, 84, 68, 71, - nil, nil, 100, nil, 103, nil, 66, nil, 60, nil, - 79, 81, 68, 71, 88, nil, 100, nil, 103, 74, - 99, nil, nil, 84, nil, nil, 90, nil, nil, nil, - nil, 66, nil, nil, 60, 79, 81, 68, 71, 88, - nil, 100, nil, 103, 74, 66, nil, nil, 84, 79, - 81, 68, 71, 88, nil, 100, nil, nil, 74, 60, - nil, nil, 84, nil, nil, nil, nil, nil, nil, nil, - 66, nil, nil, 60, 79, 81, nil, nil, 88, nil, - nil, 68, 71, 74, 66, nil, nil, 84, 79, 252, - nil, nil, 88, nil, nil, nil, nil, 139, 60, 68, - 71, 84, nil, 100, nil, 103, nil, nil, nil, nil, - nil, nil, 60, nil, 202, nil, nil, nil, 79, 252, - nil, 95, 88, nil, nil, nil, nil, 139, nil, 68, - 71, 84, 66, 100, nil, 103, 79, 81, nil, nil, - 88, nil, 60, nil, nil, 74, 99, nil, nil, 84, - nil, 95, 90, nil, nil, 68, 71, nil, nil, 100, - 60, 103, 66, nil, nil, nil, 79, 81, nil, nil, + 95, nil, 84, nil, nil, 90, nil, nil, 68, 71, + nil, 66, 100, 60, 103, 79, 81, nil, nil, 88, + nil, nil, nil, nil, 74, 99, nil, nil, 84, nil, + 95, 90, nil, nil, 68, 71, nil, nil, 100, 60, + 103, 66, nil, nil, nil, 79, 81, nil, nil, 88, + 68, 71, nil, nil, 74, 99, 68, 71, 84, nil, + 100, 90, 103, nil, nil, nil, nil, 66, nil, 60, + nil, 79, 81, nil, nil, 88, nil, nil, 95, nil, + 74, 68, 71, 66, 84, 100, nil, 79, 253, 66, + nil, 88, nil, 79, 81, 60, 139, 88, nil, nil, + 84, nil, 74, 99, nil, nil, 84, 68, 71, 90, + nil, 60, nil, nil, 66, nil, nil, 60, 79, 144, + nil, nil, 88, nil, nil, nil, nil, 139, 68, 71, + nil, 84, 100, nil, 103, nil, nil, nil, nil, nil, + 66, nil, 60, nil, 79, 253, 68, 71, 88, nil, + 100, nil, 103, 139, nil, nil, nil, 84, nil, nil, + nil, 66, nil, nil, nil, 79, 81, nil, 60, 88, + nil, 68, 71, nil, 74, nil, nil, nil, 84, 66, + nil, nil, nil, 79, 81, nil, nil, 88, nil, 60, + nil, nil, 74, nil, 261, nil, 84, 68, 71, nil, + nil, 100, nil, 103, 66, nil, nil, 60, 79, 81, + nil, nil, 88, nil, nil, nil, 72, 74, 68, 71, + nil, 84, 100, nil, 103, nil, nil, nil, nil, nil, + 66, nil, 60, nil, 79, 81, nil, nil, 88, nil, + 95, nil, nil, 74, 68, 71, nil, 84, nil, nil, + nil, 66, nil, nil, nil, 79, 81, nil, 60, 88, + nil, nil, nil, nil, 74, 99, nil, 162, 84, 68, + 71, 90, nil, 100, nil, 103, nil, 66, nil, 60, + nil, 79, 81, nil, nil, 88, nil, nil, nil, 72, + 74, 95, nil, nil, 84, 68, 71, nil, nil, 100, + nil, 103, 66, nil, nil, 60, 79, 81, nil, nil, 88, nil, nil, nil, nil, 74, 99, 95, nil, 84, - nil, nil, 90, nil, nil, 68, 71, nil, 66, 100, - 60, 103, 79, 81, nil, nil, 88, nil, nil, nil, - nil, 74, 99, nil, nil, 84, nil, 95, 90, nil, - nil, 68, 71, nil, nil, 100, 60, 103, 66, nil, - nil, nil, 79, 81, nil, nil, 88, nil, nil, nil, - nil, 74, 99, 95, nil, 84, nil, nil, 90, nil, - nil, 68, 71, nil, 66, 100, 60, 103, 79, 81, - nil, nil, 88, nil, nil, nil, nil, 74, 99, nil, - nil, 84, nil, 95, 90, nil, nil, 68, 71, nil, - nil, 100, 60, 103, 66, nil, nil, nil, 79, 81, + 68, 71, 90, nil, 100, nil, 103, nil, 66, nil, + 60, nil, 79, 81, 68, 71, 88, nil, nil, nil, + 255, 74, 99, nil, nil, 84, nil, nil, 90, nil, + nil, nil, nil, 66, nil, nil, 60, 79, 81, 68, + 71, 88, nil, 100, nil, 103, 74, 66, nil, nil, + 84, 79, 253, nil, nil, 88, nil, nil, 68, 71, + 139, 60, nil, nil, 84, nil, nil, nil, nil, nil, + nil, nil, 66, nil, nil, 60, 79, 81, nil, nil, + 88, 328, nil, 68, 71, 74, nil, nil, nil, 84, + nil, 66, nil, nil, nil, 79, 81, nil, nil, 88, + 60, 68, 71, 72, 74, 100, 193, 103, 84, nil, + nil, nil, nil, nil, nil, nil, 66, nil, nil, 60, + 79, 253, 68, 71, 88, nil, 100, nil, 103, 139, + nil, nil, nil, 84, 66, nil, nil, nil, 79, 81, + nil, nil, 88, nil, 60, nil, nil, 74, 68, 71, + nil, 84, 100, nil, 103, 66, nil, nil, nil, 79, + 81, nil, 60, 88, nil, nil, nil, nil, 74, nil, + 95, nil, 84, nil, 68, 71, nil, nil, 100, nil, + 103, 66, nil, 60, nil, 79, 81, nil, nil, 88, + nil, nil, nil, nil, 74, 99, 95, nil, 84, 68, + 71, 90, nil, 100, nil, 103, nil, 66, nil, 60, + nil, 79, 81, 68, 71, 88, nil, nil, nil, nil, + 74, 99, nil, nil, 84, nil, nil, 90, nil, nil, + nil, nil, 66, nil, nil, 60, 79, 81, nil, nil, + 88, nil, nil, nil, nil, 74, 66, nil, nil, 84, + 79, 81, nil, nil, 88, nil, nil, nil, 72, 74, + 60, 68, 71, 84, nil, 100, nil, 103, 189, 172, + 173, 174, 176, 178, 60, 183, 187, nil, 189, 172, + 173, 174, 175, 95, nil, 183, 187, 68, 71, nil, + nil, 100, 175, 103, 66, nil, nil, nil, 79, 81, nil, nil, 88, nil, nil, nil, nil, 74, 99, 95, nil, 84, nil, nil, 90, nil, nil, 68, 71, nil, 66, 100, 60, 103, 79, 81, nil, nil, 88, nil, nil, nil, nil, 74, 99, nil, nil, 84, nil, 95, 90, nil, nil, 68, 71, nil, nil, 100, 60, 103, 66, nil, nil, nil, 79, 81, nil, nil, 88, nil, - nil, nil, nil, 74, 99, 95, nil, 84, 68, 71, - 90, nil, 100, 193, 103, nil, 66, nil, 60, nil, - 79, 81, nil, nil, 88, nil, nil, nil, nil, 74, - 99, nil, nil, 84, 68, 71, 90, nil, 100, nil, - 103, 66, nil, nil, 60, 79, 81, nil, nil, 88, - nil, nil, nil, nil, 74, nil, 95, nil, 84, nil, - 68, 71, nil, nil, 100, nil, 103, 66, nil, 60, - nil, 79, 81, nil, nil, 88, nil, nil, nil, nil, - 74, 99, 95, nil, 84, nil, nil, 90, nil, nil, - nil, nil, nil, 66, nil, 60, nil, 79, 81, 188, - nil, 88, nil, nil, nil, nil, 74, 99, 181, 186, - 84, nil, nil, 90, nil, nil, nil, 177, 179, 182, - 185, 60, nil, 181, 186, nil, nil, nil, nil, nil, - nil, 282, 177, 179, 182, 185, nil, nil, nil, nil, - nil, 180, 184, nil, nil, 189, 172, 173, 174, 176, - 178, nil, 183, 187, nil, nil, 180, 184, nil, 175, - 189, 172, 173, 174, 176, 178, nil, 183, 187, 181, - 186, nil, nil, nil, 175, nil, nil, nil, 177, 179, - 182, 185, nil, nil, 181, 186, nil, nil, nil, nil, - nil, nil, nil, 177, 179, 182, 185, nil, nil, nil, - nil, nil, nil, nil, nil, nil, 189, 172, 173, 174, - 176, 178, nil, 183, 187, nil, nil, 180, 184, nil, - 175, 189, 172, 173, 174, 176, 178, nil, 183, 187, - 181, 186, nil, nil, nil, 175, nil, nil, nil, 177, - 179, 182, 185, nil, nil, 181, 186, nil, nil, nil, - nil, nil, nil, nil, 177, 179, 182, 185, nil, nil, - nil, nil, nil, 180, 184, nil, nil, 189, 172, 173, - 174, 176, 178, nil, 183, 187, nil, nil, nil, 184, - nil, 175, 189, 172, 173, 174, 176, 178, nil, 183, - 187, 181, 186, nil, nil, nil, 175, nil, nil, nil, - 177, 179, 182, 185, nil, nil, nil, 186, nil, 189, - 172, 173, 174, 176, 178, 177, 183, 187, nil, nil, - nil, nil, nil, 175, 180, 184, 186, nil, 189, 172, - 173, 174, 176, 178, 177, 183, 187, nil, nil, nil, - nil, 186, 175, 189, 172, 173, 174, 176, 178, 177, - 183, 187, nil, nil, nil, nil, nil, 175, nil, nil, - nil, nil, 189, 172, 173, 174, 176, 178, nil, 183, - 187, 280, nil, nil, nil, nil, 175, 189, 172, 173, - 174, 176, 178, nil, 183, 187, nil, nil, nil, nil, - 325, 175, 26, nil, 32, 1, nil, 8, 11, nil, - 18, nil, 23, nil, 29, nil, 2, nil, nil, 10, - 15, 26, 363, 32, 1, nil, 8, 11, nil, 18, - nil, 23, nil, 29, nil, 2, nil, nil, 10, 15, - nil, 382, nil, 26, nil, 32, 1, nil, 8, 11, - nil, 18, nil, 23, nil, 29, nil, 2, nil, nil, - 10, 15, 26, 380, 32, 1, nil, 8, 11, nil, - 18, nil, 23, nil, 29, nil, 2, nil, nil, 10, - 15, nil, 376, nil, 26, nil, 32, 1, nil, 8, - 11, nil, 18, nil, 23, nil, 29, nil, 2, nil, - nil, 10, 15, 26, 305, 32, 1, nil, 8, 11, - nil, 18, nil, 23, nil, 29, nil, 2, nil, nil, - 10, 15, nil, nil, nil, 26, nil, 32, 1, nil, + nil, nil, nil, 74, 99, 95, nil, 84, nil, nil, + 90, nil, nil, nil, nil, nil, 66, nil, 60, nil, + 79, 81, 188, nil, 88, nil, nil, nil, nil, 74, + 99, 181, 186, 84, nil, nil, 90, nil, nil, nil, + 177, 179, 182, 185, 60, nil, 181, 186, nil, nil, + nil, nil, nil, nil, nil, 177, 179, 182, 185, nil, + nil, nil, nil, nil, 180, 184, nil, nil, 189, 172, + 173, 174, 176, 178, nil, 183, 187, nil, nil, 180, + 184, nil, 175, 189, 172, 173, 174, 176, 178, nil, + 183, 187, 181, 186, nil, nil, nil, 175, nil, nil, + 283, 177, 179, 182, 185, nil, nil, 181, 186, nil, + nil, nil, nil, nil, nil, nil, 177, 179, 182, 185, + nil, nil, nil, nil, nil, 180, 184, nil, nil, 189, + 172, 173, 174, 176, 178, nil, 183, 187, nil, nil, + nil, 184, nil, 175, 189, 172, 173, 174, 176, 178, + nil, 183, 187, 181, 186, nil, nil, nil, 175, nil, + nil, nil, 177, 179, 182, 185, nil, nil, 181, 186, + nil, nil, nil, nil, nil, nil, nil, 177, 179, 182, + 185, nil, nil, nil, nil, nil, 180, 184, nil, nil, + 189, 172, 173, 174, 176, 178, nil, 183, 187, nil, + nil, 180, 184, nil, 175, 189, 172, 173, 174, 176, + 178, nil, 183, 187, 181, 186, nil, nil, nil, 175, + nil, nil, nil, 177, 179, 182, 185, nil, nil, 26, + 186, 32, 1, nil, 8, 11, nil, 18, 177, 23, + nil, 29, nil, 2, nil, nil, 10, 15, nil, 186, + nil, 189, 172, 173, 174, 176, 178, 177, 183, 187, + nil, nil, nil, nil, 186, 175, 189, 172, 173, 174, + 176, 178, 177, 183, 187, nil, nil, nil, nil, nil, + 175, nil, nil, nil, nil, 189, 172, 173, 174, 176, + 178, nil, 183, 187, 281, nil, nil, nil, nil, 175, + 189, 172, 173, 174, 176, 178, nil, 183, 187, nil, + nil, nil, nil, 377, 175, 26, nil, 32, 1, nil, 8, 11, nil, 18, nil, 23, nil, 29, nil, 2, - nil, nil, 10, 15, 26, nil, 32, 1, nil, 8, + nil, nil, 10, 15, 26, 364, 32, 1, nil, 8, 11, nil, 18, nil, 23, nil, 29, nil, 2, nil, - nil, 10, 15, 26, nil, 32, 1, nil, 8, 11, - nil, 18, nil, 23, nil, 29, nil, 2, nil, nil, - 10, 15, 26, nil, 32, 1, nil, 8, 11, nil, - 18, nil, 23, nil, 29, nil, 2, nil, nil, 10, - 15, 189, 172, 173, 174, 176, 178, nil, 183, 187, - 189, 172, 173, 174, nil, 175, nil, 183, 187, 189, - 172, 173, 174, nil, 175, nil, 183, 187, nil, nil, - nil, nil, nil, 175 ] + nil, 10, 15, nil, 383, nil, 26, nil, 32, 1, + nil, 8, 11, nil, 18, nil, 23, nil, 29, nil, + 2, nil, nil, 10, 15, 26, 306, 32, 1, nil, + 8, 11, nil, 18, nil, 23, nil, 29, nil, 2, + nil, nil, 10, 15, nil, 381, nil, 26, nil, 32, + 1, nil, 8, 11, nil, 18, nil, 23, nil, 29, + nil, 2, nil, nil, 10, 15, 26, 326, 32, 1, + nil, 8, 11, nil, 18, nil, 23, nil, 29, nil, + 2, nil, nil, 10, 15, nil, nil, nil, 26, nil, + 32, 1, nil, 8, 11, nil, 18, nil, 23, nil, + 29, nil, 2, nil, nil, 10, 15, 26, nil, 32, + 1, nil, 8, 11, nil, 18, nil, 23, nil, 29, + nil, 2, nil, nil, 10, 15, 26, nil, 32, 1, + nil, 8, 11, nil, 18, nil, 23, nil, 29, nil, + 2, nil, nil, 10, 15, 189, 172, 173, 174, 176, + 178, nil, 183, 187, nil, nil, nil, nil, nil, 175 ] racc_action_check = [ - 164, 164, 158, 154, 301, 27, 56, 27, 81, 214, - 285, 285, 301, 164, 164, 239, 293, 285, 18, 206, - 27, 213, 164, 164, 164, 164, 81, 206, 175, 175, - 194, 56, 175, 194, 175, 368, 368, 214, 214, 157, - 158, 293, 293, 158, 27, 154, 164, 164, 285, 144, - 164, 164, 164, 164, 164, 164, 18, 164, 164, 18, - 85, 175, 144, 158, 164, 175, 175, 272, 368, 175, - 83, 261, 368, 368, 175, 272, 368, 157, 175, 18, - 157, 368, 161, 161, 261, 368, 161, 216, 161, 175, - 1, 82, 356, 356, 1, 218, 368, 219, 203, 163, - 157, 1, 114, 272, 272, 272, 272, 272, 272, 203, - 272, 272, 163, 114, 203, 161, 122, 272, 114, 161, - 161, 122, 192, 161, 221, 356, 192, 192, 161, 356, - 356, 220, 161, 356, 290, 335, 335, 221, 356, 335, - 111, 335, 356, 161, 309, 290, 331, 331, 11, 309, - 290, 111, 11, 356, 329, 329, 111, 335, 329, 11, - 329, 48, 48, 103, 103, 48, 334, 48, 335, 334, - 103, 200, 335, 335, 262, 262, 335, 263, 263, 262, - 262, 335, 335, 48, 263, 335, 262, 329, 335, 224, - 280, 329, 329, 280, 48, 329, 335, 197, 48, 48, - 329, 103, 48, 227, 329, 295, 295, 48, 48, 87, - 229, 48, 307, 307, 48, 329, 307, 33, 307, 306, - 306, 33, 48, 306, 230, 306, 299, 299, 33, 33, - 225, 80, 232, 299, 225, 77, 46, 225, 295, 234, - 46, 225, 295, 295, 235, 307, 295, 46, 46, 307, - 307, 295, 306, 307, 75, 295, 306, 306, 307, 299, - 306, 212, 307, 299, 299, 306, 295, 299, 8, 306, - 23, 23, 299, 307, 23, 74, 299, 8, 8, 66, - 306, 249, 42, 252, 264, 264, 42, 299, 65, 166, - 166, 264, 23, 42, 42, 26, 26, 64, 89, 26, - 201, 26, 94, 23, 201, 201, 187, 23, 23, 169, - 101, 23, 102, 169, 169, 23, 23, 26, 105, 183, - 23, 53, 166, 52, 294, 294, 166, 166, 26, 50, - 166, 23, 26, 26, 166, 166, 26, 143, 106, 166, - 107, 26, 26, 29, 29, 26, 108, 29, 26, 29, - 166, 110, 279, 167, 167, 113, 26, 294, 115, 167, - 283, 294, 294, 281, 281, 294, 37, 211, 281, 281, - 294, 211, 211, 116, 294, 281, 29, 288, 170, 170, - 29, 29, 119, 32, 29, 294, 167, 121, 127, 29, - 167, 167, 297, 29, 167, 17, 287, 287, 133, 167, - 287, 170, 287, 167, 29, 3, 3, 3, 3, 304, - 13, 170, 12, 134, 167, 170, 170, 136, 320, 170, - 324, 172, 172, 170, 170, 172, 159, 172, 170, 287, - 140, 141, 155, 287, 287, 337, 342, 287, 346, 170, - 347, 349, 287, 172, 350, 351, 287, 45, 45, 5, - 357, 45, 142, 45, 172, 367, 147, 287, 172, 172, - 369, 2, 172, 4, 4, 4, 4, 172, 172, 45, - 146, 172, 379, 381, 172, nil, nil, 173, 173, nil, - 45, 173, 172, 173, 45, 45, nil, nil, 45, 31, - 31, 31, 31, 45, 45, nil, nil, 45, nil, 173, - 45, nil, nil, 47, 47, nil, nil, 47, 45, 47, - 173, nil, nil, nil, 173, 173, nil, nil, 173, 6, - 6, 6, 6, 173, 173, 47, nil, 173, nil, nil, - 173, nil, nil, 174, 174, nil, 47, 174, 173, 174, - 47, 47, nil, nil, 47, nil, nil, nil, nil, 47, - 47, nil, nil, 47, nil, 174, 47, nil, nil, 49, - 49, nil, nil, 49, 47, 49, 174, nil, nil, nil, - 174, 174, nil, nil, 174, nil, nil, 51, 51, 174, - 174, 51, nil, 174, 176, 176, 174, nil, 176, nil, - 176, nil, 49, nil, 174, nil, 49, 49, nil, nil, - 49, nil, nil, nil, nil, 49, 176, nil, nil, 49, - 51, nil, nil, nil, 51, 51, nil, 176, 51, nil, - 49, 176, 176, 51, nil, 176, nil, 51, nil, nil, - 176, 176, nil, nil, 176, 177, 177, 176, 51, 177, - nil, 177, nil, nil, nil, 176, nil, nil, nil, nil, - nil, nil, nil, nil, 112, 112, nil, 177, 112, nil, - 112, 259, 259, nil, nil, 259, nil, 259, 177, nil, - nil, nil, 177, 177, nil, nil, 177, nil, nil, 254, - 254, 177, 177, nil, nil, 177, nil, 112, 177, nil, - nil, 112, 112, nil, 259, 112, 177, nil, 259, 259, - 112, nil, 259, nil, 112, 70, 70, 259, nil, nil, - nil, 259, 254, nil, nil, 112, 254, 254, nil, nil, - 254, nil, 259, nil, nil, 254, 242, 242, 70, 254, - 242, nil, 242, nil, nil, nil, nil, nil, 70, nil, - 254, nil, 70, 70, nil, nil, 70, nil, 242, nil, - 70, 70, 71, 71, nil, 70, 71, nil, 71, 242, - nil, nil, nil, 242, 242, nil, 70, 242, nil, nil, - nil, nil, 242, 242, 71, nil, 242, 240, 240, 242, - nil, nil, nil, nil, nil, 71, nil, 242, nil, 71, - 71, nil, nil, 71, nil, nil, nil, nil, 71, 71, - 240, nil, 71, 178, 178, 71, nil, 178, nil, 178, - 240, nil, nil, 71, 240, 240, nil, nil, 240, nil, - nil, nil, 240, 240, nil, 178, nil, 240, 233, 233, - nil, nil, 233, nil, 233, nil, 178, nil, 240, nil, - 178, 178, 78, 78, 178, nil, 78, nil, 78, 178, - 178, nil, nil, 178, nil, nil, 178, nil, nil, nil, - nil, 233, nil, nil, 178, 233, 233, 231, 231, 233, - nil, 231, nil, 231, 233, 78, nil, nil, 233, 78, - 78, 228, 228, 78, nil, 228, nil, nil, 78, 233, - nil, nil, 78, nil, nil, nil, nil, nil, nil, nil, - 231, nil, nil, 78, 231, 231, nil, nil, 231, nil, - nil, 215, 215, 231, 228, nil, nil, 231, 228, 228, - nil, nil, 228, nil, nil, nil, nil, 228, 231, 179, - 179, 228, nil, 179, nil, 179, nil, nil, nil, nil, - nil, nil, 228, nil, 215, nil, nil, nil, 215, 215, - nil, 179, 215, nil, nil, nil, nil, 215, nil, 185, - 185, 215, 179, 185, nil, 185, 179, 179, nil, nil, - 179, nil, 215, nil, nil, 179, 179, nil, nil, 179, - nil, 185, 179, nil, nil, 181, 181, nil, nil, 181, - 179, 181, 185, nil, nil, nil, 185, 185, nil, nil, - 185, nil, nil, nil, nil, 185, 185, 181, nil, 185, - nil, nil, 185, nil, nil, 189, 189, nil, 181, 189, - 185, 189, 181, 181, nil, nil, 181, nil, nil, nil, - nil, 181, 181, nil, nil, 181, nil, 189, 181, nil, - nil, 90, 90, nil, nil, 90, 181, 90, 189, nil, - nil, nil, 189, 189, nil, nil, 189, nil, nil, nil, - nil, 189, 189, 90, nil, 189, nil, nil, 189, nil, - nil, 182, 182, nil, 90, 182, 189, 182, 90, 90, - nil, nil, 90, nil, nil, nil, nil, 90, 90, nil, - nil, 90, nil, 182, 90, nil, nil, 184, 184, nil, - nil, 184, 90, 184, 182, nil, nil, nil, 182, 182, - nil, nil, 182, nil, nil, nil, nil, 182, 182, 184, - nil, 182, nil, nil, 182, nil, nil, 95, 95, nil, - 184, 95, 182, 95, 184, 184, nil, nil, 184, nil, - nil, nil, nil, 184, 184, nil, nil, 184, nil, 95, - 184, nil, nil, 99, 99, nil, nil, 99, 184, 99, - 95, nil, nil, nil, 95, 95, nil, nil, 95, nil, - nil, nil, nil, 95, 95, 99, nil, 95, 100, 100, - 95, nil, 100, 100, 100, nil, 99, nil, 95, nil, - 99, 99, nil, nil, 99, nil, nil, nil, nil, 99, - 99, nil, nil, 99, 186, 186, 99, nil, 186, nil, - 186, 100, nil, nil, 99, 100, 100, nil, nil, 100, - nil, nil, nil, nil, 100, nil, 186, nil, 100, nil, - 180, 180, nil, nil, 180, nil, 180, 186, nil, 100, - nil, 186, 186, nil, nil, 186, nil, nil, nil, nil, - 186, 186, 180, nil, 186, nil, nil, 186, nil, nil, - nil, nil, nil, 180, nil, 186, nil, 180, 180, 91, - nil, 180, nil, nil, nil, nil, 180, 180, 91, 91, - 180, nil, nil, 180, nil, nil, nil, 91, 91, 91, - 91, 180, nil, 190, 190, nil, nil, nil, nil, nil, - nil, 190, 190, 190, 190, 190, nil, nil, nil, nil, - nil, 91, 91, nil, nil, 91, 91, 91, 91, 91, - 91, nil, 91, 91, nil, nil, 190, 190, nil, 91, - 190, 190, 190, 190, 190, 190, nil, 190, 190, 274, - 274, nil, nil, nil, 190, nil, nil, nil, 274, 274, - 274, 274, nil, nil, 132, 132, nil, nil, nil, nil, - nil, nil, nil, 132, 132, 132, 132, nil, nil, nil, - nil, nil, nil, nil, nil, nil, 274, 274, 274, 274, - 274, 274, nil, 274, 274, nil, nil, 132, 132, nil, - 274, 132, 132, 132, 132, 132, 132, nil, 132, 132, - 131, 131, nil, nil, nil, 132, nil, nil, nil, 131, - 131, 131, 131, nil, nil, 270, 270, nil, nil, nil, - nil, nil, nil, nil, 270, 270, 270, 270, nil, nil, - nil, nil, nil, 131, 131, nil, nil, 131, 131, 131, - 131, 131, 131, nil, 131, 131, nil, nil, nil, 270, - nil, 131, 270, 270, 270, 270, 270, 270, nil, 270, - 270, 129, 129, nil, nil, nil, 270, nil, nil, nil, - 129, 129, 129, 129, nil, nil, nil, 269, nil, 276, - 276, 276, 276, 276, 276, 269, 276, 276, nil, nil, - nil, nil, nil, 276, 129, 129, 275, nil, 129, 129, - 129, 129, 129, 129, 275, 129, 129, nil, nil, nil, - nil, 271, 129, 269, 269, 269, 269, 269, 269, 271, - 269, 269, nil, nil, nil, nil, nil, 269, nil, nil, - nil, nil, 275, 275, 275, 275, 275, 275, nil, 275, - 275, 188, nil, nil, nil, nil, 275, 271, 271, 271, - 271, 271, 271, nil, 271, 271, nil, nil, nil, nil, - 238, 271, 188, nil, 188, 188, nil, 188, 188, nil, - 188, nil, 188, nil, 188, nil, 188, nil, nil, 188, - 188, 238, 311, 238, 238, nil, 238, 238, nil, 238, - nil, 238, nil, 238, nil, 238, nil, nil, 238, 238, - nil, 375, nil, 311, nil, 311, 311, nil, 311, 311, - nil, 311, nil, 311, nil, 311, nil, 311, nil, nil, - 311, 311, 375, 372, 375, 375, nil, 375, 375, nil, - 375, nil, 375, nil, 375, nil, 375, nil, nil, 375, - 375, nil, 362, nil, 372, nil, 372, 372, nil, 372, - 372, nil, 372, nil, 372, nil, 372, nil, 372, nil, - nil, 372, 372, 362, 217, 362, 362, nil, 362, 362, - nil, 362, nil, 362, nil, 362, nil, 362, nil, nil, - 362, 362, nil, nil, nil, 217, nil, 217, 217, nil, - 217, 217, nil, 217, nil, 217, nil, 217, nil, 217, - nil, nil, 217, 217, 0, nil, 0, 0, nil, 0, - 0, nil, 0, nil, 0, nil, 0, nil, 0, nil, - nil, 0, 0, 20, nil, 20, 20, nil, 20, 20, - nil, 20, nil, 20, nil, 20, nil, 20, nil, nil, - 20, 20, 278, nil, 278, 278, nil, 278, 278, nil, - 278, nil, 278, nil, 278, nil, 278, nil, nil, 278, - 278, 267, 267, 267, 267, 267, 267, nil, 267, 267, - 266, 266, 266, 266, nil, 267, nil, 266, 266, 268, - 268, 268, 268, nil, 266, nil, 268, 268, nil, nil, - nil, nil, nil, 268 ] + 164, 164, 18, 103, 103, 214, 56, 157, 81, 32, + 103, 286, 286, 164, 164, 136, 11, 27, 286, 27, + 11, 158, 164, 164, 164, 164, 81, 11, 300, 300, + 154, 56, 27, 214, 214, 300, 332, 332, 189, 189, + 18, 103, 189, 18, 189, 157, 164, 164, 157, 286, + 164, 164, 164, 164, 164, 164, 27, 164, 164, 158, + 189, 300, 158, 18, 164, 300, 300, 200, 157, 300, + 294, 189, 154, 212, 300, 189, 189, 213, 300, 189, + 369, 369, 158, 134, 189, 189, 186, 186, 189, 300, + 186, 189, 186, 203, 291, 294, 294, 133, 206, 189, + 111, 216, 144, 127, 203, 291, 206, 163, 186, 203, + 291, 111, 262, 369, 273, 144, 111, 369, 369, 186, + 163, 369, 273, 186, 186, 262, 369, 186, 357, 357, + 369, 221, 186, 186, 185, 185, 186, 302, 185, 186, + 185, 369, 264, 264, 221, 302, 218, 186, 219, 264, + 273, 273, 273, 273, 273, 273, 185, 273, 273, 1, + 220, 357, 197, 1, 273, 357, 357, 185, 122, 357, + 1, 185, 185, 122, 357, 185, 281, 224, 357, 281, + 185, 185, 176, 176, 185, 310, 176, 185, 176, 357, + 310, 282, 282, 121, 192, 185, 282, 282, 192, 192, + 114, 175, 175, 282, 176, 175, 46, 175, 336, 336, + 46, 114, 336, 227, 336, 176, 114, 46, 46, 176, + 176, 263, 263, 176, 265, 265, 263, 263, 176, 176, + 336, 265, 176, 263, 175, 176, 119, 335, 175, 175, + 335, 336, 175, 176, 229, 336, 336, 175, 230, 336, + 116, 175, 215, 215, 336, 336, 232, 8, 336, 330, + 330, 336, 175, 330, 115, 330, 8, 8, 194, 336, + 234, 194, 267, 267, 267, 267, 235, 184, 184, 267, + 267, 184, 113, 184, 225, 215, 267, 239, 225, 215, + 215, 225, 330, 215, 110, 225, 330, 330, 215, 184, + 330, 108, 215, 23, 23, 330, 250, 23, 253, 330, + 184, 107, 169, 215, 184, 184, 169, 169, 184, 106, + 330, 105, 102, 184, 184, 23, 140, 184, 26, 26, + 184, 42, 26, 141, 26, 42, 23, 101, 184, 96, + 23, 23, 42, 42, 23, 94, 89, 211, 23, 23, + 26, 211, 211, 23, 228, 228, 33, 87, 228, 85, + 33, 26, 83, 82, 23, 26, 26, 33, 33, 26, + 31, 31, 31, 31, 26, 26, 29, 29, 26, 201, + 29, 26, 29, 201, 201, 80, 77, 228, 75, 26, + 280, 228, 228, 142, 74, 228, 284, 308, 308, 69, + 228, 308, 66, 308, 228, 6, 6, 6, 6, 29, + 289, 65, 64, 29, 29, 228, 53, 29, 52, 307, + 307, 298, 29, 307, 50, 307, 29, 37, 305, 138, + 308, 187, 143, 17, 308, 308, 321, 29, 308, 325, + 174, 174, 13, 308, 174, 146, 174, 308, 3, 3, + 3, 3, 307, 147, 12, 338, 307, 307, 308, 343, + 307, 347, 174, 348, 350, 307, 179, 179, 351, 307, + 179, 352, 179, 174, 183, 358, 5, 174, 174, 368, + 307, 174, 4, 4, 4, 4, 174, 174, 179, 155, + 174, 370, 159, 174, 2, 380, 173, 173, 382, 179, + 173, 174, 173, 179, 179, nil, nil, 179, nil, nil, + nil, nil, 179, 179, nil, nil, 179, nil, 173, 179, + nil, nil, 45, 45, nil, nil, 45, 179, 45, 173, + nil, nil, nil, 173, 173, nil, nil, 173, nil, nil, + nil, nil, 173, 173, 45, nil, 173, nil, nil, 173, + nil, nil, 172, 172, nil, 45, 172, 173, 172, 45, + 45, nil, nil, 45, nil, nil, nil, nil, 45, 45, + nil, nil, 45, nil, 172, 45, nil, nil, 47, 47, + nil, nil, 47, 45, 47, 172, nil, nil, nil, 172, + 172, nil, nil, 172, nil, nil, nil, nil, 172, 172, + 47, nil, 172, nil, nil, 172, nil, nil, 48, 48, + nil, 47, 48, 172, 48, 47, 47, nil, nil, 47, + nil, nil, nil, nil, 47, 47, nil, nil, 47, nil, + 48, 47, nil, nil, 49, 49, nil, nil, 49, 47, + 49, 48, nil, nil, nil, 48, 48, nil, nil, 48, + 296, 296, nil, nil, 48, 48, 177, 177, 48, nil, + 177, 48, 177, nil, nil, nil, nil, 49, nil, 48, + nil, 49, 49, nil, nil, 49, nil, nil, 177, nil, + 49, 51, 51, 296, 49, 51, nil, 296, 296, 177, + nil, 296, nil, 177, 177, 49, 296, 177, nil, nil, + 296, nil, 177, 177, nil, nil, 177, 295, 295, 177, + nil, 296, nil, nil, 51, nil, nil, 177, 51, 51, + nil, nil, 51, nil, nil, nil, nil, 51, 231, 231, + nil, 51, 231, nil, 231, nil, nil, nil, nil, nil, + 295, nil, 51, nil, 295, 295, 233, 233, 295, nil, + 233, nil, 233, 295, nil, nil, nil, 295, nil, nil, + nil, 231, nil, nil, nil, 231, 231, nil, 295, 231, + nil, 170, 170, nil, 231, nil, nil, nil, 231, 233, + nil, nil, nil, 233, 233, nil, nil, 233, nil, 231, + nil, nil, 233, nil, 170, nil, 233, 288, 288, nil, + nil, 288, nil, 288, 170, nil, nil, 233, 170, 170, + nil, nil, 170, nil, nil, nil, 170, 170, 182, 182, + nil, 170, 182, nil, 182, nil, nil, nil, nil, nil, + 288, nil, 170, nil, 288, 288, nil, nil, 288, nil, + 182, nil, nil, 288, 70, 70, nil, 288, nil, nil, + nil, 182, nil, nil, nil, 182, 182, nil, 288, 182, + nil, nil, nil, nil, 182, 182, nil, 70, 182, 71, + 71, 182, nil, 71, nil, 71, nil, 70, nil, 182, + nil, 70, 70, nil, nil, 70, nil, nil, nil, 70, + 70, 71, nil, nil, 70, 180, 180, nil, nil, 180, + nil, 180, 71, nil, nil, 70, 71, 71, nil, nil, + 71, nil, nil, nil, nil, 71, 71, 180, nil, 71, + 112, 112, 71, nil, 112, nil, 112, nil, 180, nil, + 71, nil, 180, 180, 167, 167, 180, nil, nil, nil, + 167, 180, 180, nil, nil, 180, nil, nil, 180, nil, + nil, nil, nil, 112, nil, nil, 180, 112, 112, 78, + 78, 112, nil, 78, nil, 78, 112, 167, nil, nil, + 112, 167, 167, nil, nil, 167, nil, nil, 240, 240, + 167, 112, nil, nil, 167, nil, nil, nil, nil, nil, + nil, nil, 78, nil, nil, 167, 78, 78, nil, nil, + 78, 240, nil, 255, 255, 78, nil, nil, nil, 78, + nil, 240, nil, nil, nil, 240, 240, nil, nil, 240, + 78, 100, 100, 240, 240, 100, 100, 100, 240, nil, + nil, nil, nil, nil, nil, nil, 255, nil, nil, 240, + 255, 255, 260, 260, 255, nil, 260, nil, 260, 255, + nil, nil, nil, 255, 100, nil, nil, nil, 100, 100, + nil, nil, 100, nil, 255, nil, nil, 100, 181, 181, + nil, 100, 181, nil, 181, 260, nil, nil, nil, 260, + 260, nil, 100, 260, nil, nil, nil, nil, 260, nil, + 181, nil, 260, nil, 90, 90, nil, nil, 90, nil, + 90, 181, nil, 260, nil, 181, 181, nil, nil, 181, + nil, nil, nil, nil, 181, 181, 90, nil, 181, 161, + 161, 181, nil, 161, nil, 161, nil, 90, nil, 181, + nil, 90, 90, 166, 166, 90, nil, nil, nil, nil, + 90, 90, nil, nil, 90, nil, nil, 90, nil, nil, + nil, nil, 161, nil, nil, 90, 161, 161, nil, nil, + 161, nil, nil, nil, nil, 161, 166, nil, nil, 161, + 166, 166, nil, nil, 166, nil, nil, nil, 166, 166, + 161, 95, 95, 166, nil, 95, nil, 95, 277, 277, + 277, 277, 277, 277, 166, 277, 277, nil, 269, 269, + 269, 269, 277, 95, nil, 269, 269, 178, 178, nil, + nil, 178, 269, 178, 95, nil, nil, nil, 95, 95, + nil, nil, 95, nil, nil, nil, nil, 95, 95, 178, + nil, 95, nil, nil, 95, nil, nil, 99, 99, nil, + 178, 99, 95, 99, 178, 178, nil, nil, 178, nil, + nil, nil, nil, 178, 178, nil, nil, 178, nil, 99, + 178, nil, nil, 242, 242, nil, nil, 242, 178, 242, + 99, nil, nil, nil, 99, 99, nil, nil, 99, nil, + nil, nil, nil, 99, 99, 242, nil, 99, nil, nil, + 99, nil, nil, nil, nil, nil, 242, nil, 99, nil, + 242, 242, 91, nil, 242, nil, nil, nil, nil, 242, + 242, 91, 91, 242, nil, nil, 242, nil, nil, nil, + 91, 91, 91, 91, 242, nil, 129, 129, nil, nil, + nil, nil, nil, nil, nil, 129, 129, 129, 129, nil, + nil, nil, nil, nil, 91, 91, nil, nil, 91, 91, + 91, 91, 91, 91, nil, 91, 91, nil, nil, 129, + 129, nil, 91, 129, 129, 129, 129, 129, 129, nil, + 129, 129, 190, 190, nil, nil, nil, 129, nil, nil, + 190, 190, 190, 190, 190, nil, nil, 271, 271, nil, + nil, nil, nil, nil, nil, nil, 271, 271, 271, 271, + nil, nil, nil, nil, nil, 190, 190, nil, nil, 190, + 190, 190, 190, 190, 190, nil, 190, 190, nil, nil, + nil, 271, nil, 190, 271, 271, 271, 271, 271, 271, + nil, 271, 271, 131, 131, nil, nil, nil, 271, nil, + nil, nil, 131, 131, 131, 131, nil, nil, 132, 132, + nil, nil, nil, nil, nil, nil, nil, 132, 132, 132, + 132, nil, nil, nil, nil, nil, 131, 131, nil, nil, + 131, 131, 131, 131, 131, 131, nil, 131, 131, nil, + nil, 132, 132, nil, 131, 132, 132, 132, 132, 132, + 132, nil, 132, 132, 275, 275, nil, nil, nil, 132, + nil, nil, nil, 275, 275, 275, 275, nil, nil, 279, + 276, 279, 279, nil, 279, 279, nil, 279, 276, 279, + nil, 279, nil, 279, nil, nil, 279, 279, nil, 270, + nil, 275, 275, 275, 275, 275, 275, 270, 275, 275, + nil, nil, nil, nil, 272, 275, 276, 276, 276, 276, + 276, 276, 272, 276, 276, nil, nil, nil, nil, nil, + 276, nil, nil, nil, nil, 270, 270, 270, 270, 270, + 270, nil, 270, 270, 188, nil, nil, nil, nil, 270, + 272, 272, 272, 272, 272, 272, nil, 272, 272, nil, + nil, nil, nil, 363, 272, 188, nil, 188, 188, nil, + 188, 188, nil, 188, nil, 188, nil, 188, nil, 188, + nil, nil, 188, 188, 363, 312, 363, 363, nil, 363, + 363, nil, 363, nil, 363, nil, 363, nil, 363, nil, + nil, 363, 363, nil, 376, nil, 312, nil, 312, 312, + nil, 312, 312, nil, 312, nil, 312, nil, 312, nil, + 312, nil, nil, 312, 312, 376, 217, 376, 376, nil, + 376, 376, nil, 376, nil, 376, nil, 376, nil, 376, + nil, nil, 376, 376, nil, 373, nil, 217, nil, 217, + 217, nil, 217, 217, nil, 217, nil, 217, nil, 217, + nil, 217, nil, nil, 217, 217, 373, 238, 373, 373, + nil, 373, 373, nil, 373, nil, 373, nil, 373, nil, + 373, nil, nil, 373, 373, nil, nil, nil, 238, nil, + 238, 238, nil, 238, 238, nil, 238, nil, 238, nil, + 238, nil, 238, nil, nil, 238, 238, 20, nil, 20, + 20, nil, 20, 20, nil, 20, nil, 20, nil, 20, + nil, 20, nil, nil, 20, 20, 0, nil, 0, 0, + nil, 0, 0, nil, 0, nil, 0, nil, 0, nil, + 0, nil, nil, 0, 0, 268, 268, 268, 268, 268, + 268, nil, 268, 268, nil, nil, nil, nil, nil, 268 ] racc_action_pointer = [ - 1674, 54, 417, 341, 399, 434, 455, nil, 262, nil, - nil, 112, 404, 402, nil, nil, nil, 395, 16, nil, - 1693, nil, nil, 268, nil, nil, 293, -1, nil, 341, - nil, 425, 381, 181, nil, nil, nil, 342, nil, nil, - nil, nil, 246, nil, nil, 445, 200, 501, 159, 557, - 305, 575, 283, 321, nil, nil, -6, nil, nil, nil, - nil, nil, nil, nil, 291, 265, 273, nil, nil, nil, - 703, 750, nil, nil, 269, 242, nil, 212, 840, nil, - 208, 2, 68, 64, nil, 37, nil, 186, nil, 275, - 1039, 1261, nil, nil, 279, 1125, nil, nil, nil, 1151, - 1176, 287, 289, 161, nil, 295, 315, 317, 323, nil, - 343, 116, 652, 315, 78, 350, 361, nil, nil, 374, - nil, 379, 81, nil, nil, nil, nil, 382, nil, 1444, - nil, 1383, 1337, 391, 376, nil, 394, nil, nil, nil, - 389, 408, 440, 314, 38, nil, 447, 436, nil, nil, - nil, nil, nil, nil, -8, 420, nil, 37, 0, 418, - nil, 80, nil, 87, -4, nil, 287, 351, nil, 302, - 376, nil, 419, 475, 531, 26, 582, 633, 801, 927, - 1228, 983, 1069, 256, 1095, 957, 1202, 243, 1532, 1013, - 1276, nil, 115, nil, 21, nil, nil, 186, nil, nil, - 131, 254, nil, 74, nil, nil, 1, nil, nil, nil, - nil, 360, 249, 10, -13, 909, 85, 1655, 80, 82, - 106, 112, nil, nil, 181, 194, nil, 194, 879, 170, - 215, 865, 192, 826, 199, 235, nil, nil, 1551, 8, - 775, nil, 724, nil, nil, nil, nil, nil, nil, 270, - nil, nil, 259, nil, 677, nil, nil, nil, nil, 659, - nil, 59, 118, 116, 223, nil, 1716, 1707, 1725, 1459, - 1398, 1493, 49, nil, 1322, 1478, 1425, nil, 1712, 343, - 159, 307, nil, 353, nil, 8, nil, 394, 365, nil, - 110, nil, nil, -9, 322, 203, nil, 383, nil, 224, - nil, -8, nil, nil, 400, nil, 217, 210, nil, 109, - nil, 1573, nil, nil, nil, nil, nil, nil, nil, nil, - 406, nil, nil, nil, 411, nil, nil, nil, nil, 152, - nil, 135, nil, nil, 135, 133, nil, 427, nil, nil, - nil, nil, 427, nil, nil, nil, 415, 417, nil, 418, - 421, 422, nil, nil, nil, nil, 90, 442, nil, nil, - nil, nil, 1633, nil, nil, nil, nil, 446, 33, 451, - nil, nil, 1614, nil, nil, 1592, nil, nil, nil, 463, - nil, 464, nil, nil, nil ] + 1726, 123, 450, 384, 418, 461, 341, nil, 251, nil, + nil, -20, 446, 434, nil, nil, nil, 433, 0, nil, + 1707, nil, nil, 301, nil, nil, 326, 11, nil, 374, + nil, 306, 7, 320, nil, nil, nil, 403, nil, nil, + nil, nil, 295, nil, nil, 520, 170, 576, 606, 632, + 400, 679, 378, 416, nil, nil, -6, nil, nil, nil, + nil, nil, nil, nil, 389, 388, 396, nil, nil, 393, + 842, 867, nil, nil, 388, 376, nil, 363, 957, nil, + 362, 2, 340, 356, nil, 336, nil, 334, nil, 323, + 1092, 1294, nil, nil, 322, 1179, 333, nil, nil, 1235, + 1019, 314, 299, 1, nil, 298, 296, 288, 278, nil, + 286, 76, 918, 242, 176, 256, 238, nil, nil, 228, + nil, 185, 133, nil, nil, nil, nil, 97, nil, 1309, + nil, 1416, 1431, 90, 46, nil, -8, nil, 423, nil, + 285, 310, 381, 409, 91, nil, 422, 433, nil, nil, + nil, nil, nil, nil, 19, 477, nil, 5, 19, 484, + nil, 1117, nil, 95, -4, nil, 1131, 932, nil, 305, + 769, nil, 550, 494, 438, 199, 180, 654, 1205, 464, + 893, 1066, 816, 411, 275, 132, 84, 368, 1565, 36, + 1355, nil, 187, nil, 259, nil, nil, 151, nil, nil, + 27, 333, nil, 69, nil, nil, 80, nil, nil, nil, + nil, 340, 61, 66, -17, 250, 99, 1647, 131, 133, + 135, 119, nil, nil, 169, 248, nil, 204, 352, 204, + 239, 726, 216, 744, 230, 267, nil, nil, 1688, 280, + 976, nil, 1261, nil, nil, nil, nil, nil, nil, nil, + 295, nil, nil, 284, nil, 1001, nil, nil, nil, nil, + 1040, nil, 100, 165, 81, 163, nil, 218, 1721, 1144, + 1511, 1370, 1526, 96, nil, 1477, 1492, 1134, nil, 1479, + 381, 145, 135, nil, 389, nil, 9, nil, 795, 398, + nil, 70, nil, nil, 45, 705, 648, nil, 412, nil, + 26, nil, 125, nil, nil, 419, nil, 417, 395, nil, + 150, nil, 1606, nil, nil, nil, nil, nil, nil, nil, + nil, 424, nil, nil, nil, 430, nil, nil, nil, nil, + 257, nil, 25, nil, nil, 206, 206, nil, 447, nil, + nil, nil, nil, 450, nil, nil, nil, 438, 440, nil, + 441, 445, 448, nil, nil, nil, nil, 126, 467, nil, + nil, nil, nil, 1584, nil, nil, nil, nil, 470, 78, + 482, nil, nil, 1666, nil, nil, 1625, nil, nil, nil, + 486, nil, 489, nil, nil, nil ] racc_action_default = [ - -197, -234, -51, -19, -8, -234, -234, -9, -234, -10, - -188, -189, -234, -23, -11, -186, -12, -234, -234, -13, - -1, -14, -2, -187, -15, -3, -234, -234, -16, -234, - -17, -6, -234, -234, -18, -7, -189, -197, -187, -52, - -27, -28, -234, -25, -26, -234, -234, -234, -234, -234, - -197, -86, -93, -234, -196, -194, -197, -190, -192, -193, - -222, -195, -4, -42, -232, -43, -214, -175, -118, -44, - -234, -234, -45, -34, -75, -32, -33, -234, -234, -123, - -37, -74, -38, -234, -73, -39, -173, -40, -174, -41, - -234, -234, -126, -108, -104, -234, -112, -133, -113, -234, - -234, -105, -109, -234, -111, -106, -115, -107, -114, -110, - -54, -197, -234, -86, -197, -234, -179, -176, -177, -234, - -50, -234, -198, -199, -24, -21, -23, -187, -22, -84, - -20, -83, -85, -234, -197, -79, -76, -87, -82, -75, - -71, -77, -220, -80, -74, -69, -78, -234, -172, -171, - -81, -91, -92, -94, -234, -220, 385, -234, -234, -234, - -208, -234, -31, -234, -234, -119, -234, -234, -96, -234, - -234, -143, -234, -234, -234, -234, -234, -234, -234, -234, - -234, -234, -234, -234, -234, -234, -234, -234, -234, -234, - -234, -150, -234, -217, -234, -230, -226, -234, -229, -225, - -93, -234, -214, -197, -58, -60, -234, -67, -57, -74, - -66, -234, -220, -234, -234, -234, -234, -234, -207, -205, - -234, -234, -202, -231, -234, -234, -210, -234, -72, -221, - -234, -234, -86, -234, -221, -234, -191, -209, -234, -234, - -234, -29, -234, -121, -120, -36, -35, -169, -167, -234, - -170, -161, -74, -168, -234, -162, -218, -219, -124, -234, - -117, -234, -138, -140, -139, -134, -141, -145, -142, -147, - -152, -149, -146, -135, -151, -148, -144, -136, -5, -234, - -129, -137, -153, -219, -215, -234, -223, -234, -220, -55, - -234, -63, -62, -234, -234, -234, -125, -234, -56, -234, - -155, -234, -159, -178, -234, -181, -234, -234, -200, -234, - -201, -234, -212, -213, -211, -46, -70, -88, -47, -89, - -220, -90, -95, -49, -234, -185, -233, -30, -122, -234, - -164, -220, -97, -116, -129, -234, -128, -234, -216, -227, - -224, -228, -234, -59, -61, -102, -98, -99, -64, -103, - -100, -101, -65, -48, -156, -154, -234, -234, -180, -206, - -204, -203, -234, -183, -68, -184, -166, -219, -234, -234, - -127, -130, -234, -53, -160, -234, -182, -165, -163, -234, - -132, -234, -158, -131, -157 ] + -198, -235, -51, -19, -8, -235, -235, -9, -235, -10, + -189, -190, -235, -23, -11, -187, -12, -235, -235, -13, + -1, -14, -2, -188, -15, -3, -235, -235, -16, -235, + -17, -6, -235, -235, -18, -7, -190, -198, -188, -52, + -27, -28, -235, -25, -26, -235, -235, -235, -235, -235, + -198, -86, -93, -235, -197, -195, -198, -191, -193, -194, + -223, -196, -4, -42, -233, -43, -215, -176, -118, -44, + -235, -235, -45, -34, -75, -32, -33, -235, -235, -123, + -37, -74, -38, -235, -73, -39, -173, -40, -175, -41, + -235, -235, -126, -108, -104, -235, -112, -133, -113, -235, + -235, -105, -109, -235, -111, -106, -115, -107, -114, -110, + -54, -198, -235, -86, -198, -235, -180, -177, -178, -235, + -50, -235, -199, -200, -24, -21, -23, -188, -22, -84, + -20, -83, -85, -235, -198, -79, -76, -87, -82, -75, + -71, -77, -221, -80, -74, -69, -78, -235, -172, -171, + -81, -91, -92, -94, -235, -221, 386, -235, -235, -235, + -209, -235, -31, -235, -235, -119, -235, -235, -96, -235, + -235, -143, -235, -235, -235, -235, -235, -235, -235, -235, + -235, -235, -235, -235, -235, -235, -235, -235, -235, -235, + -235, -150, -235, -218, -235, -231, -227, -235, -230, -226, + -93, -235, -215, -198, -58, -60, -235, -67, -57, -74, + -66, -235, -221, -235, -235, -235, -235, -235, -208, -206, + -235, -235, -203, -232, -235, -235, -211, -235, -72, -222, + -235, -235, -86, -235, -222, -235, -192, -210, -235, -235, + -235, -29, -235, -121, -120, -36, -35, -174, -169, -167, + -235, -170, -161, -74, -168, -235, -162, -219, -220, -124, + -235, -117, -235, -138, -140, -139, -134, -141, -145, -142, + -147, -152, -149, -146, -135, -151, -148, -144, -136, -5, + -235, -129, -137, -153, -220, -216, -235, -224, -235, -221, + -55, -235, -63, -62, -235, -235, -235, -125, -235, -56, + -235, -155, -235, -159, -179, -235, -182, -235, -235, -201, + -235, -202, -235, -213, -214, -212, -46, -70, -88, -47, + -89, -221, -90, -95, -49, -235, -186, -234, -30, -122, + -235, -164, -221, -97, -116, -129, -235, -128, -235, -217, + -228, -225, -229, -235, -59, -61, -102, -98, -99, -64, + -103, -100, -101, -65, -48, -156, -154, -235, -235, -181, + -207, -205, -204, -235, -184, -68, -185, -166, -220, -235, + -235, -127, -130, -235, -53, -160, -235, -183, -165, -163, + -235, -132, -235, -158, -131, -157 ] racc_goto_table = [ - 27, 13, 5, 37, 62, 255, 249, 20, 118, 196, - 92, 89, 142, 50, 155, 300, 69, 63, 222, 336, - 27, 13, 5, 165, 73, 75, 57, 279, 348, 352, - 246, 151, 145, 119, 343, 150, 121, 230, 65, 149, - 299, 22, 27, 126, 138, 135, 27, 126, 201, 134, - 235, 214, 120, 87, 302, 86, 304, 244, 89, 42, - 169, 128, 46, 69, 63, 128, 136, 251, 368, 331, - 322, 73, 163, 370, 212, 125, 124, 324, 123, 130, - 124, 148, 192, 86, 116, 65, 140, 224, 56, 159, - 227, 123, 330, 249, 211, 237, 220, 160, 221, 354, - 87, 110, 86, 115, 246, 314, 194, 297, 17, nil, - nil, nil, nil, nil, nil, nil, nil, nil, 195, nil, - nil, nil, nil, 133, nil, nil, nil, nil, nil, nil, - nil, nil, nil, nil, 54, nil, nil, nil, 302, nil, - 293, nil, nil, nil, nil, nil, nil, nil, nil, nil, - nil, nil, 168, nil, 89, 149, nil, nil, 89, 69, - 63, nil, 288, 69, 63, 236, nil, 245, nil, nil, - nil, 73, 261, 82, 168, 226, nil, nil, nil, 151, - nil, 65, 247, 342, nil, 65, 168, nil, 27, 13, - 5, 339, 303, 320, 328, 374, 87, 148, 86, 86, - 87, 143, 86, 149, 80, 361, 377, 249, 317, 316, - nil, 379, 150, 151, 381, 364, 149, 27, 13, 5, - 82, 138, 135, nil, nil, nil, 369, 312, 89, nil, - 247, nil, 141, 69, 63, 239, nil, nil, 27, 13, - 5, 245, 149, 136, nil, 148, nil, 86, nil, 265, - nil, 80, nil, nil, nil, 65, nil, nil, 148, nil, - 86, 210, 62, nil, 210, nil, nil, nil, 85, 247, - 87, nil, 86, 54, 54, nil, nil, nil, 27, 13, - 5, nil, 149, 149, 148, nil, 86, 149, 345, 345, - nil, nil, 207, nil, nil, 207, 146, nil, nil, 273, - 195, nil, nil, 277, nil, 319, nil, 321, nil, 346, - 346, 27, 13, 5, 247, 85, 82, 250, 362, 371, - 82, nil, nil, nil, 351, 351, 86, 86, nil, 148, - nil, 86, nil, 332, nil, nil, nil, nil, nil, nil, - nil, nil, nil, nil, 149, nil, 62, 80, 248, nil, - nil, 80, nil, 210, nil, nil, 149, nil, nil, nil, - nil, 341, 27, 13, 5, 250, nil, nil, nil, nil, - nil, 247, 27, 13, 5, 27, 13, 5, 143, nil, - 359, 360, nil, 247, 207, nil, 148, nil, 86, nil, - 82, nil, 129, nil, 131, 132, 248, nil, 148, nil, - 86, nil, nil, 366, 250, nil, nil, nil, nil, 141, - nil, 85, 253, nil, nil, 85, nil, nil, 164, nil, - nil, 80, nil, nil, nil, nil, nil, nil, nil, nil, - nil, nil, nil, nil, nil, 248, nil, 171, nil, nil, - 210, nil, 190, nil, 349, 349, 191, nil, nil, 250, - nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, - 253, nil, nil, nil, nil, nil, nil, nil, nil, nil, - nil, 207, nil, 146, nil, 347, 347, nil, nil, nil, - 248, nil, nil, nil, nil, 85, nil, nil, nil, nil, - nil, nil, nil, nil, nil, nil, nil, nil, nil, 253, - nil, nil, nil, nil, nil, nil, 250, nil, nil, nil, - nil, nil, nil, nil, nil, nil, nil, nil, 250, 262, - 263, 264, nil, 266, 267, 268, 269, 270, 271, 272, - nil, 274, 275, 276, nil, nil, 281, 248, nil, 350, - 350, nil, nil, nil, 253, nil, nil, nil, nil, 248, + 27, 13, 20, 222, 89, 92, 115, 37, 62, 5, + 65, 196, 256, 145, 230, 150, 118, 50, 155, 301, + 27, 13, 246, 75, 73, 57, 133, 235, 201, 5, + 250, 214, 149, 119, 337, 165, 121, 344, 136, 69, + 169, 120, 27, 126, 142, 22, 27, 126, 300, 134, + 128, 89, 63, 151, 128, 168, 125, 65, 280, 124, + 130, 42, 192, 124, 46, 349, 353, 138, 244, 87, + 163, 73, 252, 369, 211, 332, 323, 168, 303, 116, + 135, 140, 123, 224, 298, 56, 69, 305, 371, 168, + 195, 159, 227, 237, 220, 123, 246, 148, 221, 63, + 331, 160, 110, 315, 355, 194, 212, 17, 325, nil, + nil, 86, nil, nil, nil, nil, 87, nil, 250, nil, + 294, nil, nil, nil, nil, nil, nil, nil, nil, nil, + nil, nil, nil, nil, nil, nil, nil, nil, 239, 86, + nil, nil, nil, nil, nil, nil, nil, 89, 149, nil, + nil, 89, 266, 65, 248, nil, nil, 65, 86, nil, + nil, 343, nil, 303, 236, nil, 289, 245, nil, nil, + 262, 73, nil, nil, nil, 82, 247, nil, nil, 226, + nil, nil, 69, nil, nil, nil, 69, nil, 27, 13, + 317, 362, 150, 365, 340, 63, 149, 5, nil, 63, + 304, 151, 248, 143, 370, 85, 329, nil, 320, 149, + 322, nil, 87, 148, 378, 136, 87, 27, 13, nil, + 375, 89, 82, nil, 247, 321, 5, 65, nil, 54, + 318, 313, 250, 146, nil, 151, 149, 333, 27, 13, + nil, 245, 248, 380, 138, nil, 382, 5, nil, nil, + nil, nil, 85, nil, 86, 86, 69, 135, 86, nil, + nil, 148, nil, 210, 247, 342, 210, 62, nil, 63, + 80, nil, nil, 195, 148, nil, 149, 149, nil, 27, + 13, 149, 347, 347, 360, 361, 87, 248, 5, nil, + nil, nil, nil, nil, nil, nil, nil, nil, 141, nil, + nil, 148, nil, 86, 247, 247, nil, 367, nil, 247, + nil, nil, 27, 13, 363, 372, 86, 80, 82, 251, + nil, 5, 82, nil, 346, 346, nil, nil, 86, nil, + nil, nil, nil, nil, nil, nil, nil, nil, 149, nil, + nil, 352, 352, 86, 248, nil, 148, nil, 85, 254, + 149, 62, 85, nil, nil, 210, 248, nil, 207, nil, + nil, 207, nil, 27, 13, nil, 247, 251, 54, 54, + nil, nil, 5, 27, 13, nil, 27, 13, 247, nil, + 143, nil, 5, 86, 86, 5, nil, nil, 86, nil, + nil, nil, 82, nil, 274, nil, nil, 254, 278, nil, + nil, nil, nil, 148, nil, nil, nil, 251, nil, nil, + 146, nil, nil, 80, 249, 148, nil, 80, nil, nil, + nil, nil, 85, nil, nil, nil, nil, nil, nil, 129, + nil, 131, 132, nil, nil, nil, nil, 254, nil, nil, + nil, nil, nil, 210, nil, 86, nil, 350, 350, nil, + 207, nil, 251, nil, nil, 164, nil, 86, nil, nil, + nil, nil, 249, nil, nil, nil, nil, nil, nil, nil, + nil, nil, nil, nil, 171, 141, nil, 351, 351, 190, + nil, nil, 254, 191, nil, nil, nil, 80, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, + nil, nil, 249, nil, nil, nil, nil, nil, nil, 251, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, + nil, 251, nil, nil, nil, nil, nil, nil, nil, nil, + nil, nil, nil, nil, nil, nil, nil, nil, 207, 254, + nil, nil, 348, 348, nil, nil, nil, 249, nil, nil, + nil, 254, nil, nil, nil, nil, 263, 264, 265, nil, + 267, 268, 269, 270, 271, 272, 273, nil, 275, 276, + 277, nil, nil, 282, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, - nil, nil, nil, nil, nil, nil, nil, nil, nil, 164, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, - nil, 253, nil, nil, nil, nil, nil, nil, nil, nil, - nil, nil, nil, 253 ] + nil, nil, nil, nil, 249, nil, nil, nil, nil, nil, + nil, nil, nil, nil, nil, nil, 249, nil, nil, nil, + nil, nil, nil, nil, nil, nil, 164 ] racc_goto_check = [ - 38, 22, 53, 33, 4, 71, 69, 2, 73, 86, - 63, 29, 36, 33, 39, 67, 32, 30, 83, 64, - 38, 22, 53, 61, 22, 23, 79, 5, 47, 47, - 24, 54, 48, 38, 43, 51, 75, 37, 31, 29, - 66, 3, 38, 22, 32, 30, 38, 22, 42, 75, - 37, 42, 6, 28, 69, 50, 5, 62, 29, 21, - 58, 6, 21, 32, 30, 6, 31, 70, 59, 72, - 57, 22, 23, 64, 36, 20, 8, 5, 3, 20, - 8, 28, 58, 50, 74, 31, 34, 76, 77, 78, - 35, 3, 71, 69, 58, 80, 81, 3, 82, 67, - 28, 41, 50, 55, 24, 84, 85, 37, 1, nil, - nil, nil, nil, nil, nil, nil, nil, nil, 31, nil, - nil, nil, nil, 55, nil, nil, nil, nil, nil, nil, - nil, nil, nil, nil, 65, nil, nil, nil, 69, nil, + 38, 22, 2, 83, 29, 63, 55, 33, 4, 53, + 31, 86, 71, 48, 37, 51, 73, 33, 39, 67, + 38, 22, 24, 23, 22, 79, 55, 37, 42, 53, + 69, 42, 29, 38, 64, 61, 75, 43, 31, 32, + 58, 6, 38, 22, 36, 3, 38, 22, 66, 75, + 6, 29, 30, 54, 6, 55, 20, 31, 5, 8, + 20, 21, 58, 8, 21, 47, 47, 32, 62, 28, + 23, 22, 70, 59, 58, 72, 57, 55, 69, 74, + 30, 34, 3, 76, 37, 77, 32, 5, 64, 55, + 31, 78, 35, 80, 81, 3, 24, 28, 82, 30, + 71, 3, 41, 84, 67, 85, 36, 1, 5, nil, + nil, 50, nil, nil, nil, nil, 28, nil, 69, nil, 42, nil, nil, nil, nil, nil, nil, nil, nil, nil, - nil, nil, 55, nil, 29, 29, nil, nil, 29, 32, - 30, nil, 39, 32, 30, 79, nil, 22, nil, nil, - nil, 22, 23, 26, 55, 3, nil, nil, nil, 54, - nil, 31, 31, 37, nil, 31, 55, nil, 38, 22, - 53, 86, 73, 36, 61, 69, 28, 28, 50, 50, - 28, 26, 50, 29, 25, 83, 71, 69, 54, 48, - nil, 5, 51, 54, 5, 37, 29, 38, 22, 53, - 26, 32, 30, nil, nil, nil, 37, 33, 29, nil, - 31, nil, 25, 32, 30, 55, nil, nil, 38, 22, - 53, 22, 29, 31, nil, 28, nil, 50, nil, 55, - nil, 25, nil, nil, nil, 31, nil, nil, 28, nil, - 50, 26, 4, nil, 26, nil, nil, nil, 27, 31, - 28, nil, 50, 65, 65, nil, nil, nil, 38, 22, - 53, nil, 29, 29, 28, nil, 50, 29, 30, 30, - nil, nil, 25, nil, nil, 25, 27, nil, nil, 65, - 31, nil, nil, 65, nil, 55, nil, 55, nil, 31, - 31, 38, 22, 53, 31, 27, 26, 26, 2, 63, - 26, nil, nil, nil, 28, 28, 50, 50, nil, 28, - nil, 50, nil, 55, nil, nil, nil, nil, nil, nil, - nil, nil, nil, nil, 29, nil, 4, 25, 25, nil, - nil, 25, nil, 26, nil, nil, 29, nil, nil, nil, - nil, 55, 38, 22, 53, 26, nil, nil, nil, nil, - nil, 31, 38, 22, 53, 38, 22, 53, 26, nil, - 55, 55, nil, 31, 25, nil, 28, nil, 50, nil, - 26, nil, 52, nil, 52, 52, 25, nil, 28, nil, - 50, nil, nil, 55, 26, nil, nil, nil, nil, 25, - nil, 27, 27, nil, nil, 27, nil, nil, 52, nil, - nil, 25, nil, nil, nil, nil, nil, nil, nil, nil, - nil, nil, nil, nil, nil, 25, nil, 52, nil, nil, - 26, nil, 52, nil, 26, 26, 52, nil, nil, 26, + nil, nil, nil, nil, nil, nil, nil, nil, 55, 50, + nil, nil, nil, nil, nil, nil, nil, 29, 29, nil, + nil, 29, 55, 31, 31, nil, nil, 31, 50, nil, + nil, 37, nil, 69, 79, nil, 39, 22, nil, nil, + 23, 22, nil, nil, nil, 26, 53, nil, nil, 3, + nil, nil, 32, nil, nil, nil, 32, nil, 38, 22, + 48, 83, 51, 37, 86, 30, 29, 53, nil, 30, + 73, 54, 31, 26, 37, 27, 61, nil, 55, 29, + 55, nil, 28, 28, 71, 31, 28, 38, 22, nil, + 69, 29, 26, nil, 53, 36, 53, 31, nil, 65, + 54, 33, 69, 27, nil, 54, 29, 55, 38, 22, + nil, 22, 31, 5, 32, nil, 5, 53, nil, nil, + nil, nil, 27, nil, 50, 50, 32, 30, 50, nil, + nil, 28, nil, 26, 53, 55, 26, 4, nil, 30, + 25, nil, nil, 31, 28, nil, 29, 29, nil, 38, + 22, 29, 31, 31, 55, 55, 28, 31, 53, nil, + nil, nil, nil, nil, nil, nil, nil, nil, 25, nil, + nil, 28, nil, 50, 53, 53, nil, 55, nil, 53, + nil, nil, 38, 22, 2, 63, 50, 25, 26, 26, + nil, 53, 26, nil, 30, 30, nil, nil, 50, nil, + nil, nil, nil, nil, nil, nil, nil, nil, 29, nil, + nil, 28, 28, 50, 31, nil, 28, nil, 27, 27, + 29, 4, 27, nil, nil, 26, 31, nil, 25, nil, + nil, 25, nil, 38, 22, nil, 53, 26, 65, 65, + nil, nil, 53, 38, 22, nil, 38, 22, 53, nil, + 26, nil, 53, 50, 50, 53, nil, nil, 50, nil, + nil, nil, 26, nil, 65, nil, nil, 27, 65, nil, + nil, nil, nil, 28, nil, nil, nil, 26, nil, nil, + 27, nil, nil, 25, 25, 28, nil, 25, nil, nil, + nil, nil, 27, nil, nil, nil, nil, nil, nil, 52, + nil, 52, 52, nil, nil, nil, nil, 27, nil, nil, + nil, nil, nil, 26, nil, 50, nil, 26, 26, nil, + 25, nil, 26, nil, nil, 52, nil, 50, nil, nil, + nil, nil, 25, nil, nil, nil, nil, nil, nil, nil, + nil, nil, nil, nil, 52, 25, nil, 27, 27, 52, + nil, nil, 27, 52, nil, nil, nil, 25, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, - 27, nil, nil, nil, nil, nil, nil, nil, nil, nil, - nil, 25, nil, 27, nil, 25, 25, nil, nil, nil, - 25, nil, nil, nil, nil, 27, nil, nil, nil, nil, - nil, nil, nil, nil, nil, nil, nil, nil, nil, 27, - nil, nil, nil, nil, nil, nil, 26, nil, nil, nil, - nil, nil, nil, nil, nil, nil, nil, nil, 26, 52, - 52, 52, nil, 52, 52, 52, 52, 52, 52, 52, - nil, 52, 52, 52, nil, nil, 52, 25, nil, 27, - 27, nil, nil, nil, 27, nil, nil, nil, nil, 25, + nil, nil, 25, nil, nil, nil, nil, nil, nil, 26, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, + nil, 26, nil, nil, nil, nil, nil, nil, nil, nil, + nil, nil, nil, nil, nil, nil, nil, nil, 25, 27, + nil, nil, 25, 25, nil, nil, nil, 25, nil, nil, + nil, 27, nil, nil, nil, nil, 52, 52, 52, nil, + 52, 52, 52, 52, 52, 52, 52, nil, 52, 52, + 52, nil, nil, 52, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, - nil, nil, nil, nil, nil, nil, nil, nil, nil, 52, - nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, - nil, 27, nil, nil, nil, nil, nil, nil, nil, nil, - nil, nil, nil, 27 ] + nil, nil, nil, nil, 25, nil, nil, nil, nil, nil, + nil, nil, nil, nil, nil, nil, 25, nil, nil, nil, + nil, nil, nil, nil, nil, nil, 52 ] racc_goto_pointer = [ - nil, 108, 7, 41, -16, -161, 19, nil, 34, nil, + nil, 107, 2, 45, -12, -130, 8, nil, 17, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, - 33, 56, 1, 2, -136, 181, 150, 245, 30, -12, - -6, 15, -7, 2, 35, -50, -39, -105, 0, -38, - nil, 74, -63, -256, nil, nil, nil, -266, -19, nil, - 32, -16, 347, 2, -21, 74, nil, -164, -18, -263, - nil, -48, -107, -16, -261, 116, -175, -200, nil, -161, - -100, -162, -185, -24, 52, -1, -47, 70, 33, 8, - -63, -26, -24, -104, -120, 3, -94, nil ] + 14, 58, 1, 0, -144, 247, 152, 182, 46, -19, + 29, -13, 16, 6, 30, -48, -7, -128, 0, -34, + nil, 75, -83, -254, nil, nil, nil, -230, -38, nil, + 88, -36, 384, 9, 1, -23, nil, -158, -38, -259, + nil, -36, -96, -21, -247, 211, -167, -196, nil, -137, + -95, -155, -180, -16, 47, -1, -51, 67, 35, 7, + -65, -28, -24, -119, -122, 2, -92, nil ] racc_goto_default = [ - nil, nil, 278, 208, 25, nil, 31, 35, 4, 7, + nil, nil, 279, 208, 25, nil, 31, 35, 4, 7, 9, 14, 16, 19, 21, 24, 28, 30, 34, 3, 6, nil, 98, nil, 76, 101, 102, 105, 107, 108, 93, 94, 96, 12, nil, nil, nil, nil, 83, nil, - 33, nil, nil, 204, 290, 205, 206, nil, nil, 147, - 106, 109, 91, 64, 137, 97, 152, 153, nil, 259, - 104, nil, nil, nil, nil, 67, nil, nil, 301, 77, + 33, nil, nil, 204, 291, 205, 206, nil, nil, 147, + 106, 109, 91, 64, 137, 97, 152, 153, nil, 260, + 104, nil, nil, nil, nil, 67, nil, nil, 302, 77, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 58, nil, nil, nil, nil, nil, nil, 197 ] -racc_token_table = { - false => 0, - Object.new => 1, - :STRING => 2, - :DQPRE => 3, - :DQMID => 4, - :DQPOST => 5, - :LBRACK => 6, - :RBRACK => 7, - :LBRACE => 8, - :RBRACE => 9, - :SYMBOL => 10, - :FARROW => 11, - :COMMA => 12, - :TRUE => 13, - :FALSE => 14, - :EQUALS => 15, - :APPENDS => 16, - :LESSEQUAL => 17, - :NOTEQUAL => 18, - :DOT => 19, - :COLON => 20, - :LLCOLLECT => 21, - :RRCOLLECT => 22, - :QMARK => 23, - :LPAREN => 24, - :RPAREN => 25, - :ISEQUAL => 26, - :GREATEREQUAL => 27, - :GREATERTHAN => 28, - :LESSTHAN => 29, - :IF => 30, - :ELSE => 31, - :IMPORT => 32, - :DEFINE => 33, - :ELSIF => 34, - :VARIABLE => 35, - :CLASS => 36, - :INHERITS => 37, - :NODE => 38, - :BOOLEAN => 39, - :NAME => 40, - :SEMIC => 41, - :CASE => 42, - :DEFAULT => 43, - :AT => 44, - :LCOLLECT => 45, - :RCOLLECT => 46, - :CLASSNAME => 47, - :CLASSREF => 48, - :NOT => 49, - :OR => 50, - :AND => 51, - :UNDEF => 52, - :PARROW => 53, - :PLUS => 54, - :MINUS => 55, - :TIMES => 56, - :DIV => 57, - :LSHIFT => 58, - :RSHIFT => 59, - :UMINUS => 60, - :MATCH => 61, - :NOMATCH => 62, - :REGEX => 63, - :IN_EDGE => 64, - :OUT_EDGE => 65, - :IN_EDGE_SUB => 66, - :OUT_EDGE_SUB => 67, - :IN => 68 } +racc_reduce_table = [ + 0, 0, :racc_error, + 1, 70, :_reduce_none, + 1, 70, :_reduce_none, + 1, 71, :_reduce_3, + 2, 71, :_reduce_4, + 1, 74, :_reduce_5, + 1, 73, :_reduce_none, + 1, 73, :_reduce_none, + 1, 73, :_reduce_none, + 1, 73, :_reduce_none, + 1, 73, :_reduce_none, + 1, 73, :_reduce_none, + 1, 73, :_reduce_none, + 1, 73, :_reduce_none, + 1, 73, :_reduce_none, + 1, 73, :_reduce_none, + 1, 73, :_reduce_none, + 1, 73, :_reduce_none, + 1, 73, :_reduce_none, + 1, 73, :_reduce_none, + 3, 88, :_reduce_20, + 3, 88, :_reduce_21, + 1, 89, :_reduce_none, + 1, 89, :_reduce_none, + 1, 89, :_reduce_none, + 1, 90, :_reduce_none, + 1, 90, :_reduce_none, + 1, 90, :_reduce_none, + 1, 90, :_reduce_none, + 4, 82, :_reduce_29, + 5, 82, :_reduce_30, + 3, 82, :_reduce_31, + 2, 82, :_reduce_32, + 1, 92, :_reduce_33, + 1, 92, :_reduce_34, + 3, 92, :_reduce_35, + 3, 92, :_reduce_36, + 1, 93, :_reduce_none, + 1, 93, :_reduce_none, + 1, 93, :_reduce_none, + 1, 93, :_reduce_none, + 1, 93, :_reduce_none, + 1, 93, :_reduce_none, + 1, 93, :_reduce_none, + 1, 93, :_reduce_none, + 1, 93, :_reduce_45, + 5, 75, :_reduce_46, + 5, 75, :_reduce_47, + 5, 75, :_reduce_48, + 5, 86, :_reduce_49, + 2, 76, :_reduce_50, + 1, 109, :_reduce_51, + 2, 109, :_reduce_52, + 6, 77, :_reduce_53, + 2, 77, :_reduce_54, + 3, 110, :_reduce_55, + 3, 110, :_reduce_56, + 1, 111, :_reduce_none, + 1, 111, :_reduce_none, + 3, 111, :_reduce_59, + 1, 112, :_reduce_none, + 3, 112, :_reduce_61, + 1, 113, :_reduce_62, + 1, 113, :_reduce_63, + 3, 114, :_reduce_64, + 3, 114, :_reduce_65, + 1, 115, :_reduce_none, + 1, 115, :_reduce_none, + 4, 117, :_reduce_68, + 1, 103, :_reduce_69, + 3, 103, :_reduce_70, + 0, 104, :_reduce_none, + 1, 104, :_reduce_none, + 1, 119, :_reduce_73, + 1, 94, :_reduce_74, + 1, 96, :_reduce_75, + 1, 118, :_reduce_none, + 1, 118, :_reduce_none, + 1, 118, :_reduce_none, + 1, 118, :_reduce_none, + 1, 118, :_reduce_none, + 1, 118, :_reduce_none, + 1, 118, :_reduce_none, + 3, 78, :_reduce_83, + 3, 78, :_reduce_84, + 3, 87, :_reduce_85, + 0, 105, :_reduce_86, + 1, 105, :_reduce_87, + 3, 105, :_reduce_88, + 3, 123, :_reduce_89, + 3, 125, :_reduce_90, + 1, 126, :_reduce_none, + 1, 126, :_reduce_none, + 0, 108, :_reduce_93, + 1, 108, :_reduce_94, + 3, 108, :_reduce_95, + 1, 127, :_reduce_96, + 3, 127, :_reduce_97, + 1, 116, :_reduce_none, + 1, 116, :_reduce_none, + 1, 116, :_reduce_none, + 1, 116, :_reduce_none, + 1, 116, :_reduce_none, + 1, 116, :_reduce_none, + 1, 124, :_reduce_none, + 1, 124, :_reduce_none, + 1, 124, :_reduce_none, + 1, 124, :_reduce_none, + 1, 124, :_reduce_none, + 1, 124, :_reduce_none, + 1, 124, :_reduce_none, + 1, 124, :_reduce_none, + 1, 124, :_reduce_none, + 1, 124, :_reduce_none, + 1, 124, :_reduce_none, + 1, 124, :_reduce_none, + 4, 98, :_reduce_116, + 3, 98, :_reduce_117, + 1, 100, :_reduce_118, + 2, 100, :_reduce_119, + 2, 130, :_reduce_120, + 1, 131, :_reduce_121, + 2, 131, :_reduce_122, + 1, 97, :_reduce_123, + 4, 91, :_reduce_124, + 4, 91, :_reduce_125, + 2, 80, :_reduce_126, + 5, 132, :_reduce_127, + 4, 132, :_reduce_128, + 0, 133, :_reduce_none, + 2, 133, :_reduce_130, + 4, 133, :_reduce_131, + 3, 133, :_reduce_132, + 1, 121, :_reduce_none, + 3, 121, :_reduce_134, + 3, 121, :_reduce_135, + 3, 121, :_reduce_136, + 3, 121, :_reduce_137, + 3, 121, :_reduce_138, + 3, 121, :_reduce_139, + 3, 121, :_reduce_140, + 3, 121, :_reduce_141, + 3, 121, :_reduce_142, + 2, 121, :_reduce_143, + 3, 121, :_reduce_144, + 3, 121, :_reduce_145, + 3, 121, :_reduce_146, + 3, 121, :_reduce_147, + 3, 121, :_reduce_148, + 3, 121, :_reduce_149, + 2, 121, :_reduce_150, + 3, 121, :_reduce_151, + 3, 121, :_reduce_152, + 3, 121, :_reduce_153, + 5, 79, :_reduce_154, + 1, 135, :_reduce_155, + 2, 135, :_reduce_156, + 5, 136, :_reduce_157, + 4, 136, :_reduce_158, + 1, 137, :_reduce_159, + 3, 137, :_reduce_160, + 3, 99, :_reduce_161, + 1, 139, :_reduce_none, + 4, 139, :_reduce_163, + 1, 141, :_reduce_none, + 3, 141, :_reduce_165, + 3, 140, :_reduce_166, + 1, 138, :_reduce_none, + 1, 138, :_reduce_none, + 1, 138, :_reduce_none, + 1, 138, :_reduce_none, + 1, 138, :_reduce_none, + 1, 138, :_reduce_none, + 1, 138, :_reduce_none, + 1, 138, :_reduce_none, + 1, 138, :_reduce_175, + 1, 138, :_reduce_none, + 1, 142, :_reduce_177, + 1, 143, :_reduce_none, + 3, 143, :_reduce_179, + 2, 81, :_reduce_180, + 6, 83, :_reduce_181, + 5, 83, :_reduce_182, + 7, 84, :_reduce_183, + 6, 84, :_reduce_184, + 6, 85, :_reduce_185, + 5, 85, :_reduce_186, + 1, 107, :_reduce_187, + 1, 102, :_reduce_188, + 1, 102, :_reduce_189, + 1, 102, :_reduce_190, + 1, 146, :_reduce_191, + 3, 146, :_reduce_192, + 1, 148, :_reduce_193, + 1, 149, :_reduce_194, + 1, 149, :_reduce_195, + 1, 149, :_reduce_196, + 1, 149, :_reduce_none, + 0, 72, :_reduce_198, + 0, 150, :_reduce_199, + 1, 144, :_reduce_none, + 3, 144, :_reduce_201, + 3, 144, :_reduce_202, + 1, 151, :_reduce_none, + 3, 151, :_reduce_204, + 3, 152, :_reduce_205, + 1, 152, :_reduce_206, + 3, 152, :_reduce_207, + 1, 152, :_reduce_208, + 1, 147, :_reduce_none, + 2, 147, :_reduce_210, + 1, 145, :_reduce_none, + 2, 145, :_reduce_212, + 1, 153, :_reduce_none, + 1, 153, :_reduce_none, + 1, 95, :_reduce_215, + 3, 120, :_reduce_216, + 4, 120, :_reduce_217, + 2, 120, :_reduce_218, + 1, 128, :_reduce_none, + 1, 128, :_reduce_none, + 0, 106, :_reduce_none, + 1, 106, :_reduce_222, + 1, 134, :_reduce_223, + 3, 129, :_reduce_224, + 4, 129, :_reduce_225, + 2, 129, :_reduce_226, + 1, 154, :_reduce_none, + 3, 154, :_reduce_228, + 3, 155, :_reduce_229, + 1, 156, :_reduce_230, + 1, 156, :_reduce_231, + 4, 122, :_reduce_232, + 1, 101, :_reduce_none, + 4, 101, :_reduce_234 ] + +racc_reduce_n = 235 + +racc_shift_n = 386 -racc_use_result_var = true +racc_token_table = { + false => 0, + :error => 1, + :STRING => 2, + :DQPRE => 3, + :DQMID => 4, + :DQPOST => 5, + :LBRACK => 6, + :RBRACK => 7, + :LBRACE => 8, + :RBRACE => 9, + :SYMBOL => 10, + :FARROW => 11, + :COMMA => 12, + :TRUE => 13, + :FALSE => 14, + :EQUALS => 15, + :APPENDS => 16, + :LESSEQUAL => 17, + :NOTEQUAL => 18, + :DOT => 19, + :COLON => 20, + :LLCOLLECT => 21, + :RRCOLLECT => 22, + :QMARK => 23, + :LPAREN => 24, + :RPAREN => 25, + :ISEQUAL => 26, + :GREATEREQUAL => 27, + :GREATERTHAN => 28, + :LESSTHAN => 29, + :IF => 30, + :ELSE => 31, + :IMPORT => 32, + :DEFINE => 33, + :ELSIF => 34, + :VARIABLE => 35, + :CLASS => 36, + :INHERITS => 37, + :NODE => 38, + :BOOLEAN => 39, + :NAME => 40, + :SEMIC => 41, + :CASE => 42, + :DEFAULT => 43, + :AT => 44, + :LCOLLECT => 45, + :RCOLLECT => 46, + :CLASSNAME => 47, + :CLASSREF => 48, + :NOT => 49, + :OR => 50, + :AND => 51, + :UNDEF => 52, + :PARROW => 53, + :PLUS => 54, + :MINUS => 55, + :TIMES => 56, + :DIV => 57, + :LSHIFT => 58, + :RSHIFT => 59, + :UMINUS => 60, + :MATCH => 61, + :NOMATCH => 62, + :REGEX => 63, + :IN_EDGE => 64, + :OUT_EDGE => 65, + :IN_EDGE_SUB => 66, + :OUT_EDGE_SUB => 67, + :IN => 68 } racc_nt_base = 69 +racc_use_result_var = true + Racc_arg = [ - racc_action_table, - racc_action_check, - racc_action_default, - racc_action_pointer, - racc_goto_table, - racc_goto_check, - racc_goto_default, - racc_goto_pointer, - racc_nt_base, - racc_reduce_table, - racc_token_table, - racc_shift_n, - racc_reduce_n, - racc_use_result_var ] + racc_action_table, + racc_action_check, + racc_action_default, + racc_action_pointer, + racc_goto_table, + racc_goto_check, + racc_goto_default, + racc_goto_pointer, + racc_nt_base, + racc_reduce_table, + racc_token_table, + racc_shift_n, + racc_reduce_n, + racc_use_result_var ] Racc_token_to_s_table = [ -'$end', -'error', -'STRING', -'DQPRE', -'DQMID', -'DQPOST', -'LBRACK', -'RBRACK', -'LBRACE', -'RBRACE', -'SYMBOL', -'FARROW', -'COMMA', -'TRUE', -'FALSE', -'EQUALS', -'APPENDS', -'LESSEQUAL', -'NOTEQUAL', -'DOT', -'COLON', -'LLCOLLECT', -'RRCOLLECT', -'QMARK', -'LPAREN', -'RPAREN', -'ISEQUAL', -'GREATEREQUAL', -'GREATERTHAN', -'LESSTHAN', -'IF', -'ELSE', -'IMPORT', -'DEFINE', -'ELSIF', -'VARIABLE', -'CLASS', -'INHERITS', -'NODE', -'BOOLEAN', -'NAME', -'SEMIC', -'CASE', -'DEFAULT', -'AT', -'LCOLLECT', -'RCOLLECT', -'CLASSNAME', -'CLASSREF', -'NOT', -'OR', -'AND', -'UNDEF', -'PARROW', -'PLUS', -'MINUS', -'TIMES', -'DIV', -'LSHIFT', -'RSHIFT', -'UMINUS', -'MATCH', -'NOMATCH', -'REGEX', -'IN_EDGE', -'OUT_EDGE', -'IN_EDGE_SUB', -'OUT_EDGE_SUB', -'IN', -'$start', -'program', -'statements_and_declarations', -'nil', -'statement_or_declaration', -'statements', -'resource', -'virtualresource', -'collection', -'assignment', -'casestatement', -'ifstatement_begin', -'import', -'fstatement', -'definition', -'hostclass', -'nodedef', -'resourceoverride', -'append', -'relationship', -'relationship_side', -'edge', -'resourceref', -'funcvalues', -'namestring', -'name', -'variable', -'type', -'boolean', -'funcrvalue', -'selector', -'quotedtext', -'hasharrayaccesses', -'classname', -'resourceinstances', -'endsemi', -'params', -'endcomma', -'classref', -'anyparams', -'at', -'collectrhand', -'collstatements', -'collstatement', -'colljoin', -'collexpr', -'colllval', -'simplervalue', -'resourceinst', -'resourcename', -'undef', -'array', -'expression', -'hasharrayaccess', -'param', -'rvalue', -'addparam', -'anyparam', -'rvalues', -'comma', -'hash', -'dqrval', -'dqtail', -'ifstatement', -'else', -'regex', -'caseopts', -'caseopt', -'casevalues', -'selectlhand', -'svalues', -'selectval', -'sintvalues', -'string', -'strings', -'argumentlist', -'classparent', -'hostnames', -'nodeparent', -'nodename', -'hostname', -'nothing', -'arguments', -'argument', -'classnameordefault', -'hashpairs', -'hashpair', -'key'] + "$end", + "error", + "STRING", + "DQPRE", + "DQMID", + "DQPOST", + "LBRACK", + "RBRACK", + "LBRACE", + "RBRACE", + "SYMBOL", + "FARROW", + "COMMA", + "TRUE", + "FALSE", + "EQUALS", + "APPENDS", + "LESSEQUAL", + "NOTEQUAL", + "DOT", + "COLON", + "LLCOLLECT", + "RRCOLLECT", + "QMARK", + "LPAREN", + "RPAREN", + "ISEQUAL", + "GREATEREQUAL", + "GREATERTHAN", + "LESSTHAN", + "IF", + "ELSE", + "IMPORT", + "DEFINE", + "ELSIF", + "VARIABLE", + "CLASS", + "INHERITS", + "NODE", + "BOOLEAN", + "NAME", + "SEMIC", + "CASE", + "DEFAULT", + "AT", + "LCOLLECT", + "RCOLLECT", + "CLASSNAME", + "CLASSREF", + "NOT", + "OR", + "AND", + "UNDEF", + "PARROW", + "PLUS", + "MINUS", + "TIMES", + "DIV", + "LSHIFT", + "RSHIFT", + "UMINUS", + "MATCH", + "NOMATCH", + "REGEX", + "IN_EDGE", + "OUT_EDGE", + "IN_EDGE_SUB", + "OUT_EDGE_SUB", + "IN", + "$start", + "program", + "statements_and_declarations", + "nil", + "statement_or_declaration", + "statements", + "resource", + "virtualresource", + "collection", + "assignment", + "casestatement", + "ifstatement_begin", + "import", + "fstatement", + "definition", + "hostclass", + "nodedef", + "resourceoverride", + "append", + "relationship", + "relationship_side", + "edge", + "resourceref", + "funcvalues", + "namestring", + "name", + "variable", + "type", + "boolean", + "funcrvalue", + "selector", + "quotedtext", + "hasharrayaccesses", + "classname", + "resourceinstances", + "endsemi", + "params", + "endcomma", + "classref", + "anyparams", + "at", + "collectrhand", + "collstatements", + "collstatement", + "colljoin", + "collexpr", + "colllval", + "simplervalue", + "resourceinst", + "resourcename", + "undef", + "array", + "expression", + "hasharrayaccess", + "param", + "rvalue", + "addparam", + "anyparam", + "rvalues", + "comma", + "hash", + "dqrval", + "dqtail", + "ifstatement", + "else", + "regex", + "caseopts", + "caseopt", + "casevalues", + "selectlhand", + "svalues", + "selectval", + "sintvalues", + "string", + "strings", + "argumentlist", + "classparent", + "hostnames", + "nodeparent", + "nodename", + "hostname", + "nothing", + "arguments", + "argument", + "classnameordefault", + "hashpairs", + "hashpair", + "key" ] Racc_debug_parser = false -##### racc system variables end ##### +##### State transition tables end ##### - # reduce 0 omitted +# reduce 0 omitted - # reduce 1 omitted +# reduce 1 omitted - # reduce 2 omitted +# reduce 2 omitted -module_eval <<'.,.,', 'grammar.ra', 36 - def _reduce_3( val, _values, result ) - result = ast AST::ASTArray, :children => (val[0] ? [val[0]] : []) - result +module_eval(<<'.,.,', 'grammar.ra', 34) + def _reduce_3(val, _values, result) + result = ast AST::ASTArray, :children => (val[0] ? [val[0]] : []) + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 42 - def _reduce_4( val, _values, result ) - if val[1] +module_eval(<<'.,.,', 'grammar.ra', 37) + def _reduce_4(val, _values, result) + if val[1] val[0].push(val[1]) end result = val[0] - result + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 54 - def _reduce_5( val, _values, result ) - val[0].each do |stmt| +module_eval(<<'.,.,', 'grammar.ra', 46) + def _reduce_5(val, _values, result) + val[0].each do |stmt| if stmt.is_a?(AST::TopLevelConstruct) error "Classes, definitions, and nodes may only appear at toplevel or inside other classes", \ :line => stmt.context[:line], :file => stmt.context[:file] end end result = val[0] - result + + result end .,., - # reduce 6 omitted +# reduce 6 omitted + +# reduce 7 omitted - # reduce 7 omitted +# reduce 8 omitted - # reduce 8 omitted +# reduce 9 omitted - # reduce 9 omitted +# reduce 10 omitted - # reduce 10 omitted +# reduce 11 omitted - # reduce 11 omitted +# reduce 12 omitted - # reduce 12 omitted +# reduce 13 omitted - # reduce 13 omitted +# reduce 14 omitted - # reduce 14 omitted +# reduce 15 omitted - # reduce 15 omitted +# reduce 16 omitted - # reduce 16 omitted +# reduce 17 omitted - # reduce 17 omitted +# reduce 18 omitted - # reduce 18 omitted +# reduce 19 omitted - # reduce 19 omitted +module_eval(<<'.,.,', 'grammar.ra', 72) + def _reduce_20(val, _values, result) + result = AST::Relationship.new(val[0], val[2], val[1][:value], ast_context) -module_eval <<'.,.,', 'grammar.ra', 74 - def _reduce_20( val, _values, result ) - result = AST::Relationship.new(val[0], val[2], val[1][:value], ast_context) - result + result end .,., -module_eval <<'.,.,', 'grammar.ra', 77 - def _reduce_21( val, _values, result ) - result = AST::Relationship.new(val[0], val[2], val[1][:value], ast_context) - result +module_eval(<<'.,.,', 'grammar.ra', 75) + def _reduce_21(val, _values, result) + result = AST::Relationship.new(val[0], val[2], val[1][:value], ast_context) + + result end .,., - # reduce 22 omitted +# reduce 22 omitted - # reduce 23 omitted +# reduce 23 omitted - # reduce 24 omitted +# reduce 24 omitted - # reduce 25 omitted +# reduce 25 omitted - # reduce 26 omitted +# reduce 26 omitted - # reduce 27 omitted +# reduce 27 omitted - # reduce 28 omitted +# reduce 28 omitted -module_eval <<'.,.,', 'grammar.ra', 89 - def _reduce_29( val, _values, result ) - result = ast AST::Function, +module_eval(<<'.,.,', 'grammar.ra', 83) + def _reduce_29(val, _values, result) + result = ast AST::Function, :name => val[0][:value], :line => val[0][:line], :arguments => val[2], :ftype => :statement - result + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 96 - def _reduce_30( val, _values, result ) - result = ast AST::Function, +module_eval(<<'.,.,', 'grammar.ra', 90) + def _reduce_30(val, _values, result) + result = ast AST::Function, :name => val[0][:value], :line => val[0][:line], :arguments => val[2], :ftype => :statement - result + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 102 - def _reduce_31( val, _values, result ) - result = ast AST::Function, +module_eval(<<'.,.,', 'grammar.ra', 96) + def _reduce_31(val, _values, result) + result = ast AST::Function, :name => val[0][:value], :line => val[0][:line], :arguments => AST::ASTArray.new({}), :ftype => :statement - result + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 109 - def _reduce_32( val, _values, result ) - result = ast AST::Function, +module_eval(<<'.,.,', 'grammar.ra', 103) + def _reduce_32(val, _values, result) + result = ast AST::Function, :name => val[0][:value], :line => val[0][:line], :arguments => val[1], :ftype => :statement - result + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 110 - def _reduce_33( val, _values, result ) - result = aryfy(val[0]) - result +module_eval(<<'.,.,', 'grammar.ra', 110) + def _reduce_33(val, _values, result) + result = aryfy(val[0]) + result end .,., -module_eval <<'.,.,', 'grammar.ra', 111 - def _reduce_34( val, _values, result ) - result = aryfy(val[0]) - result +module_eval(<<'.,.,', 'grammar.ra', 111) + def _reduce_34(val, _values, result) + result = aryfy(val[0]) + result end .,., -module_eval <<'.,.,', 'grammar.ra', 116 - def _reduce_35( val, _values, result ) - val[0].push(val[2]) +module_eval(<<'.,.,', 'grammar.ra', 113) + def _reduce_35(val, _values, result) + val[0].push(val[2]) result = val[0] - result + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 120 - def _reduce_36( val, _values, result ) - val[0].push(val[2]) +module_eval(<<'.,.,', 'grammar.ra', 117) + def _reduce_36(val, _values, result) + val[0].push(val[2]) result = val[0] - result + + result end .,., - # reduce 37 omitted +# reduce 37 omitted - # reduce 38 omitted +# reduce 38 omitted - # reduce 39 omitted +# reduce 39 omitted - # reduce 40 omitted +# reduce 40 omitted - # reduce 41 omitted +# reduce 41 omitted - # reduce 42 omitted +# reduce 42 omitted - # reduce 43 omitted +# reduce 43 omitted - # reduce 44 omitted +# reduce 44 omitted -module_eval <<'.,.,', 'grammar.ra', 134 - def _reduce_45( val, _values, result ) - result = ast AST::Name, :value => val[0][:value] - result +module_eval(<<'.,.,', 'grammar.ra', 132) + def _reduce_45(val, _values, result) + result = ast AST::Name, :value => val[0][:value] + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 139 - def _reduce_46( val, _values, result ) - @lexer.commentpop +module_eval(<<'.,.,', 'grammar.ra', 136) + def _reduce_46(val, _values, result) + @lexer.commentpop result = ast(AST::Resource, :type => val[0], :instances => val[2]) - result + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 142 - def _reduce_47( val, _values, result ) - # This is a deprecated syntax. +module_eval(<<'.,.,', 'grammar.ra', 139) + def _reduce_47(val, _values, result) + # This is a deprecated syntax. error "All resource specifications require names" - result + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 146 - def _reduce_48( val, _values, result ) - # a defaults setting for a type +module_eval(<<'.,.,', 'grammar.ra', 142) + def _reduce_48(val, _values, result) + # a defaults setting for a type @lexer.commentpop result = ast(AST::ResourceDefaults, :type => val[0], :parameters => val[2]) - result + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 152 - def _reduce_49( val, _values, result ) - @lexer.commentpop +module_eval(<<'.,.,', 'grammar.ra', 149) + def _reduce_49(val, _values, result) + @lexer.commentpop result = ast AST::ResourceOverride, :object => val[0], :parameters => val[2] - result + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 171 - def _reduce_50( val, _values, result ) - type = val[0] +module_eval(<<'.,.,', 'grammar.ra', 156) + def _reduce_50(val, _values, result) + type = val[0] if (type == :exported and ! Puppet[:storeconfigs]) and ! Puppet[:parseonly] Puppet.warning addcontext("You cannot collect without storeconfigs being set") end error "Defaults are not virtualizable" if val[1].is_a? AST::ResourceDefaults method = type.to_s + "=" # Just mark our resource as exported and pass it through. val[1].send(method, true) result = val[1] - result + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 172 - def _reduce_51( val, _values, result ) - result = :virtual - result +module_eval(<<'.,.,', 'grammar.ra', 172) + def _reduce_51(val, _values, result) + result = :virtual + result end .,., -module_eval <<'.,.,', 'grammar.ra', 173 - def _reduce_52( val, _values, result ) - result = :exported - result +module_eval(<<'.,.,', 'grammar.ra', 173) + def _reduce_52(val, _values, result) + result = :exported + result end .,., -module_eval <<'.,.,', 'grammar.ra', 196 - def _reduce_53( val, _values, result ) - @lexer.commentpop +module_eval(<<'.,.,', 'grammar.ra', 178) + def _reduce_53(val, _values, result) + @lexer.commentpop Puppet.warning addcontext("Collection names must now be capitalized") if val[0] =~ /^[a-z]/ type = val[0].downcase args = {:type => type} if val[1].is_a?(AST::CollExpr) args[:query] = val[1] args[:query].type = type args[:form] = args[:query].form else args[:form] = val[1] end if args[:form] == :exported and ! Puppet[:storeconfigs] and ! Puppet[:parseonly] Puppet.warning addcontext("You cannot collect exported resources without storeconfigs being set; the collection will be ignored") end args[:override] = val[3] result = ast AST::Collection, args - result + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 215 - def _reduce_54( val, _values, result ) - if val[0] =~ /^[a-z]/ +module_eval(<<'.,.,', 'grammar.ra', 197) + def _reduce_54(val, _values, result) + if val[0] =~ /^[a-z]/ Puppet.warning addcontext("Collection names must now be capitalized") end type = val[0].downcase args = {:type => type } if val[1].is_a?(AST::CollExpr) args[:query] = val[1] args[:query].type = type args[:form] = args[:query].form else args[:form] = val[1] end if args[:form] == :exported and ! Puppet[:storeconfigs] and ! Puppet[:parseonly] Puppet.warning addcontext("You cannot collect exported resources without storeconfigs being set; the collection will be ignored") end result = ast AST::Collection, args - result + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 225 - def _reduce_55( val, _values, result ) - if val[1] +module_eval(<<'.,.,', 'grammar.ra', 218) + def _reduce_55(val, _values, result) + if val[1] result = val[1] result.form = :virtual else result = :virtual end - result + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 233 - def _reduce_56( val, _values, result ) - if val[1] +module_eval(<<'.,.,', 'grammar.ra', 226) + def _reduce_56(val, _values, result) + if val[1] result = val[1] result.form = :exported else result = :exported end - result + + result end .,., - # reduce 57 omitted +# reduce 57 omitted - # reduce 58 omitted +# reduce 58 omitted -module_eval <<'.,.,', 'grammar.ra', 241 - def _reduce_59( val, _values, result ) - result = ast AST::CollExpr, :test1 => val[0], :oper => val[1], :test2 => val[2] - result +module_eval(<<'.,.,', 'grammar.ra', 239) + def _reduce_59(val, _values, result) + result = ast AST::CollExpr, :test1 => val[0], :oper => val[1], :test2 => val[2] + + result end .,., - # reduce 60 omitted +# reduce 60 omitted -module_eval <<'.,.,', 'grammar.ra', 247 - def _reduce_61( val, _values, result ) - result = val[1] +module_eval(<<'.,.,', 'grammar.ra', 244) + def _reduce_61(val, _values, result) + result = val[1] result.parens = true - result + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 248 - def _reduce_62( val, _values, result ) - result=val[0][:value] - result +module_eval(<<'.,.,', 'grammar.ra', 248) + def _reduce_62(val, _values, result) + result=val[0][:value] + result end .,., -module_eval <<'.,.,', 'grammar.ra', 249 - def _reduce_63( val, _values, result ) - result=val[0][:value] - result +module_eval(<<'.,.,', 'grammar.ra', 249) + def _reduce_63(val, _values, result) + result=val[0][:value] + result end .,., -module_eval <<'.,.,', 'grammar.ra', 256 - def _reduce_64( val, _values, result ) - result = ast AST::CollExpr, :test1 => val[0], :oper => val[1][:value], :test2 => val[2] +module_eval(<<'.,.,', 'grammar.ra', 252) + def _reduce_64(val, _values, result) + result = ast AST::CollExpr, :test1 => val[0], :oper => val[1][:value], :test2 => val[2] #result = ast AST::CollExpr #result.push *val - result + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 261 - def _reduce_65( val, _values, result ) - result = ast AST::CollExpr, :test1 => val[0], :oper => val[1][:value], :test2 => val[2] +module_eval(<<'.,.,', 'grammar.ra', 257) + def _reduce_65(val, _values, result) + result = ast AST::CollExpr, :test1 => val[0], :oper => val[1][:value], :test2 => val[2] #result = ast AST::CollExpr #result.push *val - result + + result end .,., - # reduce 66 omitted +# reduce 66 omitted - # reduce 67 omitted +# reduce 67 omitted -module_eval <<'.,.,', 'grammar.ra', 268 - def _reduce_68( val, _values, result ) - result = ast AST::ResourceInstance, :title => val[0], :parameters => val[2] - result +module_eval(<<'.,.,', 'grammar.ra', 266) + def _reduce_68(val, _values, result) + result = ast AST::ResourceInstance, :title => val[0], :parameters => val[2] + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 269 - def _reduce_69( val, _values, result ) - result = aryfy(val[0]) - result +module_eval(<<'.,.,', 'grammar.ra', 269) + def _reduce_69(val, _values, result) + result = aryfy(val[0]) + result end .,., -module_eval <<'.,.,', 'grammar.ra', 274 - def _reduce_70( val, _values, result ) - val[0].push val[2] +module_eval(<<'.,.,', 'grammar.ra', 271) + def _reduce_70(val, _values, result) + val[0].push val[2] result = val[0] - result + + result end .,., - # reduce 71 omitted +# reduce 71 omitted - # reduce 72 omitted +# reduce 72 omitted -module_eval <<'.,.,', 'grammar.ra', 281 - def _reduce_73( val, _values, result ) - result = ast AST::Undef, :value => :undef - result +module_eval(<<'.,.,', 'grammar.ra', 279) + def _reduce_73(val, _values, result) + result = ast AST::Undef, :value => :undef + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 285 - def _reduce_74( val, _values, result ) - result = ast AST::Name, :value => val[0][:value], :line => val[0][:line] - result +module_eval(<<'.,.,', 'grammar.ra', 283) + def _reduce_74(val, _values, result) + result = ast AST::Name, :value => val[0][:value], :line => val[0][:line] + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 289 - def _reduce_75( val, _values, result ) - result = ast AST::Type, :value => val[0][:value], :line => val[0][:line] - result +module_eval(<<'.,.,', 'grammar.ra', 287) + def _reduce_75(val, _values, result) + result = ast AST::Type, :value => val[0][:value], :line => val[0][:line] + + result end .,., - # reduce 76 omitted +# reduce 76 omitted - # reduce 77 omitted +# reduce 77 omitted - # reduce 78 omitted +# reduce 78 omitted - # reduce 79 omitted +# reduce 79 omitted - # reduce 80 omitted +# reduce 80 omitted - # reduce 81 omitted +# reduce 81 omitted - # reduce 82 omitted +# reduce 82 omitted -module_eval <<'.,.,', 'grammar.ra', 304 - def _reduce_83( val, _values, result ) - raise Puppet::ParseError, "Cannot assign to variables in other namespaces" if val[0][:value] =~ /::/ +module_eval(<<'.,.,', 'grammar.ra', 299) + def _reduce_83(val, _values, result) + raise Puppet::ParseError, "Cannot assign to variables in other namespaces" if val[0][:value] =~ /::/ # this is distinct from referencing a variable variable = ast AST::Name, :value => val[0][:value], :line => val[0][:line] result = ast AST::VarDef, :name => variable, :value => val[2], :line => val[0][:line] - result + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 307 - def _reduce_84( val, _values, result ) - result = ast AST::VarDef, :name => val[0], :value => val[2] - result +module_eval(<<'.,.,', 'grammar.ra', 305) + def _reduce_84(val, _values, result) + result = ast AST::VarDef, :name => val[0], :value => val[2] + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 312 - def _reduce_85( val, _values, result ) - variable = ast AST::Name, :value => val[0][:value], :line => val[0][:line] +module_eval(<<'.,.,', 'grammar.ra', 309) + def _reduce_85(val, _values, result) + variable = ast AST::Name, :value => val[0][:value], :line => val[0][:line] result = ast AST::VarDef, :name => variable, :value => val[2], :append => true, :line => val[0][:line] - result + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 317 - def _reduce_86( val, _values, result ) - result = ast AST::ASTArray - result +module_eval(<<'.,.,', 'grammar.ra', 315) + def _reduce_86(val, _values, result) + result = ast AST::ASTArray + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 317 - def _reduce_87( val, _values, result ) - result = aryfy(val[0]) - result +module_eval(<<'.,.,', 'grammar.ra', 317) + def _reduce_87(val, _values, result) + result = aryfy(val[0]) + result end .,., -module_eval <<'.,.,', 'grammar.ra', 322 - def _reduce_88( val, _values, result ) - val[0].push(val[2]) +module_eval(<<'.,.,', 'grammar.ra', 319) + def _reduce_88(val, _values, result) + val[0].push(val[2]) result = val[0] - result + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 326 - def _reduce_89( val, _values, result ) - result = ast AST::ResourceParam, :param => val[0][:value], :line => val[0][:line], :value => val[2] - result +module_eval(<<'.,.,', 'grammar.ra', 324) + def _reduce_89(val, _values, result) + result = ast AST::ResourceParam, :param => val[0][:value], :line => val[0][:line], :value => val[2] + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 331 - def _reduce_90( val, _values, result ) - result = ast AST::ResourceParam, :param => val[0][:value], :line => val[0][:line], :value => val[2], +module_eval(<<'.,.,', 'grammar.ra', 328) + def _reduce_90(val, _values, result) + result = ast AST::ResourceParam, :param => val[0][:value], :line => val[0][:line], :value => val[2], :add => true - result + + result end .,., - # reduce 91 omitted +# reduce 91 omitted + +# reduce 92 omitted - # reduce 92 omitted +module_eval(<<'.,.,', 'grammar.ra', 337) + def _reduce_93(val, _values, result) + result = ast AST::ASTArray -module_eval <<'.,.,', 'grammar.ra', 339 - def _reduce_93( val, _values, result ) - result = ast AST::ASTArray - result + result end .,., -module_eval <<'.,.,', 'grammar.ra', 339 - def _reduce_94( val, _values, result ) - result = aryfy(val[0]) - result +module_eval(<<'.,.,', 'grammar.ra', 339) + def _reduce_94(val, _values, result) + result = aryfy(val[0]) + result end .,., -module_eval <<'.,.,', 'grammar.ra', 344 - def _reduce_95( val, _values, result ) - val[0].push(val[2]) +module_eval(<<'.,.,', 'grammar.ra', 341) + def _reduce_95(val, _values, result) + val[0].push(val[2]) result = val[0] - result + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 345 - def _reduce_96( val, _values, result ) - result = aryfy(val[0]) - result +module_eval(<<'.,.,', 'grammar.ra', 345) + def _reduce_96(val, _values, result) + result = aryfy(val[0]) + result end .,., -module_eval <<'.,.,', 'grammar.ra', 346 - def _reduce_97( val, _values, result ) - result = val[0].push(val[2]) - result +module_eval(<<'.,.,', 'grammar.ra', 346) + def _reduce_97(val, _values, result) + result = val[0].push(val[2]) + result end .,., - # reduce 98 omitted +# reduce 98 omitted - # reduce 99 omitted +# reduce 99 omitted - # reduce 100 omitted +# reduce 100 omitted - # reduce 101 omitted +# reduce 101 omitted - # reduce 102 omitted +# reduce 102 omitted - # reduce 103 omitted +# reduce 103 omitted - # reduce 104 omitted +# reduce 104 omitted - # reduce 105 omitted +# reduce 105 omitted - # reduce 106 omitted +# reduce 106 omitted - # reduce 107 omitted +# reduce 107 omitted - # reduce 108 omitted +# reduce 108 omitted - # reduce 109 omitted +# reduce 109 omitted - # reduce 110 omitted +# reduce 110 omitted - # reduce 111 omitted +# reduce 111 omitted - # reduce 112 omitted +# reduce 112 omitted - # reduce 113 omitted +# reduce 113 omitted - # reduce 114 omitted +# reduce 114 omitted - # reduce 115 omitted +# reduce 115 omitted -module_eval <<'.,.,', 'grammar.ra', 375 - def _reduce_116( val, _values, result ) - result = ast AST::Function, +module_eval(<<'.,.,', 'grammar.ra', 370) + def _reduce_116(val, _values, result) + result = ast AST::Function, :name => val[0][:value], :line => val[0][:line], :arguments => val[2], :ftype => :rvalue - result + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 380 - def _reduce_117( val, _values, result ) - result = ast AST::Function, +module_eval(<<'.,.,', 'grammar.ra', 375) + def _reduce_117(val, _values, result) + result = ast AST::Function, :name => val[0][:value], :line => val[0][:line], :arguments => AST::ASTArray.new({}), :ftype => :rvalue - result + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 381 - def _reduce_118( val, _values, result ) - result = ast AST::String, :value => val[0][:value], :line => val[0][:line] - result +module_eval(<<'.,.,', 'grammar.ra', 381) + def _reduce_118(val, _values, result) + result = ast AST::String, :value => val[0][:value], :line => val[0][:line] + result end .,., -module_eval <<'.,.,', 'grammar.ra', 382 - def _reduce_119( val, _values, result ) - result = ast AST::Concat, :value => [ast(AST::String,val[0])]+val[1], :line => val[0][:line] - result +module_eval(<<'.,.,', 'grammar.ra', 382) + def _reduce_119(val, _values, result) + result = ast AST::Concat, :value => [ast(AST::String,val[0])]+val[1], :line => val[0][:line] + result end .,., -module_eval <<'.,.,', 'grammar.ra', 384 - def _reduce_120( val, _values, result ) - result = [val[0]] + val[1] - result +module_eval(<<'.,.,', 'grammar.ra', 384) + def _reduce_120(val, _values, result) + result = [val[0]] + val[1] + result end .,., -module_eval <<'.,.,', 'grammar.ra', 386 - def _reduce_121( val, _values, result ) - result = [ast(AST::String,val[0])] - result +module_eval(<<'.,.,', 'grammar.ra', 386) + def _reduce_121(val, _values, result) + result = [ast(AST::String,val[0])] + result end .,., -module_eval <<'.,.,', 'grammar.ra', 387 - def _reduce_122( val, _values, result ) - result = [ast(AST::String,val[0])] + val[1] - result +module_eval(<<'.,.,', 'grammar.ra', 387) + def _reduce_122(val, _values, result) + result = [ast(AST::String,val[0])] + val[1] + result end .,., -module_eval <<'.,.,', 'grammar.ra', 392 - def _reduce_123( val, _values, result ) - result = ast AST::Boolean, :value => val[0][:value], :line => val[0][:line] - result +module_eval(<<'.,.,', 'grammar.ra', 390) + def _reduce_123(val, _values, result) + result = ast AST::Boolean, :value => val[0][:value], :line => val[0][:line] + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 397 - def _reduce_124( val, _values, result ) - Puppet.warning addcontext("Deprecation notice: Resource references should now be capitalized") +module_eval(<<'.,.,', 'grammar.ra', 394) + def _reduce_124(val, _values, result) + Puppet.warning addcontext("Deprecation notice: Resource references should now be capitalized") result = ast AST::ResourceReference, :type => val[0][:value], :line => val[0][:line], :title => val[2] - result + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 399 - def _reduce_125( val, _values, result ) - result = ast AST::ResourceReference, :type => val[0], :title => val[2] - result +module_eval(<<'.,.,', 'grammar.ra', 397) + def _reduce_125(val, _values, result) + result = ast AST::ResourceReference, :type => val[0], :title => val[2] + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 403 - def _reduce_126( val, _values, result ) - result = val[1] - result +module_eval(<<'.,.,', 'grammar.ra', 401) + def _reduce_126(val, _values, result) + result = val[1] + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 415 - def _reduce_127( val, _values, result ) - @lexer.commentpop +module_eval(<<'.,.,', 'grammar.ra', 405) + def _reduce_127(val, _values, result) + @lexer.commentpop args = { :test => val[0], :statements => val[2] } args[:else] = val[4] if val[4] result = ast AST::IfStatement, args - result + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 426 - def _reduce_128( val, _values, result ) - @lexer.commentpop +module_eval(<<'.,.,', 'grammar.ra', 416) + def _reduce_128(val, _values, result) + @lexer.commentpop args = { :test => val[0], :statements => ast(AST::Nop) } args[:else] = val[3] if val[3] result = ast AST::IfStatement, args - result + + result end .,., - # reduce 129 omitted +# reduce 129 omitted -module_eval <<'.,.,', 'grammar.ra', 431 - def _reduce_130( val, _values, result ) - result = ast AST::Else, :statements => val[1] - result +module_eval(<<'.,.,', 'grammar.ra', 429) + def _reduce_130(val, _values, result) + result = ast AST::Else, :statements => val[1] + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 435 - def _reduce_131( val, _values, result ) - @lexer.commentpop +module_eval(<<'.,.,', 'grammar.ra', 432) + def _reduce_131(val, _values, result) + @lexer.commentpop result = ast AST::Else, :statements => val[2] - result + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 439 - def _reduce_132( val, _values, result ) - @lexer.commentpop +module_eval(<<'.,.,', 'grammar.ra', 436) + def _reduce_132(val, _values, result) + @lexer.commentpop result = ast AST::Else, :statements => ast(AST::Nop) - result + + result end .,., - # reduce 133 omitted +# reduce 133 omitted -module_eval <<'.,.,', 'grammar.ra', 456 - def _reduce_134( val, _values, result ) - result = ast AST::InOperator, :lval => val[0], :rval => val[2] - result +module_eval(<<'.,.,', 'grammar.ra', 454) + def _reduce_134(val, _values, result) + result = ast AST::InOperator, :lval => val[0], :rval => val[2] + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 459 - def _reduce_135( val, _values, result ) - result = ast AST::MatchOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2] - result +module_eval(<<'.,.,', 'grammar.ra', 457) + def _reduce_135(val, _values, result) + result = ast AST::MatchOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2] + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 462 - def _reduce_136( val, _values, result ) - result = ast AST::MatchOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2] - result +module_eval(<<'.,.,', 'grammar.ra', 460) + def _reduce_136(val, _values, result) + result = ast AST::MatchOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2] + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 465 - def _reduce_137( val, _values, result ) - result = ast AST::ArithmeticOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2] - result +module_eval(<<'.,.,', 'grammar.ra', 463) + def _reduce_137(val, _values, result) + result = ast AST::ArithmeticOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2] + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 468 - def _reduce_138( val, _values, result ) - result = ast AST::ArithmeticOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2] - result +module_eval(<<'.,.,', 'grammar.ra', 466) + def _reduce_138(val, _values, result) + result = ast AST::ArithmeticOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2] + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 471 - def _reduce_139( val, _values, result ) - result = ast AST::ArithmeticOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2] - result +module_eval(<<'.,.,', 'grammar.ra', 469) + def _reduce_139(val, _values, result) + result = ast AST::ArithmeticOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2] + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 474 - def _reduce_140( val, _values, result ) - result = ast AST::ArithmeticOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2] - result +module_eval(<<'.,.,', 'grammar.ra', 472) + def _reduce_140(val, _values, result) + result = ast AST::ArithmeticOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2] + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 477 - def _reduce_141( val, _values, result ) - result = ast AST::ArithmeticOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2] - result +module_eval(<<'.,.,', 'grammar.ra', 475) + def _reduce_141(val, _values, result) + result = ast AST::ArithmeticOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2] + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 480 - def _reduce_142( val, _values, result ) - result = ast AST::ArithmeticOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2] - result +module_eval(<<'.,.,', 'grammar.ra', 478) + def _reduce_142(val, _values, result) + result = ast AST::ArithmeticOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2] + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 483 - def _reduce_143( val, _values, result ) - result = ast AST::Minus, :value => val[1] - result +module_eval(<<'.,.,', 'grammar.ra', 481) + def _reduce_143(val, _values, result) + result = ast AST::Minus, :value => val[1] + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 486 - def _reduce_144( val, _values, result ) - result = ast AST::ComparisonOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2] - result +module_eval(<<'.,.,', 'grammar.ra', 484) + def _reduce_144(val, _values, result) + result = ast AST::ComparisonOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2] + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 489 - def _reduce_145( val, _values, result ) - result = ast AST::ComparisonOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2] - result +module_eval(<<'.,.,', 'grammar.ra', 487) + def _reduce_145(val, _values, result) + result = ast AST::ComparisonOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2] + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 492 - def _reduce_146( val, _values, result ) - result = ast AST::ComparisonOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2] - result +module_eval(<<'.,.,', 'grammar.ra', 490) + def _reduce_146(val, _values, result) + result = ast AST::ComparisonOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2] + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 495 - def _reduce_147( val, _values, result ) - result = ast AST::ComparisonOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2] - result +module_eval(<<'.,.,', 'grammar.ra', 493) + def _reduce_147(val, _values, result) + result = ast AST::ComparisonOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2] + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 498 - def _reduce_148( val, _values, result ) - result = ast AST::ComparisonOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2] - result +module_eval(<<'.,.,', 'grammar.ra', 496) + def _reduce_148(val, _values, result) + result = ast AST::ComparisonOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2] + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 501 - def _reduce_149( val, _values, result ) - result = ast AST::ComparisonOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2] - result +module_eval(<<'.,.,', 'grammar.ra', 499) + def _reduce_149(val, _values, result) + result = ast AST::ComparisonOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2] + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 504 - def _reduce_150( val, _values, result ) - result = ast AST::Not, :value => val[1] - result +module_eval(<<'.,.,', 'grammar.ra', 502) + def _reduce_150(val, _values, result) + result = ast AST::Not, :value => val[1] + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 507 - def _reduce_151( val, _values, result ) - result = ast AST::BooleanOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2] - result +module_eval(<<'.,.,', 'grammar.ra', 505) + def _reduce_151(val, _values, result) + result = ast AST::BooleanOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2] + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 510 - def _reduce_152( val, _values, result ) - result = ast AST::BooleanOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2] - result +module_eval(<<'.,.,', 'grammar.ra', 508) + def _reduce_152(val, _values, result) + result = ast AST::BooleanOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2] + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 513 - def _reduce_153( val, _values, result ) - result = val[1] - result +module_eval(<<'.,.,', 'grammar.ra', 511) + def _reduce_153(val, _values, result) + result = val[1] + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 518 - def _reduce_154( val, _values, result ) - @lexer.commentpop +module_eval(<<'.,.,', 'grammar.ra', 515) + def _reduce_154(val, _values, result) + @lexer.commentpop result = ast AST::CaseStatement, :test => val[1], :options => val[3] - result + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 519 - def _reduce_155( val, _values, result ) - result = aryfy(val[0]) - result +module_eval(<<'.,.,', 'grammar.ra', 519) + def _reduce_155(val, _values, result) + result = aryfy(val[0]) + result end .,., -module_eval <<'.,.,', 'grammar.ra', 524 - def _reduce_156( val, _values, result ) - val[0].push val[1] +module_eval(<<'.,.,', 'grammar.ra', 521) + def _reduce_156(val, _values, result) + val[0].push val[1] result = val[0] - result + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 529 - def _reduce_157( val, _values, result ) - @lexer.commentpop +module_eval(<<'.,.,', 'grammar.ra', 526) + def _reduce_157(val, _values, result) + @lexer.commentpop result = ast AST::CaseOpt, :value => val[0], :statements => val[3] - result + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 538 - def _reduce_158( val, _values, result ) - @lexer.commentpop +module_eval(<<'.,.,', 'grammar.ra', 529) + def _reduce_158(val, _values, result) + @lexer.commentpop result = ast( AST::CaseOpt, :value => val[0], :statements => ast(AST::ASTArray) ) - result + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 539 - def _reduce_159( val, _values, result ) - result = aryfy(val[0]) - result +module_eval(<<'.,.,', 'grammar.ra', 539) + def _reduce_159(val, _values, result) + result = aryfy(val[0]) + result end .,., -module_eval <<'.,.,', 'grammar.ra', 544 - def _reduce_160( val, _values, result ) - val[0].push(val[2]) +module_eval(<<'.,.,', 'grammar.ra', 541) + def _reduce_160(val, _values, result) + val[0].push(val[2]) result = val[0] - result + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 548 - def _reduce_161( val, _values, result ) - result = ast AST::Selector, :param => val[0], :values => val[2] - result +module_eval(<<'.,.,', 'grammar.ra', 546) + def _reduce_161(val, _values, result) + result = ast AST::Selector, :param => val[0], :values => val[2] + + result end .,., - # reduce 162 omitted +# reduce 162 omitted -module_eval <<'.,.,', 'grammar.ra', 554 - def _reduce_163( val, _values, result ) - @lexer.commentpop +module_eval(<<'.,.,', 'grammar.ra', 551) + def _reduce_163(val, _values, result) + @lexer.commentpop result = val[1] - result + + result end .,., - # reduce 164 omitted +# reduce 164 omitted -module_eval <<'.,.,', 'grammar.ra', 564 - def _reduce_165( val, _values, result ) - if val[0].instance_of?(AST::ASTArray) +module_eval(<<'.,.,', 'grammar.ra', 557) + def _reduce_165(val, _values, result) + if val[0].instance_of?(AST::ASTArray) val[0].push(val[2]) result = val[0] else result = ast AST::ASTArray, :children => [val[0],val[2]] end - result + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 568 - def _reduce_166( val, _values, result ) - result = ast AST::ResourceParam, :param => val[0], :value => val[2] - result +module_eval(<<'.,.,', 'grammar.ra', 566) + def _reduce_166(val, _values, result) + result = ast AST::ResourceParam, :param => val[0], :value => val[2] + + result end .,., - # reduce 167 omitted +# reduce 167 omitted + +# reduce 168 omitted - # reduce 168 omitted +# reduce 169 omitted - # reduce 169 omitted +# reduce 170 omitted - # reduce 170 omitted +# reduce 171 omitted - # reduce 171 omitted +# reduce 172 omitted - # reduce 172 omitted +# reduce 173 omitted - # reduce 173 omitted +# reduce 174 omitted -module_eval <<'.,.,', 'grammar.ra', 579 - def _reduce_174( val, _values, result ) - result = ast AST::Default, :value => val[0][:value], :line => val[0][:line] - result +module_eval(<<'.,.,', 'grammar.ra', 578) + def _reduce_175(val, _values, result) + result = ast AST::Default, :value => val[0][:value], :line => val[0][:line] + + result end .,., - # reduce 175 omitted +# reduce 176 omitted -module_eval <<'.,.,', 'grammar.ra', 582 - def _reduce_176( val, _values, result ) - result = [val[0][:value]] - result +module_eval(<<'.,.,', 'grammar.ra', 583) + def _reduce_177(val, _values, result) + result = [val[0][:value]] + result end .,., - # reduce 177 omitted +# reduce 178 omitted -module_eval <<'.,.,', 'grammar.ra', 584 - def _reduce_178( val, _values, result ) - result = val[0] += val[2] - result +module_eval(<<'.,.,', 'grammar.ra', 585) + def _reduce_179(val, _values, result) + result = val[0] += val[2] + result end .,., -module_eval <<'.,.,', 'grammar.ra', 593 - def _reduce_179( val, _values, result ) - val[1].each do |file| +module_eval(<<'.,.,', 'grammar.ra', 588) + def _reduce_180(val, _values, result) + val[1].each do |file| import(file) end result = nil - result + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 605 - def _reduce_180( val, _values, result ) - @lexer.commentpop +module_eval(<<'.,.,', 'grammar.ra', 598) + def _reduce_181(val, _values, result) + @lexer.commentpop result = Puppet::Parser::AST::Definition.new(classname(val[1]), ast_context(true).merge(:arguments => val[2], :code => val[4], :line => val[0][:line])) @lexer.indefine = false #} | DEFINE NAME argumentlist parent LBRACE RBRACE { - result + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 610 - def _reduce_181( val, _values, result ) - @lexer.commentpop +module_eval(<<'.,.,', 'grammar.ra', 606) + def _reduce_182(val, _values, result) + @lexer.commentpop result = Puppet::Parser::AST::Definition.new(classname(val[1]), ast_context(true).merge(:arguments => val[2], :line => val[0][:line])) @lexer.indefine = false - result + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 620 - def _reduce_182( val, _values, result ) - @lexer.commentpop +module_eval(<<'.,.,', 'grammar.ra', 614) + def _reduce_183(val, _values, result) + @lexer.commentpop # Our class gets defined in the parent namespace, not our own. @lexer.namepop result = Puppet::Parser::AST::Hostclass.new(classname(val[1]), ast_context(true).merge(:arguments => val[2], :parent => val[3], :code => val[5], :line => val[0][:line])) - result + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 627 - def _reduce_183( val, _values, result ) - @lexer.commentpop +module_eval(<<'.,.,', 'grammar.ra', 621) + def _reduce_184(val, _values, result) + @lexer.commentpop # Our class gets defined in the parent namespace, not our own. @lexer.namepop result = Puppet::Parser::AST::Hostclass.new(classname(val[1]), ast_context(true).merge(:arguments => val[2], :parent => val[3], :line => val[0][:line])) - result + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 634 - def _reduce_184( val, _values, result ) - @lexer.commentpop +module_eval(<<'.,.,', 'grammar.ra', 630) + def _reduce_185(val, _values, result) + @lexer.commentpop result = Puppet::Parser::AST::Node.new(val[1], ast_context(true).merge(:parent => val[2], :code => val[4], :line => val[0][:line])) - result + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 637 - def _reduce_185( val, _values, result ) - @lexer.commentpop +module_eval(<<'.,.,', 'grammar.ra', 635) + def _reduce_186(val, _values, result) + @lexer.commentpop result = Puppet::Parser::AST::Node.new(val[1], ast_context(true).merge(:parent => val[2], :line => val[0][:line])) - result + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 638 - def _reduce_186( val, _values, result ) - result = val[0][:value] - result +module_eval(<<'.,.,', 'grammar.ra', 639) + def _reduce_187(val, _values, result) + result = val[0][:value] + result end .,., -module_eval <<'.,.,', 'grammar.ra', 640 - def _reduce_187( val, _values, result ) - result = val[0][:value] - result +module_eval(<<'.,.,', 'grammar.ra', 641) + def _reduce_188(val, _values, result) + result = val[0][:value] + result end .,., -module_eval <<'.,.,', 'grammar.ra', 641 - def _reduce_188( val, _values, result ) - result = val[0][:value] - result +module_eval(<<'.,.,', 'grammar.ra', 642) + def _reduce_189(val, _values, result) + result = val[0][:value] + result end .,., -module_eval <<'.,.,', 'grammar.ra', 642 - def _reduce_189( val, _values, result ) - result = "class" - result +module_eval(<<'.,.,', 'grammar.ra', 643) + def _reduce_190(val, _values, result) + result = "class" + result end .,., -module_eval <<'.,.,', 'grammar.ra', 649 - def _reduce_190( val, _values, result ) - result = [result] - result +module_eval(<<'.,.,', 'grammar.ra', 648) + def _reduce_191(val, _values, result) + result = [result] + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 653 - def _reduce_191( val, _values, result ) - result = val[0] +module_eval(<<'.,.,', 'grammar.ra', 651) + def _reduce_192(val, _values, result) + result = val[0] result << val[2] - result + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 657 - def _reduce_192( val, _values, result ) - result = ast AST::HostName, :value => val[0] - result +module_eval(<<'.,.,', 'grammar.ra', 656) + def _reduce_193(val, _values, result) + result = ast AST::HostName, :value => val[0] + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 658 - def _reduce_193( val, _values, result ) - result = val[0][:value] - result +module_eval(<<'.,.,', 'grammar.ra', 659) + def _reduce_194(val, _values, result) + result = val[0][:value] + result end .,., -module_eval <<'.,.,', 'grammar.ra', 659 - def _reduce_194( val, _values, result ) - result = val[0][:value] - result +module_eval(<<'.,.,', 'grammar.ra', 660) + def _reduce_195(val, _values, result) + result = val[0][:value] + result end .,., -module_eval <<'.,.,', 'grammar.ra', 660 - def _reduce_195( val, _values, result ) - result = val[0][:value] - result +module_eval(<<'.,.,', 'grammar.ra', 661) + def _reduce_196(val, _values, result) + result = val[0][:value] + result end .,., - # reduce 196 omitted +# reduce 197 omitted -module_eval <<'.,.,', 'grammar.ra', 666 - def _reduce_197( val, _values, result ) - result = nil - result +module_eval(<<'.,.,', 'grammar.ra', 665) + def _reduce_198(val, _values, result) + result = nil + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 670 - def _reduce_198( val, _values, result ) - result = ast AST::ASTArray, :children => [] - result +module_eval(<<'.,.,', 'grammar.ra', 669) + def _reduce_199(val, _values, result) + result = ast AST::ASTArray, :children => [] + + result end .,., - # reduce 199 omitted +# reduce 200 omitted + +module_eval(<<'.,.,', 'grammar.ra', 674) + def _reduce_201(val, _values, result) + result = nil -module_eval <<'.,.,', 'grammar.ra', 675 - def _reduce_200( val, _values, result ) - result = nil - result + result end .,., -module_eval <<'.,.,', 'grammar.ra', 679 - def _reduce_201( val, _values, result ) - result = val[1] +module_eval(<<'.,.,', 'grammar.ra', 677) + def _reduce_202(val, _values, result) + result = val[1] result = [result] unless result[0].is_a?(Array) - result + + result end .,., - # reduce 202 omitted +# reduce 203 omitted -module_eval <<'.,.,', 'grammar.ra', 686 - def _reduce_203( val, _values, result ) - result = val[0] +module_eval(<<'.,.,', 'grammar.ra', 683) + def _reduce_204(val, _values, result) + result = val[0] result = [result] unless result[0].is_a?(Array) result << val[2] - result + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 691 - def _reduce_204( val, _values, result ) - Puppet.warning addcontext("Deprecation notice: must now include '$' in prototype") +module_eval(<<'.,.,', 'grammar.ra', 689) + def _reduce_205(val, _values, result) + Puppet.warning addcontext("Deprecation notice: must now include '$' in prototype") result = [val[0][:value], val[2]] - result + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 695 - def _reduce_205( val, _values, result ) - Puppet.warning addcontext("Deprecation notice: must now include '$' in prototype") +module_eval(<<'.,.,', 'grammar.ra', 693) + def _reduce_206(val, _values, result) + Puppet.warning addcontext("Deprecation notice: must now include '$' in prototype") result = [val[0][:value]] - result + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 697 - def _reduce_206( val, _values, result ) - result = [val[0][:value], val[2]] - result +module_eval(<<'.,.,', 'grammar.ra', 696) + def _reduce_207(val, _values, result) + result = [val[0][:value], val[2]] + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 699 - def _reduce_207( val, _values, result ) - result = [val[0][:value]] - result +module_eval(<<'.,.,', 'grammar.ra', 698) + def _reduce_208(val, _values, result) + result = [val[0][:value]] + + result end .,., - # reduce 208 omitted +# reduce 209 omitted -module_eval <<'.,.,', 'grammar.ra', 704 - def _reduce_209( val, _values, result ) - result = val[1] - result +module_eval(<<'.,.,', 'grammar.ra', 703) + def _reduce_210(val, _values, result) + result = val[1] + + result end .,., - # reduce 210 omitted +# reduce 211 omitted -module_eval <<'.,.,', 'grammar.ra', 709 - def _reduce_211( val, _values, result ) - result = val[1] - result +module_eval(<<'.,.,', 'grammar.ra', 708) + def _reduce_212(val, _values, result) + result = val[1] + + result end .,., - # reduce 212 omitted +# reduce 213 omitted - # reduce 213 omitted +# reduce 214 omitted -module_eval <<'.,.,', 'grammar.ra', 715 - def _reduce_214( val, _values, result ) - result = ast AST::Variable, :value => val[0][:value], :line => val[0][:line] - result +module_eval(<<'.,.,', 'grammar.ra', 714) + def _reduce_215(val, _values, result) + result = ast AST::Variable, :value => val[0][:value], :line => val[0][:line] + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 716 - def _reduce_215( val, _values, result ) - result = val[1] - result +module_eval(<<'.,.,', 'grammar.ra', 717) + def _reduce_216(val, _values, result) + result = val[1] + result end .,., -module_eval <<'.,.,', 'grammar.ra', 717 - def _reduce_216( val, _values, result ) - result = val[1] - result +module_eval(<<'.,.,', 'grammar.ra', 718) + def _reduce_217(val, _values, result) + result = val[1] + result end .,., -module_eval <<'.,.,', 'grammar.ra', 718 - def _reduce_217( val, _values, result ) - result = ast AST::ASTArray - result +module_eval(<<'.,.,', 'grammar.ra', 719) + def _reduce_218(val, _values, result) + result = ast AST::ASTArray + result end .,., - # reduce 218 omitted +# reduce 219 omitted - # reduce 219 omitted +# reduce 220 omitted - # reduce 220 omitted +# reduce 221 omitted -module_eval <<'.,.,', 'grammar.ra', 724 - def _reduce_221( val, _values, result ) - result = nil - result +module_eval(<<'.,.,', 'grammar.ra', 725) + def _reduce_222(val, _values, result) + result = nil + result end .,., -module_eval <<'.,.,', 'grammar.ra', 729 - def _reduce_222( val, _values, result ) - result = ast AST::Regex, :value => val[0][:value] - result +module_eval(<<'.,.,', 'grammar.ra', 728) + def _reduce_223(val, _values, result) + result = ast AST::Regex, :value => val[0][:value] + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 737 - def _reduce_223( val, _values, result ) - if val[1].instance_of?(AST::ASTHash) +module_eval(<<'.,.,', 'grammar.ra', 732) + def _reduce_224(val, _values, result) + if val[1].instance_of?(AST::ASTHash) result = val[1] else result = ast AST::ASTHash, { :value => val[1] } end - result + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 744 - def _reduce_224( val, _values, result ) - if val[1].instance_of?(AST::ASTHash) +module_eval(<<'.,.,', 'grammar.ra', 739) + def _reduce_225(val, _values, result) + if val[1].instance_of?(AST::ASTHash) result = val[1] else result = ast AST::ASTHash, { :value => val[1] } end - result + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 746 - def _reduce_225( val, _values, result ) - result = ast AST::ASTHash - result +module_eval(<<'.,.,', 'grammar.ra', 745) + def _reduce_226(val, _values, result) + result = ast AST::ASTHash + + result end .,., - # reduce 226 omitted +# reduce 227 omitted -module_eval <<'.,.,', 'grammar.ra', 756 - def _reduce_227( val, _values, result ) - if val[0].instance_of?(AST::ASTHash) +module_eval(<<'.,.,', 'grammar.ra', 750) + def _reduce_228(val, _values, result) + if val[0].instance_of?(AST::ASTHash) result = val[0].merge(val[2]) else result = ast AST::ASTHash, :value => val[0] result.merge(val[2]) end - result + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 760 - def _reduce_228( val, _values, result ) - result = ast AST::ASTHash, { :value => { val[0] => val[2] } } - result +module_eval(<<'.,.,', 'grammar.ra', 759) + def _reduce_229(val, _values, result) + result = ast AST::ASTHash, { :value => { val[0] => val[2] } } + + result end .,., -module_eval <<'.,.,', 'grammar.ra', 761 - def _reduce_229( val, _values, result ) - result = val[0][:value] - result +module_eval(<<'.,.,', 'grammar.ra', 762) + def _reduce_230(val, _values, result) + result = val[0][:value] + result end .,., -module_eval <<'.,.,', 'grammar.ra', 762 - def _reduce_230( val, _values, result ) - result = val[0] - result +module_eval(<<'.,.,', 'grammar.ra', 763) + def _reduce_231(val, _values, result) + result = val[0] + result end .,., -module_eval <<'.,.,', 'grammar.ra', 767 - def _reduce_231( val, _values, result ) - result = ast AST::HashOrArrayAccess, :variable => val[0][:value], :key => val[2] - result +module_eval(<<'.,.,', 'grammar.ra', 766) + def _reduce_232(val, _values, result) + result = ast AST::HashOrArrayAccess, :variable => val[0][:value], :key => val[2] + + result end .,., - # reduce 232 omitted +# reduce 233 omitted + +module_eval(<<'.,.,', 'grammar.ra', 771) + def _reduce_234(val, _values, result) + result = ast AST::HashOrArrayAccess, :variable => val[0], :key => val[2] -module_eval <<'.,.,', 'grammar.ra', 772 - def _reduce_233( val, _values, result ) - result = ast AST::HashOrArrayAccess, :variable => val[0], :key => val[2] - result + result end .,., - def _reduce_none( val, _values, result ) - result - end +def _reduce_none(val, _values, result) + val[0] +end end # class Parser - - end # module Parser - -end # module Puppet + end # module Parser + end # module Puppet diff --git a/lib/puppet/provider/computer/computer.rb b/lib/puppet/provider/computer/computer.rb index a6be6bdfe..dd055beb3 100644 --- a/lib/puppet/provider/computer/computer.rb +++ b/lib/puppet/provider/computer/computer.rb @@ -1,22 +1,20 @@ require 'puppet/provider/nameservice/directoryservice' Puppet::Type.type(:computer).provide :directoryservice, :parent => Puppet::Provider::NameService::DirectoryService do desc "Computer object management using DirectoryService on OS X. Note that these are distinctly different kinds of objects to 'hosts', as they require a MAC address and can have all sorts of policy attached to them. This provider only manages Computer objects in the local directory service domain, not in remote directories. If you wish to manage /etc/hosts on Mac OS X, then simply use the host - type as per other platforms. - - " + type as per other platforms." confine :operatingsystem => :darwin defaultfor :operatingsystem => :darwin # hurray for abstraction. The nameservice directoryservice provider can # handle everything we need. super. end diff --git a/lib/puppet/provider/mount.rb b/lib/puppet/provider/mount.rb index c979f742f..65296eed2 100644 --- a/lib/puppet/provider/mount.rb +++ b/lib/puppet/provider/mount.rb @@ -1,53 +1,49 @@ # Created by Luke Kanies on 2006-11-12. # Copyright (c) 2006. All rights reserved. require 'puppet' # A module just to store the mount/unmount methods. Individual providers # still need to add the mount commands manually. module Puppet::Provider::Mount # This only works when the mount point is synced to the fstab. def mount # Manually pass the mount options in, since some OSes *cough*OS X*cough* don't # read from /etc/fstab but still want to use this type. args = [] args << "-o" << self.options if self.options and self.options != :absent args << resource[:name] - flush if respond_to?(:flush) mountcmd(*args) + case get(:ensure) + when :absent; set(:ensure => :ghost) + when :unmounted; set(:ensure => :mounted) + end end def remount info "Remounting" if resource[:remounts] == :true mountcmd "-o", "remount", resource[:name] else unmount mount end end # This only works when the mount point is synced to the fstab. def unmount - umount resource[:name] + umount(resource[:name]) + + # Update property hash for future queries (e.g. refresh is called) + case get(:ensure) + when :mounted; set(:ensure => :unmounted) + when :ghost; set(:ensure => :absent) + end end # Is the mount currently mounted? def mounted? - platform = Facter.value("operatingsystem") - name = resource[:name] - mounts = mountcmd.split("\n").find do |line| - case platform - when "Darwin" - line =~ / on #{name} / or line =~ %r{ on /private/var/automount#{name}} - when "Solaris", "HP-UX" - line =~ /^#{name} on / - when "AIX" - line.split(/\s+/)[1] == name - else - line =~ / on #{name} / - end - end + [:mounted, :ghost].include?(get(:ensure)) end end diff --git a/lib/puppet/provider/mount/parsed.rb b/lib/puppet/provider/mount/parsed.rb index 82d1628bd..11c5e21a9 100755 --- a/lib/puppet/provider/mount/parsed.rb +++ b/lib/puppet/provider/mount/parsed.rb @@ -1,47 +1,106 @@ require 'puppet/provider/parsedfile' require 'puppet/provider/mount' fstab = nil case Facter.value(:operatingsystem) when "Solaris"; fstab = "/etc/vfstab" else fstab = "/etc/fstab" end - - Puppet::Type.type(:mount).provide( - :parsed, +Puppet::Type.type(:mount).provide( + :parsed, :parent => Puppet::Provider::ParsedFile, :default_target => fstab, - :filetype => :flat ) do include Puppet::Provider::Mount - #confine :exists => fstab commands :mountcmd => "mount", :umount => "umount" - @platform = Facter["operatingsystem"].value - case @platform + case Facter["operatingsystem"] when "Solaris" @fields = [:device, :blockdevice, :name, :fstype, :pass, :atboot, :options] else @fields = [:device, :name, :fstype, :options, :dump, :pass] @fielddefaults = [ nil ] * 4 + [ "0", "2" ] end text_line :comment, :match => /^\s*#/ text_line :blank, :match => /^\s*$/ optional_fields = @fields - [:device, :name, :blockdevice] mandatory_fields = @fields - optional_fields # fstab will ignore lines that have fewer than the mandatory number of columns, # so we should, too. field_pattern = '(\s*(?>\S+))' text_line :incomplete, :match => /^(?!#{field_pattern}{#{mandatory_fields.length}})/ record_line self.name, :fields => @fields, :separator => /\s+/, :joiner => "\t", :optional => optional_fields -end + # Every entry in fstab is :unmounted until we can prove different + def self.prefetch_hook(target_records) + target_records.collect do |record| + record[:ensure] = :unmounted if record[:record_type] == :parsed + record + end + end + + def self.prefetch(resources = nil) + # Get providers for all resources the user defined and that match + # a record in /etc/fstab. + super + # We need to do two things now: + # - Update ensure from :unmounted to :mounted if the resource is mounted + # - Check for mounted devices that are not in fstab and + # set ensure to :ghost (if the user wants to add an entry + # to fstab we need to know if the device was mounted before) + mountinstances.each do |hash| + if mount = resources[hash[:name]] + case mount.provider.get(:ensure) + when :absent # Mount not in fstab + mount.provider.set(:ensure => :ghost) + when :unmounted # Mount in fstab + mount.provider.set(:ensure => :mounted) + end + end + end + end + def self.mountinstances + # XXX: Will not work for mount points that have spaces in path (does fstab support this anyways?) + regex = case Facter.value(:operatingsystem) + when "Darwin" + / on (?:\/private\/var\/automount)?(\S*)/ + when "Solaris", "HP-UX" + /^(\S*) on / + when "AIX" + /^(?:\S*\s+\S+\s+)(\S+)/ + else + / on (\S*)/ + end + instances = [] + mount_output = mountcmd.split("\n") + if mount_output.length >= 2 and mount_output[1] =~ /^[- \t]*$/ + # On some OSes (e.g. AIX) mount output begins with a header line + # followed by a line consisting of dashes and whitespace. + # Discard these two lines. + mount_output[0..1] = [] + end + mount_output.each do |line| + if match = regex.match(line) and name = match.captures.first + instances << {:name => name, :mounted => :yes} # Only :name is important here + else + raise Puppet::Error, "Could not understand line #{line} from mount output" + end + end + instances + end + + def flush + needs_mount = @property_hash.delete(:needs_mount) + super + mount if needs_mount + end +end diff --git a/lib/puppet/provider/parsedfile.rb b/lib/puppet/provider/parsedfile.rb index ffd36e59f..75a215f4b 100755 --- a/lib/puppet/provider/parsedfile.rb +++ b/lib/puppet/provider/parsedfile.rb @@ -1,372 +1,374 @@ require 'puppet' require 'puppet/util/filetype' require 'puppet/util/fileparsing' # This provider can be used as the parent class for a provider that # parses and generates files. Its content must be loaded via the # 'prefetch' method, and the file will be written when 'flush' is called # on the provider instance. At this point, the file is written once # for every provider instance. # # Once the provider prefetches the data, it's the resource's job to copy # that data over to the @is variables. class Puppet::Provider::ParsedFile < Puppet::Provider extend Puppet::Util::FileParsing class << self attr_accessor :default_target, :target end attr_accessor :property_hash def self.clean(hash) newhash = hash.dup [:record_type, :on_disk].each do |p| newhash.delete(p) if newhash.include?(p) end newhash end def self.clear @target_objects.clear @records.clear end def self.filetype @filetype ||= Puppet::Util::FileType.filetype(:flat) end def self.filetype=(type) if type.is_a?(Class) @filetype = type elsif klass = Puppet::Util::FileType.filetype(type) @filetype = klass else raise ArgumentError, "Invalid filetype #{type}" end end # Flush all of the targets for which there are modified records. The only # reason we pass a record here is so that we can add it to the stack if # necessary -- it's passed from the instance calling 'flush'. def self.flush(record) # Make sure this record is on the list to be flushed. unless record[:on_disk] record[:on_disk] = true @records << record # If we've just added the record, then make sure our # target will get flushed. modified(record[:target] || default_target) end return unless defined?(@modified) and ! @modified.empty? flushed = [] @modified.sort { |a,b| a.to_s <=> b.to_s }.uniq.each do |target| Puppet.debug "Flushing #{@resource_type.name} provider target #{target}" flush_target(target) flushed << target end @modified.reject! { |t| flushed.include?(t) } end # Make sure our file is backed up, but only back it up once per transaction. # We cheat and rely on the fact that @records is created on each prefetch. def self.backup_target(target) return nil unless target_object(target).respond_to?(:backup) @backup_stats ||= {} return nil if @backup_stats[target] == @records.object_id target_object(target).backup @backup_stats[target] = @records.object_id end # Flush all of the records relating to a specific target. def self.flush_target(target) backup_target(target) records = target_records(target).reject { |r| r[:ensure] == :absent } target_object(target).write(to_file(records)) end # Return the header placed at the top of each generated file, warning # users that modifying this file manually is probably a bad idea. def self.header %{# HEADER: This file was autogenerated at #{Time.now} # HEADER: by puppet. While it can still be managed manually, it # HEADER: is definitely not recommended.\n} end # Add another type var. def self.initvars @records = [] @target_objects = {} @target = nil # Default to flat files @filetype ||= Puppet::Util::FileType.filetype(:flat) super end # Return a list of all of the records we can find. def self.instances targets.collect do |target| prefetch_target(target) end.flatten.reject { |r| skip_record?(r) }.collect do |record| new(record) end end # Override the default method with a lot more functionality. def self.mk_resource_methods [resource_type.validproperties, resource_type.parameters].flatten.each do |attr| attr = symbolize(attr) define_method(attr) do # if @property_hash.empty? # # Note that this swaps the provider out from under us. # prefetch # if @resource.provider == self # return @property_hash[attr] # else # return @resource.provider.send(attr) # end # end # If it's not a valid field for this record type (which can happen # when different platforms support different fields), then just # return the should value, so the resource shuts up. if @property_hash[attr] or self.class.valid_attr?(self.class.name, attr) @property_hash[attr] || :absent else if defined?(@resource) @resource.should(attr) else nil end end end define_method(attr.to_s + "=") do |val| mark_target_modified @property_hash[attr] = val end end end # Always make the resource methods. def self.resource_type=(resource) super mk_resource_methods end # Mark a target as modified so we know to flush it. This only gets # used within the attr= methods. def self.modified(target) @modified ||= [] @modified << target unless @modified.include?(target) end # Retrieve all of the data from disk. There are three ways to know # which files to retrieve: We might have a list of file objects already # set up, there might be instances of our associated resource and they # will have a path parameter set, and we will have a default path # set. We need to turn those three locations into a list of files, # prefetch each one, and make sure they're associated with each appropriate # resource instance. def self.prefetch(resources = nil) # Reset the record list. @records = prefetch_all_targets(resources) match_providers_with_resources(resources) end def self.match_providers_with_resources(resources) return unless resources matchers = resources.dup @records.each do |record| # Skip things like comments and blank lines next if skip_record?(record) if name = record[:name] and resource = resources[name] resource.provider = new(record) elsif respond_to?(:match) if resource = match(record, matchers) # Remove this resource from circulation so we don't unnecessarily try to match matchers.delete(resource.title) record[:name] = resource[:name] resource.provider = new(record) end end end end def self.prefetch_all_targets(resources) records = [] targets(resources).each do |target| records += prefetch_target(target) end records end # Prefetch an individual target. def self.prefetch_target(target) target_records = retrieve(target).each do |r| r[:on_disk] = true r[:target] = target r[:ensure] = :present end target_records = prefetch_hook(target_records) if respond_to?(:prefetch_hook) raise Puppet::DevError, "Prefetching #{target} for provider #{self.name} returned nil" unless target_records target_records end # Is there an existing record with this name? def self.record?(name) return nil unless @records @records.find { |r| r[:name] == name } end # Retrieve the text for the file. Returns nil in the unlikely # event that it doesn't exist. def self.retrieve(path) # XXX We need to be doing something special here in case of failure. text = target_object(path).read if text.nil? or text == "" # there is no file return [] else # Set the target, for logging. old = @target begin @target = path return self.parse(text) rescue Puppet::Error => detail detail.file = @target raise detail ensure @target = old end end end # Should we skip the record? Basically, we skip text records. # This is only here so subclasses can override it. def self.skip_record?(record) record_type(record[:record_type]).text? end # Initialize the object if necessary. def self.target_object(target) @target_objects[target] ||= filetype.new(target) @target_objects[target] end # Find all of the records for a given target def self.target_records(target) @records.find_all { |r| r[:target] == target } end # Find a list of all of the targets that we should be reading. This is # used to figure out what targets we need to prefetch. def self.targets(resources = nil) targets = [] # First get the default target raise Puppet::DevError, "Parsed Providers must define a default target" unless self.default_target targets << self.default_target # Then get each of the file objects targets += @target_objects.keys # Lastly, check the file from any resource instances if resources resources.each do |name, resource| if value = resource.should(:target) targets << value end end end targets.uniq.compact end def self.to_file(records) text = super header + text end def create @resource.class.validproperties.each do |property| if value = @resource.should(property) @property_hash[property] = value end end mark_target_modified (@resource.class.name.to_s + "_created").intern end def destroy # We use the method here so it marks the target as modified. self.ensure = :absent (@resource.class.name.to_s + "_deleted").intern end def exists? !(@property_hash[:ensure] == :absent or @property_hash[:ensure].nil?) end # Write our data to disk. def flush # Make sure we've got a target and name set. # If the target isn't set, then this is our first modification, so # mark it for flushing. unless @property_hash[:target] @property_hash[:target] = @resource.should(:target) || self.class.default_target self.class.modified(@property_hash[:target]) end - @property_hash[:name] ||= @resource.name + @resource.class.key_attributes.each do |attr| + @property_hash[attr] ||= @resource[attr] + end self.class.flush(@property_hash) #@property_hash = {} end def initialize(record) super # The 'record' could be a resource or a record, depending on how the provider # is initialized. If we got an empty property hash (probably because the resource # is just being initialized), then we want to set up some defualts. @property_hash = self.class.record?(resource[:name]) || {:record_type => self.class.name, :ensure => :absent} if @property_hash.empty? end # Retrieve the current state from disk. def prefetch raise Puppet::DevError, "Somehow got told to prefetch with no resource set" unless @resource self.class.prefetch(@resource[:name] => @resource) end def record_type @property_hash[:record_type] end private # Mark both the resource and provider target as modified. def mark_target_modified if defined?(@resource) and restarget = @resource.should(:target) and restarget != @property_hash[:target] self.class.modified(restarget) end self.class.modified(@property_hash[:target]) if @property_hash[:target] != :absent and @property_hash[:target] end end diff --git a/lib/puppet/provider/service/daemontools.rb b/lib/puppet/provider/service/daemontools.rb index 65abf7728..bbb962a71 100644 --- a/lib/puppet/provider/service/daemontools.rb +++ b/lib/puppet/provider/service/daemontools.rb @@ -1,194 +1,194 @@ # Daemontools service management # # author Brice Figureau Puppet::Type.type(:service).provide :daemontools, :parent => :base do desc "Daemontools service management. This provider manages daemons running supervised by D.J.Bernstein daemontools. It tries to detect the service directory, with by order of preference: * /service * /etc/service * /var/lib/svscan The daemon directory should be placed in a directory that can be by default in: * /var/lib/service * /etc or this can be overriden in the service resource parameters:: - service { - \"myservice\": - provider => \"daemontools\", path => \"/path/to/daemons\"; - } + service { \"myservice\": + provider => \"daemontools\", + path => \"/path/to/daemons\", + } This provider supports out of the box: * start/stop (mapped to enable/disable) * enable/disable * restart * status - If a service has ensure => \"running\", it will link /path/to/daemon to + If a service has `ensure => \"running\"`, it will link /path/to/daemon to /path/to/service, which will automatically enable the service. - If a service has ensure => \"stopped\", it will only down the service, not + If a service has `ensure => \"stopped\"`, it will only down the service, not remove the /path/to/service link. " commands :svc => "/usr/bin/svc", :svstat => "/usr/bin/svstat" class << self attr_writer :defpath # Determine the daemon path. def defpath(dummy_argument=:work_arround_for_ruby_GC_bug) unless @defpath ["/var/lib/service", "/etc"].each do |path| if FileTest.exist?(path) @defpath = path break end end raise "Could not find the daemon directory (tested [/var/lib/service,/etc])" unless @defpath end @defpath end end attr_writer :servicedir # returns all providers for all existing services in @defpath # ie enabled or not def self.instances path = self.defpath unless FileTest.directory?(path) Puppet.notice "Service path #{path} does not exist" next end # reject entries that aren't either a directory # or don't contain a run file Dir.entries(path).reject { |e| fullpath = File.join(path, e) e =~ /^\./ or ! FileTest.directory?(fullpath) or ! FileTest.exist?(File.join(fullpath,"run")) }.collect do |name| new(:name => name, :path => path) end end # returns the daemon dir on this node def self.daemondir self.defpath end # find the service dir on this node def servicedir unless @servicedir ["/service", "/etc/service","/var/lib/svscan"].each do |path| if FileTest.exist?(path) @servicedir = path break end end raise "Could not find service directory" unless @servicedir end @servicedir end # returns the full path of this service when enabled # (ie in the service directory) def service File.join(self.servicedir, resource[:name]) end # returns the full path to the current daemon directory # note that this path can be overriden in the resource # definition def daemon File.join(resource[:path], resource[:name]) end def status begin output = svstat self.service if output =~ /:\s+up \(/ return :running end rescue Puppet::ExecutionFailure => detail raise Puppet::Error.new( "Could not get status for service #{resource.ref}: #{detail}" ) end :stopped end def setupservice if resource[:manifest] Puppet.notice "Configuring #{resource[:name]}" command = [ resource[:manifest], resource[:name] ] #texecute("setupservice", command) rv = system("#{command}") end rescue Puppet::ExecutionFailure => detail raise Puppet::Error.new( "Cannot config #{self.service} to enable it: #{detail}" ) end def enabled? case self.status when :running # obviously if the daemon is running then it is enabled return :true else # the service is enabled if it is linked return FileTest.symlink?(self.service) ? :true : :false end end def enable if ! FileTest.directory?(self.daemon) Puppet.notice "No daemon dir, calling setupservice for #{resource[:name]}" self.setupservice end if self.daemon if ! FileTest.symlink?(self.service) Puppet.notice "Enabling #{self.service}: linking #{self.daemon} -> #{self.service}" File.symlink(self.daemon, self.service) end end rescue Puppet::ExecutionFailure => detail raise Puppet::Error.new( "No daemon directory found for #{self.service}") end def disable begin if ! FileTest.directory?(self.daemon) Puppet.notice "No daemon dir, calling setupservice for #{resource[:name]}" self.setupservice end if self.daemon if FileTest.symlink?(self.service) Puppet.notice "Disabling #{self.service}: removing link #{self.daemon} -> #{self.service}" File.unlink(self.service) end end rescue Puppet::ExecutionFailure => detail raise Puppet::Error.new( "No daemon directory found for #{self.service}") end self.stop end def restart svc "-t", self.service end def start enable unless enabled? == :true svc "-u", self.service end def stop svc "-d", self.service end end diff --git a/lib/puppet/provider/service/gentoo.rb b/lib/puppet/provider/service/gentoo.rb index 382c74267..20f5d77e6 100644 --- a/lib/puppet/provider/service/gentoo.rb +++ b/lib/puppet/provider/service/gentoo.rb @@ -1,52 +1,50 @@ # Manage gentoo services. Start/stop is the same as InitSvc, but enable/disable # is special. Puppet::Type.type(:service).provide :gentoo, :parent => :init do desc "Gentoo's form of `init`-style service management. Uses `rc-update` for service enabling and disabling. " commands :update => "/sbin/rc-update" confine :operatingsystem => :gentoo defaultfor :operatingsystem => :gentoo def self.defpath superclass.defpath end def disable output = update :del, @resource[:name], :default rescue Puppet::ExecutionFailure raise Puppet::Error, "Could not disable #{self.name}: #{output}" end def enabled? begin output = update :show rescue Puppet::ExecutionFailure return :false end line = output.split(/\n/).find { |l| l.include?(@resource[:name]) } return :false unless line # If it's enabled then it will print output showing service | runlevel if output =~ /^\s*#{@resource[:name]}\s*\|\s*(boot|default)/ return :true else return :false end end def enable output = update :add, @resource[:name], :default rescue Puppet::ExecutionFailure raise Puppet::Error, "Could not enable #{self.name}: #{output}" end end - -# $Id $ diff --git a/lib/puppet/provider/service/launchd.rb b/lib/puppet/provider/service/launchd.rb index 1632edabf..07c549a8b 100644 --- a/lib/puppet/provider/service/launchd.rb +++ b/lib/puppet/provider/service/launchd.rb @@ -1,263 +1,266 @@ require 'facter/util/plist' Puppet::Type.type(:service).provide :launchd, :parent => :base do desc "launchd service management framework. - This provider manages launchd jobs, the default service framework for - Mac OS X, that has also been open sourced by Apple for possible use on - other platforms. + This provider manages jobs with launchd, which is the default service framework for + Mac OS X and is potentially available for use on other platforms. See: + * http://developer.apple.com/macosx/launchd.html * http://launchd.macosforge.org/ This provider reads plists out of the following directories: + * /System/Library/LaunchDaemons * /System/Library/LaunchAgents * /Library/LaunchDaemons * /Library/LaunchAgents - and builds up a list of services based upon each plists \"Label\" entry. + ...and builds up a list of services based upon each plist's \"Label\" entry. This provider supports: + * ensure => running/stopped, * enable => true/false * status * restart Here is how the Puppet states correspond to launchd states: - * stopped => job unloaded - * started => job loaded - * enabled => 'Disable' removed from job plist file - * disabled => 'Disable' added to job plist file + + * stopped --- job unloaded + * started --- job loaded + * enabled --- 'Disable' removed from job plist file + * disabled --- 'Disable' added to job plist file Note that this allows you to do something launchctl can't do, which is to be in a state of \"stopped/enabled\ or \"running/disabled\". " commands :launchctl => "/bin/launchctl" commands :sw_vers => "/usr/bin/sw_vers" commands :plutil => "/usr/bin/plutil" defaultfor :operatingsystem => :darwin confine :operatingsystem => :darwin has_feature :enableable Launchd_Paths = ["/Library/LaunchAgents", "/Library/LaunchDaemons", "/System/Library/LaunchAgents", "/System/Library/LaunchDaemons",] Launchd_Overrides = "/var/db/launchd.db/com.apple.launchd/overrides.plist" # Read a plist, whether its format is XML or in Apple's "binary1" # format. def self.read_plist(path) Plist::parse_xml(plutil('-convert', 'xml1', '-o', '/dev/stdout', path)) end # returns a label => path map for either all jobs, or just a single # job if the label is specified def self.jobsearch(label=nil) label_to_path_map = {} Launchd_Paths.each do |path| if FileTest.exists?(path) Dir.entries(path).each do |f| next if f =~ /^\..*$/ next if FileTest.directory?(f) fullpath = File.join(path, f) if FileTest.file?(fullpath) and job = read_plist(fullpath) and job.has_key?("Label") if job["Label"] == label return { label => fullpath } else label_to_path_map[job["Label"]] = fullpath end end end end end # if we didn't find the job above and we should have, error. raise Puppet::Error.new("Unable to find launchd plist for job: #{label}") if label # if returning all jobs label_to_path_map end def self.instances jobs = self.jobsearch jobs.keys.collect do |job| new(:name => job, :provider => :launchd, :path => jobs[job]) end end def self.get_macosx_version_major return @macosx_version_major if defined?(@macosx_version_major) begin # Make sure we've loaded all of the facts Facter.loadfacts if Facter.value(:macosx_productversion_major) product_version_major = Facter.value(:macosx_productversion_major) else # TODO: remove this code chunk once we require Facter 1.5.5 or higher. Puppet.warning("DEPRECATION WARNING: Future versions of the launchd provider will require Facter 1.5.5 or newer.") product_version = Facter.value(:macosx_productversion) fail("Could not determine OS X version from Facter") if product_version.nil? product_version_major = product_version.scan(/(\d+)\.(\d+)./).join(".") end fail("#{product_version_major} is not supported by the launchd provider") if %w{10.0 10.1 10.2 10.3}.include?(product_version_major) @macosx_version_major = product_version_major return @macosx_version_major rescue Puppet::ExecutionFailure => detail fail("Could not determine OS X version: #{detail}") end end # finds the path for a given label and returns the path and parsed plist # as an array of [path, plist]. Note plist is really a Hash here. def plist_from_label(label) job = self.class.jobsearch(label) job_path = job[label] if FileTest.file?(job_path) job_plist = self.class.read_plist(job_path) else raise Puppet::Error.new("Unable to parse launchd plist at path: #{job_path}") end [job_path, job_plist] end def status # launchctl list exits zero if the job is loaded # and non-zero if it isn't. Simple way to check... but is only # available on OS X 10.5 unfortunately, so we grab the whole list # and check if our resource is included. The output formats differ # between 10.4 and 10.5, thus the necessity for splitting begin output = launchctl :list raise Puppet::Error.new("launchctl list failed to return any data.") if output.nil? output.split("\n").each do |j| return :running if j.split(/\s/).last == resource[:name] end return :stopped rescue Puppet::ExecutionFailure raise Puppet::Error.new("Unable to determine status of #{resource[:name]}") end end # start the service. To get to a state of running/enabled, we need to # conditionally enable at load, then disable by modifying the plist file # directly. def start job_path, job_plist = plist_from_label(resource[:name]) did_enable_job = false cmds = [] cmds << :launchctl << :load if self.enabled? == :false # launchctl won't load disabled jobs cmds << "-w" did_enable_job = true end cmds << job_path begin execute(cmds) rescue Puppet::ExecutionFailure raise Puppet::Error.new("Unable to start service: #{resource[:name]} at path: #{job_path}") end # As load -w clears the Disabled flag, we need to add it in after self.disable if did_enable_job and resource[:enable] == :false end def stop job_path, job_plist = plist_from_label(resource[:name]) did_disable_job = false cmds = [] cmds << :launchctl << :unload if self.enabled? == :true # keepalive jobs can't be stopped without disabling cmds << "-w" did_disable_job = true end cmds << job_path begin execute(cmds) rescue Puppet::ExecutionFailure raise Puppet::Error.new("Unable to stop service: #{resource[:name]} at path: #{job_path}") end # As unload -w sets the Disabled flag, we need to add it in after self.enable if did_disable_job and resource[:enable] == :true end # launchd jobs are enabled by default. They are only disabled if the key # "Disabled" is set to true, but it can also be set to false to enable it. # In 10.6, the Disabled key in the job plist is consulted, but only if there # is no entry in the global overrides plist. # We need to draw a distinction between undefined, true and false for both # locations where the Disabled flag can be defined. def enabled? job_plist_disabled = nil overrides_disabled = nil job_path, job_plist = plist_from_label(resource[:name]) job_plist_disabled = job_plist["Disabled"] if job_plist.has_key?("Disabled") if self.class.get_macosx_version_major == "10.6": if FileTest.file?(Launchd_Overrides) and overrides = self.class.read_plist(Launchd_Overrides) if overrides.has_key?(resource[:name]) overrides_disabled = overrides[resource[:name]]["Disabled"] if overrides[resource[:name]].has_key?("Disabled") end end end if overrides_disabled.nil? if job_plist_disabled.nil? or job_plist_disabled == false return :true end elsif overrides_disabled == false return :true end :false end # enable and disable are a bit hacky. We write out the plist with the appropriate value # rather than dealing with launchctl as it is unable to change the Disabled flag # without actually loading/unloading the job. # In 10.6 we need to write out a disabled key to the global overrides plist, in earlier # versions this is stored in the job plist itself. def enable if self.class.get_macosx_version_major == "10.6" overrides = self.class.read_plist(Launchd_Overrides) overrides[resource[:name]] = { "Disabled" => false } Plist::Emit.save_plist(overrides, Launchd_Overrides) else job_path, job_plist = plist_from_label(resource[:name]) if self.enabled? == :false job_plist.delete("Disabled") Plist::Emit.save_plist(job_plist, job_path) end end end def disable if self.class.get_macosx_version_major == "10.6" overrides = self.class.read_plist(Launchd_Overrides) overrides[resource[:name]] = { "Disabled" => true } Plist::Emit.save_plist(overrides, Launchd_Overrides) else job_path, job_plist = plist_from_label(resource[:name]) job_plist["Disabled"] = true Plist::Emit.save_plist(job_plist, job_path) end end end diff --git a/lib/puppet/provider/service/runit.rb b/lib/puppet/provider/service/runit.rb index 0315b9597..736e3db71 100644 --- a/lib/puppet/provider/service/runit.rb +++ b/lib/puppet/provider/service/runit.rb @@ -1,103 +1,103 @@ # Daemontools service management # # author Brice Figureau Puppet::Type.type(:service).provide :runit, :parent => :daemontools do desc "Runit service management. This provider manages daemons running supervised by Runit. It tries to detect the service directory, with by order of preference: * /service * /var/service * /etc/service The daemon directory should be placed in a directory that can be by default in: * /etc/sv or this can be overriden in the service resource parameters:: - service { - \"myservice\": - provider => \"runit\", path => \"/path/to/daemons\"; - } + service { \"myservice\": + provider => \"runit\", + path => \"/path/to/daemons\", + } This provider supports out of the box: * start/stop * enable/disable * restart * status " commands :sv => "/usr/bin/sv" class << self # this is necessary to autodetect a valid resource # default path, since there is no standard for such directory. def defpath(dummy_argument=:work_arround_for_ruby_GC_bug) unless @defpath ["/etc/sv", "/var/lib/service"].each do |path| if FileTest.exist?(path) @defpath = path break end end raise "Could not find the daemon directory (tested [/var/lib/service,/etc])" unless @defpath end @defpath end end # find the service dir on this node def servicedir unless @servicedir ["/service", "/etc/service","/var/service"].each do |path| if FileTest.exist?(path) @servicedir = path break end end raise "Could not find service directory" unless @servicedir end @servicedir end def status begin output = sv "status", self.daemon return :running if output =~ /^run: / rescue Puppet::ExecutionFailure => detail unless detail.message =~ /(warning: |runsv not running$)/ raise Puppet::Error.new( "Could not get status for service #{resource.ref}: #{detail}" ) end end :stopped end def stop sv "stop", self.service end def start enable unless enabled? == :true sv "start", self.service end def restart sv "restart", self.service end # disable by removing the symlink so that runit # doesn't restart our service behind our back # note that runit doesn't need to perform a stop # before a disable def disable # unlink the daemon symlink to disable it File.unlink(self.service) if FileTest.symlink?(self.service) end end diff --git a/lib/puppet/provider/user/useradd.rb b/lib/puppet/provider/user/useradd.rb index ba406cc63..b87971738 100644 --- a/lib/puppet/provider/user/useradd.rb +++ b/lib/puppet/provider/user/useradd.rb @@ -1,109 +1,114 @@ require 'puppet/provider/nameservice/objectadd' Puppet::Type.type(:user).provide :useradd, :parent => Puppet::Provider::NameService::ObjectAdd do desc "User management via `useradd` and its ilk. Note that you will need to install the `Shadow Password` Ruby library often known as ruby-libshadow to manage user passwords." commands :add => "useradd", :delete => "userdel", :modify => "usermod", :password => "chage" options :home, :flag => "-d", :method => :dir options :comment, :method => :gecos options :groups, :flag => "-G" options :password_min_age, :flag => "-m" options :password_max_age, :flag => "-M" verify :gid, "GID must be an integer" do |value| value.is_a? Integer end verify :groups, "Groups must be comma-separated" do |value| value !~ /\s/ end - has_features :manages_homedir, :allows_duplicates, :manages_expiry + has_features :manages_homedir, :allows_duplicates, :manages_expiry, :system_users has_features :manages_passwords, :manages_password_age if Puppet.features.libshadow? def check_allow_dup @resource.allowdupe? ? ["-o"] : [] end def check_manage_home cmd = [] if @resource.managehome? cmd << "-m" elsif %w{Fedora RedHat CentOS OEL OVS}.include?(Facter.value("operatingsystem")) cmd << "-M" end cmd end def check_manage_expiry cmd = [] if @resource[:expiry] cmd << "-e #{@resource[:expiry]}" end cmd end + def check_system_users + @resource.system? ? ["-r"] : [] + end + def add_properties cmd = [] Puppet::Type.type(:user).validproperties.each do |property| next if property == :ensure next if property.to_s =~ /password_.+_age/ # the value needs to be quoted, mostly because -c might # have spaces in it if value = @resource.should(property) and value != "" cmd << flag(property) << value end end cmd end def addcmd cmd = [command(:add)] cmd += add_properties cmd += check_allow_dup cmd += check_manage_home cmd += check_manage_expiry + cmd += check_system_users cmd << @resource[:name] end def passcmd age_limits = [:password_min_age, :password_max_age].select { |property| @resource.should(property) } if age_limits.empty? nil else [command(:password),age_limits.collect { |property| [flag(property), @resource.should(property)]}, @resource[:name]].flatten end end def password_min_age if Puppet.features.libshadow? if ent = Shadow::Passwd.getspnam(@resource.name) return ent.sp_min end end :absent end def password_max_age if Puppet.features.libshadow? if ent = Shadow::Passwd.getspnam(@resource.name) return ent.sp_max end end :absent end # Retrieve the password using the Shadow Password library def password if Puppet.features.libshadow? if ent = Shadow::Passwd.getspnam(@resource.name) return ent.sp_pwdp end end :absent end end diff --git a/lib/puppet/provider/zpool/solaris.rb b/lib/puppet/provider/zpool/solaris.rb index e597c2ae1..758ea618a 100644 --- a/lib/puppet/provider/zpool/solaris.rb +++ b/lib/puppet/provider/zpool/solaris.rb @@ -1,114 +1,116 @@ Puppet::Type.type(:zpool).provide(:solaris) do desc "Provider for Solaris zpool." commands :zpool => "/usr/sbin/zpool" defaultfor :operatingsystem => :solaris def process_zpool_data(pool_array) if pool_array == [] return Hash.new(:absent) end #get the name and get rid of it pool = Hash.new pool[:pool] = pool_array[0] pool_array.shift tmp = [] #order matters here :( pool_array.reverse.each do |value| sym = nil case value - when "spares"; sym = :spare - when "logs"; sym = :log - when "mirror", "raidz1", "raidz2" - sym = value == "mirror" ? :mirror : :raidz - pool[:raid_parity] = "raidz2" if value == "raidz2" + when "spares"; + sym = :spare + when "logs"; + sym = :log + when /^mirror|^raidz1|^raidz2/; + sym = value =~ /^mirror/ ? :mirror : :raidz + pool[:raid_parity] = "raidz2" if value =~ /^raidz2/ else tmp << value sym = :disk if value == pool_array.first end if sym pool[sym] = pool[sym] ? pool[sym].unshift(tmp.reverse.join(' ')) : [tmp.reverse.join(' ')] tmp.clear end end pool end def get_pool_data #this is all voodoo dependent on the output from zpool zpool_data = %x{ zpool status #{@resource[:pool]}}.split("\n").select { |line| line.index("\t") == 0 }.collect { |l| l.strip.split("\s")[0] } zpool_data.shift zpool_data end def current_pool @current_pool = process_zpool_data(get_pool_data) unless (defined?(@current_pool) and @current_pool) @current_pool end def flush @current_pool= nil end #Adds log and spare def build_named(name) if prop = @resource[name.intern] [name] + prop.collect { |p| p.split(' ') }.flatten else [] end end #query for parity and set the right string def raidzarity @resource[:raid_parity] ? @resource[:raid_parity] : "raidz1" end #handle mirror or raid def handle_multi_arrays(prefix, array) array.collect{ |a| [prefix] + a.split(' ') }.flatten end #builds up the vdevs for create command def build_vdevs if disk = @resource[:disk] disk.collect { |d| d.split(' ') }.flatten elsif mirror = @resource[:mirror] handle_multi_arrays("mirror", mirror) elsif raidz = @resource[:raidz] handle_multi_arrays(raidzarity, raidz) end end def create zpool(*([:create, @resource[:pool]] + build_vdevs + build_named("spare") + build_named("log"))) end def delete zpool :destroy, @resource[:pool] end def exists? if current_pool[:pool] == :absent false else true end end [:disk, :mirror, :raidz, :log, :spare].each do |field| define_method(field) do current_pool[field] end define_method(field.to_s + "=") do |should| Puppet.warning "NO CHANGES BEING MADE: zpool #{field} does not match, should be '#{should}' currently is '#{current_pool[field]}'" end end end diff --git a/lib/puppet/rails/database/004_add_inventory_service_tables.rb b/lib/puppet/rails/database/004_add_inventory_service_tables.rb new file mode 100644 index 000000000..6e6b28c0c --- /dev/null +++ b/lib/puppet/rails/database/004_add_inventory_service_tables.rb @@ -0,0 +1,36 @@ +class AddInventoryServiceTables < ActiveRecord::Migration + def self.up + unless ActiveRecord::Base.connection.tables.include?("inventory_nodes") + create_table :inventory_nodes do |t| + t.column :name, :string, :null => false + t.column :timestamp, :datetime, :null => false + t.column :updated_at, :datetime + t.column :created_at, :datetime + end + + add_index :inventory_nodes, :name, :unique => true + end + + unless ActiveRecord::Base.connection.tables.include?("inventory_facts") + create_table :inventory_facts, :id => false do |t| + t.column :node_id, :integer, :null => false + t.column :name, :string, :null => false + t.column :value, :text, :null => false + end + + add_index :inventory_facts, [:node_id, :name], :unique => true + end + end + + def self.down + unless ActiveRecord::Base.connection.tables.include?("inventory_nodes") + remove_index :inventory_nodes, :name + drop_table :inventory_nodes + end + + if ActiveRecord::Base.connection.tables.include?("inventory_facts") + remove_index :inventory_facts, [:node_id, :name] + drop_table :inventory_facts + end + end +end diff --git a/lib/puppet/rails/database/schema.rb b/lib/puppet/rails/database/schema.rb index 8b389d773..7b75f4216 100644 --- a/lib/puppet/rails/database/schema.rb +++ b/lib/puppet/rails/database/schema.rb @@ -1,114 +1,131 @@ class Puppet::Rails::Schema def self.init oldout = nil Puppet::Util.benchmark(Puppet, :notice, "Initialized database") do # We want to rewrite stdout, so we don't get migration messages. oldout = $stdout $stdout = File.open("/dev/null", "w") ActiveRecord::Schema.define do create_table :resources do |t| t.column :title, :text, :null => false t.column :restype, :string, :null => false t.column :host_id, :integer t.column :source_file_id, :integer t.column :exported, :boolean t.column :line, :integer t.column :updated_at, :datetime t.column :created_at, :datetime end add_index :resources, :host_id, :integer => true add_index :resources, :source_file_id, :integer => true # Thanks, mysql! MySQL requires a length on indexes in text fields. # So, we provide them for mysql and handle everything else specially. # Oracle doesn't index on CLOB fields, so we skip it if Puppet[:dbadapter] == "mysql" execute "CREATE INDEX typentitle ON resources (restype,title(50));" elsif Puppet[:dbadapter] != "oracle_enhanced" add_index :resources, [:title, :restype] end create_table :source_files do |t| t.column :filename, :string t.column :path, :string t.column :updated_at, :datetime t.column :created_at, :datetime end add_index :source_files, :filename create_table :resource_tags do |t| t.column :resource_id, :integer t.column :puppet_tag_id, :integer t.column :updated_at, :datetime t.column :created_at, :datetime end add_index :resource_tags, :resource_id, :integer => true add_index :resource_tags, :puppet_tag_id, :integer => true create_table :puppet_tags do |t| t.column :name, :string t.column :updated_at, :datetime t.column :created_at, :datetime end # Oracle automatically creates a primary key index add_index :puppet_tags, :id, :integer => true if Puppet[:dbadapter] != "oracle_enhanced" create_table :hosts do |t| t.column :name, :string, :null => false t.column :ip, :string t.column :environment, :text t.column :last_compile, :datetime t.column :last_freshcheck, :datetime t.column :last_report, :datetime #Use updated_at to automatically add timestamp on save. t.column :updated_at, :datetime t.column :source_file_id, :integer t.column :created_at, :datetime end add_index :hosts, :source_file_id, :integer => true add_index :hosts, :name create_table :fact_names do |t| t.column :name, :string, :null => false t.column :updated_at, :datetime t.column :created_at, :datetime end add_index :fact_names, :name create_table :fact_values do |t| t.column :value, :text, :null => false t.column :fact_name_id, :integer, :null => false t.column :host_id, :integer, :null => false t.column :updated_at, :datetime t.column :created_at, :datetime end add_index :fact_values, :fact_name_id, :integer => true add_index :fact_values, :host_id, :integer => true create_table :param_values do |t| t.column :value, :text, :null => false t.column :param_name_id, :integer, :null => false t.column :line, :integer t.column :resource_id, :integer t.column :updated_at, :datetime t.column :created_at, :datetime end add_index :param_values, :param_name_id, :integer => true add_index :param_values, :resource_id, :integer => true create_table :param_names do |t| t.column :name, :string, :null => false t.column :updated_at, :datetime t.column :created_at, :datetime end add_index :param_names, :name + + create_table :inventory_nodes do |t| + t.column :name, :string, :null => false + t.column :timestamp, :datetime, :null => false + t.column :updated_at, :datetime + t.column :created_at, :datetime + end + + add_index :inventory_nodes, :name, :unique => true + + create_table :inventory_facts, :id => false do |t| + t.column :node_id, :integer, :null => false + t.column :name, :string, :null => false + t.column :value, :text, :null => false + end + + add_index :inventory_facts, [:node_id, :name], :unique => true end end ensure $stdout.close $stdout = oldout if oldout oldout = nil end end diff --git a/lib/puppet/rails/fact_name.rb b/lib/puppet/rails/fact_name.rb index fb40ec48f..4273399e5 100644 --- a/lib/puppet/rails/fact_name.rb +++ b/lib/puppet/rails/fact_name.rb @@ -1,7 +1,5 @@ require 'puppet/rails/fact_value' class Puppet::Rails::FactName < ActiveRecord::Base has_many :fact_values, :dependent => :destroy end - -# $Id: fact_name.rb 1952 2006-12-19 05:47:57Z luke $ diff --git a/lib/puppet/rails/fact_value.rb b/lib/puppet/rails/fact_value.rb index 45a88b2dc..9fd81ae1c 100644 --- a/lib/puppet/rails/fact_value.rb +++ b/lib/puppet/rails/fact_value.rb @@ -1,10 +1,8 @@ class Puppet::Rails::FactValue < ActiveRecord::Base belongs_to :fact_name belongs_to :host def to_label "#{self.fact_name.name}" end end - -# $Id: fact_value.rb 1952 2006-12-19 05:47:57Z luke $ diff --git a/lib/puppet/rails/inventory_fact.rb b/lib/puppet/rails/inventory_fact.rb new file mode 100644 index 000000000..aa6334eef --- /dev/null +++ b/lib/puppet/rails/inventory_fact.rb @@ -0,0 +1,5 @@ +require 'puppet/rails/inventory_node' + +class Puppet::Rails::InventoryFact < ::ActiveRecord::Base + belongs_to :node, :class_name => "Puppet::Rails::InventoryNode" +end diff --git a/lib/puppet/rails/inventory_node.rb b/lib/puppet/rails/inventory_node.rb new file mode 100644 index 000000000..52f8621a4 --- /dev/null +++ b/lib/puppet/rails/inventory_node.rb @@ -0,0 +1,25 @@ +require 'puppet/rails/inventory_fact' + +class Puppet::Rails::InventoryNode < ::ActiveRecord::Base + has_many :facts, :class_name => "Puppet::Rails::InventoryFact", :foreign_key => :node_id, :dependent => :delete_all + + named_scope :has_fact_with_value, lambda { |name,value| + { + :conditions => ["inventory_facts.name = ? AND inventory_facts.value = ?", name, value], + :joins => :facts + } + } + + named_scope :has_fact_without_value, lambda { |name,value| + { + :conditions => ["inventory_facts.name = ? AND inventory_facts.value != ?", name, value], + :joins => :facts + } + } + + def facts_to_hash + facts.inject({}) do |fact_hash,fact| + fact_hash.merge(fact.name => fact.value) + end + end +end diff --git a/lib/puppet/reference/configuration.rb b/lib/puppet/reference/configuration.rb index c8ff145ba..6581427ff 100644 --- a/lib/puppet/reference/configuration.rb +++ b/lib/puppet/reference/configuration.rb @@ -1,144 +1,144 @@ config = Puppet::Util::Reference.newreference(:configuration, :depth => 1, :doc => "A reference for all configuration parameters") do docs = {} Puppet.settings.each do |name, object| docs[name] = object end str = "" docs.sort { |a, b| a[0].to_s <=> b[0].to_s }.each do |name, object| # Make each name an anchor header = name.to_s str += h(header, 3) # Print the doc string itself begin str += object.desc.gsub(/\n/, " ") rescue => detail puts detail.backtrace puts detail end str += "\n\n" # Now print the data about the item. str += "" val = object.default if name.to_s == "vardir" val = "/var/lib/puppet" elsif name.to_s == "confdir" val = "/etc/puppet" end # Leave out the section information; it was apparently confusing people. #str += "- **Section**: #{object.section}\n" unless val == "" str += "- *Default*: #{val}\n" end str += "\n" end return str end config.header = " ## Specifying Configuration Parameters ### On The Command-Line Every Puppet executable (with the exception of `puppetdoc`) accepts all of the parameters below, but not all of the arguments make sense for every executable. I have tried to be as thorough as possible in the descriptions of the arguments, so it should be obvious whether an argument is appropriate or not. These parameters can be supplied to the executables either as command-line options or in the configuration file. For instance, the command-line invocation below would set the configuration directory to `/private/puppet`: $ puppet agent --confdir=/private/puppet Note that boolean options are turned on and off with a slightly different syntax on the command line: $ puppet agent --storeconfigs $ puppet agent --no-storeconfigs The invocations above will enable and disable, respectively, the storage of the client configuration. ### Configuration Files As mentioned above, the configuration parameters can also be stored in a configuration file, located in the configuration directory. As root, the default configuration directory is `/etc/puppet`, and as a regular user, the default configuration directory is `~user/.puppet`. As of 0.23.0, all executables look for `puppet.conf` in their configuration directory (although they previously looked for separate files). For example, `puppet.conf` is located at `/etc/puppet/puppet.conf` as `root` and `~user/.puppet/puppet.conf` as a regular user by default. All executables will set any parameters set within the `[main]` section, and each executable will also use one of the `[master]`, `[agent]`. #### File Format The file follows INI-style formatting. Here is an example of a very simple `puppet.conf` file: [main] confdir = /private/puppet storeconfigs = true Note that boolean parameters must be explicitly specified as `true` or `false` as seen above. If you need to change file or directory parameters (e.g., reset the mode or owner), do so within curly braces on the same line: [main] vardir = /new/vardir {owner = root, mode = 644} If you're starting out with a fresh configuration, you may wish to let the executable generate a template configuration file for you by invoking the executable in question with the `--genconfig` command. The executable will print a template configuration to standard output, which can be redirected to a file like so: $ puppet agent --genconfig > /etc/puppet/puppet.conf Note that this invocation will replace the contents of any pre-existing `puppet.conf` file, so make a backup of your present config if it contains valuable information. Like the `--genconfig` argument, the executables also accept a `--genmanifest` argument, which will generate a manifest that can be used to manage all of Puppet's directories and files and prints it to standard output. This can likewise be redirected to a file: $ puppet agent --genmanifest > /etc/puppet/manifests/site.pp Puppet can also create user and group accounts for itself (one `puppet` group and one `puppet` user) if it is invoked as `root` with the `--mkusers` argument: - $ puppet agent --mkusers + $ puppet master --mkusers ## Signals The `puppet agent` and `puppet master` executables catch some signals for special handling. Both daemons catch (`SIGHUP`), which forces the server to restart tself. Predictably, interrupt and terminate (`SIGINT` and `SIGTERM`) will shut down the server, whether it be an instance of `puppet agent` or `puppet master`. Sending the `SIGUSR1` signal to an instance of `puppet agent` will cause it to immediately begin a new configuration transaction with the server. This signal has no effect on `puppet master`. ## Configuration Parameter Reference Below is a list of all documented parameters. Not all of them are valid with all Puppet executables, but the executables will ignore any inappropriate values. " diff --git a/lib/puppet/reference/metaparameter.rb b/lib/puppet/reference/metaparameter.rb index c16a1d33a..3c4c08701 100644 --- a/lib/puppet/reference/metaparameter.rb +++ b/lib/puppet/reference/metaparameter.rb @@ -1,41 +1,41 @@ metaparameter = Puppet::Util::Reference.newreference :metaparameter, :doc => "All Puppet metaparameters and all their details" do types = {} Puppet::Type.loadall Puppet::Type.eachtype { |type| next if type.name == :puppet next if type.name == :component types[type.name] = type } str = %{ # Metaparameters Metaparameters are parameters that work with any resource type; they are part of the Puppet framework itself rather than being part of the implementation of any given instance. Thus, any defined metaparameter can be used with any instance in your manifest, including defined components. ## Available Metaparameters } begin params = [] Puppet::Type.eachmetaparam { |param| params << param } params.sort { |a,b| a.to_s <=> b.to_s }.each { |param| - str += paramwrap(param.to_s, scrub(Puppet::Type.metaparamdoc(param)), :level => 4) + str += paramwrap(param.to_s, scrub(Puppet::Type.metaparamdoc(param)), :level => 3) } rescue => detail puts detail.backtrace puts "incorrect metaparams: #{detail}" exit(1) end str end diff --git a/lib/puppet/reports/store.rb b/lib/puppet/reports/store.rb index 99a9fc177..625a263b3 100644 --- a/lib/puppet/reports/store.rb +++ b/lib/puppet/reports/store.rb @@ -1,42 +1,45 @@ require 'puppet' Puppet::Reports.register_report(:store) do desc "Store the yaml report on disk. Each host sends its report as a YAML dump and this just stores the file on disk, in the `reportdir` directory. These files collect quickly -- one every half hour -- so it is a good idea to perform some maintenance on them if you use this report (it's the only default report)." def process # We don't want any tracking back in the fs. Unlikely, but there # you go. client = self.host.gsub("..",".") dir = File.join(Puppet[:reportdir], client) - Dir.mkdir(dir, 0750) unless FileTest.exists?(dir) + if ! FileTest.exists?(dir) + FileUtils.mkdir_p(dir) + FileUtils.chmod_R(0750, dir) + end # Now store the report. now = Time.now.gmtime name = %w{year month day hour min}.collect do |method| # Make sure we're at least two digits everywhere "%02d" % now.send(method).to_s end.join("") + ".yaml" file = File.join(dir, name) begin File.open(file, "w", 0640) do |f| f.print to_yaml end rescue => detail puts detail.backtrace if Puppet[:trace] Puppet.warning "Could not write report for #{client} at #{file}: #{detail}" end # Only testing cares about the return value file end end diff --git a/lib/puppet/resource.rb b/lib/puppet/resource.rb index e832804f5..214516908 100644 --- a/lib/puppet/resource.rb +++ b/lib/puppet/resource.rb @@ -1,425 +1,439 @@ require 'puppet' require 'puppet/util/tagging' require 'puppet/util/pson' # The simplest resource class. Eventually it will function as the # base class for all resource-like behaviour. class Puppet::Resource + # This stub class is only needed for serialization compatibility with 0.25.x. + # Specifically, it exists to provide a compatibility API when using YAML + # serialized objects loaded from StoreConfigs. + Reference = Puppet::Resource + include Puppet::Util::Tagging require 'puppet/resource/type_collection_helper' include Puppet::Resource::TypeCollectionHelper extend Puppet::Util::Pson include Enumerable attr_accessor :file, :line, :catalog, :exported, :virtual, :validate_parameters, :strict attr_reader :type, :title require 'puppet/indirector' extend Puppet::Indirector indirects :resource, :terminus_class => :ral ATTRIBUTES = [:file, :line, :exported] def self.from_pson(pson) raise ArgumentError, "No resource type provided in pson data" unless type = pson['type'] raise ArgumentError, "No resource title provided in pson data" unless title = pson['title'] resource = new(type, title) if params = pson['parameters'] params.each { |param, value| resource[param] = value } end if tags = pson['tags'] tags.each { |tag| resource.tag(tag) } end ATTRIBUTES.each do |a| if value = pson[a.to_s] resource.send(a.to_s + "=", value) end end resource.exported ||= false resource end def inspect "#{@type}[#{@title}]#{to_hash.inspect}" end def to_pson_data_hash data = ([:type, :title, :tags] + ATTRIBUTES).inject({}) do |hash, param| next hash unless value = self.send(param) hash[param.to_s] = value hash end data["exported"] ||= false params = self.to_hash.inject({}) do |hash, ary| param, value = ary # Don't duplicate the title as the namevar next hash if param == namevar and value == title hash[param] = Puppet::Resource.value_to_pson_data(value) hash end data["parameters"] = params unless params.empty? data end def self.value_to_pson_data(value) if value.is_a? Array value.map{|v| value_to_pson_data(v) } elsif value.is_a? Puppet::Resource value.to_s else value end end def yaml_property_munge(x) case x when Hash - x.inject({}) { |h,kv| + x.inject({}) { |h,kv| k,v = kv h[k] = self.class.value_to_pson_data(v) h } else self.class.value_to_pson_data(x) end end def to_pson(*args) to_pson_data_hash.to_pson(*args) end # Proxy these methods to the parameters hash. It's likely they'll # be overridden at some point, but this works for now. %w{has_key? keys length delete empty? <<}.each do |method| define_method(method) do |*args| - @parameters.send(method, *args) + parameters.send(method, *args) end end # Set a given parameter. Converts all passed names # to lower-case symbols. def []=(param, value) validate_parameter(param) if validate_parameters - @parameters[parameter_name(param)] = value + parameters[parameter_name(param)] = value end # Return a given parameter's value. Converts all passed names # to lower-case symbols. def [](param) - @parameters[parameter_name(param)] + parameters[parameter_name(param)] end def ==(other) return false unless other.respond_to?(:title) and self.type == other.type and self.title == other.title return false unless to_hash == other.to_hash true end # Compatibility method. def builtin? builtin_type? end # Is this a builtin resource type? def builtin_type? resource_type.is_a?(Class) end # Iterate over each param/value pair, as required for Enumerable. def each - @parameters.each { |p,v| yield p, v } + parameters.each { |p,v| yield p, v } end def include?(parameter) - super || @parameters.keys.include?( parameter_name(parameter) ) + super || parameters.keys.include?( parameter_name(parameter) ) end # These two methods are extracted into a Helper # module, but file load order prevents me # from including them in the class, and I had weird # behaviour (i.e., sometimes it didn't work) when # I directly extended each resource with the helper. def environment Puppet::Node::Environment.new(@environment) end def environment=(env) if env.is_a?(String) or env.is_a?(Symbol) @environment = env else @environment = env.name end end %w{exported virtual strict}.each do |m| define_method(m+"?") do self.send(m) end end - # This stub class is only needed for serialization compatibility with 0.25.x - class Reference - attr_accessor :type,:title - def initialize(type,title) - @type,@title = type,title - end - end - # Create our resource. def initialize(type, title = nil, attributes = {}) @parameters = {} # Set things like strictness first. attributes.each do |attr, value| next if attr == :parameters send(attr.to_s + "=", value) end @type, @title = extract_type_and_title(type, title) @type = munge_type_name(@type) if @type == "Class" @title = :main if @title == "" @title = munge_type_name(@title) end if params = attributes[:parameters] extract_parameters(params) end tag(self.type) tag(self.title) if valid_tag?(self.title) - @reference = Reference.new(@type,@title) # for serialization compatibility with 0.25.x + @reference = self # for serialization compatibility with 0.25.x if strict? and ! resource_type if @type == 'Class' raise ArgumentError, "Could not find declared class #{title}" else raise ArgumentError, "Invalid resource type #{type}" end end end def ref to_s end # Find our resource. def resolve return(catalog ? catalog.resource(to_s) : nil) end def resource_type case type when "Class"; known_resource_types.hostclass(title == :main ? "" : title) when "Node"; known_resource_types.node(title) else Puppet::Type.type(type.to_s.downcase.to_sym) || known_resource_types.definition(type) end end # Produce a simple hash of our parameters. def to_hash - parse_title.merge @parameters + parse_title.merge parameters end def to_s "#{type}[#{title}]" end def uniqueness_key # Temporary kludge to deal with inconsistant use patters h = self.to_hash h[namevar] ||= h[:name] h[:name] ||= h[namevar] h.values_at(*key_attributes.sort_by { |k| k.to_s }) end def key_attributes return(resource_type.respond_to? :key_attributes) ? resource_type.key_attributes : [:name] end # Convert our resource to Puppet code. def to_manifest - "%s { '%s':\n%s\n}" % [self.type.to_s.downcase, self.title, - @parameters.collect { |p, v| - if v.is_a? Array - " #{p} => [\'#{v.join("','")}\']" - else - " #{p} => \'#{v}\'" - end - }.join(",\n") - ] + # Collect list of attributes to align => and move ensure first + attr = parameters.keys + attr_max = attr.inject(0) { |max,k| k.to_s.length > max ? k.to_s.length : max } + + attr.sort! + if attr.first != :ensure && attr.include?(:ensure) + attr.delete(:ensure) + attr.unshift(:ensure) + end + + attributes = attr.collect { |k| + v = parameters[k] + if v.is_a? Array + " %-#{attr_max}s => %s,\n" % [ k, "[\'#{v.join("', '")}\']" ] + else + " %-#{attr_max}s => %s,\n" % [ k, "\'#{v}\'" ] + end + } + + "%s { '%s':\n%s}" % [self.type.to_s.downcase, self.title, attributes] end def to_ref ref end # Convert our resource to a RAL resource instance. Creates component # instances for resource types that don't exist. def to_ral if typeklass = Puppet::Type.type(self.type) return typeklass.new(self) else return Puppet::Type::Component.new(self) end end # Translate our object to a backward-compatible transportable object. def to_trans if builtin_type? and type.downcase.to_s != "stage" result = to_transobject else result = to_transbucket end result.file = self.file result.line = self.line result end def to_trans_ref [type.to_s, title.to_s] end # Create an old-style TransObject instance, for builtin resource types. def to_transobject # Now convert to a transobject result = Puppet::TransObject.new(title, type) to_hash.each do |p, v| if v.is_a?(Puppet::Resource) v = v.to_trans_ref elsif v.is_a?(Array) v = v.collect { |av| av = av.to_trans_ref if av.is_a?(Puppet::Resource) av } end # If the value is an array with only one value, then # convert it to a single value. This is largely so that # the database interaction doesn't have to worry about # whether it returns an array or a string. result[p.to_s] = if v.is_a?(Array) and v.length == 1 v[0] else v end end result.tags = self.tags result end def name # this is potential namespace conflict # between the notion of an "indirector name" # and a "resource name" [ type, title ].join('/') end def to_resource self end def valid_parameter?(name) resource_type.valid_parameter?(name) end def validate_parameter(name) raise ArgumentError, "Invalid parameter #{name}" unless valid_parameter?(name) end private # Produce a canonical method name. def parameter_name(param) param = param.to_s.downcase.to_sym if param == :name and n = namevar param = namevar end param end # The namevar for our resource type. If the type doesn't exist, # always use :name. def namevar if builtin_type? and t = resource_type and t.key_attributes.length == 1 t.key_attributes.first else :name end end # Create an old-style TransBucket instance, for non-builtin resource types. def to_transbucket bucket = Puppet::TransBucket.new([]) bucket.type = self.type bucket.name = self.title # TransBuckets don't support parameters, which is why they're being deprecated. bucket end def extract_parameters(params) params.each do |param, value| validate_parameter(param) if strict? self[param] = value end end def extract_type_and_title(argtype, argtitle) if (argtitle || argtype) =~ /^([^\[\]]+)\[(.+)\]$/m then [ $1, $2 ] elsif argtitle then [ argtype, argtitle ] elsif argtype.is_a?(Puppet::Type) then [ argtype.class.name, argtype.title ] elsif argtype.is_a?(Hash) then raise ArgumentError, "Puppet::Resource.new does not take a hash as the first argument. "+ "Did you mean (#{(argtype[:type] || argtype["type"]).inspect}, #{(argtype[:title] || argtype["title"]).inspect }) ?" else raise ArgumentError, "No title provided and #{argtype.inspect} is not a valid resource reference" end end def munge_type_name(value) return :main if value == :main return "Class" if value == "" or value.nil? or value.to_s.downcase == "component" value.to_s.split("::").collect { |s| s.capitalize }.join("::") end def parse_title h = {} type = resource_type if type.respond_to? :title_patterns type.title_patterns.each { |regexp, symbols_and_lambdas| if captures = regexp.match(title.to_s) symbols_and_lambdas.zip(captures[1..-1]).each { |symbol_and_lambda,capture| sym, lam = symbol_and_lambda #self[sym] = lam.call(capture) h[sym] = lam.call(capture) } return h end } else return { :name => title.to_s } end end + + def parameters + # @parameters could have been loaded from YAML, causing it to be nil (by + # bypassing initialize). + @parameters ||= {} + end end diff --git a/lib/puppet/simple_graph.rb b/lib/puppet/simple_graph.rb index 9d7f218a6..e39aa8770 100644 --- a/lib/puppet/simple_graph.rb +++ b/lib/puppet/simple_graph.rb @@ -1,453 +1,591 @@ -# Created by Luke A. Kanies on 2007-11-07. -# Copyright (c) 2007. All rights reserved. - require 'puppet/external/dot' require 'puppet/relationship' require 'set' # A hopefully-faster graph class to replace the use of GRATR. class Puppet::SimpleGraph # # All public methods of this class must maintain (assume ^ ensure) the following invariants, where "=~=" means # equiv. up to order: # # @in_to.keys =~= @out_to.keys =~= all vertices # @in_to.values.collect { |x| x.values }.flatten =~= @out_from.values.collect { |x| x.values }.flatten =~= all edges # @in_to[v1][v2] =~= @out_from[v2][v1] =~= all edges from v1 to v2 # @in_to [v].keys =~= vertices with edges leading to v # @out_from[v].keys =~= vertices with edges leading from v # no operation may shed reference loops (for gc) # recursive operation must scale with the depth of the spanning trees, or better (e.g. no recursion over the set # of all vertices, etc.) # # This class is intended to be used with DAGs. However, if the # graph has a cycle, it will not cause non-termination of any of the # algorithms. The topsort method detects and reports cycles. # def initialize @in_to = {} @out_from = {} @upstream_from = {} @downstream_from = {} end # Clear our graph. def clear @in_to.clear @out_from.clear @upstream_from.clear @downstream_from.clear end # Which resources depend upon the given resource. def dependencies(resource) vertex?(resource) ? upstream_from_vertex(resource).keys : [] end def dependents(resource) vertex?(resource) ? downstream_from_vertex(resource).keys : [] end # Whether our graph is directed. Always true. Used to produce dot files. def directed? true end # Determine all of the leaf nodes below a given vertex. def leaves(vertex, direction = :out) tree_from_vertex(vertex, direction).keys.find_all { |c| adjacent(c, :direction => direction).empty? } end # Collect all of the edges that the passed events match. Returns # an array of edges. def matching_edges(event, base = nil) source = base || event.resource unless vertex?(source) Puppet.warning "Got an event from invalid vertex #{source.ref}" return [] end # Get all of the edges that this vertex should forward events # to, which is the same thing as saying all edges directly below # This vertex in the graph. @out_from[source].values.flatten.find_all { |edge| edge.match?(event.name) } end # Return a reversed version of this graph. def reversal result = self.class.new vertices.each { |vertex| result.add_vertex(vertex) } edges.each do |edge| result.add_edge edge.class.new(edge.target, edge.source, edge.label) end result end # Return the size of the graph. def size vertices.size end def to_a vertices end - # Provide a topological sort with cycle reporting - def topsort_with_cycles - degree = {} - zeros = [] - result = [] + # This is a simple implementation of Tarjan's algorithm to find strongly + # connected components in the graph; this is a fairly ugly implementation, + # because I can't just decorate the vertices themselves. + # + # This method has an unhealthy relationship with the find_cycles_in_graph + # method below, which contains the knowledge of how the state object is + # maintained. + def tarjan(root, s) + # initialize the recursion stack we use to work around the nasty lack of a + # decent Ruby stack. + recur = [{ :node => root }] + + while not recur.empty? do + frame = recur.last + vertex = frame[:node] + + case frame[:step] + when nil then + s[:index][vertex] = s[:number] + s[:lowlink][vertex] = s[:number] + s[:number] = s[:number] + 1 + + s[:stack].push(vertex) + s[:seen][vertex] = true + + frame[:children] = adjacent(vertex) + frame[:step] = :children + + when :children then + if frame[:children].length > 0 then + child = frame[:children].shift + if ! s[:index][child] then + # Never seen, need to recurse. + frame[:step] = :after_recursion + frame[:child] = child + recur.push({ :node => child }) + elsif s[:seen][child] then + s[:lowlink][vertex] = [s[:lowlink][vertex], s[:index][child]].min + end + else + if s[:lowlink][vertex] == s[:index][vertex] then + this_scc = [] + begin + top = s[:stack].pop + s[:seen][top] = false + this_scc << top + end until top == vertex + # NOTE: if we don't reverse we get the components in the opposite + # order to what a human being would expect; reverse should be an + # O(1) operation, without even copying, because we know the length + # of the source, but I worry that an implementation will get this + # wrong. Still, the worst case is O(n) for n vertices as we can't + # possibly put a vertex into two SCCs. + # + # Also, my feeling is that most implementations are going to do + # better with a reverse operation than a string of 'unshift' + # insertions at the head of the array; if they were going to mess + # up the performance of one, it would be unshift. + s[:scc] << this_scc.reverse + end + recur.pop # done with this node, finally. + end - # Collect each of our vertices, with the number of in-edges each has. - vertices.each do |v| - edges = @in_to[v].dup - zeros << v if edges.empty? - degree[v] = edges + when :after_recursion then + s[:lowlink][vertex] = [s[:lowlink][vertex], s[:lowlink][frame[:child]]].min + frame[:step] = :children + + else + fail "#{frame[:step]} is an unknown step" + end end + end - # Iterate over each 0-degree vertex, decrementing the degree of - # each of its out-edges. - while v = zeros.pop - result << v - @out_from[v].each { |v2,es| - degree[v2].delete(v) - zeros << v2 if degree[v2].empty? - } + # Find all cycles in the graph by detecting all the strongly connected + # components, then eliminating everything with a size of one as + # uninteresting - which it is, because it can't be a cycle. :) + # + # This has an unhealthy relationship with the 'tarjan' method above, which + # it uses to implement the detection of strongly connected components. + def find_cycles_in_graph + state = { + :number => 0, :index => {}, :lowlink => {}, :scc => [], + :stack => [], :seen => {} + } + + # we usually have a disconnected graph, must walk all possible roots + vertices.each do |vertex| + if ! state[:index][vertex] then + tarjan vertex, state + end end - # If we have any vertices left with non-zero in-degrees, then we've found a cycle. - if cycles = degree.values.reject { |ns| ns.empty? } and cycles.length > 0 - message = cycles.collect { |edges| '('+edges.collect { |e| e.to_s }.join(", ")+')' }.join(", ") - raise Puppet::Error, "Found dependency cycles in the following relationships: #{message}; try using the '--graph' option and open the '.dot' files in OmniGraffle or GraphViz" + state[:scc].select { |c| c.length > 1 } + end + + # Perform a BFS on the sub graph representing the cycle, with a view to + # generating a sufficient set of paths to report the cycle meaningfully, and + # ideally usefully, for the end user. + # + # BFS is preferred because it will generally report the shortest paths + # through the graph first, which are more likely to be interesting to the + # user. I think; it would be interesting to verify that. --daniel 2011-01-23 + def paths_in_cycle(cycle, max_paths = 1) + raise ArgumentError, "negative or zero max_paths" if max_paths < 1 + + # Calculate our filtered outbound vertex lists... + adj = {} + cycle.each do |vertex| + adj[vertex] = adjacent(vertex).select{|s| cycle.member? s} end - result + found = [] + + # frame struct is vertex, [path] + stack = [[cycle.first, []]] + while frame = stack.shift do + if frame[1].member?(frame[0]) then + found << frame[1] + [frame[0]] + break if found.length >= max_paths + else + adj[frame[0]].each do |to| + stack.push [to, frame[1] + [frame[0]]] + end + end + end + + return found + end + + def report_cycles_in_graph + cycles = find_cycles_in_graph + n = cycles.length # where is "pluralize"? --daniel 2011-01-22 + s = n == 1 ? '' : 's' + + message = "Found #{n} dependency cycle#{s}:\n" + cycles.each do |cycle| + paths = paths_in_cycle(cycle) + message += paths.map{ |path| '(' + path.join(" => ") + ')'}.join("\n") + "\n" + end + + if Puppet[:graph] then + filename = write_cycles_to_graph(cycles) + message += "Cycle graph written to #{filename}." + else + message += "Try the '--graph' option and opening the " + message += "resulting '.dot' file in OmniGraffle or GraphViz" + end + + raise Puppet::Error, message + end + + def write_cycles_to_graph(cycles) + # This does not use the DOT graph library, just writes the content + # directly. Given the complexity of this, there didn't seem much point + # using a heavy library to generate exactly the same content. --daniel 2011-01-27 + Puppet.settings.use(:graphing) + + graph = ["digraph Resource_Cycles {"] + graph << ' label = "Resource Cycles"' + + cycles.each do |cycle| + paths_in_cycle(cycle, 10).each do |path| + graph << path.map { |v| '"' + v.to_s.gsub(/"/, '\\"') + '"' }.join(" -> ") + end + end + + graph << '}' + + filename = File.join(Puppet[:graphdir], "cycles.dot") + File.open(filename, "w") { |f| f.puts graph } + return filename end # Provide a topological sort. def topsort degree = {} zeros = [] result = [] # Collect each of our vertices, with the number of in-edges each has. vertices.each do |v| edges = @in_to[v] zeros << v if edges.empty? degree[v] = edges.length end # Iterate over each 0-degree vertex, decrementing the degree of # each of its out-edges. while v = zeros.pop result << v - @out_from[v].each { |v2,es| + @out_from[v].each { |v2,es| zeros << v2 if (degree[v2] -= 1) == 0 } end # If we have any vertices left with non-zero in-degrees, then we've found a cycle. if cycles = degree.values.reject { |ns| ns == 0 } and cycles.length > 0 - topsort_with_cycles + report_cycles_in_graph end result end # Add a new vertex to the graph. def add_vertex(vertex) @in_to[vertex] ||= {} @out_from[vertex] ||= {} end # Remove a vertex from the graph. def remove_vertex!(v) return unless vertex?(v) @upstream_from.clear @downstream_from.clear (@in_to[v].values+@out_from[v].values).flatten.each { |e| remove_edge!(e) } @in_to.delete(v) @out_from.delete(v) end # Test whether a given vertex is in the graph. def vertex?(v) @in_to.include?(v) end # Return a list of all vertices. def vertices @in_to.keys end # Add a new edge. The graph user has to create the edge instance, # since they have to specify what kind of edge it is. def add_edge(e,*a) return add_relationship(e,*a) unless a.empty? @upstream_from.clear @downstream_from.clear add_vertex(e.source) add_vertex(e.target) @in_to[ e.target][e.source] ||= []; @in_to[ e.target][e.source] |= [e] @out_from[e.source][e.target] ||= []; @out_from[e.source][e.target] |= [e] end def add_relationship(source, target, label = nil) add_edge Puppet::Relationship.new(source, target, label) end # Find all matching edges. def edges_between(source, target) (@out_from[source] || {})[target] || [] end # Is there an edge between the two vertices? def edge?(source, target) vertex?(source) and vertex?(target) and @out_from[source][target] end def edges @in_to.values.collect { |x| x.values }.flatten end def each_edge @in_to.each { |t,ns| ns.each { |s,es| es.each { |e| yield e }}} end # Remove an edge from our graph. def remove_edge!(e) if edge?(e.source,e.target) @upstream_from.clear @downstream_from.clear @in_to [e.target].delete e.source if (@in_to [e.target][e.source] -= [e]).empty? @out_from[e.source].delete e.target if (@out_from[e.source][e.target] -= [e]).empty? end end # Find adjacent edges. def adjacent(v, options = {}) return [] unless ns = (options[:direction] == :in) ? @in_to[v] : @out_from[v] (options[:type] == :edges) ? ns.values.flatten : ns.keys end # Take container information from another graph and use it # to replace any container vertices with their respective leaves. # This creates direct relationships where there were previously # indirect relationships through the containers. def splice!(other, type) # We have to get the container list via a topological sort on the # configuration graph, because otherwise containers that contain # other containers will add those containers back into the # graph. We could get a similar affect by only setting relationships # to container leaves, but that would result in many more # relationships. stage_class = Puppet::Type.type(:stage) whit_class = Puppet::Type.type(:whit) containers = other.topsort.find_all { |v| (v.is_a?(type) or v.is_a?(stage_class)) and vertex?(v) } containers.each do |container| # Get the list of children from the other graph. children = other.adjacent(container, :direction => :out) # MQR TODO: Luke suggests that it should be possible to refactor the system so that # container nodes are retained, thus obviating the need for the whit. children = [whit_class.new(:name => container.name, :catalog => other)] if children.empty? # First create new edges for each of the :in edges [:in, :out].each do |dir| edges = adjacent(container, :direction => dir, :type => :edges) edges.each do |edge| children.each do |child| if dir == :in s = edge.source t = child else s = child t = edge.target end add_edge(s, t, edge.label) end # Now get rid of the edge, so remove_vertex! works correctly. remove_edge!(edge) end end remove_vertex!(container) end end # Just walk the tree and pass each edge. def walk(source, direction) # Use an iterative, breadth-first traversal of the graph. One could do # this recursively, but Ruby's slow function calls and even slower # recursion make the shorter, recursive algorithm cost-prohibitive. stack = [source] seen = Set.new until stack.empty? node = stack.shift next if seen.member? node connected = adjacent(node, :direction => direction) connected.each do |target| yield node, target end stack.concat(connected) seen << node end end # A different way of walking a tree, and a much faster way than the # one that comes with GRATR. def tree_from_vertex(start, direction = :out) predecessor={} walk(start, direction) do |parent, child| predecessor[child] = parent end predecessor end def downstream_from_vertex(v) return @downstream_from[v] if @downstream_from[v] result = @downstream_from[v] = {} @out_from[v].keys.each do |node| result[node] = 1 result.update(downstream_from_vertex(node)) end result end def upstream_from_vertex(v) return @upstream_from[v] if @upstream_from[v] result = @upstream_from[v] = {} @in_to[v].keys.each do |node| result[node] = 1 result.update(upstream_from_vertex(node)) end result end # LAK:FIXME This is just a paste of the GRATR code with slight modifications. # Return a DOT::DOTDigraph for directed graphs or a DOT::DOTSubgraph for an # undirected Graph. _params_ can contain any graph property specified in # rdot.rb. If an edge or vertex label is a kind of Hash then the keys # which match +dot+ properties will be used as well. def to_dot_graph (params = {}) params['name'] ||= self.class.name.gsub(/:/,'_') fontsize = params['fontsize'] ? params['fontsize'] : '8' graph = (directed? ? DOT::DOTDigraph : DOT::DOTSubgraph).new(params) edge_klass = directed? ? DOT::DOTDirectedEdge : DOT::DOTEdge vertices.each do |v| name = v.to_s params = {'name' => '"'+name+'"', 'fontsize' => fontsize, 'label' => name} v_label = v.to_s params.merge!(v_label) if v_label and v_label.kind_of? Hash graph << DOT::DOTNode.new(params) end edges.each do |e| params = {'from' => '"'+ e.source.to_s + '"', 'to' => '"'+ e.target.to_s + '"', 'fontsize' => fontsize } e_label = e.to_s params.merge!(e_label) if e_label and e_label.kind_of? Hash graph << edge_klass.new(params) end graph end # Output the dot format as a string def to_dot (params={}) to_dot_graph(params).to_s; end # Call +dotty+ for the graph which is written to the file 'graph.dot' # in the # current directory. def dotty (params = {}, dotfile = 'graph.dot') File.open(dotfile, 'w') {|f| f << to_dot(params) } system('dotty', dotfile) end # Produce the graph files if requested. def write_graph(name) return unless Puppet[:graph] Puppet.settings.use(:graphing) file = File.join(Puppet[:graphdir], "#{name}.dot") File.open(file, "w") { |f| f.puts to_dot("name" => name.to_s.capitalize) } end # This flag may be set to true to use the new YAML serialzation # format (where @vertices is a simple list of vertices rather than a # list of VertexWrapper objects). Deserialization supports both # formats regardless of the setting of this flag. class << self attr_accessor :use_new_yaml_format end self.use_new_yaml_format = false # Stub class to allow graphs to be represented in YAML using the old # (version 2.6) format. class VertexWrapper attr_reader :vertex, :adjacencies def initialize(vertex, adjacencies) @vertex = vertex @adjacencies = adjacencies end def inspect { :@adjacencies => @adjacencies, :@vertex => @vertex.to_s }.inspect end end # instance_variable_get is used by Object.to_zaml to get instance # variables. Override it so that we can simulate the presence of # instance variables @edges and @vertices for serialization. def instance_variable_get(v) case v.to_s when '@edges' then edges when '@vertices' then if self.class.use_new_yaml_format vertices else result = {} vertices.each do |vertex| adjacencies = {} [:in, :out].each do |direction| adjacencies[direction] = {} adjacent(vertex, :direction => direction, :type => :edges).each do |edge| other_vertex = direction == :in ? edge.source : edge.target (adjacencies[direction][other_vertex] ||= Set.new).add(edge) end end result[vertex] = Puppet::SimpleGraph::VertexWrapper.new(vertex, adjacencies) end result end else super(v) end end def to_yaml_properties other_vars = instance_variables.reject { |v| %w{@in_to @out_from @upstream_from @downstream_from}.include?(v) } (other_vars + %w{@vertices @edges}).sort.uniq end def yaml_initialize(tag, var) initialize() vertices = var.delete('vertices') edges = var.delete('edges') if vertices.is_a?(Hash) # Support old (2.6) format vertices = vertices.keys end vertices.each { |v| add_vertex(v) } edges.each { |e| add_edge(e) } var.each do |varname, value| instance_variable_set("@#{varname}", value) end end end diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb index e03650b54..d24cc8554 100644 --- a/lib/puppet/type.rb +++ b/lib/puppet/type.rb @@ -1,1897 +1,1910 @@ require 'puppet' require 'puppet/util/log' require 'puppet/util/metric' require 'puppet/property' require 'puppet/parameter' require 'puppet/util' require 'puppet/util/autoload' require 'puppet/metatype/manager' require 'puppet/util/errors' require 'puppet/util/log_paths' require 'puppet/util/logging' require 'puppet/util/cacher' require 'puppet/file_collection/lookup' require 'puppet/util/tagging' # see the bottom of the file for the rest of the inclusions module Puppet class Type include Puppet::Util include Puppet::Util::Errors include Puppet::Util::LogPaths include Puppet::Util::Logging include Puppet::Util::Cacher include Puppet::FileCollection::Lookup include Puppet::Util::Tagging ############################### # Code related to resource type attributes. class << self include Puppet::Util::ClassGen include Puppet::Util::Warnings attr_reader :properties end def self.states warnonce "The states method is deprecated; use properties" properties end # All parameters, in the appropriate order. The key_attributes come first, then # the provider, then the properties, and finally the params and metaparams # in the order they were specified in the files. def self.allattrs key_attributes | (parameters & [:provider]) | properties.collect { |property| property.name } | parameters | metaparams end # Retrieve an attribute alias, if there is one. def self.attr_alias(param) @attr_aliases[symbolize(param)] end # Create an alias to an existing attribute. This will cause the aliased # attribute to be valid when setting and retrieving values on the instance. def self.set_attr_alias(hash) hash.each do |new, old| @attr_aliases[symbolize(new)] = symbolize(old) end end # Find the class associated with any given attribute. def self.attrclass(name) @attrclasses ||= {} # We cache the value, since this method gets called such a huge number # of times (as in, hundreds of thousands in a given run). unless @attrclasses.include?(name) @attrclasses[name] = case self.attrtype(name) when :property; @validproperties[name] when :meta; @@metaparamhash[name] when :param; @paramhash[name] end end @attrclasses[name] end # What type of parameter are we dealing with? Cache the results, because # this method gets called so many times. def self.attrtype(attr) @attrtypes ||= {} unless @attrtypes.include?(attr) @attrtypes[attr] = case when @validproperties.include?(attr); :property when @paramhash.include?(attr); :param when @@metaparamhash.include?(attr); :meta end end @attrtypes[attr] end def self.eachmetaparam @@metaparams.each { |p| yield p.name } end # Create the 'ensure' class. This is a separate method so other types # can easily call it and create their own 'ensure' values. def self.ensurable(&block) if block_given? self.newproperty(:ensure, :parent => Puppet::Property::Ensure, &block) else self.newproperty(:ensure, :parent => Puppet::Property::Ensure) do self.defaultvalues end end end # Should we add the 'ensure' property to this class? def self.ensurable? # If the class has all three of these methods defined, then it's # ensurable. ens = [:exists?, :create, :destroy].inject { |set, method| set &&= self.public_method_defined?(method) } ens end # Deal with any options passed into parameters. def self.handle_param_options(name, options) # If it's a boolean parameter, create a method to test the value easily if options[:boolean] define_method(name.to_s + "?") do val = self[name] if val == :true or val == true return true end end end end # Is the parameter in question a meta-parameter? def self.metaparam?(param) @@metaparamhash.include?(symbolize(param)) end # Find the metaparameter class associated with a given metaparameter name. def self.metaparamclass(name) @@metaparamhash[symbolize(name)] end def self.metaparams @@metaparams.collect { |param| param.name } end def self.metaparamdoc(metaparam) @@metaparamhash[metaparam].doc end # Create a new metaparam. Requires a block and a name, stores it in the # @parameters array, and does some basic checking on it. def self.newmetaparam(name, options = {}, &block) @@metaparams ||= [] @@metaparamhash ||= {} name = symbolize(name) param = genclass( name, :parent => options[:parent] || Puppet::Parameter, :prefix => "MetaParam", :hash => @@metaparamhash, :array => @@metaparams, :attributes => options[:attributes], &block ) # Grr. param.required_features = options[:required_features] if options[:required_features] handle_param_options(name, options) param.metaparam = true param end def self.key_attribute_parameters @key_attribute_parameters ||= ( params = @parameters.find_all { |param| param.isnamevar? or param.name == :name } ) end def self.key_attributes key_attribute_parameters.collect { |p| p.name } end def self.title_patterns case key_attributes.length when 0; [] when 1; identity = lambda {|x| x} [ [ /(.*)/m, [ [key_attributes.first, identity ] ] ] ] else raise Puppet::DevError,"you must specify title patterns when there are two or more key attributes" end end def uniqueness_key - to_resource.uniqueness_key + self.class.key_attributes.sort_by { |attribute_name| attribute_name.to_s }.map{ |attribute_name| self[attribute_name] } end # Create a new parameter. Requires a block and a name, stores it in the # @parameters array, and does some basic checking on it. def self.newparam(name, options = {}, &block) options[:attributes] ||= {} param = genclass( name, :parent => options[:parent] || Puppet::Parameter, :attributes => options[:attributes], :block => block, :prefix => "Parameter", :array => @parameters, :hash => @paramhash ) handle_param_options(name, options) # Grr. param.required_features = options[:required_features] if options[:required_features] param.isnamevar if options[:namevar] param end def self.newstate(name, options = {}, &block) Puppet.warning "newstate() has been deprecrated; use newproperty(#{name})" newproperty(name, options, &block) end # Create a new property. The first parameter must be the name of the property; # this is how users will refer to the property when creating new instances. # The second parameter is a hash of options; the options are: # * :parent: The parent class for the property. Defaults to Puppet::Property. # * :retrieve: The method to call on the provider or @parent object (if # the provider is not set) to retrieve the current value. def self.newproperty(name, options = {}, &block) name = symbolize(name) # This is here for types that might still have the old method of defining # a parent class. unless options.is_a? Hash raise Puppet::DevError, "Options must be a hash, not #{options.inspect}" end raise Puppet::DevError, "Class #{self.name} already has a property named #{name}" if @validproperties.include?(name) if parent = options[:parent] options.delete(:parent) else parent = Puppet::Property end # We have to create our own, new block here because we want to define # an initial :retrieve method, if told to, and then eval the passed # block if available. prop = genclass(name, :parent => parent, :hash => @validproperties, :attributes => options) do # If they've passed a retrieve method, then override the retrieve # method on the class. if options[:retrieve] define_method(:retrieve) do provider.send(options[:retrieve]) end end class_eval(&block) if block end # If it's the 'ensure' property, always put it first. if name == :ensure @properties.unshift prop else @properties << prop end prop end def self.paramdoc(param) @paramhash[param].doc end # Return the parameter names def self.parameters return [] unless defined?(@parameters) @parameters.collect { |klass| klass.name } end # Find the parameter class associated with a given parameter name. def self.paramclass(name) @paramhash[name] end # Return the property class associated with a name def self.propertybyname(name) @validproperties[name] end def self.validattr?(name) name = symbolize(name) return true if name == :name @validattrs ||= {} unless @validattrs.include?(name) @validattrs[name] = !!(self.validproperty?(name) or self.validparameter?(name) or self.metaparam?(name)) end @validattrs[name] end # does the name reflect a valid property? def self.validproperty?(name) name = symbolize(name) @validproperties.include?(name) && @validproperties[name] end # Return the list of validproperties def self.validproperties return {} unless defined?(@parameters) @validproperties.keys end # does the name reflect a valid parameter? def self.validparameter?(name) raise Puppet::DevError, "Class #{self} has not defined parameters" unless defined?(@parameters) !!(@paramhash.include?(name) or @@metaparamhash.include?(name)) end # This is a forward-compatibility method - it's the validity interface we'll use in Puppet::Resource. def self.valid_parameter?(name) validattr?(name) end # Return either the attribute alias or the attribute. def attr_alias(name) name = symbolize(name) if synonym = self.class.attr_alias(name) return synonym else return name end end # Are we deleting this resource? def deleting? obj = @parameters[:ensure] and obj.should == :absent end # Create a new property if it is valid but doesn't exist # Returns: true if a new parameter was added, false otherwise def add_property_parameter(prop_name) if self.class.validproperty?(prop_name) && !@parameters[prop_name] self.newattr(prop_name) return true end false end # # The name_var is the key_attribute in the case that there is only one. # def name_var key_attributes = self.class.key_attributes (key_attributes.length == 1) && key_attributes.first end # abstract accessing parameters and properties, and normalize # access to always be symbols, not strings # This returns a value, not an object. It returns the 'is' # value, but you can also specifically return 'is' and 'should' # values using 'object.is(:property)' or 'object.should(:property)'. def [](name) name = attr_alias(name) fail("Invalid parameter #{name}(#{name.inspect})") unless self.class.validattr?(name) - if name == :name - name = name_var + if name == :name && nv = name_var + name = nv end if obj = @parameters[name] # Note that if this is a property, then the value is the "should" value, # not the current value. obj.value else return nil end end # Abstract setting parameters and properties, and normalize # access to always be symbols, not strings. This sets the 'should' # value on properties, and otherwise just sets the appropriate parameter. def []=(name,value) name = attr_alias(name) fail("Invalid parameter #{name}") unless self.class.validattr?(name) - if name == :name - name = name_var + if name == :name && nv = name_var + name = nv end raise Puppet::Error.new("Got nil value for #{name}") if value.nil? property = self.newattr(name) if property begin # make sure the parameter doesn't have any errors property.value = value rescue => detail error = Puppet::Error.new("Parameter #{name} failed: #{detail}") error.set_backtrace(detail.backtrace) raise error end end nil end # remove a property from the object; useful in testing or in cleanup # when an error has been encountered def delete(attr) attr = symbolize(attr) if @parameters.has_key?(attr) @parameters.delete(attr) else raise Puppet::DevError.new("Undefined attribute '#{attr}' in #{self}") end end # iterate across the existing properties def eachproperty # properties is a private method properties.each { |property| yield property } end # Create a transaction event. Called by Transaction or by # a property. def event(options = {}) Puppet::Transaction::Event.new({:resource => self, :file => file, :line => line, :tags => tags}.merge(options)) end # Let the catalog determine whether a given cached value is # still valid or has expired. def expirer catalog end # retrieve the 'should' value for a specified property def should(name) name = attr_alias(name) (prop = @parameters[name] and prop.is_a?(Puppet::Property)) ? prop.should : nil end # Create the actual attribute instance. Requires either the attribute # name or class as the first argument, then an optional hash of # attributes to set during initialization. def newattr(name) if name.is_a?(Class) klass = name name = klass.name end unless klass = self.class.attrclass(name) raise Puppet::Error, "Resource type #{self.class.name} does not support parameter #{name}" end if provider and ! provider.class.supports_parameter?(klass) missing = klass.required_features.find_all { |f| ! provider.class.feature?(f) } info "Provider %s does not support features %s; not managing attribute %s" % [provider.class.name, missing.join(", "), name] return nil end return @parameters[name] if @parameters.include?(name) @parameters[name] = klass.new(:resource => self) end # return the value of a parameter def parameter(name) @parameters[name.to_sym] end def parameters @parameters.dup end # Is the named property defined? def propertydefined?(name) name = name.intern unless name.is_a? Symbol @parameters.include?(name) end # Return an actual property instance by name; to return the value, use 'resource[param]' # LAK:NOTE(20081028) Since the 'parameter' method is now a superset of this method, # this one should probably go away at some point. def property(name) (obj = @parameters[symbolize(name)] and obj.is_a?(Puppet::Property)) ? obj : nil end # For any parameters or properties that have defaults and have not yet been # set, set them now. This method can be handed a list of attributes, # and if so it will only set defaults for those attributes. def set_default(attr) return unless klass = self.class.attrclass(attr) return unless klass.method_defined?(:default) return if @parameters.include?(klass.name) return unless parameter = newattr(klass.name) if value = parameter.default and ! value.nil? parameter.value = value else @parameters.delete(parameter.name) end end # Convert our object to a hash. This just includes properties. def to_hash rethash = {} @parameters.each do |name, obj| rethash[name] = obj.value end rethash end def type self.class.name end # Return a specific value for an attribute. def value(name) name = attr_alias(name) (obj = @parameters[name] and obj.respond_to?(:value)) ? obj.value : nil end def version return 0 unless catalog catalog.version end # Return all of the property objects, in the order specified in the # class. def properties self.class.properties.collect { |prop| @parameters[prop.name] }.compact end # Is this type's name isomorphic with the object? That is, if the # name conflicts, does it necessarily mean that the objects conflict? # Defaults to true. def self.isomorphic? if defined?(@isomorphic) return @isomorphic else return true end end def isomorphic? self.class.isomorphic? end # is the instance a managed instance? A 'yes' here means that # the instance was created from the language, vs. being created # in order resolve other questions, such as finding a package # in a list def managed? # Once an object is managed, it always stays managed; but an object # that is listed as unmanaged might become managed later in the process, # so we have to check that every time if @managed return @managed else @managed = false properties.each { |property| s = property.should if s and ! property.class.unmanaged @managed = true break end } return @managed end end ############################### # Code related to the container behaviour. # this is a retarded hack method to get around the difference between # component children and file children def self.depthfirst? @depthfirst end def depthfirst? self.class.depthfirst? end # Remove an object. The argument determines whether the object's # subscriptions get eliminated, too. def remove(rmdeps = true) # This is hackish (mmm, cut and paste), but it works for now, and it's # better than warnings. @parameters.each do |name, obj| obj.remove end @parameters.clear @parent = nil # Remove the reference to the provider. if self.provider @provider.clear @provider = nil end end ############################### # Code related to evaluating the resources. # Flush the provider, if it supports it. This is called by the # transaction. def flush self.provider.flush if self.provider and self.provider.respond_to?(:flush) end # if all contained objects are in sync, then we're in sync # FIXME I don't think this is used on the type instances any more, # it's really only used for testing def insync?(is) insync = true if property = @parameters[:ensure] unless is.include? property raise Puppet::DevError, "The is value is not in the is array for '#{property.name}'" end ensureis = is[property] if property.safe_insync?(ensureis) and property.should == :absent return true end end properties.each { |property| unless is.include? property raise Puppet::DevError, "The is value is not in the is array for '#{property.name}'" end propis = is[property] unless property.safe_insync?(propis) property.debug("Not in sync: #{propis.inspect} vs #{property.should.inspect}") insync = false #else # property.debug("In sync") end } #self.debug("#{self} sync status is #{insync}") insync end # retrieve the current value of all contained properties def retrieve fail "Provider #{provider.class.name} is not functional on this host" if self.provider.is_a?(Puppet::Provider) and ! provider.class.suitable? result = Puppet::Resource.new(type, title) # Provide the name, so we know we'll always refer to a real thing result[:name] = self[:name] unless self[:name] == title if ensure_prop = property(:ensure) or (self.class.validattr?(:ensure) and ensure_prop = newattr(:ensure)) result[:ensure] = ensure_state = ensure_prop.retrieve else ensure_state = nil end properties.each do |property| next if property.name == :ensure if ensure_state == :absent result[property] = :absent else result[property] = property.retrieve end end result end def retrieve_resource resource = retrieve resource = Resource.new(type, title, :parameters => resource) if resource.is_a? Hash resource end # Get a hash of the current properties. Returns a hash with # the actual property instance as the key and the current value # as the, um, value. def currentpropvalues # It's important to use the 'properties' method here, as it follows the order # in which they're defined in the class. It also guarantees that 'ensure' # is the first property, which is important for skipping 'retrieve' on # all the properties if the resource is absent. ensure_state = false return properties.inject({}) do | prophash, property| if property.name == :ensure ensure_state = property.retrieve prophash[property] = ensure_state else if ensure_state == :absent prophash[property] = :absent else prophash[property] = property.retrieve end end prophash end end # Are we running in noop mode? def noop? # If we're not a host_config, we're almost certainly part of # Settings, and we want to ignore 'noop' return false if catalog and ! catalog.host_config? if defined?(@noop) @noop else Puppet[:noop] end end def noop noop? end ############################### # Code related to managing resource instances. require 'puppet/transportable' # retrieve a named instance of the current type def self.[](name) raise "Global resource access is deprecated" @objects[name] || @aliases[name] end # add an instance by name to the class list of instances def self.[]=(name,object) raise "Global resource storage is deprecated" newobj = nil if object.is_a?(Puppet::Type) newobj = object else raise Puppet::DevError, "must pass a Puppet::Type object" end if exobj = @objects[name] and self.isomorphic? msg = "Object '#{newobj.class.name}[#{name}]' already exists" msg += ("in file #{object.file} at line #{object.line}") if exobj.file and exobj.line msg += ("and cannot be redefined in file #{object.file} at line #{object.line}") if object.file and object.line error = Puppet::Error.new(msg) raise error else #Puppet.info("adding %s of type %s to class list" % # [name,object.class]) @objects[name] = newobj end end # Create an alias. We keep these in a separate hash so that we don't encounter # the objects multiple times when iterating over them. def self.alias(name, obj) raise "Global resource aliasing is deprecated" if @objects.include?(name) unless @objects[name] == obj raise Puppet::Error.new( "Cannot create alias #{name}: object already exists" ) end end if @aliases.include?(name) unless @aliases[name] == obj raise Puppet::Error.new( "Object #{@aliases[name].name} already has alias #{name}" ) end end @aliases[name] = obj end # remove all of the instances of a single type def self.clear raise "Global resource removal is deprecated" if defined?(@objects) @objects.each do |name, obj| obj.remove(true) end @objects.clear end @aliases.clear if defined?(@aliases) end # Force users to call this, so that we can merge objects if # necessary. def self.create(args) # LAK:DEP Deprecation notice added 12/17/2008 Puppet.warning "Puppet::Type.create is deprecated; use Puppet::Type.new" new(args) end # remove a specified object def self.delete(resource) raise "Global resource removal is deprecated" return unless defined?(@objects) @objects.delete(resource.title) if @objects.include?(resource.title) @aliases.delete(resource.title) if @aliases.include?(resource.title) if @aliases.has_value?(resource) names = [] @aliases.each do |name, otherres| if otherres == resource names << name end end names.each { |name| @aliases.delete(name) } end end # iterate across each of the type's instances def self.each raise "Global resource iteration is deprecated" return unless defined?(@objects) @objects.each { |name,instance| yield instance } end # does the type have an object with the given name? def self.has_key?(name) raise "Global resource access is deprecated" @objects.has_key?(name) end # Retrieve all known instances. Either requires providers or must be overridden. def self.instances raise Puppet::DevError, "#{self.name} has no providers and has not overridden 'instances'" if provider_hash.empty? # Put the default provider first, then the rest of the suitable providers. provider_instances = {} providers_by_source.collect do |provider| provider.instances.collect do |instance| # We always want to use the "first" provider instance we find, unless the resource # is already managed and has a different provider set if other = provider_instances[instance.name] Puppet.warning "%s %s found in both %s and %s; skipping the %s version" % [self.name.to_s.capitalize, instance.name, other.class.name, instance.class.name, instance.class.name] next end provider_instances[instance.name] = instance new(:name => instance.name, :provider => instance, :audit => :all) end end.flatten.compact end # Return a list of one suitable provider per source, with the default provider first. def self.providers_by_source # Put the default provider first, then the rest of the suitable providers. sources = [] [defaultprovider, suitableprovider].flatten.uniq.collect do |provider| next if sources.include?(provider.source) sources << provider.source provider end.compact end # Convert a simple hash into a Resource instance. def self.hash2resource(hash) hash = hash.inject({}) { |result, ary| result[ary[0].to_sym] = ary[1]; result } title = hash.delete(:title) title ||= hash[:name] title ||= hash[key_attributes.first] if key_attributes.length == 1 raise Puppet::Error, "Title or name must be provided" unless title # Now create our resource. resource = Puppet::Resource.new(self.name, title) [:catalog].each do |attribute| if value = hash[attribute] hash.delete(attribute) resource.send(attribute.to_s + "=", value) end end hash.each do |param, value| resource[param] = value end resource end # Create the path for logging and such. def pathbuilder if p = parent [p.pathbuilder, self.ref].flatten else [self.ref] end end ############################### # Add all of the meta parameters. newmetaparam(:noop) do desc "Boolean flag indicating whether work should actually be done." newvalues(:true, :false) munge do |value| case value when true, :true, "true"; @resource.noop = true when false, :false, "false"; @resource.noop = false end end end newmetaparam(:schedule) do desc "On what schedule the object should be managed. You must create a schedule object, and then reference the name of that object to use that for your schedule: schedule { daily: period => daily, range => \"2-4\" } exec { \"/usr/bin/apt-get update\": schedule => daily } The creation of the schedule object does not need to appear in the configuration before objects that use it." end newmetaparam(:audit) do - desc "Audit specified attributes of resources over time, and report if any have changed. - This attribute can be used to track changes to any resource over time, and can - provide an audit trail of every change that happens on any given machine. - - Note that you cannot both audit and manage an attribute - managing it guarantees - the value, and any changes already get logged." + desc "Marks a subset of this resource's unmanaged attributes for auditing. Accepts an + attribute name or a list of attribute names. + + Auditing a resource attribute has two effects: First, whenever a catalog + is applied with puppet apply or puppet agent, Puppet will check whether + that attribute of the resource has been modified, comparing its current + value to the previous run; any change will be logged alongside any actions + performed by Puppet while applying the catalog. + + Secondly, marking a resource attribute for auditing will include that + attribute in inspection reports generated by puppet inspect; see the + puppet inspect documentation for more details. + + Managed attributes for a resource can also be audited, but note that + changes made by Puppet will be logged as additional modifications. (I.e. + if a user manually edits a file whose contents are audited and managed, + puppet agent's next two runs will both log an audit notice: the first run + will log the user's edit and then revert the file to the desired state, + and the second run will log the edit made by Puppet.)" validate do |list| list = Array(list).collect {|p| p.to_sym} unless list == [:all] list.each do |param| next if @resource.class.validattr?(param) fail "Cannot audit #{param}: not a valid attribute for #{resource}" end end end munge do |args| properties_to_audit(args).each do |param| next unless resource.class.validproperty?(param) resource.newattr(param) end end def all_properties resource.class.properties.find_all do |property| resource.provider.nil? or resource.provider.class.supports_parameter?(property) end.collect do |property| property.name end end def properties_to_audit(list) if !list.kind_of?(Array) && list.to_sym == :all list = all_properties else list = Array(list).collect { |p| p.to_sym } end end end newmetaparam(:check) do desc "Audit specified attributes of resources over time, and report if any have changed. This parameter has been deprecated in favor of 'audit'." munge do |args| resource.warning "'check' attribute is deprecated; use 'audit' instead" resource[:audit] = args end end newmetaparam(:loglevel) do desc "Sets the level that information will be logged. The log levels have the biggest impact when logs are sent to syslog (which is currently the default)." defaultto :notice newvalues(*Puppet::Util::Log.levels) newvalues(:verbose) munge do |loglevel| val = super(loglevel) if val == :verbose val = :info end val end end newmetaparam(:alias) do desc "Creates an alias for the object. Puppet uses this internally when you provide a symbolic name: file { sshdconfig: path => $operatingsystem ? { solaris => \"/usr/local/etc/ssh/sshd_config\", default => \"/etc/ssh/sshd_config\" }, source => \"...\" } service { sshd: subscribe => File[sshdconfig] } When you use this feature, the parser sets `sshdconfig` as the name, and the library sets that as an alias for the file so the dependency lookup for `sshd` works. You can use this parameter yourself, but note that only the library can use these aliases; for instance, the following code will not work: file { \"/etc/ssh/sshd_config\": owner => root, group => root, alias => sshdconfig } file { sshdconfig: mode => 644 } There's no way here for the Puppet parser to know that these two stanzas should be affecting the same file. See the [Language Tutorial](http://docs.puppetlabs.com/guides/language_tutorial.html) for more information. " munge do |aliases| aliases = [aliases] unless aliases.is_a?(Array) raise(ArgumentError, "Cannot add aliases without a catalog") unless @resource.catalog aliases.each do |other| if obj = @resource.catalog.resource(@resource.class.name, other) unless obj.object_id == @resource.object_id self.fail("#{@resource.title} can not create alias #{other}: object already exists") end next end # Newschool, add it to the catalog. @resource.catalog.alias(@resource, other) end end end newmetaparam(:tag) do desc "Add the specified tags to the associated resource. While all resources are automatically tagged with as much information as possible (e.g., each class and definition containing the resource), it can be useful to add your own tags to a given resource. Tags are currently useful for things like applying a subset of a host's configuration: puppet agent --test --tags mytag This way, when you're testing a configuration you can run just the portion you're testing." munge do |tags| tags = [tags] unless tags.is_a? Array tags.each do |tag| @resource.tag(tag) end end end class RelationshipMetaparam < Puppet::Parameter class << self attr_accessor :direction, :events, :callback, :subclasses end @subclasses = [] def self.inherited(sub) @subclasses << sub end def munge(references) references = [references] unless references.is_a?(Array) references.collect do |ref| if ref.is_a?(Puppet::Resource) ref else Puppet::Resource.new(ref) end end end def validate_relationship @value.each do |ref| unless @resource.catalog.resource(ref.to_s) description = self.class.direction == :in ? "dependency" : "dependent" fail "Could not find #{description} #{ref} for #{resource.ref}" end end end # Create edges from each of our relationships. :in # relationships are specified by the event-receivers, and :out # relationships are specified by the event generator. This # way 'source' and 'target' are consistent terms in both edges # and events -- that is, an event targets edges whose source matches # the event's source. The direction of the relationship determines # which resource is applied first and which resource is considered # to be the event generator. def to_edges @value.collect do |reference| reference.catalog = resource.catalog # Either of the two retrieval attempts could have returned # nil. unless related_resource = reference.resolve self.fail "Could not retrieve dependency '#{reference}' of #{@resource.ref}" end # Are we requiring them, or vice versa? See the method docs # for futher info on this. if self.class.direction == :in source = related_resource target = @resource else source = @resource target = related_resource end if method = self.class.callback subargs = { :event => self.class.events, :callback => method } self.debug("subscribes to #{related_resource.ref}") else # If there's no callback, there's no point in even adding # a label. subargs = nil self.debug("requires #{related_resource.ref}") end rel = Puppet::Relationship.new(source, target, subargs) end end end def self.relationship_params RelationshipMetaparam.subclasses end # Note that the order in which the relationships params is defined # matters. The labelled params (notify and subcribe) must be later, # so that if both params are used, those ones win. It's a hackish # solution, but it works. newmetaparam(:require, :parent => RelationshipMetaparam, :attributes => {:direction => :in, :events => :NONE}) do desc "One or more objects that this object depends on. This is used purely for guaranteeing that changes to required objects happen before the dependent object. For instance: # Create the destination directory before you copy things down file { \"/usr/local/scripts\": ensure => directory } file { \"/usr/local/scripts/myscript\": source => \"puppet://server/module/myscript\", mode => 755, require => File[\"/usr/local/scripts\"] } Multiple dependencies can be specified by providing a comma-seperated list of resources, enclosed in square brackets: require => [ File[\"/usr/local\"], File[\"/usr/local/scripts\"] ] Note that Puppet will autorequire everything that it can, and there are hooks in place so that it's easy for resources to add new ways to autorequire objects, so if you think Puppet could be smarter here, let us know. In fact, the above code was redundant -- Puppet will autorequire any parent directories that are being managed; it will automatically realize that the parent directory should be created before the script is pulled down. Currently, exec resources will autorequire their CWD (if it is specified) plus any fully qualified paths that appear in the command. For instance, if you had an `exec` command that ran the `myscript` mentioned above, the above code that pulls the file down would be automatically listed as a requirement to the `exec` code, so that you would always be running againts the most recent version. " end newmetaparam(:subscribe, :parent => RelationshipMetaparam, :attributes => {:direction => :in, :events => :ALL_EVENTS, :callback => :refresh}) do desc "One or more objects that this object depends on. Changes in the subscribed to objects result in the dependent objects being refreshed (e.g., a service will get restarted). For instance: class nagios { file { \"/etc/nagios/nagios.conf\": source => \"puppet://server/module/nagios.conf\", alias => nagconf # just to make things easier for me } service { nagios: ensure => running, subscribe => File[nagconf] } } Currently the `exec`, `mount` and `service` type support refreshing. " end newmetaparam(:before, :parent => RelationshipMetaparam, :attributes => {:direction => :out, :events => :NONE}) do desc %{This parameter is the opposite of **require** -- it guarantees that the specified object is applied later than the specifying object: file { "/var/nagios/configuration": source => "...", recurse => true, before => Exec["nagios-rebuid"] } exec { "nagios-rebuild": command => "/usr/bin/make", cwd => "/var/nagios/configuration" } This will make sure all of the files are up to date before the make command is run.} end newmetaparam(:notify, :parent => RelationshipMetaparam, :attributes => {:direction => :out, :events => :ALL_EVENTS, :callback => :refresh}) do desc %{This parameter is the opposite of **subscribe** -- it sends events to the specified object: file { "/etc/sshd_config": source => "....", notify => Service[sshd] } service { sshd: ensure => running } This will restart the sshd service if the sshd config file changes.} end newmetaparam(:stage) do desc %{Which run stage a given resource should reside in. This just creates a dependency on or from the named milestone. For instance, saying that this is in the 'bootstrap' stage creates a dependency on the 'bootstrap' milestone. By default, all classes get directly added to the 'main' stage. You can create new stages as resources: stage { [pre, post]: } To order stages, use standard relationships: stage { pre: before => Stage[main] } Or use the new relationship syntax: Stage[pre] -> Stage[main] -> Stage[post] Then use the new class parameters to specify a stage: class { foo: stage => pre } Stages can only be set on classes, not individual resources. This will fail: file { '/foo': stage => pre, ensure => file } } end ############################### # All of the provider plumbing for the resource types. require 'puppet/provider' require 'puppet/util/provider_features' # Add the feature handling module. extend Puppet::Util::ProviderFeatures attr_reader :provider # the Type class attribute accessors class << self attr_accessor :providerloader attr_writer :defaultprovider end # Find the default provider. def self.defaultprovider unless @defaultprovider suitable = suitableprovider # Find which providers are a default for this system. defaults = suitable.find_all { |provider| provider.default? } # If we don't have any default we use suitable providers defaults = suitable if defaults.empty? max = defaults.collect { |provider| provider.specificity }.max defaults = defaults.find_all { |provider| provider.specificity == max } retval = nil if defaults.length > 1 Puppet.warning( "Found multiple default providers for #{self.name}: #{defaults.collect { |i| i.name.to_s }.join(", ")}; using #{defaults[0].name}" ) retval = defaults.shift elsif defaults.length == 1 retval = defaults.shift else raise Puppet::DevError, "Could not find a default provider for #{self.name}" end @defaultprovider = retval end @defaultprovider end def self.provider_hash_by_type(type) @provider_hashes ||= {} @provider_hashes[type] ||= {} end def self.provider_hash Puppet::Type.provider_hash_by_type(self.name) end # Retrieve a provider by name. def self.provider(name) name = Puppet::Util.symbolize(name) # If we don't have it yet, try loading it. @providerloader.load(name) unless provider_hash.has_key?(name) provider_hash[name] end # Just list all of the providers. def self.providers provider_hash.keys end def self.validprovider?(name) name = Puppet::Util.symbolize(name) (provider_hash.has_key?(name) && provider_hash[name].suitable?) end # Create a new provider of a type. This method must be called # directly on the type that it's implementing. def self.provide(name, options = {}, &block) name = Puppet::Util.symbolize(name) if obj = provider_hash[name] Puppet.debug "Reloading #{name} #{self.name} provider" unprovide(name) end parent = if pname = options[:parent] options.delete(:parent) if pname.is_a? Class pname else if provider = self.provider(pname) provider else raise Puppet::DevError, "Could not find parent provider #{pname} of #{name}" end end else Puppet::Provider end options[:resource_type] ||= self self.providify provider = genclass( name, :parent => parent, :hash => provider_hash, :prefix => "Provider", :block => block, :include => feature_module, :extend => feature_module, :attributes => options ) provider end # Make sure we have a :provider parameter defined. Only gets called if there # are providers. def self.providify return if @paramhash.has_key? :provider newparam(:provider) do desc "The specific backend for #{self.name.to_s} to use. You will seldom need to specify this -- Puppet will usually discover the appropriate provider for your platform." # This is so we can refer back to the type to get a list of # providers for documentation. class << self attr_accessor :parenttype end # We need to add documentation for each provider. def self.doc @doc + " Available providers are:\n\n" + parenttype.providers.sort { |a,b| a.to_s <=> b.to_s }.collect { |i| "* **#{i}**: #{parenttype().provider(i).doc}" }.join("\n") end defaultto { @resource.class.defaultprovider.name } validate do |provider_class| provider_class = provider_class[0] if provider_class.is_a? Array provider_class = provider_class.class.name if provider_class.is_a?(Puppet::Provider) unless provider = @resource.class.provider(provider_class) raise ArgumentError, "Invalid #{@resource.class.name} provider '#{provider_class}'" end end munge do |provider| provider = provider[0] if provider.is_a? Array provider = provider.intern if provider.is_a? String @resource.provider = provider if provider.is_a?(Puppet::Provider) provider.class.name else provider end end end.parenttype = self end def self.unprovide(name) if provider_hash.has_key? name rmclass( name, :hash => provider_hash, :prefix => "Provider" ) if @defaultprovider and @defaultprovider.name == name @defaultprovider = nil end end end # Return an array of all of the suitable providers. def self.suitableprovider providerloader.loadall if provider_hash.empty? provider_hash.find_all { |name, provider| provider.suitable? }.collect { |name, provider| provider }.reject { |p| p.name == :fake } # For testing end def provider=(name) if name.is_a?(Puppet::Provider) @provider = name @provider.resource = self elsif klass = self.class.provider(name) @provider = klass.new(self) else raise ArgumentError, "Could not find #{name} provider of #{self.class.name}" end end ############################### # All of the relationship code. # Specify a block for generating a list of objects to autorequire. This # makes it so that you don't have to manually specify things that you clearly # require. def self.autorequire(name, &block) @autorequires ||= {} @autorequires[name] = block end # Yield each of those autorequires in turn, yo. def self.eachautorequire @autorequires ||= {} @autorequires.each { |type, block| yield(type, block) } end # Figure out of there are any objects we can automatically add as # dependencies. def autorequire(rel_catalog = nil) rel_catalog ||= catalog raise(Puppet::DevError, "You cannot add relationships without a catalog") unless rel_catalog reqs = [] self.class.eachautorequire { |type, block| # Ignore any types we can't find, although that would be a bit odd. next unless typeobj = Puppet::Type.type(type) # Retrieve the list of names from the block. next unless list = self.instance_eval(&block) list = [list] unless list.is_a?(Array) # Collect the current prereqs list.each { |dep| obj = nil # Support them passing objects directly, to save some effort. unless dep.is_a? Puppet::Type # Skip autorequires that we aren't managing unless dep = rel_catalog.resource(type, dep) next end end reqs << Puppet::Relationship.new(dep, self) } } reqs end # Build the dependencies associated with an individual object. def builddepends # Handle the requires self.class.relationship_params.collect do |klass| if param = @parameters[klass.name] param.to_edges end end.flatten.reject { |r| r.nil? } end # Define the initial list of tags. def tags=(list) tag(self.class.name) tag(*list) end # Types (which map to resources in the languages) are entirely composed of # attribute value pairs. Generally, Puppet calls any of these things an # 'attribute', but these attributes always take one of three specific # forms: parameters, metaparams, or properties. # In naming methods, I have tried to consistently name the method so # that it is clear whether it operates on all attributes (thus has 'attr' in # the method name, or whether it operates on a specific type of attributes. attr_writer :title attr_writer :noop include Enumerable # class methods dealing with Type management public # the Type class attribute accessors class << self attr_reader :name attr_accessor :self_refresh include Enumerable, Puppet::Util::ClassGen include Puppet::MetaType::Manager include Puppet::Util include Puppet::Util::Logging end # all of the variables that must be initialized for each subclass def self.initvars # all of the instances of this class @objects = Hash.new @aliases = Hash.new @defaults = {} @parameters ||= [] @validproperties = {} @properties = [] @parameters = [] @paramhash = {} @attr_aliases = {} @paramdoc = Hash.new { |hash,key| key = key.intern if key.is_a?(String) if hash.include?(key) hash[key] else "Param Documentation for #{key} not found" end } @doc ||= "" end def self.to_s if defined?(@name) "Puppet::Type::#{@name.to_s.capitalize}" else super end end # Create a block to validate that our object is set up entirely. This will # be run before the object is operated on. def self.validate(&block) define_method(:validate, &block) #@validate = block end # The catalog that this resource is stored in. attr_accessor :catalog # is the resource exported attr_accessor :exported # is the resource virtual (it should not :-)) attr_accessor :virtual # create a log at specified level def log(msg) Puppet::Util::Log.create( :level => @parameters[:loglevel].value, :message => msg, :source => self ) end # instance methods related to instance intrinsics # e.g., initialize and name public attr_reader :original_parameters # initialize the type instance def initialize(resource) raise Puppet::DevError, "Got TransObject instead of Resource or hash" if resource.is_a?(Puppet::TransObject) resource = self.class.hash2resource(resource) unless resource.is_a?(Puppet::Resource) # The list of parameter/property instances. @parameters = {} # Set the title first, so any failures print correctly. if resource.type.to_s.downcase.to_sym == self.class.name self.title = resource.title else # This should only ever happen for components self.title = resource.ref end [:file, :line, :catalog, :exported, :virtual].each do |getter| setter = getter.to_s + "=" if val = resource.send(getter) self.send(setter, val) end end @tags = resource.tags @original_parameters = resource.to_hash set_name(@original_parameters) set_default(:provider) set_parameters(@original_parameters) self.validate if self.respond_to?(:validate) end private # Set our resource's name. def set_name(hash) self[name_var] = hash.delete(name_var) if name_var end # Set all of the parameters from a hash, in the appropriate order. def set_parameters(hash) # Use the order provided by allattrs, but add in any # extra attributes from the resource so we get failures # on invalid attributes. no_values = [] (self.class.allattrs + hash.keys).uniq.each do |attr| begin # Set any defaults immediately. This is mostly done so # that the default provider is available for any other # property validation. if hash.has_key?(attr) self[attr] = hash[attr] else no_values << attr end rescue ArgumentError, Puppet::Error, TypeError raise rescue => detail error = Puppet::DevError.new( "Could not set #{attr} on #{self.class.name}: #{detail}") error.set_backtrace(detail.backtrace) raise error end end no_values.each do |attr| set_default(attr) end end public # Set up all of our autorequires. def finish # Make sure all of our relationships are valid. Again, must be done # when the entire catalog is instantiated. self.class.relationship_params.collect do |klass| if param = @parameters[klass.name] param.validate_relationship end end.flatten.reject { |r| r.nil? } end # For now, leave the 'name' method functioning like it used to. Once 'title' # works everywhere, I'll switch it. def name self[:name] end # Look up our parent in the catalog, if we have one. def parent return nil unless catalog unless defined?(@parent) if parents = catalog.adjacent(self, :direction => :in) # We should never have more than one parent, so let's just ignore # it if we happen to. @parent = parents.shift else @parent = nil end end @parent end # Return the "type[name]" style reference. def ref "#{self.class.name.to_s.capitalize}[#{self.title}]" end def self_refresh? self.class.self_refresh end # Mark that we're purging. def purging @purging = true end # Is this resource being purged? Used by transactions to forbid # deletion when there are dependencies. def purging? if defined?(@purging) @purging else false end end # Retrieve the title of an object. If no title was set separately, # then use the object's name. def title unless @title if self.class.validparameter?(name_var) @title = self[:name] elsif self.class.validproperty?(name_var) @title = self.should(name_var) else self.devfail "Could not find namevar #{name_var} for #{self.class.name}" end end @title end # convert to a string def to_s self.ref end # Convert to a transportable object def to_trans(ret = true) trans = TransObject.new(self.title, self.class.name) values = retrieve_resource values.each do |name, value| name = name.name if name.respond_to? :name trans[name] = value end @parameters.each do |name, param| # Avoid adding each instance name twice next if param.class.isnamevar? and param.value == self.title # We've already got property values next if param.is_a?(Puppet::Property) trans[name] = param.value end trans.tags = self.tags # FIXME I'm currently ignoring 'parent' and 'path' trans end def to_resource # this 'type instance' versus 'resource' distinction seems artificial # I'd like to see it collapsed someday ~JW self.to_trans.to_resource end def virtual?; !!@virtual; end def exported?; !!@exported; end end end require 'puppet/provider' # Always load these types. require 'puppet/type/component' diff --git a/lib/puppet/type/augeas.rb b/lib/puppet/type/augeas.rb index d29bda648..a8fb1f15f 100644 --- a/lib/puppet/type/augeas.rb +++ b/lib/puppet/type/augeas.rb @@ -1,182 +1,182 @@ #-- # Copyright (C) 2008 Red Hat Inc. # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Author: Bryan Kearney Puppet::Type.newtype(:augeas) do include Puppet::Util feature :parse_commands, "Parse the command string" feature :need_to_run?, "If the command should run" feature :execute_changes, "Actually make the changes" @doc = "Apply the changes (single or array of changes) to the filesystem via the augeas tool. Requires: - augeas to be installed (http://www.augeas.net) - ruby-augeas bindings Sample usage with a string: augeas{\"test1\" : context => \"/files/etc/sysconfig/firstboot\", changes => \"set RUN_FIRSTBOOT YES\", onlyif => \"match other_value size > 0\", } Sample usage with an array and custom lenses: augeas{\"jboss_conf\": context => \"/files\", changes => [ \"set /etc/jbossas/jbossas.conf/JBOSS_IP $ipaddress\", \"set /etc/jbossas/jbossas.conf/JAVA_HOME /usr\" ], load_path => \"$/usr/share/jbossas/lenses\", } " newparam (:name) do desc "The name of this task. Used for uniqueness" isnamevar end newparam (:context) do desc "Optional context path. This value is prepended to the paths of all changes if the path is relative. If INCL is set, defaults to '/files' + INCL, otherwise the empty string" defaultto "" munge do |value| if value.empty? and resource[:incl] "/files" + resource[:incl] else value end end end newparam (:onlyif) do desc "Optional augeas command and comparisons to control the execution of this type. Supported onlyif syntax: get [AUGEAS_PATH] [COMPARATOR] [STRING] match [MATCH_PATH] size [COMPARATOR] [INT] match [MATCH_PATH] include [STRING] match [MATCH_PATH] not_include [STRING] match [MATCH_PATH] == [AN_ARRAY] match [MATCH_PATH] != [AN_ARRAY] where: AUGEAS_PATH is a valid path scoped by the context MATCH_PATH is a valid match synatx scoped by the context COMPARATOR is in the set [> >= != == <= <] STRING is a string INT is a number AN_ARRAY is in the form ['a string', 'another']" defaultto "" end newparam(:changes) do desc "The changes which should be applied to the filesystem. This can be either a string which contains a command or an array of commands. Commands supported are: - set [PATH] [VALUE] Sets the value VALUE at loction PATH - rm [PATH] Removes the node at location PATH - remove [PATH] Synonym for rm - clear [PATH] Keeps the node at PATH, but removes the value. + set [PATH] [VALUE] Sets the value VALUE at loction PATH + rm [PATH] Removes the node at location PATH + remove [PATH] Synonym for rm + clear [PATH] Keeps the node at PATH, but removes the value. ins [LABEL] [WHERE] [PATH] Inserts an empty node LABEL either [WHERE={before|after}] PATH. insert [LABEL] [WHERE] [PATH] Synonym for ins If the parameter 'context' is set that value is prepended to PATH" end newparam(:root) do desc "A file system path; all files loaded by Augeas are loaded underneath ROOT" defaultto "/" end newparam(:load_path) do desc "Optional colon separated list of directories; these directories are searched for schema definitions" defaultto "" end newparam(:force) do desc "Optional command to force the augeas type to execute even if it thinks changes will not be made. This does not overide the only setting. If onlyif is set, then the foce setting will not override that result" defaultto false end newparam(:type_check) do desc "Set to true if augeas should perform typechecking. Optional, defaults to false" newvalues(:true, :false) defaultto :false end newparam(:lens) do desc "Use a specific lens, e.g. `Hosts.lns`. When this parameter is set, you must also set the incl parameter to indicate which file to load. Only that file will be loaded, which greatly speeds up execution of the type" end newparam(:incl) do desc "Load only a specific file, e.g. `/etc/hosts`. When this parameter is set, you must also set the lens parameter to indicate which lens to use." end validate do has_lens = !self[:lens].nil? has_incl = !self[:incl].nil? self.fail "You must specify both the lens and incl parameters, or neither" if has_lens != has_incl end # This is the acutal meat of the code. It forces # augeas to be run and fails or not based on the augeas return # code. newproperty(:returns) do |property| include Puppet::Util desc "The expected return code from the augeas command. Should not be set" defaultto 0 # Make output a bit prettier def change_to_s(currentvalue, newvalue) "executed successfully" end # if the onlyif resource is provided, then the value is parsed. # a return value of 0 will stop exection because it matches the # default value. def retrieve if @resource.provider.need_to_run?() :need_to_run else 0 end end # Actually execute the command. def sync @resource.provider.execute_changes end end end diff --git a/lib/puppet/type/computer.rb b/lib/puppet/type/computer.rb index 89a0692bf..7a2c52d53 100644 --- a/lib/puppet/type/computer.rb +++ b/lib/puppet/type/computer.rb @@ -1,62 +1,66 @@ Puppet::Type.newtype(:computer) do @doc = "Computer object management using DirectoryService on OS X. Note that these are distinctly different kinds of objects to 'hosts', as they require a MAC address and can have all sorts of policy attached to them. This provider only manages Computer objects in the local directory service domain, not in remote directories. If you wish to manage `/etc/hosts` file on Mac OS X, then simply use the host type as per other platforms. This type primarily exists to create localhost Computer objects that MCX - policy can then be attached to." + policy can then be attached to. + + **Autorequires:** If Puppet is managing the plist file representing a + Computer object (located at `/var/db/dslocal/nodes/Default/computers/{name}.plist`), + the Computer resource will autorequire it." # ensurable # We autorequire the computer object in case it is being managed at the # file level by Puppet. autorequire(:file) do if self[:name] "/var/db/dslocal/nodes/Default/computers/#{self[:name]}.plist" else nil end end newproperty(:ensure, :parent => Puppet::Property::Ensure) do desc "Control the existences of this computer record. Set this attribute to `present` to ensure the computer record exists. Set it to `absent` to delete any computer records with this name" newvalue(:present) do provider.create end newvalue(:absent) do provider.delete end end newparam(:name) do desc "The authoritative 'short' name of the computer record." isnamevar end newparam(:realname) do desc "The 'long' name of the computer record." end newproperty(:en_address) do desc "The MAC address of the primary network interface. Must match en0." end newproperty(:ip_address) do desc "The IP Address of the Computer object." end end diff --git a/lib/puppet/type/exec.rb b/lib/puppet/type/exec.rb index daa49e223..ae579502a 100755 --- a/lib/puppet/type/exec.rb +++ b/lib/puppet/type/exec.rb @@ -1,649 +1,642 @@ module Puppet newtype(:exec) do include Puppet::Util::Execution require 'timeout' @doc = "Executes external commands. It is critical that all commands executed using this mechanism can be run multiple times without harm, i.e., they are *idempotent*. One useful way to create idempotent commands is to use the checks like `creates` to avoid running the command unless some condition is met. Note that you can restrict an `exec` to only run when it receives events by using the `refreshonly` parameter; this is a useful way to have your configuration respond to events with arbitrary commands. Note also that if an `exec` receives an event from another resource, it will get executed again (or execute the command specified in `refresh`, if there is one). There is a strong tendency to use `exec` to do whatever work Puppet can't already do; while this is obviously acceptable (and unavoidable) in the short term, it is highly recommended to migrate work from `exec` to native Puppet types as quickly as possible. If you find that you are doing a lot of work with `exec`, please at least notify us at Puppet Labs what you are doing, and hopefully we can work with - you to get a native resource type for the work you are doing." + you to get a native resource type for the work you are doing. + + **Autorequires:** If Puppet is managing an exec's cwd or the executable file used in an exec's command, the exec resource will autorequire those files. If Puppet is managing the user that an exec should run as, the exec resource will autorequire that user." require 'open3' # Create a new check mechanism. It's basically just a parameter that # provides one extra 'check' method. def self.newcheck(name, &block) @checks ||= {} check = newparam(name, &block) @checks[name] = check end def self.checks @checks.keys end newproperty(:returns, :array_matching => :all, :event => :executed_command) do |property| include Puppet::Util::Execution munge do |value| value.to_s end def event_name :executed_command end defaultto "0" attr_reader :output desc "The expected return code(s). An error will be returned if the executed command returns something else. Defaults to 0. Can be specified as an array of acceptable return codes or a single value." # Make output a bit prettier def change_to_s(currentvalue, newvalue) "executed successfully" end # First verify that all of our checks pass. def retrieve # Default to somethinng if @resource.check return :notrun else return self.should end end # Actually execute the command. def sync olddir = nil # We need a dir to change to, even if it's just the cwd dir = self.resource[:cwd] || Dir.pwd event = :executed_command tries = self.resource[:tries] try_sleep = self.resource[:try_sleep] begin tries.times do |try| # Only add debug messages for tries > 1 to reduce log spam. debug("Exec try #{try+1}/#{tries}") if tries > 1 @output, @status = @resource.run(self.resource[:command]) break if self.should.include?(@status.exitstatus.to_s) if try_sleep > 0 and tries > 1 debug("Sleeping for #{try_sleep} seconds between tries") sleep try_sleep end end rescue Timeout::Error self.fail "Command exceeded timeout" % value.inspect end if log = @resource[:logoutput] case log when :true log = @resource[:loglevel] when :on_failure unless self.should.include?(@status.exitstatus.to_s) log = @resource[:loglevel] else log = :false end end unless log == :false @output.split(/\n/).each { |line| self.send(log, line) } end end unless self.should.include?(@status.exitstatus.to_s) self.fail("#{self.resource[:command]} returned #{@status.exitstatus} instead of one of [#{self.should.join(",")}]") end event end end newparam(:command) do isnamevar desc "The actual command to execute. Must either be fully qualified or a search path for the command must be provided. If the command succeeds, any output produced will be logged at the instance's normal log level (usually `notice`), but if the command fails (meaning its return code does not match the specified code) then any output is logged at the `err` log level." end newparam(:path) do desc "The search path used for command execution. Commands must be fully qualified if no path is specified. Paths can be specified as an array or as a colon-separated list." # Support both arrays and colon-separated fields. def value=(*values) @value = values.flatten.collect { |val| if val =~ /;/ # recognize semi-colon separated paths val.split(";") elsif val =~ /^\w:[^:]*$/ # heuristic to avoid splitting a driveletter away val else val.split(":") end }.flatten end end newparam(:user) do desc "The user to run the command as. Note that if you use this then any error output is not currently captured. This is because of a bug within Ruby. If you are using Puppet to create this user, the exec will automatically require the user, as long as it is specified by name." # Most validation is handled by the SUIDManager class. validate do |user| self.fail "Only root can execute commands as other users" unless Puppet.features.root? end end newparam(:group) do desc "The group to run the command as. This seems to work quite haphazardly on different platforms -- it is a platform issue not a Ruby or Puppet one, since the same variety exists when running commnands as different users in the shell." # Validation is handled by the SUIDManager class. end newparam(:cwd) do desc "The directory from which to run the command. If this directory does not exist, the command will fail." validate do |dir| unless dir =~ /^#{File::SEPARATOR}/ self.fail("CWD must be a fully qualified path") end end munge do |dir| dir = dir[0] if dir.is_a?(Array) dir end end newparam(:logoutput) do desc "Whether to log output. Defaults to logging output at the loglevel for the `exec` resource. Use *on_failure* to only log the output when the command reports an error. Values are **true**, *false*, *on_failure*, and any legal log level." newvalues(:true, :false, :on_failure) end newparam(:refresh) do desc "How to refresh this command. By default, the exec is just called again when it receives an event from another resource, but this parameter allows you to define a different command for refreshing." validate do |command| @resource.validatecmd(command) end end - newparam(:env) do - desc "This parameter is deprecated. Use 'environment' instead." - - munge do |value| - warning "'env' is deprecated on exec; use 'environment' instead." - resource[:environment] = value - end - end - newparam(:environment) do desc "Any additional environment variables you want to set for a command. Note that if you use this to set PATH, it will override the `path` attribute. Multiple environment variables should be specified as an array." validate do |values| values = [values] unless values.is_a? Array values.each do |value| unless value =~ /\w+=/ raise ArgumentError, "Invalid environment setting '#{value}'" end end end end newparam(:timeout) do desc "The maximum time the command should take. If the command takes longer than the timeout, the command is considered to have failed and will be stopped. Use any negative number to disable the timeout. The time is specified in seconds." munge do |value| value = value.shift if value.is_a?(Array) if value.is_a?(String) unless value =~ /^[-\d.]+$/ raise ArgumentError, "The timeout must be a number." end Float(value) else value end end defaultto 300 end newparam(:tries) do desc "The number of times execution of the command should be tried. Defaults to '1'. This many attempts will be made to execute the command until an acceptable return code is returned. Note that the timeout paramater applies to each try rather than to the complete set of tries." munge do |value| if value.is_a?(String) unless value =~ /^[\d]+$/ raise ArgumentError, "Tries must be an integer" end value = Integer(value) end raise ArgumentError, "Tries must be an integer >= 1" if value < 1 value end defaultto 1 end newparam(:try_sleep) do desc "The time to sleep in seconds between 'tries'." munge do |value| if value.is_a?(String) unless value =~ /^[-\d.]+$/ raise ArgumentError, "try_sleep must be a number" end value = Float(value) end raise ArgumentError, "try_sleep cannot be a negative number" if value < 0 value end defaultto 0 end newcheck(:refreshonly) do desc "The command should only be run as a refresh mechanism for when a dependent object is changed. It only makes sense to use this option when this command depends on some other object; it is useful for triggering an action: # Pull down the main aliases file file { \"/etc/aliases\": source => \"puppet://server/module/aliases\" } # Rebuild the database, but only when the file changes exec { newaliases: path => [\"/usr/bin\", \"/usr/sbin\"], subscribe => File[\"/etc/aliases\"], refreshonly => true } Note that only `subscribe` and `notify` can trigger actions, not `require`, so it only makes sense to use `refreshonly` with `subscribe` or `notify`." newvalues(:true, :false) # We always fail this test, because we're only supposed to run # on refresh. def check(value) # We have to invert the values. if value == :true false else true end end end newcheck(:creates) do desc "A file that this command creates. If this parameter is provided, then the command will only be run if the specified file does not exist: exec { \"tar xf /my/tar/file.tar\": cwd => \"/var/tmp\", creates => \"/var/tmp/myfile\", path => [\"/usr/bin\", \"/usr/sbin\"] } " # FIXME if they try to set this and fail, then we should probably # fail the entire exec, right? validate do |files| files = [files] unless files.is_a? Array files.each do |file| self.fail("'creates' must be set to a fully qualified path") unless file unless file =~ %r{^#{File::SEPARATOR}} self.fail "'creates' files must be fully qualified." end end end # If the file exists, return false (i.e., don't run the command), # else return true def check(value) ! FileTest.exists?(value) end end newcheck(:unless) do desc "If this parameter is set, then this `exec` will run unless the command returns 0. For example: exec { \"/bin/echo root >> /usr/lib/cron/cron.allow\": path => \"/usr/bin:/usr/sbin:/bin\", unless => \"grep root /usr/lib/cron/cron.allow 2>/dev/null\" } This would add `root` to the cron.allow file (on Solaris) unless `grep` determines it's already there. Note that this command follows the same rules as the main command, which is to say that it must be fully qualified if the path is not set. " validate do |cmds| cmds = [cmds] unless cmds.is_a? Array cmds.each do |cmd| @resource.validatecmd(cmd) end end # Return true if the command does not return 0. def check(value) begin output, status = @resource.run(value, true) rescue Timeout::Error err "Check #{value.inspect} exceeded timeout" return false end status.exitstatus != 0 end end newcheck(:onlyif) do desc "If this parameter is set, then this `exec` will only run if the command returns 0. For example: exec { \"logrotate\": path => \"/usr/bin:/usr/sbin:/bin\", onlyif => \"test `du /var/log/messages | cut -f1` -gt 100000\" } This would run `logrotate` only if that test returned true. Note that this command follows the same rules as the main command, which is to say that it must be fully qualified if the path is not set. Also note that onlyif can take an array as its value, e.g.: onlyif => [\"test -f /tmp/file1\", \"test -f /tmp/file2\"] This will only run the exec if /all/ conditions in the array return true. " validate do |cmds| cmds = [cmds] unless cmds.is_a? Array cmds.each do |cmd| @resource.validatecmd(cmd) end end # Return true if the command returns 0. def check(value) begin output, status = @resource.run(value, true) rescue Timeout::Error err "Check #{value.inspect} exceeded timeout" return false end status.exitstatus == 0 end end # Exec names are not isomorphic with the objects. @isomorphic = false validate do validatecmd(self[:command]) end # FIXME exec should autorequire any exec that 'creates' our cwd autorequire(:file) do reqs = [] # Stick the cwd in there if we have it reqs << self[:cwd] if self[:cwd] self[:command].scan(/^(#{File::SEPARATOR}\S+)/) { |str| reqs << str } self[:command].scan(/^"([^"]+)"/) { |str| reqs << str } [:onlyif, :unless].each { |param| next unless tmp = self[param] tmp = [tmp] unless tmp.is_a? Array tmp.each do |line| # And search the command line for files, adding any we # find. This will also catch the command itself if it's # fully qualified. It might not be a bad idea to add # unqualified files, but, well, that's a bit more annoying # to do. reqs += line.scan(%r{(#{File::SEPARATOR}\S+)}) end } # For some reason, the += isn't causing a flattening reqs.flatten! reqs end autorequire(:user) do # Autorequire users if they are specified by name if user = self[:user] and user !~ /^\d+$/ user end end def self.instances [] end # Verify that we pass all of the checks. The argument determines whether # we skip the :refreshonly check, which is necessary because we now check # within refresh def check(refreshing = false) self.class.checks.each { |check| next if refreshing and check == :refreshonly if @parameters.include?(check) val = @parameters[check].value val = [val] unless val.is_a? Array val.each do |value| return false unless @parameters[check].check(value) end end } true end # Verify that we have the executable def checkexe(cmd) exe = extractexe(cmd) if self[:path] if Puppet.features.posix? and !File.exists?(exe) withenv :PATH => self[:path].join(File::PATH_SEPARATOR) do exe = which(exe) || raise(ArgumentError,"Could not find command '#{exe}'") end elsif Puppet.features.microsoft_windows? and !File.exists?(exe) self[:path].each do |path| [".exe", ".ps1", ".bat", ".com", ""].each do |extension| file = File.join(path, exe+extension) return if File.exists?(file) end end end end raise ArgumentError, "Could not find executable '#{exe}'" unless FileTest.exists?(exe) unless FileTest.executable?(exe) raise ArgumentError, "'#{exe}' is not executable" end end def output if self.property(:returns).nil? return nil else return self.property(:returns).output end end # Run the command, or optionally run a separately-specified command. def refresh if self.check(true) if cmd = self[:refresh] self.run(cmd) else self.property(:returns).sync end end end # Run a command. def run(command, check = false) output = nil status = nil dir = nil checkexe(command) if dir = self[:cwd] unless File.directory?(dir) if check dir = nil else self.fail "Working directory '#{dir}' does not exist" end end end dir ||= Dir.pwd if check debug "Executing check '#{command}'" else debug "Executing '#{command}'" end begin # Do our chdir Dir.chdir(dir) do environment = {} environment[:PATH] = self[:path].join(":") if self[:path] if envlist = self[:environment] envlist = [envlist] unless envlist.is_a? Array envlist.each do |setting| if setting =~ /^(\w+)=((.|\n)+)$/ name = $1 value = $2 if environment.include? name warning( "Overriding environment setting '#{name}' with '#{value}'" ) end environment[name] = value else warning "Cannot understand environment setting #{setting.inspect}" end end end withenv environment do Timeout::timeout(self[:timeout]) do output, status = Puppet::Util::SUIDManager.run_and_capture( [command], self[:user], self[:group] ) end # The shell returns 127 if the command is missing. if status.exitstatus == 127 raise ArgumentError, output end end end rescue Errno::ENOENT => detail self.fail detail.to_s end return output, status end def validatecmd(cmd) exe = extractexe(cmd) # if we're not fully qualified, require a path self.fail "'#{cmd}' is not qualified and no path was specified. Please qualify the command or specify a path." if File.expand_path(exe) != exe and self[:path].nil? end def extractexe(cmd) # easy case: command was quoted if cmd =~ /^"([^"]+)"/ $1 else cmd.split(/ /)[0] end end end end diff --git a/lib/puppet/type/file.rb b/lib/puppet/type/file.rb index 963b9e5dd..16b1f962d 100644 --- a/lib/puppet/type/file.rb +++ b/lib/puppet/type/file.rb @@ -1,791 +1,793 @@ require 'digest/md5' require 'cgi' require 'etc' require 'uri' require 'fileutils' require 'puppet/network/handler' require 'puppet/util/diff' require 'puppet/util/checksums' require 'puppet/network/client' require 'puppet/util/backups' Puppet::Type.newtype(:file) do include Puppet::Util::MethodHelper include Puppet::Util::Checksums include Puppet::Util::Backups @doc = "Manages local files, including setting ownership and permissions, creation of both files and directories, and retrieving entire files from remote servers. As Puppet matures, it expected that the `file` resource will be used less and less to manage content, and instead native resources will be used to do so. If you find that you are often copying files in from a central location, rather than using native resources, please contact Puppet Labs and we can hopefully work with you to develop a - native resource to support what you are doing." + native resource to support what you are doing. + + **Autorequires:** If Puppet is managing the user or group that owns a file, the file resource will autorequire them. If Puppet is managing any parent directories of a file, the file resource will autorequire them." def self.title_patterns [ [ /^(.*?)\/*\Z/m, [ [ :path, lambda{|x| x} ] ] ] ] end newparam(:path) do desc "The path to the file to manage. Must be fully qualified." isnamevar validate do |value| # accept various path syntaxes: lone slash, posix, win32, unc unless (Puppet.features.posix? and value =~ /^\//) or (Puppet.features.microsoft_windows? and (value =~ /^.:\// or value =~ /^\/\/[^\/]+\/[^\/]+/)) fail Puppet::Error, "File paths must be fully qualified, not '#{value}'" end end # convert the current path in an index into the collection and the last # path name. The aim is to use less storage for all common paths in a hierarchy munge do |value| path, name = File.split(value.gsub(/\/+/,'/')) { :index => Puppet::FileCollection.collection.index(path), :name => name } end # and the reverse unmunge do |value| basedir = Puppet::FileCollection.collection.path(value[:index]) # a lone slash as :name indicates a root dir on windows if value[:name] == '/' basedir else File.join( basedir, value[:name] ) end end end newparam(:backup) do desc "Whether files should be backed up before being replaced. The preferred method of backing files up is via a `filebucket`, which stores files by their MD5 sums and allows easy retrieval without littering directories with backups. You can specify a local filebucket or a network-accessible server-based filebucket by setting `backup => bucket-name`. Alternatively, if you specify any value that begins with a `.` (e.g., `.puppet-bak`), then Puppet will use copy the file in the same directory with that value as the extension of the backup. Setting `backup => false` disables all backups of the file in question. Puppet automatically creates a local filebucket named `puppet` and defaults to backing up there. To use a server-based filebucket, you must specify one in your configuration filebucket { main: server => puppet } The `puppet master` daemon creates a filebucket by default, so you can usually back up to your main server with this configuration. Once you've described the bucket in your configuration, you can use it in any file file { \"/my/file\": source => \"/path/in/nfs/or/something\", backup => main } This will back the file up to the central server. At this point, the benefits of using a filebucket are that you do not have backup files lying around on each of your machines, a given version of a file is only backed up once, and you can restore any given file manually, no matter how old. Eventually, transactional support will be able to automatically restore filebucketed files. " defaultto "puppet" munge do |value| # I don't really know how this is happening. value = value.shift if value.is_a?(Array) case value when false, "false", :false false when true, "true", ".puppet-bak", :true ".puppet-bak" when String value else self.fail "Invalid backup type #{value.inspect}" end end end newparam(:recurse) do desc "Whether and how deeply to do recursive management." newvalues(:true, :false, :inf, :remote, /^[0-9]+$/) # Replace the validation so that we allow numbers in # addition to string representations of them. validate { |arg| } munge do |value| newval = super(value) case newval when :true, :inf; true when :false; false when :remote; :remote when Integer, Fixnum, Bignum self.warning "Setting recursion depth with the recurse parameter is now deprecated, please use recurselimit" # recurse == 0 means no recursion return false if value == 0 resource[:recurselimit] = value true when /^\d+$/ self.warning "Setting recursion depth with the recurse parameter is now deprecated, please use recurselimit" value = Integer(value) # recurse == 0 means no recursion return false if value == 0 resource[:recurselimit] = value true else self.fail "Invalid recurse value #{value.inspect}" end end end newparam(:recurselimit) do desc "How deeply to do recursive management." newvalues(/^[0-9]+$/) munge do |value| newval = super(value) case newval when Integer, Fixnum, Bignum; value when /^\d+$/; Integer(value) else self.fail "Invalid recurselimit value #{value.inspect}" end end end newparam(:replace, :boolean => true) do desc "Whether or not to replace a file that is sourced but exists. This is useful for using file sources purely for initialization." newvalues(:true, :false) aliasvalue(:yes, :true) aliasvalue(:no, :false) defaultto :true end newparam(:force, :boolean => true) do desc "Force the file operation. Currently only used when replacing directories with links." newvalues(:true, :false) defaultto false end newparam(:ignore) do desc "A parameter which omits action on files matching specified patterns during recursion. Uses Ruby's builtin globbing engine, so shell metacharacters are fully supported, e.g. `[a-z]*`. Matches that would descend into the directory structure are ignored, e.g., `*/*`." validate do |value| unless value.is_a?(Array) or value.is_a?(String) or value == false self.devfail "Ignore must be a string or an Array" end end end newparam(:links) do desc "How to handle links during file actions. During file copying, `follow` will copy the target file instead of the link, `manage` will copy the link itself, and `ignore` will just pass it by. When not copying, `manage` and `ignore` behave equivalently (because you cannot really ignore links entirely during local recursion), and `follow` will manage the file to which the link points." newvalues(:follow, :manage) defaultto :manage end newparam(:purge, :boolean => true) do desc "Whether unmanaged files should be purged. If you have a filebucket configured the purged files will be uploaded, but if you do not, this will destroy data. Only use this option for generated files unless you really know what you are doing. This option only makes sense when recursively managing directories. Note that when using `purge` with `source`, Puppet will purge any files that are not on the remote system." defaultto :false newvalues(:true, :false) end newparam(:sourceselect) do desc "Whether to copy all valid sources, or just the first one. This parameter is only used in recursive copies; by default, the first valid source is the only one used as a recursive source, but if this parameter is set to `all`, then all valid sources will have all of their contents copied to the local host, and for sources that have the same file, the source earlier in the list will be used." defaultto :first newvalues(:first, :all) end # Autorequire any parent directories. autorequire(:file) do basedir = File.dirname(self[:path]) if basedir != self[:path] basedir else nil end end # Autorequire the owner and group of the file. {:user => :owner, :group => :group}.each do |type, property| autorequire(type) do if @parameters.include?(property) # The user/group property automatically converts to IDs next unless should = @parameters[property].shouldorig val = should[0] if val.is_a?(Integer) or val =~ /^\d+$/ nil else val end end end end CREATORS = [:content, :source, :target] SOURCE_ONLY_CHECKSUMS = [:none, :ctime, :mtime] validate do creator_count = 0 CREATORS.each do |param| creator_count += 1 if self.should(param) end creator_count += 1 if @parameters.include?(:source) self.fail "You cannot specify more than one of #{CREATORS.collect { |p| p.to_s}.join(", ")}" if creator_count > 1 self.fail "You cannot specify a remote recursion without a source" if !self[:source] and self[:recurse] == :remote self.fail "You cannot specify source when using checksum 'none'" if self[:checksum] == :none && !self[:source].nil? SOURCE_ONLY_CHECKSUMS.each do |checksum_type| self.fail "You cannot specify content when using checksum '#{checksum_type}'" if self[:checksum] == checksum_type && !self[:content].nil? end self.warning "Possible error: recurselimit is set but not recurse, no recursion will happen" if !self[:recurse] and self[:recurselimit] end def self.[](path) return nil unless path super(path.gsub(/\/+/, '/').sub(/\/$/, '')) end def self.instances(base = '/') return self.new(:name => base, :recurse => true, :recurselimit => 1, :audit => :all).recurse_local.values end @depthfirst = false # Determine the user to write files as. def asuser if self.should(:owner) and ! self.should(:owner).is_a?(Symbol) writeable = Puppet::Util::SUIDManager.asuser(self.should(:owner)) { FileTest.writable?(File.dirname(self[:path])) } # If the parent directory is writeable, then we execute # as the user in question. Otherwise we'll rely on # the 'owner' property to do things. asuser = self.should(:owner) if writeable end asuser end def bucket return @bucket if @bucket backup = self[:backup] return nil unless backup return nil if backup =~ /^\./ unless catalog or backup == "puppet" fail "Can not find filebucket for backups without a catalog" end unless catalog and filebucket = catalog.resource(:filebucket, backup) or backup == "puppet" fail "Could not find filebucket #{backup} specified in backup" end return default_bucket unless filebucket @bucket = filebucket.bucket @bucket end def default_bucket Puppet::Type.type(:filebucket).mkdefaultbucket.bucket end # Does the file currently exist? Just checks for whether # we have a stat def exist? stat ? true : false end # We have to do some extra finishing, to retrieve our bucket if # there is one. def finish # Look up our bucket, if there is one bucket super end # Create any children via recursion or whatever. def eval_generate return [] unless self.recurse? recurse #recurse.reject do |resource| # catalog.resource(:file, resource[:path]) #end.each do |child| # catalog.add_resource child # catalog.relationship_graph.add_edge self, child #end end def flush # We want to make sure we retrieve metadata anew on each transaction. @parameters.each do |name, param| param.flush if param.respond_to?(:flush) end @stat = nil end def initialize(hash) # Used for caching clients @clients = {} super # If they've specified a source, we get our 'should' values # from it. unless self[:ensure] if self[:target] self[:ensure] = :symlink elsif self[:content] self[:ensure] = :file end end @stat = nil end # Configure discovered resources to be purged. def mark_children_for_purging(children) children.each do |name, child| next if child[:source] child[:ensure] = :absent end end # Create a new file or directory object as a child to the current # object. def newchild(path) full_path = File.join(self[:path], path) # Add some new values to our original arguments -- these are the ones # set at initialization. We specifically want to exclude any param # values set by the :source property or any default values. # LAK:NOTE This is kind of silly, because the whole point here is that # the values set at initialization should live as long as the resource # but values set by default or by :source should only live for the transaction # or so. Unfortunately, we don't have a straightforward way to manage # the different lifetimes of this data, so we kludge it like this. # The right-side hash wins in the merge. options = @original_parameters.merge(:path => full_path).reject { |param, value| value.nil? } # These should never be passed to our children. [:parent, :ensure, :recurse, :recurselimit, :target, :alias, :source].each do |param| options.delete(param) if options.include?(param) end self.class.new(options) end # Files handle paths specially, because they just lengthen their # path names, rather than including the full parent's title each # time. def pathbuilder # We specifically need to call the method here, so it looks # up our parent in the catalog graph. if parent = parent() # We only need to behave specially when our parent is also # a file if parent.is_a?(self.class) # Remove the parent file name list = parent.pathbuilder list.pop # remove the parent's path info return list << self.ref else return super end else return [self.ref] end end # Should we be purging? def purge? @parameters.include?(:purge) and (self[:purge] == :true or self[:purge] == "true") end # Recursively generate a list of file resources, which will # be used to copy remote files, manage local files, and/or make links # to map to another directory. def recurse children = {} children = recurse_local if self[:recurse] != :remote if self[:target] recurse_link(children) elsif self[:source] recurse_remote(children) end # If we're purging resources, then delete any resource that isn't on the # remote system. mark_children_for_purging(children) if self.purge? result = children.values.sort { |a, b| a[:path] <=> b[:path] } remove_less_specific_files(result) end # This is to fix bug #2296, where two files recurse over the same # set of files. It's a rare case, and when it does happen you're # not likely to have many actual conflicts, which is good, because # this is a pretty inefficient implementation. def remove_less_specific_files(files) mypath = self[:path].split(File::Separator) other_paths = catalog.vertices. select { |r| r.is_a?(self.class) and r[:path] != self[:path] }. collect { |r| r[:path].split(File::Separator) }. select { |p| p[0,mypath.length] == mypath } return files if other_paths.empty? files.reject { |file| path = file[:path].split(File::Separator) other_paths.any? { |p| path[0,p.length] == p } } end # A simple method for determining whether we should be recursing. def recurse? return false unless @parameters.include?(:recurse) val = @parameters[:recurse].value !!(val and (val == true or val == :remote)) end # Recurse the target of the link. def recurse_link(children) perform_recursion(self[:target]).each do |meta| if meta.relative_path == "." self[:ensure] = :directory next end children[meta.relative_path] ||= newchild(meta.relative_path) if meta.ftype == "directory" children[meta.relative_path][:ensure] = :directory else children[meta.relative_path][:ensure] = :link children[meta.relative_path][:target] = meta.full_path end end children end # Recurse the file itself, returning a Metadata instance for every found file. def recurse_local result = perform_recursion(self[:path]) return {} unless result result.inject({}) do |hash, meta| next hash if meta.relative_path == "." hash[meta.relative_path] = newchild(meta.relative_path) hash end end # Recurse against our remote file. def recurse_remote(children) sourceselect = self[:sourceselect] total = self[:source].collect do |source| next unless result = perform_recursion(source) return if top = result.find { |r| r.relative_path == "." } and top.ftype != "directory" result.each { |data| data.source = "#{source}/#{data.relative_path}" } break result if result and ! result.empty? and sourceselect == :first result end.flatten # This only happens if we have sourceselect == :all unless sourceselect == :first found = [] total.reject! do |data| result = found.include?(data.relative_path) found << data.relative_path unless found.include?(data.relative_path) result end end total.each do |meta| if meta.relative_path == "." parameter(:source).metadata = meta next end children[meta.relative_path] ||= newchild(meta.relative_path) children[meta.relative_path][:source] = meta.source children[meta.relative_path][:checksum] = :md5 if meta.ftype == "file" children[meta.relative_path].parameter(:source).metadata = meta end children end def perform_recursion(path) Puppet::FileServing::Metadata.indirection.search( path, :links => self[:links], :recurse => (self[:recurse] == :remote ? true : self[:recurse]), :recurselimit => self[:recurselimit], :ignore => self[:ignore], :checksum_type => (self[:source] || self[:content]) ? self[:checksum] : :none ) end # Remove any existing data. This is only used when dealing with # links or directories. def remove_existing(should) return unless s = stat self.fail "Could not back up; will not replace" unless perform_backup unless should.to_s == "link" return if s.ftype.to_s == should.to_s end case s.ftype when "directory" if self[:force] == :true debug "Removing existing directory for replacement with #{should}" FileUtils.rmtree(self[:path]) else notice "Not removing directory; use 'force' to override" end when "link", "file" debug "Removing existing #{s.ftype} for replacement with #{should}" File.unlink(self[:path]) else self.fail "Could not back up files of type #{s.ftype}" end expire end def retrieve if source = parameter(:source) source.copy_source_values end super end # Set the checksum, from another property. There are multiple # properties that modify the contents of a file, and they need the # ability to make sure that the checksum value is in sync. def setchecksum(sum = nil) if @parameters.include? :checksum if sum @parameters[:checksum].checksum = sum else # If they didn't pass in a sum, then tell checksum to # figure it out. currentvalue = @parameters[:checksum].retrieve @parameters[:checksum].checksum = currentvalue end end end # Should this thing be a normal file? This is a relatively complex # way of determining whether we're trying to create a normal file, # and it's here so that the logic isn't visible in the content property. def should_be_file? return true if self[:ensure] == :file # I.e., it's set to something like "directory" return false if e = self[:ensure] and e != :present # The user doesn't really care, apparently if self[:ensure] == :present return true unless s = stat return(s.ftype == "file" ? true : false) end # If we've gotten here, then :ensure isn't set return true if self[:content] return true if stat and stat.ftype == "file" false end # Stat our file. Depending on the value of the 'links' attribute, we # use either 'stat' or 'lstat', and we expect the properties to use the # resulting stat object accordingly (mostly by testing the 'ftype' # value). cached_attr(:stat) do method = :stat # Files are the only types that support links if (self.class.name == :file and self[:links] != :follow) or self.class.name == :tidy method = :lstat end path = self[:path] begin File.send(method, self[:path]) rescue Errno::ENOENT => error return nil rescue Errno::EACCES => error warning "Could not stat; permission denied" return nil end end # We have to hack this just a little bit, because otherwise we'll get # an error when the target and the contents are created as properties on # the far side. def to_trans(retrieve = true) obj = super obj.delete(:target) if obj[:target] == :notlink obj end # Write out the file. Requires the property name for logging. # Write will be done by the content property, along with checksum computation def write(property) remove_existing(:file) use_temporary_file = write_temporary_file? if use_temporary_file path = "#{self[:path]}.puppettmp_#{rand(10000)}" path = "#{self[:path]}.puppettmp_#{rand(10000)}" while File.exists?(path) or File.symlink?(path) else path = self[:path] end mode = self.should(:mode) # might be nil umask = mode ? 000 : 022 mode_int = mode ? mode.to_i(8) : nil content_checksum = Puppet::Util.withumask(umask) { File.open(path, 'w', mode_int ) { |f| write_content(f) } } # And put our new file in place if use_temporary_file # This is only not true when our file is empty. begin fail_if_checksum_is_wrong(path, content_checksum) if validate_checksum? File.rename(path, self[:path]) rescue => detail fail "Could not rename temporary file #{path} to #{self[:path]}: #{detail}" ensure # Make sure the created file gets removed File.unlink(path) if FileTest.exists?(path) end end # make sure all of the modes are actually correct property_fix end private # Should we validate the checksum of the file we're writing? def validate_checksum? self[:checksum] !~ /time/ end # Make sure the file we wrote out is what we think it is. def fail_if_checksum_is_wrong(path, content_checksum) newsum = parameter(:checksum).sum_file(path) return if [:absent, nil, content_checksum].include?(newsum) self.fail "File written to disk did not match checksum; discarding changes (#{content_checksum} vs #{newsum})" end # write the current content. Note that if there is no content property # simply opening the file with 'w' as done in write is enough to truncate # or write an empty length file. def write_content(file) (content = property(:content)) && content.write(file) end private def write_temporary_file? # unfortunately we don't know the source file size before fetching it # so let's assume the file won't be empty (c = property(:content) and c.length) || (s = @parameters[:source] and 1) end # There are some cases where all of the work does not get done on # file creation/modification, so we have to do some extra checking. def property_fix properties.each do |thing| next unless [:mode, :owner, :group, :seluser, :selrole, :seltype, :selrange].include?(thing.name) # Make sure we get a new stat objct expire currentvalue = thing.retrieve thing.sync unless thing.safe_insync?(currentvalue) end end end # We put all of the properties in separate files, because there are so many # of them. The order these are loaded is important, because it determines # the order they are in the property lit. require 'puppet/type/file/checksum' require 'puppet/type/file/content' # can create the file require 'puppet/type/file/source' # can create the file require 'puppet/type/file/target' # creates a different type of file require 'puppet/type/file/ensure' # can create the file require 'puppet/type/file/owner' require 'puppet/type/file/group' require 'puppet/type/file/mode' require 'puppet/type/file/type' require 'puppet/type/file/selcontext' # SELinux file context require 'puppet/type/file/ctime' require 'puppet/type/file/mtime' diff --git a/lib/puppet/type/file/content.rb b/lib/puppet/type/file/content.rb index cf924f371..827183213 100755 --- a/lib/puppet/type/file/content.rb +++ b/lib/puppet/type/file/content.rb @@ -1,217 +1,221 @@ require 'net/http' require 'uri' require 'tempfile' require 'puppet/util/checksums' require 'puppet/network/http/api/v1' require 'puppet/network/http/compression' module Puppet Puppet::Type.type(:file).newproperty(:content) do include Puppet::Util::Diff include Puppet::Util::Checksums include Puppet::Network::HTTP::API::V1 include Puppet::Network::HTTP::Compression.module attr_reader :actual_content desc "Specify the contents of a file as a string. Newlines, tabs, and spaces can be specified using the escaped syntax (e.g., \\n for a newline). The primary purpose of this parameter is to provide a - kind of limited templating:: - - define resolve(nameserver1, nameserver2, domain, search) { - $str = \"search $search - domain $domain - nameserver $nameserver1 - nameserver $nameserver2 - \" - - file { \"/etc/resolv.conf\": - content => $str + kind of limited templating: + + define resolve(nameserver1, nameserver2, domain, search) { + $str = \"search $search + domain $domain + nameserver $nameserver1 + nameserver $nameserver2 + \" + + file { \"/etc/resolv.conf\": + content => $str + } } - } - This attribute is especially useful when used with - `PuppetTemplating templating`:trac:." + This attribute is especially useful when used with templating." # Store a checksum as the value, rather than the actual content. # Simplifies everything. munge do |value| if value == :absent value elsif checksum?(value) # XXX This is potentially dangerous because it means users can't write a file whose # entire contents are a plain checksum value else @actual_content = value resource.parameter(:checksum).sum(value) end end # Checksums need to invert how changes are printed. def change_to_s(currentvalue, newvalue) # Our "new" checksum value is provided by the source. if source = resource.parameter(:source) and tmp = source.checksum newvalue = tmp end if currentvalue == :absent return "defined content as '#{newvalue}'" elsif newvalue == :absent return "undefined content from '#{currentvalue}'" else return "content changed '#{currentvalue}' to '#{newvalue}'" end end def checksum_type if source = resource.parameter(:source) result = source.checksum else checksum = resource.parameter(:checksum) result = resource[:checksum] end if result =~ /^\{(\w+)\}.+/ return $1.to_sym else return result end end def length (actual_content and actual_content.length) || 0 end def content self.should end # Override this method to provide diffs if asked for. # Also, fix #872: when content is used, and replace is true, the file # should be insync when it exists def insync?(is) if resource.should_be_file? return false if is == :absent else return true end return true if ! @resource.replace? result = super if ! result and Puppet[:show_diff] write_temporarily do |path| print diff(@resource[:path], path) end end result end def retrieve return :absent unless stat = @resource.stat ftype = stat.ftype # Don't even try to manage the content on directories or links return nil if ["directory","link"].include?(ftype) begin resource.parameter(:checksum).sum_file(resource[:path]) rescue => detail raise Puppet::Error, "Could not read #{ftype} #{@resource.title}: #{detail}" end end # Make sure we're also managing the checksum property. def should=(value) @resource.newattr(:checksum) unless @resource.parameter(:checksum) super end # Just write our content out to disk. def sync return_event = @resource.stat ? :file_changed : :file_created # We're safe not testing for the 'source' if there's no 'should' # because we wouldn't have gotten this far if there weren't at least # one valid value somewhere. @resource.write(:content) return_event end def write_temporarily tempfile = Tempfile.new("puppet-file") tempfile.open write(tempfile) tempfile.close yield tempfile.path tempfile.delete end def write(file) resource.parameter(:checksum).sum_stream { |sum| each_chunk_from(actual_content || resource.parameter(:source)) { |chunk| sum << chunk file.print chunk } } end def self.standalone? Puppet.settings[:name] == "apply" end + # the content is munged so if it's a checksum source_or_content is nil + # unless the checksum indirectly comes from source def each_chunk_from(source_or_content) if source_or_content.is_a?(String) yield source_or_content - elsif source_or_content.nil? && resource.parameter(:ensure) && [:present, :file].include?(resource.parameter(:ensure).value) - yield '' - elsif source_or_content.nil? + elsif content_is_really_a_checksum? && source_or_content.nil? yield read_file_from_filebucket + elsif source_or_content.nil? + yield '' elsif self.class.standalone? yield source_or_content.content elsif source_or_content.local? chunk_file_from_disk(source_or_content) { |chunk| yield chunk } else chunk_file_from_source(source_or_content) { |chunk| yield chunk } end end private + def content_is_really_a_checksum? + checksum?(should) + end + def chunk_file_from_disk(source_or_content) File.open(source_or_content.full_path, "r") do |src| while chunk = src.read(8192) yield chunk end end end def chunk_file_from_source(source_or_content) request = Puppet::Indirector::Request.new(:file_content, :find, source_or_content.full_path.sub(/^\//,'')) connection = Puppet::Network::HttpPool.http_instance(source_or_content.server, source_or_content.port) connection.request_get(indirection2uri(request), add_accept_encoding({"Accept" => "raw"})) do |response| case response.code - when "404"; nil when /^2/; uncompress(response) { |uncompressor| response.read_body { |chunk| yield uncompressor.uncompress(chunk) } } else # Raise the http error if we didn't get a 'success' of some kind. message = "Error #{response.code} on SERVER: #{(response.body||'').empty? ? response.message : uncompress_body(response)}" raise Net::HTTPError.new(message, response) end end end def read_file_from_filebucket raise "Could not get filebucket from file" unless dipper = resource.bucket sum = should.sub(/\{\w+\}/, '') dipper.getfile(sum) rescue => detail fail "Could not retrieve content for #{should} from filebucket: #{detail}" end end end diff --git a/lib/puppet/type/file/ensure.rb b/lib/puppet/type/file/ensure.rb index 4a68551ee..99652ecc6 100755 --- a/lib/puppet/type/file/ensure.rb +++ b/lib/puppet/type/file/ensure.rb @@ -1,170 +1,164 @@ module Puppet Puppet::Type.type(:file).ensurable do require 'etc' desc "Whether to create files that don't currently exist. Possible values are *absent*, *present*, *file*, and *directory*. Specifying `present` will match any form of file existence, and if the file is missing will create an empty file. Specifying `absent` will delete the file (and directory if recurse => true). - Anything other than those values will be considered to be a symlink. - For instance, the following text creates a link: + Anything other than those values will create a symlink. In the interest of readability and clarity, you should use `ensure => link` and explicitly specify a + target; however, if a `target` attribute isn't provided, the value of the `ensure` + attribute will be used as the symlink target: - # Useful on solaris + # (Useful on Solaris) + # Less maintainable: file { \"/etc/inetd.conf\": - ensure => \"/etc/inet/inetd.conf\" + ensure => \"/etc/inet/inetd.conf\", } - You can make relative links: - - # Useful on solaris + # More maintainable: file { \"/etc/inetd.conf\": - ensure => \"inet/inetd.conf\" + ensure => link, + target => \"/etc/inet/inetd.conf\", } - - If you need to make a relative link to a file named the same - as one of the valid values, you must prefix it with `./` or - something similar. - - You can also make recursive symlinks, which will create a - directory structure that maps to the target directory, - with directories corresponding to each directory - and links corresponding to each file." + + These two declarations are equivalent." # Most 'ensure' properties have a default, but with files we, um, don't. nodefault newvalue(:absent) do File.unlink(@resource[:path]) end aliasvalue(:false, :absent) newvalue(:file, :event => :file_created) do # Make sure we're not managing the content some other way if property = @resource.property(:content) property.sync else @resource.write(:ensure) mode = @resource.should(:mode) end end #aliasvalue(:present, :file) newvalue(:present, :event => :file_created) do # Make a file if they want something, but this will match almost # anything. set_file end newvalue(:directory, :event => :directory_created) do mode = @resource.should(:mode) parent = File.dirname(@resource[:path]) unless FileTest.exists? parent raise Puppet::Error, "Cannot create #{@resource[:path]}; parent directory #{parent} does not exist" end if mode Puppet::Util.withumask(000) do Dir.mkdir(@resource[:path], mode.to_i(8)) end else Dir.mkdir(@resource[:path]) end @resource.send(:property_fix) return :directory_created end newvalue(:link, :event => :link_created) do fail "Cannot create a symlink without a target" unless property = resource.property(:target) property.retrieve property.mklink end # Symlinks. newvalue(/./) do # This code never gets executed. We need the regex to support # specifying it, but the work is done in the 'symlink' code block. end munge do |value| value = super(value) value,resource[:target] = :link,value unless value.is_a? Symbol resource[:links] = :manage if value == :link and resource[:links] != :follow value end def change_to_s(currentvalue, newvalue) return super unless newvalue.to_s == "file" return super unless property = @resource.property(:content) # We know that content is out of sync if we're here, because # it's essentially equivalent to 'ensure' in the transaction. if source = @resource.parameter(:source) should = source.checksum else should = property.should end if should == :absent is = property.retrieve else is = :absent end property.change_to_s(is, should) end # Check that we can actually create anything def check basedir = File.dirname(@resource[:path]) if ! FileTest.exists?(basedir) raise Puppet::Error, "Can not create #{@resource.title}; parent directory does not exist" elsif ! FileTest.directory?(basedir) raise Puppet::Error, "Can not create #{@resource.title}; #{dirname} is not a directory" end end # We have to treat :present specially, because it works with any # type of file. def insync?(currentvalue) unless currentvalue == :absent or resource.replace? return true end if self.should == :present return !(currentvalue.nil? or currentvalue == :absent) else return super(currentvalue) end end def retrieve if stat = @resource.stat(false) return stat.ftype.intern else if self.should == :false return :false else return :absent end end end def sync @resource.remove_existing(self.should) if self.should == :absent return :file_removed end event = super event end end end diff --git a/lib/puppet/type/file/selcontext.rb b/lib/puppet/type/file/selcontext.rb index a33c6a000..ea385eec0 100644 --- a/lib/puppet/type/file/selcontext.rb +++ b/lib/puppet/type/file/selcontext.rb @@ -1,103 +1,119 @@ # Manage SELinux context of files. # # This code actually manages three pieces of data in the context. # # [root@delenn files]# ls -dZ / # drwxr-xr-x root root system_u:object_r:root_t / # # The context of '/' here is 'system_u:object_r:root_t'. This is # three seperate fields: # # system_u is the user context # object_r is the role context # root_t is the type context # # All three of these fields are returned in a single string by the # output of the stat command, but set individually with the chcon # command. This allows the user to specify a subset of the three # values while leaving the others alone. # # See http://www.nsa.gov/selinux/ for complete docs on SELinux. module Puppet require 'puppet/util/selinux' class SELFileContext < Puppet::Property include Puppet::Util::SELinux def retrieve return :absent unless @resource.stat(false) context = self.get_selinux_current_context(@resource[:path]) parse_selinux_context(name, context) end def retrieve_default_context(property) + if @resource[:selinux_ignore_defaults] == :true + return nil + end + unless context = self.get_selinux_default_context(@resource[:path]) return nil end + property_default = self.parse_selinux_context(property, context) self.debug "Found #{property} default '#{property_default}' for #{@resource[:path]}" if not property_default.nil? property_default end def insync?(value) if not selinux_support? debug("SELinux bindings not found. Ignoring parameter.") return true end super end def sync self.set_selinux_context(@resource[:path], @should, name) :file_changed end end + Puppet::Type.type(:file).newparam(:selinux_ignore_defaults) do + desc "If this is set then Puppet will not ask SELinux (via matchpathcon) to + supply defaults for the SELinux attributes (seluser, selrole, + seltype, and selrange). In general, you should leave this set at its + default and only set it to true when you need Puppet to not try to fix + SELinux labels automatically." + newvalues(:true, :false) + + defaultto :false + end + Puppet::Type.type(:file).newproperty(:seluser, :parent => Puppet::SELFileContext) do desc "What the SELinux user component of the context of the file should be. Any valid SELinux user component is accepted. For example `user_u`. If not specified it defaults to the value returned by matchpathcon for the file, if any exists. Only valid on systems with SELinux support enabled." @event = :file_changed defaultto { self.retrieve_default_context(:seluser) } end Puppet::Type.type(:file).newproperty(:selrole, :parent => Puppet::SELFileContext) do desc "What the SELinux role component of the context of the file should be. Any valid SELinux role component is accepted. For example `role_r`. If not specified it defaults to the value returned by matchpathcon for the file, if any exists. Only valid on systems with SELinux support enabled." @event = :file_changed defaultto { self.retrieve_default_context(:selrole) } end Puppet::Type.type(:file).newproperty(:seltype, :parent => Puppet::SELFileContext) do desc "What the SELinux type component of the context of the file should be. Any valid SELinux type component is accepted. For example `tmp_t`. If not specified it defaults to the value returned by matchpathcon for the file, if any exists. Only valid on systems with SELinux support enabled." @event = :file_changed defaultto { self.retrieve_default_context(:seltype) } end Puppet::Type.type(:file).newproperty(:selrange, :parent => Puppet::SELFileContext) do desc "What the SELinux range component of the context of the file should be. Any valid SELinux range component is accepted. For example `s0` or `SystemHigh`. If not specified it defaults to the value returned by matchpathcon for the file, if any exists. Only valid on systems with SELinux support enabled and that have support for MCS (Multi-Category Security)." @event = :file_changed defaultto { self.retrieve_default_context(:selrange) } end end diff --git a/lib/puppet/type/file/source.rb b/lib/puppet/type/file/source.rb index ac06a26a1..d3b3a48eb 100755 --- a/lib/puppet/type/file/source.rb +++ b/lib/puppet/type/file/source.rb @@ -1,196 +1,182 @@ require 'puppet/file_serving/content' require 'puppet/file_serving/metadata' module Puppet # Copy files from a local or remote source. This state *only* does any work # when the remote file is an actual file; in that case, this state copies # the file down. If the remote file is a dir or a link or whatever, then # this state, during retrieval, modifies the appropriate other states # so that things get taken care of appropriately. Puppet::Type.type(:file).newparam(:source) do include Puppet::Util::Diff attr_accessor :source, :local desc "Copy a file over the current file. Uses `checksum` to determine when a file should be copied. Valid values are either fully qualified paths to files, or URIs. Currently supported URI types are *puppet* and *file*. This is one of the primary mechanisms for getting content into applications that Puppet does not directly support and is very useful for those configuration files that don't change much across sytems. For instance: class sendmail { file { \"/etc/mail/sendmail.cf\": source => \"puppet://server/modules/module_name/sendmail.cf\" } } You can also leave out the server name, in which case `puppet agent` will fill in the name of its configuration server and `puppet apply` will use the local filesystem. This makes it easy to use the same configuration in both local and centralized forms. Currently, only the `puppet` scheme is supported for source URL's. Puppet will connect to the file server running on `server` to retrieve the contents of the file. If the `server` part is empty, the behavior of the command-line interpreter (`puppet apply`) and the client demon (`puppet agent`) differs slightly: `apply` will look such a file up on the module path on the local host, whereas `agent` will connect to the puppet server that it received the manifest from. See the [fileserver configuration documentation](http://projects.puppetlabs.com/projects/puppet/wiki/File_Serving_Configuration) for information on how to configure and use file services within Puppet. If you specify multiple file sources for a file, then the first source that exists will be used. This allows you to specify what amount to search paths for files: file { \"/path/to/my/file\": source => [ \"/modules/nfs/files/file.$host\", \"/modules/nfs/files/file.$operatingsystem\", \"/modules/nfs/files/file\" ] } This will use the first found file as the source. You cannot currently copy links using this mechanism; set `links` to `follow` if any remote sources are links. " validate do |sources| sources = [sources] unless sources.is_a?(Array) sources.each do |source| begin uri = URI.parse(URI.escape(source)) rescue => detail self.fail "Could not understand source #{source}: #{detail}" end self.fail "Cannot use URLs of type '#{uri.scheme}' as source for fileserving" unless uri.scheme.nil? or %w{file puppet}.include?(uri.scheme) end end munge do |sources| sources = [sources] unless sources.is_a?(Array) sources.collect { |source| source.sub(/\/$/, '') } end def change_to_s(currentvalue, newvalue) # newvalue = "{md5}#{@metadata.checksum}" if @resource.property(:ensure).retrieve == :absent return "creating from source #{metadata.source} with contents #{metadata.checksum}" else return "replacing from source #{metadata.source} with contents #{metadata.checksum}" end end def checksum metadata && metadata.checksum end # Look up (if necessary) and return remote content. cached_attr(:content) do raise Puppet::DevError, "No source for content was stored with the metadata" unless metadata.source unless tmp = Puppet::FileServing::Content.indirection.find(metadata.source) fail "Could not find any content at %s" % metadata.source end tmp.content end # Copy the values from the source to the resource. Yay. def copy_source_values devfail "Somehow got asked to copy source values without any metadata" unless metadata # Take each of the stats and set them as states on the local file # if a value has not already been provided. [:owner, :mode, :group, :checksum].each do |metadata_method| param_name = (metadata_method == :checksum) ? :content : metadata_method next if metadata_method == :owner and !Puppet.features.root? next if metadata_method == :checksum and metadata.ftype == "directory" if resource[param_name].nil? or resource[param_name] == :absent resource[param_name] = metadata.send(metadata_method) end end if resource[:ensure] == :absent # We know all we need to elsif metadata.ftype != "link" resource[:ensure] = metadata.ftype elsif @resource[:links] == :follow resource[:ensure] = :present else resource[:ensure] = "link" resource[:target] = metadata.destination end end - def pinparams - [:mode, :type, :owner, :group, :content] - end - def found? ! (metadata.nil? or metadata.ftype.nil?) end # Provide, and retrieve if necessary, the metadata for this file. Fail # if we can't find data about this host, and fail if there are any # problems in our query. cached_attr(:metadata) do return nil unless value result = nil value.each do |source| begin if data = Puppet::FileServing::Metadata.indirection.find(source) result = data result.source = source break end rescue => detail fail detail, "Could not retrieve file metadata for #{source}: #{detail}" end end fail "Could not retrieve information from source(s) #{value.join(", ")}" unless result result end - # Make sure we're also checking the checksum - def value=(value) - super - - checks = (pinparams + [:ensure]) - checks.delete(:checksum) - - resource[:audit] = checks - end - def local? found? and uri and (uri.scheme || "file") == "file" end def full_path URI.unescape(uri.path) if found? and uri end def server (uri and uri.host) or Puppet.settings[:server] end def port (uri and uri.port) or Puppet.settings[:masterport] end private def uri @uri ||= URI.parse(URI.escape(metadata.source)) end end end diff --git a/lib/puppet/type/file/target.rb b/lib/puppet/type/file/target.rb index b9fe9213b..7d391e672 100644 --- a/lib/puppet/type/file/target.rb +++ b/lib/puppet/type/file/target.rb @@ -1,74 +1,87 @@ module Puppet Puppet::Type.type(:file).newproperty(:target) do desc "The target for creating a link. Currently, symlinks are the - only type supported." + only type supported. + + You can make relative links: + + # (Useful on Solaris) + file { \"/etc/inetd.conf\": + ensure => link, + target => \"inet/inetd.conf\", + } + + You can also make recursive symlinks, which will create a + directory structure that maps to the target directory, + with directories corresponding to each directory + and links corresponding to each file." newvalue(:notlink) do # We do nothing if the value is absent return :nochange end # Anything else, basically newvalue(/./) do @resource[:ensure] = :link if ! @resource.should(:ensure) # Only call mklink if ensure didn't call us in the first place. currentensure = @resource.property(:ensure).retrieve mklink if @resource.property(:ensure).safe_insync?(currentensure) end # Create our link. def mklink raise Puppet::Error, "Cannot symlink on Microsoft Windows" if Puppet.features.microsoft_windows? target = self.should # Clean up any existing objects. The argument is just for logging, # it doesn't determine what's removed. @resource.remove_existing(target) raise Puppet::Error, "Could not remove existing file" if FileTest.exists?(@resource[:path]) Dir.chdir(File.dirname(@resource[:path])) do Puppet::Util::SUIDManager.asuser(@resource.asuser) do mode = @resource.should(:mode) if mode Puppet::Util.withumask(000) do File.symlink(target, @resource[:path]) end else File.symlink(target, @resource[:path]) end end @resource.send(:property_fix) :link_created end end def insync?(currentvalue) if [:nochange, :notlink].include?(self.should) or @resource.recurse? return true elsif ! @resource.replace? and File.exists?(@resource[:path]) return true else return super(currentvalue) end end def retrieve if stat = @resource.stat if stat.ftype == "link" return File.readlink(@resource[:path]) else return :notlink end else return :absent end end end end diff --git a/lib/puppet/type/k5login.rb b/lib/puppet/type/k5login.rb index a343e9e5c..eac142ff7 100644 --- a/lib/puppet/type/k5login.rb +++ b/lib/puppet/type/k5login.rb @@ -1,87 +1,85 @@ -# $Id: k5login.rb 2468 2007-08-07 23:30:20Z digant $ -# # Plug-in type for handling k5login files Puppet::Type.newtype(:k5login) do @doc = "Manage the `.k5login` file for a user. Specify the full path to the `.k5login` file as the name and an array of principals as the property principals." ensurable # Principals that should exist in the file newproperty(:principals, :array_matching => :all) do desc "The principals present in the `.k5login` file." end # The path/name of the k5login file newparam(:path) do isnamevar desc "The path to the file to manage. Must be fully qualified." validate do |value| unless value =~ /^#{File::SEPARATOR}/ raise Puppet::Error, "File paths must be fully qualified" end end end # To manage the mode of the file newproperty(:mode) do desc "Manage the k5login file's mode" defaultto { "644" } end provide(:k5login) do desc "The k5login provider is the only provider for the k5login type." # Does this file exist? def exists? File.exists?(@resource[:name]) end # create the file def create write(@resource.should(:principals)) should_mode = @resource.should(:mode) unless self.mode == should_mode self.mode = should_mode end end # remove the file def destroy File.unlink(@resource[:name]) end # Return the principals def principals(dummy_argument=:work_arround_for_ruby_GC_bug) if File.exists?(@resource[:name]) File.readlines(@resource[:name]).collect { |line| line.chomp } else :absent end end # Write the principals out to the k5login file def principals=(value) write(value) end # Return the mode as an octal string, not as an integer def mode "%o" % (File.stat(@resource[:name]).mode & 007777) end # Set the file mode, converting from a string to an integer. def mode=(value) File.chmod(Integer("0#{value}"), @resource[:name]) end private def write(value) File.open(@resource[:name], "w") { |f| f.puts value.join("\n") } end end end diff --git a/lib/puppet/type/macauthorization.rb b/lib/puppet/type/macauthorization.rb index ef6fbb6c1..e89aa7c89 100644 --- a/lib/puppet/type/macauthorization.rb +++ b/lib/puppet/type/macauthorization.rb @@ -1,163 +1,166 @@ Puppet::Type.newtype(:macauthorization) do @doc = "Manage the Mac OS X authorization database. - See the [Apple developer site](http://developer.apple.com/documentation/Security/Conceptual/Security_Overview/Security_Services/chapter_4_section_5.html) for more information." + See the [Apple developer site](http://developer.apple.com/documentation/Security/Conceptual/Security_Overview/Security_Services/chapter_4_section_5.html) for more information. + + **Autorequires:** If Puppet is managing the `/etc/authorization` file, each + macauthorization resource will autorequire it." ensurable autorequire(:file) do ["/etc/authorization"] end def munge_boolean(value) case value when true, "true", :true :true when false, "false", :false :false else fail("munge_boolean only takes booleans") end end def munge_integer(value) Integer(value) rescue ArgumentError fail("munge_integer only takes integers") end newparam(:name) do desc "The name of the right or rule to be managed. Corresponds to 'key' in Authorization Services. The key is the name of a rule. A key uses the same naming conventions as a right. The Security Server uses a rule’s key to match the rule with a right. Wildcard keys end with a ‘.’. The generic rule has an empty key value. Any rights that do not match a specific rule use the generic rule." isnamevar end newproperty(:auth_type) do desc "type - can be a 'right' or a 'rule'. 'comment' has not yet been implemented." newvalue(:right) newvalue(:rule) # newvalue(:comment) # not yet implemented. end newproperty(:allow_root, :boolean => true) do desc "Corresponds to 'allow-root' in the authorization store, renamed due to hyphens being problematic. Specifies whether a right should be allowed automatically if the requesting process is running with uid == 0. AuthorizationServices defaults this attribute to false if not specified" newvalue(:true) newvalue(:false) munge do |value| @resource.munge_boolean(value) end end newproperty(:authenticate_user, :boolean => true) do desc "Corresponds to 'authenticate-user' in the authorization store, renamed due to hyphens being problematic." newvalue(:true) newvalue(:false) munge do |value| @resource.munge_boolean(value) end end newproperty(:auth_class) do desc "Corresponds to 'class' in the authorization store, renamed due to 'class' being a reserved word." newvalue(:user) newvalue(:'evaluate-mechanisms') newvalue(:allow) newvalue(:deny) newvalue(:rule) end newproperty(:comment) do desc "The 'comment' attribute for authorization resources." end newproperty(:group) do desc "The user must authenticate as a member of this group. This attribute can be set to any one group." end newproperty(:k_of_n) do desc "k-of-n describes how large a subset of rule mechanisms must succeed for successful authentication. If there are 'n' mechanisms, then 'k' (the integer value of this parameter) mechanisms must succeed. The most common setting for this parameter is '1'. If k-of-n is not set, then 'n-of-n' mechanisms must succeed." munge do |value| @resource.munge_integer(value) end end newproperty(:mechanisms, :array_matching => :all) do desc "an array of suitable mechanisms." end newproperty(:rule, :array_matching => :all) do desc "The rule(s) that this right refers to." end newproperty(:session_owner, :boolean => true) do desc "Corresponds to 'session-owner' in the authorization store, renamed due to hyphens being problematic. Whether the session owner automatically matches this rule or right." newvalue(:true) newvalue(:false) munge do |value| @resource.munge_boolean(value) end end newproperty(:shared, :boolean => true) do desc "If this is set to true, then the Security Server marks the credentials used to gain this right as shared. The Security Server may use any shared credentials to authorize this right. For maximum security, set sharing to false so credentials stored by the Security Server for one application may not be used by another application." newvalue(:true) newvalue(:false) munge do |value| @resource.munge_boolean(value) end end newproperty(:timeout) do desc "The credential used by this rule expires in the specified number of seconds. For maximum security where the user must authenticate every time, set the timeout to 0. For minimum security, remove the timeout attribute so the user authenticates only once per session." munge do |value| @resource.munge_integer(value) end end newproperty(:tries) do desc "The number of tries allowed." munge do |value| @resource.munge_integer(value) end end end diff --git a/lib/puppet/type/mcx.rb b/lib/puppet/type/mcx.rb index 4f0a6c3c5..07c9348dd 100644 --- a/lib/puppet/type/mcx.rb +++ b/lib/puppet/type/mcx.rb @@ -1,115 +1,118 @@ #-- # Copyright (C) 2008 Jeffrey J McCune. # This program and entire repository is free software; you can # redistribute it and/or modify it under the terms of the GNU # General Public License as published by the Free Software # Foundation; either version 2 of the License, or any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # Author: Jeff McCune Puppet::Type.newtype(:mcx) do @doc = "MCX object management using DirectoryService on OS X. The default provider of this type merely manages the XML plist as reported by the dscl -mcxexport command. This is similar to the content property of the file type in Puppet. The recommended method of using this type is to use Work Group Manager to manage users and groups on the local computer, record the resulting -puppet manifest using the command 'ralsh mcx' then deploying this +puppet manifest using the command `puppet resource mcx`, then deploy it to other machines. + +**Autorequires:** If Puppet is managing the user, group, or computer that these +MCX settings refer to, the MCX resource will autorequire that user, group, or computer. " feature :manages_content, \ "The provider can manage MCXSettings as a string.", :methods => [:content, :content=] ensurable do desc "Create or remove the MCX setting." newvalue(:present) do provider.create end newvalue(:absent) do provider.destroy end end newparam(:name) do desc "The name of the resource being managed. The default naming convention follows Directory Service paths: /Computers/localhost /Groups/admin /Users/localadmin The `ds_type` and `ds_name` type parameters are not necessary if the default naming convention is followed." isnamevar end newparam(:ds_type) do desc "The DirectoryService type this MCX setting attaches to." newvalues(:user, :group, :computer, :computerlist) end newparam(:ds_name) do desc "The name to attach the MCX Setting to. e.g. 'localhost' when ds_type => computer. This setting is not required, as it may be parsed so long as the resource name is parseable. e.g. /Groups/admin where 'group' is the dstype." end newproperty(:content, :required_features => :manages_content) do desc "The XML Plist. The value of MCXSettings in DirectoryService. This is the standard output from the system command: dscl localhost -mcxexport /Local/Default//ds_name Note that `ds_type` is capitalized and plural in the dscl command." end # JJM Yes, this is not DRY at all. Because of the code blocks # autorequire must be done this way. I think. def setup_autorequire(type) # value returns a Symbol name = value(:name) ds_type = value(:ds_type) ds_name = value(:ds_name) if ds_type == type rval = [ ds_name.to_s ] else rval = [ ] end rval end autorequire(:user) do setup_autorequire(:user) end autorequire(:group) do setup_autorequire(:group) end autorequire(:computer) do setup_autorequire(:computer) end end diff --git a/lib/puppet/type/mount.rb b/lib/puppet/type/mount.rb index 915bb8e6c..5b8c5ca58 100755 --- a/lib/puppet/type/mount.rb +++ b/lib/puppet/type/mount.rb @@ -1,224 +1,240 @@ module Puppet # We want the mount to refresh when it changes. newtype(:mount, :self_refresh => true) do @doc = "Manages mounted filesystems, including putting mount information into the mount table. The actual behavior depends on the value of the 'ensure' parameter. Note that if a `mount` receives an event from another resource, it will try to remount the filesystems if `ensure` is set to `mounted`." feature :refreshable, "The provider can remount the filesystem.", :methods => [:remount] # Use the normal parent class, because we actually want to # call code when sync is called. newproperty(:ensure) do desc "Control what to do with this mount. Set this attribute to `umounted` to make sure the filesystem is in the filesystem table but not mounted (if the filesystem is currently mounted, it will be unmounted). Set it to `absent` to unmount (if necessary) and remove the filesystem from the fstab. Set to `mounted` to add it to the fstab and mount it. Set to `present` to add to fstab but not change mount/unmount status" + # IS -> SHOULD In Sync Action + # ghost -> present NO create + # absent -> present NO create + # (mounted -> present YES) + # (unmounted -> present YES) newvalue(:defined) do provider.create return :mount_created end aliasvalue :present, :defined + # IS -> SHOULD In Sync Action + # ghost -> unmounted NO create, unmount + # absent -> unmounted NO create + # mounted -> unmounted NO unmount newvalue(:unmounted) do - if provider.mounted? - syncothers + case self.retrieve + when :ghost # (not in fstab but mounted) + provider.create + @resource.flush provider.unmount return :mount_unmounted - else + when nil, :absent # (not in fstab and not mounted) provider.create return :mount_created + when :mounted # (in fstab and mounted) + provider.unmount + syncothers # I guess it's more likely that the mount was originally mounted with + # the wrong attributes so I sync AFTER the umount + return :mount_unmounted + else + raise Puppet::Error, "Unexpected change from #{current_value} to unmounted}" end end + # IS -> SHOULD In Sync Action + # ghost -> absent NO unmount + # mounted -> absent NO provider.destroy AND unmount + # unmounted -> absent NO provider.destroy newvalue(:absent, :event => :mount_deleted) do + current_value = self.retrieve provider.unmount if provider.mounted? - - provider.destroy + provider.destroy unless current_value == :ghost end + # IS -> SHOULD In Sync Action + # ghost -> mounted NO provider.create + # absent -> mounted NO provider.create AND mount + # unmounted -> mounted NO mount newvalue(:mounted, :event => :mount_mounted) do # Create the mount point if it does not already exist. current_value = self.retrieve - provider.create if current_value.nil? or current_value == :absent + currently_mounted = provider.mounted? + provider.create if [nil, :absent, :ghost].include?(current_value) syncothers # The fs can be already mounted if it was absent but mounted - provider.mount unless provider.mounted? + provider.property_hash[:needs_mount] = true unless currently_mounted end + # insync: mounted -> present + # unmounted -> present def insync?(is) - if should == :defined and is != :absent + if should == :defined and [:mounted,:unmounted].include?(is) true else super end end - def retrieve - # We need to special case :mounted; if we're absent, we still - # want - curval = super() - if curval == :absent - return :absent - elsif provider.mounted? - return :mounted - else - return :unmounted - end - end - def syncothers # We have to flush any changes to disk. currentvalues = @resource.retrieve_resource # Determine if there are any out-of-sync properties. oos = @resource.send(:properties).find_all do |prop| unless currentvalues.include?(prop) raise Puppet::DevError, "Parent has property %s but it doesn't appear in the current values", [prop.name] end if prop.name == :ensure false else ! prop.safe_insync?(currentvalues[prop]) end end.each { |prop| prop.sync }.length @resource.flush if oos > 0 end end newproperty(:device) do desc "The device providing the mount. This can be whatever device is supporting by the mount, including network devices or devices specified by UUID rather than device path, depending on the operating system." end # Solaris specifies two devices, not just one. newproperty(:blockdevice) do desc "The device to fsck. This is property is only valid on Solaris, and in most cases will default to the correct value." # Default to the device but with "dsk" replaced with "rdsk". defaultto do if Facter["operatingsystem"].value == "Solaris" device = @resource.value(:device) if device =~ %r{/dsk/} device.sub(%r{/dsk/}, "/rdsk/") else nil end else nil end end end newproperty(:fstype) do desc "The mount type. Valid values depend on the operating system. This is a required option." end newproperty(:options) do desc "Mount options for the mounts, as they would appear in the fstab." end newproperty(:pass) do desc "The pass in which the mount is checked." defaultto { 0 if @resource.managed? } end newproperty(:atboot) do desc "Whether to mount the mount at boot. Not all platforms support this." end newproperty(:dump) do desc "Whether to dump the mount. Not all platform support this. Valid values are `1` or `0`. or `2` on FreeBSD, Default is `0`." if Facter["operatingsystem"].value == "FreeBSD" newvalue(%r{(0|1|2)}) else newvalue(%r{(0|1)}) end newvalue(%r{(0|1)}) defaultto { 0 if @resource.managed? } end newproperty(:target) do desc "The file in which to store the mount table. Only used by those providers that write to disk." defaultto { if @resource.class.defaultprovider.ancestors.include?(Puppet::Provider::ParsedFile) @resource.class.defaultprovider.default_target else nil end } end newparam(:name) do desc "The mount path for the mount." isnamevar end newparam(:path) do desc "The deprecated name for the mount point. Please use `name` now." def value=(value) warning "'path' is deprecated for mounts. Please use 'name'." @resource[:name] = value super end end newparam(:remounts) do desc "Whether the mount can be remounted `mount -o remount`. If this is false, then the filesystem will be unmounted and remounted manually, which is prone to failure." newvalues(:true, :false) defaultto do case Facter.value(:operatingsystem) when "FreeBSD", "Darwin", "AIX" false else true end end end def refresh # Only remount if we're supposed to be mounted. - provider.remount if self.should(:fstype) != "swap" and self.should(:ensure) == :mounted + provider.remount if self.should(:fstype) != "swap" and provider.mounted? end def value(name) name = symbolize(name) ret = nil if property = @parameters[name] return property.value end end end end diff --git a/lib/puppet/type/package.rb b/lib/puppet/type/package.rb index d73d90dff..1222a5319 100644 --- a/lib/puppet/type/package.rb +++ b/lib/puppet/type/package.rb @@ -1,319 +1,323 @@ # Define the different packaging systems. Each package system is implemented # in a module, which then gets used to individually extend each package object. # This allows packages to exist on the same machine using different packaging # systems. module Puppet newtype(:package) do @doc = "Manage packages. There is a basic dichotomy in package support right now: Some package types (e.g., yum and apt) can retrieve their own package files, while others (e.g., rpm and sun) cannot. For those package formats that cannot retrieve their own files, you can use the `source` parameter to point to the correct file. Puppet will automatically guess the packaging format that you are using based on the platform you are on, but you can override it using the `provider` parameter; each provider defines what it requires in order to function, and you must meet those requirements - to use a given provider." + to use a given provider. + + **Autorequires:** If Puppet is managing the files specified as a package's + `adminfile`, `responsefile`, or `source`, the package resource will autorequire + those files." feature :installable, "The provider can install packages.", :methods => [:install] feature :uninstallable, "The provider can uninstall packages.", :methods => [:uninstall] feature :upgradeable, "The provider can upgrade to the latest version of a package. This feature is used by specifying `latest` as the desired value for the package.", :methods => [:update, :latest] feature :purgeable, "The provider can purge packages. This generally means that all traces of the package are removed, including existing configuration files. This feature is thus destructive and should be used with the utmost care.", :methods => [:purge] feature :versionable, "The provider is capable of interrogating the package database for installed version(s), and can select which out of a set of available versions of a package to install if asked." feature :holdable, "The provider is capable of placing packages on hold such that they are not automatically upgraded as a result of other package dependencies unless explicit action is taken by a user or another package. Held is considered a superset of installed.", :methods => [:hold] ensurable do desc "What state the package should be in. *latest* only makes sense for those packaging formats that can retrieve new packages on their own and will throw an error on those that cannot. For those packaging systems that allow you to specify package versions, specify them here. Similarly, *purged* is only useful for packaging systems that support the notion of managing configuration files separately from 'normal' system files." attr_accessor :latest newvalue(:present, :event => :package_installed) do provider.install end newvalue(:absent, :event => :package_removed) do provider.uninstall end newvalue(:purged, :event => :package_purged, :required_features => :purgeable) do provider.purge end newvalue(:held, :event => :package_held, :required_features => :holdable) do provider.hold end # Alias the 'present' value. aliasvalue(:installed, :present) newvalue(:latest, :required_features => :upgradeable) do # Because yum always exits with a 0 exit code, there's a retrieve # in the "install" method. So, check the current state now, # to compare against later. current = self.retrieve begin provider.update rescue => detail self.fail "Could not update: #{detail}" end if current == :absent :package_installed else :package_changed end end newvalue(/./, :required_features => :versionable) do begin provider.install rescue => detail self.fail "Could not update: #{detail}" end if self.retrieve == :absent :package_installed else :package_changed end end defaultto :installed # Override the parent method, because we've got all kinds of # funky definitions of 'in sync'. def insync?(is) @latest ||= nil @lateststamp ||= (Time.now.to_i - 1000) # Iterate across all of the should values, and see how they # turn out. @should.each { |should| case should when :present return true unless [:absent, :purged, :held].include?(is) when :latest # Short-circuit packages that are not present return false if is == :absent or is == :purged # Don't run 'latest' more than about every 5 minutes if @latest and ((Time.now.to_i - @lateststamp) / 60) < 5 #self.debug "Skipping latest check" else begin @latest = provider.latest @lateststamp = Time.now.to_i rescue => detail error = Puppet::Error.new("Could not get latest version: #{detail}") error.set_backtrace(detail.backtrace) raise error end end case is when @latest return true when :present # This will only happen on retarded packaging systems # that can't query versions. return true else self.debug "#{@resource.name} #{is.inspect} is installed, latest is #{@latest.inspect}" end when :absent return true if is == :absent or is == :purged when :purged return true if is == :purged when is return true end } false end # This retrieves the current state. LAK: I think this method is unused. def retrieve provider.properties[:ensure] end # Provide a bit more information when logging upgrades. def should_to_s(newvalue = @should) if @latest @latest.to_s else super(newvalue) end end end newparam(:name) do desc "The package name. This is the name that the packaging system uses internally, which is sometimes (especially on Solaris) a name that is basically useless to humans. If you want to abstract package installation, then you can use aliases to provide a common name to packages: # In the 'openssl' class $ssl = $operatingsystem ? { solaris => SMCossl, default => openssl } # It is not an error to set an alias to the same value as the # object name. package { $ssl: ensure => installed, alias => openssl } . etc. . $ssh = $operatingsystem ? { solaris => SMCossh, default => openssh } # Use the alias to specify a dependency, rather than # having another selector to figure it out again. package { $ssh: ensure => installed, alias => openssh, require => Package[openssl] } " isnamevar end newparam(:source) do desc "Where to find the actual package. This must be a local file (or on a network file system) or a URL that your specific packaging type understands; Puppet will not retrieve files for you." end newparam(:instance) do desc "A read-only parameter set by the package." end newparam(:status) do desc "A read-only parameter set by the package." end newparam(:type) do desc "Deprecated form of `provider`." munge do |value| warning "'type' is deprecated; use 'provider' instead" @resource[:provider] = value @resource[:provider] end end newparam(:adminfile) do desc "A file containing package defaults for installing packages. This is currently only used on Solaris. The value will be validated according to system rules, which in the case of Solaris means that it should either be a fully qualified path or it should be in `/var/sadm/install/admin`." end newparam(:responsefile) do desc "A file containing any necessary answers to questions asked by the package. This is currently used on Solaris and Debian. The value will be validated according to system rules, but it should generally be a fully qualified path." end newparam(:configfiles) do desc "Whether configfiles should be kept or replaced. Most packages types do not support this parameter." defaultto :keep newvalues(:keep, :replace) end newparam(:category) do desc "A read-only parameter set by the package." end newparam(:platform) do desc "A read-only parameter set by the package." end newparam(:root) do desc "A read-only parameter set by the package." end newparam(:vendor) do desc "A read-only parameter set by the package." end newparam(:description) do desc "A read-only parameter set by the package." end newparam(:allowcdrom) do desc "Tells apt to allow cdrom sources in the sources.list file. Normally apt will bail if you try this." newvalues(:true, :false) end newparam(:flavor) do desc "Newer versions of OpenBSD support 'flavors', which are further specifications for which type of package you want." end autorequire(:file) do autos = [] [:responsefile, :adminfile].each { |param| if val = self[param] autos << val end } if source = self[:source] if source =~ /^#{File::SEPARATOR}/ autos << source end end autos end # This only exists for testing. def clear if obj = @parameters[:ensure] obj.latest = nil end end # The 'query' method returns a hash of info if the package # exists and returns nil if it does not. def exists? @provider.get(:ensure) != :absent end end end diff --git a/lib/puppet/type/schedule.rb b/lib/puppet/type/schedule.rb index 82f17e533..5fb008f6f 100755 --- a/lib/puppet/type/schedule.rb +++ b/lib/puppet/type/schedule.rb @@ -1,349 +1,349 @@ module Puppet newtype(:schedule) do @doc = "Defined schedules for Puppet. The important thing to understand about how schedules are currently implemented in Puppet is that they can only be used to stop a resource from being applied, they never guarantee that it is applied. Every time Puppet applies its configuration, it will collect the list of resources whose schedule does not eliminate them from running right then, but there is currently no system in place to guarantee that a given resource runs at a given time. If you specify a very restrictive schedule and Puppet happens to run at a time within that schedule, then the resources will get applied; otherwise, that work may never get done. Thus, it behooves you to use wider scheduling (e.g., over a couple of hours) combined with periods and repetitions. For instance, if you wanted to restrict certain resources to only running once, between the hours of two and 4 AM, then you would use this schedule: - schedule { maint: - range => \"2 - 4\", - period => daily, - repeat => 1 - } + schedule { maint: + range => \"2 - 4\", + period => daily, + repeat => 1 + } With this schedule, the first time that Puppet runs between 2 and 4 AM, all resources with this schedule will get applied, but they won't get applied again between 2 and 4 because they will have already run once that day, and they won't get applied outside that schedule because they will be outside the scheduled range. Puppet automatically creates a schedule for each valid period with the same name as that period (e.g., hourly and daily). Additionally, a schedule named *puppet* is created and used as the default, with the following attributes: - schedule { puppet: - period => hourly, - repeat => 2 - } + schedule { puppet: + period => hourly, + repeat => 2 + } This will cause resources to be applied every 30 minutes by default. " newparam(:name) do desc "The name of the schedule. This name is used to retrieve the schedule when assigning it to an object: - schedule { daily: - period => daily, - range => \"2 - 4\", - } - - exec { \"/usr/bin/apt-get update\": - schedule => daily - } + schedule { daily: + period => daily, + range => \"2 - 4\", + } + + exec { \"/usr/bin/apt-get update\": + schedule => daily + } " isnamevar end newparam(:range) do desc "The earliest and latest that a resource can be applied. This is always a range within a 24 hour period, and hours must be specified in numbers between 0 and 23, inclusive. Minutes and seconds can be provided, using the normal colon as a separator. For instance: - schedule { maintenance: - range => \"1:30 - 4:30\" - } + schedule { maintenance: + range => \"1:30 - 4:30\" + } This is mostly useful for restricting certain resources to being applied in maintenance windows or during off-peak hours." # This is lame; properties all use arrays as values, but parameters don't. # That's going to hurt eventually. validate do |values| values = [values] unless values.is_a?(Array) values.each { |value| unless value.is_a?(String) and value =~ /\d+(:\d+){0,2}\s*-\s*\d+(:\d+){0,2}/ self.fail "Invalid range value '#{value}'" end } end munge do |values| values = [values] unless values.is_a?(Array) ret = [] values.each { |value| range = [] # Split each range value into a hour, minute, second triad value.split(/\s*-\s*/).each { |val| # Add the values as an array. range << val.split(":").collect { |n| n.to_i } } self.fail "Invalid range #{value}" if range.length != 2 # Make sure the hours are valid [range[0][0], range[1][0]].each do |n| raise ArgumentError, "Invalid hour '#{n}'" if n < 0 or n > 23 end [range[0][1], range[1][1]].each do |n| raise ArgumentError, "Invalid minute '#{n}'" if n and (n < 0 or n > 59) end if range[0][0] > range[1][0] self.fail(("Invalid range #{value}; ") + "ranges cannot span days." ) end ret << range } # Now our array of arrays ret end def match?(previous, now) # The lowest-level array is of the hour, minute, second triad # then it's an array of two of those, to present the limits # then it's array of those ranges @value = [@value] unless @value[0][0].is_a?(Array) @value.each do |value| limits = value.collect do |range| ary = [now.year, now.month, now.day, range[0]] if range[1] ary << range[1] else ary << now.min end if range[2] ary << range[2] else ary << now.sec end time = Time.local(*ary) unless time.hour == range[0] self.devfail( "Incorrectly converted time: #{time}: #{time.hour} vs #{range[0]}" ) end time end unless limits[0] < limits[1] self.info( "Assuming upper limit should be that time the next day" ) ary = limits[1].to_a ary[3] += 1 limits[1] = Time.local(*ary) #self.devfail("Lower limit is above higher limit: %s" % # limits.inspect #) end #self.info limits.inspect #self.notice now return now.between?(*limits) end # Else, return false, since our current time isn't between # any valid times false end end newparam(:periodmatch) do desc "Whether periods should be matched by number (e.g., the two times are in the same hour) or by distance (e.g., the two times are 60 minutes apart)." newvalues(:number, :distance) defaultto :distance end newparam(:period) do desc "The period of repetition for a resource. Choose from among a fixed list of *hourly*, *daily*, *weekly*, and *monthly*. The default is for a resource to get applied every time that Puppet runs, whatever that period is. Note that the period defines how often a given resource will get applied but not when; if you would like to restrict the hours that a given resource can be applied (e.g., only at night during a maintenance window) then use the `range` attribute. If the provided periods are not sufficient, you can provide a value to the *repeat* attribute, which will cause Puppet to schedule the affected resources evenly in the period the specified number of times. Take this schedule: schedule { veryoften: period => hourly, repeat => 6 } This can cause Puppet to apply that resource up to every 10 minutes. At the moment, Puppet cannot guarantee that level of repetition; that is, it can run up to every 10 minutes, but internal factors might prevent it from actually running that often (e.g., long-running Puppet runs will squash conflictingly scheduled runs). See the `periodmatch` attribute for tuning whether to match times by their distance apart or by their specific value." newvalues(:hourly, :daily, :weekly, :monthly, :never) @@scale = { :hourly => 3600, :daily => 86400, :weekly => 604800, :monthly => 2592000 } @@methods = { :hourly => :hour, :daily => :day, :monthly => :month, :weekly => proc do |prev, now| # Run the resource if the previous day was after this weekday (e.g., prev is wed, current is tue) # or if it's been more than a week since we ran prev.wday > now.wday or (now - prev) > (24 * 3600 * 7) end } def match?(previous, now) return false if value == :never value = self.value case @resource[:periodmatch] when :number method = @@methods[value] if method.is_a?(Proc) return method.call(previous, now) else # We negate it, because if they're equal we don't run return now.send(method) != previous.send(method) end when :distance scale = @@scale[value] # If the number of seconds between the two times is greater # than the unit of time, we match. We divide the scale # by the repeat, so that we'll repeat that often within # the scale. diff = (now.to_i - previous.to_i) comparison = (scale / @resource[:repeat]) return (now.to_i - previous.to_i) >= (scale / @resource[:repeat]) end end end newparam(:repeat) do desc "How often the application gets repeated in a given period. Defaults to 1. Must be an integer." defaultto 1 validate do |value| unless value.is_a?(Integer) or value =~ /^\d+$/ raise Puppet::Error, "Repeat must be a number" end # This implicitly assumes that 'periodmatch' is distance -- that # is, if there's no value, we assume it's a valid value. return unless @resource[:periodmatch] if value != 1 and @resource[:periodmatch] != :distance raise Puppet::Error, "Repeat must be 1 unless periodmatch is 'distance', not '#{@resource[:periodmatch]}'" end end munge do |value| value = Integer(value) unless value.is_a?(Integer) value end def match?(previous, now) true end end def self.instances [] end def self.mkdefaultschedules result = [] Puppet.debug "Creating default schedules" result << self.new( :name => "puppet", :period => :hourly, :repeat => "2" ) # And then one for every period @parameters.find { |p| p.name == :period }.value_collection.values.each { |value| result << self.new( :name => value.to_s, :period => value ) } result end def match?(previous = nil, now = nil) # If we've got a value, then convert it to a Time instance previous &&= Time.at(previous) now ||= Time.now # Pull them in order self.class.allattrs.each { |param| if @parameters.include?(param) and @parameters[param].respond_to?(:match?) return false unless @parameters[param].match?(previous, now) end } # If we haven't returned false, then return true; in other words, # any provided schedules need to all match true end end end diff --git a/lib/puppet/type/selmodule.rb b/lib/puppet/type/selmodule.rb index 60be8a855..e76c18cc0 100644 --- a/lib/puppet/type/selmodule.rb +++ b/lib/puppet/type/selmodule.rb @@ -1,53 +1,55 @@ # # Simple module for manageing SELinux policy modules # Puppet::Type.newtype(:selmodule) do @doc = "Manages loading and unloading of SELinux policy modules on the system. Requires SELinux support. See man semodule(8) - for more information on SELinux policy modules." + for more information on SELinux policy modules. + + **Autorequires:** If Puppet is managing the file containing this SELinux policy module (which is either explicitly specified in the `selmodulepath` attribute or will be found at {`selmoduledir`}/{`name`}.pp), the selmodule resource will autorequire that file." ensurable newparam(:name) do desc "The name of the SELinux policy to be managed. You should not include the customary trailing .pp extension." isnamevar end newparam(:selmoduledir) do desc "The directory to look for the compiled pp module file in. Currently defaults to `/usr/share/selinux/targeted`. If selmodulepath is not specified the module will be looked for in this directory in a in a file called NAME.pp, where NAME is the value of the name parameter." defaultto "/usr/share/selinux/targeted" end newparam(:selmodulepath) do desc "The full path to the compiled .pp policy module. You only need to use this if the module file is not in the directory pointed at by selmoduledir." end newproperty(:syncversion) do desc "If set to `true`, the policy will be reloaded if the version found in the on-disk file differs from the loaded version. If set to `false` (the default) the the only check that will be made is if the policy is loaded at all or not." newvalue(:true) newvalue(:false) end autorequire(:file) do if self[:selmodulepath] [self[:selmodulepath]] else ["#{self[:selmoduledir]}/#{self[:name]}.pp"] end end end diff --git a/lib/puppet/type/ssh_authorized_key.rb b/lib/puppet/type/ssh_authorized_key.rb index e3320140e..8338e2d64 100644 --- a/lib/puppet/type/ssh_authorized_key.rb +++ b/lib/puppet/type/ssh_authorized_key.rb @@ -1,98 +1,102 @@ module Puppet newtype(:ssh_authorized_key) do @doc = "Manages SSH authorized keys. Currently only type 2 keys are - supported." + supported. + + **Autorequires:** If Puppet is managing the user account in which this + SSH key should be installed, the `ssh_authorized_key` resource will autorequire + that user." ensurable newparam(:name) do desc "The SSH key comment. This attribute is currently used as a system-wide primary key and therefore has to be unique." isnamevar end newproperty(:type) do desc "The encryption type used: ssh-dss or ssh-rsa." newvalue("ssh-dss") newvalue("ssh-rsa") aliasvalue(:dsa, "ssh-dss") aliasvalue(:rsa, "ssh-rsa") end newproperty(:key) do desc "The key itself; generally a long string of hex digits." end newproperty(:user) do desc "The user account in which the SSH key should be installed. The resource will automatically depend on this user." end newproperty(:target) do desc "The absolute filename in which to store the SSH key. This property is optional and should only be used in cases where keys are stored in a non-standard location (i.e.` not in `~user/.ssh/authorized_keys`)." defaultto :absent def should return super if defined?(@should) and @should[0] != :absent return nil unless user = resource[:user] begin return File.expand_path("~#{user}/.ssh/authorized_keys") rescue Puppet.debug "The required user is not yet present on the system" return nil end end def insync?(is) is == should end end newproperty(:options, :array_matching => :all) do desc "Key options, see sshd(8) for possible values. Multiple values should be specified as an array." defaultto do :absent end def is_to_s(value) if value == :absent or value.include?(:absent) super else value.join(",") end end def should_to_s(value) if value == :absent or value.include?(:absent) super else value.join(",") end end end autorequire(:user) do should(:user) if should(:user) end validate do # Go ahead if target attribute is defined return if @parameters[:target].shouldorig[0] != :absent # Go ahead if user attribute is defined return if @parameters.include?(:user) # If neither target nor user is defined, this is an error raise Puppet::Error, "Attribute 'user' or 'target' is mandatory" end end end diff --git a/lib/puppet/type/user.rb b/lib/puppet/type/user.rb index e7389a0d1..f74e4266f 100755 --- a/lib/puppet/type/user.rb +++ b/lib/puppet/type/user.rb @@ -1,436 +1,449 @@ require 'etc' require 'facter' require 'puppet/property/list' require 'puppet/property/ordered_list' require 'puppet/property/keyvalue' module Puppet newtype(:user) do @doc = "Manage users. This type is mostly built to manage system users, so it is lacking some features useful for managing normal users. This resource type uses the prescribed native tools for creating groups and generally uses POSIX APIs for retrieving information - about them. It does not directly modify `/etc/passwd` or anything." + about them. It does not directly modify `/etc/passwd` or anything. + + **Autorequires:** If Puppet is managing the user's primary group (as provided in the `gid` attribute), the user resource will autorequire that group. If Puppet is managing any role accounts corresponding to the user's roles, the user resource will autorequire those role accounts." feature :allows_duplicates, "The provider supports duplicate users with the same UID." feature :manages_homedir, "The provider can create and remove home directories." feature :manages_passwords, "The provider can modify user passwords, by accepting a password hash." feature :manages_password_age, "The provider can set age requirements and restrictions for passwords." feature :manages_solaris_rbac, "The provider can manage roles and normal users" feature :manages_expiry, "The provider can manage the expiry date for a user." + feature :system_users, + "The provider allows you to create system users with lower UIDs." + newproperty(:ensure, :parent => Puppet::Property::Ensure) do newvalue(:present, :event => :user_created) do provider.create end newvalue(:absent, :event => :user_removed) do provider.delete end newvalue(:role, :event => :role_created, :required_features => :manages_solaris_rbac) do provider.create_role end desc "The basic state that the object should be in." # If they're talking about the thing at all, they generally want to # say it should exist. defaultto do if @resource.managed? :present else nil end end def retrieve if provider.exists? if provider.respond_to?(:is_role?) and provider.is_role? return :role else return :present end else return :absent end end end newproperty(:home) do desc "The home directory of the user. The directory must be created separately and is not currently checked for existence." end newproperty(:uid) do desc "The user ID. Must be specified numerically. For new users being created, if no user ID is specified then one will be chosen automatically, which will likely result in the same user having different IDs on different systems, which is not recommended. This is especially noteworthy if you use Puppet to manage the same user on both Darwin and other platforms, since Puppet does the ID generation for you on Darwin, but the tools do so on other platforms." munge do |value| case value when String if value =~ /^[-0-9]+$/ value = Integer(value) end end return value end end newproperty(:gid) do desc "The user's primary group. Can be specified numerically or by name." munge do |value| if value.is_a?(String) and value =~ /^[-0-9]+$/ Integer(value) else value end end def insync?(is) # We know the 'is' is a number, so we need to convert the 'should' to a number, # too. @should.each do |value| return true if number = Puppet::Util.gid(value) and is == number end false end def sync found = false @should.each do |value| if number = Puppet::Util.gid(value) provider.gid = number found = true break end end fail "Could not find group(s) #{@should.join(",")}" unless found # Use the default event. end end newproperty(:comment) do desc "A description of the user. Generally is a user's full name." end newproperty(:shell) do desc "The user's login shell. The shell must exist and be executable." end newproperty(:password, :required_features => :manages_passwords) do desc "The user's password, in whatever encrypted format the local machine requires. Be sure to enclose any value that includes a dollar sign ($) in single quotes (\')." validate do |value| raise ArgumentError, "Passwords cannot include ':'" if value.is_a?(String) and value.include?(":") end def change_to_s(currentvalue, newvalue) if currentvalue == :absent return "created password" else return "changed password" end end end newproperty(:password_min_age, :required_features => :manages_password_age) do desc "The minimum amount of time in days a password must be used before it may be changed" munge do |value| case value when String Integer(value) else value end end validate do |value| if value.to_s !~ /^-?\d+$/ raise ArgumentError, "Password minimum age must be provided as a number" end end end newproperty(:password_max_age, :required_features => :manages_password_age) do desc "The maximum amount of time in days a password may be used before it must be changed" munge do |value| case value when String Integer(value) else value end end validate do |value| if value.to_s !~ /^-?\d+$/ raise ArgumentError, "Password maximum age must be provided as a number" end end end newproperty(:groups, :parent => Puppet::Property::List) do desc "The groups of which the user is a member. The primary group should not be listed. Multiple groups should be specified as an array." validate do |value| if value =~ /^\d+$/ raise ArgumentError, "Group names must be provided, not numbers" end raise ArgumentError, "Group names must be provided as an array, not a comma-separated list" if value.include?(",") end end newparam(:name) do desc "User name. While limitations are determined for each operating system, it is generally a good idea to keep to the degenerate 8 characters, beginning with a letter." isnamevar end newparam(:membership) do desc "Whether specified groups should be treated as the only groups of which the user is a member or whether they should merely be treated as the minimum membership list." newvalues(:inclusive, :minimum) defaultto :minimum end + newparam(:system, :boolean => true) do + desc "Whether the user is a system user with lower UID." + + newvalues(:true, :false) + + defaultto false + end + newparam(:allowdupe, :boolean => true) do desc "Whether to allow duplicate UIDs." newvalues(:true, :false) defaultto false end newparam(:managehome, :boolean => true) do desc "Whether to manage the home directory when managing the user." newvalues(:true, :false) defaultto false validate do |val| if val.to_s == "true" raise ArgumentError, "User provider #{provider.class.name} can not manage home directories" unless provider.class.manages_homedir? end end end newproperty(:expiry, :required_features => :manages_expiry) do desc "The expiry date for this user. Must be provided in a zero padded YYYY-MM-DD format - e.g 2010-02-19." validate do |value| if value !~ /^\d{4}-\d{2}-\d{2}$/ raise ArgumentError, "Expiry dates must be YYYY-MM-DD" end end end # Autorequire the group, if it's around autorequire(:group) do autos = [] if obj = @parameters[:gid] and groups = obj.shouldorig groups = groups.collect { |group| if group =~ /^\d+$/ Integer(group) else group end } groups.each { |group| case group when Integer if resource = catalog.resources.find { |r| r.is_a?(Puppet::Type.type(:group)) and r.should(:gid) == group } autos << resource end else autos << group end } end if obj = @parameters[:groups] and groups = obj.should autos += groups.split(",") end autos end # Provide an external hook. Yay breaking out of APIs. def exists? provider.exists? end def retrieve absent = false properties.inject({}) { |prophash, property| current_value = :absent if absent prophash[property] = :absent else current_value = property.retrieve prophash[property] = current_value end if property.name == :ensure and current_value == :absent absent = true end prophash } end newproperty(:roles, :parent => Puppet::Property::List, :required_features => :manages_solaris_rbac) do desc "The roles the user has. Multiple roles should be specified as an array." def membership :role_membership end validate do |value| if value =~ /^\d+$/ raise ArgumentError, "Role names must be provided, not numbers" end raise ArgumentError, "Role names must be provided as an array, not a comma-separated list" if value.include?(",") end end #autorequire the roles that the user has autorequire(:user) do reqs = [] if roles_property = @parameters[:roles] and roles = roles_property.should reqs += roles.split(',') end reqs end newparam(:role_membership) do desc "Whether specified roles should be treated as the only roles of which the user is a member or whether they should merely be treated as the minimum membership list." newvalues(:inclusive, :minimum) defaultto :minimum end newproperty(:auths, :parent => Puppet::Property::List, :required_features => :manages_solaris_rbac) do desc "The auths the user has. Multiple auths should be specified as an array." def membership :auth_membership end validate do |value| if value =~ /^\d+$/ raise ArgumentError, "Auth names must be provided, not numbers" end raise ArgumentError, "Auth names must be provided as an array, not a comma-separated list" if value.include?(",") end end newparam(:auth_membership) do desc "Whether specified auths should be treated as the only auths of which the user is a member or whether they should merely be treated as the minimum membership list." newvalues(:inclusive, :minimum) defaultto :minimum end newproperty(:profiles, :parent => Puppet::Property::OrderedList, :required_features => :manages_solaris_rbac) do desc "The profiles the user has. Multiple profiles should be specified as an array." def membership :profile_membership end validate do |value| if value =~ /^\d+$/ raise ArgumentError, "Profile names must be provided, not numbers" end raise ArgumentError, "Profile names must be provided as an array, not a comma-separated list" if value.include?(",") end end newparam(:profile_membership) do desc "Whether specified roles should be treated as the only roles of which the user is a member or whether they should merely be treated as the minimum membership list." newvalues(:inclusive, :minimum) defaultto :minimum end newproperty(:keys, :parent => Puppet::Property::KeyValue, :required_features => :manages_solaris_rbac) do desc "Specify user attributes in an array of keyvalue pairs" def membership :key_membership end validate do |value| raise ArgumentError, "key value pairs must be seperated by an =" unless value.include?("=") end end newparam(:key_membership) do desc "Whether specified key value pairs should be treated as the only attributes of the user or whether they should merely be treated as the minimum list." newvalues(:inclusive, :minimum) defaultto :minimum end newproperty(:project, :required_features => :manages_solaris_rbac) do desc "The name of the project associated with a user" end end end diff --git a/lib/puppet/type/zfs.rb b/lib/puppet/type/zfs.rb index be18ab5aa..7123f8ac9 100755 --- a/lib/puppet/type/zfs.rb +++ b/lib/puppet/type/zfs.rb @@ -1,70 +1,72 @@ module Puppet newtype(:zfs) do - @doc = "Manage zfs. Create destroy and set properties on zfs instances." + @doc = "Manage zfs. Create destroy and set properties on zfs instances. + +**Autorequires:** If Puppet is managing the zpool at the root of this zfs instance, the zfs resource will autorequire it. If Puppet is managing any parent zfs instances, the zfs resource will autorequire them." ensurable newparam(:name) do desc "The full name for this filesystem. (including the zpool)" end newproperty(:mountpoint) do desc "The mountpoint property." end newproperty(:recordsize) do desc "The recordsize property." end newproperty(:aclmode) do desc "The aclmode property." end newproperty(:aclinherit) do desc "The aclinherit property." end newproperty(:primarycache) do desc "The primarycache property." end newproperty(:secondarycache) do desc "The secondarycache property." end newproperty(:compression) do desc "The compression property." end newproperty(:copies) do desc "The copies property." end newproperty(:quota) do desc "The quota property." end newproperty(:reservation) do desc "The reservation property." end newproperty(:sharenfs) do desc "The sharenfs property." end newproperty(:snapdir) do desc "The snapdir property." end autorequire(:zpool) do #strip the zpool off the zfs name and autorequire it [@parameters[:name].value.split('/')[0]] end autorequire(:zfs) do #slice and dice, we want all the zfs before this one names = @parameters[:name].value.split('/') names.slice(1..-2).inject([]) { |a,v| a << "#{a.last}/#{v}" }.collect { |fs| names[0] + fs } end end end diff --git a/lib/puppet/type/zone.rb b/lib/puppet/type/zone.rb index fc524a541..1bae93120 100644 --- a/lib/puppet/type/zone.rb +++ b/lib/puppet/type/zone.rb @@ -1,471 +1,490 @@ Puppet::Type.newtype(:zone) do - @doc = "Solaris zones." + @doc = "Solaris zones. + +**Autorequires:** If Puppet is managing the directory specified as the root of the zone's filesystem (with the `path` attribute), the zone resource will autorequire that directory." # These properties modify the zone configuration, and they need to provide # the text separately from syncing it, so all config statements can be rolled # into a single creation statement. class ZoneConfigProperty < Puppet::Property # Perform the config operation. def sync provider.setconfig self.configtext end end # Those properties that can have multiple instances. class ZoneMultiConfigProperty < ZoneConfigProperty def configtext list = @should current_value = self.retrieve unless current_value.is_a? Symbol if current_value.is_a? Array list += current_value else list << current_value if current_value end end # Some hackery so we can test whether current_value is an array or a symbol if current_value.is_a? Array tmpis = current_value else if current_value tmpis = [current_value] else tmpis = [] end end rms = [] adds = [] # Collect the modifications to make list.sort.uniq.collect do |obj| # Skip objectories that are configured and should be next if tmpis.include?(obj) and @should.include?(obj) if tmpis.include?(obj) rms << obj else adds << obj end end # And then perform all of the removals before any of the adds. (rms.collect { |o| rm(o) } + adds.collect { |o| add(o) }).join("\n") end # We want all specified directories to be included. def insync?(current_value) if current_value.is_a? Array and @should.is_a? Array current_value.sort == @should.sort else current_value == @should end end end ensurable do desc "The running state of the zone. The valid states directly reflect the states that `zoneadm` provides. The states are linear, in that a zone must be `configured` then `installed`, and only then can be `running`. Note also that `halt` is currently used to stop zones." @states = {} @parametervalues = [] def self.alias_state(values) @state_aliases ||= {} values.each do |nick, name| @state_aliases[nick] = name end end def self.newvalue(name, hash) @parametervalues = [] if @parametervalues.is_a? Hash @parametervalues << name @states[name] = hash hash[:name] = name end def self.state_name(name) if other = @state_aliases[name] other else name end end newvalue :absent, :down => :destroy newvalue :configured, :up => :configure, :down => :uninstall newvalue :installed, :up => :install, :down => :stop newvalue :running, :up => :start alias_state :incomplete => :installed, :ready => :installed, :shutting_down => :running defaultto :running def self.state_index(value) @parametervalues.index(state_name(value)) end # Return all of the states between two listed values, exclusive # of the first item. def self.state_sequence(first, second) findex = sindex = nil unless findex = @parametervalues.index(state_name(first)) raise ArgumentError, "'#{first}' is not a valid zone state" end unless sindex = @parametervalues.index(state_name(second)) raise ArgumentError, "'#{first}' is not a valid zone state" end list = nil # Apparently ranges are unidirectional, so we have to reverse # the range op twice. if findex > sindex list = @parametervalues[sindex..findex].collect do |name| @states[name] end.reverse else list = @parametervalues[findex..sindex].collect do |name| @states[name] end end # The first result is the current state, so don't return it. list[1..-1] end def retrieve provider.properties[:ensure] end def sync method = nil if up? direction = :up else direction = :down end # We need to get the state we're currently in and just call # everything between it and us. self.class.state_sequence(self.retrieve, self.should).each do |state| if method = state[direction] warned = false while provider.processing? unless warned info "Waiting for zone to finish processing" warned = true end sleep 1 end provider.send(method) else raise Puppet::DevError, "Cannot move #{direction} from #{st[:name]}" end end ("zone_#{self.should}").intern end # Are we moving up the property tree? def up? current_value = self.retrieve self.class.state_index(current_value) < self.class.state_index(self.should) end end newparam(:name) do desc "The name of the zone." isnamevar end newparam(:id) do desc "The numerical ID of the zone. This number is autogenerated and cannot be changed." end newparam(:clone) do desc "Instead of installing the zone, clone it from another zone. If the zone root resides on a zfs file system, a snapshot will be used to create the clone, is it redisides on ufs, a copy of the zone will be used. The zone you clone from must not be running." end newproperty(:ip, :parent => ZoneMultiConfigProperty) do require 'ipaddr' desc "The IP address of the zone. IP addresses must be specified with the interface, separated by a colon, e.g.: bge0:192.168.0.1. For multiple interfaces, specify them in an array." # Add an interface. def add(str) interface, ip, defrouter = ipsplit(str) cmd = "add net\n" cmd += "set physical=#{interface}\n" if interface cmd += "set address=#{ip}\n" if ip cmd += "set defrouter=#{defrouter}\n" if defrouter #if @resource[:iptype] == :shared cmd += "end\n" end # Convert a string into the component interface, address and defrouter def ipsplit(str) interface, address, defrouter = str.split(':') return interface, address, defrouter end # Remove an interface. def rm(str) interface, ip, defrouter = ipsplit(str) # Reality seems to disagree with the documentation here; the docs # specify that braces are required, but they're apparently only # required if you're specifying multiple values. if ip "remove net address=#{ip}" elsif interface "remove net interface=#{interface}" else raise ArgumentError, "can not remove network based on default router" end end end newproperty(:iptype, :parent => ZoneConfigProperty) do desc "The IP stack type of the zone. Can either be 'shared' or 'exclusive'." defaultto :shared newvalue :shared newvalue :exclusive def configtext "set ip-type=#{self.should}" end end newproperty(:autoboot, :parent => ZoneConfigProperty) do desc "Whether the zone should automatically boot." defaultto true newvalue(:true) {} newvalue(:false) {} def configtext "set autoboot=#{self.should}" end end newproperty(:pool, :parent => ZoneConfigProperty) do desc "The resource pool for this zone." def configtext "set pool=#{self.should}" end end newproperty(:shares, :parent => ZoneConfigProperty) do desc "Number of FSS CPU shares allocated to the zone." def configtext "add rctl\nset name=zone.cpu-shares\nadd value (priv=privileged,limit=#{self.should},action=none)\nend" end end newproperty(:dataset, :parent => ZoneMultiConfigProperty) do desc "The list of datasets delegated to the non global zone from the global zone. All datasets must be zfs filesystem names which is different than the mountpoint." validate do |value| unless value !~ /^\// raise ArgumentError, "Datasets must be the name of a zfs filesystem" end end # Add a zfs filesystem to our list of datasets. def add(dataset) "add dataset\nset name=#{dataset}\nend" end # Remove a zfs filesystem from our list of datasets. def rm(dataset) "remove dataset name=#{dataset}" end def should @should end end newproperty(:inherit, :parent => ZoneMultiConfigProperty) do desc "The list of directories that the zone inherits from the global zone. All directories must be fully qualified." validate do |value| unless value =~ /^\// raise ArgumentError, "Inherited filesystems must be fully qualified" end end # Add a directory to our list of inherited directories. def add(dir) "add inherit-pkg-dir\nset dir=#{dir}\nend" end def rm(dir) # Reality seems to disagree with the documentation here; the docs # specify that braces are required, but they're apparently only # required if you're specifying multiple values. "remove inherit-pkg-dir dir=#{dir}" end def should @should end end # Specify the sysidcfg file. This is pretty hackish, because it's # only used to boot the zone the very first time. newparam(:sysidcfg) do desc %{The text to go into the sysidcfg file when the zone is first booted. The best way is to use a template: # $templatedir/sysidcfg system_locale=en_US timezone=GMT terminal=xterms security_policy=NONE root_password=<%= password %> timeserver=localhost name_service=DNS {domain_name=<%= domain %> name_server=<%= nameserver %>} network_interface=primary {hostname=<%= realhostname %> ip_address=<%= ip %> netmask=<%= netmask %> protocol_ipv6=no default_route=<%= defaultroute %>} nfs4_domain=dynamic And then call that: zone { myzone: ip => "bge0:192.168.0.23", sysidcfg => template(sysidcfg), path => "/opt/zones/myzone", realhostname => "fully.qualified.domain.name" } The sysidcfg only matters on the first booting of the zone, so Puppet only checks for it at that time.} end newparam(:path) do desc "The root of the zone's filesystem. Must be a fully qualified file name. If you include '%s' in the path, then it will be replaced with the zone's name. At this point, you cannot use Puppet to move a zone." validate do |value| unless value =~ /^\// raise ArgumentError, "The zone base must be fully qualified" end end munge do |value| if value =~ /%s/ value % @resource[:name] else value end end end newparam(:create_args) do desc "Arguments to the zonecfg create command. This can be used to create branded zones." end newparam(:install_args) do desc "Arguments to the zoneadm install command. This can be used to create branded zones." end newparam(:realhostname) do desc "The actual hostname of the zone." end # If Puppet is also managing the base dir or its parent dir, list them # both as prerequisites. autorequire(:file) do if @parameters.include? :path [@parameters[:path].value, File.dirname(@parameters[:path].value)] else nil end end + # If Puppet is also managing the zfs filesystem which is the zone dataset + # then list it as a prerequisite. Zpool's get autorequired by the zfs + # type. We just need to autorequire the dataset zfs itself as the zfs type + # will autorequire all of the zfs parents and zpool. + autorequire(:zfs) do + + # Check if we have datasets in our zone configuration + if @parameters.include? :dataset + reqs = [] + # Autorequire each dataset + self[:dataset].each { |value| + reqs << value + } + reqs + end + end + def validate_ip(ip, name) IPAddr.new(ip) if ip rescue ArgumentError self.fail "'#{ip}' is an invalid #{name}" end validate do value = self[:ip] interface, address, defrouter = value.split(':') if self[:iptype] == :shared if (interface && address && defrouter.nil?) || (interface && address && defrouter) validate_ip(address, "IP address") validate_ip(defrouter, "default router") else self.fail "ip must contain interface name and ip address separated by a \":\"" end else self.fail "only interface may be specified when using exclusive IP stack: #{value}" unless interface && address.nil? && defrouter.nil? end self.fail "zone path is required" unless self[:path] end def retrieve provider.flush if hash = provider.properties and hash[:ensure] != :absent result = setstatus(hash) result else # Return all properties as absent. return properties.inject({}) do | prophash, property| prophash[property] = :absent prophash end end end # Take the results of a listing and set everything appropriately. def setstatus(hash) prophash = {} hash.each do |param, value| next if param == :name case self.class.attrtype(param) when :property # Only try to provide values for the properties we're managing if prop = self.property(param) prophash[prop] = value end else self[param] = value end end prophash end end diff --git a/lib/puppet/type/zpool.rb b/lib/puppet/type/zpool.rb index df06522e8..40ee8f286 100755 --- a/lib/puppet/type/zpool.rb +++ b/lib/puppet/type/zpool.rb @@ -1,88 +1,90 @@ module Puppet class Property class VDev < Property def flatten_and_sort(array) array.collect { |a| a.split(' ') }.flatten.sort end def insync?(is) return @should == [:absent] if is == :absent flatten_and_sort(is) == flatten_and_sort(@should) end end class MultiVDev < VDev def insync?(is) return @should == [:absent] if is == :absent return false unless is.length == @should.length is.each_with_index { |list, i| return false unless flatten_and_sort(list) == flatten_and_sort(@should[i]) } #if we made it this far we are in sync true end end end newtype(:zpool) do @doc = "Manage zpools. Create and delete zpools. The provider WILL NOT SYNC, only report differences. Supports vdevs with mirrors, raidz, logs and spares." ensurable newproperty(:disk, :array_matching => :all, :parent => Puppet::Property::VDev) do desc "The disk(s) for this pool. Can be an array or space separated string" end newproperty(:mirror, :array_matching => :all, :parent => Puppet::Property::MultiVDev) do - desc "List of all the devices to mirror for this pool. Each mirror should be a space separated string: + desc "List of all the devices to mirror for this pool. Each mirror should be a + space separated string: - mirror => [\"disk1 disk2\", \"disk3 disk4\"] + mirror => [\"disk1 disk2\", \"disk3 disk4\"], " validate do |value| raise ArgumentError, "mirror names must be provided as string separated, not a comma-separated list" if value.include?(",") end end newproperty(:raidz, :array_matching => :all, :parent => Puppet::Property::MultiVDev) do - desc "List of all the devices to raid for this pool. Should be an array of space separated strings: - - raidz => [\"disk1 disk2\", \"disk3 disk4\"] + desc "List of all the devices to raid for this pool. Should be an array of + space separated strings: + + raidz => [\"disk1 disk2\", \"disk3 disk4\"], " validate do |value| raise ArgumentError, "raid names must be provided as string separated, not a comma-separated list" if value.include?(",") end end newproperty(:spare, :array_matching => :all, :parent => Puppet::Property::VDev) do desc "Spare disk(s) for this pool." end newproperty(:log, :array_matching => :all, :parent => Puppet::Property::VDev) do desc "Log disks for this pool. (doesn't support mirroring yet)" end newparam(:pool) do desc "The name for this pool." isnamevar end newparam(:raid_parity) do desc "Determines parity when using raidz property." end validate do has_should = [:disk, :mirror, :raidz].select { |prop| self.should(prop) } self.fail "You cannot specify #{has_should.join(" and ")} on this type (only one)" if has_should.length > 1 end end end diff --git a/lib/puppet/util.rb b/lib/puppet/util.rb index 850d147e2..d06f44808 100644 --- a/lib/puppet/util.rb +++ b/lib/puppet/util.rb @@ -1,464 +1,469 @@ # A module to collect utility functions. require 'puppet/util/monkey_patches' require 'sync' require 'puppet/external/lock' require 'monitor' +require 'puppet/util/execution_stub' module Puppet # A command failed to execute. require 'puppet/error' class ExecutionFailure < Puppet::Error end module Util require 'benchmark' # These are all for backward compatibility -- these are methods that used # to be in Puppet::Util but have been moved into external modules. require 'puppet/util/posix' extend Puppet::Util::POSIX @@sync_objects = {}.extend MonitorMixin def self.activerecord_version if (defined?(::ActiveRecord) and defined?(::ActiveRecord::VERSION) and defined?(::ActiveRecord::VERSION::MAJOR) and defined?(::ActiveRecord::VERSION::MINOR)) ([::ActiveRecord::VERSION::MAJOR, ::ActiveRecord::VERSION::MINOR].join('.').to_f) else 0 end end def self.synchronize_on(x,type) sync_object,users = 0,1 begin @@sync_objects.synchronize { (@@sync_objects[x] ||= [Sync.new,0])[users] += 1 } @@sync_objects[x][sync_object].synchronize(type) { yield } ensure @@sync_objects.synchronize { @@sync_objects.delete(x) unless (@@sync_objects[x][users] -= 1) > 0 } end end # Change the process to a different user def self.chuser if group = Puppet[:group] group = self.gid(group) raise Puppet::Error, "No such group #{Puppet[:group]}" unless group unless Puppet::Util::SUIDManager.gid == group begin Puppet::Util::SUIDManager.egid = group Puppet::Util::SUIDManager.gid = group rescue => detail Puppet.warning "could not change to group #{group.inspect}: #{detail}" $stderr.puts "could not change to group #{group.inspect}" # Don't exit on failed group changes, since it's # not fatal #exit(74) end end end if user = Puppet[:user] user = self.uid(user) raise Puppet::Error, "No such user #{Puppet[:user]}" unless user unless Puppet::Util::SUIDManager.uid == user begin Puppet::Util::SUIDManager.initgroups(user) Puppet::Util::SUIDManager.uid = user Puppet::Util::SUIDManager.euid = user rescue => detail $stderr.puts "Could not change to user #{user}: #{detail}" exit(74) end end end end # Create instance methods for each of the log levels. This allows # the messages to be a little richer. Most classes will be calling this # method. def self.logmethods(klass, useself = true) Puppet::Util::Log.eachlevel { |level| klass.send(:define_method, level, proc { |args| args = args.join(" ") if args.is_a?(Array) if useself Puppet::Util::Log.create( :level => level, :source => self, :message => args ) else Puppet::Util::Log.create( :level => level, :message => args ) end }) } end # Proxy a bunch of methods to another object. def self.classproxy(klass, objmethod, *methods) classobj = class << klass; self; end methods.each do |method| classobj.send(:define_method, method) do |*args| obj = self.send(objmethod) obj.send(method, *args) end end end # Proxy a bunch of methods to another object. def self.proxy(klass, objmethod, *methods) methods.each do |method| klass.send(:define_method, method) do |*args| obj = self.send(objmethod) obj.send(method, *args) end end end # XXX this should all be done using puppet objects, not using # normal mkdir def self.recmkdir(dir,mode = 0755) if FileTest.exist?(dir) return false else tmp = dir.sub(/^\//,'') path = [File::SEPARATOR] tmp.split(File::SEPARATOR).each { |dir| path.push dir if ! FileTest.exist?(File.join(path)) Dir.mkdir(File.join(path), mode) elsif FileTest.directory?(File.join(path)) next else FileTest.exist?(File.join(path)) raise "Cannot create #{dir}: basedir #{File.join(path)} is a file" end } return true end end # Execute a given chunk of code with a new umask. def self.withumask(mask) cur = File.umask(mask) begin yield ensure File.umask(cur) end end def benchmark(*args) msg = args.pop level = args.pop object = nil if args.empty? if respond_to?(level) object = self else object = Puppet end else object = args.pop end raise Puppet::DevError, "Failed to provide level to :benchmark" unless level unless level == :none or object.respond_to? level raise Puppet::DevError, "Benchmarked object does not respond to #{level}" end # Only benchmark if our log level is high enough if level != :none and Puppet::Util::Log.sendlevel?(level) result = nil seconds = Benchmark.realtime { yield } object.send(level, msg + (" in %0.2f seconds" % seconds)) return seconds else yield end end def which(bin) if bin =~ /^\// return bin if FileTest.file? bin and FileTest.executable? bin else ENV['PATH'].split(File::PATH_SEPARATOR).each do |dir| dest=File.join(dir, bin) return dest if FileTest.file? dest and FileTest.executable? dest end end nil end module_function :which # Execute the provided command in a pipe, yielding the pipe object. def execpipe(command, failonfail = true) if respond_to? :debug debug "Executing '#{command}'" else Puppet.debug "Executing '#{command}'" end output = open("| #{command} 2>&1") do |pipe| yield pipe end if failonfail unless $CHILD_STATUS == 0 raise ExecutionFailure, output end end output end def execfail(command, exception) output = execute(command) return output rescue ExecutionFailure raise exception, output end # Execute the desired command, and return the status and output. # def execute(command, failonfail = true, uid = nil, gid = nil) # :combine sets whether or not to combine stdout/stderr in the output # :stdinfile sets a file that can be used for stdin. Passing a string # for stdin is not currently supported. def execute(command, arguments = {:failonfail => true, :combine => true}) if command.is_a?(Array) command = command.flatten.collect { |i| i.to_s } str = command.join(" ") else # We require an array here so we know where we're incorrectly # using a string instead of an array. Once everything is # switched to an array, we might relax this requirement. raise ArgumentError, "Must pass an array to execute()" end if respond_to? :debug debug "Executing '#{str}'" else Puppet.debug "Executing '#{str}'" end arguments[:uid] = Puppet::Util::SUIDManager.convert_xid(:uid, arguments[:uid]) if arguments[:uid] arguments[:gid] = Puppet::Util::SUIDManager.convert_xid(:gid, arguments[:gid]) if arguments[:gid] + if execution_stub = Puppet::Util::ExecutionStub.current_value + return execution_stub.call(command, arguments) + end + @@os ||= Facter.value(:operatingsystem) output = nil child_pid, child_status = nil # There are problems with read blocking with badly behaved children # read.partialread doesn't seem to capture either stdout or stderr # We hack around this using a temporary file # The idea here is to avoid IO#read whenever possible. output_file="/dev/null" error_file="/dev/null" if ! arguments[:squelch] require "tempfile" output_file = Tempfile.new("puppet") error_file=output_file if arguments[:combine] end if Puppet.features.posix? oldverb = $VERBOSE $VERBOSE = nil child_pid = Kernel.fork $VERBOSE = oldverb if child_pid # Parent process executes this child_status = (Process.waitpid2(child_pid)[1]).to_i >> 8 else # Child process executes this Process.setsid begin if arguments[:stdinfile] $stdin.reopen(arguments[:stdinfile]) else $stdin.reopen("/dev/null") end $stdout.reopen(output_file) $stderr.reopen(error_file) 3.upto(256){|fd| IO::new(fd).close rescue nil} if arguments[:gid] Process.egid = arguments[:gid] Process.gid = arguments[:gid] unless @@os == "Darwin" end if arguments[:uid] Process.euid = arguments[:uid] Process.uid = arguments[:uid] unless @@os == "Darwin" end ENV['LANG'] = ENV['LC_ALL'] = ENV['LC_MESSAGES'] = ENV['LANGUAGE'] = 'C' if command.is_a?(Array) Kernel.exec(*command) else Kernel.exec(command) end rescue => detail puts detail.to_s exit!(1) end end elsif Puppet.features.microsoft_windows? command = command.collect {|part| '"' + part.gsub(/"/, '\\"') + '"'}.join(" ") if command.is_a?(Array) Puppet.debug "Creating process '#{command}'" processinfo = Process.create( :command_line => command ) child_status = (Process.waitpid2(child_pid)[1]).to_i >> 8 end # read output in if required if ! arguments[:squelch] # Make sure the file's actually there. This is # basically a race condition, and is probably a horrible # way to handle it, but, well, oh well. unless FileTest.exists?(output_file.path) Puppet.warning "sleeping" sleep 0.5 unless FileTest.exists?(output_file.path) Puppet.warning "sleeping 2" sleep 1 unless FileTest.exists?(output_file.path) Puppet.warning "Could not get output" output = "" end end end unless output # We have to explicitly open here, so that it reopens # after the child writes. output = output_file.open.read # The 'true' causes the file to get unlinked right away. output_file.close(true) end end if arguments[:failonfail] unless child_status == 0 raise ExecutionFailure, "Execution of '#{str}' returned #{child_status}: #{output}" end end output end module_function :execute # Create an exclusive lock. def threadlock(resource, type = Sync::EX) Puppet::Util.synchronize_on(resource,type) { yield } end # Because some modules provide their own version of this method. alias util_execute execute module_function :benchmark def memory unless defined?(@pmap) @pmap = which('pmap') end if @pmap %x{#{@pmap} #{Process.pid}| grep total}.chomp.sub(/^\s*total\s+/, '').sub(/K$/, '').to_i else 0 end end def symbolize(value) if value.respond_to? :intern value.intern else value end end def symbolizehash(hash) newhash = {} hash.each do |name, val| if name.is_a? String newhash[name.intern] = val else newhash[name] = val end end end def symbolizehash!(hash) hash.each do |name, val| if name.is_a? String hash[name.intern] = val hash.delete(name) end end hash end module_function :symbolize, :symbolizehash, :symbolizehash! # Just benchmark, with no logging. def thinmark seconds = Benchmark.realtime { yield } seconds end module_function :memory, :thinmark def secure_open(file,must_be_w,&block) raise Puppet::DevError,"secure_open only works with mode 'w'" unless must_be_w == 'w' raise Puppet::DevError,"secure_open only requires a block" unless block_given? Puppet.warning "#{file} was a symlink to #{File.readlink(file)}" if File.symlink?(file) if File.exists?(file) or File.symlink?(file) wait = File.symlink?(file) ? 5.0 : 0.1 File.delete(file) sleep wait # give it a chance to reappear, just in case someone is actively trying something. end begin File.open(file,File::CREAT|File::EXCL|File::TRUNC|File::WRONLY,&block) rescue Errno::EEXIST desc = File.symlink?(file) ? "symlink to #{File.readlink(file)}" : File.stat(file).ftype puts "Warning: #{file} was apparently created by another process (as" puts "a #{desc}) as soon as it was deleted by this process. Someone may be trying" puts "to do something objectionable (such as tricking you into overwriting system" puts "files if you are running as root)." raise end end module_function :secure_open end end require 'puppet/util/errors' require 'puppet/util/methodhelper' require 'puppet/util/metaid' require 'puppet/util/classgen' require 'puppet/util/docs' require 'puppet/util/execution' require 'puppet/util/logging' require 'puppet/util/package' require 'puppet/util/warnings' diff --git a/lib/puppet/util/command_line.rb b/lib/puppet/util/command_line.rb index 3562a3dc0..7f74d266a 100644 --- a/lib/puppet/util/command_line.rb +++ b/lib/puppet/util/command_line.rb @@ -1,95 +1,99 @@ module Puppet module Util class CommandLine LegacyName = Hash.new{|h,k| k}.update( { 'agent' => 'puppetd', 'cert' => 'puppetca', 'doc' => 'puppetdoc', 'filebucket' => 'filebucket', 'apply' => 'puppet', 'describe' => 'pi', 'queue' => 'puppetqd', 'resource' => 'ralsh', 'kick' => 'puppetrun', 'master' => 'puppetmasterd', }) def initialize( zero = $0, argv = ARGV, stdin = STDIN ) @zero = zero @argv = argv.dup @stdin = stdin @subcommand_name, @args = subcommand_and_args( @zero, @argv, @stdin ) end attr :subcommand_name attr :args def appdir File.join('puppet', 'application') end def available_subcommands - absolute_appdir = $LOAD_PATH.collect { |x| File.join(x,'puppet','application') }.detect{ |x| File.directory?(x) } - Dir[File.join(absolute_appdir, '*.rb')].map{|fn| File.basename(fn, '.rb')} + absolute_appdirs = $LOAD_PATH.collect do |x| + File.join(x,'puppet','application') + end.select{ |x| File.directory?(x) } + absolute_appdirs.inject([]) do |commands, dir| + commands + Dir[File.join(dir, '*.rb')].map{|fn| File.basename(fn, '.rb')} + end.uniq end def usage_message usage = "Usage: puppet command " available = "Available commands are: #{available_subcommands.sort.join(', ')}" [usage, available].join("\n") end def require_application(application) require File.join(appdir, application) end def execute if subcommand_name.nil? puts usage_message elsif available_subcommands.include?(subcommand_name) #subcommand require_application subcommand_name Puppet::Application.find(subcommand_name).new(self).run else abort "Error: Unknown command #{subcommand_name}.\n#{usage_message}" unless execute_external_subcommand end end def execute_external_subcommand external_command = "puppet-#{subcommand_name}" require 'puppet/util' path_to_subcommand = Puppet::Util.which( external_command ) return false unless path_to_subcommand system( path_to_subcommand, *args ) true end def legacy_executable_name LegacyName[ subcommand_name ] end private def subcommand_and_args( zero, argv, stdin ) zero = File.basename(zero, '.rb') if zero == 'puppet' case argv.first when nil; [ stdin.tty? ? nil : "apply", argv] # ttys get usage info - when "--help"; [nil, argv] # help should give you usage, not the help for `puppet apply` + when "--help", "-h"; [nil, argv] # help should give you usage, not the help for `puppet apply` when /^-|\.pp$|\.rb$/; ["apply", argv] else [ argv.first, argv[1..-1] ] end else [ zero, argv ] end end end end end diff --git a/lib/puppet/util/command_line/filebucket b/lib/puppet/util/command_line/filebucket deleted file mode 100755 index 34b01508e..000000000 --- a/lib/puppet/util/command_line/filebucket +++ /dev/null @@ -1,97 +0,0 @@ -#!/usr/bin/env ruby - -# -# = Synopsis -# -# A stand-alone Puppet filebucket client. -# -# = Usage -# -# puppet filebucket [-h|--help] [-V|--version] [-d|--debug] [-v|--verbose] -# [-l|--local] [-r|--remote] -# [-s|--server ] [-b|--bucket ] ... -# -# = Description -# -# This is a stand-alone filebucket client for sending files to a local -# or central filebucket. -# -# = Usage -# -# This client can operate in three modes, with only one mode per call: -# -# backup:: -# Send one or more files to the specified file bucket. Each sent file -# is printed with its resulting md5 sum. -# -# get:: -# Return the text associated with an md5 sum. The text is printed to -# stdout, and only one file can be retrieved at a time. -# -# restore:: -# Given a file path and an md5 sum, store the content associated with the -# sum into the specified file path. You can specify an entirely new path -# to this argument; you are not restricted to restoring the content to its -# original location. -# -# Note that +filebucket+ defaults to using a network-based filebucket available on -# the server named +puppet+. To use this, you'll have to be running as a user -# with valid Puppet certificates. Alternatively, you can use your local file bucket -# by specifying +--local+. -# -# = Example -# -# $ puppet filebucket backup /etc/passwd -# /etc/passwd: 429b225650b912a2ee067b0a4cf1e949 -# $ puppet filebucket restore /tmp/passwd 429b225650b912a2ee067b0a4cf1e949 -# $ -# -# = Options -# -# Note that any configuration parameter that's valid in the configuration file -# is also a valid long argument. For example, 'ssldir' is a valid configuration -# parameter, so you can specify '--ssldir ' as an argument. -# -# See the configuration file documentation at -# http://docs.puppetlabs.com/references/stable/configuration.html for -# the full list of acceptable parameters. A commented list of all -# configuration options can also be generated by running puppet with -# '--genconfig'. -# -# debug:: -# Enable full debugging. -# -# help:: -# Print this help message -# -# local:: -# Use the local filebucket. This will use the default configuration -# information. -# -# remote:: -# Use a remote filebucket. This will use the default configuration -# information. -# -# server:: -# The server to send the file to, instead of locally. -# -# verbose:: -# Print extra information. -# -# version:: -# Print version information. -# -# = Example -# -# puppet filebucket -b /tmp/filebucket /my/file -# -# = Author -# -# Luke Kanies -# -# = Copyright -# -# Copyright (c) 2005 Puppet Labs, LLC -# Licensed under the GNU Public License - -#Puppet::Application[:filebucket].run diff --git a/lib/puppet/util/command_line/pi b/lib/puppet/util/command_line/pi deleted file mode 100755 index 3d80eea8f..000000000 --- a/lib/puppet/util/command_line/pi +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env ruby - -# -# = Synopsis -# -# Print help about puppet types on the console. Run with '-h' to get detailed -# help. -# = Usage -# -# puppet describe [-h|--help] [-s|--short] [-p|--providers] [-l|--list] [-m|--meta] -# -# = Description -# -# Prints details of Puppet types, providers and metaparameters on the console. -# -# = Options -# -# help:: -# Print this help text -# -# providers:: -# Describe providers in detail for each type -# -# list:: -# List all types -# -# meta:: -# List all metaparameters -# -# short:: -# List only parameters without detail -# -# = Example -# -# puppet describe --list -# puppet describe file --providers -# puppet describe user -s -m -# -# = Author -# -# David Lutterkort -# -# = Copyright -# -# Copyright (c) 2005 Puppet Labs, LLC -# Licensed under the GNU Public License - -#Puppet::Application[:describe].run diff --git a/lib/puppet/util/command_line/puppet b/lib/puppet/util/command_line/puppet deleted file mode 100755 index e75b92af8..000000000 --- a/lib/puppet/util/command_line/puppet +++ /dev/null @@ -1,69 +0,0 @@ - -# -# = Synopsis -# -# Run a stand-alone +puppet+ manifest. -# -# = Usage -# -# puppet apply [-h|--help] [-V|--version] [-d|--debug] [-v|--verbose] [-e|--execute] -# [--detailed-exitcodes] [-l|--logdest ] -# -# = Description -# -# This is the standalone puppet execution tool; use it to execute -# individual manifests that you write. If you need to execute site-wide -# manifests, use 'puppet agent' and 'puppet master'. -# -# = Options -# -# Note that any configuration parameter that's valid in the configuration file -# is also a valid long argument. For example, 'ssldir' is a valid configuration -# parameter, so you can specify '--ssldir ' as an argument. -# -# See the configuration file documentation at -# http://docs.puppetlabs.com/references/stable/configuration.html for -# the full list of acceptable parameters. A commented list of all -# configuration options can also be generated by running puppet with -# '--genconfig'. -# -# debug:: -# Enable full debugging. -# -# detailed-exitcodes:: -# Provide transaction information via exit codes. If this is enabled, an exit -# code of '2' means there were changes, and an exit code of '4' means that there -# were failures during the transaction. -# -# help:: -# Print this help message -# -# loadclasses:: -# Load any stored classes. 'puppet agent' caches configured classes (usually at -# /etc/puppet/classes.txt), and setting this option causes all of those classes -# to be set in your puppet manifest. -# -# logdest:: -# Where to send messages. Choose between syslog, the console, and a log file. -# Defaults to sending messages to the console. -# -# execute:: -# Execute a specific piece of Puppet code -# -# verbose:: -# Print extra information. -# -# = Example -# -# puppet -l /tmp/manifest.log manifest.pp -# -# = Author -# -# Luke Kanies -# -# = Copyright -# -# Copyright (c) 2005 Puppet Labs, LLC -# Licensed under the GNU Public License - -#Puppet::Application[:apply].run diff --git a/lib/puppet/util/command_line/puppetca b/lib/puppet/util/command_line/puppetca deleted file mode 100755 index 317d99881..000000000 --- a/lib/puppet/util/command_line/puppetca +++ /dev/null @@ -1,110 +0,0 @@ -#!/usr/bin/env ruby - -# -# = Synopsis -# -# Stand-alone certificate authority. Capable of generating certificates -# but mostly meant for signing certificate requests from puppet clients. -# -# = Usage -# -# puppet cert [-h|--help] [-V|--version] [-d|--debug] [-v|--verbose] -# [-g|--generate] [-l|--list] [-s|--sign] [-r|--revoke] -# [-p|--print] [-c|--clean] [--verify] [--digest DIGEST] -# [--fingerprint] [host] -# -# = Description -# -# Because the puppetmasterd daemon defaults to not signing client certificate -# requests, this script is available for signing outstanding requests. It -# can be used to list outstanding requests and then either sign them individually -# or sign all of them. -# -# = Options -# -# Note that any configuration parameter that's valid in the configuration file -# is also a valid long argument. For example, 'ssldir' is a valid configuration -# parameter, so you can specify '--ssldir ' as an argument. -# -# See the configuration file documentation at -# http://docs.puppetlabs.com/references/stable/configuration.html for -# the full list of acceptable parameters. A commented list of all -# configuration options can also be generated by running puppet cert with -# '--genconfig'. -# -# all:: -# Operate on all items. Currently only makes sense with '--sign', -# '--clean', or '--list'. -# -# digest:: -# Set the digest for fingerprinting (defaults to md5). Valid values depends -# on your openssl and openssl ruby extension version, but should contain at -# least md5, sha1, md2, sha256. -# -# clean:: -# Remove all files related to a host from puppet cert's storage. This is -# useful when rebuilding hosts, since new certificate signing requests -# will only be honored if puppet cert does not have a copy of a signed -# certificate for that host. The certificate of the host is also revoked. -# If '--all' is specified then all host certificates, both signed and -# unsigned, will be removed. -# -# debug:: -# Enable full debugging. -# -# generate:: -# Generate a certificate for a named client. A certificate/keypair will be -# generated for each client named on the command line. -# -# help:: -# Print this help message -# -# list:: -# List outstanding certificate requests. If '--all' is specified, -# signed certificates are also listed, prefixed by '+', and revoked -# or invalid certificates are prefixed by '-' (the verification outcome -# is printed in parenthesis). -# -# print:: -# Print the full-text version of a host's certificate. -# -# fingerprint:: -# Print the DIGEST (defaults to md5) fingerprint of a host's certificate. -# -# revoke:: -# Revoke the certificate of a client. The certificate can be specified -# either by its serial number, given as a decimal number or a hexadecimal -# number prefixed by '0x', or by its hostname. The certificate is revoked -# by adding it to the Certificate Revocation List given by the 'cacrl' -# config parameter. Note that the puppetmasterd needs to be restarted -# after revoking certificates. -# -# sign:: -# Sign an outstanding certificate request. Unless '--all' is specified, -# hosts must be listed after all flags. -# -# verbose:: -# Enable verbosity. -# -# version:: -# Print the puppet version number and exit. -# -# verify:: -# Verify the named certificate against the local CA certificate. -# -# = Example -# -# $ puppet cert -l -# culain.madstop.com -# $ puppet cert -s culain.madstop.com -# -# = Author -# -# Luke Kanies -# -# = Copyright -# -# Copyright (c) 2005 Puppet Labs, LLC -# Licensed under the GNU Public License - -#Puppet::Application[:cert].run diff --git a/lib/puppet/util/command_line/puppetd b/lib/puppet/util/command_line/puppetd deleted file mode 100755 index 71b28429b..000000000 --- a/lib/puppet/util/command_line/puppetd +++ /dev/null @@ -1,188 +0,0 @@ -#!/usr/bin/env ruby - -# == Synopsis -# -# Retrieve the client configuration from the puppet master and apply -# it to the local host. -# -# Currently must be run out periodically, using cron or something similar. -# -# = Usage -# -# puppet agent [-D|--daemonize|--no-daemonize] [-d|--debug] -# [--detailed-exitcodes] [--disable] [--enable] -# [-h|--help] [--certname ] [-l|--logdest syslog||console] -# [-o|--onetime] [--serve ] [-t|--test] [--noop] -# [--digest ] [--fingerprint] [-V|--version] -# [-v|--verbose] [-w|--waitforcert ] -# -# = Description -# -# This is the main puppet client. Its job is to retrieve the local machine's -# configuration from a remote server and apply it. In order to successfully -# communicate with the remote server, the client must have a certificate signed -# by a certificate authority that the server trusts; the recommended method -# for this, at the moment, is to run a certificate authority as part of the -# puppet server (which is the default). The client will connect and request -# a signed certificate, and will continue connecting until it receives one. -# -# Once the client has a signed certificate, it will retrieve its configuration -# and apply it. -# -# = Usage Notes -# -# +puppet agent+ does its best to find a compromise between interactive use and -# daemon use. Run with no arguments and no configuration, it will go into the -# backgroun, attempt to get a signed certificate, and retrieve and apply its -# configuration every 30 minutes. -# -# Some flags are meant specifically for interactive use -- in particular, -# +test+, +tags+ or +fingerprint+ are useful. +test+ enables verbose logging, causes -# the daemon to stay in the foreground, exits if the server's configuration is -# invalid (this happens if, for instance, you've left a syntax error on the -# server), and exits after running the configuration once (rather than hanging -# around as a long-running process). -# -# +tags+ allows you to specify what portions of a configuration you want to apply. -# Puppet elements are tagged with all of the class or definition names that -# contain them, and you can use the +tags+ flag to specify one of these names, -# causing only configuration elements contained within that class or definition -# to be applied. This is very useful when you are testing new configurations -- -# for instance, if you are just starting to manage +ntpd+, you would put all of -# the new elements into an +ntpd+ class, and call puppet with +--tags ntpd+, -# which would only apply that small portion of the configuration during your -# testing, rather than applying the whole thing. -# -# +fingerprint+ is a one-time flag. In this mode +puppet agent+ will run once and -# display on the console (and in the log) the current certificate (or certificate -# request) fingerprint. Providing the +--digest+ option allows to use a different -# digest algorithm to generate the fingerprint. The main use is to verify that -# before signing a certificate request on the master, the certificate request the -# master received is the same as the one the client sent (to prevent against -# man-in-the-middle attacks when signing certificates). -# -# -# = Options -# -# Note that any configuration parameter that's valid in the configuration file -# is also a valid long argument. For example, 'server' is a valid configuration -# parameter, so you can specify '--server ' as an argument. -# -# See the configuration file documentation at -# http://docs.puppetlabs.com/references/stable/configuration.html for -# the full list of acceptable parameters. A commented list of all -# configuration options can also be generated by running puppet agent with -# '--genconfig'. -# -# daemonize:: -# Send the process into the background. This is the default. -# -# no-daemonize:: -# Do not send the process into the background. -# -# debug:: -# Enable full debugging. -# -# digest:: -# Change the certificate fingerprinting digest algorithm. The default is MD5. -# Valid values depends on the version of OpenSSL installed, but should always -# at least contain MD5, MD2, SHA1 and SHA256. -# -# detailed-exitcodes:: -# Provide transaction information via exit codes. If this is enabled, an -# exit code of '2' means there were changes, and an exit code of '4' means -# that there were failures during the transaction. This option only makes -# sense in conjunction with --onetime. -# -# disable:: -# Disable working on the local system. This puts a lock file in place, -# causing +puppet agent+ not to work on the system until the lock file is removed. -# This is useful if you are testing a configuration and do not want the central -# configuration to override the local state until everything is tested and -# committed. -# -# +puppet agent+ uses the same lock file while it is running, so no more than one -# +puppet agent+ process is working at a time. -# -# +puppet agent+ exits after executing this. -# -# enable:: -# Enable working on the local system. This removes any lock file, causing -# +puppet agent+ to start managing the local system again (although it will continue -# to use its normal scheduling, so it might not start for another half hour). -# -# +puppet agent+ exits after executing this. -# -# certname:: -# Set the certname (unique ID) of the client. The master reads this unique -# identifying string, which is usually set to the node's fully-qualified domain -# name, to determine which configurations the node will receive. Use this option -# to debug setup problems or implement unusual node identification schemes. -# -# help:: -# Print this help message -# -# logdest:: -# Where to send messages. Choose between syslog, the console, and a log file. -# Defaults to sending messages to syslog, or the console if debugging or -# verbosity is enabled. -# -# no-client:: -# Do not create a config client. This will cause the daemon to run -# without ever checking for its configuration automatically, and only -# makes sense when used in conjunction with --listen. -# -# onetime:: -# Run the configuration once. Runs a single (normally daemonized) Puppet run. -# Useful for interactively running puppet agent when used in conjunction with -# the --no-daemonize option. -# -# fingerprint:: -# Display the current certificate or certificate signing request fingerprint -# and then exit. Use the +--digest+ option to change the digest algorithm used. -# -# serve:: -# Start another type of server. By default, +puppet agent+ will start -# a service handler that allows authenticated and authorized remote nodes to -# trigger the configuration to be pulled down and applied. You can specify -# any handler here that does not require configuration, e.g., filebucket, ca, -# or resource. The handlers are in +lib/puppet/network/handler+, and the names -# must match exactly, both in the call to +serve+ and in +namespaceauth.conf+. -# -# test:: -# Enable the most common options used for testing. These are +onetime+, -# +verbose+, +ignorecache, +no-daemonize+, +no-usecacheonfailure+, -# +detailed-exit-codes+, +no-splay+, and +show_diff+. -# -# noop:: -# Use +noop+ mode where the daemon runs in a no-op or dry-run mode. This is useful -# for seeing what changes Puppet will make without actually executing the changes. -# -# verbose:: -# Turn on verbose reporting. -# -# version:: -# Print the puppet version number and exit. -# -# waitforcert:: -# This option only matters for daemons that do not yet have certificates -# and it is enabled by default, with a value of 120 (seconds). This causes -# +puppet agent+ to connect to the server every 2 minutes and ask it to sign a -# certificate request. This is useful for the initial setup of a puppet -# client. You can turn off waiting for certificates by specifying a time -# of 0. -# -# = Example -# -# puppet agent --server puppet.domain.com -# -# = Author -# -# Luke Kanies -# -# = Copyright -# -# Copyright (c) 2005, 2006 Puppet Labs, LLC -# Licensed under the GNU Public License - -#Puppet::Application[:agent].run diff --git a/lib/puppet/util/command_line/puppetdoc b/lib/puppet/util/command_line/puppetdoc deleted file mode 100755 index 45a9c6518..000000000 --- a/lib/puppet/util/command_line/puppetdoc +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/env ruby - -# -# = Synopsis -# -# Generate a reference for all Puppet types. Largely meant for internal Puppet -# Labs use. -# -# = Usage -# -# puppet doc [-a|--all] [-h|--help] [-o|--outputdir ] [-m|--mode ] -# [-r|--reference <[type]|configuration|..>] [--charset CHARSET] [manifest-file] -# -# = Description -# -# If mode is not 'rdoc', then this command generates a Markdown document describing all installed -# Puppet types or all allowable arguments to puppet executables. It is largely -# meant for internal use and is used to generate the reference document -# available on the Puppet Labs web site. -# -# In 'rdoc' mode, this command generates an html RDoc hierarchy describing the manifests that -# are in 'manifestdir' and 'modulepath' configuration directives. -# The generated documentation directory is doc by default but can be changed with the 'outputdir' option. -# -# If the command is started with 'manifest-file' command-line arguments, puppet doc generate a single -# manifest documentation that is output on stdout. -# -# = Options -# -# all:: -# Output the docs for all of the reference types. In 'rdoc' modes, this also outputs documentation for all resources -# -# help:: -# Print this help message -# -# outputdir:: -# Specifies the directory where to output the rdoc documentation in 'rdoc' mode. -# -# mode:: -# Determine the output mode. Valid modes are 'text', 'pdf' and 'rdoc'. The 'pdf' mode creates PDF formatted files in the /tmp directory. The default mode is 'text'. In 'rdoc' mode you must provide 'manifests-path' -# -# reference:: -# Build a particular reference. Get a list of references by running +puppet doc --list+. -# -# charset:: -# Used only in 'rdoc' mode. It sets the charset used in the html files produced. -# -# = Example -# -# $ puppet doc -r type > /tmp/type_reference.markdown -# or -# $ puppet doc --outputdir /tmp/rdoc --mode rdoc /path/to/manifests -# or -# $ puppet doc /etc/puppet/manifests/site.pp -# or -# $ puppet doc -m pdf -r configuration -# -# = Author -# -# Luke Kanies -# -# = Copyright -# -# Copyright (c) 2005-2007 Puppet Labs, LLC -# Licensed under the GNU Public License - -#Puppet::Application[:doc].run diff --git a/lib/puppet/util/command_line/puppetmasterd b/lib/puppet/util/command_line/puppetmasterd deleted file mode 100755 index 445169820..000000000 --- a/lib/puppet/util/command_line/puppetmasterd +++ /dev/null @@ -1,74 +0,0 @@ -#!/usr/bin/env ruby - -# -# = Synopsis -# -# The central puppet server. Functions as a certificate authority by default. -# -# = Usage -# -# puppet master [-D|--daemonize|--no-daemonize] [-d|--debug] [-h|--help] -# [-l|--logdest |console|syslog] [-v|--verbose] [-V|--version] -# [--compile ] [--apply ] -# -# = Description -# -# This is the puppet central daemon. -# -# = Options -# -# Note that any configuration parameter that's valid in the configuration file -# is also a valid long argument. For example, 'ssldir' is a valid configuration -# parameter, so you can specify '--ssldir ' as an argument. -# -# See the configuration file documentation at -# http://docs.puppetlabs.com/references/stable/configuration.html for -# the full list of acceptable parameters. A commented list of all -# configuration options can also be generated by running puppetmasterdd with -# '--genconfig'. -# -# daemonize:: -# Send the process into the background. This is the default. -# -# no-daemonize:: -# Do not send the process into the background. -# -# debug:: -# Enable full debugging. -# -# help:: -# Print this help message. -# -# logdest:: -# Where to send messages. Choose between syslog, the console, and a log file. -# Defaults to sending messages to syslog, or the console -# if debugging or verbosity is enabled. -# -# verbose:: -# Enable verbosity. -# -# version:: -# Print the puppet version number and exit. -# -# compile:: -# Capability to compile a catalogue and output it in JSON from the Puppet master. Uses -# facts contained in the $vardir/yaml/ directory to compile the catalog. -# -# apply:: -# Capability to apply JSON catalog (such as one generated with --compile). You can either specify -# a JSON file or pipe in JSON from standard input. -# -# = Example -# -# puppet master -# -# = Author -# -# Luke Kanies -# -# = Copyright -# -# Copyright (c) 2005 Puppet Labs, LLC -# Licensed under the GNU Public License - -#Puppet::Application[:master].run diff --git a/lib/puppet/util/command_line/puppetqd b/lib/puppet/util/command_line/puppetqd deleted file mode 100755 index 81963d537..000000000 --- a/lib/puppet/util/command_line/puppetqd +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/env ruby - -# == Synopsis -# -# Retrieve serialized records from a queue and process them in order. -# -# = Usage -# -# puppet queue [-d|--debug] [-v|--verbose] -# -# = Description -# -# This is a simple application that just processes entities in a queue as they -# are recieved. -# -# = Options -# -# Note that any configuration parameter that's valid in the configuration file -# is also a valid long argument. For example, 'server' is a valid configuration -# parameter, so you can specify '--server ' as an argument. -# -# See the configuration file documentation at -# http://docs.puppetlabs.com/references/stable/configuration.html for -# the full list of acceptable parameters. A commented list of all -# configuration options can also be generated by running puppetd with -# '--genconfig'. -# -# debug:: -# Enable full debugging. -# -# help:: -# Print this help message -# -# verbose:: -# Turn on verbose reporting. -# -# version:: -# Print the puppet version number and exit. -# -# = Example -# -# puppet queue -# -# = Author -# -# Luke Kanies -# -# = Copyright -# -# Copyright (c) 2009 Puppet Labs, LLC -# Licensed under the GNU Public License - -#Puppet::Application[:queue].run diff --git a/lib/puppet/util/command_line/puppetrun b/lib/puppet/util/command_line/puppetrun deleted file mode 100755 index 7eba3b2c4..000000000 --- a/lib/puppet/util/command_line/puppetrun +++ /dev/null @@ -1,126 +0,0 @@ -#!/usr/bin/env ruby - -# -# = Synopsis -# -# Trigger a puppet agent run on a set of hosts. -# -# = Usage -# -# puppet kick [-a|--all] [-c|--class ] [-d|--debug] [-f|--foreground] -# [-h|--help] [--host ] [--no-fqdn] [--ignoreschedules] -# [-t|--tag ] [--test] [-p|--ping] [ [...]] -# -# = Description -# -# This script can be used to connect to a set of machines running +puppet agent+ -# and trigger them to run their configurations. The most common usage would -# be to specify a class of hosts and a set of tags, and +puppet kick+ would -# look up in LDAP all of the hosts matching that class, then connect to -# each host and trigger a run of all of the objects with the specified tags. -# -# If you are not storing your host configurations in LDAP, you can specify -# hosts manually. -# -# You will most likely have to run +puppet kick+ as root to get access to -# the SSL certificates. -# -# +puppet kick+ reads +puppet master+'s configuration file, so that it can copy -# things like LDAP settings. -# -# = Usage Notes -# -# +puppet kick+ is useless unless +puppet agent+ is listening. See its documentation -# for more information, but the gist is that you must enable +listen+ on the -# +puppet agent+ daemon, either using +--listen+ on the command line or adding -# 'listen: true' in its config file. In addition, you need to set the daemons -# up to specifically allow connections by creating the +namespaceauth+ file, -# normally at '/etc/puppet/namespaceauth.conf'. This file specifies who has -# access to each namespace; if you create the file you must add every namespace -# you want any Puppet daemon to allow -- it is currently global to all Puppet -# daemons. -# -# An example file looks like this:: -# -# [fileserver] -# allow *.madstop.com -# -# [puppetmaster] -# allow *.madstop.com -# -# [puppetrunner] -# allow culain.madstop.com -# -# This is what you would install on your Puppet master; non-master hosts could -# leave off the 'fileserver' and 'puppetmaster' namespaces. -# -# = Options -# -# Note that any configuration parameter that's valid in the configuration file -# is also a valid long argument. For example, 'ssldir' is a valid configuration -# parameter, so you can specify '--ssldir ' as an argument. -# -# See the configuration file documentation at -# http://reductivelabs.com/projects/puppet/reference/configref.html for -# the full list of acceptable parameters. A commented list of all -# configuration options can also be generated by running puppet master with -# '--genconfig'. -# -# -# all:: -# Connect to all available hosts. Requires LDAP support at this point. -# -# class:: -# Specify a class of machines to which to connect. This only works if you -# have LDAP configured, at the moment. -# -# debug:: -# Enable full debugging. -# -# foreground:: -# Run each configuration in the foreground; that is, when connecting to a host, -# do not return until the host has finished its run. The default is false. -# -# help:: -# Print this help message -# -# host:: -# A specific host to which to connect. This flag can be specified more -# than once. -# -# ignoreschedules:: -# Whether the client should ignore schedules when running its configuration. -# This can be used to force the client to perform work it would not normally -# perform so soon. The default is false. -# -# parallel:: -# How parallel to make the connections. Parallelization is provided by forking -# for each client to which to connect. The default is 1, meaning serial execution. -# -# tag:: -# Specify a tag for selecting the objects to apply. Does not work with the -# --test option. -# -# -# test:: -# Print the hosts you would connect to but do not actually connect. This -# option requires LDAP support at this point. -# -# ping:: -# -# Do a ICMP echo against the target host. Skip hosts that don't respond to ping. -# -# = Example -# -# sudo puppet kick -p 10 -t remotefile -t webserver host1 host2 -# -# = Author -# -# Luke Kanies -# -# = Copyright -# -# Copyright (c) 2005 Puppet Labs, LLC -# Licensed under the GNU Public License - -#Puppet::Application[:kick].run diff --git a/lib/puppet/util/command_line/ralsh b/lib/puppet/util/command_line/ralsh deleted file mode 100755 index 5c1f719e2..000000000 --- a/lib/puppet/util/command_line/ralsh +++ /dev/null @@ -1,89 +0,0 @@ -#!/usr/bin/env ruby - -# -# = Synopsis -# -# Use the Puppet RAL to directly interact with the system. -# -# = Usage -# -# puppet resource [-h|--help] [-d|--debug] [-v|--verbose] [-e|--edit] -# [-H|--host ] [-p|--param ] [-t|--types] -# type -# -# = Description -# -# This command provides simple facilities for converting current system state -# into Puppet code, along with some ability to use Puppet to affect the current -# state. -# -# By default, you must at least provide a type to list, which case puppet resource -# will tell you everything it knows about all instances of that type. You can -# optionally specify an instance name, and puppet resource will only describe that single -# instance. -# -# You can also add +--edit+ as an argument, and puppet resource will write its output -# to a file, open that file in an editor, and then apply the file as a Puppet -# transaction. You can easily use this to use Puppet to make simple changes to -# a system. -# -# = Options -# -# Note that any configuration parameter that's valid in the configuration file -# is also a valid long argument. For example, 'ssldir' is a valid configuration -# parameter, so you can specify '--ssldir ' as an argument. -# -# See the configuration file documentation at -# http://docs.puppetlabs.com/references/stable/configuration.html for -# the full list of acceptable parameters. A commented list of all -# configuration options can also be generated by running puppet with -# '--genconfig'. -# -# debug:: -# Enable full debugging. -# -# edit: -# Write the results of the query to a file, open the file in an editor, -# and read the file back in as an executable Puppet manifest. -# -# host: -# When specified, connect to the resource server on the named host -# and retrieve the list of resouces of the type specified. -# -# help: -# Print this help message. -# -# param: -# Add more parameters to be outputted from queries. -# -# types: -# List all available types. -# -# verbose: -# Print extra information. -# -# = Example -# -# This example uses `puppet resource` to return Puppet configuration for the user `luke`: -# -# $ puppet resource user luke -# user { 'luke': -# home => '/home/luke', -# uid => '100', -# ensure => 'present', -# comment => 'Luke Kanies,,,', -# gid => '1000', -# shell => '/bin/bash', -# groups => ['sysadmin','audio','video','puppet'] -# } -# -# = Author -# -# Luke Kanies -# -# = Copyright -# -# Copyright (c) 2005-2007 Puppet Labs, LLC -# Licensed under the GNU Public License - -#Puppet::Application[:resource].run diff --git a/lib/puppet/util/execution.rb b/lib/puppet/util/execution.rb index dd820f856..69f4f2c15 100644 --- a/lib/puppet/util/execution.rb +++ b/lib/puppet/util/execution.rb @@ -1,21 +1,20 @@ module Puppet::Util::Execution module_function # Run some code with a specific environment. Resets the environment back to # what it was at the end of the code. def withenv(hash) - oldvals = {} + saved = ENV.to_hash hash.each do |name, val| - name = name.to_s - oldvals[name] = ENV[name] - ENV[name] = val + ENV[name.to_s] = val end yield ensure - oldvals.each do |name, val| + ENV.clear + saved.each do |name, val| ENV[name] = val end end end diff --git a/lib/puppet/util/execution_stub.rb b/lib/puppet/util/execution_stub.rb new file mode 100644 index 000000000..af74e0f72 --- /dev/null +++ b/lib/puppet/util/execution_stub.rb @@ -0,0 +1,26 @@ +module Puppet::Util + class ExecutionStub + class << self + # Set a stub block that Puppet::Util.execute() should invoke instead + # of actually executing commands on the target machine. Intended + # for spec testing. + # + # The arguments passed to the block are |command, options|, where + # command is an array of strings and options is an options hash. + def set(&block) + @value = block + end + + # Uninstall any execution stub, so that calls to + # Puppet::Util.execute() behave normally again. + def reset + @value = nil + end + + # Retrieve the current execution stub, or nil if there is no stub. + def current_value + @value + end + end + end +end diff --git a/lib/puppet/util/log.rb b/lib/puppet/util/log.rb index 2f9f356bb..d34fbaf55 100644 --- a/lib/puppet/util/log.rb +++ b/lib/puppet/util/log.rb @@ -1,259 +1,265 @@ require 'puppet/util/tagging' require 'puppet/util/classgen' # Pass feedback to the user. Log levels are modeled after syslog's, and it is # expected that that will be the most common log destination. Supports # multiple destinations, one of which is a remote server. class Puppet::Util::Log include Puppet::Util extend Puppet::Util::ClassGen include Puppet::Util::Tagging @levels = [:debug,:info,:notice,:warning,:err,:alert,:emerg,:crit] @loglevel = 2 @desttypes = {} # Create a new destination type. def self.newdesttype(name, options = {}, &block) dest = genclass( name, :parent => Puppet::Util::Log::Destination, :prefix => "Dest", :block => block, :hash => @desttypes, :attributes => options ) dest.match(dest.name) dest end require 'puppet/util/log/destination' require 'puppet/util/log/destinations' @destinations = {} @queued = [] class << self include Puppet::Util include Puppet::Util::ClassGen attr_reader :desttypes end # Reset log to basics. Basically just flushes and closes files and # undefs other objects. def Log.close(destination) if @destinations.include?(destination) @destinations[destination].flush if @destinations[destination].respond_to?(:flush) @destinations[destination].close if @destinations[destination].respond_to?(:close) @destinations.delete(destination) end end def self.close_all destinations.keys.each { |dest| close(dest) } raise Puppet::DevError.new("Log.close_all failed to close #{@destinations.keys.inspect}") if !@destinations.empty? end # Flush any log destinations that support such operations. def Log.flush @destinations.each { |type, dest| dest.flush if dest.respond_to?(:flush) } end + def Log.autoflush=(v) + @destinations.each do |type, dest| + dest.autoflush = v if dest.respond_to?(:autoflush=) + end + end + # Create a new log message. The primary role of this method is to # avoid creating log messages below the loglevel. def Log.create(hash) raise Puppet::DevError, "Logs require a level" unless hash.include?(:level) raise Puppet::DevError, "Invalid log level #{hash[:level]}" unless @levels.index(hash[:level]) @levels.index(hash[:level]) >= @loglevel ? Puppet::Util::Log.new(hash) : nil end def Log.destinations @destinations end # Yield each valid level in turn def Log.eachlevel @levels.each { |level| yield level } end # Return the current log level. def Log.level @levels[@loglevel] end # Set the current log level. def Log.level=(level) level = level.intern unless level.is_a?(Symbol) raise Puppet::DevError, "Invalid loglevel #{level}" unless @levels.include?(level) @loglevel = @levels.index(level) end def Log.levels @levels.dup end # Create a new log destination. def Log.newdestination(dest) # Each destination can only occur once. if @destinations.find { |name, obj| obj.name == dest } return end name, type = @desttypes.find do |name, klass| klass.match?(dest) end raise Puppet::DevError, "Unknown destination type #{dest}" unless type begin if type.instance_method(:initialize).arity == 1 @destinations[dest] = type.new(dest) else @destinations[dest] = type.new end flushqueue @destinations[dest] rescue => detail puts detail.backtrace if Puppet[:debug] # If this was our only destination, then add the console back in. newdestination(:console) if @destinations.empty? and (dest != :console and dest != "console") end end # Route the actual message. FIXME There are lots of things this method # should do, like caching and a bit more. It's worth noting that there's # a potential for a loop here, if the machine somehow gets the destination set as # itself. def Log.newmessage(msg) return if @levels.index(msg.level) < @loglevel queuemessage(msg) if @destinations.length == 0 @destinations.each do |name, dest| threadlock(dest) do dest.handle(msg) end end end def Log.queuemessage(msg) @queued.push(msg) end def Log.flushqueue return unless @destinations.size >= 1 @queued.each do |msg| Log.newmessage(msg) end @queued.clear end def Log.sendlevel?(level) @levels.index(level) >= @loglevel end # Reopen all of our logs. def Log.reopen Puppet.notice "Reopening log files" types = @destinations.keys @destinations.each { |type, dest| dest.close if dest.respond_to?(:close) } @destinations.clear # We need to make sure we always end up with some kind of destination begin types.each { |type| Log.newdestination(type) } rescue => detail if @destinations.empty? Log.newdestination(:syslog) Puppet.err detail.to_s end end end # Is the passed level a valid log level? def self.validlevel?(level) @levels.include?(level) end attr_accessor :time, :remote, :file, :line, :source attr_reader :level, :message def initialize(args) self.level = args[:level] self.message = args[:message] self.source = args[:source] || "Puppet" @time = Time.now if tags = args[:tags] tags.each { |t| self.tag(t) } end [:file, :line].each do |attr| next unless value = args[attr] send(attr.to_s + "=", value) end Log.newmessage(self) end def message=(msg) raise ArgumentError, "Puppet::Util::Log requires a message" unless msg @message = msg.to_s end def level=(level) raise ArgumentError, "Puppet::Util::Log requires a log level" unless level @level = level.to_sym raise ArgumentError, "Invalid log level #{@level}" unless self.class.validlevel?(@level) # Tag myself with my log level tag(level) end # If they pass a source in to us, we make sure it is a string, and # we retrieve any tags we can. def source=(source) if source.respond_to?(:source_descriptors) descriptors = source.source_descriptors @source = descriptors[:path] descriptors[:tags].each { |t| tag(t) } [:file, :line].each do |param| next unless descriptors[param] send(param.to_s + "=", descriptors[param]) end else @source = source.to_s end end def to_report "#{time} #{source} (#{level}): #{to_s}" end def to_s message end end # This is for backward compatibility from when we changed the constant to Puppet::Util::Log # because the reports include the constant name. Apparently the alias was created in # March 2007, should could probably be removed soon. Puppet::Log = Puppet::Util::Log diff --git a/lib/puppet/util/log/destinations.rb b/lib/puppet/util/log/destinations.rb index 2e2f9a5b7..dd0d996bf 100644 --- a/lib/puppet/util/log/destinations.rb +++ b/lib/puppet/util/log/destinations.rb @@ -1,229 +1,231 @@ Puppet::Util::Log.newdesttype :syslog do def close Syslog.close end def initialize Syslog.close if Syslog.opened? name = Puppet[:name] name = "puppet-#{name}" unless name =~ /puppet/ options = Syslog::LOG_PID | Syslog::LOG_NDELAY # XXX This should really be configurable. str = Puppet[:syslogfacility] begin facility = Syslog.const_get("LOG_#{str.upcase}") rescue NameError raise Puppet::Error, "Invalid syslog facility #{str}" end @syslog = Syslog.open(name, options, facility) end def handle(msg) # XXX Syslog currently has a bug that makes it so you # cannot log a message with a '%' in it. So, we get rid # of them. if msg.source == "Puppet" @syslog.send(msg.level, msg.to_s.gsub("%", '%%')) else @syslog.send(msg.level, "(%s) %s" % [msg.source.to_s.gsub("%", ""), msg.to_s.gsub("%", '%%') ] ) end end end Puppet::Util::Log.newdesttype :file do match(/^\//) def close if defined?(@file) @file.close @file = nil end end def flush @file.flush if defined?(@file) end + attr_accessor :autoflush + def initialize(path) @name = path # first make sure the directory exists # We can't just use 'Config.use' here, because they've # specified a "special" destination. unless FileTest.exist?(File.dirname(path)) Puppet.recmkdir(File.dirname(path)) Puppet.info "Creating log directory #{File.dirname(path)}" end # create the log file, if it doesn't already exist file = File.open(path, File::WRONLY|File::CREAT|File::APPEND) @file = file @autoflush = Puppet[:autoflush] end def handle(msg) @file.puts("#{msg.time} #{msg.source} (#{msg.level}): #{msg}") @file.flush if @autoflush end end Puppet::Util::Log.newdesttype :console do RED = {:console => "", :html => "FFA0A0"} GREEN = {:console => "", :html => "00CD00"} YELLOW = {:console => "", :html => "FFFF60"} BLUE = {:console => "", :html => "80A0FF"} PURPLE = {:console => "", :html => "FFA500"} CYAN = {:console => "", :html => "40FFFF"} WHITE = {:console => "", :html => "FFFFFF"} HRED = {:console => "", :html => "FFA0A0"} HGREEN = {:console => "", :html => "00CD00"} HYELLOW = {:console => "", :html => "FFFF60"} HBLUE = {:console => "", :html => "80A0FF"} HPURPLE = {:console => "", :html => "FFA500"} HCYAN = {:console => "", :html => "40FFFF"} HWHITE = {:console => "", :html => "FFFFFF"} RESET = {:console => "", :html => "" } @@colormap = { :debug => WHITE, :info => GREEN, :notice => CYAN, :warning => YELLOW, :err => HPURPLE, :alert => RED, :emerg => HRED, :crit => HRED } def colorize(level, str) case Puppet[:color] when true, :ansi, "ansi", "yes"; console_color(level, str) when :html, "html"; html_color(level, str) else str end end def console_color(level, str) @@colormap[level][:console] + str + RESET[:console] end def html_color(level, str) %{%s} % [@@colormap[level][:html], str] end def initialize # Flush output immediately. $stdout.sync = true end def handle(msg) if msg.source == "Puppet" puts colorize(msg.level, "#{msg.level}: #{msg}") else puts colorize(msg.level, "#{msg.level}: #{msg.source}: #{msg}") end end end Puppet::Util::Log.newdesttype :host do def initialize(host) Puppet.info "Treating #{host} as a hostname" args = {} if host =~ /:(\d+)/ args[:Port] = $1 args[:Server] = host.sub(/:\d+/, '') else args[:Server] = host end @name = host @driver = Puppet::Network::Client::LogClient.new(args) end def handle(msg) unless msg.is_a?(String) or msg.remote @hostname ||= Facter["hostname"].value unless defined?(@domain) @domain = Facter["domain"].value @hostname += ".#{@domain}" if @domain end if msg.source =~ /^\// msg.source = @hostname + ":#{msg.source}" elsif msg.source == "Puppet" msg.source = @hostname + " #{msg.source}" else msg.source = @hostname + " #{msg.source}" end begin #puts "would have sent #{msg}" #puts "would have sent %s" % # CGI.escape(YAML.dump(msg)) begin tmp = CGI.escape(YAML.dump(msg)) rescue => detail puts "Could not dump: #{detail}" return end # Add the hostname to the source @driver.addlog(tmp) rescue => detail puts detail.backtrace if Puppet[:trace] Puppet.err detail Puppet::Util::Log.close(self) end end end end # Log to a transaction report. Puppet::Util::Log.newdesttype :report do attr_reader :report match "Puppet::Transaction::Report" def initialize(report) @report = report end def handle(msg) @report << msg end end # Log to an array, just for testing. module Puppet::Test class LogCollector def initialize(logs) @logs = logs end def <<(value) @logs << value end end end Puppet::Util::Log.newdesttype :array do match "Puppet::Test::LogCollector" def initialize(messages) @messages = messages end def handle(msg) @messages << msg end end diff --git a/lib/puppet/util/monkey_patches.rb b/lib/puppet/util/monkey_patches.rb index 1c35ae523..a93c66b07 100644 --- a/lib/puppet/util/monkey_patches.rb +++ b/lib/puppet/util/monkey_patches.rb @@ -1,73 +1,92 @@ unless defined? JRUBY_VERSION Process.maxgroups = 1024 end module RDoc def self.caller(skip=nil) in_gem_wrapper = false Kernel.caller.reject { |call| in_gem_wrapper ||= call =~ /#{Regexp.escape $0}:\d+:in `load'/ } end end require "yaml" require "puppet/util/zaml.rb" class Symbol def to_zaml(z) z.emit("!ruby/sym ") to_s.to_zaml(z) end + def <=> (other) + self.to_s <=> other.to_s + end end [Object, Exception, Integer, Struct, Date, Time, Range, Regexp, Hash, Array, Float, String, FalseClass, TrueClass, Symbol, NilClass, Class].each { |cls| cls.class_eval do def to_yaml(ignored=nil) ZAML.dump(self) end end } def YAML.dump(*args) ZAML.dump(*args) end # # Workaround for bug in MRI 1.8.7, see # http://redmine.ruby-lang.org/issues/show/2708 # for details # if RUBY_VERSION == '1.8.7' class NilClass def closed? true end end end - class Object # ActiveSupport 2.3.x mixes in a dangerous method # that can cause rspec to fork bomb # and other strange things like that. def daemonize raise NotImplementedError, "Kernel.daemonize is too dangerous, please don't try to use it." end + + # The following code allows callers to make assertions that are only + # checked when the environment variable PUPPET_ENABLE_ASSERTIONS is + # set to a non-empty string. For example: + # + # assert_that { condition } + # assert_that(message) { condition } + if ENV["PUPPET_ENABLE_ASSERTIONS"].to_s != '' + def assert_that(message = nil) + unless yield + raise Exception.new("Assertion failure: #{message}") + end + end + else + def assert_that(message = nil) + end + end end # Workaround for yaml_initialize, which isn't supported before Ruby # 1.8.3. if RUBY_VERSION == '1.8.1' || RUBY_VERSION == '1.8.2' YAML.add_ruby_type( /^object/ ) { |tag, val| type, obj_class = YAML.read_type_class( tag, Object ) r = YAML.object_maker( obj_class, val ) if r.respond_to? :yaml_initialize r.instance_eval { instance_variables.each { |name| remove_instance_variable name } } r.yaml_initialize(tag, val) end r } end diff --git a/lib/puppet/util/rdoc.rb b/lib/puppet/util/rdoc.rb index bdac579d6..c00bc6f85 100644 --- a/lib/puppet/util/rdoc.rb +++ b/lib/puppet/util/rdoc.rb @@ -1,92 +1,86 @@ module Puppet::Util::RDoc module_function # launch a rdoc documenation process # with the files/dir passed in +files+ def rdoc(outputdir, files, charset = nil) Puppet[:ignoreimport] = true # then rdoc require 'rdoc/rdoc' require 'rdoc/options' # load our parser require 'puppet/util/rdoc/parser' r = RDoc::RDoc.new RDoc::RDoc::GENERATORS["puppet"] = RDoc::RDoc::Generator.new( "puppet/util/rdoc/generators/puppet_generator.rb", "PuppetGenerator".intern, "puppet") # specify our own format & where to output options = [ "--fmt", "puppet", "--quiet", "--exclude", "/modules/[^/]*/files/.*\.pp$", "--op", outputdir ] options << "--force-update" if Options::OptionList.options.any? { |o| o[0] == "--force-update" } options += [ "--charset", charset] if charset options += files + #TODO dedup file paths (not strict duplication sense, parents, children, etc # launch the documentation process r.document(options) rescue RDoc::RDocError => e raise Puppet::ParseError.new("RDoc error #{e}") end # launch a output to console manifest doc def manifestdoc(files) Puppet[:ignoreimport] = true files.select { |f| FileTest.file?(f) }.each do |f| parser = Puppet::Parser::Parser.new(Puppet::Node::Environment.new(Puppet[:environment])) parser.file = f ast = parser.parse output(f, ast) end end # Ouputs to the console the documentation # of a manifest def output(file, ast) astobj = [] - ast.nodes.each do |name, k| - astobj << k if k.file == file + ast.instantiate('').each do |resource_type| + astobj << resource_type if resource_type.file == file end - ast.hostclasses.each do |name,k| - astobj << k if k.file == file - end - - ast.definitions.each do |name, k| - astobj << k if k.file == file - end astobj.sort! {|a,b| a.line <=> b.line }.each do |k| output_astnode_doc(k) end end def output_astnode_doc(ast) puts ast.doc if !ast.doc.nil? and !ast.doc.empty? if Puppet.settings[:document_all] # scan each underlying resources to produce documentation code = ast.code.children if ast.code.is_a?(Puppet::Parser::AST::ASTArray) code ||= ast.code output_resource_doc(code) unless code.nil? end end def output_resource_doc(code) code.sort { |a,b| a.line <=> b.line }.each do |stmt| output_resource_doc(stmt.children) if stmt.is_a?(Puppet::Parser::AST::ASTArray) if stmt.is_a?(Puppet::Parser::AST::Resource) puts stmt.doc if !stmt.doc.nil? and !stmt.doc.empty? end end end -end \ No newline at end of file +end diff --git a/lib/puppet/util/rdoc/code_objects.rb b/lib/puppet/util/rdoc/code_objects.rb index 3854fbc01..3c789a0c5 100644 --- a/lib/puppet/util/rdoc/code_objects.rb +++ b/lib/puppet/util/rdoc/code_objects.rb @@ -1,241 +1,280 @@ require 'rdoc/code_objects' module RDoc # This modules contains various class that are used to hold information # about the various Puppet language structures we found while parsing. # # Those will be mapped to their html counterparts which are defined in # PuppetGenerator. # PuppetTopLevel is a top level (usually a .pp/.rb file) class PuppetTopLevel < TopLevel attr_accessor :module_name, :global # will contain all plugins @@all_plugins = {} # contains all cutoms facts @@all_facts = {} def initialize(toplevel) super(toplevel.file_relative_name) end def self.all_plugins @@all_plugins.values end def self.all_facts @@all_facts.values end end # PuppetModule holds a Puppet Module # This is mapped to an HTMLPuppetModule # it leverage the RDoc (ruby) module infrastructure class PuppetModule < NormalModule attr_accessor :facts, :plugins def initialize(name,superclass=nil) @facts = [] @plugins = [] super(name,superclass) end def initialize_classes_and_modules super @nodes = {} end def add_plugin(plugin) add_to(@plugins, plugin) end def add_fact(fact) add_to(@facts, fact) end def add_node(name,superclass) cls = @nodes[name] unless cls cls = PuppetNode.new(name, superclass) @nodes[name] = cls if !@done_documenting cls.parent = self cls.section = @current_section end cls end def each_fact @facts.each {|c| yield c} end def each_plugin @plugins.each {|c| yield c} end def each_node @nodes.each {|c| yield c} end def nodes @nodes.values end end # PuppetClass holds a puppet class # It is mapped to a HTMLPuppetClass for display # It leverages RDoc (ruby) Class class PuppetClass < ClassModule attr_accessor :resource_list, :requires, :childs, :realizes def initialize(name, superclass) super(name,superclass) @resource_list = [] @requires = [] @realizes = [] @childs = [] end def add_resource(resource) add_to(@resource_list, resource) end def is_module? false end def superclass=(superclass) @superclass = superclass end # we're (ab)using the RDoc require system here. # we're adding a required Puppet class, overriding # the RDoc add_require method which sees ruby required files. def add_require(required) add_to(@requires, required) end def add_realize(realized) add_to(@realizes, realized) end def add_child(child) @childs << child end + + # Look up the given symbol. RDoc only looks for class1::class2.method + # or class1::class2#method. Since our definitions are mapped to RDoc methods + # but are written class1::class2::define we need to perform the lookup by + # ourselves. + def find_symbol(symbol, method=nil) + result = super + if not result and symbol =~ /::/ + modules = symbol.split(/::/) + unless modules.empty? + module_name = modules.shift + result = find_module_named(module_name) + if result + last_name = "" + previous = nil + modules.each do |module_name| + previous = result + last_name = module_name + result = result.find_module_named(module_name) + break unless result + end + unless result + result = previous + method = last_name + end + end + end + if result && method + if !result.respond_to?(:find_local_symbol) + p result.name + p method + fail + end + result = result.find_local_symbol(method) + end + end + result + end + end # PuppetNode holds a puppet node # It is mapped to a HTMLPuppetNode for display # A node is just a variation of a class class PuppetNode < PuppetClass def initialize(name, superclass) super(name,superclass) end def is_module? false end end # Plugin holds a native puppet plugin (function,type...) # It is mapped to a HTMLPuppetPlugin for display class Plugin < Context attr_accessor :name, :type def initialize(name, type) super() @name = name @type = type @comment = "" end def <=>(other) @name <=> other.name end def full_name @name end def http_url(prefix) path = full_name.split("::") File.join(prefix, *path) + ".html" end def is_fact? false end def to_s res = self.class.name + ": #{@name} (#{@type})\n" res << @comment.to_s res end end # Fact holds a custom fact # It is mapped to a HTMLPuppetPlugin for display class Fact < Context attr_accessor :name, :confine def initialize(name, confine) super() @name = name @confine = confine @comment = "" end def <=>(other) @name <=> other.name end def is_fact? true end def full_name @name end def to_s res = self.class.name + ": #{@name}\n" res << @comment.to_s res end end # PuppetResource holds a puppet resource # It is mapped to a HTMLPuppetResource for display # A resource is defined by its "normal" form Type[title] class PuppetResource < CodeObject attr_accessor :type, :title, :params def initialize(type, title, comment, params) super() @type = type @title = title @comment = comment @params = params end def <=>(other) full_name <=> other.full_name end def full_name @type + "[#{@title}]" end def name full_name end def to_s res = @type + "[#{@title}]\n" res << @comment.to_s res end end end diff --git a/lib/puppet/util/rdoc/generators/puppet_generator.rb b/lib/puppet/util/rdoc/generators/puppet_generator.rb index e6bbb2e1e..249c9a8ba 100644 --- a/lib/puppet/util/rdoc/generators/puppet_generator.rb +++ b/lib/puppet/util/rdoc/generators/puppet_generator.rb @@ -1,893 +1,911 @@ require 'rdoc/generators/html_generator' require 'puppet/util/rdoc/code_objects' require 'digest/md5' module Generators # This module holds all the classes needed to generate the HTML documentation # of a bunch of puppet manifests. # # It works by traversing all the code objects defined by the Puppet RDoc::Parser # and produces HTML counterparts objects that in turns are used by RDoc template engine # to produce the final HTML. # # It is also responsible of creating the whole directory hierarchy, and various index # files. # # It is to be noted that the whole system is built on top of ruby RDoc. As such there # is an implicit mapping of puppet entities to ruby entitites: # # Puppet => Ruby # ------------------------ # Module Module # Class Class # Definition Method # Resource # Node # Plugin # Fact MODULE_DIR = "modules" NODE_DIR = "nodes" PLUGIN_DIR = "plugins" + # We're monkey patching RDoc markup to allow + # lowercase class1::class2::class3 crossref hyperlinking + module MarkUp + alias :old_markup :markup + + def new_markup(str, remove_para=false) + first = @markup.nil? + res = old_markup(str, remove_para) + if first and not @markup.nil? + @markup.add_special(/\b([a-z]\w+(::\w+)*)/,:CROSSREF) + # we need to call it again, since we added a rule + res = old_markup(str, remove_para) + end + res + end + alias :markup :new_markup + end + # This is a specialized HTMLGenerator tailored to Puppet manifests class PuppetGenerator < HTMLGenerator def PuppetGenerator.for(options) AllReferences::reset HtmlMethod::reset if options.all_one_file PuppetGeneratorInOne.new(options) else PuppetGenerator.new(options) end end def initialize(options) #:not-new: @options = options load_html_template end # loads our own html template file def load_html_template require 'puppet/util/rdoc/generators/template/puppet/puppet' extend RDoc::Page rescue LoadError $stderr.puts "Could not find Puppet template '#{template}'" exit 99 end def gen_method_index # we don't generate an all define index # as the presentation is per module/per class end # This is the central method, it generates the whole structures # along with all the indices. def generate_html super gen_into(@nodes) gen_into(@plugins) end ## # Generate: # the list of modules # the list of classes and definitions of a specific module # the list of all classes # the list of nodes # the list of resources def build_indices @allfiles = [] @nodes = [] @plugins = [] # contains all the seen modules @modules = {} @allclasses = {} # remove unknown toplevels # it can happen that RDoc triggers a different parser for some files (ie .c, .cc or .h) # in this case RDoc generates a RDoc::TopLevel which we do not support in this generator # So let's make sure we don't generate html for those. @toplevels = @toplevels.select { |tl| tl.is_a? RDoc::PuppetTopLevel } # build the modules, classes and per modules classes and define list @toplevels.each do |toplevel| next unless toplevel.document_self file = HtmlFile.new(toplevel, @options, FILE_DIR) classes = [] methods = [] modules = [] nodes = [] # find all classes of this toplevel # store modules if we find one toplevel.each_classmodule do |k| generate_class_list(classes, modules, k, toplevel, CLASS_DIR) end # find all defines belonging to this toplevel HtmlMethod.all_methods.each do |m| # find parent module, check this method is not already # defined. if m.context.parent.toplevel === toplevel methods << m end end classes.each do |k| @allclasses[k.index_name] = k if !@allclasses.has_key?(k.index_name) end # generate nodes and plugins found classes.each do |k| if k.context.is_module? k.context.each_node do |name,node| nodes << HTMLPuppetNode.new(node, toplevel, NODE_DIR, @options) @nodes << nodes.last end k.context.each_plugin do |plugin| @plugins << HTMLPuppetPlugin.new(plugin, toplevel, PLUGIN_DIR, @options) end k.context.each_fact do |fact| @plugins << HTMLPuppetPlugin.new(fact, toplevel, PLUGIN_DIR, @options) end end end @files << file @allfiles << { "file" => file, "modules" => modules, "classes" => classes, "methods" => methods, "nodes" => nodes } end # scan all classes to create the childs references @allclasses.values.each do |klass| if superklass = klass.context.superclass if superklass = AllReferences[superklass] and (superklass.is_a?(HTMLPuppetClass) or superklass.is_a?(HTMLPuppetNode)) superklass.context.add_child(klass.context) end end end @classes = @allclasses.values end # produce a class/module list of HTMLPuppetModule/HTMLPuppetClass # based on the code object traversal. def generate_class_list(classes, modules, from, html_file, class_dir) if from.is_module? and !@modules.has_key?(from.name) k = HTMLPuppetModule.new(from, html_file, class_dir, @options) classes << k @modules[from.name] = k modules << @modules[from.name] elsif from.is_module? modules << @modules[from.name] elsif !from.is_module? k = HTMLPuppetClass.new(from, html_file, class_dir, @options) classes << k end from.each_classmodule do |mod| generate_class_list(classes, modules, mod, html_file, class_dir) end end # generate all the subdirectories, modules, classes and files def gen_sub_directories super File.makedirs(MODULE_DIR) File.makedirs(NODE_DIR) File.makedirs(PLUGIN_DIR) rescue $stderr.puts $ERROR_INFO.message exit 1 end # generate the index of modules def gen_file_index gen_top_index(@modules.values, 'All Modules', RDoc::Page::TOP_INDEX, "fr_modules_index.html") end # generate a top index def gen_top_index(collection, title, template, filename) template = TemplatePage.new(RDoc::Page::FR_INDEX_BODY, template) res = [] collection.sort.each do |f| if f.document_self res << { "classlist" => CGI.escapeHTML("#{MODULE_DIR}/fr_#{f.index_name}.html"), "module" => CGI.escapeHTML("#{CLASS_DIR}/#{f.index_name}.html"),"name" => CGI.escapeHTML(f.index_name) } end end values = { "entries" => res, 'list_title' => CGI.escapeHTML(title), 'index_url' => main_url, 'charset' => @options.charset, 'style_url' => style_url('', @options.css), } File.open(filename, "w") do |f| template.write_html_on(f, values) end end # generate the all classes index file and the combo index def gen_class_index gen_an_index(@classes, 'All Classes', RDoc::Page::CLASS_INDEX, "fr_class_index.html") @allfiles.each do |file| unless file['file'].context.file_relative_name =~ /\.rb$/ gen_composite_index( file, RDoc::Page::COMBO_INDEX, "#{MODULE_DIR}/fr_#{file["file"].context.module_name}.html") end end end def gen_composite_index(collection, template, filename)\ return if FileTest.exists?(filename) template = TemplatePage.new(RDoc::Page::FR_INDEX_BODY, template) res1 = [] collection['classes'].sort.each do |f| if f.document_self res1 << { "href" => "../"+CGI.escapeHTML(f.path), "name" => CGI.escapeHTML(f.index_name) } unless f.context.is_module? end end res2 = [] collection['methods'].sort.each do |f| res2 << { "href" => "../#{f.path}", "name" => f.index_name.sub(/\(.*\)$/,'') } if f.document_self end module_name = [] res3 = [] res4 = [] collection['modules'].sort.each do |f| module_name << { "href" => "../"+CGI.escapeHTML(f.path), "name" => CGI.escapeHTML(f.index_name) } unless f.facts.nil? f.facts.each do |fact| res3 << {"href" => "../"+CGI.escapeHTML(AllReferences["PLUGIN(#{fact.name})"].path), "name" => CGI.escapeHTML(fact.name)} end end unless f.plugins.nil? f.plugins.each do |plugin| res4 << {"href" => "../"+CGI.escapeHTML(AllReferences["PLUGIN(#{plugin.name})"].path), "name" => CGI.escapeHTML(plugin.name)} end end end res5 = [] collection['nodes'].sort.each do |f| res5 << { "href" => "../"+CGI.escapeHTML(f.path), "name" => CGI.escapeHTML(f.name) } if f.document_self end values = { "module" => module_name, "classes" => res1, 'classes_title' => CGI.escapeHTML("Classes"), 'defines_title' => CGI.escapeHTML("Defines"), 'facts_title' => CGI.escapeHTML("Custom Facts"), 'plugins_title' => CGI.escapeHTML("Plugins"), 'nodes_title' => CGI.escapeHTML("Nodes"), 'index_url' => main_url, 'charset' => @options.charset, 'style_url' => style_url('', @options.css), } values["defines"] = res2 if res2.size>0 values["facts"] = res3 if res3.size>0 values["plugins"] = res4 if res4.size>0 values["nodes"] = res5 if res5.size>0 File.open(filename, "w") do |f| template.write_html_on(f, values) end end # returns the initial_page url def main_url main_page = @options.main_page ref = nil if main_page ref = AllReferences[main_page] if ref ref = ref.path else $stderr.puts "Could not find main page #{main_page}" end end unless ref for file in @files if file.document_self and file.context.global ref = CGI.escapeHTML("#{CLASS_DIR}/#{file.context.module_name}.html") break end end end unless ref for file in @files if file.document_self and !file.context.global ref = CGI.escapeHTML("#{CLASS_DIR}/#{file.context.module_name}.html") break end end end unless ref $stderr.puts "Couldn't find anything to document" $stderr.puts "Perhaps you've used :stopdoc: in all classes" exit(1) end ref end end # This module is used to generate a referenced full name list of ContextUser module ReferencedListBuilder def build_referenced_list(list) res = [] list.each do |i| ref = AllReferences[i.name] || @context.find_symbol(i.name) ref = ref.viewer if ref and ref.respond_to?(:viewer) name = i.respond_to?(:full_name) ? i.full_name : i.name h_name = CGI.escapeHTML(name) if ref and ref.document_self path = url(ref.path) res << { "name" => h_name, "aref" => path } else res << { "name" => h_name } end end res end end # This module is used to hold/generate a list of puppet resources # this is used in HTMLPuppetClass and HTMLPuppetNode module ResourceContainer def collect_resources list = @context.resource_list @resources = list.collect {|m| HTMLPuppetResource.new(m, self, @options) } end def build_resource_summary_list(path_prefix='') collect_resources unless @resources resources = @resources.sort res = [] resources.each do |r| res << { "name" => CGI.escapeHTML(r.name), "aref" => CGI.escape(path_prefix)+"\#"+CGI.escape(r.aref) } end res end def build_resource_detail_list(section) outer = [] resources = @resources.sort resources.each do |r| row = {} if r.section == section and r.document_self row["name"] = CGI.escapeHTML(r.name) desc = r.description.strip row["m_desc"] = desc unless desc.empty? row["aref"] = r.aref row["params"] = r.params outer << row end end outer end end class HTMLPuppetClass < HtmlClass include ResourceContainer, ReferencedListBuilder def value_hash super rl = build_resource_summary_list @values["resources"] = rl unless rl.empty? @context.sections.each do |section| secdata = @values["sections"].select { |secdata| secdata["secsequence"] == section.sequence } if secdata.size == 1 secdata = secdata[0] rdl = build_resource_detail_list(section) secdata["resource_list"] = rdl unless rdl.empty? end end rl = build_require_list(@context) @values["requires"] = rl unless rl.empty? rl = build_realize_list(@context) @values["realizes"] = rl unless rl.empty? cl = build_child_list(@context) @values["childs"] = cl unless cl.empty? @values end def build_require_list(context) build_referenced_list(context.requires) end def build_realize_list(context) build_referenced_list(context.realizes) end def build_child_list(context) build_referenced_list(context.childs) end end class HTMLPuppetNode < ContextUser include ResourceContainer, ReferencedListBuilder attr_reader :path def initialize(context, html_file, prefix, options) super(context, options) @html_file = html_file @is_module = context.is_module? @values = {} context.viewer = self if options.all_one_file @path = context.full_name else @path = http_url(context.full_name, prefix) end AllReferences.add("NODE(#{@context.full_name})", self) end def name @context.name end # return the relative file name to store this class in, # which is also its url def http_url(full_name, prefix) path = full_name.dup path.gsub!(/<<\s*(\w*)/) { "from-#$1" } if path['<<'] File.join(prefix, path.split("::").collect { |p| Digest::MD5.hexdigest(p) }) + ".html" end def parent_name @context.parent.full_name end def index_name name end def write_on(f) value_hash template = TemplatePage.new( RDoc::Page::BODYINC, RDoc::Page::NODE_PAGE, RDoc::Page::METHOD_LIST) template.write_html_on(f, @values) end def value_hash class_attribute_values add_table_of_sections @values["charset"] = @options.charset @values["style_url"] = style_url(path, @options.css) d = markup(@context.comment) @values["description"] = d unless d.empty? ml = build_method_summary_list @values["methods"] = ml unless ml.empty? rl = build_resource_summary_list @values["resources"] = rl unless rl.empty? il = build_include_list(@context) @values["includes"] = il unless il.empty? rl = build_require_list(@context) @values["requires"] = rl unless rl.empty? rl = build_realize_list(@context) @values["realizes"] = rl unless rl.empty? cl = build_child_list(@context) @values["childs"] = cl unless cl.empty? @values["sections"] = @context.sections.map do |section| secdata = { "sectitle" => section.title, "secsequence" => section.sequence, "seccomment" => markup(section.comment) } al = build_alias_summary_list(section) secdata["aliases"] = al unless al.empty? co = build_constants_summary_list(section) secdata["constants"] = co unless co.empty? al = build_attribute_list(section) secdata["attributes"] = al unless al.empty? cl = build_class_list(0, @context, section) secdata["classlist"] = cl unless cl.empty? mdl = build_method_detail_list(section) secdata["method_list"] = mdl unless mdl.empty? rdl = build_resource_detail_list(section) secdata["resource_list"] = rdl unless rdl.empty? secdata end @values end def build_attribute_list(section) atts = @context.attributes.sort res = [] atts.each do |att| next unless att.section == section if att.visibility == :public || att.visibility == :protected || @options.show_all entry = { "name" => CGI.escapeHTML(att.name), "rw" => att.rw, "a_desc" => markup(att.comment, true) } unless att.visibility == :public || att.visibility == :protected entry["rw"] << "-" end res << entry end end res end def class_attribute_values h_name = CGI.escapeHTML(name) @values["classmod"] = "Node" @values["title"] = CGI.escapeHTML("#{@values['classmod']}: #{h_name}") c = @context c = c.parent while c and !c.diagram @values["diagram"] = diagram_reference(c.diagram) if c && c.diagram @values["full_name"] = h_name parent_class = @context.superclass if parent_class @values["parent"] = CGI.escapeHTML(parent_class) if parent_name lookup = parent_name + "::#{parent_class}" else lookup = parent_class end lookup = "NODE(#{lookup})" parent_url = AllReferences[lookup] || AllReferences[parent_class] @values["par_url"] = aref_to(parent_url.path) if parent_url and parent_url.document_self end files = [] @context.in_files.each do |f| res = {} full_path = CGI.escapeHTML(f.file_absolute_name) res["full_path"] = full_path res["full_path_url"] = aref_to(f.viewer.path) if f.document_self res["cvsurl"] = cvs_url( @options.webcvs, full_path ) if @options.webcvs files << res end @values['infiles'] = files end def build_require_list(context) build_referenced_list(context.requires) end def build_realize_list(context) build_referenced_list(context.realizes) end def build_child_list(context) build_referenced_list(context.childs) end def <=>(other) self.name <=> other.name end end class HTMLPuppetModule < HtmlClass def initialize(context, html_file, prefix, options) super(context, html_file, prefix, options) end def value_hash @values = super fl = build_facts_summary_list @values["facts"] = fl unless fl.empty? pl = build_plugins_summary_list @values["plugins"] = pl unless pl.empty? nl = build_nodes_list(0, @context) @values["nodelist"] = nl unless nl.empty? @values end def build_nodes_list(level, context) res = "" prefix = "  ::" * level; context.nodes.sort.each do |node| if node.document_self res << prefix << "Node " << href(url(node.viewer.path), "link", node.full_name) << "
\n" end end res end def build_facts_summary_list potentially_referenced_list(context.facts) {|fn| ["PLUGIN(#{fn})"] } end def build_plugins_summary_list potentially_referenced_list(context.plugins) {|fn| ["PLUGIN(#{fn})"] } end def facts @context.facts end def plugins @context.plugins end end class HTMLPuppetPlugin < ContextUser attr_reader :path def initialize(context, html_file, prefix, options) super(context, options) @html_file = html_file @is_module = false @values = {} context.viewer = self if options.all_one_file @path = context.full_name else @path = http_url(context.full_name, prefix) end AllReferences.add("PLUGIN(#{@context.full_name})", self) end def name @context.name end # return the relative file name to store this class in, # which is also its url def http_url(full_name, prefix) path = full_name.dup path.gsub!(/<<\s*(\w*)/) { "from-#$1" } if path['<<'] File.join(prefix, path.split("::")) + ".html" end def parent_name @context.parent.full_name end def index_name name end def write_on(f) value_hash template = TemplatePage.new( RDoc::Page::BODYINC, RDoc::Page::PLUGIN_PAGE, RDoc::Page::PLUGIN_LIST) template.write_html_on(f, @values) end def value_hash attribute_values add_table_of_sections @values["charset"] = @options.charset @values["style_url"] = style_url(path, @options.css) d = markup(@context.comment) @values["description"] = d unless d.empty? if context.is_fact? unless context.confine.empty? res = {} res["type"] = context.confine[:type] res["value"] = context.confine[:value] @values["confine"] = [res] end else @values["type"] = context.type end @values["sections"] = @context.sections.map do |section| secdata = { "sectitle" => section.title, "secsequence" => section.sequence, "seccomment" => markup(section.comment) } secdata end @values end def attribute_values h_name = CGI.escapeHTML(name) if @context.is_fact? @values["classmod"] = "Fact" else @values["classmod"] = "Plugin" end @values["title"] = "#{@values['classmod']}: #{h_name}" c = @context @values["full_name"] = h_name files = [] @context.in_files.each do |f| res = {} full_path = CGI.escapeHTML(f.file_absolute_name) res["full_path"] = full_path res["full_path_url"] = aref_to(f.viewer.path) if f.document_self res["cvsurl"] = cvs_url( @options.webcvs, full_path ) if @options.webcvs files << res end @values['infiles'] = files end def <=>(other) self.name <=> other.name end end class HTMLPuppetResource include MarkUp attr_reader :context @@seq = "R000000" def initialize(context, html_class, options) @context = context @html_class = html_class @options = options @@seq = @@seq.succ @seq = @@seq context.viewer = self AllReferences.add(name, self) end def as_href(from_path) if @options.all_one_file "##{path}" else HTMLGenerator.gen_url(from_path, path) end end def name @context.name end def section @context.section end def index_name "#{@context.name}" end def params @context.params end def parent_name if @context.parent.parent @context.parent.parent.full_name else nil end end def aref @seq end def path if @options.all_one_file aref else @html_class.path + "##{aref}" end end def description markup(@context.comment) end def <=>(other) @context <=> other.context end def document_self @context.document_self end def find_symbol(symbol, method=nil) res = @context.parent.find_symbol(symbol, method) res &&= res.viewer end end class PuppetGeneratorInOne < HTMLGeneratorInOne def gen_method_index gen_an_index(HtmlMethod.all_methods, 'Defines') end end end diff --git a/lib/puppet/util/rdoc/parser.rb b/lib/puppet/util/rdoc/parser.rb index ce34442ab..0f746e2ea 100644 --- a/lib/puppet/util/rdoc/parser.rb +++ b/lib/puppet/util/rdoc/parser.rb @@ -1,485 +1,487 @@ # Puppet "parser" for the rdoc system # The parser uses puppet parser and traverse the AST to instruct RDoc about # our current structures. It also parses ruby files that could contain # either custom facts or puppet plugins (functions, types...) # rdoc mandatory includes require "rdoc/code_objects" require "puppet/util/rdoc/code_objects" require "rdoc/tokenstream" require "rdoc/markup/simple_markup/preprocess" require "rdoc/parsers/parserfactory" module RDoc class Parser extend ParserFactory SITE = "__site__" attr_accessor :input_file_name, :top_level # parser registration into RDoc parse_files_matching(/\.(rb|pp)$/) # called with the top level file def initialize(top_level, file_name, content, options, stats) @options = options @stats = stats @input_file_name = file_name @top_level = PuppetTopLevel.new(top_level) @progress = $stderr unless options.quiet end # main entry point def scan environment = Puppet::Node::Environment.new + @known_resource_types = environment.known_resource_types unless environment.known_resource_types.watching_file?(@input_file_name) Puppet.info "rdoc: scanning #{@input_file_name}" if @input_file_name =~ /\.pp$/ @parser = Puppet::Parser::Parser.new(environment) @parser.file = @input_file_name - @known_resource_types = environment.known_resource_types @parser.parse.instantiate('').each do |type| @known_resource_types.add type end - scan_top_level(@top_level) end end + + scan_top_level(@top_level) @top_level end # Due to a bug in RDoc, we need to roll our own find_module_named # The issue is that RDoc tries harder by asking the parent for a class/module # of the name. But by doing so, it can mistakenly use a module of same name # but from which we are not descendant. def find_object_named(container, name) return container if container.name == name container.each_classmodule do |m| return m if m.name == name end nil end # walk down the namespace and lookup/create container as needed def get_class_or_module(container, name) # class ::A -> A is in the top level if name =~ /^::/ container = @top_level end names = name.split('::') final_name = names.pop names.each do |name| prev_container = container container = find_object_named(container, name) container ||= prev_container.add_class(PuppetClass, name, nil) end [container, final_name] end # split_module tries to find if +path+ belongs to the module path # if it does, it returns the module name, otherwise if we are sure # it is part of the global manifest path, "__site__" is returned. # And finally if this path couldn't be mapped anywhere, nil is returned. def split_module(path) # find a module fullpath = File.expand_path(path) Puppet.debug "rdoc: testing #{fullpath}" if fullpath =~ /(.*)\/([^\/]+)\/(?:manifests|plugins|lib)\/.+\.(pp|rb)$/ modpath = $1 name = $2 Puppet.debug "rdoc: module #{name} into #{modpath} ?" Puppet::Module.modulepath.each do |mp| if File.identical?(modpath,mp) Puppet.debug "rdoc: found module #{name}" return name end end end if fullpath =~ /\.(pp|rb)$/ # there can be paths we don't want to scan under modules # imagine a ruby or manifest that would be distributed as part as a module # but we don't want those to be hosted under Puppet::Module.modulepath.each do |mp| # check that fullpath is a descendant of mp dirname = fullpath while (dirname = File.dirname(dirname)) != '/' return nil if File.identical?(dirname,mp) end end end # we are under a global manifests Puppet.debug "rdoc: global manifests" SITE end # create documentation for the top level +container+ def scan_top_level(container) # use the module README as documentation for the module comment = "" readme = File.join(File.dirname(File.dirname(@input_file_name)), "README") comment = File.open(readme,"r") { |f| f.read } if FileTest.readable?(readme) look_for_directives_in(container, comment) unless comment.empty? # infer module name from directory name = split_module(@input_file_name) if name.nil? # skip .pp files that are not in manifests directories as we can't guarantee they're part # of a module or the global configuration. container.document_self = false return end Puppet.debug "rdoc: scanning for #{name}" container.module_name = name container.global=true if name == SITE @stats.num_modules += 1 container, name = get_class_or_module(container,name) mod = container.add_module(PuppetModule, name) mod.record_location(@top_level) mod.comment = comment if @input_file_name =~ /\.pp$/ parse_elements(mod) elsif @input_file_name =~ /\.rb$/ parse_plugins(mod) end end # create documentation for include statements we can find in +code+ # and associate it with +container+ def scan_for_include_or_require(container, code) code = [code] unless code.is_a?(Array) code.each do |stmt| scan_for_include_or_require(container,stmt.children) if stmt.is_a?(Puppet::Parser::AST::ASTArray) if stmt.is_a?(Puppet::Parser::AST::Function) and ['include','require'].include?(stmt.name) stmt.arguments.each do |included| - Puppet.debug "found #{stmt.name}: #{included.value}" - container.send("add_#{stmt.name}",Include.new(included.value, stmt.doc)) + Puppet.debug "found #{stmt.name}: #{included}" + container.send("add_#{stmt.name}",Include.new(included.to_s, stmt.doc)) end end end end # create documentation for realize statements we can find in +code+ # and associate it with +container+ def scan_for_realize(container, code) code = [code] unless code.is_a?(Array) code.each do |stmt| scan_for_realize(container,stmt.children) if stmt.is_a?(Puppet::Parser::AST::ASTArray) if stmt.is_a?(Puppet::Parser::AST::Function) and stmt.name == 'realize' stmt.arguments.each do |realized| Puppet.debug "found #{stmt.name}: #{realized}" container.add_realize(Include.new(realized.to_s, stmt.doc)) end end end end # create documentation for global variables assignements we can find in +code+ # and associate it with +container+ def scan_for_vardef(container, code) code = [code] unless code.is_a?(Array) code.each do |stmt| scan_for_vardef(container,stmt.children) if stmt.is_a?(Puppet::Parser::AST::ASTArray) if stmt.is_a?(Puppet::Parser::AST::VarDef) Puppet.debug "rdoc: found constant: #{stmt.name} = #{stmt.value}" container.add_constant(Constant.new(stmt.name.to_s, stmt.value.to_s, stmt.doc)) end end end # create documentation for resources we can find in +code+ # and associate it with +container+ def scan_for_resource(container, code) code = [code] unless code.is_a?(Array) code.each do |stmt| scan_for_resource(container,stmt.children) if stmt.is_a?(Puppet::Parser::AST::ASTArray) if stmt.is_a?(Puppet::Parser::AST::Resource) and !stmt.type.nil? begin type = stmt.type.split("::").collect { |s| s.capitalize }.join("::") stmt.instances.each do |inst| title = inst.title.is_a?(Puppet::Parser::AST::ASTArray) ? inst.title.to_s.gsub(/\[(.*)\]/,'\1') : inst.title.to_s Puppet.debug "rdoc: found resource: #{type}[#{title}]" param = [] inst.parameters.children.each do |p| res = {} res["name"] = p.param res["value"] = "#{p.value.to_s}" unless p.value.nil? param << res end container.add_resource(PuppetResource.new(type, title, stmt.doc, param)) end rescue => detail raise Puppet::ParseError, "impossible to parse resource in #{stmt.file} at line #{stmt.line}: #{detail}" end end end end def resource_stmt_to_ref(stmt) type = stmt.type.split("::").collect { |s| s.capitalize }.join("::") title = stmt.title.is_a?(Puppet::Parser::AST::ASTArray) ? stmt.title.to_s.gsub(/\[(.*)\]/,'\1') : stmt.title.to_s param = stmt.params.children.collect do |p| {"name" => p.param, "value" => p.value.to_s} end PuppetResource.new(type, title, stmt.doc, param) end # create documentation for a class named +name+ def document_class(name, klass, container) Puppet.debug "rdoc: found new class #{name}" container, name = get_class_or_module(container, name) superclass = klass.parent superclass = "" if superclass.nil? or superclass.empty? @stats.num_classes += 1 comment = klass.doc look_for_directives_in(container, comment) unless comment.empty? cls = container.add_class(PuppetClass, name, superclass) # it is possible we already encountered this class, while parsing some namespaces # from other classes of other files. But at that time we couldn't know this class superclass # so, now we know it and force it. cls.superclass = superclass cls.record_location(@top_level) # scan class code for include code = klass.code.children if klass.code.is_a?(Puppet::Parser::AST::ASTArray) code ||= klass.code unless code.nil? scan_for_include_or_require(cls, code) scan_for_realize(cls, code) scan_for_resource(cls, code) if Puppet.settings[:document_all] end cls.comment = comment rescue => detail raise Puppet::ParseError, "impossible to parse class '#{name}' in #{klass.file} at line #{klass.line}: #{detail}" end # create documentation for a node def document_node(name, node, container) Puppet.debug "rdoc: found new node #{name}" superclass = node.parent superclass = "" if superclass.nil? or superclass.empty? comment = node.doc look_for_directives_in(container, comment) unless comment.empty? n = container.add_node(name, superclass) n.record_location(@top_level) code = node.code.children if node.code.is_a?(Puppet::Parser::AST::ASTArray) code ||= node.code unless code.nil? scan_for_include_or_require(n, code) scan_for_realize(n, code) scan_for_vardef(n, code) scan_for_resource(n, code) if Puppet.settings[:document_all] end n.comment = comment rescue => detail raise Puppet::ParseError, "impossible to parse node '#{name}' in #{node.file} at line #{node.line}: #{detail}" end # create documentation for a define def document_define(name, define, container) Puppet.debug "rdoc: found new definition #{name}" # find superclas if any @stats.num_methods += 1 # find the parent # split define name by :: to find the complete module hierarchy container, name = get_class_or_module(container,name) # build up declaration declaration = "" define.arguments.each do |arg,value| declaration << "\$#{arg}" unless value.nil? declaration << " => " case value when Puppet::Parser::AST::Leaf declaration << "'#{value.value}'" when Puppet::Parser::AST::ASTArray declaration << "[#{value.children.collect { |v| "'#{v}'" }.join(", ")}]" else declaration << "#{value.to_s}" end end declaration << ", " end declaration.chop!.chop! if declaration.size > 1 # register method into the container meth = AnyMethod.new(declaration, name) meth.comment = define.doc container.add_method(meth) look_for_directives_in(container, meth.comment) unless meth.comment.empty? meth.params = "( #{declaration} )" meth.visibility = :public meth.document_self = true meth.singleton = false rescue => detail raise Puppet::ParseError, "impossible to parse definition '#{name}' in #{define.file} at line #{define.line}: #{detail}" end # Traverse the AST tree and produce code-objects node # that contains the documentation def parse_elements(container) Puppet.debug "rdoc: scanning manifest" + @known_resource_types.hostclasses.values.sort { |a,b| a.name <=> b.name }.each do |klass| name = klass.name if klass.file == @input_file_name unless name.empty? document_class(name,klass,container) else # on main class document vardefs code = klass.code.children if klass.code.is_a?(Puppet::Parser::AST::ASTArray) code ||= klass.code scan_for_vardef(container, code) unless code.nil? end end end @known_resource_types.definitions.each do |name, define| if define.file == @input_file_name document_define(name,define,container) end end @known_resource_types.nodes.each do |name, node| if node.file == @input_file_name document_node(name.to_s,node,container) end end end # create documentation for plugins def parse_plugins(container) Puppet.debug "rdoc: scanning plugin or fact" if @input_file_name =~ /\/facter\/[^\/]+\.rb$/ parse_fact(container) else parse_puppet_plugin(container) end end # this is a poor man custom fact parser :-) def parse_fact(container) comments = "" current_fact = nil File.open(@input_file_name) do |of| of.each do |line| # fetch comments if line =~ /^[ \t]*# ?(.*)$/ comments += $1 + "\n" elsif line =~ /^[ \t]*Facter.add\(['"](.*?)['"]\)/ current_fact = Fact.new($1,{}) look_for_directives_in(container, comments) unless comments.empty? current_fact.comment = comments container.add_fact(current_fact) current_fact.record_location(@top_level) comments = "" Puppet.debug "rdoc: found custom fact #{current_fact.name}" elsif line =~ /^[ \t]*confine[ \t]*:(.*?)[ \t]*=>[ \t]*(.*)$/ current_fact.confine = { :type => $1, :value => $2 } unless current_fact.nil? else # unknown line type comments ="" end end end end # this is a poor man puppet plugin parser :-) # it doesn't extract doc nor desc :-( def parse_puppet_plugin(container) comments = "" current_plugin = nil File.open(@input_file_name) do |of| of.each do |line| # fetch comments if line =~ /^[ \t]*# ?(.*)$/ comments += $1 + "\n" elsif line =~ /^[ \t]*newfunction[ \t]*\([ \t]*:(.*?)[ \t]*,[ \t]*:type[ \t]*=>[ \t]*(:rvalue|:lvalue)\)/ current_plugin = Plugin.new($1, "function") container.add_plugin(current_plugin) look_for_directives_in(container, comments) unless comments.empty? current_plugin.comment = comments current_plugin.record_location(@top_level) comments = "" Puppet.debug "rdoc: found new function plugins #{current_plugin.name}" elsif line =~ /^[ \t]*Puppet::Type.newtype[ \t]*\([ \t]*:(.*?)\)/ current_plugin = Plugin.new($1, "type") container.add_plugin(current_plugin) look_for_directives_in(container, comments) unless comments.empty? current_plugin.comment = comments current_plugin.record_location(@top_level) comments = "" Puppet.debug "rdoc: found new type plugins #{current_plugin.name}" elsif line =~ /module Puppet::Parser::Functions/ # skip else # unknown line type comments ="" end end end end # look_for_directives_in scans the current +comment+ for RDoc directives def look_for_directives_in(context, comment) preprocess = SM::PreProcess.new(@input_file_name, @options.rdoc_include) preprocess.handle(comment) do |directive, param| case directive when "stopdoc" context.stop_doc "" when "startdoc" context.start_doc context.force_documentation = true "" when "enddoc" #context.done_documenting = true #"" throw :enddoc when "main" options = Options.instance options.main_page = param "" when "title" options = Options.instance options.title = param "" when "section" context.set_current_section(param, comment) comment.replace("") # 1.8 doesn't support #clear break else warn "Unrecognized directive '#{directive}'" break end end remove_private_comments(comment) end def remove_private_comments(comment) comment.gsub!(/^#--.*?^#\+\+/m, '') comment.sub!(/^#--.*/m, '') end end end diff --git a/lib/puppet/util/settings.rb b/lib/puppet/util/settings.rb index 626ed20eb..f243b8691 100644 --- a/lib/puppet/util/settings.rb +++ b/lib/puppet/util/settings.rb @@ -1,932 +1,932 @@ require 'puppet' require 'sync' require 'getoptlong' require 'puppet/external/event-loop' require 'puppet/util/cacher' require 'puppet/util/loadedfile' # The class for handling configuration files. class Puppet::Util::Settings include Enumerable include Puppet::Util::Cacher require 'puppet/util/settings/setting' require 'puppet/util/settings/file_setting' require 'puppet/util/settings/boolean_setting' attr_accessor :file attr_reader :timer ReadOnly = [:run_mode, :name] # Retrieve a config value def [](param) value(param) end # Set a config value. This doesn't set the defaults, it sets the value itself. def []=(param, value) set_value(param, value, :memory) end # Generate the list of valid arguments, in a format that GetoptLong can # understand, and add them to the passed option list. def addargs(options) # Add all of the config parameters as valid options. self.each { |name, setting| setting.getopt_args.each { |args| options << args } } options end # Generate the list of valid arguments, in a format that OptionParser can # understand, and add them to the passed option list. def optparse_addargs(options) # Add all of the config parameters as valid options. self.each { |name, setting| options << setting.optparse_args } options end # Is our parameter a boolean parameter? def boolean?(param) param = param.to_sym !!(@config.include?(param) and @config[param].kind_of? BooleanSetting) end # Remove all set values, potentially skipping cli values. def clear(exceptcli = false) @sync.synchronize do unsafe_clear(exceptcli) end end # Remove all set values, potentially skipping cli values. def unsafe_clear(exceptcli = false) @values.each do |name, values| @values.delete(name) unless exceptcli and name == :cli end # Don't clear the 'used' in this case, since it's a config file reparse, # and we want to retain this info. @used = [] unless exceptcli @cache.clear end # This is mostly just used for testing. def clearused @cache.clear @used = [] end # Do variable interpolation on the value. def convert(value, environment = nil) return value unless value return value unless value.is_a? String newval = value.gsub(/\$(\w+)|\$\{(\w+)\}/) do |value| varname = $2 || $1 if varname == "environment" and environment environment - elsif pval = self.value(varname) + elsif pval = self.value(varname, environment) pval else raise Puppet::DevError, "Could not find value for #{value}" end end newval end # Return a value's description. def description(name) if obj = @config[name.to_sym] obj.desc else nil end end def each @config.each { |name, object| yield name, object } end # Iterate over each section name. def eachsection yielded = [] @config.each do |name, object| section = object.section unless yielded.include? section yield section yielded << section end end end # Return an object by name. def setting(param) param = param.to_sym @config[param] end # Handle a command-line argument. def handlearg(opt, value = nil) @cache.clear value &&= munge_value(value) str = opt.sub(/^--/,'') bool = true newstr = str.sub(/^no-/, '') if newstr != str str = newstr bool = false end str = str.intern if @config[str].is_a?(Puppet::Util::Settings::BooleanSetting) if value == "" or value.nil? value = bool end end set_value(str, value, :cli) end def include?(name) name = name.intern if name.is_a? String @config.include?(name) end # check to see if a short name is already defined def shortinclude?(short) short = short.intern if name.is_a? String @shortnames.include?(short) end # Create a new collection of config settings. def initialize @config = {} @shortnames = {} @created = [] @searchpath = nil # Mutex-like thing to protect @values @sync = Sync.new # Keep track of set values. @values = Hash.new { |hash, key| hash[key] = {} } # And keep a per-environment cache @cache = Hash.new { |hash, key| hash[key] = {} } # The list of sections we've used. @used = [] end # NOTE: ACS ahh the util classes. . .sigh # as part of a fix for 1183, I pulled the logic for the following 5 methods out of the executables and puppet.rb # They probably deserve their own class, but I don't want to do that until I can refactor environments # its a little better than where they were # Prints the contents of a config file with the available config settings, or it # prints a single value of a config setting. def print_config_options env = value(:environment) val = value(:configprint) if val == "all" hash = {} each do |name, obj| val = value(name,env) val = val.inspect if val == "" hash[name] = val end hash.sort { |a,b| a[0].to_s <=> b[0].to_s }.each do |name, val| puts "#{name} = #{val}" end else val.split(/\s*,\s*/).sort.each do |v| if include?(v) #if there is only one value, just print it for back compatibility if v == val puts value(val,env) break end puts "#{v} = #{value(v,env)}" else puts "invalid parameter: #{v}" return false end end end true end def generate_config puts to_config true end def generate_manifest puts to_manifest true end def print_configs return print_config_options if value(:configprint) != "" return generate_config if value(:genconfig) generate_manifest if value(:genmanifest) end def print_configs? (value(:configprint) != "" || value(:genconfig) || value(:genmanifest)) && true end # Return a given object's file metadata. def metadata(param) if obj = @config[param.to_sym] and obj.is_a?(FileSetting) return [:owner, :group, :mode].inject({}) do |meta, p| if v = obj.send(p) meta[p] = v end meta end else nil end end # Make a directory with the appropriate user, group, and mode def mkdir(default) obj = get_config_file_default(default) Puppet::Util::SUIDManager.asuser(obj.owner, obj.group) do mode = obj.mode || 0750 Dir.mkdir(obj.value, mode) end end # Figure out the section name for the run_mode. def run_mode Puppet.run_mode.name end # Return all of the parameters associated with a given section. def params(section = nil) if section section = section.intern if section.is_a? String @config.find_all { |name, obj| obj.section == section }.collect { |name, obj| name } else @config.keys end end # Parse the configuration file. Just provides # thread safety. def parse raise "No :config setting defined; cannot parse unknown config file" unless self[:config] @sync.synchronize do unsafe_parse(self[:config]) end # Create a timer so that this file will get checked automatically # and reparsed if necessary. set_filetimeout_timer end # Unsafely parse the file -- this isn't thread-safe and causes plenty of problems if used directly. def unsafe_parse(file) return unless FileTest.exist?(file) begin data = parse_file(file) rescue => details puts details.backtrace if Puppet[:trace] Puppet.err "Could not parse #{file}: #{details}" return end unsafe_clear(true) metas = {} data.each do |area, values| metas[area] = values.delete(:_meta) values.each do |key,value| set_value(key, value, area, :dont_trigger_handles => true, :ignore_bad_settings => true ) end end # Determine our environment, if we have one. if @config[:environment] env = self.value(:environment).to_sym else env = "none" end # Call any hooks we should be calling. settings_with_hooks.each do |setting| each_source(env) do |source| if value = @values[source][setting.name] # We still have to use value to retrieve the value, since # we want the fully interpolated value, not $vardir/lib or whatever. # This results in extra work, but so few of the settings # will have associated hooks that it ends up being less work this # way overall. setting.handle(self.value(setting.name, env)) break end end end # We have to do it in the reverse of the search path, # because multiple sections could set the same value # and I'm too lazy to only set the metadata once. searchpath.reverse.each do |source| source = run_mode if source == :run_mode source = @name if (@name && source == :name) if meta = metas[source] set_metadata(meta) end end end # Create a new setting. The value is passed in because it's used to determine # what kind of setting we're creating, but the value itself might be either # a default or a value, so we can't actually assign it. def newsetting(hash) klass = nil hash[:section] = hash[:section].to_sym if hash[:section] if type = hash[:type] unless klass = {:setting => Setting, :file => FileSetting, :boolean => BooleanSetting}[type] raise ArgumentError, "Invalid setting type '#{type}'" end hash.delete(:type) else case hash[:default] when true, false, "true", "false" klass = BooleanSetting when /^\$\w+\//, /^\//, /^\w:\// klass = FileSetting when String, Integer, Float # nothing klass = Setting else raise ArgumentError, "Invalid value '#{hash[:default].inspect}' for #{hash[:name]}" end end hash[:settings] = self setting = klass.new(hash) setting end # This has to be private, because it doesn't add the settings to @config private :newsetting # Iterate across all of the objects in a given section. def persection(section) section = section.to_sym self.each { |name, obj| if obj.section == section yield obj end } end # Cache this in an easily clearable way, since we were # having trouble cleaning it up after tests. cached_attr(:file) do if path = self[:config] and FileTest.exist?(path) Puppet::Util::LoadedFile.new(path) end end # Reparse our config file, if necessary. def reparse if file and file.changed? Puppet.notice "Reparsing #{file.file}" parse reuse end end def reuse return unless defined?(@used) @sync.synchronize do # yay, thread-safe new = @used @used = [] self.use(*new) end end # The order in which to search for values. def searchpath(environment = nil) if environment [:cli, :memory, environment, :run_mode, :main, :mutable_defaults] else [:cli, :memory, :run_mode, :main, :mutable_defaults] end end # Get a list of objects per section def sectionlist sectionlist = [] self.each { |name, obj| section = obj.section || "puppet" sections[section] ||= [] sectionlist << section unless sectionlist.include?(section) sections[section] << obj } return sectionlist, sections end def service_user_available? return @service_user_available if defined?(@service_user_available) return @service_user_available = false unless user_name = self[:user] user = Puppet::Type.type(:user).new :name => self[:user], :audit => :ensure @service_user_available = user.exists? end def legacy_to_mode(type, param) if not defined?(@app_names) require 'puppet/util/command_line' command_line = Puppet::Util::CommandLine.new @app_names = Puppet::Util::CommandLine::LegacyName.inject({}) do |hash, pair| app, legacy = pair command_line.require_application app hash[legacy.to_sym] = Puppet::Application.find(app).run_mode.name hash end end if new_type = @app_names[type] Puppet.warning "You have configuration parameter $#{param} specified in [#{type}], which is a deprecated section. I'm assuming you meant [#{new_type}]" return new_type end type end def set_value(param, value, type, options = {}) param = param.to_sym unless setting = @config[param] if options[:ignore_bad_settings] return else raise ArgumentError, "Attempt to assign a value to unknown configuration parameter #{param.inspect}" end end value = setting.munge(value) if setting.respond_to?(:munge) setting.handle(value) if setting.respond_to?(:handle) and not options[:dont_trigger_handles] if ReadOnly.include? param and type != :mutable_defaults raise ArgumentError, "You're attempting to set configuration parameter $#{param}, which is read-only." end type = legacy_to_mode(type, param) @sync.synchronize do # yay, thread-safe @values[type][param] = value @cache.clear clearused # Clear the list of environments, because they cache, at least, the module path. # We *could* preferentially just clear them if the modulepath is changed, # but we don't really know if, say, the vardir is changed and the modulepath # is defined relative to it. We need the defined?(stuff) because of loading # order issues. Puppet::Node::Environment.clear if defined?(Puppet::Node) and defined?(Puppet::Node::Environment) end value end # Set a bunch of defaults in a given section. The sections are actually pretty # pointless, but they help break things up a bit, anyway. def setdefaults(section, defs) section = section.to_sym call = [] defs.each { |name, hash| if hash.is_a? Array unless hash.length == 2 raise ArgumentError, "Defaults specified as an array must contain only the default value and the decription" end tmp = hash hash = {} [:default, :desc].zip(tmp).each { |p,v| hash[p] = v } end name = name.to_sym hash[:name] = name hash[:section] = section raise ArgumentError, "Parameter #{name} is already defined" if @config.include?(name) tryconfig = newsetting(hash) if short = tryconfig.short if other = @shortnames[short] raise ArgumentError, "Parameter #{other.name} is already using short name '#{short}'" end @shortnames[short] = tryconfig end @config[name] = tryconfig # Collect the settings that need to have their hooks called immediately. # We have to collect them so that we can be sure we're fully initialized before # the hook is called. call << tryconfig if tryconfig.call_on_define } call.each { |setting| setting.handle(self.value(setting.name)) } end # Create a timer to check whether the file should be reparsed. def set_filetimeout_timer return unless timeout = self[:filetimeout] and timeout = Integer(timeout) and timeout > 0 timer = EventLoop::Timer.new(:interval => timeout, :tolerance => 1, :start? => true) { self.reparse } end # Convert the settings we manage into a catalog full of resources that model those settings. def to_catalog(*sections) sections = nil if sections.empty? catalog = Puppet::Resource::Catalog.new("Settings") @config.values.find_all { |value| value.is_a?(FileSetting) }.each do |file| next unless (sections.nil? or sections.include?(file.section)) next unless resource = file.to_resource next if catalog.resource(resource.ref) catalog.add_resource(resource) end add_user_resources(catalog, sections) catalog end # Convert our list of config settings into a configuration file. def to_config str = %{The configuration file for #{Puppet[:name]}. Note that this file is likely to have unused configuration parameters in it; any parameter that's valid anywhere in Puppet can be in any config file, even if it's not used. Every section can specify three special parameters: owner, group, and mode. These parameters affect the required permissions of any files specified after their specification. Puppet will sometimes use these parameters to check its own configured state, so they can be used to make Puppet a bit more self-managing. Generated on #{Time.now}. }.gsub(/^/, "# ") # Add a section heading that matches our name. if @config.include?(:run_mode) str += "[#{self[:run_mode]}]\n" end eachsection do |section| persection(section) do |obj| str += obj.to_config + "\n" unless ReadOnly.include? obj.name or obj.name == :genconfig end end return str end # Convert to a parseable manifest def to_manifest catalog = to_catalog catalog.resource_refs.collect do |ref| catalog.resource(ref).to_manifest end.join("\n\n") end # Create the necessary objects to use a section. This is idempotent; # you can 'use' a section as many times as you want. def use(*sections) sections = sections.collect { |s| s.to_sym } @sync.synchronize do # yay, thread-safe sections = sections.reject { |s| @used.include?(s) } return if sections.empty? begin catalog = to_catalog(*sections).to_ral rescue => detail puts detail.backtrace if Puppet[:trace] Puppet.err "Could not create resources for managing Puppet's files and directories in sections #{sections.inspect}: #{detail}" # We need some way to get rid of any resources created during the catalog creation # but not cleaned up. return end catalog.host_config = false catalog.apply do |transaction| if transaction.any_failed? report = transaction.report failures = report.logs.find_all { |log| log.level == :err } raise "Got #{failures.length} failure(s) while initializing: #{failures.collect { |l| l.to_s }.join("; ")}" end end sections.each { |s| @used << s } @used.uniq! end end def valid?(param) param = param.to_sym @config.has_key?(param) end def uninterpolated_value(param, environment = nil) param = param.to_sym environment &&= environment.to_sym # See if we can find it within our searchable list of values val = catch :foundval do each_source(environment) do |source| # Look for the value. We have to test the hash for whether # it exists, because the value might be false. @sync.synchronize do throw :foundval, @values[source][param] if @values[source].include?(param) end end throw :foundval, nil end # If we didn't get a value, use the default val = @config[param].default if val.nil? val end # Find the correct value using our search path. Optionally accept an environment # in which to search before the other configuration sections. def value(param, environment = nil) param = param.to_sym environment &&= environment.to_sym # Short circuit to nil for undefined parameters. return nil unless @config.include?(param) # Yay, recursion. #self.reparse unless [:config, :filetimeout].include?(param) # Check the cache first. It needs to be a per-environment # cache so that we don't spread values from one env # to another. if cached = @cache[environment||"none"][param] return cached end val = uninterpolated_value(param, environment) if param == :code # if we interpolate code, all hell breaks loose. return val end # Convert it if necessary val = convert(val, environment) # And cache it @cache[environment||"none"][param] = val val end # Open a file with the appropriate user, group, and mode def write(default, *args, &bloc) obj = get_config_file_default(default) writesub(default, value(obj.name), *args, &bloc) end # Open a non-default file under a default dir with the appropriate user, # group, and mode def writesub(default, file, *args, &bloc) obj = get_config_file_default(default) chown = nil if Puppet.features.root? chown = [obj.owner, obj.group] else chown = [nil, nil] end Puppet::Util::SUIDManager.asuser(*chown) do mode = obj.mode || 0640 args << "w" if args.empty? args << mode # Update the umask to make non-executable files Puppet::Util.withumask(File.umask ^ 0111) do File.open(file, *args) do |file| yield file end end end end def readwritelock(default, *args, &bloc) file = value(get_config_file_default(default).name) tmpfile = file + ".tmp" sync = Sync.new raise Puppet::DevError, "Cannot create #{file}; directory #{File.dirname(file)} does not exist" unless FileTest.directory?(File.dirname(tmpfile)) sync.synchronize(Sync::EX) do File.open(file, ::File::CREAT|::File::RDWR, 0600) do |rf| rf.lock_exclusive do if File.exist?(tmpfile) raise Puppet::Error, ".tmp file already exists for #{file}; Aborting locked write. Check the .tmp file and delete if appropriate" end # If there's a failure, remove our tmpfile begin writesub(default, tmpfile, *args, &bloc) rescue File.unlink(tmpfile) if FileTest.exist?(tmpfile) raise end begin File.rename(tmpfile, file) rescue => detail Puppet.err "Could not rename #{file} to #{tmpfile}: #{detail}" File.unlink(tmpfile) if FileTest.exist?(tmpfile) end end end end end private def get_config_file_default(default) obj = nil unless obj = @config[default] raise ArgumentError, "Unknown default #{default}" end raise ArgumentError, "Default #{default} is not a file" unless obj.is_a? FileSetting obj end # Create the transportable objects for users and groups. def add_user_resources(catalog, sections) return unless Puppet.features.root? return unless self[:mkusers] @config.each do |name, setting| next unless setting.respond_to?(:owner) next unless sections.nil? or sections.include?(setting.section) if user = setting.owner and user != "root" and catalog.resource(:user, user).nil? resource = Puppet::Resource.new(:user, user, :parameters => {:ensure => :present}) resource[:gid] = self[:group] if self[:group] catalog.add_resource resource end if group = setting.group and ! %w{root wheel}.include?(group) and catalog.resource(:group, group).nil? catalog.add_resource Puppet::Resource.new(:group, group, :parameters => {:ensure => :present}) end end end # Yield each search source in turn. def each_source(environment) searchpath(environment).each do |source| # Modify the source as necessary. source = self.run_mode if source == :run_mode yield source end end # Return all settings that have associated hooks; this is so # we can call them after parsing the configuration file. def settings_with_hooks @config.values.find_all { |setting| setting.respond_to?(:handle) } end # Extract extra setting information for files. def extract_fileinfo(string) result = {} value = string.sub(/\{\s*([^}]+)\s*\}/) do params = $1 params.split(/\s*,\s*/).each do |str| if str =~ /^\s*(\w+)\s*=\s*([\w\d]+)\s*$/ param, value = $1.intern, $2 result[param] = value raise ArgumentError, "Invalid file option '#{param}'" unless [:owner, :mode, :group].include?(param) if param == :mode and value !~ /^\d+$/ raise ArgumentError, "File modes must be numbers" end else raise ArgumentError, "Could not parse '#{string}'" end end '' end result[:value] = value.sub(/\s*$/, '') result end # Convert arguments into booleans, integers, or whatever. def munge_value(value) # Handle different data types correctly return case value when /^false$/i; false when /^true$/i; true when /^\d+$/i; Integer(value) when true; true when false; false else value.gsub(/^["']|["']$/,'').sub(/\s+$/, '') end end # This method just turns a file in to a hash of hashes. def parse_file(file) text = read_file(file) result = Hash.new { |names, name| names[name] = {} } count = 0 # Default to 'main' for the section. section = :main result[section][:_meta] = {} text.split(/\n/).each { |line| count += 1 case line when /^\s*\[(\w+)\]\s*$/ section = $1.intern # Section names # Add a meta section result[section][:_meta] ||= {} when /^\s*#/; next # Skip comments when /^\s*$/; next # Skip blanks when /^\s*(\w+)\s*=\s*(.*?)\s*$/ # settings var = $1.intern # We don't want to munge modes, because they're specified in octal, so we'll # just leave them as a String, since Puppet handles that case correctly. if var == :mode value = $2 else value = munge_value($2) end # Check to see if this is a file argument and it has extra options begin if value.is_a?(String) and options = extract_fileinfo(value) value = options[:value] options.delete(:value) result[section][:_meta][var] = options end result[section][var] = value rescue Puppet::Error => detail detail.file = file detail.line = line raise end else error = Puppet::Error.new("Could not match line #{line}") error.file = file error.line = line raise error end } result end # Read the file in. def read_file(file) begin return File.read(file) rescue Errno::ENOENT raise ArgumentError, "No such file #{file}" rescue Errno::EACCES raise ArgumentError, "Permission denied to file #{file}" end end # Set file metadata. def set_metadata(meta) meta.each do |var, values| values.each do |param, value| @config[var].send(param.to_s + "=", value) end end end end diff --git a/lib/puppet/util/zaml.rb b/lib/puppet/util/zaml.rb index 2155e989c..bbb2af2d2 100644 --- a/lib/puppet/util/zaml.rb +++ b/lib/puppet/util/zaml.rb @@ -1,320 +1,321 @@ # # ZAML -- A partial replacement for YAML, writen with speed and code clarity # in mind. ZAML fixes one YAML bug (loading Exceptions) and provides # a replacement for YAML.dump unimaginatively called ZAML.dump, # which is faster on all known cases and an order of magnitude faster # with complex structures. # # http://github.com/hallettj/zaml # # Authors: Markus Roberts, Jesse Hallett, Ian McIntosh, Igal Koshevoy, Simon Chiang # require 'yaml' class ZAML VERSION = "0.1.1" # # Class Methods # def self.dump(stuff, where='') z = new stuff.to_zaml(z) where << z.to_s end # # Instance Methods # def initialize @result = [] @indent = nil @structured_key_prefix = nil @previously_emitted_object = {} @next_free_label_number = 0 emit('--- ') end def nested(tail=' ') old_indent = @indent @indent = "#{@indent || "\n"}#{tail}" yield @indent = old_indent end class Label # # YAML only wants objects in the datastream once; if the same object # occurs more than once, we need to emit a label ("&idxxx") on the # first occurrence and then emit a back reference (*idxxx") on any # subsequent occurrence(s). # # To accomplish this we keeps a hash (by object id) of the labels of # the things we serialize as we begin to serialize them. The labels # initially serialize as an empty string (since most objects are only # going to be be encountered once), but can be changed to a valid # (by assigning it a number) the first time it is subsequently used, # if it ever is. Note that we need to do the label setup BEFORE we # start to serialize the object so that circular structures (in # which we will encounter a reference to the object as we serialize # it can be handled). # attr_accessor :this_label_number def initialize(obj,indent) @indent = indent @this_label_number = nil + @obj = obj # prevent garbage collection so that object id isn't reused end def to_s @this_label_number ? ('&id%03d%s' % [@this_label_number, @indent]) : '' end def reference @reference ||= '*id%03d' % @this_label_number end end def label_for(obj) @previously_emitted_object[obj.object_id] end def new_label_for(obj) label = Label.new(obj,(Hash === obj || Array === obj) ? "#{@indent || "\n"} " : ' ') @previously_emitted_object[obj.object_id] = label label end def first_time_only(obj) if label = label_for(obj) label.this_label_number ||= (@next_free_label_number += 1) emit(label.reference) else if @structured_key_prefix and not obj.is_a? String emit(@structured_key_prefix) @structured_key_prefix = nil end emit(new_label_for(obj)) yield end end def emit(s) @result << s @recent_nl = false unless s.kind_of?(Label) end def nl(s='') emit(@indent || "\n") unless @recent_nl emit(s) @recent_nl = true end def to_s @result.join end def prefix_structured_keys(x) @structured_key_prefix = x yield nl unless @structured_key_prefix @structured_key_prefix = nil end end ################################################################ # # Behavior for custom classes # ################################################################ class Object def to_yaml_properties instance_variables.sort # Default YAML behavior end def yaml_property_munge(x) x end def zamlized_class_name(root) cls = self.class "!ruby/#{root.name.downcase}#{cls == root ? '' : ":#{cls.respond_to?(:name) ? cls.name : cls}"}" end def to_zaml(z) z.first_time_only(self) { z.emit(zamlized_class_name(Object)) z.nested { instance_variables = to_yaml_properties if instance_variables.empty? z.emit(" {}") else instance_variables.each { |v| z.nl v[1..-1].to_zaml(z) # Remove leading '@' z.emit(': ') yaml_property_munge(instance_variable_get(v)).to_zaml(z) } end } } end end ################################################################ # # Behavior for built-in classes # ################################################################ class NilClass def to_zaml(z) z.emit('') # NOTE: blank turns into nil in YAML.load end end class Symbol def to_zaml(z) z.emit(self.inspect) end end class TrueClass def to_zaml(z) z.emit('true') end end class FalseClass def to_zaml(z) z.emit('false') end end class Numeric def to_zaml(z) z.emit(self) end end class Regexp def to_zaml(z) z.first_time_only(self) { z.emit("#{zamlized_class_name(Regexp)} #{inspect}") } end end class Exception def to_zaml(z) z.emit(zamlized_class_name(Exception)) z.nested { z.nl("message: ") message.to_zaml(z) } end # # Monkey patch for buggy Exception restore in YAML # # This makes it work for now but is not very future-proof; if things # change we'll most likely want to remove this. To mitigate the risks # as much as possible, we test for the bug before appling the patch. # if respond_to? :yaml_new and yaml_new(self, :tag, "message" => "blurp").message != "blurp" def self.yaml_new( klass, tag, val ) o = YAML.object_maker( klass, {} ).exception(val.delete( 'message')) val.each_pair do |k,v| o.instance_variable_set("@#{k}", v) end o end end end class String ZAML_ESCAPES = %w{\x00 \x01 \x02 \x03 \x04 \x05 \x06 \a \x08 \t \n \v \f \r \x0e \x0f \x10 \x11 \x12 \x13 \x14 \x15 \x16 \x17 \x18 \x19 \x1a \e \x1c \x1d \x1e \x1f } def escaped_for_zaml gsub( /\x5C/, "\\\\\\" ). # Demi-kludge for Maglev/rubinius; the regexp should be /\\/ but parsetree chokes on that. gsub( /"/, "\\\"" ). gsub( /([\x00-\x1F])/ ) { |x| ZAML_ESCAPES[ x.unpack("C")[0] ] }. gsub( /([\x80-\xFF])/ ) { |x| "\\x#{x.unpack("C")[0].to_s(16)}" } end def to_zaml(z) z.first_time_only(self) { num = '[-+]?(0x)?\d+\.?\d*' case when self == '' z.emit('""') # when self =~ /[\x00-\x08\x0B\x0C\x0E-\x1F\x80-\xFF]/ # z.emit("!binary |\n") # z.emit([self].pack("m*")) when ( (self =~ /\A(true|false|yes|no|on|null|off|#{num}(:#{num})*|!|=|~)$/i) or (self =~ /\A\n* /) or (self =~ /[\s:]$/) or (self =~ /^[>|][-+\d]*\s/i) or (self[-1..-1] =~ /\s/) or (self =~ /[\x00-\x08\x0B\x0C\x0E-\x1F\x80-\xFF]/) or (self =~ /[,\[\]\{\}\r\t]|:\s|\s#/) or (self =~ /\A([-:?!#&*'"]|<<|%.+:.)/) ) z.emit("\"#{escaped_for_zaml}\"") when self =~ /\n/ if self[-1..-1] == "\n" then z.emit('|+') else z.emit('|-') end z.nested { split("\n",-1).each { |line| z.nl; z.emit(line.chomp("\n")) } } else z.emit(self) end } end end class Hash def to_zaml(z) z.first_time_only(self) { z.nested { if empty? z.emit('{}') else each_pair { |k, v| z.nl z.prefix_structured_keys('? ') { k.to_zaml(z) } z.emit(': ') v.to_zaml(z) } end } } end end class Array def to_zaml(z) z.first_time_only(self) { z.nested { if empty? z.emit('[]') else each { |v| z.nl('- '); v.to_zaml(z) } end } } end end class Time def to_zaml(z) # 2008-12-06 10:06:51.373758 -07:00 ms = ("%0.6f" % (usec * 1e-6)).sub(/^\d+\./,'') offset = "%+0.2i:%0.2i" % [utc_offset / 3600, (utc_offset / 60) % 60] z.emit(self.strftime("%Y-%m-%d %H:%M:%S.#{ms} #{offset}")) end end class Date def to_zaml(z) z.emit(strftime('%Y-%m-%d')) end end class Range def to_zaml(z) z.first_time_only(self) { z.emit(zamlized_class_name(Range)) z.nested { z.nl z.emit('begin: ') z.emit(first) z.nl z.emit('end: ') z.emit(last) z.nl z.emit('excl: ') z.emit(exclude_end?) } } end end diff --git a/man/man5/puppet.conf.5 b/man/man5/puppet.conf.5 index 210f36786..f6c9926c3 100644 --- a/man/man5/puppet.conf.5 +++ b/man/man5/puppet.conf.5 @@ -1,2103 +1,1592 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "PUPPETCONF" "5" "August 2010" "" "" -\fBThis page is autogenerated; any changes will get overwritten\fR \fI(last generated on Sat Aug 28 14:00:20 \-0700 2010)\fR -. -.P -{:toc} +.TH "PUPPETCONF" "5" "February 2011" "Puppet Labs, LLC" "Puppet manual" +\fBThis page is autogenerated; any changes will get overwritten\fR \fI(last generated on Thu Feb 17 09:56:34 \-0800 2011)\fR . .SH "Specifying Configuration Parameters" -On The Command\-Line +++++++++++++++++++ Every Puppet executable (with the exception of \fBpuppetdoc\fR) accepts all of the parameters below, but not all of the arguments make sense for every executable\. +. +.SS "On The Command\-Line" +Every Puppet executable (with the exception of \fBpuppetdoc\fR) accepts all of the parameters below, but not all of the arguments make sense for every executable\. . .P I have tried to be as thorough as possible in the descriptions of the arguments, so it should be obvious whether an argument is appropriate or not\. . .P These parameters can be supplied to the executables either as command\-line options or in the configuration file\. For instance, the command\-line invocation below would set the configuration directory to \fB/private/puppet\fR: . .IP "" 4 . .nf $ puppet agent \-\-confdir=/private/puppet . .fi . .IP "" 0 . .P Note that boolean options are turned on and off with a slightly different syntax on the command line: . .IP "" 4 . .nf $ puppet agent \-\-storeconfigs $ puppet agent \-\-no\-storeconfigs . .fi . .IP "" 0 . .P The invocations above will enable and disable, respectively, the storage of the client configuration\. . -.P -Configuration Files +++++++++++++++++++ -. -.P +.SS "Configuration Files" As mentioned above, the configuration parameters can also be stored in a configuration file, located in the configuration directory\. As root, the default configuration directory is \fB/etc/puppet\fR, and as a regular user, the default configuration directory is \fB~user/\.puppet\fR\. As of 0\.23\.0, all executables look for \fBpuppet\.conf\fR in their configuration directory (although they previously looked for separate files)\. For example, \fBpuppet\.conf\fR is located at \fB/etc/puppet/puppet\.conf\fR as \fBroot\fR and \fB~user/\.puppet/puppet\.conf\fR as a regular user by default\. . .P All executables will set any parameters set within the \fB[main]\fR section, and each executable will also use one of the \fB[master]\fR, \fB[agent]\fR\. . .P -File Format \'\'\'\'\'\'\'\'\'\'\' -. -.P The file follows INI\-style formatting\. Here is an example of a very simple \fBpuppet\.conf\fR file: . .IP "" 4 . .nf [main] confdir = /private/puppet storeconfigs = true . .fi . .IP "" 0 . .P Note that boolean parameters must be explicitly specified as \fBtrue\fR or \fBfalse\fR as seen above\. . .P -If you need to change file parameters (e\.g\., reset the mode or owner), do so within curly braces on the same line: +If you need to change file or directory parameters (e\.g\., reset the mode or owner), do so within curly braces on the same line: . .IP "" 4 . .nf [main] - myfile = /tmp/whatever {owner = root, mode = 644} + vardir = /new/vardir {owner = root, mode = 644} . .fi . .IP "" 0 . .P If you\'re starting out with a fresh configuration, you may wish to let the executable generate a template configuration file for you by invoking the executable in question with the \fB\-\-genconfig\fR command\. The executable will print a template configuration to standard output, which can be redirected to a file like so: . .IP "" 4 . .nf $ puppet agent \-\-genconfig > /etc/puppet/puppet\.conf . .fi . .IP "" 0 . .P Note that this invocation will replace the contents of any pre\-existing \fBpuppet\.conf\fR file, so make a backup of your present config if it contains valuable information\. . .P Like the \fB\-\-genconfig\fR argument, the executables also accept a \fB\-\-genmanifest\fR argument, which will generate a manifest that can be used to manage all of Puppet\'s directories and files and prints it to standard output\. This can likewise be redirected to a file: . .IP "" 4 . .nf $ puppet agent \-\-genmanifest > /etc/puppet/manifests/site\.pp . .fi . .IP "" 0 . .P Puppet can also create user and group accounts for itself (one \fBpuppet\fR group and one \fBpuppet\fR user) if it is invoked as \fBroot\fR with the \fB\-\-mkusers\fR argument: . .IP "" 4 . .nf $ puppet agent \-\-mkusers . .fi . .IP "" 0 . .SH "Signals" The \fBpuppet agent\fR and \fBpuppet master\fR executables catch some signals for special handling\. Both daemons catch (\fBSIGHUP\fR), which forces the server to restart tself\. Predictably, interrupt and terminate (\fBSIGINT\fR and \fBSIGTERM\fR) will shut down the server, whether it be an instance of \fBpuppet agent\fR or \fBpuppet master\fR\. . .P Sending the \fBSIGUSR1\fR signal to an instance of \fBpuppet agent\fR will cause it to immediately begin a new configuration transaction with the server\. This signal has no effect on \fBpuppet master\fR\. . .SH "Configuration Parameter Reference" Below is a list of all documented parameters\. Not all of them are valid with all Puppet executables, but the executables will ignore any inappropriate values\. . -.P -async_storeconfigs ++++++++++++++++++ +.SS "archive_file_server" +During an inspect run, the file bucket server to archive files to if archive_files is set\. . -.P -Whether to use a queueing system to provide asynchronous database integration\. Requires that \fBpuppetqd\fR be running and that \'PSON\' support for ruby be installed\. +.IP "\(bu" 4 +\fIDefault\fR: $server +. +.IP "" 0 +. +.SS "archive_files" +During an inspect run, whether to archive files whose contents are audited to a file bucket\. . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . -.P -authconfig ++++++++++ +.SS "async_storeconfigs" +Whether to use a queueing system to provide asynchronous database integration\. Requires that \fBpuppetqd\fR be running and that \'PSON\' support for ruby be installed\. . -.P +.IP "\(bu" 4 +\fIDefault\fR: false +. +.IP "" 0 +. +.SS "authconfig" The configuration file that defines the rights to the different namespaces and methods\. This can be used as a coarse\-grained authorization system for both \fBpuppet agent\fR and \fBpuppet master\fR\. . .IP "\(bu" 4 \fIDefault\fR: $confdir/namespaceauth\.conf . .IP "" 0 . -.P -autoflush +++++++++ -. -.P +.SS "autoflush" Whether log files should always flush to disk\. . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . -.P -autosign ++++++++ -. -.P +.SS "autosign" Whether to enable autosign\. Valid values are true (which autosigns any key request, and is a very bad idea), false (which never autosigns any key request), and the path to a file, which uses that configuration file to determine which keys to sign\. . .IP "\(bu" 4 \fIDefault\fR: $confdir/autosign\.conf . .IP "" 0 . -.P -bindaddress +++++++++++ -. -.P +.SS "bindaddress" The address a listening server should bind to\. Mongrel servers default to 127\.0\.0\.1 and WEBrick defaults to 0\.0\.0\.0\. . -.P -bucketdir +++++++++ -. -.P +.SS "bucketdir" Where FileBucket files are stored\. . .IP "\(bu" 4 \fIDefault\fR: $vardir/bucket . .IP "" 0 . -.P -ca ++ -. -.P +.SS "ca" Wether the master should function as a certificate authority\. . .IP "\(bu" 4 \fIDefault\fR: true . .IP "" 0 . -.P -ca_days +++++++ -. -.P +.SS "ca_days" How long a certificate should be valid\. This parameter is deprecated, use ca_ttl instead . -.P -ca_md +++++ -. -.P +.SS "ca_md" The type of hash used in certificates\. . .IP "\(bu" 4 \fIDefault\fR: md5 . .IP "" 0 . -.P -ca_name +++++++ -. -.P +.SS "ca_name" The name to use the Certificate Authority certificate\. . .IP "\(bu" 4 -\fIDefault\fR: $certname +\fIDefault\fR: Puppet CA: $certname . .IP "" 0 . -.P -ca_port +++++++ -. -.P +.SS "ca_port" The port to use for the certificate authority\. . .IP "\(bu" 4 \fIDefault\fR: $masterport . .IP "" 0 . -.P -ca_server +++++++++ -. -.P +.SS "ca_server" The server to use for certificate authority requests\. It\'s a separate server because it cannot and does not need to horizontally scale\. . .IP "\(bu" 4 \fIDefault\fR: $server . .IP "" 0 . -.P -ca_ttl ++++++ -. -.P +.SS "ca_ttl" The default TTL for new certificates; valid values must be an integer, optionally followed by one of the units \'y\' (years of 365 days), \'d\' (days), \'h\' (hours), or \'s\' (seconds)\. The unit defaults to seconds\. If this parameter is set, ca_days is ignored\. Examples are \'3600\' (one hour) and \'1825d\', which is the same as \'5y\' (5 years) . .IP "\(bu" 4 \fIDefault\fR: 5y . .IP "" 0 . -.P -cacert ++++++ -. -.P +.SS "cacert" The CA certificate\. . .IP "\(bu" 4 \fIDefault\fR: $cadir/ca_crt\.pem . .IP "" 0 . -.P -cacrl +++++ -. -.P +.SS "cacrl" The certificate revocation list (CRL) for the CA\. Will be used if present but otherwise ignored\. . .IP "\(bu" 4 \fIDefault\fR: $cadir/ca_crl\.pem . .IP "" 0 . -.P -cadir +++++ -. -.P +.SS "cadir" The root directory for the certificate authority\. . .IP "\(bu" 4 \fIDefault\fR: $ssldir/ca . .IP "" 0 . -.P -cakey +++++ -. -.P +.SS "cakey" The CA private key\. . .IP "\(bu" 4 \fIDefault\fR: $cadir/ca_key\.pem . .IP "" 0 . -.P -capass ++++++ -. -.P +.SS "capass" Where the CA stores the password for the private key . .IP "\(bu" 4 \fIDefault\fR: $caprivatedir/ca\.pass . .IP "" 0 . -.P -caprivatedir ++++++++++++ -. -.P +.SS "caprivatedir" Where the CA stores private certificate information\. . .IP "\(bu" 4 \fIDefault\fR: $cadir/private . .IP "" 0 . -.P -capub +++++ -. -.P +.SS "capub" The CA public key\. . .IP "\(bu" 4 \fIDefault\fR: $cadir/ca_pub\.pem . .IP "" 0 . -.P -catalog_format ++++++++++++++ -. -.P +.SS "catalog_format" (Deprecated for \'preferred_serialization_format\') What format to use to dump the catalog\. Only supports \'marshal\' and \'yaml\'\. Only matters on the client, since it asks the server for a specific format\. . -.P -catalog_terminus ++++++++++++++++ -. -.P +.SS "catalog_terminus" Where to get node catalogs\. This is useful to change if, for instance, you\'d like to pre\-compile catalogs and store them in memcached or some other easily\-accessed store\. . .IP "\(bu" 4 \fIDefault\fR: compiler . .IP "" 0 . -.P -cert_inventory ++++++++++++++ -. -.P +.SS "cert_inventory" A Complete listing of all certificates . .IP "\(bu" 4 \fIDefault\fR: $cadir/inventory\.txt . .IP "" 0 . -.P -certdir +++++++ -. -.P +.SS "certdir" The certificate directory\. . .IP "\(bu" 4 \fIDefault\fR: $ssldir/certs . .IP "" 0 . -.P -certdnsnames ++++++++++++ -. -.P +.SS "certdnsnames" The DNS names on the Server certificate as a colon\-separated list\. If it\'s anything other than an empty string, it will be used as an alias in the created certificate\. By default, only the server gets an alias set up, and only for \'puppet\'\. . -.P -certificate_revocation ++++++++++++++++++++++ -. -.P +.SS "certificate_revocation" Whether certificate revocation should be supported by downloading a Certificate Revocation List (CRL) to all clients\. If enabled, CA chaining will almost definitely not work\. . .IP "\(bu" 4 \fIDefault\fR: true . .IP "" 0 . -.P -certname ++++++++ -. -.P +.SS "certname" The name to use when handling certificates\. Defaults to the fully qualified domain name\. . .IP "\(bu" 4 -\fIDefault\fR: pelin\.members\.linode\.com +\fIDefault\fR: magpie\.puppetlabs\.lan . .IP "" 0 . -.P -classfile +++++++++ -. -.P +.SS "classfile" The file in which puppet agent stores a list of the classes associated with the retrieved configuration\. Can be loaded in the separate \fBpuppet\fR executable using the \fB\-\-loadclasses\fR option\. . .IP "\(bu" 4 \fIDefault\fR: $statedir/classes\.txt . .IP "" 0 . -.P -client_datadir ++++++++++++++ -. -.P +.SS "client_datadir" The directory in which serialized data is stored on the client\. . .IP "\(bu" 4 \fIDefault\fR: $vardir/client_data . .IP "" 0 . -.P -clientbucketdir +++++++++++++++ -. -.P +.SS "clientbucketdir" Where FileBucket files are stored locally\. . .IP "\(bu" 4 \fIDefault\fR: $vardir/clientbucket . .IP "" 0 . -.P -clientyamldir +++++++++++++ -. -.P +.SS "clientyamldir" The directory in which client\-side YAML data is stored\. . .IP "\(bu" 4 \fIDefault\fR: $vardir/client_yaml . .IP "" 0 . -.P -code ++++ -. -.P +.SS "code" Code to parse directly\. This is essentially only used by \fBpuppet\fR, and should only be set if you\'re writing your own Puppet executable . -.P -color +++++ -. -.P +.SS "color" Whether to use colors when logging to the console\. Valid values are \fBansi\fR (equivalent to \fBtrue\fR), \fBhtml\fR (mostly used during testing with TextMate), and \fBfalse\fR, which produces no color\. . .IP "\(bu" 4 \fIDefault\fR: ansi . .IP "" 0 . -.P -confdir +++++++ -. -.P -The main Puppet configuration directory\. The default for this parameter is calculated based on the user\. If the process is running as root or the user that \fBpuppet master\fR is supposed to run as, it defaults to a system directory, but if it\'s running as any other user, it defaults to being in \fB~\fR\. +.SS "confdir" +The main Puppet configuration directory\. The default for this parameter is calculated based on the user\. If the process is running as root or the user that Puppet is supposed to run as, it defaults to a system directory, but if it\'s running as any other user, it defaults to being in the user\'s home directory\. . .IP "\(bu" 4 \fIDefault\fR: /etc/puppet . .IP "" 0 . -.P -config ++++++ -. -.P +.SS "config" The configuration file for doc\. . .IP "\(bu" 4 \fIDefault\fR: $confdir/puppet\.conf . .IP "" 0 . -.P -config_version ++++++++++++++ -. -.P +.SS "config_version" How to determine the configuration version\. By default, it will be the time that the configuration is parsed, but you can provide a shell script to override how the version is determined\. The output of this script will be added to every log message in the reports, allowing you to correlate changes on your hosts to the source version on the server\. . -.P -configprint +++++++++++ -. -.P +.SS "configprint" Print the value of a specific configuration parameter\. If a parameter is provided for this, then the value is printed and puppet exits\. Comma\-separate multiple values\. For a list of all values, specify \'all\'\. This feature is only available in Puppet versions higher than 0\.18\.4\. . -.P -configtimeout +++++++++++++ -. -.P +.SS "configtimeout" How long the client should wait for the configuration to be retrieved before considering it a failure\. This can help reduce flapping if too many clients contact the server at one time\. . .IP "\(bu" 4 \fIDefault\fR: 120 . .IP "" 0 . -.P -couchdb_url +++++++++++ -. -.P +.SS "couchdb_url" The url where the puppet couchdb database will be created . .IP "\(bu" 4 \fIDefault\fR: http://127\.0\.0\.1:5984/puppet . .IP "" 0 . -.P -csrdir ++++++ -. -.P +.SS "csrdir" Where the CA stores certificate requests . .IP "\(bu" 4 \fIDefault\fR: $cadir/requests . .IP "" 0 . -.P -daemonize +++++++++ -. -.P +.SS "daemonize" Send the process into the background\. This is the default\. . .IP "\(bu" 4 \fIDefault\fR: true . .IP "" 0 . -.P -dbadapter +++++++++ -. -.P +.SS "dbadapter" The type of database to use\. . .IP "\(bu" 4 \fIDefault\fR: sqlite3 . .IP "" 0 . -.P -dbconnections +++++++++++++ -. -.P -The number of database connections\. Only used when networked databases are used\. Will be ignored if the value is an empty string or is less than 1\. -. -.IP "\(bu" 4 -\fIDefault\fR: 0 -. -.IP "" 0 -. -.P -dblocation ++++++++++ +.SS "dbconnections" +The number of database connections for networked databases\. Will be ignored unless the value is a positive integer\. . -.P +.SS "dblocation" The database cache for client configurations\. Used for querying within the language\. . .IP "\(bu" 4 \fIDefault\fR: $statedir/clientconfigs\.sqlite3 . .IP "" 0 . -.P -dbmigrate +++++++++ -. -.P +.SS "dbmigrate" Whether to automatically migrate the database\. . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . -.P -dbname ++++++ -. -.P +.SS "dbname" The name of the database to use\. . .IP "\(bu" 4 \fIDefault\fR: puppet . .IP "" 0 . -.P -dbpassword ++++++++++ -. -.P +.SS "dbpassword" The database password for caching\. Only used when networked databases are used\. . .IP "\(bu" 4 \fIDefault\fR: puppet . .IP "" 0 . -.P -dbport ++++++ -. -.P +.SS "dbport" The database password for caching\. Only used when networked databases are used\. . -.P -dbserver ++++++++ -. -.P +.SS "dbserver" The database server for caching\. Only used when networked databases are used\. . .IP "\(bu" 4 \fIDefault\fR: localhost . .IP "" 0 . -.P -dbsocket ++++++++ -. -.P +.SS "dbsocket" The database socket location\. Only used when networked databases are used\. Will be ignored if the value is an empty string\. . -.P -dbuser ++++++ -. -.P +.SS "dbuser" The database user for caching\. Only used when networked databases are used\. . .IP "\(bu" 4 \fIDefault\fR: puppet . .IP "" 0 . -.P -diff ++++ -. -.P +.SS "diff" Which diff command to use when printing differences between files\. . .IP "\(bu" 4 \fIDefault\fR: diff . .IP "" 0 . -.P -diff_args +++++++++ -. -.P +.SS "diff_args" Which arguments to pass to the diff command when printing differences between files\. . .IP "\(bu" 4 \fIDefault\fR: \-u . .IP "" 0 . -.P -downcasefacts +++++++++++++ -. -.P +.SS "downcasefacts" Whether facts should be made all lowercase when sent to the server\. . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . -.P -dynamicfacts ++++++++++++ -. -.P +.SS "dynamicfacts" Facts that are dynamic; these facts will be ignored when deciding whether changed facts should result in a recompile\. Multiple facts should be comma\-separated\. . .IP "\(bu" 4 \fIDefault\fR: memorysize,memoryfree,swapsize,swapfree . .IP "" 0 . -.P -environment +++++++++++ -. -.P +.SS "environment" The environment Puppet is running in\. For clients (e\.g\., \fBpuppet agent\fR) this determines the environment itself, which is used to find modules and much more\. For servers (i\.e\., \fBpuppet master\fR) this provides the default environment for nodes we know nothing about\. . .IP "\(bu" 4 \fIDefault\fR: production . .IP "" 0 . -.P -evaltrace +++++++++ -. -.P +.SS "evaltrace" Whether each resource should log when it is being evaluated\. This allows you to interactively see exactly what is being done\. . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . -.P -external_nodes ++++++++++++++ -. -.P +.SS "external_nodes" An external command that can produce node information\. The output must be a YAML dump of a hash, and that hash must have one or both of \fBclasses\fR and \fBparameters\fR, where \fBclasses\fR is an array and \fBparameters\fR is a hash\. For unknown nodes, the commands should exit with a non\-zero exit code\. This command makes it straightforward to store your node mapping information in other data sources like databases\. . .IP "\(bu" 4 \fIDefault\fR: none . .IP "" 0 . -.P -factdest ++++++++ -. -.P +.SS "factdest" Where Puppet should store facts that it pulls down from the central server\. . .IP "\(bu" 4 \fIDefault\fR: $vardir/facts/ . .IP "" 0 . -.P -factpath ++++++++ -. -.P +.SS "factpath" Where Puppet should look for facts\. Multiple directories should be colon\-separated, like normal PATH variables\. . .IP "\(bu" 4 \fIDefault\fR: $vardir/lib/facter:$vardir/facts . .IP "" 0 . -.P -facts_terminus ++++++++++++++ -. -.P +.SS "facts_terminus" The node facts terminus\. . .IP "\(bu" 4 \fIDefault\fR: facter . .IP "" 0 . -.P -factsignore +++++++++++ -. -.P +.SS "factsignore" What files to ignore when pulling down facts\. . .IP "\(bu" 4 \fIDefault\fR: \.svn CVS . .IP "" 0 . -.P -factsource ++++++++++ -. -.P +.SS "factsource" From where to retrieve facts\. The standard Puppet \fBfile\fR type is used for retrieval, so anything that is a valid file source can be used here\. . .IP "\(bu" 4 \fIDefault\fR: puppet://$server/facts/ . .IP "" 0 . -.P -factsync ++++++++ -. -.P +.SS "factsync" Whether facts should be synced with the central server\. . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . -.P -fileserverconfig ++++++++++++++++ -. -.P +.SS "fileserverconfig" Where the fileserver configuration is stored\. . .IP "\(bu" 4 \fIDefault\fR: $confdir/fileserver\.conf . .IP "" 0 . -.P -filetimeout +++++++++++ -. -.P +.SS "filetimeout" The minimum time to wait (in seconds) between checking for updates in configuration files\. This timeout determines how quickly Puppet checks whether a file (such as manifests or templates) has changed on disk\. . .IP "\(bu" 4 \fIDefault\fR: 15 . .IP "" 0 . -.P -freeze_main +++++++++++ -. -.P +.SS "freeze_main" Freezes the \'main\' class, disallowing any code to be added to it\. This essentially means that you can\'t have any code outside of a node, class, or definition other than in the site manifest\. . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . -.P -genconfig +++++++++ -. -.P +.SS "genconfig" Whether to just print a configuration to stdout and exit\. Only makes sense when used interactively\. Takes into account arguments specified on the CLI\. . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . -.P -genmanifest +++++++++++ -. -.P +.SS "genmanifest" Whether to just print a manifest to stdout and exit\. Only makes sense when used interactively\. Takes into account arguments specified on the CLI\. . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . -.P -graph +++++ -. -.P +.SS "graph" Whether to create dot graph files for the different configuration graphs\. These dot files can be interpreted by tools like OmniGraffle or dot (which is part of ImageMagick)\. . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . -.P -graphdir ++++++++ -. -.P +.SS "graphdir" Where to store dot\-outputted graphs\. . .IP "\(bu" 4 \fIDefault\fR: $statedir/graphs . .IP "" 0 . -.P -group +++++ -. -.P +.SS "group" The group puppet master should run as\. . .IP "\(bu" 4 \fIDefault\fR: puppet . .IP "" 0 . -.P -hostcert ++++++++ -. -.P +.SS "hostcert" Where individual hosts store and look for their certificates\. . .IP "\(bu" 4 \fIDefault\fR: $certdir/$certname\.pem . .IP "" 0 . -.P -hostcrl +++++++ -. -.P +.SS "hostcrl" Where the host\'s certificate revocation list can be found\. This is distinct from the certificate authority\'s CRL\. . .IP "\(bu" 4 \fIDefault\fR: $ssldir/crl\.pem . .IP "" 0 . -.P -hostcsr +++++++ -. -.P +.SS "hostcsr" Where individual hosts store and look for their certificate requests\. . .IP "\(bu" 4 \fIDefault\fR: $ssldir/csr_$certname\.pem . .IP "" 0 . -.P -hostprivkey +++++++++++ -. -.P +.SS "hostprivkey" Where individual hosts store and look for their private key\. . .IP "\(bu" 4 \fIDefault\fR: $privatekeydir/$certname\.pem . .IP "" 0 . -.P -hostpubkey ++++++++++ -. -.P +.SS "hostpubkey" Where individual hosts store and look for their public key\. . .IP "\(bu" 4 \fIDefault\fR: $publickeydir/$certname\.pem . .IP "" 0 . -.P -http_compression ++++++++++++++++ -. -.P +.SS "http_compression" Allow http compression in REST communication with the master\. This setting might improve performance for agent \-> master communications over slow WANs\. Your puppetmaster needs to support compression (usually by activating some settings in a reverse\-proxy in front of the puppetmaster, which rules out webrick)\. It is harmless to activate this settings if your master doesn\'t support compression, but if it supports it, this setting might reduce performance on high\-speed LANs\. . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . -.P -http_proxy_host +++++++++++++++ -. -.P +.SS "http_proxy_host" The HTTP proxy host to use for outgoing connections\. Note: You may need to use a FQDN for the server hostname when using a proxy\. . .IP "\(bu" 4 \fIDefault\fR: none . .IP "" 0 . -.P -http_proxy_port +++++++++++++++ -. -.P +.SS "http_proxy_port" The HTTP proxy port to use for outgoing connections . .IP "\(bu" 4 \fIDefault\fR: 3128 . .IP "" 0 . -.P -httplog +++++++ -. -.P +.SS "httplog" Where the puppet agent web server logs\. . .IP "\(bu" 4 \fIDefault\fR: $logdir/http\.log . .IP "" 0 . -.P -ignorecache +++++++++++ -. -.P +.SS "ignorecache" Ignore cache and always recompile the configuration\. This is useful for testing new configurations, where the local cache may in fact be stale even if the timestamps are up to date \- if the facts change or if the server changes\. . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . -.P -ignoreimport ++++++++++++ -. -.P +.SS "ignoreimport" A parameter that can be used in commit hooks, since it enables you to parse\-check a single file rather than requiring that all files exist\. . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . -.P -ignoreschedules +++++++++++++++ -. -.P +.SS "ignoreschedules" Boolean; whether puppet agent should ignore schedules\. This is useful for initial puppet agent runs\. . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . -.P -keylength +++++++++ +.SS "inventory_port" +The port to communicate with the inventory_server\. . -.P +.IP "\(bu" 4 +\fIDefault\fR: $masterport +. +.IP "" 0 +. +.SS "inventory_server" +The server to send facts to\. +. +.IP "\(bu" 4 +\fIDefault\fR: $server +. +.IP "" 0 +. +.SS "inventory_terminus" +Should usually be the same as the facts terminus +. +.IP "\(bu" 4 +\fIDefault\fR: $facts_terminus +. +.IP "" 0 +. +.SS "keylength" The bit length of keys\. . .IP "\(bu" 4 \fIDefault\fR: 1024 . .IP "" 0 . -.P -ldapattrs +++++++++ +.SS "lastrunfile" +Where puppet agent stores the last run report summary in yaml format\. . -.P +.IP "\(bu" 4 +\fIDefault\fR: $statedir/last_run_summary\.yaml +. +.IP "" 0 +. +.SS "lastrunreport" +Where puppet agent stores the last run report in yaml format\. +. +.IP "\(bu" 4 +\fIDefault\fR: $statedir/last_run_report\.yaml +. +.IP "" 0 +. +.SS "ldapattrs" The LDAP attributes to include when querying LDAP for nodes\. All returned attributes are set as variables in the top\-level scope\. Multiple values should be comma\-separated\. The value \'all\' returns all attributes\. . .IP "\(bu" 4 \fIDefault\fR: all . .IP "" 0 . -.P -ldapbase ++++++++ -. -.P +.SS "ldapbase" The search base for LDAP searches\. It\'s impossible to provide a meaningful default here, although the LDAP libraries might have one already set\. Generally, it should be the \'ou=Hosts\' branch under your main directory\. . -.P -ldapclassattrs ++++++++++++++ -. -.P +.SS "ldapclassattrs" The LDAP attributes to use to define Puppet classes\. Values should be comma\-separated\. . .IP "\(bu" 4 \fIDefault\fR: puppetclass . .IP "" 0 . -.P -ldapnodes +++++++++ -. -.P +.SS "ldapnodes" Whether to search for node configurations in LDAP\. See http://projects\.puppetlabs\.com/projects/puppet/wiki/LDAP_Nodes for more information\. . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . -.P -ldapparentattr ++++++++++++++ -. -.P +.SS "ldapparentattr" The attribute to use to define the parent node\. . .IP "\(bu" 4 \fIDefault\fR: parentnode . .IP "" 0 . -.P -ldappassword ++++++++++++ -. -.P +.SS "ldappassword" The password to use to connect to LDAP\. . -.P -ldapport ++++++++ -. -.P +.SS "ldapport" The LDAP port\. Only used if \fBldapnodes\fR is enabled\. . .IP "\(bu" 4 \fIDefault\fR: 389 . .IP "" 0 . -.P -ldapserver ++++++++++ -. -.P +.SS "ldapserver" The LDAP server\. Only used if \fBldapnodes\fR is enabled\. . .IP "\(bu" 4 \fIDefault\fR: ldap . .IP "" 0 . -.P -ldapssl +++++++ -. -.P +.SS "ldapssl" Whether SSL should be used when searching for nodes\. Defaults to false because SSL usually requires certificates to be set up on the client side\. . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . -.P -ldapstackedattrs ++++++++++++++++ -. -.P +.SS "ldapstackedattrs" The LDAP attributes that should be stacked to arrays by adding the values in all hierarchy elements of the tree\. Values should be comma\-separated\. . .IP "\(bu" 4 \fIDefault\fR: puppetvar . .IP "" 0 . -.P -ldapstring ++++++++++ -. -.P +.SS "ldapstring" The search string used to find an LDAP node\. . .IP "\(bu" 4 \fIDefault\fR: (&(objectclass=puppetClient)(cn=%s)) . .IP "" 0 . -.P -ldaptls +++++++ -. -.P +.SS "ldaptls" Whether TLS should be used when searching for nodes\. Defaults to false because TLS usually requires certificates to be set up on the client side\. . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . -.P -ldapuser ++++++++ -. -.P +.SS "ldapuser" The user to use to connect to LDAP\. Must be specified as a full DN\. . -.P -lexical +++++++ -. -.P +.SS "lexical" Whether to use lexical scoping (vs\. dynamic)\. . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . -.P -libdir ++++++ -. -.P +.SS "libdir" An extra search path for Puppet\. This is only useful for those files that Puppet will load on demand, and is only guaranteed to work for those cases\. In fact, the autoload mechanism is responsible for making sure this directory is in Ruby\'s search path . .IP "\(bu" 4 \fIDefault\fR: $vardir/lib . .IP "" 0 . -.P -listen ++++++ -. -.P +.SS "listen" Whether puppet agent should listen for connections\. If this is true, then by default only the \fBrunner\fR server is started, which allows remote authorized and authenticated nodes to connect and trigger \fBpuppet agent\fR runs\. . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . -.P -localcacert +++++++++++ -. -.P +.SS "localcacert" Where each client stores the CA certificate\. . .IP "\(bu" 4 \fIDefault\fR: $certdir/ca\.pem . .IP "" 0 . -.P -localconfig +++++++++++ -. -.P +.SS "localconfig" Where puppet agent caches the local configuration\. An extension indicating the cache format is added automatically\. . .IP "\(bu" 4 \fIDefault\fR: $statedir/localconfig . .IP "" 0 . -.P -logdir ++++++ -. -.P +.SS "logdir" The Puppet log directory\. . .IP "\(bu" 4 \fIDefault\fR: $vardir/log . .IP "" 0 . -.P -manage_internal_file_permissions ++++++++++++++++++++++++++++++++ -. -.P +.SS "manage_internal_file_permissions" Whether Puppet should manage the owner, group, and mode of files it uses internally . .IP "\(bu" 4 \fIDefault\fR: true . .IP "" 0 . -.P -manifest ++++++++ -. -.P +.SS "manifest" The entry\-point manifest for puppet master\. . .IP "\(bu" 4 \fIDefault\fR: $manifestdir/site\.pp . .IP "" 0 . -.P -manifestdir +++++++++++ -. -.P +.SS "manifestdir" Where puppet master looks for its manifests\. . .IP "\(bu" 4 \fIDefault\fR: $confdir/manifests . .IP "" 0 . -.P -masterhttplog +++++++++++++ -. -.P +.SS "masterhttplog" Where the puppet master web server logs\. . .IP "\(bu" 4 \fIDefault\fR: $logdir/masterhttp\.log . .IP "" 0 . -.P -masterlog +++++++++ -. -.P +.SS "masterlog" Where puppet master logs\. This is generally not used, since syslog is the default log destination\. . .IP "\(bu" 4 \fIDefault\fR: $logdir/puppetmaster\.log . .IP "" 0 . -.P -masterport ++++++++++ -. -.P +.SS "masterport" Which port puppet master listens on\. . .IP "\(bu" 4 \fIDefault\fR: 8140 . .IP "" 0 . -.P -maximum_uid +++++++++++ -. -.P +.SS "maximum_uid" The maximum allowed UID\. Some platforms use negative UIDs but then ship with tools that do not know how to handle signed ints, so the UIDs show up as huge numbers that can then not be fed back into the system\. This is a hackish way to fail in a slightly more useful way when that happens\. . .IP "\(bu" 4 \fIDefault\fR: 4294967290 . .IP "" 0 . -.P -mkusers +++++++ -. -.P +.SS "mkusers" Whether to create the necessary user and group that puppet agent will run as\. . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . -.P -modulepath ++++++++++ -. -.P +.SS "modulepath" The search path for modules as a colon\-separated list of directories\. . .IP "\(bu" 4 \fIDefault\fR: $confdir/modules:/usr/share/puppet/modules . .IP "" 0 . -.P -name ++++ -. -.P +.SS "name" The name of the application, if we are running as one\. The default is essentially $0 without the path or \fB\.rb\fR\. . .IP "\(bu" 4 \fIDefault\fR: doc . .IP "" 0 . -.P -node_name +++++++++ -. -.P +.SS "node_name" How the puppetmaster determines the client\'s identity and sets the \'hostname\', \'fqdn\' and \'domain\' facts for use in the manifest, in particular for determining which \'node\' statement applies to the client\. Possible values are \'cert\' (use the subject\'s CN in the client\'s certificate) and \'facter\' (use the hostname that the client reported in its facts) . .IP "\(bu" 4 \fIDefault\fR: cert . .IP "" 0 . -.P -node_terminus +++++++++++++ -. -.P +.SS "node_terminus" Where to find information about nodes\. . .IP "\(bu" 4 \fIDefault\fR: plain . .IP "" 0 . -.P -noop ++++ -. -.P +.SS "noop" Whether puppet agent should be run in noop mode\. . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . -.P -onetime +++++++ -. -.P +.SS "onetime" Run the configuration once, rather than as a long\-running daemon\. This is useful for interactively running puppetd\. . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . -.P -parseonly +++++++++ -. -.P +.SS "parseonly" Just check the syntax of the manifests\. . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . -.P -passfile ++++++++ -. -.P +.SS "passfile" Where puppet agent stores the password for its private key\. Generally unused\. . .IP "\(bu" 4 \fIDefault\fR: $privatedir/password . .IP "" 0 . -.P -path ++++ -. -.P +.SS "path" The shell search path\. Defaults to whatever is inherited from the parent process\. . .IP "\(bu" 4 \fIDefault\fR: none . .IP "" 0 . -.P -pidfile +++++++ -. -.P +.SS "pidfile" The pid file . .IP "\(bu" 4 \fIDefault\fR: $rundir/$name\.pid . .IP "" 0 . -.P -plugindest ++++++++++ -. -.P +.SS "plugindest" Where Puppet should store plugins that it pulls down from the central server\. . .IP "\(bu" 4 \fIDefault\fR: $libdir . .IP "" 0 . -.P -pluginsignore +++++++++++++ -. -.P +.SS "pluginsignore" What files to ignore when pulling down plugins\. . .IP "\(bu" 4 \fIDefault\fR: \.svn CVS \.git . .IP "" 0 . -.P -pluginsource ++++++++++++ -. -.P +.SS "pluginsource" From where to retrieve plugins\. The standard Puppet \fBfile\fR type is used for retrieval, so anything that is a valid file source can be used here\. . .IP "\(bu" 4 \fIDefault\fR: puppet://$server/plugins . .IP "" 0 . -.P -pluginsync ++++++++++ -. -.P +.SS "pluginsync" Whether plugins should be synced with the central server\. . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . -.P -postrun_command +++++++++++++++ -. -.P +.SS "postrun_command" A command to run after every agent run\. If this command returns a non\-zero return code, the entire Puppet run will be considered to have failed, even though it might have performed work during the normal run\. . -.P -preferred_serialization_format ++++++++++++++++++++++++++++++ -. -.P +.SS "preferred_serialization_format" The preferred means of serializing ruby instances for passing over the wire\. This won\'t guarantee that all instances will be serialized using this method, since not all classes can be guaranteed to support this format, but it will be used for all classes that support it\. . .IP "\(bu" 4 \fIDefault\fR: pson . .IP "" 0 . -.P -prerun_command ++++++++++++++ -. -.P +.SS "prerun_command" A command to run before every agent run\. If this command returns a non\-zero return code, the entire Puppet run will fail\. . -.P -privatedir ++++++++++ -. -.P +.SS "privatedir" Where the client stores private certificate information\. . .IP "\(bu" 4 \fIDefault\fR: $ssldir/private . .IP "" 0 . -.P -privatekeydir +++++++++++++ -. -.P +.SS "privatekeydir" The private key directory\. . .IP "\(bu" 4 \fIDefault\fR: $ssldir/private_keys . .IP "" 0 . -.P -publickeydir ++++++++++++ -. -.P +.SS "publickeydir" The public key directory\. . .IP "\(bu" 4 \fIDefault\fR: $ssldir/public_keys . .IP "" 0 . -.P -puppetdlockfile +++++++++++++++ -. -.P +.SS "puppetdlockfile" A lock file to temporarily stop puppet agent from doing anything\. . .IP "\(bu" 4 \fIDefault\fR: $statedir/puppetdlock . .IP "" 0 . -.P -puppetdlog ++++++++++ -. -.P +.SS "puppetdlog" The log file for puppet agent\. This is generally not used\. . .IP "\(bu" 4 \fIDefault\fR: $logdir/puppetd\.log . .IP "" 0 . -.P -puppetport ++++++++++ -. -.P +.SS "puppetport" Which port puppet agent listens on\. . .IP "\(bu" 4 \fIDefault\fR: 8139 . .IP "" 0 . -.P -queue_source ++++++++++++ -. -.P +.SS "queue_source" Which type of queue to use for asynchronous processing\. If your stomp server requires authentication, you can include it in the URI as long as your stomp client library is at least 1\.1\.1 . .IP "\(bu" 4 \fIDefault\fR: stomp://localhost:61613/ . .IP "" 0 . -.P -queue_type ++++++++++ -. -.P +.SS "queue_type" Which type of queue to use for asynchronous processing\. . .IP "\(bu" 4 \fIDefault\fR: stomp . .IP "" 0 . -.P -rails_loglevel ++++++++++++++ -. -.P +.SS "rails_loglevel" The log level for Rails connections\. The value must be a valid log level within Rails\. Production environments normally use \fBinfo\fR and other environments normally use \fBdebug\fR\. . .IP "\(bu" 4 \fIDefault\fR: info . .IP "" 0 . -.P -railslog ++++++++ -. -.P +.SS "railslog" Where Rails\-specific logs are sent . .IP "\(bu" 4 \fIDefault\fR: $logdir/rails\.log . .IP "" 0 . -.P -report ++++++ -. -.P +.SS "report" Whether to send reports after every transaction\. . .IP "\(bu" 4 -\fIDefault\fR: false +\fIDefault\fR: true . .IP "" 0 . -.P -report_port +++++++++++ -. -.P +.SS "report_port" The port to communicate with the report_server\. . .IP "\(bu" 4 \fIDefault\fR: $masterport . .IP "" 0 . -.P -report_server +++++++++++++ -. -.P -The server to which to send transaction reports\. +.SS "report_server" +The server to send transaction reports to\. . .IP "\(bu" 4 \fIDefault\fR: $server . .IP "" 0 . -.P -reportdir +++++++++ -. -.P +.SS "reportdir" The directory in which to store reports received from the client\. Each client gets a separate subdirectory\. . .IP "\(bu" 4 \fIDefault\fR: $vardir/reports . .IP "" 0 . -.P -reportfrom ++++++++++ -. -.P +.SS "reportfrom" The \'from\' email address for the reports\. . .IP "\(bu" 4 -\fIDefault\fR: report@pelin\.members\.linode\.com +\fIDefault\fR: report@magpie\.puppetlabs\.lan . .IP "" 0 . -.P -reports +++++++ -. -.P +.SS "reports" The list of reports to generate\. All reports are looked for in \fBpuppet/reports/name\.rb\fR, and multiple report names should be comma\-separated (whitespace is okay)\. . .IP "\(bu" 4 \fIDefault\fR: store . .IP "" 0 . -.P -reportserver ++++++++++++ -. -.P +.SS "reportserver" (Deprecated for \'report_server\') The server to which to send transaction reports\. . .IP "\(bu" 4 \fIDefault\fR: $server . .IP "" 0 . -.P -reporturl +++++++++ -. -.P +.SS "reporturl" The URL used by the http reports processor to send reports . .IP "\(bu" 4 \fIDefault\fR: http://localhost:3000/reports . .IP "" 0 . -.P -req_bits ++++++++ -. -.P +.SS "req_bits" The bit length of the certificates\. . .IP "\(bu" 4 \fIDefault\fR: 2048 . .IP "" 0 . -.P -requestdir ++++++++++ -. -.P +.SS "requestdir" Where host certificate requests are stored\. . .IP "\(bu" 4 \fIDefault\fR: $ssldir/certificate_requests . .IP "" 0 . -.P -rest_authconfig +++++++++++++++ -. -.P +.SS "rest_authconfig" The configuration file that defines the rights to the different rest indirections\. This can be used as a fine\-grained authorization system for \fBpuppet master\fR\. . .IP "\(bu" 4 \fIDefault\fR: $confdir/auth\.conf . .IP "" 0 . -.P -rrddir ++++++ -. -.P +.SS "rrddir" The directory where RRD database files are stored\. Directories for each reporting host will be created under this directory\. . .IP "\(bu" 4 \fIDefault\fR: $vardir/rrd . .IP "" 0 . -.P -rrdinterval +++++++++++ -. -.P +.SS "rrdinterval" How often RRD should expect data\. This should match how often the hosts report back to the server\. . .IP "\(bu" 4 \fIDefault\fR: $runinterval . .IP "" 0 . -.P -run_mode ++++++++ -. -.P +.SS "run_mode" The effective \'run mode\' of the application: master, agent, or user\. . .IP "\(bu" 4 \fIDefault\fR: master . .IP "" 0 . -.P -rundir ++++++ -. -.P +.SS "rundir" Where Puppet PID files are kept\. . .IP "\(bu" 4 \fIDefault\fR: $vardir/run . .IP "" 0 . -.P -runinterval +++++++++++ -. -.P +.SS "runinterval" How often puppet agent applies the client configuration; in seconds\. . .IP "\(bu" 4 \fIDefault\fR: 1800 . .IP "" 0 . -.P -sendmail ++++++++ -. -.P +.SS "sendmail" Where to find the sendmail binary with which to send email\. . .IP "\(bu" 4 \fIDefault\fR: /usr/sbin/sendmail . .IP "" 0 . -.P -serial ++++++ -. -.P +.SS "serial" Where the serial number for certificates is stored\. . .IP "\(bu" 4 \fIDefault\fR: $cadir/serial . .IP "" 0 . -.P -server ++++++ -. -.P +.SS "server" The server to which server puppet agent should connect . .IP "\(bu" 4 \fIDefault\fR: puppet . .IP "" 0 . -.P -server_datadir ++++++++++++++ -. -.P +.SS "server_datadir" The directory in which serialized data is stored, usually in a subdirectory\. . .IP "\(bu" 4 \fIDefault\fR: $vardir/server_data . .IP "" 0 . -.P -servertype ++++++++++ -. -.P +.SS "servertype" The type of server to use\. Currently supported options are webrick and mongrel\. If you use mongrel, you will need a proxy in front of the process or processes, since Mongrel cannot speak SSL\. . .IP "\(bu" 4 \fIDefault\fR: webrick . .IP "" 0 . -.P -show_diff +++++++++ -. -.P +.SS "show_diff" Whether to print a contextual diff when files are being replaced\. The diff is printed on stdout, so this option is meaningless unless you are running Puppet interactively\. This feature currently requires the \fBdiff/lcs\fR Ruby library\. . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . -.P -signeddir +++++++++ -. -.P +.SS "signeddir" Where the CA stores signed certificates\. . .IP "\(bu" 4 \fIDefault\fR: $cadir/signed . .IP "" 0 . -.P -smtpserver ++++++++++ -. -.P +.SS "smtpserver" The server through which to send email reports\. . .IP "\(bu" 4 \fIDefault\fR: none . .IP "" 0 . -.P -splay +++++ -. -.P +.SS "splay" Whether to sleep for a pseudo\-random (but consistent) amount of time before a run\. . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . -.P -splaylimit ++++++++++ -. -.P +.SS "splaylimit" The maximum time to delay before runs\. Defaults to being the same as the run interval\. . .IP "\(bu" 4 \fIDefault\fR: $runinterval . .IP "" 0 . -.P -ssl_client_header +++++++++++++++++ -. -.P +.SS "ssl_client_header" The header containing an authenticated client\'s SSL DN\. Only used with Mongrel\. This header must be set by the proxy to the authenticated client\'s SSL DN (e\.g\., \fB/CN=puppet\.puppetlabs\.com\fR)\. See http://projects\.puppetlabs\.com/projects/puppet/wiki/Using_Mongrel for more information\. . .IP "\(bu" 4 \fIDefault\fR: HTTP_X_CLIENT_DN . .IP "" 0 . -.P -ssl_client_verify_header ++++++++++++++++++++++++ -. -.P +.SS "ssl_client_verify_header" The header containing the status message of the client verification\. Only used with Mongrel\. This header must be set by the proxy to \'SUCCESS\' if the client successfully authenticated, and anything else otherwise\. See http://projects\.puppetlabs\.com/projects/puppet/wiki/Using_Mongrel for more information\. . .IP "\(bu" 4 \fIDefault\fR: HTTP_X_CLIENT_VERIFY . .IP "" 0 . -.P -ssldir ++++++ -. -.P +.SS "ssldir" Where SSL certificates are kept\. . .IP "\(bu" 4 \fIDefault\fR: $confdir/ssl . .IP "" 0 . -.P -statedir ++++++++ -. -.P +.SS "statedir" The directory where Puppet state is stored\. Generally, this directory can be removed without causing harm (although it might result in spurious service restarts)\. . .IP "\(bu" 4 \fIDefault\fR: $vardir/state . .IP "" 0 . -.P -statefile +++++++++ -. -.P +.SS "statefile" Where puppet agent and puppet master store state associated with the running configuration\. In the case of puppet master, this file reflects the state discovered through interacting with clients\. . .IP "\(bu" 4 \fIDefault\fR: $statedir/state\.yaml . .IP "" 0 . -.P -storeconfigs ++++++++++++ -. -.P +.SS "storeconfigs" Whether to store each client\'s configuration\. This requires ActiveRecord from Ruby on Rails\. . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . -.P -strict_hostname_checking ++++++++++++++++++++++++ -. -.P +.SS "strict_hostname_checking" Whether to only search for the complete hostname as it is in the certificate when searching for node information in the catalogs\. . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . -.P -summarize +++++++++ -. -.P +.SS "summarize" Whether to print a transaction summary\. . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . -.P -syslogfacility ++++++++++++++ -. -.P +.SS "syslogfacility" What syslog facility to use when logging to syslog\. Syslog has a fixed list of valid facilities, and you must choose one of those; you cannot just make one up\. . .IP "\(bu" 4 \fIDefault\fR: daemon . .IP "" 0 . -.P -tagmap ++++++ -. -.P +.SS "tagmap" The mapping between reporting tags and email addresses\. . .IP "\(bu" 4 \fIDefault\fR: $confdir/tagmail\.conf . .IP "" 0 . -.P -tags ++++ -. -.P +.SS "tags" Tags to use to find resources\. If this is set, then only resources tagged with the specified tags will be applied\. Values must be comma\-separated\. . -.P -templatedir +++++++++++ -. -.P +.SS "templatedir" Where Puppet looks for template files\. Can be a list of colon\-seperated directories\. . .IP "\(bu" 4 \fIDefault\fR: $vardir/templates . .IP "" 0 . -.P -thin_storeconfigs +++++++++++++++++ -. -.P +.SS "thin_storeconfigs" Boolean; wether storeconfigs store in the database only the facts and exported resources\. If true, then storeconfigs performance will be higher and still allow exported/collected resources, but other usage external to Puppet might not work . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . -.P -trace +++++ -. -.P +.SS "trace" Whether to print stack traces on some errors . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . -.P -use_cached_catalog ++++++++++++++++++ -. -.P +.SS "use_cached_catalog" Whether to only use the cached catalog rather than compiling a new catalog on every run\. Puppet can be run with this enabled by default and then selectively disabled when a recompile is desired\. . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . -.P -usecacheonfailure +++++++++++++++++ -. -.P +.SS "usecacheonfailure" Whether to use the cached configuration when the remote configuration will not compile\. This option is useful for testing new configurations, where you want to fix the broken configuration rather than reverting to a known\-good one\. . .IP "\(bu" 4 \fIDefault\fR: true . .IP "" 0 . -.P -user ++++ -. -.P +.SS "user" The user puppet master should run as\. . .IP "\(bu" 4 \fIDefault\fR: puppet . .IP "" 0 . -.P -vardir ++++++ -. -.P +.SS "vardir" Where Puppet stores dynamic and growing data\. The default for this parameter is calculated specially, like \fBconfdir\fR_\. . .IP "\(bu" 4 \fIDefault\fR: /var/lib/puppet . .IP "" 0 . -.P -yamldir +++++++ -. -.P +.SS "yamldir" The directory in which YAML data is stored, usually in a subdirectory\. . .IP "\(bu" 4 \fIDefault\fR: $vardir/yaml . .IP "" 0 . -.P -zlib ++++ -. -.P +.SS "zlib" Boolean; whether to use the zlib library . .IP "\(bu" 4 \fIDefault\fR: true . .IP "" 0 . .P -\fIThis page autogenerated on Sat Aug 28 14:00:20 \-0700 2010\fR +\fIThis page autogenerated on Thu Feb 17 09:56:34 \-0800 2011\fR diff --git a/man/man8/filebucket.8 b/man/man8/filebucket.8 index 59afc2ed3..7ff0da9af 100644 --- a/man/man8/filebucket.8 +++ b/man/man8/filebucket.8 @@ -1,105 +1,81 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "FILEBUCKET" "8" "August 2010" "" "" -A stand\-alone Puppet filebucket client\.puppet filebucket [\-h|\-\-help] [\-V|\-\-version] [\-d|\-\-debug] [\-v|\-\-verbose] +.TH "PUPPET\-FILEBUCKET" "8" "February 2011" "Puppet Labs, LLC" "Puppet manual" . -.IP "" 4 +.SH "NAME" +\fBpuppet\-filebucket\fR \- Store and retrieve files in a filebucket . -.nf - - [\-l|\-\-local] [\-r|\-\-remote] - [\-s|\-\-server ] [\-b|\-\-bucket ] \.\.\. +.SH "SYNOPSIS" +A stand\-alone Puppet filebucket client\. . -.fi -. -.IP "" 0 -This is a stand\-alone filebucket client for sending files to a local or central filebucket\.This client can operate in three modes, with only one mode per call: +.SH "USAGE" +puppet filebucket \fImode\fR [\-h|\-\-help] [\-V|\-\-version] [\-d|\-\-debug] [\-v|\-\-verbose] [\-l|\-\-local] [\-r|\-\-remote] [\-s|\-\-server \fIserver\fR] [\-b|\-\-bucket \fIdirectory\fR] \fIfile\fR \fIfile\fR \.\.\. . .P -backup: Send one or more files to the specified file bucket\. Each sent -. -.IP "" 4 -. -.nf - - file is printed with its resulting md5 sum\. -. -.fi -. -.IP "" 0 +Puppet filebucket can operate in three modes, with only one mode per call: . .P -get: Return the text associated with an md5 sum\. The text is printed -. -.IP "" 4 -. -.nf - - to stdout, and only one file can be retrieved at a time\. -. -.fi -. -.IP "" 0 +backup: Send one or more files to the specified file bucket\. Each sent file is printed with its resulting md5 sum\. . .P -restore: Given a file path and an md5 sum, store the content associated -. -.IP "" 4 +get: Return the text associated with an md5 sum\. The text is printed to stdout, and only one file can be retrieved at a time\. . -.nf - - with the sum into the specified file path\. You can specify an - entirely new path to this argument; you are not restricted to - restoring the content to its original location\. -. -.fi +.P +restore: Given a file path and an md5 sum, store the content associated with the sum into the specified file path\. You can specify an entirely new path to this argument; you are not restricted to restoring the content to its original location\. . -.IP "" 0 +.SH "DESCRIPTION" +This is a stand\-alone filebucket client for sending files to a local or central filebucket\. . .P -Note that +filebucket+ defaults to using a network\-based filebucket available on the server named +puppet+\. To use this, you\'ll have to be running as a user with valid Puppet certificates\. Alternatively, you can use your local file bucket by specifying +\-\-local+\.$ puppet filebucket backup /etc/passwd /etc/passwd: 429b225650b912a2ee067b0a4cf1e949 $ puppet filebucket restore /tmp/passwd 429b225650b912a2ee067b0a4cf1e949 $Note that any configuration parameter that\'s valid in the configuration file is also a valid long argument\. For example, \'ssldir\' is a valid configuration parameter, so you can specify \'\-\-ssldir \fIdirectory\fR\' as an argument\. +Note that \'filebucket\' defaults to using a network\-based filebucket available on the server named \'puppet\'\. To use this, you\'ll have to be running as a user with valid Puppet certificates\. Alternatively, you can use your local file bucket by specifying \'\-\-local\'\. +. +.SH "OPTIONS" +Note that any configuration parameter that\'s valid in the configuration file is also a valid long argument\. For example, \'ssldir\' is a valid configuration parameter, so you can specify \'\-\-ssldir \fIdirectory\fR\' as an argument\. . .P See the configuration file documentation at http://docs\.puppetlabs\.com/references/stable/configuration\.html for the full list of acceptable parameters\. A commented list of all configuration options can also be generated by running puppet with \'\-\-genconfig\'\. . -.P -debug: Enable full debugging\. +.TP +\-\-debug +Enable full debugging\. . -.P -help: Print this help message +.TP +\-\-help +Print this help message . -.P -local: Use the local filebucket\. This will use the default +.TP +\-\-local +Use the local filebucket\. This will use the default configuration information\. . -.IP "" 4 +.TP +\-\-remote +Use a remote filebucket\. This will use the default configuration information\. . -.nf - - configuration information\. +.TP +\-\-server +The server to send the file to, instead of locally\. . -.fi +.TP +\-\-verbose +Print extra information\. . -.IP "" 0 +.TP +\-\-version +Print version information\. . -.P -remote: Use a remote filebucket\. This will use the default -. -.IP "" 4 +.SH "EXAMPLE" . .nf - configuration information\. +$ puppet filebucket backup /etc/passwd +/etc/passwd: 429b225650b912a2ee067b0a4cf1e949 +$ puppet filebucket restore /tmp/passwd 429b225650b912a2ee067b0a4cf1e949 . .fi . -.IP "" 0 +.SH "AUTHOR" +Luke Kanies . -.P -server: The server to send the file to, instead of locally\. -. -.P -verbose: Print extra information\. -. -.P -version: Print version information\.puppet filebucket \-b /tmp/filebucket /my/fileLuke KaniesCopyright (c) 2005 Puppet Labs, LLC Licensed under the GNU Public License +.SH "COPYRIGHT" +Copyright (c) 2005 Puppet Labs, LLC Licensed under the GNU Public License diff --git a/man/man8/pi.8 b/man/man8/pi.8 index b70a128e7..c54a7bec7 100644 --- a/man/man8/pi.8 +++ b/man/man8/pi.8 @@ -1,17 +1,51 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "PI" "8" "August 2010" "" "" -Print help about puppet types on the console\. Run with \'\-h\' to get detailed help\.puppet describe [\-h|\-\-help] [\-s|\-\-short] [\-p|\-\-providers] [\-l|\-\-list] [\-m|\-\-meta]Prints details of Puppet types, providers and metaparameters on the console\.help: Print this help text +.TH "PUPPET\-DESCRIBE" "8" "February 2011" "Puppet Labs, LLC" "Puppet manual" . -.P -providers: Describe providers in detail for each type +.SH "NAME" +\fBpuppet\-describe\fR \- Display help about resource types . -.P -list: List all types +.SH "SYNOPSIS" +Prints help about Puppet resource types, providers, and metaparameters\. . -.P -meta: List all metaparameters +.SH "USAGE" +puppet describe [\-h|\-\-help] [\-s|\-\-short] [\-p|\-\-providers] [\-l|\-\-list] [\-m|\-\-meta] . -.P -short: List only parameters without detailpuppet describe \-\-list puppet describe file \-\-providers puppet describe user \-s \-mDavid LutterkortCopyright (c) 2005 Puppet Labs, LLC Licensed under the GNU Public License +.SH "OPTIONS" +. +.TP +\-\-help +Print this help text +. +.TP +\-\-providers +Describe providers in detail for each type +. +.TP +\-\-list +List all types +. +.TP +\-\-meta +List all metaparameters +. +.TP +\-\-short +List only parameters without detail +. +.SH "EXAMPLE" +. +.nf + +$ puppet describe \-\-list +$ puppet describe file \-\-providers +$ puppet describe user \-s \-m +. +.fi +. +.SH "AUTHOR" +David Lutterkort +. +.SH "COPYRIGHT" +Copyright (c) 2005 Puppet Labs, LLC Licensed under the GNU Public License diff --git a/man/man8/puppet-agent.8 b/man/man8/puppet-agent.8 new file mode 100644 index 000000000..3fadd9df7 --- /dev/null +++ b/man/man8/puppet-agent.8 @@ -0,0 +1,139 @@ +.\" generated with Ronn/v0.7.3 +.\" http://github.com/rtomayko/ronn/tree/0.7.3 +. +.TH "PUPPET\-AGENT" "8" "February 2011" "Puppet Labs, LLC" "Puppet manual" +. +.SH "NAME" +\fBpuppet\-agent\fR \- The puppet agent daemon +. +.SH "SYNOPSIS" +Retrieves the client configuration from the puppet master and applies it to the local host\. +. +.P +This service may be run as a daemon, run periodically using cron (or something similar), or run interactively for testing purposes\. +. +.SH "USAGE" +puppet agent [\-D|\-\-daemonize|\-\-no\-daemonize] [\-d|\-\-debug] [\-\-detailed\-exitcodes] [\-\-disable] [\-\-enable] [\-h|\-\-help] [\-\-certname \fIhost name\fR] [\-l|\-\-logdest syslog|\fIfile\fR|console] [\-o|\-\-onetime] [\-\-serve \fIhandler\fR] [\-t|\-\-test] [\-\-noop] [\-\-digest \fIdigest\fR] [\-\-fingerprint] [\-V|\-\-version] [\-v|\-\-verbose] [\-w|\-\-waitforcert \fIseconds\fR] +. +.SH "DESCRIPTION" +This is the main puppet client\. Its job is to retrieve the local machine\'s configuration from a remote server and apply it\. In order to successfully communicate with the remote server, the client must have a certificate signed by a certificate authority that the server trusts; the recommended method for this, at the moment, is to run a certificate authority as part of the puppet server (which is the default)\. The client will connect and request a signed certificate, and will continue connecting until it receives one\. +. +.P +Once the client has a signed certificate, it will retrieve its configuration and apply it\. +. +.SH "USAGE NOTES" +\'puppet agent\' does its best to find a compromise between interactive use and daemon use\. Run with no arguments and no configuration, it will go into the background, attempt to get a signed certificate, and retrieve and apply its configuration every 30 minutes\. +. +.P +Some flags are meant specifically for interactive use \-\- in particular, \'test\', \'tags\' or \'fingerprint\' are useful\. \'test\' enables verbose logging, causes the daemon to stay in the foreground, exits if the server\'s configuration is invalid (this happens if, for instance, you\'ve left a syntax error on the server), and exits after running the configuration once (rather than hanging around as a long\-running process)\. +. +.P +\'tags\' allows you to specify what portions of a configuration you want to apply\. Puppet elements are tagged with all of the class or definition names that contain them, and you can use the \'tags\' flag to specify one of these names, causing only configuration elements contained within that class or definition to be applied\. This is very useful when you are testing new configurations \-\- for instance, if you are just starting to manage \'ntpd\', you would put all of the new elements into an \'ntpd\' class, and call puppet with \'\-\-tags ntpd\', which would only apply that small portion of the configuration during your testing, rather than applying the whole thing\. +. +.P +\'fingerprint\' is a one\-time flag\. In this mode \'puppet agent\' will run once and display on the console (and in the log) the current certificate (or certificate request) fingerprint\. Providing the \'\-\-digest\' option allows to use a different digest algorithm to generate the fingerprint\. The main use is to verify that before signing a certificate request on the master, the certificate request the master received is the same as the one the client sent (to prevent against man\-in\-the\-middle attacks when signing certificates)\. +. +.SH "OPTIONS" +Note that any configuration parameter that\'s valid in the configuration file is also a valid long argument\. For example, \'server\' is a valid configuration parameter, so you can specify \'\-\-server \fIservername\fR\' as an argument\. +. +.P +See the configuration file documentation at http://docs\.puppetlabs\.com/references/stable/configuration\.html for the full list of acceptable parameters\. A commented list of all configuration options can also be generated by running puppet agent with \'\-\-genconfig\'\. +. +.TP +\-\-daemonize +Send the process into the background\. This is the default\. +. +.TP +\-\-no\-daemonize +Do not send the process into the background\. +. +.TP +\-\-debug +Enable full debugging\. +. +.TP +\-\-digest +Change the certificate fingerprinting digest algorithm\. The default is MD5\. Valid values depends on the version of OpenSSL installed, but should always at least contain MD5, MD2, SHA1 and SHA256\. +. +.TP +\-\-detailed\-exitcodes +Provide transaction information via exit codes\. If this is enabled, an exit code of \'2\' means there were changes, and an exit code of \'4\' means that there were failures during the transaction\. This option only makes sense in conjunction with \-\-onetime\. +. +.TP +\-\-disable +Disable working on the local system\. This puts a lock file in place, causing \'puppet agent\' not to work on the system until the lock file is removed\. This is useful if you are testing a configuration and do not want the central configuration to override the local state until everything is tested and committed\. +. +.IP +\'puppet agent\' uses the same lock file while it is running, so no more than one \'puppet agent\' process is working at a time\. +. +.IP +\'puppet agent\' exits after executing this\. +. +.TP +\-\-enable +Enable working on the local system\. This removes any lock file, causing \'puppet agent\' to start managing the local system again (although it will continue to use its normal scheduling, so it might not start for another half hour)\. +. +.IP +\'puppet agent\' exits after executing this\. +. +.TP +\-\-certname +Set the certname (unique ID) of the client\. The master reads this unique identifying string, which is usually set to the node\'s fully\-qualified domain name, to determine which configurations the node will receive\. Use this option to debug setup problems or implement unusual node identification schemes\. +. +.TP +\-\-help +Print this help message +. +.TP +\-\-logdest +Where to send messages\. Choose between syslog, the console, and a log file\. Defaults to sending messages to syslog, or the console if debugging or verbosity is enabled\. +. +.TP +\-\-no\-client +Do not create a config client\. This will cause the daemon to run without ever checking for its configuration automatically, and only makes sense +. +.TP +\-\-onetime +Run the configuration once\. Runs a single (normally daemonized) Puppet run\. Useful for interactively running puppet agent when used in conjunction with the \-\-no\-daemonize option\. +. +.TP +\-\-fingerprint +Display the current certificate or certificate signing request fingerprint and then exit\. Use the \'\-\-digest\' option to change the digest algorithm used\. +. +.TP +\-\-serve +Start another type of server\. By default, \'puppet agent\' will start a service handler that allows authenticated and authorized remote nodes to trigger the configuration to be pulled down and applied\. You can specify any handler here that does not require configuration, e\.g\., filebucket, ca, or resource\. The handlers are in \'lib/puppet/network/handler\', and the names must match exactly, both in the call to \'serve\' and in \'namespaceauth\.conf\'\. +. +.TP +\-\-test +Enable the most common options used for testing\. These are \'onetime\', \'verbose\', \'ignorecache\', \'no\-daemonize\', \'no\-usecacheonfailure\', \'detailed\-exit\-codes\', \'no\-splay\', and \'show_diff\'\. +. +.TP +\-\-noop +Use \'noop\' mode where the daemon runs in a no\-op or dry\-run mode\. This is useful for seeing what changes Puppet will make without actually executing the changes\. +. +.TP +\-\-verbose +Turn on verbose reporting\. +. +.TP +\-\-version +Print the puppet version number and exit\. +. +.TP +\-\-waitforcert +This option only matters for daemons that do not yet have certificates and it is enabled by default, with a value of 120 (seconds)\. This causes \'puppet agent\' to connect to the server every 2 minutes and ask it to sign a certificate request\. This is useful for the initial setup of a puppet client\. You can turn off waiting for certificates by specifying a time of 0\. +. +.SH "EXAMPLE" +. +.nf + +$ puppet agent \-\-server puppet\.domain\.com +. +.fi +. +.SH "AUTHOR" +Luke Kanies +. +.SH "COPYRIGHT" +Copyright (c) 2005, 2006 Puppet Labs, LLC Licensed under the GNU Public License diff --git a/man/man8/puppet-apply.8 b/man/man8/puppet-apply.8 new file mode 100644 index 000000000..d8d864b56 --- /dev/null +++ b/man/man8/puppet-apply.8 @@ -0,0 +1,75 @@ +.\" generated with Ronn/v0.7.3 +.\" http://github.com/rtomayko/ronn/tree/0.7.3 +. +.TH "PUPPET\-APPLY" "8" "February 2011" "Puppet Labs, LLC" "Puppet manual" +. +.SH "NAME" +\fBpuppet\-apply\fR \- Apply Puppet manifests locally +. +.SH "SYNOPSIS" +Applies a standalone Puppet manifest to the local system\. +. +.SH "USAGE" +puppet apply [\-h|\-\-help] [\-V|\-\-version] [\-d|\-\-debug] [\-v|\-\-verbose] [\-e|\-\-execute] [\-\-detailed\-exitcodes] [\-l|\-\-logdest \fIfile\fR] [\-\-apply \fIcatalog\fR] \fIfile\fR +. +.SH "DESCRIPTION" +This is the standalone puppet execution tool; use it to apply individual manifests\. +. +.P +When provided with a modulepath, via command line or config file, puppet apply can effectively mimic the catalog that would be served by puppet master with access to the same modules, although there are some subtle differences\. When combined with scheduling and an automated system for pushing manifests, this can be used to implement a serverless Puppet site\. +. +.P +Most users should use \'puppet agent\' and \'puppet master\' for site\-wide manifests\. +. +.SH "OPTIONS" +Note that any configuration parameter that\'s valid in the configuration file is also a valid long argument\. For example, \'modulepath\' is a valid configuration parameter, so you can specify \'\-\-tags \fIclass\fR,\fItag\fR\' as an argument\. +. +.P +See the configuration file documentation at http://docs\.puppetlabs\.com/references/stable/configuration\.html for the full list of acceptable parameters\. A commented list of all configuration options can also be generated by running puppet with \'\-\-genconfig\'\. +. +.TP +\-\-debug +Enable full debugging\. +. +.TP +\-\-detailed\-exitcodes +Provide transaction information via exit codes\. If this is enabled, an exit code of \'2\' means there were changes, and an exit code of \'4\' means that there were failures during the transaction\. +. +.TP +\-\-help +Print this help message +. +.TP +\-\-loadclasses +Load any stored classes\. \'puppet agent\' caches configured classes (usually at /etc/puppet/classes\.txt), and setting this option causes all of those classes to be set in your puppet manifest\. +. +.TP +\-\-logdest +Where to send messages\. Choose between syslog, the console, and a log file\. Defaults to sending messages to the console\. +. +.TP +\-\-execute +Execute a specific piece of Puppet code +. +.TP +\-\-verbose +Print extra information\. +. +.TP +\-\-apply +Apply a JSON catalog (such as one generated with \'puppet master \-\-compile\')\. You can either specify a JSON file or pipe in JSON from standard input\. +. +.SH "EXAMPLE" +. +.nf + +$ puppet apply \-l /tmp/manifest\.log manifest\.pp +$ puppet apply \-\-modulepath=/root/dev/modules \-e "include ntpd::server" +. +.fi +. +.SH "AUTHOR" +Luke Kanies +. +.SH "COPYRIGHT" +Copyright (c) 2005 Puppet Labs, LLC Licensed under the GNU Public License diff --git a/man/man8/puppet-cert.8 b/man/man8/puppet-cert.8 new file mode 100644 index 000000000..bea7596d4 --- /dev/null +++ b/man/man8/puppet-cert.8 @@ -0,0 +1,94 @@ +.\" generated with Ronn/v0.7.3 +.\" http://github.com/rtomayko/ronn/tree/0.7.3 +. +.TH "PUPPET\-CERT" "8" "February 2011" "Puppet Labs, LLC" "Puppet manual" +. +.SH "NAME" +\fBpuppet\-cert\fR \- Manage certificates and requests +. +.SH "SYNOPSIS" +Standalone certificate authority\. Capable of generating certificates, but mostly used for signing certificate requests from puppet clients\. +. +.SH "USAGE" +puppet cert [\-h|\-\-help] [\-V|\-\-version] [\-d|\-\-debug] [\-v|\-\-verbose] [\-g|\-\-generate] [\-l|\-\-list] [\-s|\-\-sign] [\-r|\-\-revoke] [\-p|\-\-print] [\-c|\-\-clean] [\-\-verify] [\-\-digest \fIdigest\fR] [\-\-fingerprint] [host] +. +.SH "DESCRIPTION" +Because the puppet master service defaults to not signing client certificate requests, this script is available for signing outstanding requests\. It can be used to list outstanding requests and then either sign them individually or sign all of them\. +. +.SH "OPTIONS" +Note that any configuration parameter that\'s valid in the configuration file is also a valid long argument\. For example, \'ssldir\' is a valid configuration parameter, so you can specify \'\-\-ssldir \fIdirectory\fR\' as an argument\. +. +.P +See the configuration file documentation at http://docs\.puppetlabs\.com/references/stable/configuration\.html for the full list of acceptable parameters\. A commented list of all configuration options can also be generated by running puppet cert with \'\-\-genconfig\'\. +. +.TP +\-\-all +Operate on all items\. Currently only makes sense with \'\-\-sign\', \'\-\-clean\', or \'\-\-list\'\. +. +.TP +\-\-digest +Set the digest for fingerprinting (defaults to md5)\. Valid values depends on your openssl and openssl ruby extension version, but should contain at least md5, sha1, md2, sha256\. +. +.TP +\-\-clean +Remove all files related to a host from puppet cert\'s storage\. This is useful when rebuilding hosts, since new certificate signing requests will only be honored if puppet cert does not have a copy of a signed certificate for that host\. The certificate of the host is also revoked\. If \'\-\-all\' is specified then all host certificates, both signed and unsigned, will be removed\. +. +.TP +\-\-debug +Enable full debugging\. +. +.TP +\-\-generate +Generate a certificate for a named client\. A certificate/keypair will be generated for each client named on the command line\. +. +.TP +\-\-help +Print this help message +. +.TP +\-\-list +List outstanding certificate requests\. If \'\-\-all\' is specified, signed certificates are also listed, prefixed by \'+\', and revoked or invalid certificates are prefixed by \'\-\' (the verification outcome is printed in parenthesis)\. +. +.TP +\-\-print +Print the full\-text version of a host\'s certificate\. +. +.TP +\-\-fingerprint +Print the DIGEST (defaults to md5) fingerprint of a host\'s certificate\. +. +.TP +\-\-revoke +Revoke the certificate of a client\. The certificate can be specified either by its serial number, given as a decimal number or a hexadecimal number prefixed by \'0x\', or by its hostname\. The certificate is revoked by adding it to the Certificate Revocation List given by the \'cacrl\' config parameter\. Note that the puppetmasterd needs to be restarted after revoking certificates\. +. +.TP +\-\-sign +Sign an outstanding certificate request\. Unless \'\-\-all\' is specified, hosts must be listed after all flags\. +. +.TP +\-\-verbose +Enable verbosity\. +. +.TP +\-\-version +Print the puppet version number and exit\. +. +.TP +\-\-verify +Verify the named certificate against the local CA certificate\. +. +.SH "EXAMPLE" +. +.nf + +$ puppet cert \-l +culain\.madstop\.com +$ puppet cert \-s culain\.madstop\.com +. +.fi +. +.SH "AUTHOR" +Luke Kanies +. +.SH "COPYRIGHT" +Copyright (c) 2005 Puppet Labs, LLC Licensed under the GNU Public License diff --git a/man/man8/puppet-describe.8 b/man/man8/puppet-describe.8 new file mode 100644 index 000000000..c54a7bec7 --- /dev/null +++ b/man/man8/puppet-describe.8 @@ -0,0 +1,51 @@ +.\" generated with Ronn/v0.7.3 +.\" http://github.com/rtomayko/ronn/tree/0.7.3 +. +.TH "PUPPET\-DESCRIBE" "8" "February 2011" "Puppet Labs, LLC" "Puppet manual" +. +.SH "NAME" +\fBpuppet\-describe\fR \- Display help about resource types +. +.SH "SYNOPSIS" +Prints help about Puppet resource types, providers, and metaparameters\. +. +.SH "USAGE" +puppet describe [\-h|\-\-help] [\-s|\-\-short] [\-p|\-\-providers] [\-l|\-\-list] [\-m|\-\-meta] +. +.SH "OPTIONS" +. +.TP +\-\-help +Print this help text +. +.TP +\-\-providers +Describe providers in detail for each type +. +.TP +\-\-list +List all types +. +.TP +\-\-meta +List all metaparameters +. +.TP +\-\-short +List only parameters without detail +. +.SH "EXAMPLE" +. +.nf + +$ puppet describe \-\-list +$ puppet describe file \-\-providers +$ puppet describe user \-s \-m +. +.fi +. +.SH "AUTHOR" +David Lutterkort +. +.SH "COPYRIGHT" +Copyright (c) 2005 Puppet Labs, LLC Licensed under the GNU Public License diff --git a/man/man8/puppet-doc.8 b/man/man8/puppet-doc.8 new file mode 100644 index 000000000..e0cabd5d1 --- /dev/null +++ b/man/man8/puppet-doc.8 @@ -0,0 +1,101 @@ +.\" generated with Ronn/v0.7.3 +.\" http://github.com/rtomayko/ronn/tree/0.7.3 +. +.TH "PUPPET\-DOC" "8" "February 2011" "Puppet Labs, LLC" "Puppet manual" +. +.SH "NAME" +\fBpuppet\-doc\fR \- Generate Puppet documentation and references +. +.SH "SYNOPSIS" +Generates a reference for all Puppet types\. Largely meant for internal Puppet Labs use\. +. +.SH "USAGE" +puppet doc [\-a|\-\-all] [\-h|\-\-help] [\-o|\-\-outputdir \fIrdoc\-outputdir\fR] [\-m|\-\-mode text|pdf|rdoc] [\-r|\-\-reference \fIreference\-name\fR] [\-\-charset \fIcharset\fR] [\fImanifest\-file\fR] +. +.SH "DESCRIPTION" +If mode is not \'rdoc\', then this command generates a Markdown document describing all installed Puppet types or all allowable arguments to puppet executables\. It is largely meant for internal use and is used to generate the reference document available on the Puppet Labs web site\. +. +.P +In \'rdoc\' mode, this command generates an html RDoc hierarchy describing the manifests that are in \'manifestdir\' and \'modulepath\' configuration directives\. The generated documentation directory is doc by default but can be changed with the \'outputdir\' option\. +. +.P +If the command is run with the name of a manifest file as an argument, puppet doc will output a single manifest\'s documentation on stdout\. +. +.SH "OPTIONS" +. +.TP +\-\-all +Output the docs for all of the reference types\. In \'rdoc\' modes, this also outputs documentation for all resources +. +.TP +\-\-help +Print this help message +. +.TP +\-\-outputdir +Specifies the directory where to output the rdoc documentation in \'rdoc\' mode\. +. +.TP +\-\-mode +Determine the output mode\. Valid modes are \'text\', \'pdf\' and \'rdoc\'\. The \'pdf\' mode creates PDF formatted files in the /tmp directory\. The default mode is \'text\'\. In \'rdoc\' mode you must provide \'manifests\-path\' +. +.TP +\-\-reference +Build a particular reference\. Get a list of references by running \'puppet doc \-\-list\'\. +. +.TP +\-\-charset +Used only in \'rdoc\' mode\. It sets the charset used in the html files produced\. +. +.SH "EXAMPLE" +. +.nf + +$ puppet doc \-r type > /tmp/type_reference\.markdown +. +.fi +. +.P +or +. +.IP "" 4 +. +.nf + +$ puppet doc \-\-outputdir /tmp/rdoc \-\-mode rdoc /path/to/manifests +. +.fi +. +.IP "" 0 +. +.P +or +. +.IP "" 4 +. +.nf + +$ puppet doc /etc/puppet/manifests/site\.pp +. +.fi +. +.IP "" 0 +. +.P +or +. +.IP "" 4 +. +.nf + +$ puppet doc \-m pdf \-r configuration +. +.fi +. +.IP "" 0 +. +.SH "AUTHOR" +Luke Kanies +. +.SH "COPYRIGHT" +Copyright (c) 2005\-2007 Puppet Labs, LLC Licensed under the GNU Public License diff --git a/man/man8/puppet-filebucket.8 b/man/man8/puppet-filebucket.8 new file mode 100644 index 000000000..7ff0da9af --- /dev/null +++ b/man/man8/puppet-filebucket.8 @@ -0,0 +1,81 @@ +.\" generated with Ronn/v0.7.3 +.\" http://github.com/rtomayko/ronn/tree/0.7.3 +. +.TH "PUPPET\-FILEBUCKET" "8" "February 2011" "Puppet Labs, LLC" "Puppet manual" +. +.SH "NAME" +\fBpuppet\-filebucket\fR \- Store and retrieve files in a filebucket +. +.SH "SYNOPSIS" +A stand\-alone Puppet filebucket client\. +. +.SH "USAGE" +puppet filebucket \fImode\fR [\-h|\-\-help] [\-V|\-\-version] [\-d|\-\-debug] [\-v|\-\-verbose] [\-l|\-\-local] [\-r|\-\-remote] [\-s|\-\-server \fIserver\fR] [\-b|\-\-bucket \fIdirectory\fR] \fIfile\fR \fIfile\fR \.\.\. +. +.P +Puppet filebucket can operate in three modes, with only one mode per call: +. +.P +backup: Send one or more files to the specified file bucket\. Each sent file is printed with its resulting md5 sum\. +. +.P +get: Return the text associated with an md5 sum\. The text is printed to stdout, and only one file can be retrieved at a time\. +. +.P +restore: Given a file path and an md5 sum, store the content associated with the sum into the specified file path\. You can specify an entirely new path to this argument; you are not restricted to restoring the content to its original location\. +. +.SH "DESCRIPTION" +This is a stand\-alone filebucket client for sending files to a local or central filebucket\. +. +.P +Note that \'filebucket\' defaults to using a network\-based filebucket available on the server named \'puppet\'\. To use this, you\'ll have to be running as a user with valid Puppet certificates\. Alternatively, you can use your local file bucket by specifying \'\-\-local\'\. +. +.SH "OPTIONS" +Note that any configuration parameter that\'s valid in the configuration file is also a valid long argument\. For example, \'ssldir\' is a valid configuration parameter, so you can specify \'\-\-ssldir \fIdirectory\fR\' as an argument\. +. +.P +See the configuration file documentation at http://docs\.puppetlabs\.com/references/stable/configuration\.html for the full list of acceptable parameters\. A commented list of all configuration options can also be generated by running puppet with \'\-\-genconfig\'\. +. +.TP +\-\-debug +Enable full debugging\. +. +.TP +\-\-help +Print this help message +. +.TP +\-\-local +Use the local filebucket\. This will use the default configuration information\. +. +.TP +\-\-remote +Use a remote filebucket\. This will use the default configuration information\. +. +.TP +\-\-server +The server to send the file to, instead of locally\. +. +.TP +\-\-verbose +Print extra information\. +. +.TP +\-\-version +Print version information\. +. +.SH "EXAMPLE" +. +.nf + +$ puppet filebucket backup /etc/passwd +/etc/passwd: 429b225650b912a2ee067b0a4cf1e949 +$ puppet filebucket restore /tmp/passwd 429b225650b912a2ee067b0a4cf1e949 +. +.fi +. +.SH "AUTHOR" +Luke Kanies +. +.SH "COPYRIGHT" +Copyright (c) 2005 Puppet Labs, LLC Licensed under the GNU Public License diff --git a/man/man8/puppet-inspect.8 b/man/man8/puppet-inspect.8 new file mode 100644 index 000000000..ae19deede --- /dev/null +++ b/man/man8/puppet-inspect.8 @@ -0,0 +1,28 @@ +.\" generated with Ronn/v0.7.3 +.\" http://github.com/rtomayko/ronn/tree/0.7.3 +. +.TH "PUPPET\-INSPECT" "8" "February 2011" "Puppet Labs, LLC" "Puppet manual" +. +.SH "NAME" +\fBpuppet\-inspect\fR \- Send an inspection report +. +.SH "SYNOPSIS" +Prepares and submits an inspection report to the puppet master\. +. +.SH "USAGE" +puppet inspect +. +.SH "DESCRIPTION" +This command uses the cached catalog from the previous run of \'puppet agent\' to determine which attributes of which resources have been marked as auditable with the \'audit\' metaparameter\. It then examines the current state of the system, writes the state of the specified resource attributes to a report, and submits the report to the puppet master\. +. +.P +Puppet inspect does not run as a daemon, and must be run manually or from cron\. +. +.SH "OPTIONS" +Any configuration setting which is valid in the configuration file is also a valid long argument, e\.g\. \'\-\-server=master\.domain\.com\'\. See the configuration file documentation at http://docs\.puppetlabs\.com/references/latest/configuration\.html for the full list of acceptable settings\. +. +.SH "AUTHOR" +Puppet Labs +. +.SH "COPYRIGHT" +Copyright (c) 2011 Puppet Labs, LLC Licensed under the GNU General Public License version 2 diff --git a/man/man8/puppet-kick.8 b/man/man8/puppet-kick.8 new file mode 100644 index 000000000..b6a868918 --- /dev/null +++ b/man/man8/puppet-kick.8 @@ -0,0 +1,115 @@ +.\" generated with Ronn/v0.7.3 +.\" http://github.com/rtomayko/ronn/tree/0.7.3 +. +.TH "PUPPET\-KICK" "8" "February 2011" "Puppet Labs, LLC" "Puppet manual" +. +.SH "NAME" +\fBpuppet\-kick\fR \- Remotely control puppet agent +. +.SH "SYNOPSIS" +Trigger a puppet agent run on a set of hosts\. +. +.SH "USAGE" +puppet kick [\-a|\-\-all] [\-c|\-\-class \fIclass\fR] [\-d|\-\-debug] [\-f|\-\-foreground] [\-h|\-\-help] [\-\-host \fIhost\fR] [\-\-no\-fqdn] [\-\-ignoreschedules] [\-t|\-\-tag \fItag\fR] [\-\-test] [\-p|\-\-ping] \fIhost\fR [\fIhost\fR [\.\.\.]] +. +.SH "DESCRIPTION" +This script can be used to connect to a set of machines running \'puppet agent\' and trigger them to run their configurations\. The most common usage would be to specify a class of hosts and a set of tags, and \'puppet kick\' would look up in LDAP all of the hosts matching that class, then connect to each host and trigger a run of all of the objects with the specified tags\. +. +.P +If you are not storing your host configurations in LDAP, you can specify hosts manually\. +. +.P +You will most likely have to run \'puppet kick\' as root to get access to the SSL certificates\. +. +.P +\'puppet kick\' reads \'puppet master\'\'s configuration file, so that it can copy things like LDAP settings\. +. +.SH "USAGE NOTES" +\'puppet kick\' is useless unless \'puppet agent\' is listening\. See its documentation for more information, but the gist is that you must enable \'listen\' on the \'puppet agent\' daemon, either using \'\-\-listen\' on the command line or adding \'listen = true\' in its config file\. In addition, you need to set the daemons up to specifically allow connections by creating the \'namespaceauth\' file, normally at \'/etc/puppet/namespaceauth\.conf\'\. This file specifies who has access to each namespace; if you create the file you must add every namespace you want any Puppet daemon to allow \-\- it is currently global to all Puppet daemons\. +. +.P +An example file looks like this: +. +.IP "" 4 +. +.nf + +[fileserver] + allow *\.madstop\.com + +[puppetmaster] + allow *\.madstop\.com + +[puppetrunner] + allow culain\.madstop\.com +. +.fi +. +.IP "" 0 +. +.P +This is what you would install on your Puppet master; non\-master hosts could leave off the \'fileserver\' and \'puppetmaster\' namespaces\. +. +.SH "OPTIONS" +Note that any configuration parameter that\'s valid in the configuration file is also a valid long argument\. For example, \'ssldir\' is a valid configuration parameter, so you can specify \'\-\-ssldir \fIdirectory\fR\' as an argument\. +. +.P +See the configuration file documentation at http://docs\.puppetlabs\.com/references/latest/configuration\.html for the full list of acceptable parameters\. A commented list of all configuration options can also be generated by running puppet master with \'\-\-genconfig\'\. +. +.TP +\-\-all +Connect to all available hosts\. Requires LDAP support at this point\. +. +.TP +\-\-class +Specify a class of machines to which to connect\. This only works if you have LDAP configured, at the moment\. +. +.TP +\-\-debug +Enable full debugging\. +. +.TP +\-\-foreground +Run each configuration in the foreground; that is, when connecting to a host, do not return until the host has finished its run\. The default is false\. +. +.TP +\-\-help +Print this help message +. +.TP +\-\-host +A specific host to which to connect\. This flag can be specified more than once\. +. +.TP +\-\-ignoreschedules +Whether the client should ignore schedules when running its configuration\. This can be used to force the client to perform work it would not normally perform so soon\. The default is false\. +. +.TP +\-\-parallel +How parallel to make the connections\. Parallelization is provided by forking for each client to which to connect\. The default is 1, meaning serial execution\. +. +.TP +\-\-tag +Specify a tag for selecting the objects to apply\. Does not work with the \-\-test option\. +. +.TP +\-\-test +Print the hosts you would connect to but do not actually connect\. This option requires LDAP support at this point\. +. +.TP +\-\-ping +Do a ICMP echo against the target host\. Skip hosts that don\'t respond to ping\. +. +.SH "EXAMPLE" +. +.nf + +$ sudo puppet kick \-p 10 \-t remotefile \-t webserver host1 host2 +. +.fi +. +.SH "AUTHOR" +Luke Kanies +. +.SH "COPYRIGHT" +Copyright (c) 2005 Puppet Labs, LLC Licensed under the GNU Public License diff --git a/man/man8/puppet-master.8 b/man/man8/puppet-master.8 new file mode 100644 index 000000000..9ed2a6ad6 --- /dev/null +++ b/man/man8/puppet-master.8 @@ -0,0 +1,63 @@ +.\" generated with Ronn/v0.7.3 +.\" http://github.com/rtomayko/ronn/tree/0.7.3 +. +.TH "PUPPET\-MASTER" "8" "February 2011" "Puppet Labs, LLC" "Puppet manual" +. +.SH "NAME" +\fBpuppet\-master\fR \- The puppet master daemon +. +.SH "SYNOPSIS" +The central puppet server\. Functions as a certificate authority by default\. +. +.SH "USAGE" +puppet master [\-D|\-\-daemonize|\-\-no\-daemonize] [\-d|\-\-debug] [\-h|\-\-help] [\-l|\-\-logdest \fIfile\fR|console|syslog] [\-v|\-\-verbose] [\-V|\-\-version] [\-\-compile \fInode\-name\fR] +. +.SH "DESCRIPTION" +This command starts an instance of puppet master, running as a daemon and using Ruby\'s built\-in Webrick webserver\. Puppet master can also be managed by other application servers; when this is the case, this executable is not used\. +. +.SH "OPTIONS" +Note that any configuration parameter that\'s valid in the configuration file is also a valid long argument\. For example, \'ssldir\' is a valid configuration parameter, so you can specify \'\-\-ssldir \fIdirectory\fR\' as an argument\. +. +.P +See the configuration file documentation at http://docs\.puppetlabs\.com/references/stable/configuration\.html for the full list of acceptable parameters\. A commented list of all configuration options can also be generated by running puppet master with \'\-\-genconfig\'\. +. +.TP +\-\-daemonize +Send the process into the background\. This is the default\. +. +.TP +\-\-no\-daemonize +Do not send the process into the background\. +. +.TP +\-\-debug +Enable full debugging\. +. +.TP +\-\-help +Print this help message\. +. +.TP +\-\-logdest +Where to send messages\. Choose between syslog, the console, and a log file\. Defaults to sending messages to syslog, or the console if debugging or verbosity is enabled\. +. +.TP +\-\-verbose +Enable verbosity\. +. +.TP +\-\-version +Print the puppet version number and exit\. +. +.TP +\-\-compile +Compile a catalogue and output it in JSON from the puppet master\. Uses facts contained in the $vardir/yaml/ directory to compile the catalog\. +. +.SH "EXAMPLE" +puppet master +. +.SH "AUTHOR" +Luke Kanies +. +.SH "COPYRIGHT" +Copyright (c) 2005 Puppet Labs, LLC Licensed under the GNU Public License diff --git a/man/man8/puppet-queue.8 b/man/man8/puppet-queue.8 new file mode 100644 index 000000000..7dbd683bf --- /dev/null +++ b/man/man8/puppet-queue.8 @@ -0,0 +1,55 @@ +.\" generated with Ronn/v0.7.3 +.\" http://github.com/rtomayko/ronn/tree/0.7.3 +. +.TH "PUPPET\-QUEUE" "8" "February 2011" "Puppet Labs, LLC" "Puppet manual" +. +.SH "NAME" +\fBpuppet\-queue\fR \- Queuing daemon for asynchronous storeconfigs +. +.SH "SYNOPSIS" +Retrieves serialized storeconfigs records from a queue and processes them in order\. +. +.SH "USAGE" +puppet queue [\-d|\-\-debug] [\-v|\-\-verbose] +. +.SH "DESCRIPTION" +This application runs as a daemon and processes storeconfigs data, retrieving the data from a stomp server message queue and writing it to a database\. +. +.P +For more information, including instructions for properly setting up your puppet master and message queue, see the documentation on setting up asynchronous storeconfigs at: http://projects\.puppetlabs\.com/projects/1/wiki/Using_Stored_Configuration +. +.SH "OPTIONS" +Note that any configuration parameter that\'s valid in the configuration file is also a valid long argument\. For example, \'server\' is a valid configuration parameter, so you can specify \'\-\-server \fIservername\fR\' as an argument\. +. +.P +See the configuration file documentation at http://docs\.puppetlabs\.com/references/stable/configuration\.html for the full list of acceptable parameters\. A commented list of all configuration options can also be generated by running puppet queue with \'\-\-genconfig\'\. +. +.TP +\-\-debug +Enable full debugging\. +. +.TP +\-\-help +Print this help message +. +.TP +\-\-verbose +Turn on verbose reporting\. +. +.TP +\-\-version +Print the puppet version number and exit\. +. +.SH "EXAMPLE" +. +.nf + +$ puppet queue +. +.fi +. +.SH "AUTHOR" +Luke Kanies +. +.SH "COPYRIGHT" +Copyright (c) 2009 Puppet Labs, LLC Licensed under the GNU Public License diff --git a/man/man8/puppet-resource.8 b/man/man8/puppet-resource.8 new file mode 100644 index 000000000..738537e84 --- /dev/null +++ b/man/man8/puppet-resource.8 @@ -0,0 +1,84 @@ +.\" generated with Ronn/v0.7.3 +.\" http://github.com/rtomayko/ronn/tree/0.7.3 +. +.TH "PUPPET\-RESOURCE" "8" "February 2011" "Puppet Labs, LLC" "Puppet manual" +. +.SH "NAME" +\fBpuppet\-resource\fR \- The resource abstraction layer shell +. +.SH "SYNOPSIS" +Uses the Puppet RAL to directly interact with the system\. +. +.SH "USAGE" +puppet resource [\-h|\-\-help] [\-d|\-\-debug] [\-v|\-\-verbose] [\-e|\-\-edit] [\-H|\-\-host \fIhost\fR] [\-p|\-\-param \fIparameter\fR] [\-t|\-\-types] \fItype\fR [\fIname\fR] [\fIattribute\fR=\fIvalue\fR \.\.\.] +. +.SH "DESCRIPTION" +This command provides simple facilities for converting current system state into Puppet code, along with some ability to modify the current state using Puppet\'s RAL\. +. +.P +By default, you must at least provide a type to list, in which case puppet resource will tell you everything it knows about all resources of that type\. You can optionally specify an instance name, and puppet resource will only describe that single instance\. +. +.P +If given a type, a name, and a series of \fIattribute\fR=\fIvalue\fR pairs, puppet resource will modify the state of the specified resource\. Alternately, if given a type, a name, and the \'\-\-edit\' flag, puppet resource will write its output to a file, open that file in an editor, and then apply the saved file as a Puppet transaction\. +. +.SH "OPTIONS" +Note that any configuration parameter that\'s valid in the configuration file is also a valid long argument\. For example, \'ssldir\' is a valid configuration parameter, so you can specify \'\-\-ssldir \fIdirectory\fR\' as an argument\. +. +.P +See the configuration file documentation at http://docs\.puppetlabs\.com/references/stable/configuration\.html for the full list of acceptable parameters\. A commented list of all configuration options can also be generated by running puppet with \'\-\-genconfig\'\. +. +.TP +\-\-debug +Enable full debugging\. +. +.TP +\-\-edit +Write the results of the query to a file, open the file in an editor, and read the file back in as an executable Puppet manifest\. +. +.TP +\-\-host +When specified, connect to the resource server on the named host and retrieve the list of resouces of the type specified\. +. +.TP +\-\-help +Print this help message\. +. +.TP +\-\-param +Add more parameters to be outputted from queries\. +. +.TP +\-\-types +List all available types\. +. +.TP +\-\-verbose +Print extra information\. +. +.SH "EXAMPLE" +This example uses \fBpuppet resource\fR to return a Puppet configuration for the user \fBluke\fR: +. +.IP "" 4 +. +.nf + +$ puppet resource user luke +user { \'luke\': + home => \'/home/luke\', + uid => \'100\', + ensure => \'present\', + comment => \'Luke Kanies,,,\', + gid => \'1000\', + shell => \'/bin/bash\', + groups => [\'sysadmin\',\'audio\',\'video\',\'puppet\'] +} +. +.fi +. +.IP "" 0 +. +.SH "AUTHOR" +Luke Kanies +. +.SH "COPYRIGHT" +Copyright (c) 2005\-2007 Puppet Labs, LLC Licensed under the GNU Public License diff --git a/man/man8/puppet.8 b/man/man8/puppet.8 index 513d45338..f58a54d41 100644 --- a/man/man8/puppet.8 +++ b/man/man8/puppet.8 @@ -1,10 +1,10 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "PUPPET" "8" "August 2010" "" "" +.TH "PUPPET" "8" "February 2011" "Puppet Labs, LLC" "Puppet manual" . .SH "NAME" \fBpuppet\fR . .P -Usage: puppet command \fIspace separated arguments\fR Available commands are: agent, apply, cert, describe, doc, filebucket, kick, master, queue, resource +Usage: puppet command \fIspace separated arguments\fR Available commands are: agent, apply, cert, describe, doc, filebucket, inspect, kick, master, queue, resource diff --git a/man/man8/puppetca.8 b/man/man8/puppetca.8 index 62fa7a5bf..bea7596d4 100644 --- a/man/man8/puppetca.8 +++ b/man/man8/puppetca.8 @@ -1,169 +1,94 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "PUPPETCA" "8" "August 2010" "" "" -Stand\-alone certificate authority\. Capable of generating certificates but mostly meant for signing certificate requests from puppet clients\.puppet cert [\-h|\-\-help] [\-V|\-\-version] [\-d|\-\-debug] [\-v|\-\-verbose] +.TH "PUPPET\-CERT" "8" "February 2011" "Puppet Labs, LLC" "Puppet manual" . -.IP "" 4 +.SH "NAME" +\fBpuppet\-cert\fR \- Manage certificates and requests . -.nf - - [\-g|\-\-generate] [\-l|\-\-list] [\-s|\-\-sign] [\-r|\-\-revoke] - [\-p|\-\-print] [\-c|\-\-clean] [\-\-verify] [\-\-digest DIGEST] - [\-\-fingerprint] [host] -. -.fi -. -.IP "" 0 -Because the puppetmasterd daemon defaults to not signing client certificate requests, this script is available for signing outstanding requests\. It can be used to list outstanding requests and then either sign them individually or sign all of them\.Note that any configuration parameter that\'s valid in the configuration file is also a valid long argument\. For example, \'ssldir\' is a valid configuration parameter, so you can specify \'\-\-ssldir \fIdirectory\fR\' as an argument\. -. -.P -See the configuration file documentation at http://reductivelabs\.com/projects/puppet/reference/configref\.html for the full list of acceptable parameters\. A commented list of all configuration options can also be generated by running puppet cert with \'\-\-genconfig\'\. -. -.P -all: Operate on all items\. Currently only makes sense with +.SH "SYNOPSIS" +Standalone certificate authority\. Capable of generating certificates, but mostly used for signing certificate requests from puppet clients\. . -.IP "" 4 +.SH "USAGE" +puppet cert [\-h|\-\-help] [\-V|\-\-version] [\-d|\-\-debug] [\-v|\-\-verbose] [\-g|\-\-generate] [\-l|\-\-list] [\-s|\-\-sign] [\-r|\-\-revoke] [\-p|\-\-print] [\-c|\-\-clean] [\-\-verify] [\-\-digest \fIdigest\fR] [\-\-fingerprint] [host] . -.nf - - \'\-\-sign\', \'\-\-clean\', or \'\-\-list\'\. +.SH "DESCRIPTION" +Because the puppet master service defaults to not signing client certificate requests, this script is available for signing outstanding requests\. It can be used to list outstanding requests and then either sign them individually or sign all of them\. . -.fi -. -.IP "" 0 +.SH "OPTIONS" +Note that any configuration parameter that\'s valid in the configuration file is also a valid long argument\. For example, \'ssldir\' is a valid configuration parameter, so you can specify \'\-\-ssldir \fIdirectory\fR\' as an argument\. . .P -digest: Set the digest for fingerprinting (defaults to md5)\. Valid -. -.IP "" 4 -. -.nf - - values depends on your openssl and openssl ruby extension - version, but should contain at least md5, sha1, md2, - sha256\. -. -.fi +See the configuration file documentation at http://docs\.puppetlabs\.com/references/stable/configuration\.html for the full list of acceptable parameters\. A commented list of all configuration options can also be generated by running puppet cert with \'\-\-genconfig\'\. . -.IP "" 0 +.TP +\-\-all +Operate on all items\. Currently only makes sense with \'\-\-sign\', \'\-\-clean\', or \'\-\-list\'\. . -.P -clean: Remove all files related to a host from puppet cert\'s +.TP +\-\-digest +Set the digest for fingerprinting (defaults to md5)\. Valid values depends on your openssl and openssl ruby extension version, but should contain at least md5, sha1, md2, sha256\. . -.IP "" 4 +.TP +\-\-clean +Remove all files related to a host from puppet cert\'s storage\. This is useful when rebuilding hosts, since new certificate signing requests will only be honored if puppet cert does not have a copy of a signed certificate for that host\. The certificate of the host is also revoked\. If \'\-\-all\' is specified then all host certificates, both signed and unsigned, will be removed\. . -.nf - - storage\. This is useful when rebuilding hosts, since new - certificate signing requests will only be honored if puppet - cert does not have a copy of a signed certificate for that - host\. The certificate of the host remains valid\. If \'\-\-all\' - is specified then all host certificates, both signed and - unsigned, will be removed\. +.TP +\-\-debug +Enable full debugging\. . -.fi +.TP +\-\-generate +Generate a certificate for a named client\. A certificate/keypair will be generated for each client named on the command line\. . -.IP "" 0 +.TP +\-\-help +Print this help message . -.P -debug: Enable full debugging\. +.TP +\-\-list +List outstanding certificate requests\. If \'\-\-all\' is specified, signed certificates are also listed, prefixed by \'+\', and revoked or invalid certificates are prefixed by \'\-\' (the verification outcome is printed in parenthesis)\. . -.P -generate: Generate a certificate for a named client\. A +.TP +\-\-print +Print the full\-text version of a host\'s certificate\. . -.IP "" 4 +.TP +\-\-fingerprint +Print the DIGEST (defaults to md5) fingerprint of a host\'s certificate\. . -.nf - - certificate/keypair will be generated for each client named - on the command line\. +.TP +\-\-revoke +Revoke the certificate of a client\. The certificate can be specified either by its serial number, given as a decimal number or a hexadecimal number prefixed by \'0x\', or by its hostname\. The certificate is revoked by adding it to the Certificate Revocation List given by the \'cacrl\' config parameter\. Note that the puppetmasterd needs to be restarted after revoking certificates\. . -.fi +.TP +\-\-sign +Sign an outstanding certificate request\. Unless \'\-\-all\' is specified, hosts must be listed after all flags\. . -.IP "" 0 +.TP +\-\-verbose +Enable verbosity\. . -.P -help: Print this help message +.TP +\-\-version +Print the puppet version number and exit\. . -.P -list: List outstanding certificate requests\. If \'\-\-all\' is +.TP +\-\-verify +Verify the named certificate against the local CA certificate\. . -.IP "" 4 +.SH "EXAMPLE" . .nf - specified, signed certificates are also listed, prefixed by - \'+\', and revoked or invalid certificates are prefixed by - \'\-\' (the verification outcome is printed in parenthesis)\. +$ puppet cert \-l +culain\.madstop\.com +$ puppet cert \-s culain\.madstop\.com . .fi . -.IP "" 0 -. -.P -print: Print the full\-text version of a host\'s certificate\. -. -.P -fingerprint: Print the DIGEST (defaults to md5) fingerprint of a host\'s -. -.IP "" 4 -. -.nf - - certificate\. -. -.fi -. -.IP "" 0 -. -.P -revoke: Revoke the certificate of a client\. The certificate can be -. -.IP "" 4 -. -.nf - - specified either by its serial number, given as a decimal - number or a hexadecimal number prefixed by \'0x\', or by its - hostname\. The certificate is revoked by adding it to the - Certificate Revocation List given by the \'cacrl\' config - parameter\. Note that the puppetmasterd needs to be - restarted after revoking certificates\. -. -.fi -. -.IP "" 0 -. -.P -sign: Sign an outstanding certificate request\. Unless \'\-\-all\' is -. -.IP "" 4 -. -.nf - - specified, hosts must be listed after all flags\. -. -.fi -. -.IP "" 0 -. -.P -verbose: Enable verbosity\. -. -.P -version: Print the puppet version number and exit\. -. -.P -verify: Verify the named certificate against the local CA -. -.IP "" 4 -. -.nf - - certificate\. -. -.fi +.SH "AUTHOR" +Luke Kanies . -.IP "" 0 -$ puppet cert \-l culain\.madstop\.com $ puppet cert \-s culain\.madstop\.comLuke KaniesCopyright (c) 2005 Puppet Labs, LLC Licensed under the GNU Public License +.SH "COPYRIGHT" +Copyright (c) 2005 Puppet Labs, LLC Licensed under the GNU Public License diff --git a/man/man8/puppetd.8 b/man/man8/puppetd.8 index 861137553..3fadd9df7 100644 --- a/man/man8/puppetd.8 +++ b/man/man8/puppetd.8 @@ -1,283 +1,139 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "PUPPETD" "8" "August 2010" "" "" -puppet agent [\-D|\-\-daemonize|\-\-no\-daemonize] [\-d|\-\-debug] +.TH "PUPPET\-AGENT" "8" "February 2011" "Puppet Labs, LLC" "Puppet manual" . -.IP "" 4 +.SH "NAME" +\fBpuppet\-agent\fR \- The puppet agent daemon . -.nf - - [\-\-detailed\-exitcodes] [\-\-disable] [\-\-enable] - [\-h|\-\-help] [\-\-fqdn ] [\-l|\-\-logdest syslog||console] - [\-o|\-\-onetime] [\-\-serve ] [\-t|\-\-test] [\-\-noop] - [\-\-digest ] [\-\-fingerprint] [\-V|\-\-version] - [\-v|\-\-verbose] [\-w|\-\-waitforcert ] -. -.fi -. -.IP "" 0 -This is the main puppet client\. Its job is to retrieve the local machine\'s configuration from a remote server and apply it\. In order to successfully communicate with the remote server, the client must have a certificate signed by a certificate authority that the server trusts; the recommended method for this, at the moment, is to run a certificate authority as part of the puppet server (which is the default)\. The client will connect and request a signed certificate, and will continue connecting until it receives one\. -. -.P -Once the client has a signed certificate, it will retrieve its configuration and apply it\.+puppet agent+ does its best to find a compromise between interactive use and daemon use\. Run with no arguments and no configuration, it will go into the backgroun, attempt to get a signed certificate, and retrieve and apply its configuration every 30 minutes\. -. -.P -Some flags are meant specifically for interactive use \-\- in particular, +test+, +tags+ or +fingerprint+ are useful\. +test+ enables verbose logging, causes the daemon to stay in the foreground, exits if the server\'s configuration is invalid (this happens if, for instance, you\'ve left a syntax error on the server), and exits after running the configuration once (rather than hanging around as a long\-running process)\. -. -.P -+tags+ allows you to specify what portions of a configuration you want to apply\. Puppet elements are tagged with all of the class or definition names that contain them, and you can use the +tags+ flag to specify one of these names, causing only configuration elements contained within that class or definition to be applied\. This is very useful when you are testing new configurations \-\- for instance, if you are just starting to manage +ntpd+, you would put all of the new elements into an +ntpd+ class, and call puppet with +\-\-tags ntpd+, which would only apply that small portion of the configuration during your testing, rather than applying the whole thing\. -. -.P -+fingerprint+ is a one\-time flag\. In this mode +puppet agent+ will run once and display on the console (and in the log) the current certificate (or certificate request) fingerprint\. Providing the +\-\-digest+ option allows to use a different digest algorithm to generate the fingerprint\. The main use is to verify that before signing a certificate request on the master, the certificate request the master received is the same as the one the client sent (to prevent against man\-in\-the\-middle attacks when signing certificates)\.Note that any configuration parameter that\'s valid in the configuration file is also a valid long argument\. For example, \'server\' is a valid configuration parameter, so you can specify \'\-\-server \fIservername\fR\' as an argument\. -. -.P -See the configuration file documentation at http://docs\.puppetlabs\.com/references/stable/configuration\.html for the full list of acceptable parameters\. A commented list of all configuration options can also be generated by running puppet agent with \'\-\-genconfig\'\. -. -.P -daemonize: Send the process into the background\. This is the -. -.IP "" 4 -. -.nf - - default\. -. -.fi -. -.IP "" 0 -. -.P -no\-daemonize: Do not send the process into the background\. -. -.P -debug: Enable full debugging\. +.SH "SYNOPSIS" +Retrieves the client configuration from the puppet master and applies it to the local host\. . .P -digest: Change the certificate fingerprinting digest -. -.IP "" 4 -. -.nf - - algorithm\. The default is MD5\. Valid values depends - on the version of OpenSSL installed, but should - always at least contain MD5, MD2, SHA1 and SHA256\. -. -.fi -. -.IP "" 0 +This service may be run as a daemon, run periodically using cron (or something similar), or run interactively for testing purposes\. . -.P -detailed\-exitcodes: Provide transaction information via exit codes\. If -. -.IP "" 4 -. -.nf - - this is enabled, an exit code of \'2\' means there - were changes, and an exit code of \'4\' means that - there were failures during the transaction\. This - option only makes sense in conjunction with - \-\-onetime\. -. -.fi +.SH "USAGE" +puppet agent [\-D|\-\-daemonize|\-\-no\-daemonize] [\-d|\-\-debug] [\-\-detailed\-exitcodes] [\-\-disable] [\-\-enable] [\-h|\-\-help] [\-\-certname \fIhost name\fR] [\-l|\-\-logdest syslog|\fIfile\fR|console] [\-o|\-\-onetime] [\-\-serve \fIhandler\fR] [\-t|\-\-test] [\-\-noop] [\-\-digest \fIdigest\fR] [\-\-fingerprint] [\-V|\-\-version] [\-v|\-\-verbose] [\-w|\-\-waitforcert \fIseconds\fR] . -.IP "" 0 +.SH "DESCRIPTION" +This is the main puppet client\. Its job is to retrieve the local machine\'s configuration from a remote server and apply it\. In order to successfully communicate with the remote server, the client must have a certificate signed by a certificate authority that the server trusts; the recommended method for this, at the moment, is to run a certificate authority as part of the puppet server (which is the default)\. The client will connect and request a signed certificate, and will continue connecting until it receives one\. . .P -disable: Disable working on the local system\. This puts a -. -.IP "" 4 -. -.nf - - lock file in place, causing +puppet agent+ not to - work on the system until the lock file is removed\. - This is useful if you are testing a configuration - and do not want the central configuration to - override the local state until everything is tested - and committed\. -. -.fi +Once the client has a signed certificate, it will retrieve its configuration and apply it\. . -.IP "" 0 +.SH "USAGE NOTES" +\'puppet agent\' does its best to find a compromise between interactive use and daemon use\. Run with no arguments and no configuration, it will go into the background, attempt to get a signed certificate, and retrieve and apply its configuration every 30 minutes\. . .P -+puppet agent+ uses the same lock file while it is running, so no more than one +puppet agent+ process is working at a time\. +Some flags are meant specifically for interactive use \-\- in particular, \'test\', \'tags\' or \'fingerprint\' are useful\. \'test\' enables verbose logging, causes the daemon to stay in the foreground, exits if the server\'s configuration is invalid (this happens if, for instance, you\'ve left a syntax error on the server), and exits after running the configuration once (rather than hanging around as a long\-running process)\. . .P -+puppet agent+ exits after executing this\. +\'tags\' allows you to specify what portions of a configuration you want to apply\. Puppet elements are tagged with all of the class or definition names that contain them, and you can use the \'tags\' flag to specify one of these names, causing only configuration elements contained within that class or definition to be applied\. This is very useful when you are testing new configurations \-\- for instance, if you are just starting to manage \'ntpd\', you would put all of the new elements into an \'ntpd\' class, and call puppet with \'\-\-tags ntpd\', which would only apply that small portion of the configuration during your testing, rather than applying the whole thing\. . .P -enable: Enable working on the local system\. This removes any +\'fingerprint\' is a one\-time flag\. In this mode \'puppet agent\' will run once and display on the console (and in the log) the current certificate (or certificate request) fingerprint\. Providing the \'\-\-digest\' option allows to use a different digest algorithm to generate the fingerprint\. The main use is to verify that before signing a certificate request on the master, the certificate request the master received is the same as the one the client sent (to prevent against man\-in\-the\-middle attacks when signing certificates)\. . -.IP "" 4 -. -.nf - - lock file, causing +puppet agent+ to start managing - the local system again (although it will continue to - use its normal scheduling, so it might not start for - another half hour)\. -. -.fi -. -.IP "" 0 +.SH "OPTIONS" +Note that any configuration parameter that\'s valid in the configuration file is also a valid long argument\. For example, \'server\' is a valid configuration parameter, so you can specify \'\-\-server \fIservername\fR\' as an argument\. . .P -+puppet agent+ exits after executing this\. -. -.P -fqdn: Set the fully\-qualified domain name of the client\. +See the configuration file documentation at http://docs\.puppetlabs\.com/references/stable/configuration\.html for the full list of acceptable parameters\. A commented list of all configuration options can also be generated by running puppet agent with \'\-\-genconfig\'\. . -.IP "" 4 +.TP +\-\-daemonize +Send the process into the background\. This is the default\. . -.nf - - This is only used for certificate purposes, but can - be used to override the discovered hostname\. If you - need to use this flag, it is generally an indication - of a setup problem\. +.TP +\-\-no\-daemonize +Do not send the process into the background\. . -.fi +.TP +\-\-debug +Enable full debugging\. . -.IP "" 0 +.TP +\-\-digest +Change the certificate fingerprinting digest algorithm\. The default is MD5\. Valid values depends on the version of OpenSSL installed, but should always at least contain MD5, MD2, SHA1 and SHA256\. . -.P -help: Print this help message +.TP +\-\-detailed\-exitcodes +Provide transaction information via exit codes\. If this is enabled, an exit code of \'2\' means there were changes, and an exit code of \'4\' means that there were failures during the transaction\. This option only makes sense in conjunction with \-\-onetime\. . -.P -logdest: Where to send messages\. Choose between syslog, the +.TP +\-\-disable +Disable working on the local system\. This puts a lock file in place, causing \'puppet agent\' not to work on the system until the lock file is removed\. This is useful if you are testing a configuration and do not want the central configuration to override the local state until everything is tested and committed\. . -.IP "" 4 +.IP +\'puppet agent\' uses the same lock file while it is running, so no more than one \'puppet agent\' process is working at a time\. . -.nf - - console, and a log file\. Defaults to sending - messages to syslog, or the console if debugging or - verbosity is enabled\. +.IP +\'puppet agent\' exits after executing this\. . -.fi +.TP +\-\-enable +Enable working on the local system\. This removes any lock file, causing \'puppet agent\' to start managing the local system again (although it will continue to use its normal scheduling, so it might not start for another half hour)\. . -.IP "" 0 +.IP +\'puppet agent\' exits after executing this\. . -.P -no\-client: Do not create a config client\. This will cause the +.TP +\-\-certname +Set the certname (unique ID) of the client\. The master reads this unique identifying string, which is usually set to the node\'s fully\-qualified domain name, to determine which configurations the node will receive\. Use this option to debug setup problems or implement unusual node identification schemes\. . -.IP "" 4 +.TP +\-\-help +Print this help message . -.nf - - daemon to run without ever checking for its - configuration automatically, and only makes sense - when used in conjunction with \-\-listen\. +.TP +\-\-logdest +Where to send messages\. Choose between syslog, the console, and a log file\. Defaults to sending messages to syslog, or the console if debugging or verbosity is enabled\. . -.fi +.TP +\-\-no\-client +Do not create a config client\. This will cause the daemon to run without ever checking for its configuration automatically, and only makes sense . -.IP "" 0 +.TP +\-\-onetime +Run the configuration once\. Runs a single (normally daemonized) Puppet run\. Useful for interactively running puppet agent when used in conjunction with the \-\-no\-daemonize option\. . -.P -onetime: Run the configuration once\. Runs a single (normally +.TP +\-\-fingerprint +Display the current certificate or certificate signing request fingerprint and then exit\. Use the \'\-\-digest\' option to change the digest algorithm used\. . -.IP "" 4 +.TP +\-\-serve +Start another type of server\. By default, \'puppet agent\' will start a service handler that allows authenticated and authorized remote nodes to trigger the configuration to be pulled down and applied\. You can specify any handler here that does not require configuration, e\.g\., filebucket, ca, or resource\. The handlers are in \'lib/puppet/network/handler\', and the names must match exactly, both in the call to \'serve\' and in \'namespaceauth\.conf\'\. . -.nf - - daemonized) Puppet run\. Useful for interactively - running puppet agent when used in conjunction with - the \-\-no\-daemonize option\. -. -.fi -. -.IP "" 0 -. -.P -fingerprint: Display the current certificate or certificate +.TP +\-\-test +Enable the most common options used for testing\. These are \'onetime\', \'verbose\', \'ignorecache\', \'no\-daemonize\', \'no\-usecacheonfailure\', \'detailed\-exit\-codes\', \'no\-splay\', and \'show_diff\'\. . -.IP "" 4 +.TP +\-\-noop +Use \'noop\' mode where the daemon runs in a no\-op or dry\-run mode\. This is useful for seeing what changes Puppet will make without actually executing the changes\. . -.nf - - signing request fingerprint and then exit\. Use the - +\-\-digest+ option to change the digest algorithm - used\. +.TP +\-\-verbose +Turn on verbose reporting\. . -.fi +.TP +\-\-version +Print the puppet version number and exit\. . -.IP "" 0 +.TP +\-\-waitforcert +This option only matters for daemons that do not yet have certificates and it is enabled by default, with a value of 120 (seconds)\. This causes \'puppet agent\' to connect to the server every 2 minutes and ask it to sign a certificate request\. This is useful for the initial setup of a puppet client\. You can turn off waiting for certificates by specifying a time of 0\. . -.P -serve: Start another type of server\. By default, +puppet -. -.IP "" 4 +.SH "EXAMPLE" . .nf - agent+ will start a service handler that allows - authenticated and authorized remote nodes to trigger - the configuration to be pulled down and applied\. You - can specify any handler here that does not require - configuration, e\.g\., filebucket, ca, or resource\. - The handlers are in +lib/puppet/network/handler+, - and the names must match exactly, both in the call - to +serve+ and in +namespaceauth\.conf+\. +$ puppet agent \-\-server puppet\.domain\.com . .fi . -.IP "" 0 -. -.P -test: Enable the most common options used for testing\. -. -.IP "" 4 -. -.nf - - These are +onetime+, +verbose+, +ignorecache, - +no\-daemonize+, and +no\-usecacheonfailure+\. -. -.fi -. -.IP "" 0 -. -.P -noop: Use +noop+ mode where the daemon runs in a no\-op or -. -.IP "" 4 -. -.nf - - dry\-run mode\. This is useful for seeing what changes - Puppet will make without actually executing the - changes\. -. -.fi -. -.IP "" 0 -. -.P -verbose: Turn on verbose reporting\. -. -.P -version: Print the puppet version number and exit\. -. -.P -waitforcert: This option only matters for daemons that do not yet -. -.IP "" 4 -. -.nf - - have certificates and it is enabled by default, with - a value of 120 (seconds)\. This causes +puppet agent+ - to connect to the server every 2 minutes and ask it - to sign a certificate request\. This is useful for - the initial setup of a puppet client\. You can turn - off waiting for certificates by specifying a time of - 0\. -. -.fi +.SH "AUTHOR" +Luke Kanies . -.IP "" 0 -puppet agent \-\-server puppet\.domain\.comLuke KaniesCopyright (c) 2005, 2006 Puppet Labs, LLC Licensed under the GNU Public License +.SH "COPYRIGHT" +Copyright (c) 2005, 2006 Puppet Labs, LLC Licensed under the GNU Public License diff --git a/man/man8/puppetdoc.8 b/man/man8/puppetdoc.8 index 47df0e764..e0cabd5d1 100644 --- a/man/man8/puppetdoc.8 +++ b/man/man8/puppetdoc.8 @@ -1,108 +1,101 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "PUPPETDOC" "8" "August 2010" "" "" -Generate a reference for all Puppet types\. Largely meant for internal Puppet Labs use\.puppet doc [\-a|\-\-all] [\-h|\-\-help] [\-o|\-\-outputdir \fIrdoc outputdir\fR] [\-m|\-\-mode \fItext|pdf|rdoc\fR] +.TH "PUPPET\-DOC" "8" "February 2011" "Puppet Labs, LLC" "Puppet manual" . -.IP "" 4 +.SH "NAME" +\fBpuppet\-doc\fR \- Generate Puppet documentation and references . -.nf - - [\-r|\-\-reference <[type]|configuration|\.\.>] [\-\-charset CHARSET] [manifest\-file] +.SH "SYNOPSIS" +Generates a reference for all Puppet types\. Largely meant for internal Puppet Labs use\. . -.fi +.SH "USAGE" +puppet doc [\-a|\-\-all] [\-h|\-\-help] [\-o|\-\-outputdir \fIrdoc\-outputdir\fR] [\-m|\-\-mode text|pdf|rdoc] [\-r|\-\-reference \fIreference\-name\fR] [\-\-charset \fIcharset\fR] [\fImanifest\-file\fR] . -.IP "" 0 +.SH "DESCRIPTION" If mode is not \'rdoc\', then this command generates a Markdown document describing all installed Puppet types or all allowable arguments to puppet executables\. It is largely meant for internal use and is used to generate the reference document available on the Puppet Labs web site\. . .P In \'rdoc\' mode, this command generates an html RDoc hierarchy describing the manifests that are in \'manifestdir\' and \'modulepath\' configuration directives\. The generated documentation directory is doc by default but can be changed with the \'outputdir\' option\. . .P -If the command is started with \'manifest\-file\' command\-line arguments, puppet doc generate a single manifest documentation that is output on stdout\.all: Output the docs for all of the reference types\. In \'rdoc\' +If the command is run with the name of a manifest file as an argument, puppet doc will output a single manifest\'s documentation on stdout\. . -.IP "" 4 +.SH "OPTIONS" . -.nf - - modes, this also outputs documentation for all resources +.TP +\-\-all +Output the docs for all of the reference types\. In \'rdoc\' modes, this also outputs documentation for all resources . -.fi +.TP +\-\-help +Print this help message . -.IP "" 0 +.TP +\-\-outputdir +Specifies the directory where to output the rdoc documentation in \'rdoc\' mode\. . -.P -help: Print this help message +.TP +\-\-mode +Determine the output mode\. Valid modes are \'text\', \'pdf\' and \'rdoc\'\. The \'pdf\' mode creates PDF formatted files in the /tmp directory\. The default mode is \'text\'\. In \'rdoc\' mode you must provide \'manifests\-path\' . -.P -outputdir: Specifies the directory where to output the rdoc +.TP +\-\-reference +Build a particular reference\. Get a list of references by running \'puppet doc \-\-list\'\. . -.IP "" 4 +.TP +\-\-charset +Used only in \'rdoc\' mode\. It sets the charset used in the html files produced\. +. +.SH "EXAMPLE" . .nf - documentation in \'rdoc\' mode\. +$ puppet doc \-r type > /tmp/type_reference\.markdown . .fi . -.IP "" 0 -. .P -mode: Determine the output mode\. Valid modes are \'text\', \'trac\', +or . .IP "" 4 . .nf - \'pdf\' and \'rdoc\'\. The \'pdf\' mode creates PDF formatted files - in the /tmp directory\. The default mode is \'text\'\. In \'rdoc\' - mode you must provide \'manifests\-path\' +$ puppet doc \-\-outputdir /tmp/rdoc \-\-mode rdoc /path/to/manifests . .fi . .IP "" 0 . .P -reference: Build a particular reference\. Get a list of references by +or . .IP "" 4 . .nf - running +puppet doc \-\-list+\. +$ puppet doc /etc/puppet/manifests/site\.pp . .fi . .IP "" 0 . .P -charset: Used only in \'rdoc\' mode\. It sets the charset used in the +or . .IP "" 4 . .nf - html files produced\. +$ puppet doc \-m pdf \-r configuration . .fi . .IP "" 0 -$ puppet doc \-r type > /tmp/type_reference\.rst -. -.P -or -. -.P -$ puppet doc \-\-outputdir /tmp/rdoc \-\-mode rdoc /path/to/manifests . -.P -or -. -.P -$ puppet doc /etc/puppet/manifests/site\.pp +.SH "AUTHOR" +Luke Kanies . -.P -or -. -.P -$ puppet doc \-m pdf \-r configurationLuke KaniesCopyright (c) 2005\-2007 Puppet Labs, LLC Licensed under the GNU Public License +.SH "COPYRIGHT" +Copyright (c) 2005\-2007 Puppet Labs, LLC Licensed under the GNU Public License diff --git a/man/man8/puppetmasterd.8 b/man/man8/puppetmasterd.8 index dde93a3d6..9ed2a6ad6 100644 --- a/man/man8/puppetmasterd.8 +++ b/man/man8/puppetmasterd.8 @@ -1,52 +1,63 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "PUPPETMASTERD" "8" "August 2010" "" "" -The central puppet server\. Functions as a certificate authority by default\.puppet master [\-D|\-\-daemonize|\-\-no\-daemonize] [\-d|\-\-debug] [\-h|\-\-help] +.TH "PUPPET\-MASTER" "8" "February 2011" "Puppet Labs, LLC" "Puppet manual" . -.IP "" 4 +.SH "NAME" +\fBpuppet\-master\fR \- The puppet master daemon . -.nf - - [\-l|\-\-logdest |console|syslog] [\-v|\-\-verbose] [\-V|\-\-version] +.SH "SYNOPSIS" +The central puppet server\. Functions as a certificate authority by default\. . -.fi +.SH "USAGE" +puppet master [\-D|\-\-daemonize|\-\-no\-daemonize] [\-d|\-\-debug] [\-h|\-\-help] [\-l|\-\-logdest \fIfile\fR|console|syslog] [\-v|\-\-verbose] [\-V|\-\-version] [\-\-compile \fInode\-name\fR] . -.IP "" 0 -This is the puppet central daemon\.Note that any configuration parameter that\'s valid in the configuration file is also a valid long argument\. For example, \'ssldir\' is a valid configuration parameter, so you can specify \'\-\-ssldir \fIdirectory\fR\' as an argument\. +.SH "DESCRIPTION" +This command starts an instance of puppet master, running as a daemon and using Ruby\'s built\-in Webrick webserver\. Puppet master can also be managed by other application servers; when this is the case, this executable is not used\. . -.P -See the configuration file documentation at http://docs\.puppetlabs\.com/references/stable/configuration\.html for the full list of acceptable parameters\. A commented list of all configuration options can also be generated by running puppetmasterdd with \'\-\-genconfig\'\. +.SH "OPTIONS" +Note that any configuration parameter that\'s valid in the configuration file is also a valid long argument\. For example, \'ssldir\' is a valid configuration parameter, so you can specify \'\-\-ssldir \fIdirectory\fR\' as an argument\. . .P -daemonize: Send the process into the background\. This is the default\. +See the configuration file documentation at http://docs\.puppetlabs\.com/references/stable/configuration\.html for the full list of acceptable parameters\. A commented list of all configuration options can also be generated by running puppet master with \'\-\-genconfig\'\. . -.P -no\-daemonize: Do not send the process into the background\. +.TP +\-\-daemonize +Send the process into the background\. This is the default\. . -.P -debug: Enable full debugging\. +.TP +\-\-no\-daemonize +Do not send the process into the background\. . -.P -help: Print this help message\. +.TP +\-\-debug +Enable full debugging\. . -.P -logdest: Where to send messages\. Choose between syslog, the +.TP +\-\-help +Print this help message\. . -.IP "" 4 +.TP +\-\-logdest +Where to send messages\. Choose between syslog, the console, and a log file\. Defaults to sending messages to syslog, or the console if debugging or verbosity is enabled\. . -.nf - - console, and a log file\. Defaults to sending messages to - syslog, or the console if debugging or verbosity is - enabled\. +.TP +\-\-verbose +Enable verbosity\. . -.fi +.TP +\-\-version +Print the puppet version number and exit\. . -.IP "" 0 +.TP +\-\-compile +Compile a catalogue and output it in JSON from the puppet master\. Uses facts contained in the $vardir/yaml/ directory to compile the catalog\. . -.P -verbose: Enable verbosity\. +.SH "EXAMPLE" +puppet master . -.P -version: Print the puppet version number and exit\.puppet masterLuke KaniesCopyright (c) 2005 Puppet Labs, LLC Licensed under the GNU Public License +.SH "AUTHOR" +Luke Kanies +. +.SH "COPYRIGHT" +Copyright (c) 2005 Puppet Labs, LLC Licensed under the GNU Public License diff --git a/man/man8/puppetqd.8 b/man/man8/puppetqd.8 index f630c74a5..7dbd683bf 100644 --- a/man/man8/puppetqd.8 +++ b/man/man8/puppetqd.8 @@ -1,20 +1,55 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "PUPPETQD" "8" "August 2010" "" "" -puppet queue [\-d|\-\-debug] [\-v|\-\-verbose]This is a simple application that just processes entities in a queue as they are recieved\.Note that any configuration parameter that\'s valid in the configuration file is also a valid long argument\. For example, \'server\' is a valid configuration parameter, so you can specify \'\-\-server \fIservername\fR\' as an argument\. +.TH "PUPPET\-QUEUE" "8" "February 2011" "Puppet Labs, LLC" "Puppet manual" . -.P -See the configuration file documentation at http://docs\.puppetlabs\.com/references/stable/configuration\.html for the full list of acceptable parameters\. A commented list of all configuration options can also be generated by running puppetd with \'\-\-genconfig\'\. +.SH "NAME" +\fBpuppet\-queue\fR \- Queuing daemon for asynchronous storeconfigs . -.P -debug: Enable full debugging\. +.SH "SYNOPSIS" +Retrieves serialized storeconfigs records from a queue and processes them in order\. . -.P -help: Print this help message +.SH "USAGE" +puppet queue [\-d|\-\-debug] [\-v|\-\-verbose] +. +.SH "DESCRIPTION" +This application runs as a daemon and processes storeconfigs data, retrieving the data from a stomp server message queue and writing it to a database\. . .P -verbose: Turn on verbose reporting\. +For more information, including instructions for properly setting up your puppet master and message queue, see the documentation on setting up asynchronous storeconfigs at: http://projects\.puppetlabs\.com/projects/1/wiki/Using_Stored_Configuration +. +.SH "OPTIONS" +Note that any configuration parameter that\'s valid in the configuration file is also a valid long argument\. For example, \'server\' is a valid configuration parameter, so you can specify \'\-\-server \fIservername\fR\' as an argument\. . .P -version: Print the puppet version number and exit\.puppet queueLuke KaniesCopyright (c) 2009 Puppet Labs, LLC Licensed under the GNU Public License +See the configuration file documentation at http://docs\.puppetlabs\.com/references/stable/configuration\.html for the full list of acceptable parameters\. A commented list of all configuration options can also be generated by running puppet queue with \'\-\-genconfig\'\. +. +.TP +\-\-debug +Enable full debugging\. +. +.TP +\-\-help +Print this help message +. +.TP +\-\-verbose +Turn on verbose reporting\. +. +.TP +\-\-version +Print the puppet version number and exit\. +. +.SH "EXAMPLE" +. +.nf + +$ puppet queue +. +.fi +. +.SH "AUTHOR" +Luke Kanies +. +.SH "COPYRIGHT" +Copyright (c) 2009 Puppet Labs, LLC Licensed under the GNU Public License diff --git a/man/man8/puppetrun.8 b/man/man8/puppetrun.8 index 09fa31b15..b6a868918 100644 --- a/man/man8/puppetrun.8 +++ b/man/man8/puppetrun.8 @@ -1,173 +1,115 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "PUPPETRUN" "8" "August 2010" "" "" -Trigger a puppet agent run on a set of hosts\.puppet kick [\-a|\-\-all] [\-c|\-\-class \fIclass\fR] [\-d|\-\-debug] [\-f|\-\-foreground] +.TH "PUPPET\-KICK" "8" "February 2011" "Puppet Labs, LLC" "Puppet manual" . -.IP "" 4 +.SH "NAME" +\fBpuppet\-kick\fR \- Remotely control puppet agent . -.nf - - [\-h|\-\-help] [\-\-host ] [\-\-no\-fqdn] [\-\-ignoreschedules] - [\-t|\-\-tag ] [\-\-test] [\-p|\-\-ping] [ [\.\.\.]] +.SH "SYNOPSIS" +Trigger a puppet agent run on a set of hosts\. . -.fi +.SH "USAGE" +puppet kick [\-a|\-\-all] [\-c|\-\-class \fIclass\fR] [\-d|\-\-debug] [\-f|\-\-foreground] [\-h|\-\-help] [\-\-host \fIhost\fR] [\-\-no\-fqdn] [\-\-ignoreschedules] [\-t|\-\-tag \fItag\fR] [\-\-test] [\-p|\-\-ping] \fIhost\fR [\fIhost\fR [\.\.\.]] . -.IP "" 0 -This script can be used to connect to a set of machines running +puppet agent+ and trigger them to run their configurations\. The most common usage would be to specify a class of hosts and a set of tags, and +puppet kick+ would look up in LDAP all of the hosts matching that class, then connect to each host and trigger a run of all of the objects with the specified tags\. +.SH "DESCRIPTION" +This script can be used to connect to a set of machines running \'puppet agent\' and trigger them to run their configurations\. The most common usage would be to specify a class of hosts and a set of tags, and \'puppet kick\' would look up in LDAP all of the hosts matching that class, then connect to each host and trigger a run of all of the objects with the specified tags\. . .P If you are not storing your host configurations in LDAP, you can specify hosts manually\. . .P -You will most likely have to run +puppet kick+ as root to get access to the SSL certificates\. +You will most likely have to run \'puppet kick\' as root to get access to the SSL certificates\. . .P -+puppet kick+ reads +puppet master+\'s configuration file, so that it can copy things like LDAP settings\.+puppet kick+ is useless unless +puppet agent+ is listening\. See its documentation for more information, but the gist is that you must enable +listen+ on the +puppet agent+ daemon, either using +\-\-listen+ on the command line or adding \'listen: true\' in its config file\. In addition, you need to set the daemons up to specifically allow connections by creating the +namespaceauth+ file, normally at \'/etc/puppet/namespaceauth\.conf\'\. This file specifies who has access to each namespace; if you create the file you must add every namespace you want any Puppet daemon to allow \-\- it is currently global to all Puppet daemons\. +\'puppet kick\' reads \'puppet master\'\'s configuration file, so that it can copy things like LDAP settings\. +. +.SH "USAGE NOTES" +\'puppet kick\' is useless unless \'puppet agent\' is listening\. See its documentation for more information, but the gist is that you must enable \'listen\' on the \'puppet agent\' daemon, either using \'\-\-listen\' on the command line or adding \'listen = true\' in its config file\. In addition, you need to set the daemons up to specifically allow connections by creating the \'namespaceauth\' file, normally at \'/etc/puppet/namespaceauth\.conf\'\. This file specifies who has access to each namespace; if you create the file you must add every namespace you want any Puppet daemon to allow \-\- it is currently global to all Puppet daemons\. . .P -An example file looks like this:: +An example file looks like this: . .IP "" 4 . .nf [fileserver] allow *\.madstop\.com [puppetmaster] allow *\.madstop\.com [puppetrunner] allow culain\.madstop\.com . .fi . .IP "" 0 . .P -This is what you would install on your Puppet master; non\-master hosts could leave off the \'fileserver\' and \'puppetmaster\' namespaces\.Note that any configuration parameter that\'s valid in the configuration file is also a valid long argument\. For example, \'ssldir\' is a valid configuration parameter, so you can specify \'\-\-ssldir \fIdirectory\fR\' as an argument\. -. -.P -See the configuration file documentation at http://reductivelabs\.com/projects/puppet/reference/configref\.html for the full list of acceptable parameters\. A commented list of all configuration options can also be generated by running puppet master with \'\-\-genconfig\'\. -. -.P -all: Connect to all available hosts\. Requires LDAP support -. -.IP "" 4 -. -.nf - - at this point\. -. -.fi -. -.IP "" 0 -. -.P -class: Specify a class of machines to which to connect\. This -. -.IP "" 4 -. -.nf - - only works if you have LDAP configured, at the moment\. -. -.fi -. -.IP "" 0 -. -.P -debug: Enable full debugging\. -. -.P -foreground: Run each configuration in the foreground; that is, when -. -.IP "" 4 -. -.nf - - connecting to a host, do not return until the host has - finished its run\. The default is false\. -. -.fi -. -.IP "" 0 -. -.P -help: Print this help message +This is what you would install on your Puppet master; non\-master hosts could leave off the \'fileserver\' and \'puppetmaster\' namespaces\. . -.P -host: A specific host to which to connect\. This flag can be -. -.IP "" 4 -. -.nf - - specified more than once\. -. -.fi -. -.IP "" 0 +.SH "OPTIONS" +Note that any configuration parameter that\'s valid in the configuration file is also a valid long argument\. For example, \'ssldir\' is a valid configuration parameter, so you can specify \'\-\-ssldir \fIdirectory\fR\' as an argument\. . .P -ignoreschedules: Whether the client should ignore schedules when running +See the configuration file documentation at http://docs\.puppetlabs\.com/references/latest/configuration\.html for the full list of acceptable parameters\. A commented list of all configuration options can also be generated by running puppet master with \'\-\-genconfig\'\. . -.IP "" 4 +.TP +\-\-all +Connect to all available hosts\. Requires LDAP support at this point\. . -.nf - - its configuration\. This can be used to force the client - to perform work it would not normally perform so soon\. - The default is false\. +.TP +\-\-class +Specify a class of machines to which to connect\. This only works if you have LDAP configured, at the moment\. . -.fi +.TP +\-\-debug +Enable full debugging\. . -.IP "" 0 +.TP +\-\-foreground +Run each configuration in the foreground; that is, when connecting to a host, do not return until the host has finished its run\. The default is false\. . -.P -parallel: How parallel to make the connections\. Parallelization +.TP +\-\-help +Print this help message . -.IP "" 4 +.TP +\-\-host +A specific host to which to connect\. This flag can be specified more than once\. . -.nf - - is provided by forking for each client to which to - connect\. The default is 1, meaning serial execution\. -. -.fi -. -.IP "" 0 -. -.P -tag: Specify a tag for selecting the objects to apply\. Does -. -.IP "" 4 +.TP +\-\-ignoreschedules +Whether the client should ignore schedules when running its configuration\. This can be used to force the client to perform work it would not normally perform so soon\. The default is false\. . -.nf - - not work with the \-\-test option\. +.TP +\-\-parallel +How parallel to make the connections\. Parallelization is provided by forking for each client to which to connect\. The default is 1, meaning serial execution\. . -.fi +.TP +\-\-tag +Specify a tag for selecting the objects to apply\. Does not work with the \-\-test option\. . -.IP "" 0 +.TP +\-\-test +Print the hosts you would connect to but do not actually connect\. This option requires LDAP support at this point\. . -.P -test: Print the hosts you would connect to but do not +.TP +\-\-ping +Do a ICMP echo against the target host\. Skip hosts that don\'t respond to ping\. . -.IP "" 4 +.SH "EXAMPLE" . .nf - actually connect\. This option requires LDAP support at - this point\. +$ sudo puppet kick \-p 10 \-t remotefile \-t webserver host1 host2 . .fi . -.IP "" 0 +.SH "AUTHOR" +Luke Kanies . -.P -ping:: -. -.P -Do a ICMP echo against the target host\. Skip hosts that don\'t respond to ping\.sudo puppet kick \-p 10 \-t remotefile \-t webserver host1 host2Luke KaniesCopyright (c) 2005 Puppet Labs, LLC Licensed under the GNU Public License +.SH "COPYRIGHT" +Copyright (c) 2005 Puppet Labs, LLC Licensed under the GNU Public License diff --git a/man/man8/ralsh.8 b/man/man8/ralsh.8 index bdc81e90a..738537e84 100644 --- a/man/man8/ralsh.8 +++ b/man/man8/ralsh.8 @@ -1,85 +1,84 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "RALSH" "8" "August 2010" "" "" -Use the Puppet RAL to directly interact with the system\.puppet resource [\-h|\-\-help] [\-d|\-\-debug] [\-v|\-\-verbose] [\-e|\-\-edit] +.TH "PUPPET\-RESOURCE" "8" "February 2011" "Puppet Labs, LLC" "Puppet manual" . -.IP "" 4 +.SH "NAME" +\fBpuppet\-resource\fR \- The resource abstraction layer shell . -.nf - - [\-H|\-\-host ] [\-p|\-\-param ] [\-t|\-\-types] - type +.SH "SYNOPSIS" +Uses the Puppet RAL to directly interact with the system\. . -.fi +.SH "USAGE" +puppet resource [\-h|\-\-help] [\-d|\-\-debug] [\-v|\-\-verbose] [\-e|\-\-edit] [\-H|\-\-host \fIhost\fR] [\-p|\-\-param \fIparameter\fR] [\-t|\-\-types] \fItype\fR [\fIname\fR] [\fIattribute\fR=\fIvalue\fR \.\.\.] . -.IP "" 0 -This command provides simple facilities for converting current system state into Puppet code, along with some ability to use Puppet to affect the current state\. +.SH "DESCRIPTION" +This command provides simple facilities for converting current system state into Puppet code, along with some ability to modify the current state using Puppet\'s RAL\. . .P -By default, you must at least provide a type to list, which case puppet resource will tell you everything it knows about all instances of that type\. You can optionally specify an instance name, and puppet resource will only describe that single instance\. +By default, you must at least provide a type to list, in which case puppet resource will tell you everything it knows about all resources of that type\. You can optionally specify an instance name, and puppet resource will only describe that single instance\. . .P -You can also add +\-\-edit+ as an argument, and puppet resource will write its output to a file, open that file in an editor, and then apply the file as a Puppet transaction\. You can easily use this to use Puppet to make simple changes to a system\.Note that any configuration parameter that\'s valid in the configuration file is also a valid long argument\. For example, \'ssldir\' is a valid configuration parameter, so you can specify \'\-\-ssldir \fIdirectory\fR\' as an argument\. +If given a type, a name, and a series of \fIattribute\fR=\fIvalue\fR pairs, puppet resource will modify the state of the specified resource\. Alternately, if given a type, a name, and the \'\-\-edit\' flag, puppet resource will write its output to a file, open that file in an editor, and then apply the saved file as a Puppet transaction\. . -.P -See the configuration file documentation at http://docs\.puppetlabs\.com/references/stable/configuration\.html for the full list of acceptable parameters\. A commented list of all configuration options can also be generated by running puppet with \'\-\-genconfig\'\. +.SH "OPTIONS" +Note that any configuration parameter that\'s valid in the configuration file is also a valid long argument\. For example, \'ssldir\' is a valid configuration parameter, so you can specify \'\-\-ssldir \fIdirectory\fR\' as an argument\. . .P -debug: Enable full debugging\. +See the configuration file documentation at http://docs\.puppetlabs\.com/references/stable/configuration\.html for the full list of acceptable parameters\. A commented list of all configuration options can also be generated by running puppet with \'\-\-genconfig\'\. . -.P -edit: +.TP +\-\-debug +Enable full debugging\. . -.P +.TP +\-\-edit Write the results of the query to a file, open the file in an editor, and read the file back in as an executable Puppet manifest\. . -.P -host: -. -.P +.TP +\-\-host When specified, connect to the resource server on the named host and retrieve the list of resouces of the type specified\. . -.P -help: -. -.P +.TP +\-\-help Print this help message\. . -.P -param: -. -.P +.TP +\-\-param Add more parameters to be outputted from queries\. . -.P -types: -. -.P +.TP +\-\-types List all available types\. . -.P -verbose: +.TP +\-\-verbose +Print extra information\. . -.P -Print extra information\.This example uses \fBpuppet resource\fR to return Puppet configuration for the user \fBluke\fR: +.SH "EXAMPLE" +This example uses \fBpuppet resource\fR to return a Puppet configuration for the user \fBluke\fR: . .IP "" 4 . .nf - $ puppet resource user luke - user { \'luke\': - home => \'/home/luke\', - uid => \'100\', - ensure => \'present\', - comment => \'Luke Kanies,,,\', - gid => \'1000\', - shell => \'/bin/bash\', - groups => [\'sysadmin\',\'audio\',\'video\',\'puppet\'] - } +$ puppet resource user luke +user { \'luke\': + home => \'/home/luke\', + uid => \'100\', + ensure => \'present\', + comment => \'Luke Kanies,,,\', + gid => \'1000\', + shell => \'/bin/bash\', + groups => [\'sysadmin\',\'audio\',\'video\',\'puppet\'] +} . .fi . .IP "" 0 -Luke KaniesCopyright (c) 2005\-2007 Puppet Labs, LLC Licensed under the GNU Public License +. +.SH "AUTHOR" +Luke Kanies +. +.SH "COPYRIGHT" +Copyright (c) 2005\-2007 Puppet Labs, LLC Licensed under the GNU Public License diff --git a/spec/fixtures/integration/provider/mailalias/aliases/test1 b/spec/fixtures/integration/provider/mailalias/aliases/test1 new file mode 100644 index 000000000..ecf532213 --- /dev/null +++ b/spec/fixtures/integration/provider/mailalias/aliases/test1 @@ -0,0 +1,28 @@ +# Basic system aliases -- these MUST be present +MAILER-DAEMON: postmaster +postmaster: root + +# General redirections for pseudo accounts +bin: root +daemon: root +named: root +nobody: root +uucp: root +www: root +ftp-bugs: root +postfix: root + +# Put your local aliases here. + +# Well-known aliases +manager: root +dumper: root +operator: root +abuse: postmaster + +# trap decode to catch security attacks +decode: root + +# Other tests +anothertest: "|/path/to/rt-mailgate --queue 'another test' --action correspond --url http://my.com/" +test: "|/path/to/rt-mailgate --queue 'test' --action correspond --url http://my.com/" diff --git a/spec/fixtures/unit/parser/lexer/aliastest.pp b/spec/fixtures/unit/parser/lexer/aliastest.pp new file mode 100644 index 000000000..f2b61592e --- /dev/null +++ b/spec/fixtures/unit/parser/lexer/aliastest.pp @@ -0,0 +1,16 @@ +file { "a file": + path => "/tmp/aliastest", + ensure => file +} + +file { "another": + path => "/tmp/aliastest2", + ensure => file, + require => File["a file"] +} + +file { "a third": + path => "/tmp/aliastest3", + ensure => file, + require => File["/tmp/aliastest"] +} diff --git a/spec/fixtures/unit/parser/lexer/append.pp b/spec/fixtures/unit/parser/lexer/append.pp new file mode 100644 index 000000000..20cbda662 --- /dev/null +++ b/spec/fixtures/unit/parser/lexer/append.pp @@ -0,0 +1,11 @@ +$var=['/tmp/file1','/tmp/file2'] + +class arraytest { + $var += ['/tmp/file3', '/tmp/file4'] + file { + $var: + content => "test" + } +} + +include arraytest diff --git a/spec/fixtures/unit/parser/lexer/argumentdefaults.pp b/spec/fixtures/unit/parser/lexer/argumentdefaults.pp new file mode 100644 index 000000000..eac9dd757 --- /dev/null +++ b/spec/fixtures/unit/parser/lexer/argumentdefaults.pp @@ -0,0 +1,14 @@ +# $Id$ + +define testargs($file, $mode = 755) { + file { $file: ensure => file, mode => $mode } +} + +testargs { "testingname": + file => "/tmp/argumenttest1" +} + +testargs { "testingother": + file => "/tmp/argumenttest2", + mode => 644 +} diff --git a/spec/fixtures/unit/parser/lexer/arithmetic_expression.pp b/spec/fixtures/unit/parser/lexer/arithmetic_expression.pp new file mode 100644 index 000000000..aae98a4db --- /dev/null +++ b/spec/fixtures/unit/parser/lexer/arithmetic_expression.pp @@ -0,0 +1,8 @@ + +$one = 1.30 +$two = 2.034e-2 + +$result = ((( $two + 2) / $one) + 4 * 5.45) - (6 << 7) + (0x800 + -9) + + +notice("result is $result == 1295.87692307692") \ No newline at end of file diff --git a/spec/fixtures/unit/parser/lexer/arraytrailingcomma.pp b/spec/fixtures/unit/parser/lexer/arraytrailingcomma.pp new file mode 100644 index 000000000..a410f9553 --- /dev/null +++ b/spec/fixtures/unit/parser/lexer/arraytrailingcomma.pp @@ -0,0 +1,3 @@ +file { + ["/tmp/arraytrailingcomma1","/tmp/arraytrailingcomma2", ]: content => "tmp" +} diff --git a/spec/fixtures/unit/parser/lexer/casestatement.pp b/spec/fixtures/unit/parser/lexer/casestatement.pp new file mode 100644 index 000000000..66ecd72b9 --- /dev/null +++ b/spec/fixtures/unit/parser/lexer/casestatement.pp @@ -0,0 +1,65 @@ +# $Id$ + +$var = "value" + +case $var { + "nope": { + file { "/tmp/fakefile": mode => 644, ensure => file } + } + "value": { + file { "/tmp/existsfile": mode => 755, ensure => file } + } +} + +$ovar = "yayness" + +case $ovar { + "fooness": { + file { "/tmp/nostillexistsfile": mode => 644, ensure => file } + } + "booness", "yayness": { + case $var { + "nep": { + file { "/tmp/noexistsfile": mode => 644, ensure => file } + } + "value": { + file { "/tmp/existsfile2": mode => 755, ensure => file } + } + } + } +} + +case $ovar { + "fooness": { + file { "/tmp/nostillexistsfile": mode => 644, ensure => file } + } + default: { + file { "/tmp/existsfile3": mode => 755, ensure => file } + } +} + +$bool = true + +case $bool { + true: { + file { "/tmp/existsfile4": mode => 755, ensure => file } + } +} + +$yay = yay +$a = yay +$b = boo + +case $yay { + $a: { file { "/tmp/existsfile5": mode => 755, ensure => file } } + $b: { file { "/tmp/existsfile5": mode => 644, ensure => file } } + default: { file { "/tmp/existsfile5": mode => 711, ensure => file } } + +} + +$regexvar = "exists regex" +case $regexvar { + "no match": { file { "/tmp/existsfile6": mode => 644, ensure => file } } + /(.*) regex$/: { file { "/tmp/${1}file6": mode => 755, ensure => file } } + default: { file { "/tmp/existsfile6": mode => 711, ensure => file } } +} diff --git a/spec/fixtures/unit/parser/lexer/classheirarchy.pp b/spec/fixtures/unit/parser/lexer/classheirarchy.pp new file mode 100644 index 000000000..36619d8b9 --- /dev/null +++ b/spec/fixtures/unit/parser/lexer/classheirarchy.pp @@ -0,0 +1,15 @@ +# $Id$ + +class base { + file { "/tmp/classheir1": ensure => file, mode => 755 } +} + +class sub1 inherits base { + file { "/tmp/classheir2": ensure => file, mode => 755 } +} + +class sub2 inherits base { + file { "/tmp/classheir3": ensure => file, mode => 755 } +} + +include sub1, sub2 diff --git a/spec/fixtures/unit/parser/lexer/classincludes.pp b/spec/fixtures/unit/parser/lexer/classincludes.pp new file mode 100644 index 000000000..bd5b44ed7 --- /dev/null +++ b/spec/fixtures/unit/parser/lexer/classincludes.pp @@ -0,0 +1,17 @@ +# $Id$ + +class base { + file { "/tmp/classincludes1": ensure => file, mode => 755 } +} + +class sub1 inherits base { + file { "/tmp/classincludes2": ensure => file, mode => 755 } +} + +class sub2 inherits base { + file { "/tmp/classincludes3": ensure => file, mode => 755 } +} + +$sub = "sub2" + +include sub1, $sub diff --git a/spec/fixtures/unit/parser/lexer/classpathtest.pp b/spec/fixtures/unit/parser/lexer/classpathtest.pp new file mode 100644 index 000000000..580333369 --- /dev/null +++ b/spec/fixtures/unit/parser/lexer/classpathtest.pp @@ -0,0 +1,11 @@ +# $Id$ + +define mytype { + file { "/tmp/classtest": ensure => file, mode => 755 } +} + +class testing { + mytype { "componentname": } +} + +include testing diff --git a/spec/fixtures/unit/parser/lexer/collection.pp b/spec/fixtures/unit/parser/lexer/collection.pp new file mode 100644 index 000000000..bc29510a9 --- /dev/null +++ b/spec/fixtures/unit/parser/lexer/collection.pp @@ -0,0 +1,10 @@ +class one { + @file { "/tmp/colltest1": content => "one" } + @file { "/tmp/colltest2": content => "two" } +} + +class two { + File <| content == "one" |> +} + +include one, two diff --git a/spec/fixtures/unit/parser/lexer/collection_override.pp b/spec/fixtures/unit/parser/lexer/collection_override.pp new file mode 100644 index 000000000..b1b39ab16 --- /dev/null +++ b/spec/fixtures/unit/parser/lexer/collection_override.pp @@ -0,0 +1,8 @@ +@file { + "/tmp/collection": + content => "whatever" +} + +File<| |> { + mode => 0600 +} diff --git a/spec/fixtures/unit/parser/lexer/collection_within_virtual_definitions.pp b/spec/fixtures/unit/parser/lexer/collection_within_virtual_definitions.pp new file mode 100644 index 000000000..3c21468b0 --- /dev/null +++ b/spec/fixtures/unit/parser/lexer/collection_within_virtual_definitions.pp @@ -0,0 +1,20 @@ +define test($name) { + file {"/tmp/collection_within_virtual_definitions1_$name.txt": + content => "File name $name\n" + } + Test2 <||> +} + +define test2() { + file {"/tmp/collection_within_virtual_definitions2_$name.txt": + content => "This is a test\n" + } +} + +node default { + @test {"foo": + name => "foo" + } + @test2 {"foo2": } + Test <||> +} diff --git a/spec/fixtures/unit/parser/lexer/componentmetaparams.pp b/spec/fixtures/unit/parser/lexer/componentmetaparams.pp new file mode 100644 index 000000000..7d9f0c2c1 --- /dev/null +++ b/spec/fixtures/unit/parser/lexer/componentmetaparams.pp @@ -0,0 +1,11 @@ +file { "/tmp/component1": + ensure => file +} + +define thing { + file { $name: ensure => file } +} + +thing { "/tmp/component2": + require => File["/tmp/component1"] +} diff --git a/spec/fixtures/unit/parser/lexer/componentrequire.pp b/spec/fixtures/unit/parser/lexer/componentrequire.pp new file mode 100644 index 000000000..a61d2050c --- /dev/null +++ b/spec/fixtures/unit/parser/lexer/componentrequire.pp @@ -0,0 +1,8 @@ +define testfile($mode) { + file { $name: mode => $mode, ensure => present } +} + +testfile { "/tmp/testing_component_requires2": mode => 755 } + +file { "/tmp/testing_component_requires1": mode => 755, ensure => present, + require => Testfile["/tmp/testing_component_requires2"] } diff --git a/spec/fixtures/unit/parser/lexer/deepclassheirarchy.pp b/spec/fixtures/unit/parser/lexer/deepclassheirarchy.pp new file mode 100644 index 000000000..249e6334d --- /dev/null +++ b/spec/fixtures/unit/parser/lexer/deepclassheirarchy.pp @@ -0,0 +1,23 @@ +# $Id$ + +class base { + file { "/tmp/deepclassheir1": ensure => file, mode => 755 } +} + +class sub1 inherits base { + file { "/tmp/deepclassheir2": ensure => file, mode => 755 } +} + +class sub2 inherits sub1 { + file { "/tmp/deepclassheir3": ensure => file, mode => 755 } +} + +class sub3 inherits sub2 { + file { "/tmp/deepclassheir4": ensure => file, mode => 755 } +} + +class sub4 inherits sub3 { + file { "/tmp/deepclassheir5": ensure => file, mode => 755 } +} + +include sub4 diff --git a/spec/fixtures/unit/parser/lexer/defineoverrides.pp b/spec/fixtures/unit/parser/lexer/defineoverrides.pp new file mode 100644 index 000000000..c68b139e3 --- /dev/null +++ b/spec/fixtures/unit/parser/lexer/defineoverrides.pp @@ -0,0 +1,17 @@ +# $Id$ + +$file = "/tmp/defineoverrides1" + +define myfile($mode) { + file { $name: ensure => file, mode => $mode } +} + +class base { + myfile { $file: mode => 644 } +} + +class sub inherits base { + Myfile[$file] { mode => 755, } # test the end-comma +} + +include sub diff --git a/spec/fixtures/unit/parser/lexer/emptyclass.pp b/spec/fixtures/unit/parser/lexer/emptyclass.pp new file mode 100644 index 000000000..48047e748 --- /dev/null +++ b/spec/fixtures/unit/parser/lexer/emptyclass.pp @@ -0,0 +1,9 @@ +# $Id$ + +define component { +} + +class testing { +} + +include testing diff --git a/spec/fixtures/unit/parser/lexer/emptyexec.pp b/spec/fixtures/unit/parser/lexer/emptyexec.pp new file mode 100644 index 000000000..847a30d18 --- /dev/null +++ b/spec/fixtures/unit/parser/lexer/emptyexec.pp @@ -0,0 +1,3 @@ +exec { "touch /tmp/emptyexectest": + path => "/usr/bin:/bin" +} diff --git a/spec/fixtures/unit/parser/lexer/emptyifelse.pp b/spec/fixtures/unit/parser/lexer/emptyifelse.pp new file mode 100644 index 000000000..598b486ac --- /dev/null +++ b/spec/fixtures/unit/parser/lexer/emptyifelse.pp @@ -0,0 +1,9 @@ + +if false { +} else { + # nothing here +} + +if true { + # still nothing +} diff --git a/spec/fixtures/unit/parser/lexer/falsevalues.pp b/spec/fixtures/unit/parser/lexer/falsevalues.pp new file mode 100644 index 000000000..2143b79a7 --- /dev/null +++ b/spec/fixtures/unit/parser/lexer/falsevalues.pp @@ -0,0 +1,3 @@ +$value = false + +file { "/tmp/falsevalues$value": ensure => file } diff --git a/spec/fixtures/unit/parser/lexer/filecreate.pp b/spec/fixtures/unit/parser/lexer/filecreate.pp new file mode 100644 index 000000000..d7972c234 --- /dev/null +++ b/spec/fixtures/unit/parser/lexer/filecreate.pp @@ -0,0 +1,11 @@ +# $Id$ + +file { + "/tmp/createatest": ensure => file, mode => 755; + "/tmp/createbtest": ensure => file, mode => 755 +} + +file { + "/tmp/createctest": ensure => file; + "/tmp/createdtest": ensure => file; +} diff --git a/spec/fixtures/unit/parser/lexer/fqdefinition.pp b/spec/fixtures/unit/parser/lexer/fqdefinition.pp new file mode 100644 index 000000000..ddb0675a9 --- /dev/null +++ b/spec/fixtures/unit/parser/lexer/fqdefinition.pp @@ -0,0 +1,5 @@ +define one::two($ensure) { + file { "/tmp/fqdefinition": ensure => $ensure } +} + +one::two { "/tmp/fqdefinition": ensure => file } diff --git a/spec/fixtures/unit/parser/lexer/fqparents.pp b/spec/fixtures/unit/parser/lexer/fqparents.pp new file mode 100644 index 000000000..ee2f65423 --- /dev/null +++ b/spec/fixtures/unit/parser/lexer/fqparents.pp @@ -0,0 +1,11 @@ +class base { + class one { + file { "/tmp/fqparent1": ensure => file } + } +} + +class two::three inherits base::one { + file { "/tmp/fqparent2": ensure => file } +} + +include two::three diff --git a/spec/fixtures/unit/parser/lexer/funccomma.pp b/spec/fixtures/unit/parser/lexer/funccomma.pp new file mode 100644 index 000000000..32e34f92e --- /dev/null +++ b/spec/fixtures/unit/parser/lexer/funccomma.pp @@ -0,0 +1,5 @@ +@file { + ["/tmp/funccomma1","/tmp/funccomma2"]: content => "1" +} + +realize( File["/tmp/funccomma1"], File["/tmp/funccomma2"] , ) diff --git a/spec/fixtures/unit/parser/lexer/hash.pp b/spec/fixtures/unit/parser/lexer/hash.pp new file mode 100644 index 000000000..d33249872 --- /dev/null +++ b/spec/fixtures/unit/parser/lexer/hash.pp @@ -0,0 +1,33 @@ + +$hash = { "file" => "/tmp/myhashfile1" } + +file { + $hash["file"]: + ensure => file, content => "content"; +} + +$hash2 = { "a" => { key => "/tmp/myhashfile2" }} + +file { + $hash2["a"][key]: + ensure => file, content => "content"; +} + +define test($a = { "b" => "c" }) { + file { + $a["b"]: + ensure => file, content => "content" + } +} + +test { + "test": + a => { "b" => "/tmp/myhashfile3" } +} + +$hash3 = { mykey => "/tmp/myhashfile4" } +$key = "mykey" + +file { + $hash3[$key]: ensure => file, content => "content" +} diff --git a/spec/fixtures/unit/parser/lexer/ifexpression.pp b/spec/fixtures/unit/parser/lexer/ifexpression.pp new file mode 100644 index 000000000..29a637291 --- /dev/null +++ b/spec/fixtures/unit/parser/lexer/ifexpression.pp @@ -0,0 +1,12 @@ +$one = 1 +$two = 2 + +if ($one < $two) and (($two < 3) or ($two == 2)) { + notice("True!") +} + +if "test regex" =~ /(.*) regex/ { + file { + "/tmp/${1}iftest": ensure => file, mode => 0755 + } +} diff --git a/spec/fixtures/unit/parser/lexer/implicititeration.pp b/spec/fixtures/unit/parser/lexer/implicititeration.pp new file mode 100644 index 000000000..6f34cb29c --- /dev/null +++ b/spec/fixtures/unit/parser/lexer/implicititeration.pp @@ -0,0 +1,15 @@ +# $Id$ + +$files = ["/tmp/iterationatest", "/tmp/iterationbtest"] + +file { $files: ensure => file, mode => 755 } + +file { ["/tmp/iterationctest", "/tmp/iterationdtest"]: + ensure => file, + mode => 755 +} + +file { + ["/tmp/iterationetest", "/tmp/iterationftest"]: ensure => file, mode => 755; + ["/tmp/iterationgtest", "/tmp/iterationhtest"]: ensure => file, mode => 755; +} diff --git a/spec/fixtures/unit/parser/lexer/multilinecomments.pp b/spec/fixtures/unit/parser/lexer/multilinecomments.pp new file mode 100644 index 000000000..f9819c020 --- /dev/null +++ b/spec/fixtures/unit/parser/lexer/multilinecomments.pp @@ -0,0 +1,10 @@ + +/* +file { + "/tmp/multilinecomments": content => "pouet" +} +*/ + +/* and another one for #2333, the whitespace after the +end comment is here on purpose */ + diff --git a/spec/fixtures/unit/parser/lexer/multipleclass.pp b/spec/fixtures/unit/parser/lexer/multipleclass.pp new file mode 100644 index 000000000..ae02edc38 --- /dev/null +++ b/spec/fixtures/unit/parser/lexer/multipleclass.pp @@ -0,0 +1,9 @@ +class one { + file { "/tmp/multipleclassone": content => "one" } +} + +class one { + file { "/tmp/multipleclasstwo": content => "two" } +} + +include one diff --git a/spec/fixtures/unit/parser/lexer/multipleinstances.pp b/spec/fixtures/unit/parser/lexer/multipleinstances.pp new file mode 100644 index 000000000..2f9b3c2e8 --- /dev/null +++ b/spec/fixtures/unit/parser/lexer/multipleinstances.pp @@ -0,0 +1,7 @@ +# $Id$ + +file { + "/tmp/multipleinstancesa": ensure => file, mode => 755; + "/tmp/multipleinstancesb": ensure => file, mode => 755; + "/tmp/multipleinstancesc": ensure => file, mode => 755; +} diff --git a/spec/fixtures/unit/parser/lexer/multisubs.pp b/spec/fixtures/unit/parser/lexer/multisubs.pp new file mode 100644 index 000000000..bcec69e2a --- /dev/null +++ b/spec/fixtures/unit/parser/lexer/multisubs.pp @@ -0,0 +1,13 @@ +class base { + file { "/tmp/multisubtest": content => "base", mode => 644 } +} + +class sub1 inherits base { + File["/tmp/multisubtest"] { mode => 755 } +} + +class sub2 inherits base { + File["/tmp/multisubtest"] { content => sub2 } +} + +include sub1, sub2 diff --git a/spec/fixtures/unit/parser/lexer/namevartest.pp b/spec/fixtures/unit/parser/lexer/namevartest.pp new file mode 100644 index 000000000..dbee1c356 --- /dev/null +++ b/spec/fixtures/unit/parser/lexer/namevartest.pp @@ -0,0 +1,9 @@ +define filetest($mode, $ensure = file) { + file { $name: + mode => $mode, + ensure => $ensure + } +} + +filetest { "/tmp/testfiletest": mode => 644} +filetest { "/tmp/testdirtest": mode => 755, ensure => directory} diff --git a/spec/fixtures/unit/parser/lexer/scopetest.pp b/spec/fixtures/unit/parser/lexer/scopetest.pp new file mode 100644 index 000000000..331491766 --- /dev/null +++ b/spec/fixtures/unit/parser/lexer/scopetest.pp @@ -0,0 +1,13 @@ + +$mode = 640 + +define thing { + file { "/tmp/$name": ensure => file, mode => $mode } +} + +class testing { + $mode = 755 + thing {scopetest: } +} + +include testing diff --git a/spec/fixtures/unit/parser/lexer/selectorvalues.pp b/spec/fixtures/unit/parser/lexer/selectorvalues.pp new file mode 100644 index 000000000..d80d26c36 --- /dev/null +++ b/spec/fixtures/unit/parser/lexer/selectorvalues.pp @@ -0,0 +1,49 @@ +$value1 = "" +$value2 = true +$value3 = false +$value4 = yay + +$test = "yay" + +$mode1 = $value1 ? { + "" => 755, + default => 644 +} + +$mode2 = $value2 ? { + true => 755, + default => 644 +} + +$mode3 = $value3 ? { + false => 755, + default => 644 +} + +$mode4 = $value4 ? { + $test => 755, + default => 644 +} + +$mode5 = yay ? { + $test => 755, + default => 644 +} + +$mode6 = $mode5 ? { + 755 => 755 +} + +$mode7 = "test regex" ? { + /regex$/ => 755, + default => 644 +} + + +file { "/tmp/selectorvalues1": ensure => file, mode => $mode1 } +file { "/tmp/selectorvalues2": ensure => file, mode => $mode2 } +file { "/tmp/selectorvalues3": ensure => file, mode => $mode3 } +file { "/tmp/selectorvalues4": ensure => file, mode => $mode4 } +file { "/tmp/selectorvalues5": ensure => file, mode => $mode5 } +file { "/tmp/selectorvalues6": ensure => file, mode => $mode6 } +file { "/tmp/selectorvalues7": ensure => file, mode => $mode7 } diff --git a/spec/fixtures/unit/parser/lexer/simpledefaults.pp b/spec/fixtures/unit/parser/lexer/simpledefaults.pp new file mode 100644 index 000000000..63d199a68 --- /dev/null +++ b/spec/fixtures/unit/parser/lexer/simpledefaults.pp @@ -0,0 +1,5 @@ +# $Id$ + +File { mode => 755 } + +file { "/tmp/defaulttest": ensure => file } diff --git a/spec/fixtures/unit/parser/lexer/simpleselector.pp b/spec/fixtures/unit/parser/lexer/simpleselector.pp new file mode 100644 index 000000000..8b9bc7292 --- /dev/null +++ b/spec/fixtures/unit/parser/lexer/simpleselector.pp @@ -0,0 +1,38 @@ +# $Id$ + +$var = "value" + +file { "/tmp/snippetselectatest": + ensure => file, + mode => $var ? { + nottrue => 641, + value => 755 + } +} + +file { "/tmp/snippetselectbtest": + ensure => file, + mode => $var ? { + nottrue => 644, + default => 755 + } +} + +$othervar = "complex value" + +file { "/tmp/snippetselectctest": + ensure => file, + mode => $othervar ? { + "complex value" => 755, + default => 644 + } +} +$anothervar = Yayness + +file { "/tmp/snippetselectdtest": + ensure => file, + mode => $anothervar ? { + Yayness => 755, + default => 644 + } +} diff --git a/spec/fixtures/unit/parser/lexer/singleary.pp b/spec/fixtures/unit/parser/lexer/singleary.pp new file mode 100644 index 000000000..9ce56dd89 --- /dev/null +++ b/spec/fixtures/unit/parser/lexer/singleary.pp @@ -0,0 +1,19 @@ +# $Id$ + +file { "/tmp/singleary1": + ensure => file +} + +file { "/tmp/singleary2": + ensure => file +} + +file { "/tmp/singleary3": + ensure => file, + require => [File["/tmp/singleary1"], File["/tmp/singleary2"]] +} + +file { "/tmp/singleary4": + ensure => file, + require => [File["/tmp/singleary1"]] +} diff --git a/spec/fixtures/unit/parser/lexer/singlequote.pp b/spec/fixtures/unit/parser/lexer/singlequote.pp new file mode 100644 index 000000000..dc876a2f8 --- /dev/null +++ b/spec/fixtures/unit/parser/lexer/singlequote.pp @@ -0,0 +1,11 @@ +# $Id$ + +file { "/tmp/singlequote1": + ensure => file, + content => 'a $quote' +} + +file { "/tmp/singlequote2": + ensure => file, + content => 'some "\yayness\"' +} diff --git a/spec/fixtures/unit/parser/lexer/singleselector.pp b/spec/fixtures/unit/parser/lexer/singleselector.pp new file mode 100644 index 000000000..520a14017 --- /dev/null +++ b/spec/fixtures/unit/parser/lexer/singleselector.pp @@ -0,0 +1,22 @@ +$value1 = "" +$value2 = true +$value3 = false +$value4 = yay + +$test = "yay" + +$mode1 = $value1 ? { + "" => 755 +} + +$mode2 = $value2 ? { + true => 755 +} + +$mode3 = $value3 ? { + default => 755 +} + +file { "/tmp/singleselector1": ensure => file, mode => $mode1 } +file { "/tmp/singleselector2": ensure => file, mode => $mode2 } +file { "/tmp/singleselector3": ensure => file, mode => $mode3 } diff --git a/spec/fixtures/unit/parser/lexer/subclass_name_duplication.pp b/spec/fixtures/unit/parser/lexer/subclass_name_duplication.pp new file mode 100755 index 000000000..10f1d75ed --- /dev/null +++ b/spec/fixtures/unit/parser/lexer/subclass_name_duplication.pp @@ -0,0 +1,11 @@ +#!/usr/bin/env puppet + +class one::fake { + file { "/tmp/subclass_name_duplication1": ensure => present } +} + +class two::fake { + file { "/tmp/subclass_name_duplication2": ensure => present } +} + +include one::fake, two::fake diff --git a/spec/fixtures/unit/parser/lexer/tag.pp b/spec/fixtures/unit/parser/lexer/tag.pp new file mode 100644 index 000000000..e6e770dd9 --- /dev/null +++ b/spec/fixtures/unit/parser/lexer/tag.pp @@ -0,0 +1,9 @@ +# $Id$ + +$variable = value + +tag yayness, rahness + +tag booness, $variable + +file { "/tmp/settestingness": ensure => file } diff --git a/spec/fixtures/unit/parser/lexer/tagged.pp b/spec/fixtures/unit/parser/lexer/tagged.pp new file mode 100644 index 000000000..7bf90a645 --- /dev/null +++ b/spec/fixtures/unit/parser/lexer/tagged.pp @@ -0,0 +1,35 @@ +# $Id$ + +tag testing +tag(funtest) + +class tagdefine { + $path = tagged(tagdefine) ? { + true => "true", false => "false" + } + + file { "/tmp/taggeddefine$path": ensure => file } +} + +include tagdefine + +$yayness = tagged(yayness) ? { + true => "true", false => "false" +} + +$funtest = tagged(testing) ? { + true => "true", false => "false" +} + +$both = tagged(testing, yayness) ? { + true => "true", false => "false" +} + +$bothtrue = tagged(testing, testing) ? { + true => "true", false => "false" +} + +file { "/tmp/taggedyayness$yayness": ensure => file } +file { "/tmp/taggedtesting$funtest": ensure => file } +file { "/tmp/taggedboth$both": ensure => file } +file { "/tmp/taggedbothtrue$bothtrue": ensure => file } diff --git a/spec/fixtures/unit/parser/lexer/virtualresources.pp b/spec/fixtures/unit/parser/lexer/virtualresources.pp new file mode 100644 index 000000000..a29406b84 --- /dev/null +++ b/spec/fixtures/unit/parser/lexer/virtualresources.pp @@ -0,0 +1,14 @@ +class one { + @file { "/tmp/virtualtest1": content => "one" } + @file { "/tmp/virtualtest2": content => "two" } + @file { "/tmp/virtualtest3": content => "three" } + @file { "/tmp/virtualtest4": content => "four" } +} + +class two { + File <| content == "one" |> + realize File["/tmp/virtualtest2"] + realize(File["/tmp/virtualtest3"], File["/tmp/virtualtest4"]) +} + +include one, two diff --git a/spec/fixtures/unit/provider/host/parsed/valid_hosts b/spec/fixtures/unit/provider/host/parsed/valid_hosts new file mode 100644 index 000000000..24636295d --- /dev/null +++ b/spec/fixtures/unit/provider/host/parsed/valid_hosts @@ -0,0 +1,19 @@ +# Some leading comment, that should be ignored +# The next line is empty so it should be ignored + +::1 localhost + +# We now try another delimiter: Several tabs +127.0.0.1 localhost + +# No test trailing spaces +10.0.0.1 host1 + +# Ok its time to test aliases +2001:252:0:1::2008:8 ipv6host alias1 +192.168.0.1 ipv4host alias2 alias3 + +# Testing inlinecomments now +192.168.0.2 host3 # This is host3 +192.168.0.3 host4 alias10 # This is host4 +192.168.0.4 host5 alias11 alias12 # This is host5 diff --git a/spec/fixtures/unit/provider/mount/mount-output.aix.txt b/spec/fixtures/unit/provider/mount/mount-output.aix.txt index 54edb9c1c..380dbc5ae 100644 --- a/spec/fixtures/unit/provider/mount/mount-output.aix.txt +++ b/spec/fixtures/unit/provider/mount/mount-output.aix.txt @@ -1,7 +1,7 @@ -/dev/hd4 / jfs2 Nov 11 12:11 rw,log=/dev/hd8 -/dev/hd2 /usr jfs2 Nov 11 12:11 rw,log=/dev/hd8 -/dev/hd9var /var jfs2 Nov 11 12:11 rw,log=/dev/hd8 -/dev/hd3 /tmp jfs2 Nov 11 12:11 rw,log=/dev/hd8 -/dev/hd1 /home jfs2 Nov 11 12:11 rw,log=/dev/hd8 -/proc /proc procfs Nov 11 12:11 rw -/dev/hd10opt /opt jfs2 Nov 11 12:11 rw,log=/dev/hd8 +node mounted mounted over vfs date options +---- ------- ------------ --- ------------ ------------------- + /dev/hd0 / jfs Dec 17 08:04 rw, log =/dev/hd8 + /dev/hd3 /tmp jfs Dec 17 08:04 rw, log =/dev/hd8 + /dev/hd1 /home jfs Dec 17 08:06 rw, log =/dev/hd8 + /dev/hd2 /usr jfs Dec 17 08:06 rw, log =/dev/hd8 +sue /home/local/src /usr/code nfs Dec 17 08:06 ro, log =/dev/hd8 diff --git a/spec/fixtures/unit/provider/mount/parsed/aix.filesystems b/spec/fixtures/unit/provider/mount/parsed/aix.filesystems new file mode 100644 index 000000000..7347f2b8c --- /dev/null +++ b/spec/fixtures/unit/provider/mount/parsed/aix.filesystems @@ -0,0 +1,144 @@ +* IBM_PROLOG_BEGIN_TAG +* This is an automatically generated prolog. +* +* bos61B src/bos/etc/filesystems/filesystems 1.23 +* +* Licensed Materials - Property of IBM +* +* COPYRIGHT International Business Machines Corp. 1985,1993 +* All Rights Reserved +* +* US Government Users Restricted Rights - Use, duplication or +* disclosure restricted by GSA ADP Schedule Contract with IBM Corp. +* +* @(#)filesystems @(#)29 1.23 src/bos/etc/filesystems/filesystems, cmdfs, bos61B, b2007_38A8 8/16/07 17:18:35 +* IBM_PROLOG_END_TAG +* +* COMPONENT_NAME: CMDFS +* +* FUNCTIONS: none +* +* ORIGINS: 27 +* +* (C) COPYRIGHT International Business Machines Corp. 1985, 1993 +* All Rights Reserved +* Licensed Materials - Property of IBM +* +* US Government Users Restricted Rights - Use, duplication or +* disclosure restricted by GSA ADP Schedule Contract with IBM Corp. +* +* +* +* This version of /etc/filesystems assumes that only the root file system +* is created and ready. As new file systems are added, change the check, +* mount, free, log, vol and vfs entries for the appropriate stanza. +* + +/: + dev = /dev/hd4 + vfs = jfs2 + log = /dev/hd8 + mount = automatic + check = false + type = bootfs + vol = root + free = true + quota = no + +/home: + dev = /dev/hd1 + vfs = jfs2 + log = /dev/hd8 + mount = true + check = true + vol = /home + free = false + quota = no + +/usr: + dev = /dev/hd2 + vfs = jfs2 + log = /dev/hd8 + mount = automatic + check = false + type = bootfs + vol = /usr + free = false + quota = no + +/var: + dev = /dev/hd9var + vfs = jfs2 + log = /dev/hd8 + mount = automatic + check = false + type = bootfs + vol = /var + free = false + quota = no + +/tmp: + dev = /dev/hd3 + vfs = jfs2 + log = /dev/hd8 + mount = automatic + check = false + vol = /tmp + free = false + quota = no + +/admin: + dev = /dev/hd11admin + vfs = jfs2 + log = /dev/hd8 + mount = true + check = false + vol = /admin + free = false + quota = no + +/proc: + dev = /proc + vol = "/proc" + mount = true + check = false + free = false + vfs = procfs + +/opt: + dev = /dev/hd10opt + vfs = jfs2 + log = /dev/hd8 + mount = true + check = true + vol = /opt + free = false + quota = no + +/var/adm/ras/livedump: + dev = /dev/livedump + vfs = jfs2 + log = /dev/hd8 + mount = true + account = false + quota = no + + +/stage/middleware: + dev = "/stage/middleware" + vfs = nfs + nodename = 192.168.1.11 + mount = true + type = nfs + options = ro,bg,hard,intr,sec=sys + account = false + +/home/u0010689: + dev = "/userdata/20010689" + vfs = nfs + nodename = 192.168.1.11 + mount = true + type = nfs + options = bg,hard,intr + account = false + diff --git a/spec/fixtures/unit/provider/mount/parsed/aix.mount b/spec/fixtures/unit/provider/mount/parsed/aix.mount new file mode 100644 index 000000000..380dbc5ae --- /dev/null +++ b/spec/fixtures/unit/provider/mount/parsed/aix.mount @@ -0,0 +1,7 @@ +node mounted mounted over vfs date options +---- ------- ------------ --- ------------ ------------------- + /dev/hd0 / jfs Dec 17 08:04 rw, log =/dev/hd8 + /dev/hd3 /tmp jfs Dec 17 08:04 rw, log =/dev/hd8 + /dev/hd1 /home jfs Dec 17 08:06 rw, log =/dev/hd8 + /dev/hd2 /usr jfs Dec 17 08:06 rw, log =/dev/hd8 +sue /home/local/src /usr/code nfs Dec 17 08:06 ro, log =/dev/hd8 diff --git a/spec/fixtures/unit/provider/mount/parsed/darwin.mount b/spec/fixtures/unit/provider/mount/parsed/darwin.mount new file mode 100644 index 000000000..1bdfcf89a --- /dev/null +++ b/spec/fixtures/unit/provider/mount/parsed/darwin.mount @@ -0,0 +1,6 @@ +/dev/disk0s2 on / (hfs, local, journaled) +devfs on /dev (devfs, local, nobrowse) +map -hosts on /net (autofs, nosuid, automounted, nobrowse) +map auto_home on /home (autofs, automounted, nobrowse) +/dev/disk0s3 on /usr (hfs, local, journaled) +/dev/fake on /ghost (hfs, local, journaled) diff --git a/spec/fixtures/unit/provider/mount/parsed/freebsd.fstab b/spec/fixtures/unit/provider/mount/parsed/freebsd.fstab new file mode 100644 index 000000000..41b749bff --- /dev/null +++ b/spec/fixtures/unit/provider/mount/parsed/freebsd.fstab @@ -0,0 +1,8 @@ +# Device Mountpoint FStype Options Dump Pass# +/dev/ad0s1b none swap sw 0 0 +/dev/ad0s1a / ufs rw 1 1 +/dev/ad0s1e /tmp ufs rw 2 2 +/dev/ad0s1f /usr ufs rw 2 2 +/dev/ad0s1d /var ufs rw 2 2 +/dev/ad0s1g /boot ufs rw 2 2 +/dev/acd0 /cdrom cd9660 ro,noauto 0 0 diff --git a/spec/fixtures/unit/provider/mount/parsed/freebsd.mount b/spec/fixtures/unit/provider/mount/parsed/freebsd.mount new file mode 100644 index 000000000..89c518c5d --- /dev/null +++ b/spec/fixtures/unit/provider/mount/parsed/freebsd.mount @@ -0,0 +1,3 @@ +/dev/ad0s1a on / (ufs, local, soft-updates) +/dev/ad0s1d on /ghost (ufs, local, soft-updates) +devfs on /dev (devfs, local, multilabel) diff --git a/spec/fixtures/unit/provider/mount/parsed/hpux.mount b/spec/fixtures/unit/provider/mount/parsed/hpux.mount new file mode 100644 index 000000000..d414fa47a --- /dev/null +++ b/spec/fixtures/unit/provider/mount/parsed/hpux.mount @@ -0,0 +1,17 @@ +/ on rpool/ROOT/opensolaris read/write/setuid/devices/dev=2d90002 on Wed Dec 31 16:00:00 1969 +/devices on /devices read/write/setuid/devices/dev=4a00000 on Thu Feb 17 14:34:02 2011 +/dev on /dev read/write/setuid/devices/dev=4a40000 on Thu Feb 17 14:34:02 2011 +/system/contract on ctfs read/write/setuid/devices/dev=4ac0001 on Thu Feb 17 14:34:02 2011 +/proc on proc read/write/setuid/devices/dev=4b00000 on Thu Feb 17 14:34:02 2011 +/etc/mnttab on mnttab read/write/setuid/devices/dev=4b40001 on Thu Feb 17 14:34:02 2011 +/etc/svc/volatile on swap read/write/setuid/devices/xattr/dev=4b80001 on Thu Feb 17 14:34:02 2011 +/system/object on objfs read/write/setuid/devices/dev=4bc0001 on Thu Feb 17 14:34:02 2011 +/etc/dfs/sharetab on sharefs read/write/setuid/devices/dev=4c00001 on Thu Feb 17 14:34:02 2011 +/lib/libc.so.1 on /usr/lib/libc/libc_hwcap1.so.1 read/write/setuid/devices/dev=2d90002 on Thu Feb 17 14:34:14 2011 +/dev/fd on fd read/write/setuid/devices/dev=4d00001 on Thu Feb 17 14:34:18 2011 +/tmp on swap read/write/setuid/devices/xattr/dev=4b80002 on Thu Feb 17 14:34:19 2011 +/var/run on swap read/write/setuid/devices/xattr/dev=4b80003 on Thu Feb 17 14:34:19 2011 +/export on rpool/export read/write/setuid/devices/nonbmand/exec/xattr/atime/dev=2d90006 on Thu Feb 17 14:37:48 2011 +/export/home on rpool/export/home read/write/setuid/devices/nonbmand/exec/xattr/atime/dev=2d90007 on Thu Feb 17 14:37:48 2011 +/rpool on rpool read/write/setuid/devices/nonbmand/exec/xattr/atime/dev=2d90009 on Thu Feb 17 14:37:48 2011 +/ghost on /dev/fake read/write/setuid/devices/nonbmand/exec/xattr/atime/dev=2d90009 on Thu Feb 17 14:37:48 2011 diff --git a/test/data/types/mount/linux.fstab b/spec/fixtures/unit/provider/mount/parsed/linux.fstab similarity index 100% copy from test/data/types/mount/linux.fstab copy to spec/fixtures/unit/provider/mount/parsed/linux.fstab diff --git a/spec/fixtures/unit/provider/mount/parsed/linux.mount b/spec/fixtures/unit/provider/mount/parsed/linux.mount new file mode 100644 index 000000000..75dd71fd4 --- /dev/null +++ b/spec/fixtures/unit/provider/mount/parsed/linux.mount @@ -0,0 +1,5 @@ +/dev/root on / type jfs (rw,noatime) +rc-svcdir on /lib64/rc/init.d type tmpfs (rw,nosuid,nodev,noexec,relatime,size=1024k,mode=755) +sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime) +/dev/sda9 on /usr/portage type jfs (rw) +/dev/fake on /ghost type jfs (rw) diff --git a/spec/fixtures/unit/provider/mount/parsed/netbsd.fstab b/spec/fixtures/unit/provider/mount/parsed/netbsd.fstab new file mode 100644 index 000000000..ca3ca8450 --- /dev/null +++ b/spec/fixtures/unit/provider/mount/parsed/netbsd.fstab @@ -0,0 +1,9 @@ +# Device Mountpoint FStype Options Dump Pass# +/dev/ad0s1b none swap sw 0 0 +/dev/ad0s1a / ufs rw 1 1 +/dev/ad0s1e /tmp ufs rw 2 2 +/dev/ad0s1f /usr ufs rw 2 2 +/dev/ad0s1d /var ufs rw 2 2 +/dev/ad3s1b none swap sw 0 0 +/dev/ad3s1e /data ufs rw 2 2 +/dev/ad3s1g /boot ufs rw 2 2 diff --git a/spec/fixtures/unit/provider/mount/parsed/netbsd.mount b/spec/fixtures/unit/provider/mount/parsed/netbsd.mount new file mode 100644 index 000000000..dfdc26a34 --- /dev/null +++ b/spec/fixtures/unit/provider/mount/parsed/netbsd.mount @@ -0,0 +1,8 @@ +/dev/ad0s1a on / (ufs, local) +devfs on /dev (devfs, local) +/dev/ad0s1e on /tmp (ufs, local, soft-updates) +/dev/ad0s1f on /usr (ufs, local, soft-updates) +/dev/ad0s1d on /var (ufs, local, soft-updates) +/dev/ad3s1e on /data (ufs, local, soft-updates) +/dev/ad3s1h on /ghost (ufs, local, soft-updates) +devfs on /var/named/dev (devfs, local) diff --git a/spec/fixtures/unit/provider/mount/parsed/openbsd.fstab b/spec/fixtures/unit/provider/mount/parsed/openbsd.fstab new file mode 100644 index 000000000..44c83eed1 --- /dev/null +++ b/spec/fixtures/unit/provider/mount/parsed/openbsd.fstab @@ -0,0 +1,4 @@ +/dev/wd0a / ffs rw 1 1 +/dev/wd0e /home ffs rw,nodev,nosuid 1 2 +/dev/wd0d /usr ffs rw,nodev 1 2 +/dev/wd0f /boot ffs rw,nodev 1 2 diff --git a/spec/fixtures/unit/provider/mount/parsed/openbsd.mount b/spec/fixtures/unit/provider/mount/parsed/openbsd.mount new file mode 100644 index 000000000..367475783 --- /dev/null +++ b/spec/fixtures/unit/provider/mount/parsed/openbsd.mount @@ -0,0 +1,4 @@ +/dev/wd0a on / type ffs (local) +/dev/wd0e on /home type ffs (local, nodev, nosuid) +/dev/wd0d on /usr type ffs (local, nodev) +/dev/wd0g on /ghost type ffs (local, nodev) diff --git a/test/data/types/mount/solaris.fstab b/spec/fixtures/unit/provider/mount/parsed/solaris.fstab similarity index 100% copy from test/data/types/mount/solaris.fstab copy to spec/fixtures/unit/provider/mount/parsed/solaris.fstab diff --git a/spec/fixtures/unit/provider/mount/parsed/solaris.mount b/spec/fixtures/unit/provider/mount/parsed/solaris.mount new file mode 100644 index 000000000..26fabc575 --- /dev/null +++ b/spec/fixtures/unit/provider/mount/parsed/solaris.mount @@ -0,0 +1,6 @@ +/ on /dev/dsk/c0t0d0s0 read/write/setuid/intr/largefiles/xattr/onerror=panic/dev=2200000 on Mon Mar 18 08:48:45 2002 +/proc on /proc read/write/setuid/dev=4300000 on Mon Mar 18 08:48:44 2002 +/etc/mnttab on mnttab read/write/setuid/dev=43c0000 on Mon Mar 18 08:48:44 2002 +/tmp on swap read/write/setuid/xattr/dev=2 on Mon Mar 18 08:48:52 2002 +/export/home on /dev/dsk/c0t0d0s7 read/write/setuid/intr/largefiles/xattr/onerror=panic/dev=2200007 on Mon Mar 18 +/ghost on /dev/dsk/c0t1d0s7 read/write/setuid/intr/largefiles/xattr/onerror=panic/dev=2200007 on Mon Mar 18 diff --git a/spec/fixtures/unit/provider/ssh_authorized_key/parsed/authorized_keys b/spec/fixtures/unit/provider/ssh_authorized_key/parsed/authorized_keys new file mode 100644 index 000000000..b22329dca --- /dev/null +++ b/spec/fixtures/unit/provider/ssh_authorized_key/parsed/authorized_keys @@ -0,0 +1,7 @@ +ssh-dss AAAAB3NzaC1kc3MAAACBAJkupmdsJSDXfUy5EU5NTRBDr9Woo3w0YnB8KmnJW9ghU8C7SkWPB1fIHVe+esFfd3qWBseb83PoFX63geZJAg6bjV4/Rdn1zEoa9EO2QyUdYUen4+rpsh3vVKZ6HFNsn3+W5+kPYgE1F/N4INqkbjY3sqCkP/W1BL9+sbVVbuJFAAAAFQCfjWDk5XhvGUkPjNWWVqltBYzHtwAAAIEAg/XL7ky7x9Ad5banzPFAfmM+DGFe0A/JEbLDjKmr5KBM5x4RFohtEvZ8ECuVGUOqBWdgAjyYwsG4oRVjLnKrf/rgmbNRzSFgEWkcAye3BVwk7Dt6hh4knEl+mNfOLq+FH0011UhecOiqTcESMzQDtgQ1vJh2VchElBLjl3x/ZugAAACAAh5jGQC338t5ObP8trSlOefkx0sXmmEzUbo3Mt8mGUuGJPx8m+X0L8Xd+l5rQxytqE3SmV/RD+6REqBuPqHM8RQuqAzfjdOeg/Ajdggx1CRMTVhltZsgQoxO30cz9Qo0SdPoL+Jp1fLuaLZq7m/RmsWYvoLT3jebBlpvvQE8YlI= francois.deppierraz@nimag.net +ssh-dss AAAAB3NzaC1kc3MAAACBAJkupmdsJSDXfUy5EU5NTRBDr9Woo3w0YnB8KmnJW9ghU8C7SkWPB1fIHVe+esFfd3qWBseb83PoFX63geZJAg6bjV4/Rdn1zEoa9EO2QyUdYUen4+rpsh3vVKZ6HFNsn3+W5+kPYgE1F/N4INqkbjY3sqCkP/W1BL9+sbVVbuJFAAAAFQCfjWDk5XhvGUkPjNWWVqltBYzHtwAAAIEAg/XL7ky7x9Ad5banzPFAfmM+DGFe0A/JEbLDjKmr5KBM5x4RFohtEvZ8ECuVGUOqBWdgAjyYwsG4oRVjLnKrf/rgmbNRzSFgEWkcAye3BVwk7Dt6hh4knEl+mNfOLq+FH0011UhecOiqTcESMzQDtgQ1vJh2VchElBLjl3x/ZugAAACAAh5jGQC338t5ObP8trSlOefkx0sXmmEzUbo3Mt8mGUuGJPx8m+X0L8Xd+l5rQxytqE3SmV/RD+6REqBuPqHM8RQuqAzfjdOeg/Ajdggx1CRMTVhltZsgQoxO30cz9Qo0SdPoL+Jp1fLuaLZq7m/RmsWYvoLT3jebBlpvvQE8YlI= Francois Deppierraz +from="192.168.1.1",command="/bin/false",no-pty,no-port-forwarding ssh-dss AAAAB3NzaC1kc3MAAACBAJkupmdsJSDXfUy5EU5NTRBDr9Woo3w0YnB8KmnJW9ghU8C7SkWPB1fIHVe+esFfd3qWBseb83PoFX63geZJAg6bjV4/Rdn1zEoa9EO2QyUdYUen4+rpsh3vVKZ6HFNsn3+W5+kPYgE1F/N4INqkbjY3sqCkP/W1BL9+sbVVbuJFAAAAFQCfjWDk5XhvGUkPjNWWVqltBYzHtwAAAIEAg/XL7ky7x9Ad5banzPFAfmM+DGFe0A/JEbLDjKmr5KBM5x4RFohtEvZ8ECuVGUOqBWdgAjyYwsG4oRVjLnKrf/rgmbNRzSFgEWkcAye3BVwk7Dt6hh4knEl+mNfOLq+FH0011UhecOiqTcESMzQDtgQ1vJh2VchElBLjl3x/ZugAAACAAh5jGQC338t5ObP8trSlOefkx0sXmmEzUbo3Mt8mGUuGJPx8m+X0L8Xd+l5rQxytqE3SmV/RD+6REqBuPqHM8RQuqAzfjdOeg/Ajdggx1CRMTVhltZsgQoxO30cz9Qo0SdPoL+Jp1fLuaLZq7m/RmsWYvoLT3jebBlpvvQE8YlI= Francois Deppierraz +from="192.168.1.1, www.reductivelabs.com",command="/bin/false",no-pty,no-port-forwarding ssh-dss AAAAB3NzaC1kc3MAAACBAJkupmdsJSDXfUy5EU5NTRBDr9Woo3w0YnB8KmnJW9ghU8C7SkWPB1fIHVe+esFfd3qWBseb83PoFX63geZJAg6bjV4/Rdn1zEoa9EO2QyUdYUen4+rpsh3vVKZ6HFNsn3+W5+kPYgE1F/N4INqkbjY3sqCkP/W1BL9+sbVVbuJFAAAAFQCfjWDk5XhvGUkPjNWWVqltBYzHtwAAAIEAg/XL7ky7x9Ad5banzPFAfmM+DGFe0A/JEbLDjKmr5KBM5x4RFohtEvZ8ECuVGUOqBWdgAjyYwsG4oRVjLnKrf/rgmbNRzSFgEWkcAye3BVwk7Dt6hh4knEl+mNfOLq+FH0011UhecOiqTcESMzQDtgQ1vJh2VchElBLjl3x/ZugAAACAAh5jGQC338t5ObP8trSlOefkx0sXmmEzUbo3Mt8mGUuGJPx8m+X0L8Xd+l5rQxytqE3SmV/RD+6REqBuPqHM8RQuqAzfjdOeg/Ajdggx1CRMTVhltZsgQoxO30cz9Qo0SdPoL+Jp1fLuaLZq7m/RmsWYvoLT3jebBlpvvQE8YlI= Francois Deppierraz +ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA2Vi+TdC3iOGYcIo5vGTvC9P9rjHl9RxCuZmSfn+YDFQ35RXf0waijtjp9I7GYh6R4hBjA5z0u/Pzi95LET5NfRM0Gdc0DJyvBI7K+ALBxIT383Iz6Yz4iKxe1TEJgHGM2he4+7BHkjc3kdIZqIpZjucCk4VsXSxujO4MKKvtaKK2l+kahlLQHHw/vZkDpIgL52iGVsjW9l8RLJaKHZ4mDHJN/Q/Rzn2W4EvcdHUzwhvGMwZlm8clDwITBrSsawYtnivJrQSYcmTRqJuS8wprNDrLIhTGjrwFg5WpruUuMt6fLuCqwe6TeEL+nh3DQ4g554c5aRp3oU6LGBKTvNZGWQ== francois@korn +ssh-dss AAAAB3NzaC1kc3MAAACBAMPpCYnjywOemd8LqbbmC+bePNR3/H1rXsiFwjSLhYE3bbOpvclvOzN1DruFc34m0FopVnMkP+aubjdIYF8pijl+5hg9ggB7Kno2dl0Dd1rGN/swvmhA8OpLAQv7Qt7UnXKVho3as08zYZsrHxYFu0wlnkdbsv4cy4aXyQKd4MPVAAAAFQDSyQFWg8Qt3wU05buhZ10psoR7tQAAAIEAmAhguXwUnI3P2FF5NAW/mpJUmUERdL4pyZARUyAgpf7ezwrh9TJqrvGTQNBF97Xqaivyncm5JWQdMIsTBxEFaXZGkmBta02KnWcn447qvIh7iv8XpNL6M9flCkBEZOJ4t9El0ytTSHHaiCz8A20Et+E8evWyi1kXkFDt8ML2dGgAAACBAK0X4ympbdEjgV/ZyOc+BU22u7vOnfSOUJmyar4Ax1MIDNnoyNWKnGvxRutydQcQOKQHZEU0fE8MhPFn6nLF6CoVfEl/oz0EYz3hjV4WPFpHrF5DY/rhvNj8iuneKJ5P0dy/rG6m5qey25PnHyGFVoIRlkHJvBCJT40dHs40YEjI francois@korn +ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAut8aOSxenjOqF527dlsdHWV4MNoAsX14l9M297+SQXaQ5Z3BedIxZaoQthkDALlV/25A1COELrg9J2MqJNQc8Xe9XQOIkBQWWinUlD/BXwoOTWEy8C8zSZPHZ3getMMNhGTBO+q/O+qiJx3y5cA4MTbw2zSxukfWC87qWwcZ64UUlegIM056vPsdZWFclS9hsROVEa57YUMrehQ1EGxT4Z5j6zIopufGFiAPjZigq/vqgcAqhAKP6yu4/gwO6S9tatBeEjZ8fafvj1pmvvIplZeMr96gHE7xS3pEEQqnB3nd4RY7AF6j9kFixnsytAUO7STPh/M3pLiVQBN89TvWPQ== diff --git a/spec/fixtures/unit/provider/ssh_authorized_key/parsed/authorized_keys1 b/spec/fixtures/unit/provider/ssh_authorized_key/parsed/authorized_keys1 new file mode 100644 index 000000000..7aa0647ca --- /dev/null +++ b/spec/fixtures/unit/provider/ssh_authorized_key/parsed/authorized_keys1 @@ -0,0 +1,3 @@ +1024 35 167576894966720957580065952882142495543043407324667405194097438434880798807651864847570827148390962746149410384891026772700627764845955493549511618975091512997118590589399665757714186775228807376424903966072778732134483862302766419277581465932186641863495699668069439475320990051723279127881281145164415361627 francois@korn +2048 35 27332429396020032283276339339051507284036000350350092862949624519871013308460312287866673933080560923221560798334008554200019645416448528663000202951887890525621015333936122655294782671001073795264378070156670395703161543893088138531854776737799752600933431638059304355933305878665812555436198516842364330938321746086651639330436648850787370397302524667456837036413634152938122227368132322078811602953517461933179827432019932348409533535942749570969101453655028606209719023224268890314608444789012688070463327764203306501923404494017305972543000091038543051645924928018568725584728655193415567703220002707737714942757 francois@korn +from="192.168.1.1",command="/bin/false",no-pty,no-port-forwarding 2048 35 27332429396020032283276339339051507284036000350350092862949624519871013308460312287866673933080560923221560798334008554200019645416448528663000202951887890525621015333936122655294782671001073795264378070156670395703161543893088138531854776737799752600933431638059304355933305878665812555436198516842364330938321746086651639330436648850787370397302524667456837036413634152938122227368132322078811602953517461933179827432019932348409533535942749570969101453655028606209719023224268890314608444789012688070463327764203306501923404494017305972543000091038543051645924928018568725584728655193415567703220002707737714942757 francois@korn diff --git a/spec/fixtures/unit/provider/ssh_authorized_key/parsed/authorized_keys2 b/spec/fixtures/unit/provider/ssh_authorized_key/parsed/authorized_keys2 new file mode 100644 index 000000000..9bf830112 --- /dev/null +++ b/spec/fixtures/unit/provider/ssh_authorized_key/parsed/authorized_keys2 @@ -0,0 +1 @@ +false ssh-dss AAAAB3NzaC1kc3MAAACBAJkupmdsJSDXfUy5EU5NTRBDr9Woo3w0YnB8KmnJW9ghU8C7SkWPB1fIHVe+esFfd3qWBseb83PoFX63geZJAg6bjV4/Rdn1zEoa9EO2QyUdYUen4+rpsh3vVKZ6HFNsn3+W5+kPYgE1F/N4INqkbjY3sqCkP/W1BL9+sbVVbuJFAAAAFQCfjWDk5XhvGUkPjNWWVqltBYzHtwAAAIEAg/XL7ky7x9Ad5banzPFAfmM+DGFe0A/JEbLDjKmr5KBM5x4RFohtEvZ8ECuVGUOqBWdgAjyYwsG4oRVjLnKrf/rgmbNRzSFgEWkcAye3BVwk7Dt6hh4knEl+mNfOLq+FH0011UhecOiqTcESMzQDtgQ1vJh2VchElBLjl3x/ZugAAACAAh5jGQC338t5ObP8trSlOefkx0sXmmEzUbo3Mt8mGUuGJPx8m+X0L8Xd+l5rQxytqE3SmV/RD+6REqBuPqHM8RQuqAzfjdOeg/Ajdggx1CRMTVhltZsgQoxO30cz9Qo0SdPoL+Jp1fLuaLZq7m/RmsWYvoLT3jebBlpvvQE8YlI= Francois Deppierraz diff --git a/spec/fixtures/unit/reports/tagmail/tagmail_failers.conf b/spec/fixtures/unit/reports/tagmail/tagmail_failers.conf new file mode 100644 index 000000000..d116b5fc7 --- /dev/null +++ b/spec/fixtures/unit/reports/tagmail/tagmail_failers.conf @@ -0,0 +1,3 @@ +tag: +: abuse@domain.com +invalid!tag: abuse@domain.com diff --git a/spec/fixtures/unit/reports/tagmail/tagmail_passers.conf b/spec/fixtures/unit/reports/tagmail/tagmail_passers.conf new file mode 100644 index 000000000..ae6d2e7f2 --- /dev/null +++ b/spec/fixtures/unit/reports/tagmail/tagmail_passers.conf @@ -0,0 +1,30 @@ +# A comment +# or maybe two +# plus some blank lines + # with some blanks plus a comment + +# a simple tag report +one: abuse@domain.com + +# with weird spacing + one : abuse@domain.com + +# with multiple tags +one, two: abuse@domain.com + +# again with the weird syntax + one , two : abuse@domain.com + +# Some negations +one, !two: abuse@domain.com + +# some oddly-formatted tags +one, two-three, !four-five, !six: abuse@domain.com + +# multiple addresses +one, two: abuse@domain.com, testing@domain.com + +# and with weird spacing +one, two: abuse@domain.com , testing@domain.com + +# and a trailing comment diff --git a/spec/fixtures/unit/util/rdoc/basic.pp b/spec/fixtures/unit/util/rdoc/basic.pp new file mode 100644 index 000000000..5616503c1 --- /dev/null +++ b/spec/fixtures/unit/util/rdoc/basic.pp @@ -0,0 +1,16 @@ +# im a class +class foo { + file { '/tmp/foo' : + ensure => present, + } +} + +# im a node +node gar { +} + +# im a define +define baz { } + +# im a resource +host { 'cow' : } diff --git a/spec/integration/configurer_spec.rb b/spec/integration/configurer_spec.rb index 825b6322e..05b3d6146 100755 --- a/spec/integration/configurer_spec.rb +++ b/spec/integration/configurer_spec.rb @@ -1,68 +1,73 @@ #!/usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') require 'puppet/configurer' describe Puppet::Configurer do include PuppetSpec::Files describe "when downloading plugins" do it "should use the :pluginsignore setting, split on whitespace, for ignoring remote files" do resource = Puppet::Type.type(:notify).new :name => "yay" Puppet::Type.type(:file).expects(:new).with { |args| args[:ignore] == Puppet[:pluginsignore].split(/\s+/) }.returns resource configurer = Puppet::Configurer.new configurer.stubs(:download_plugins?).returns true configurer.download_plugins end end describe "when running" do before(:each) do @catalog = Puppet::Resource::Catalog.new @catalog.add_resource(Puppet::Type.type(:notify).new(:title => "testing")) # Make sure we don't try to persist the local state after the transaction ran, # because it will fail during test (the state file is in an not existing directory) # and we need the transaction to be successful to be able to produce a summary report @catalog.host_config = false @configurer = Puppet::Configurer.new end it "should send a transaction report with valid data" do @configurer.stubs(:save_last_run_summary) Puppet::Transaction::Report.indirection.expects(:save).with do |report, x| report.time.class == Time and report.logs.length > 0 end Puppet[:report] = true @configurer.run :catalog => @catalog end it "should save a correct last run summary" do report = Puppet::Transaction::Report.new("apply") Puppet::Transaction::Report.indirection.stubs(:save) Puppet[:lastrunfile] = tmpfile("lastrunfile") Puppet[:report] = true + # We only record integer seconds in the timestamp, and truncate + # backwards, so don't use a more accurate timestamp in the test. + # --daniel 2011-03-07 + t1 = Time.now.tv_sec @configurer.run :catalog => @catalog, :report => report + t2 = Time.now.tv_sec summary = nil File.open(Puppet[:lastrunfile], "r") do |fd| summary = YAML.load(fd.read) end summary.should be_a(Hash) %w{time changes events resources}.each do |key| summary.should be_key(key) end summary["time"].should be_key("notify") - summary["time"]["last_run"].should >= Time.now.tv_sec + summary["time"]["last_run"].should be_between(t1, t2) end end end diff --git a/spec/integration/parser/parser_spec.rb b/spec/integration/parser/parser_spec.rb index ec084b441..b7dfcc3e0 100755 --- a/spec/integration/parser/parser_spec.rb +++ b/spec/integration/parser/parser_spec.rb @@ -1,115 +1,122 @@ #!/usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') describe Puppet::Parser::Parser do module ParseMatcher class ParseAs def initialize(klass) @parser = Puppet::Parser::Parser.new "development" @class = klass end def result_instance @result.code[0] end def matches?(string) @string = string @result = @parser.parse(string) result_instance.instance_of?(@class) end def description "parse as a #{@class}" end def failure_message " expected #{@string} to parse as #{@class} but was #{result_instance.class}" end def negative_failure_message " expected #{@string} not to parse as #{@class}" end end def parse_as(klass) ParseAs.new(klass) end class ParseWith def initialize(block) @parser = Puppet::Parser::Parser.new "development" @block = block end def result_instance @result.code[0] end def matches?(string) @string = string @result = @parser.parse(string) @block.call(result_instance) end def description "parse with the block evaluating to true" end def failure_message " expected #{@string} to parse with a true result in the block" end def negative_failure_message " expected #{@string} not to parse with a true result in the block" end end def parse_with(&block) ParseWith.new(block) end end include ParseMatcher before :each do @resource_type_collection = Puppet::Resource::TypeCollection.new("env") @parser = Puppet::Parser::Parser.new "development" end describe "when parsing comments before statement" do it "should associate the documentation to the statement AST node" do ast = @parser.parse(""" # comment class test {} """) ast.code[0].should be_a(Puppet::Parser::AST::Hostclass) ast.code[0].name.should == 'test' ast.code[0].instantiate('')[0].doc.should == "comment\n" end end describe "when parsing" do it "should be able to parse normal left to right relationships" do "Notify[foo] -> Notify[bar]".should parse_as(Puppet::Parser::AST::Relationship) end it "should be able to parse right to left relationships" do "Notify[foo] <- Notify[bar]".should parse_as(Puppet::Parser::AST::Relationship) end it "should be able to parse normal left to right subscriptions" do "Notify[foo] ~> Notify[bar]".should parse_as(Puppet::Parser::AST::Relationship) end it "should be able to parse right to left subscriptions" do "Notify[foo] <~ Notify[bar]".should parse_as(Puppet::Parser::AST::Relationship) end it "should correctly set the arrow type of a relationship" do "Notify[foo] <~ Notify[bar]".should parse_with { |rel| rel.arrow == "<~" } end + + it "should be able to parse deep hash access" do + %q{ + $hash = { 'a' => { 'b' => { 'c' => 'it works' } } } + $out = $hash['a']['b']['c'] + }.should parse_with { |v| v.value.is_a?(Puppet::Parser::AST::ASTHash) } + end end end diff --git a/spec/integration/provider/mailalias/aliases_spec.rb b/spec/integration/provider/mailalias/aliases_spec.rb index bce9374c1..19e430ba1 100755 --- a/spec/integration/provider/mailalias/aliases_spec.rb +++ b/spec/integration/provider/mailalias/aliases_spec.rb @@ -1,24 +1,10 @@ #!/usr/bin/env ruby - require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper') - -require 'puppettest/support/utils' -require 'puppettest/fileparsing' +require 'shared_behaviours/all_parsedfile_providers' provider_class = Puppet::Type.type(:mailalias).provider(:aliases) describe provider_class do - include PuppetTest::FileParsing - include PuppetTest::Support::Utils - - before :each do - @provider = provider_class - end - - # #1560 - it "should be able to parse the mailalias examples" do - fakedata("data/providers/mailalias/aliases").each { |file| - fakedataparse(file) - } - end + # #1560, in which we corrupt the format of complex mail aliases. + it_should_behave_like "all parsedfile providers", provider_class end diff --git a/spec/integration/provider/mount_spec.rb b/spec/integration/provider/mount_spec.rb new file mode 100644 index 000000000..d6f25fe1d --- /dev/null +++ b/spec/integration/provider/mount_spec.rb @@ -0,0 +1,151 @@ +require File.dirname(__FILE__) + '/../../spec_helper' + +require 'puppet/file_bucket/dipper' + +describe "mount provider (integration)" do + include PuppetSpec::Files + + def create_fake_fstab(initially_contains_entry) + File.open(@fake_fstab, 'w') do |f| + if initially_contains_entry + f.puts("/dev/disk1s1\t/Volumes/foo_disk\tmsdos\tlocal\t0\t0") + end + end + end + + before :each do + @fake_fstab = tmpfile('fstab') + @current_options = "local" + @current_device = "/dev/disk1s1" + Puppet::Type.type(:mount).defaultprovider.stubs(:default_target).returns(@fake_fstab) + Facter.stubs(:value).with(:operatingsystem).returns('Darwin') + Puppet::Util::ExecutionStub.set do |command, options| + case command[0] + when %r{/s?bin/mount} + if command.length == 1 + if @mounted + "#{@current_device} on /Volumes/foo_disk (msdos, #{@current_options})\n" + else + '' + end + else + command.length.should == 4 + command[1].should == '-o' + command[3].should == '/Volumes/foo_disk' + @mounted.should == false # verify that we don't try to call "mount" redundantly + @current_options = command[2] + @current_device = check_fstab(true) + @mounted = true + '' + end + when %r{/s?bin/umount} + command.length.should == 2 + command[1].should == '/Volumes/foo_disk' + @mounted.should == true # "umount" doesn't work when device not mounted (see #6632) + @mounted = false + '' + else + fail "Unexpected command #{command.inspect} executed" + end + end + end + + after :each do + Puppet::Type::Mount::ProviderParsed.clear # Work around bug #6628 + end + + def check_fstab(expected_to_be_present) + # Verify that the fake fstab has the expected data in it + fstab_contents = File.read(@fake_fstab).lines.map(&:chomp).reject { |x| x =~ /^#|^$/ } + if expected_to_be_present + fstab_contents.length().should == 1 + device, rest_of_line = fstab_contents[0].split(/\t/,2) + rest_of_line.should == "/Volumes/foo_disk\tmsdos\t#{@desired_options}\t0\t0" + device + else + fstab_contents.length().should == 0 + nil + end + end + + def run_in_catalog(settings) + resource = Puppet::Type.type(:mount).new(settings.merge(:name => "/Volumes/foo_disk", + :device => "/dev/disk1s1", :fstype => "msdos")) + Puppet::FileBucket::Dipper.any_instance.stubs(:backup) # Don't backup to the filebucket + resource.expects(:err).never + catalog = Puppet::Resource::Catalog.new + catalog.host_config = false # Stop Puppet from doing a bunch of magic + catalog.add_resource resource + catalog.apply + end + + [false, true].each do |initial_state| + describe "When initially #{initial_state ? 'mounted' : 'unmounted'}" do + before :each do + @mounted = initial_state + end + + [false, true].each do |initial_fstab_entry| + describe "When there is #{initial_fstab_entry ? 'an' : 'no'} initial fstab entry" do + before :each do + create_fake_fstab(initial_fstab_entry) + end + + [:defined, :present, :mounted, :unmounted, :absent].each do |ensure_setting| + expected_final_state = case ensure_setting + when :mounted + true + when :unmounted, :absent + false + when :defined, :present + initial_state + else + fail "Unknown ensure_setting #{ensure_setting}" + end + expected_fstab_data = (ensure_setting != :absent) + describe "When setting ensure => #{ensure_setting}" do + ["local", "journaled"].each do |options_setting| + describe "When setting options => #{options_setting}" do + it "should leave the system in the #{expected_final_state ? 'mounted' : 'unmounted'} state, #{expected_fstab_data ? 'with' : 'without'} data in /etc/fstab" do + @desired_options = options_setting + run_in_catalog(:ensure=>ensure_setting, :options => options_setting) + @mounted.should == expected_final_state + if expected_fstab_data + check_fstab(expected_fstab_data).should == "/dev/disk1s1" + else + check_fstab(expected_fstab_data).should == nil + end + if @mounted + if ![:defined, :present].include?(ensure_setting) + @current_options.should == @desired_options + elsif initial_fstab_entry + @current_options.should == @desired_options + else + @current_options.should == 'local' #Workaround for #6645 + end + end + end + end + end + end + end + end + end + end + end + + describe "When the wrong device is mounted" do + it "should remount the correct device" do + pending "Due to bug 6309" + @mounted = true + @current_device = "/dev/disk2s2" + create_fake_fstab(true) + @desired_options = "local" + run_in_catalog(:ensure=>:mounted, :options=>'local') + @current_device.should=="/dev/disk1s1" + @mounted.should==true + @current_options.should=='local' + check_fstab(true).should == "/dev/disk1s1" + end + end +end diff --git a/spec/integration/type/file_spec.rb b/spec/integration/type/file_spec.rb index c2702ee7a..46900a0f1 100755 --- a/spec/integration/type/file_spec.rb +++ b/spec/integration/type/file_spec.rb @@ -1,506 +1,509 @@ #!/usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') require 'puppet_spec/files' describe Puppet::Type.type(:file) do include PuppetSpec::Files before do # stub this to not try to create state.yaml Puppet::Util::Storage.stubs(:store) end it "should not attempt to manage files that do not exist if no means of creating the file is specified" do file = Puppet::Type.type(:file).new :path => "/my/file", :mode => "755" catalog = Puppet::Resource::Catalog.new catalog.add_resource file file.parameter(:mode).expects(:retrieve).never transaction = Puppet::Transaction.new(catalog) transaction.resource_harness.evaluate(file).should_not be_failed end describe "when writing files" do it "should backup files to a filebucket when one is configured" do bucket = Puppet::Type.type(:filebucket).new :path => tmpfile("filebucket"), :name => "mybucket" file = Puppet::Type.type(:file).new :path => tmpfile("bucket_backs"), :backup => "mybucket", :content => "foo" catalog = Puppet::Resource::Catalog.new catalog.add_resource file, bucket File.open(file[:path], "w") { |f| f.puts "bar" } md5 = Digest::MD5.hexdigest(File.read(file[:path])) catalog.apply bucket.bucket.getfile(md5).should == "bar\n" end it "should backup files in the local directory when a backup string is provided" do file = Puppet::Type.type(:file).new :path => tmpfile("bucket_backs"), :backup => ".bak", :content => "foo" catalog = Puppet::Resource::Catalog.new catalog.add_resource file File.open(file[:path], "w") { |f| f.puts "bar" } catalog.apply backup = file[:path] + ".bak" FileTest.should be_exist(backup) File.read(backup).should == "bar\n" end it "should fail if no backup can be performed" do dir = tmpfile("backups") Dir.mkdir(dir) path = File.join(dir, "testfile") file = Puppet::Type.type(:file).new :path => path, :backup => ".bak", :content => "foo" catalog = Puppet::Resource::Catalog.new catalog.add_resource file File.open(file[:path], "w") { |f| f.puts "bar" } # Create a directory where the backup should be so that writing to it fails Dir.mkdir(File.join(dir, "testfile.bak")) Puppet::Util::Log.stubs(:newmessage) catalog.apply File.read(file[:path]).should == "bar\n" end it "should not backup symlinks" do link = tmpfile("link") dest1 = tmpfile("dest1") dest2 = tmpfile("dest2") bucket = Puppet::Type.type(:filebucket).new :path => tmpfile("filebucket"), :name => "mybucket" file = Puppet::Type.type(:file).new :path => link, :target => dest2, :ensure => :link, :backup => "mybucket" catalog = Puppet::Resource::Catalog.new catalog.add_resource file, bucket File.open(dest1, "w") { |f| f.puts "whatever" } File.symlink(dest1, link) md5 = Digest::MD5.hexdigest(File.read(file[:path])) catalog.apply File.readlink(link).should == dest2 Find.find(bucket[:path]) { |f| File.file?(f) }.should be_nil end it "should backup directories to the local filesystem by copying the whole directory" do file = Puppet::Type.type(:file).new :path => tmpfile("bucket_backs"), :backup => ".bak", :content => "foo", :force => true catalog = Puppet::Resource::Catalog.new catalog.add_resource file Dir.mkdir(file[:path]) otherfile = File.join(file[:path], "foo") File.open(otherfile, "w") { |f| f.print "yay" } catalog.apply backup = file[:path] + ".bak" FileTest.should be_directory(backup) File.read(File.join(backup, "foo")).should == "yay" end it "should backup directories to filebuckets by backing up each file separately" do bucket = Puppet::Type.type(:filebucket).new :path => tmpfile("filebucket"), :name => "mybucket" file = Puppet::Type.type(:file).new :path => tmpfile("bucket_backs"), :backup => "mybucket", :content => "foo", :force => true catalog = Puppet::Resource::Catalog.new catalog.add_resource file, bucket Dir.mkdir(file[:path]) foofile = File.join(file[:path], "foo") barfile = File.join(file[:path], "bar") File.open(foofile, "w") { |f| f.print "fooyay" } File.open(barfile, "w") { |f| f.print "baryay" } foomd5 = Digest::MD5.hexdigest(File.read(foofile)) barmd5 = Digest::MD5.hexdigest(File.read(barfile)) catalog.apply bucket.bucket.getfile(foomd5).should == "fooyay" bucket.bucket.getfile(barmd5).should == "baryay" end it "should propagate failures encountered when renaming the temporary file" do file = Puppet::Type.type(:file).new :path => tmpfile("fail_rename"), :content => "foo" file.stubs(:remove_existing) # because it tries to make a backup catalog = Puppet::Resource::Catalog.new catalog.add_resource file File.open(file[:path], "w") { |f| f.print "bar" } File.expects(:rename).raises ArgumentError lambda { file.write(:content) }.should raise_error(Puppet::Error) File.read(file[:path]).should == "bar" end end describe "when recursing" do def build_path(dir) Dir.mkdir(dir) File.chmod(0750, dir) @dirs = [dir] @files = [] %w{one two}.each do |subdir| fdir = File.join(dir, subdir) Dir.mkdir(fdir) File.chmod(0750, fdir) @dirs << fdir %w{three}.each do |file| ffile = File.join(fdir, file) @files << ffile File.open(ffile, "w") { |f| f.puts "test #{file}" } File.chmod(0640, ffile) end end end it "should be able to recurse over a nonexistent file" do @path = tmpfile("file_integration_tests") - @file = Puppet::Type::File.new(:name => @path, :mode => 0644, :recurse => true, :backup => false) + @file = Puppet::Type::File.new( + :name => @path, + :mode => 0644, + :recurse => true, + :backup => false + ) @catalog = Puppet::Resource::Catalog.new @catalog.add_resource @file lambda { @file.eval_generate }.should_not raise_error end it "should be able to recursively set properties on existing files" do @path = tmpfile("file_integration_tests") build_path(@path) - @file = Puppet::Type::File.new(:name => @path, :mode => 0644, :recurse => true, :backup => false) + @file = Puppet::Type::File.new( + :name => @path, + :mode => 0644, + :recurse => true, + :backup => false + ) @catalog = Puppet::Resource::Catalog.new @catalog.add_resource @file @catalog.apply @dirs.each do |path| (File.stat(path).mode & 007777).should == 0755 end @files.each do |path| (File.stat(path).mode & 007777).should == 0644 end end it "should be able to recursively make links to other files" do source = tmpfile("file_link_integration_source") build_path(source) dest = tmpfile("file_link_integration_dest") @file = Puppet::Type::File.new(:name => dest, :target => source, :recurse => true, :ensure => :link, :backup => false) @catalog = Puppet::Resource::Catalog.new @catalog.add_resource @file @catalog.apply @dirs.each do |path| link_path = path.sub(source, dest) File.lstat(link_path).should be_directory end @files.each do |path| link_path = path.sub(source, dest) File.lstat(link_path).ftype.should == "link" end end it "should be able to recursively copy files" do source = tmpfile("file_source_integration_source") build_path(source) dest = tmpfile("file_source_integration_dest") @file = Puppet::Type::File.new(:name => dest, :source => source, :recurse => true, :backup => false) @catalog = Puppet::Resource::Catalog.new @catalog.add_resource @file @catalog.apply @dirs.each do |path| newpath = path.sub(source, dest) File.lstat(newpath).should be_directory end @files.each do |path| newpath = path.sub(source, dest) File.lstat(newpath).ftype.should == "file" end end it "should not recursively manage files managed by a more specific explicit file" do dir = tmpfile("recursion_vs_explicit_1") subdir = File.join(dir, "subdir") file = File.join(subdir, "file") FileUtils.mkdir_p(subdir) File.open(file, "w") { |f| f.puts "" } base = Puppet::Type::File.new(:name => dir, :recurse => true, :backup => false, :mode => "755") sub = Puppet::Type::File.new(:name => subdir, :recurse => true, :backup => false, :mode => "644") @catalog = Puppet::Resource::Catalog.new @catalog.add_resource base @catalog.add_resource sub @catalog.apply (File.stat(file).mode & 007777).should == 0644 end it "should recursively manage files even if there is an explicit file whose name is a prefix of the managed file" do dir = tmpfile("recursion_vs_explicit_2") managed = File.join(dir, "file") generated = File.join(dir, "file_with_a_name_starting_with_the_word_file") FileUtils.mkdir_p(dir) File.open(managed, "w") { |f| f.puts "" } File.open(generated, "w") { |f| f.puts "" } @catalog = Puppet::Resource::Catalog.new @catalog.add_resource Puppet::Type::File.new(:name => dir, :recurse => true, :backup => false, :mode => "755") @catalog.add_resource Puppet::Type::File.new(:name => managed, :recurse => true, :backup => false, :mode => "644") @catalog.apply (File.stat(generated).mode & 007777).should == 0755 end end describe "when generating resources" do before do @source = tmpfile("generating_in_catalog_source") @dest = tmpfile("generating_in_catalog_dest") Dir.mkdir(@source) s1 = File.join(@source, "one") s2 = File.join(@source, "two") File.open(s1, "w") { |f| f.puts "uno" } File.open(s2, "w") { |f| f.puts "dos" } @file = Puppet::Type::File.new(:name => @dest, :source => @source, :recurse => true, :backup => false) @catalog = Puppet::Resource::Catalog.new @catalog.add_resource @file end it "should add each generated resource to the catalog" do @catalog.apply do |trans| @catalog.resource(:file, File.join(@dest, "one")).should be_instance_of(@file.class) @catalog.resource(:file, File.join(@dest, "two")).should be_instance_of(@file.class) end end it "should have an edge to each resource in the relationship graph" do @catalog.apply do |trans| one = @catalog.resource(:file, File.join(@dest, "one")) @catalog.relationship_graph.should be_edge(@file, one) two = @catalog.resource(:file, File.join(@dest, "two")) @catalog.relationship_graph.should be_edge(@file, two) end end end describe "when copying files" do # Ticket #285. it "should be able to copy files with pound signs in their names" do source = tmpfile("filewith#signs") dest = tmpfile("destwith#signs") File.open(source, "w") { |f| f.print "foo" } file = Puppet::Type::File.new(:name => dest, :source => source) catalog = Puppet::Resource::Catalog.new catalog.add_resource file catalog.apply File.read(dest).should == "foo" end it "should be able to copy files with spaces in their names" do source = tmpfile("filewith spaces") dest = tmpfile("destwith spaces") File.open(source, "w") { |f| f.print "foo" } File.chmod(0755, source) file = Puppet::Type::File.new(:path => dest, :source => source) catalog = Puppet::Resource::Catalog.new catalog.add_resource file catalog.apply File.read(dest).should == "foo" (File.stat(dest).mode & 007777).should == 0755 end it "should be able to copy individual files even if recurse has been specified" do source = tmpfile("source") dest = tmpfile("dest") File.open(source, "w") { |f| f.print "foo" } file = Puppet::Type::File.new(:name => dest, :source => source, :recurse => true) catalog = Puppet::Resource::Catalog.new catalog.add_resource file catalog.apply File.read(dest).should == "foo" end end it "should be able to create files when 'content' is specified but 'ensure' is not" do dest = tmpfile("files_with_content") - file = Puppet::Type.type(:file).new( - - :name => dest, - + file = Puppet::Type.type(:file).new( + :name => dest, :content => "this is some content, yo" ) catalog = Puppet::Resource::Catalog.new catalog.add_resource file catalog.apply File.read(dest).should == "this is some content, yo" end it "should create files with content if both 'content' and 'ensure' are set" do dest = tmpfile("files_with_content") - file = Puppet::Type.type(:file).new( - - :name => dest, - :ensure => "file", - + file = Puppet::Type.type(:file).new( + :name => dest, + :ensure => "file", :content => "this is some content, yo" ) catalog = Puppet::Resource::Catalog.new catalog.add_resource file catalog.apply File.read(dest).should == "this is some content, yo" end it "should delete files with sources but that are set for deletion" do dest = tmpfile("dest_source_with_ensure") source = tmpfile("source_source_with_ensure") File.open(source, "w") { |f| f.puts "yay" } File.open(dest, "w") { |f| f.puts "boo" } - file = Puppet::Type.type(:file).new( - - :name => dest, + file = Puppet::Type.type(:file).new( + :name => dest, :ensure => :absent, :source => source, - :backup => false ) catalog = Puppet::Resource::Catalog.new catalog.add_resource file catalog.apply File.should_not be_exist(dest) end describe "when purging files" do before do @sourcedir = tmpfile("purge_source") @destdir = tmpfile("purge_dest") Dir.mkdir(@sourcedir) Dir.mkdir(@destdir) @sourcefile = File.join(@sourcedir, "sourcefile") @copiedfile = File.join(@destdir, "sourcefile") @localfile = File.join(@destdir, "localfile") @purgee = File.join(@destdir, "to_be_purged") File.open(@localfile, "w") { |f| f.puts "rahtest" } File.open(@sourcefile, "w") { |f| f.puts "funtest" } # this file should get removed File.open(@purgee, "w") { |f| f.puts "footest" } - @lfobj = Puppet::Type.newfile( - - :title => "localfile", - :path => @localfile, + @lfobj = Puppet::Type.newfile( + :title => "localfile", + :path => @localfile, :content => "rahtest\n", - :ensure => :file, - - :backup => false + :ensure => :file, + :backup => false ) - @destobj = Puppet::Type.newfile( - :title => "destdir", :path => @destdir, - :source => @sourcedir, - :backup => false, - :purge => true, - - :recurse => true) + @destobj = Puppet::Type.newfile( + :title => "destdir", + :path => @destdir, + :source => @sourcedir, + :backup => false, + :purge => true, + :recurse => true + ) @catalog = Puppet::Resource::Catalog.new @catalog.add_resource @lfobj, @destobj end it "should still copy remote files" do @catalog.apply FileTest.should be_exist(@copiedfile) end it "should not purge managed, local files" do @catalog.apply FileTest.should be_exist(@localfile) end it "should purge files that are neither remote nor otherwise managed" do @catalog.apply FileTest.should_not be_exist(@purgee) end end end diff --git a/spec/lib/puppet_spec/files.rb b/spec/lib/puppet_spec/files.rb index 52ed903ec..38c51a572 100644 --- a/spec/lib/puppet_spec/files.rb +++ b/spec/lib/puppet_spec/files.rb @@ -1,20 +1,43 @@ require 'fileutils' require 'tempfile' # A support module for testing files. module PuppetSpec::Files + def self.cleanup + if defined?($tmpfiles) + $tmpfiles.each do |file| + file = File.expand_path(file) + if Puppet.features.posix? and file !~ /^\/tmp/ and file !~ /^\/var\/folders/ + puts "Not deleting tmpfile #{file} outside of /tmp or /var/folders" + next + elsif Puppet.features.microsoft_windows? + tempdir = File.expand_path(File.join(Dir::LOCAL_APPDATA, "Temp")) + if file !~ /^#{tempdir}/ + puts "Not deleting tmpfile #{file} outside of #{tempdir}" + next + end + end + if FileTest.exist?(file) + system("chmod -R 755 '#{file}'") + system("rm -rf '#{file}'") + end + end + $tmpfiles.clear + end + end + def tmpfile(name) source = Tempfile.new(name) path = source.path source.close! $tmpfiles ||= [] $tmpfiles << path path end def tmpdir(name) file = tmpfile(name) FileUtils.mkdir_p(file) file end end diff --git a/spec/lib/puppet_spec/fixtures.rb b/spec/lib/puppet_spec/fixtures.rb new file mode 100644 index 000000000..7f6bc2a8f --- /dev/null +++ b/spec/lib/puppet_spec/fixtures.rb @@ -0,0 +1,28 @@ +module PuppetSpec::Fixtures + def fixtures(*rest) + File.join(PuppetSpec::FIXTURE_DIR, *rest) + end + def my_fixture_dir + callers = caller + while line = callers.shift do + next unless found = line.match(%r{/spec/(.*)_spec\.rb:}) + return fixtures(found[1]) + end + fail "sorry, I couldn't work out your path from the caller stack!" + end + def my_fixture(name) + file = File.join(my_fixture_dir, name) + unless File.readable? file then + fail Puppet::DevError, "fixture '#{name}' for #{my_fixture_dir} is not readable" + end + return file + end + def my_fixtures(glob = '*', flags = 0) + files = Dir.glob(File.join(my_fixture_dir, glob), flags) + unless files.length > 0 then + fail Puppet::DevError, "fixture '#{glob}' for #{my_fixture_dir} had no files!" + end + block_given? and files.each do |file| yield file end + files + end +end diff --git a/spec/shared_behaviours/all_parsedfile_providers.rb b/spec/shared_behaviours/all_parsedfile_providers.rb new file mode 100644 index 000000000..9cb199b5f --- /dev/null +++ b/spec/shared_behaviours/all_parsedfile_providers.rb @@ -0,0 +1,21 @@ +shared_examples_for "all parsedfile providers" do |provider, *files| + if files.empty? then + files = my_fixtures + end + + files.flatten.each do |file| + it "should rewrite #{file} reasonably unchanged" do + provider.stubs(:default_target).returns(file) + provider.prefetch + + text = provider.to_file(provider.target_records(file)) + text.gsub!(/^# HEADER.+\n/, '') + + oldlines = File.readlines(file) + newlines = text.chomp.split "\n" + oldlines.zip(newlines).each do |old, new| + new.gsub(/\s+/, '').should == old.chomp.gsub(/\s+/, '') + end + end + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 84ef3f279..d7f546b0b 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,81 +1,63 @@ unless defined?(SPEC_HELPER_IS_LOADED) SPEC_HELPER_IS_LOADED = 1 dir = File.expand_path(File.dirname(__FILE__)) $LOAD_PATH.unshift("#{dir}/") $LOAD_PATH.unshift("#{dir}/lib") # a spec-specific test lib dir $LOAD_PATH.unshift("#{dir}/../lib") -$LOAD_PATH.unshift("#{dir}/../test/lib") # Don't want puppet getting the command line arguments for rake or autotest ARGV.clear require 'puppet' require 'mocha' gem 'rspec', '>=2.0.0' # So everyone else doesn't have to include this base constant. module PuppetSpec FIXTURE_DIR = File.join(dir = File.expand_path(File.dirname(__FILE__)), "fixtures") unless defined?(FIXTURE_DIR) end -module PuppetTest -end - require 'lib/puppet_spec/files' +require 'lib/puppet_spec/fixtures' require 'monkey_patches/alias_should_to_must' require 'monkey_patches/publicize_methods' RSpec.configure do |config| - config.mock_with :mocha - - config.after :each do - Puppet.settings.clear - Puppet::Node::Environment.clear - Puppet::Util::Storage.clear - - if defined?($tmpfiles) - $tmpfiles.each do |file| - file = File.expand_path(file) - if Puppet.features.posix? and file !~ /^\/tmp/ and file !~ /^\/var\/folders/ - puts "Not deleting tmpfile #{file} outside of /tmp or /var/folders" - next - elsif Puppet.features.microsoft_windows? - tempdir = File.expand_path(File.join(Dir::LOCAL_APPDATA, "Temp")) - if file !~ /^#{tempdir}/ - puts "Not deleting tmpfile #{file} outside of #{tempdir}" - next - end - end - if FileTest.exist?(file) - system("chmod -R 755 '#{file}'") - system("rm -rf '#{file}'") - end - end - $tmpfiles.clear - end + include PuppetSpec::Fixtures - @logs.clear - Puppet::Util::Log.close_all - end + config.mock_with :mocha config.before :each do # these globals are set by Application $puppet_application_mode = nil $puppet_application_name = nil + Signal.stubs(:trap) # Set the confdir and vardir to gibberish so that tests # have to be correctly mocked. Puppet[:confdir] = "/dev/null" Puppet[:vardir] = "/dev/null" # Avoid opening ports to the outside world Puppet.settings[:bindaddress] = "127.0.0.1" @logs = [] Puppet::Util::Log.newdestination(Puppet::Test::LogCollector.new(@logs)) end + + config.after :each do + Puppet.settings.clear + Puppet::Node::Environment.clear + Puppet::Util::Storage.clear + Puppet::Util::ExecutionStub.reset + + PuppetSpec::Files.cleanup + + @logs.clear + Puppet::Util::Log.close_all + end end end diff --git a/spec/unit/application/agent_spec.rb b/spec/unit/application/agent_spec.rb index cee6a0d1a..cc745d1fc 100755 --- a/spec/unit/application/agent_spec.rb +++ b/spec/unit/application/agent_spec.rb @@ -1,596 +1,592 @@ #!/usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') require 'puppet/agent' require 'puppet/application/agent' require 'puppet/network/server' require 'puppet/daemon' require 'puppet/network/handler' describe Puppet::Application::Agent do before :each do @puppetd = Puppet::Application[:agent] @puppetd.stubs(:puts) @daemon = stub_everything 'daemon' Puppet::Daemon.stubs(:new).returns(@daemon) Puppet[:daemonize] = false @agent = stub_everything 'agent' Puppet::Agent.stubs(:new).returns(@agent) @puppetd.preinit Puppet::Util::Log.stubs(:newdestination) Puppet::Util::Log.stubs(:level=) Puppet::Node.indirection.stubs(:terminus_class=) Puppet::Node.indirection.stubs(:cache_class=) Puppet::Node::Facts.indirection.stubs(:terminus_class=) end it "should operate in agent run_mode" do @puppetd.class.run_mode.name.should == :agent end it "should ask Puppet::Application to parse Puppet configuration file" do @puppetd.should_parse_config?.should be_true end it "should declare a main command" do @puppetd.should respond_to(:main) end it "should declare a onetime command" do @puppetd.should respond_to(:onetime) end it "should declare a fingerprint command" do @puppetd.should respond_to(:fingerprint) end it "should declare a preinit block" do @puppetd.should respond_to(:preinit) end describe "in preinit" do - before :each do - @puppetd.stubs(:trap) - end - it "should catch INT" do - @puppetd.expects(:trap).with { |arg,block| arg == :INT } + Signal.expects(:trap).with { |arg,block| arg == :INT } @puppetd.preinit end it "should init client to true" do @puppetd.preinit @puppetd.options[:client].should be_true end it "should init fqdn to nil" do @puppetd.preinit @puppetd.options[:fqdn].should be_nil end it "should init serve to []" do @puppetd.preinit @puppetd.options[:serve].should == [] end it "should use MD5 as default digest algorithm" do @puppetd.preinit @puppetd.options[:digest].should == :MD5 end it "should not fingerprint by default" do @puppetd.preinit @puppetd.options[:fingerprint].should be_false end end describe "when handling options" do before do @puppetd.command_line.stubs(:args).returns([]) end [:centrallogging, :disable, :enable, :debug, :fqdn, :test, :verbose, :digest].each do |option| it "should declare handle_#{option} method" do @puppetd.should respond_to("handle_#{option}".to_sym) end it "should store argument value when calling handle_#{option}" do @puppetd.options.expects(:[]=).with(option, 'arg') @puppetd.send("handle_#{option}".to_sym, 'arg') end end it "should set an existing handler on server" do Puppet::Network::Handler.stubs(:handler).with("handler").returns(true) @puppetd.handle_serve("handler") @puppetd.options[:serve].should == [ :handler ] end it "should set client to false with --no-client" do @puppetd.handle_no_client(nil) @puppetd.options[:client].should be_false end it "should set waitforcert to 0 with --onetime and if --waitforcert wasn't given" do Puppet[:onetime] = true Puppet::SSL::Host.any_instance.expects(:wait_for_cert).with(0) @puppetd.setup_host end it "should use supplied waitforcert when --onetime is specified" do Puppet[:onetime] = true @puppetd.handle_waitforcert(60) Puppet::SSL::Host.any_instance.expects(:wait_for_cert).with(60) @puppetd.setup_host end it "should use a default value for waitforcert when --onetime and --waitforcert are not specified" do Puppet::SSL::Host.any_instance.expects(:wait_for_cert).with(120) @puppetd.setup_host end it "should set the log destination with --logdest" do @puppetd.options.stubs(:[]=).with { |opt,val| opt == :setdest } Puppet::Log.expects(:newdestination).with("console") @puppetd.handle_logdest("console") end it "should put the setdest options to true" do @puppetd.options.expects(:[]=).with(:setdest,true) @puppetd.handle_logdest("console") end it "should parse the log destination from the command line" do @puppetd.command_line.stubs(:args).returns(%w{--logdest /my/file}) Puppet::Util::Log.expects(:newdestination).with("/my/file") @puppetd.parse_options end it "should store the waitforcert options with --waitforcert" do @puppetd.options.expects(:[]=).with(:waitforcert,42) @puppetd.handle_waitforcert("42") end it "should set args[:Port] with --port" do @puppetd.handle_port("42") @puppetd.args[:Port].should == "42" end end describe "during setup" do before :each do @puppetd.options.stubs(:[]) Puppet.stubs(:info) FileTest.stubs(:exists?).returns(true) Puppet[:libdir] = "/dev/null/lib" Puppet::SSL::Host.stubs(:ca_location=) Puppet::Transaction::Report.indirection.stubs(:terminus_class=) Puppet::Transaction::Report.indirection.stubs(:cache_class=) Puppet::Resource::Catalog.indirection.stubs(:terminus_class=) Puppet::Resource::Catalog.indirection.stubs(:cache_class=) Puppet::Node::Facts.indirection.stubs(:terminus_class=) @host = stub_everything 'host' Puppet::SSL::Host.stubs(:new).returns(@host) Puppet.stubs(:settraps) end describe "with --test" do before :each do #Puppet.settings.stubs(:handlearg) @puppetd.options.stubs(:[]=) end it "should call setup_test" do @puppetd.options.stubs(:[]).with(:test).returns(true) @puppetd.expects(:setup_test) @puppetd.setup end it "should set options[:verbose] to true" do @puppetd.options.expects(:[]=).with(:verbose,true) @puppetd.setup_test end it "should set options[:onetime] to true" do Puppet[:onetime] = false @puppetd.setup_test Puppet[:onetime].should == true end it "should set options[:detailed_exitcodes] to true" do @puppetd.options.expects(:[]=).with(:detailed_exitcodes,true) @puppetd.setup_test end end it "should call setup_logs" do @puppetd.expects(:setup_logs) @puppetd.setup end describe "when setting up logs" do before :each do Puppet::Util::Log.stubs(:newdestination) end it "should set log level to debug if --debug was passed" do @puppetd.options.stubs(:[]).with(:debug).returns(true) Puppet::Util::Log.expects(:level=).with(:debug) @puppetd.setup_logs end it "should set log level to info if --verbose was passed" do @puppetd.options.stubs(:[]).with(:verbose).returns(true) Puppet::Util::Log.expects(:level=).with(:info) @puppetd.setup_logs end [:verbose, :debug].each do |level| it "should set console as the log destination with level #{level}" do @puppetd.options.stubs(:[]).with(level).returns(true) Puppet::Util::Log.expects(:newdestination).with(:console) @puppetd.setup_logs end end it "should set syslog as the log destination if no --logdest" do @puppetd.options.stubs(:[]).with(:setdest).returns(false) Puppet::Util::Log.expects(:newdestination).with(:syslog) @puppetd.setup_logs end end it "should print puppet config if asked to in Puppet config" do @puppetd.stubs(:exit) Puppet[:configprint] = "pluginsync" Puppet.settings.expects(:print_configs) @puppetd.setup end it "should exit after printing puppet config if asked to in Puppet config" do Puppet[:configprint] = "pluginsync" lambda { @puppetd.setup }.should raise_error(SystemExit) end it "should set a central log destination with --centrallogs" do @puppetd.options.stubs(:[]).with(:centrallogs).returns(true) Puppet[:server] = "puppet.reductivelabs.com" Puppet::Util::Log.stubs(:newdestination).with(:syslog) Puppet::Util::Log.expects(:newdestination).with("puppet.reductivelabs.com") @puppetd.setup end it "should use :main, :puppetd, and :ssl" do Puppet.settings.expects(:use).with(:main, :agent, :ssl) @puppetd.setup end it "should install a remote ca location" do Puppet::SSL::Host.expects(:ca_location=).with(:remote) @puppetd.setup end it "should install a none ca location in fingerprint mode" do @puppetd.options.stubs(:[]).with(:fingerprint).returns(true) Puppet::SSL::Host.expects(:ca_location=).with(:none) @puppetd.setup end it "should tell the report handler to use REST" do Puppet::Transaction::Report.indirection.expects(:terminus_class=).with(:rest) @puppetd.setup end it "should tell the report handler to cache locally as yaml" do Puppet::Transaction::Report.indirection.expects(:cache_class=).with(:yaml) @puppetd.setup end it "should change the catalog_terminus setting to 'rest'" do Puppet[:catalog_terminus] = :foo @puppetd.setup Puppet[:catalog_terminus].should == :rest end it "should tell the catalog handler to use cache" do Puppet::Resource::Catalog.indirection.expects(:cache_class=).with(:yaml) @puppetd.setup end it "should change the facts_terminus setting to 'facter'" do Puppet[:facts_terminus] = :foo @puppetd.setup Puppet[:facts_terminus].should == :facter end it "should create an agent" do Puppet::Agent.stubs(:new).with(Puppet::Configurer) @puppetd.setup end [:enable, :disable].each do |action| it "should delegate to enable_disable_client if we #{action} the agent" do @puppetd.options.stubs(:[]).with(action).returns(true) @puppetd.expects(:enable_disable_client).with(@agent) @puppetd.setup end end describe "when enabling or disabling agent" do [:enable, :disable].each do |action| it "should call client.#{action}" do @puppetd.stubs(:exit) @puppetd.options.stubs(:[]).with(action).returns(true) @agent.expects(action) @puppetd.enable_disable_client(@agent) end end it "should finally exit" do lambda { @puppetd.enable_disable_client(@agent) }.should raise_error(SystemExit) end end it "should inform the daemon about our agent if :client is set to 'true'" do @puppetd.options.expects(:[]).with(:client).returns true @daemon.expects(:agent=).with(@agent) @puppetd.setup end it "should not inform the daemon about our agent if :client is set to 'false'" do @puppetd.options[:client] = false @daemon.expects(:agent=).never @puppetd.setup end it "should daemonize if needed" do Puppet[:daemonize] = true @daemon.expects(:daemonize) @puppetd.setup end it "should wait for a certificate" do @puppetd.options.stubs(:[]).with(:waitforcert).returns(123) @host.expects(:wait_for_cert).with(123) @puppetd.setup end it "should not wait for a certificate in fingerprint mode" do @puppetd.options.stubs(:[]).with(:fingerprint).returns(true) @puppetd.options.stubs(:[]).with(:waitforcert).returns(123) @host.expects(:wait_for_cert).never @puppetd.setup end it "should setup listen if told to and not onetime" do Puppet[:listen] = true @puppetd.options.stubs(:[]).with(:onetime).returns(false) @puppetd.expects(:setup_listen) @puppetd.setup end describe "when setting up listen" do before :each do Puppet[:authconfig] = 'auth' FileTest.stubs(:exists?).with('auth').returns(true) File.stubs(:exist?).returns(true) @puppetd.options.stubs(:[]).with(:serve).returns([]) @puppetd.stubs(:exit) @server = stub_everything 'server' Puppet::Network::Server.stubs(:new).returns(@server) end it "should exit if no authorization file" do Puppet.stubs(:err) FileTest.stubs(:exists?).with(Puppet[:authconfig]).returns(false) @puppetd.expects(:exit) @puppetd.setup_listen end it "should create a server to listen on at least the Runner handler" do Puppet::Network::Server.expects(:new).with { |args| args[:xmlrpc_handlers] == [:Runner] } @puppetd.setup_listen end it "should create a server to listen for specific handlers" do @puppetd.options.stubs(:[]).with(:serve).returns([:handler]) Puppet::Network::Server.expects(:new).with { |args| args[:xmlrpc_handlers] == [:handler] } @puppetd.setup_listen end it "should use puppet default port" do Puppet[:puppetport] = 32768 Puppet::Network::Server.expects(:new).with { |args| args[:port] == 32768 } @puppetd.setup_listen end end end describe "when running" do before :each do @puppetd.agent = @agent @puppetd.daemon = @daemon @puppetd.options.stubs(:[]).with(:fingerprint).returns(false) end it "should dispatch to fingerprint if --fingerprint is used" do @puppetd.options.stubs(:[]).with(:fingerprint).returns(true) @puppetd.stubs(:fingerprint) @puppetd.run_command end it "should dispatch to onetime if --onetime is used" do @puppetd.options.stubs(:[]).with(:onetime).returns(true) @puppetd.stubs(:onetime) @puppetd.run_command end it "should dispatch to main if --onetime and --fingerprint are not used" do @puppetd.options.stubs(:[]).with(:onetime).returns(false) @puppetd.stubs(:main) @puppetd.run_command end describe "with --onetime" do before :each do @agent.stubs(:run).returns(:report) @puppetd.options.stubs(:[]).with(:client).returns(:client) @puppetd.options.stubs(:[]).with(:detailed_exitcodes).returns(false) @puppetd.stubs(:exit).with(0) Puppet.stubs(:newservice) end it "should exit if no defined --client" do $stderr.stubs(:puts) @puppetd.options.stubs(:[]).with(:client).returns(nil) @puppetd.expects(:exit).with(43) @puppetd.onetime end it "should setup traps" do @daemon.expects(:set_signal_traps) @puppetd.onetime end it "should let the agent run" do @agent.expects(:run).returns(:report) @puppetd.onetime end it "should finish by exiting with 0 error code" do @puppetd.expects(:exit).with(0) @puppetd.onetime end describe "and --detailed-exitcodes" do before :each do @puppetd.options.stubs(:[]).with(:detailed_exitcodes).returns(true) end it "should exit with report's computed exit status" do Puppet[:noop] = false report = stub 'report', :exit_status => 666 @agent.stubs(:run).returns(report) @puppetd.expects(:exit).with(666) @puppetd.onetime end - it "should always exit with 0 if --noop" do + it "should exit with the report's computer exit status, even if --noop is set." do Puppet[:noop] = true report = stub 'report', :exit_status => 666 @agent.stubs(:run).returns(report) - @puppetd.expects(:exit).with(0) + @puppetd.expects(:exit).with(666) @puppetd.onetime end end end describe "with --fingerprint" do before :each do @cert = stub_everything 'cert' @puppetd.options.stubs(:[]).with(:fingerprint).returns(true) @puppetd.options.stubs(:[]).with(:digest).returns(:MD5) @host = stub_everything 'host' @puppetd.stubs(:host).returns(@host) end it "should fingerprint the certificate if it exists" do @host.expects(:certificate).returns(@cert) @cert.expects(:fingerprint).with(:MD5).returns "fingerprint" @puppetd.fingerprint end it "should fingerprint the certificate request if no certificate have been signed" do @host.expects(:certificate).returns(nil) @host.expects(:certificate_request).returns(@cert) @cert.expects(:fingerprint).with(:MD5).returns "fingerprint" @puppetd.fingerprint end it "should display the fingerprint" do @host.stubs(:certificate).returns(@cert) @cert.stubs(:fingerprint).with(:MD5).returns("DIGEST") Puppet.expects(:notice).with("DIGEST") @puppetd.fingerprint end end describe "without --onetime and --fingerprint" do before :each do Puppet.stubs(:notice) @puppetd.options.stubs(:[]).with(:client) end it "should start our daemon" do @daemon.expects(:start) @puppetd.main end end end end diff --git a/spec/unit/application/apply_spec.rb b/spec/unit/application/apply_spec.rb index 8aaa5d8f9..0c6df2cf8 100755 --- a/spec/unit/application/apply_spec.rb +++ b/spec/unit/application/apply_spec.rb @@ -1,419 +1,434 @@ #!/usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') require 'puppet/application/apply' require 'puppet/file_bucket/dipper' require 'puppet/configurer' describe Puppet::Application::Apply do before :each do @apply = Puppet::Application[:apply] Puppet::Util::Log.stubs(:newdestination) Puppet::Util::Log.stubs(:level=) end [:debug,:loadclasses,:verbose,:use_nodes,:detailed_exitcodes].each do |option| it "should declare handle_#{option} method" do @apply.should respond_to("handle_#{option}".to_sym) end it "should store argument value when calling handle_#{option}" do @apply.options.expects(:[]=).with(option, 'arg') @apply.send("handle_#{option}".to_sym, 'arg') end end it "should set the code to the provided code when :execute is used" do @apply.options.expects(:[]=).with(:code, 'arg') @apply.send("handle_execute".to_sym, 'arg') end it "should ask Puppet::Application to parse Puppet configuration file" do @apply.should_parse_config?.should be_true end describe "when applying options" do it "should set the log destination with --logdest" do Puppet::Log.expects(:newdestination).with("console") @apply.handle_logdest("console") end it "should put the logset options to true" do @apply.options.expects(:[]=).with(:logset,true) @apply.handle_logdest("console") end end describe "during setup" do before :each do Puppet::Log.stubs(:newdestination) - Puppet.stubs(:trap) Puppet::Log.stubs(:level=) Puppet.stubs(:parse_config) Puppet::FileBucket::Dipper.stubs(:new) STDIN.stubs(:read) Puppet::Transaction::Report.indirection.stubs(:cache_class=) @apply.options.stubs(:[]).with(any_parameters) end it "should set show_diff on --noop" do Puppet.stubs(:[]=) Puppet.stubs(:[]).with(:config) Puppet.stubs(:[]).with(:noop).returns(true) Puppet.expects(:[]=).with(:show_diff, true) @apply.setup end it "should set console as the log destination if logdest option wasn't provided" do Puppet::Log.expects(:newdestination).with(:console) @apply.setup end it "should set INT trap" do - @apply.expects(:trap).with(:INT) + Signal.expects(:trap).with(:INT) @apply.setup end it "should set log level to debug if --debug was passed" do @apply.options.stubs(:[]).with(:debug).returns(true) Puppet::Log.expects(:level=).with(:debug) @apply.setup end it "should set log level to info if --verbose was passed" do @apply.options.stubs(:[]).with(:verbose).returns(true) Puppet::Log.expects(:level=).with(:info) @apply.setup end it "should print puppet config if asked to in Puppet config" do @apply.stubs(:exit) Puppet.settings.stubs(:print_configs?).returns(true) Puppet.settings.expects(:print_configs) @apply.setup end it "should exit after printing puppet config if asked to in Puppet config" do Puppet.settings.stubs(:print_configs?).returns(true) lambda { @apply.setup }.should raise_error(SystemExit) end it "should tell the report handler to cache locally as yaml" do Puppet::Transaction::Report.indirection.expects(:cache_class=).with(:yaml) @apply.setup end end describe "when executing" do it "should dispatch to parseonly if parseonly is set" do @apply.stubs(:options).returns({}) Puppet.stubs(:[]).with(:parseonly).returns(true) @apply.expects(:parseonly) @apply.run_command end it "should dispatch to 'apply' if it was called with 'apply'" do @apply.options[:catalog] = "foo" @apply.expects(:apply) @apply.run_command end it "should dispatch to main if parseonly is not set" do @apply.stubs(:options).returns({}) Puppet.stubs(:[]).with(:parseonly).returns(false) @apply.expects(:main) @apply.run_command end describe "the parseonly command" do before :each do @environment = Puppet::Node::Environment.new("env") Puppet.stubs(:[]).with(:environment).returns(@environment) Puppet.stubs(:[]).with(:manifest).returns("site.pp") Puppet.stubs(:err) @apply.stubs(:exit) @apply.options.stubs(:[]).with(:code).returns "some code" end it "should use the environment to parse the file" do @environment.stubs(:perform_initial_import) @apply.parseonly end it "should exit with exit code 0 if no error" do @apply.expects(:exit).with(0) @apply.parseonly end it "should exit with exit code 1 if error" do @environment.stubs(:perform_initial_import).raises(Puppet::ParseError) @apply.expects(:exit).with(1) @apply.parseonly end + + it "should exit with exit code 1 if error, even if --noop is set" do + Puppet[:noop] = true + @environment.stubs(:perform_initial_import).raises(Puppet::ParseError) + @apply.expects(:exit).with(1) + @apply.parseonly + end end describe "the main command" do before :each do Puppet.stubs(:[]) Puppet.settings.stubs(:use) Puppet.stubs(:[]).with(:prerun_command).returns "" Puppet.stubs(:[]).with(:postrun_command).returns "" Puppet.stubs(:[]).with(:trace).returns(true) @apply.options.stubs(:[]) @facts = stub_everything 'facts' Puppet::Node::Facts.indirection.stubs(:find).returns(@facts) @node = stub_everything 'node' Puppet::Node.indirection.stubs(:find).returns(@node) @catalog = stub_everything 'catalog' @catalog.stubs(:to_ral).returns(@catalog) Puppet::Resource::Catalog.indirection.stubs(:find).returns(@catalog) STDIN.stubs(:read) @transaction = stub_everything 'transaction' @catalog.stubs(:apply).returns(@transaction) @apply.stubs(:exit) Puppet::Util::Storage.stubs(:load) Puppet::Configurer.any_instance.stubs(:save_last_run_summary) # to prevent it from trying to write files end it "should set the code to run from --code" do @apply.options.stubs(:[]).with(:code).returns("code to run") Puppet.expects(:[]=).with(:code,"code to run") @apply.main end it "should set the code to run from STDIN if no arguments" do @apply.command_line.stubs(:args).returns([]) STDIN.stubs(:read).returns("code to run") Puppet.expects(:[]=).with(:code,"code to run") @apply.main end it "should set the manifest if a file is passed on command line and the file exists" do File.stubs(:exist?).with('site.pp').returns true @apply.command_line.stubs(:args).returns(['site.pp']) Puppet.expects(:[]=).with(:manifest,"site.pp") @apply.main end it "should raise an error if a file is passed on command line and the file does not exist" do File.stubs(:exist?).with('noexist.pp').returns false @apply.command_line.stubs(:args).returns(['noexist.pp']) lambda { @apply.main }.should raise_error(RuntimeError, 'Could not find file noexist.pp') end it "should set the manifest to the first file and warn other files will be skipped" do File.stubs(:exist?).with('starwarsIV').returns true File.expects(:exist?).with('starwarsI').never @apply.command_line.stubs(:args).returns(['starwarsIV', 'starwarsI', 'starwarsII']) Puppet.expects(:[]=).with(:manifest,"starwarsIV") Puppet.expects(:warning).with('Only one file can be applied per run. Skipping starwarsI, starwarsII') @apply.main end it "should collect the node facts" do Puppet::Node::Facts.indirection.expects(:find).returns(@facts) @apply.main end it "should raise an error if we can't find the node" do Puppet::Node::Facts.indirection.expects(:find).returns(nil) lambda { @apply.main }.should raise_error end it "should look for the node" do Puppet::Node.indirection.expects(:find).returns(@node) @apply.main end it "should raise an error if we can't find the node" do Puppet::Node.indirection.expects(:find).returns(nil) lambda { @apply.main }.should raise_error end it "should merge in our node the loaded facts" do @facts.stubs(:values).returns("values") @node.expects(:merge).with("values") @apply.main end it "should load custom classes if loadclasses" do @apply.options.stubs(:[]).with(:loadclasses).returns(true) Puppet.stubs(:[]).with(:classfile).returns("/etc/puppet/classes.txt") FileTest.stubs(:exists?).with("/etc/puppet/classes.txt").returns(true) FileTest.stubs(:readable?).with("/etc/puppet/classes.txt").returns(true) File.stubs(:read).with("/etc/puppet/classes.txt").returns("class") @node.expects(:classes=) @apply.main end it "should compile the catalog" do Puppet::Resource::Catalog.indirection.expects(:find).returns(@catalog) @apply.main end it "should transform the catalog to ral" do @catalog.expects(:to_ral).returns(@catalog) @apply.main end it "should finalize the catalog" do @catalog.expects(:finalize) @apply.main end it "should call the prerun and postrun commands on a Configurer instance" do Puppet::Configurer.any_instance.expects(:execute_prerun_command) Puppet::Configurer.any_instance.expects(:execute_postrun_command) @apply.main end it "should apply the catalog" do @catalog.expects(:apply).returns(stub_everything('transaction')) @apply.main end it "should save the last run summary" do Puppet.stubs(:[]).with(:noop).returns(false) report = Puppet::Transaction::Report.new("apply") Puppet::Transaction::Report.stubs(:new).returns(report) Puppet::Configurer.any_instance.expects(:save_last_run_summary).with(report) @apply.main end describe "with detailed_exitcodes" do it "should exit with report's computed exit status" do Puppet.stubs(:[]).with(:noop).returns(false) @apply.options.stubs(:[]).with(:detailed_exitcodes).returns(true) Puppet::Transaction::Report.any_instance.stubs(:exit_status).returns(666) @apply.expects(:exit).with(666) @apply.main end + it "should exit with report's computed exit status, even if --noop is set" do + Puppet.stubs(:[]).with(:noop).returns(true) + @apply.options.stubs(:[]).with(:detailed_exitcodes).returns(true) + Puppet::Transaction::Report.any_instance.stubs(:exit_status).returns(666) + @apply.expects(:exit).with(666) + + @apply.main + end + it "should always exit with 0 if option is disabled" do Puppet.stubs(:[]).with(:noop).returns(false) @apply.options.stubs(:[]).with(:detailed_exitcodes).returns(false) report = stub 'report', :exit_status => 666 @transaction.stubs(:report).returns(report) @apply.expects(:exit).with(0) @apply.main end it "should always exit with 0 if --noop" do Puppet.stubs(:[]).with(:noop).returns(true) @apply.options.stubs(:[]).with(:detailed_exitcodes).returns(true) report = stub 'report', :exit_status => 666 @transaction.stubs(:report).returns(report) @apply.expects(:exit).with(0) @apply.main end end end describe "the 'apply' command" do it "should read the catalog in from disk if a file name is provided" do @apply.options[:catalog] = "/my/catalog.pson" File.expects(:read).with("/my/catalog.pson").returns "something" Puppet::Resource::Catalog.stubs(:convert_from).with(:pson,'something').returns Puppet::Resource::Catalog.new @apply.apply end it "should read the catalog in from stdin if '-' is provided" do @apply.options[:catalog] = "-" $stdin.expects(:read).returns "something" Puppet::Resource::Catalog.stubs(:convert_from).with(:pson,'something').returns Puppet::Resource::Catalog.new @apply.apply end it "should deserialize the catalog from the default format" do @apply.options[:catalog] = "/my/catalog.pson" File.stubs(:read).with("/my/catalog.pson").returns "something" Puppet::Resource::Catalog.stubs(:default_format).returns :rot13_piglatin Puppet::Resource::Catalog.stubs(:convert_from).with(:rot13_piglatin,'something').returns Puppet::Resource::Catalog.new @apply.apply end it "should fail helpfully if deserializing fails" do @apply.options[:catalog] = "/my/catalog.pson" File.stubs(:read).with("/my/catalog.pson").returns "something syntacically invalid" lambda { @apply.apply }.should raise_error(Puppet::Error) end it "should convert plain data structures into a catalog if deserialization does not do so" do @apply.options[:catalog] = "/my/catalog.pson" File.stubs(:read).with("/my/catalog.pson").returns "something" Puppet::Resource::Catalog.stubs(:convert_from).with(:pson,"something").returns({:foo => "bar"}) Puppet::Resource::Catalog.expects(:pson_create).with({:foo => "bar"}).returns(Puppet::Resource::Catalog.new) @apply.apply end it "should convert the catalog to a RAL catalog and use a Configurer instance to apply it" do @apply.options[:catalog] = "/my/catalog.pson" File.stubs(:read).with("/my/catalog.pson").returns "something" catalog = Puppet::Resource::Catalog.new Puppet::Resource::Catalog.stubs(:convert_from).with(:pson,'something').returns catalog catalog.expects(:to_ral).returns "mycatalog" configurer = stub 'configurer' Puppet::Configurer.expects(:new).returns configurer configurer.expects(:run).with(:catalog => "mycatalog") @apply.apply end end end end diff --git a/spec/unit/application/cert_spec.rb b/spec/unit/application/cert_spec.rb index c7f463ea2..4315bb8d8 100755 --- a/spec/unit/application/cert_spec.rb +++ b/spec/unit/application/cert_spec.rb @@ -1,194 +1,234 @@ #!/usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') require 'puppet/application/cert' describe Puppet::Application::Cert do before :each do @cert_app = Puppet::Application[:cert] Puppet::Util::Log.stubs(:newdestination) Puppet::Util::Log.stubs(:level=) end it "should operate in master run_mode" do @cert_app.class.run_mode.name.should equal(:master) end it "should ask Puppet::Application to parse Puppet configuration file" do @cert_app.should_parse_config?.should be_true end it "should declare a main command" do @cert_app.should respond_to(:main) end Puppet::SSL::CertificateAuthority::Interface::INTERFACE_METHODS.reject{ |m| m == :destroy }.each do |method| it "should declare option --#{method}" do @cert_app.should respond_to("handle_#{method}".to_sym) end end it "should set log level to info with the --verbose option" do Puppet::Log.expects(:level=).with(:info) @cert_app.handle_verbose(0) end it "should set log level to debug with the --debug option" do Puppet::Log.expects(:level=).with(:debug) @cert_app.handle_debug(0) end it "should set the fingerprint digest with the --digest option" do @cert_app.handle_digest(:digest) @cert_app.digest.should == :digest end it "should set cert_mode to :destroy for --clean" do @cert_app.handle_clean(0) - @cert_app.cert_mode.should == :destroy + @cert_app.subcommand.should == :destroy end it "should set all to true for --all" do @cert_app.handle_all(0) @cert_app.all.should be_true end it "should set signed to true for --signed" do @cert_app.handle_signed(0) @cert_app.signed.should be_true end Puppet::SSL::CertificateAuthority::Interface::INTERFACE_METHODS.reject { |m| m == :destroy }.each do |method| it "should set cert_mode to #{method} with option --#{method}" do @cert_app.send("handle_#{method}".to_sym, nil) - @cert_app.cert_mode.should == method + @cert_app.subcommand.should == method end end describe "during setup" do before :each do Puppet::Log.stubs(:newdestination) Puppet::SSL::Host.stubs(:ca_location=) Puppet::SSL::CertificateAuthority.stubs(:new) end it "should set console as the log destination" do Puppet::Log.expects(:newdestination).with(:console) @cert_app.setup end it "should print puppet config if asked to in Puppet config" do @cert_app.stubs(:exit) Puppet.settings.stubs(:print_configs?).returns(true) Puppet.settings.expects(:print_configs) @cert_app.setup end it "should exit after printing puppet config if asked to in Puppet config" do Puppet.settings.stubs(:print_configs?).returns(true) lambda { @cert_app.setup }.should raise_error(SystemExit) end it "should set the CA location to 'only'" do Puppet::SSL::Host.expects(:ca_location=).with(:only) @cert_app.setup end it "should create a new certificate authority" do Puppet::SSL::CertificateAuthority.expects(:new) @cert_app.setup end it "should set the ca_location to :local if the cert_mode is generate" do - @cert_app.find_mode('--generate') + @cert_app.subcommand = 'generate' Puppet::SSL::Host.expects(:ca_location=).with(:local) @cert_app.setup end it "should set the ca_location to :local if the cert_mode is destroy" do - @cert_app.find_mode('--destroy') + @cert_app.subcommand = 'destroy' Puppet::SSL::Host.expects(:ca_location=).with(:local) @cert_app.setup end it "should set the ca_location to :only if the cert_mode is print" do - @cert_app.find_mode('--print') + @cert_app.subcommand = 'print' Puppet::SSL::Host.expects(:ca_location=).with(:only) @cert_app.setup end end describe "when running" do before :each do @cert_app.all = false @ca = stub_everything 'ca' @cert_app.ca = @ca @cert_app.command_line.stubs(:args).returns([]) end it "should delegate to the CertificateAuthority" do @ca.expects(:apply) @cert_app.main end it "should delegate with :all if option --all was given" do @cert_app.handle_all(0) @ca.expects(:apply).with { |cert_mode,to| to[:to] == :all } @cert_app.main end it "should delegate to ca.apply with the hosts given on command line" do @cert_app.command_line.stubs(:args).returns(["host"]) @ca.expects(:apply).with { |cert_mode,to| to[:to] == ["host"]} @cert_app.main end it "should send the currently set digest" do @cert_app.command_line.stubs(:args).returns(["host"]) @cert_app.handle_digest(:digest) @ca.expects(:apply).with { |cert_mode,to| to[:digest] == :digest} @cert_app.main end - it "should delegate to ca.apply with current set cert_mode" do - @cert_app.cert_mode = "currentmode" + it "should revoke cert if cert_mode is clean" do + @cert_app.subcommand = :destroy @cert_app.command_line.stubs(:args).returns(["host"]) - @ca.expects(:apply).with { |cert_mode,to| cert_mode == "currentmode" } + @ca.expects(:apply).with { |cert_mode,to| cert_mode == :revoke } + @ca.expects(:apply).with { |cert_mode,to| cert_mode == :destroy } @cert_app.main end + end - it "should revoke cert if cert_mode is clean" do - @cert_app.cert_mode = :destroy - @cert_app.command_line.stubs(:args).returns(["host"]) + describe "when identifying subcommands" do + before :each do + @cert_app.all = false + @ca = stub_everything 'ca' + @cert_app.ca = @ca + end - @ca.expects(:apply).with { |cert_mode,to| cert_mode == :revoke } - @ca.expects(:apply).with { |cert_mode,to| cert_mode == :destroy } + it "should SystemExit after printing help message" do + # Make the help method silent for testing; this is a bit nasty, but we + # can't identify a cleaner method. Help welcome. --daniel 2011-02-22 + Puppet.features.stubs(:usage?).returns(false) + @cert_app.stubs(:puts) - @cert_app.main + @cert_app.command_line.stubs(:args).returns([]) + expect { @cert_app.parse_options }.should raise_error SystemExit end + %w{list revoke generate sign print verify fingerprint}.each do |cmd| + short = cmd[0,1] + [cmd, "--#{cmd}", "-#{short}"].each do |option| + # In our command line '-v' was eaten by 'verbose', so we can't consume + # it here; this is a special case from our otherwise standard + # processing. --daniel 2011-02-22 + next if option == "-v" + + it "should recognise '#{option}'" do + args = [option, "fun.example.com"] + + @cert_app.command_line.stubs(:args).returns(args) + @cert_app.parse_options + @cert_app.subcommand.should == cmd.to_sym + + args.should == ["fun.example.com"] + end + end + end + + %w{clean --clean -c}.each do |ugly| + it "should recognise the '#{ugly}' option as destroy" do + args = [ugly, "fun.example.com"] + + @cert_app.command_line.stubs(:args).returns(args) + @cert_app.parse_options + @cert_app.subcommand.should == :destroy + + args.should == ["fun.example.com"] + end + end end end diff --git a/spec/unit/application/filebucket_spec.rb b/spec/unit/application/filebucket_spec.rb index 8b811d7c5..013e358d8 100644 --- a/spec/unit/application/filebucket_spec.rb +++ b/spec/unit/application/filebucket_spec.rb @@ -1,224 +1,224 @@ #!/usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') require 'puppet/application/filebucket' require 'puppet/file_bucket/dipper' describe Puppet::Application::Filebucket do before :each do @filebucket = Puppet::Application[:filebucket] end it "should ask Puppet::Application to not parse Puppet configuration file" do @filebucket.should_parse_config?.should be_false end it "should declare a get command" do @filebucket.should respond_to(:get) end it "should declare a backup command" do @filebucket.should respond_to(:backup) end it "should declare a restore command" do @filebucket.should respond_to(:restore) end [:bucket, :debug, :local, :remote, :verbose].each do |option| it "should declare handle_#{option} method" do @filebucket.should respond_to("handle_#{option}".to_sym) end it "should store argument value when calling handle_#{option}" do @filebucket.options.expects(:[]=).with("#{option}".to_sym, 'arg') @filebucket.send("handle_#{option}".to_sym, 'arg') end end describe "during setup" do before :each do Puppet::Log.stubs(:newdestination) Puppet.stubs(:settraps) Puppet::Log.stubs(:level=) Puppet.stubs(:parse_config) Puppet::FileBucket::Dipper.stubs(:new) @filebucket.options.stubs(:[]).with(any_parameters) end it "should set console as the log destination" do Puppet::Log.expects(:newdestination).with(:console) @filebucket.setup end it "should trap INT" do - @filebucket.expects(:trap).with(:INT) + Signal.expects(:trap).with(:INT) @filebucket.setup end it "should set log level to debug if --debug was passed" do @filebucket.options.stubs(:[]).with(:debug).returns(true) Puppet::Log.expects(:level=).with(:debug) @filebucket.setup end it "should set log level to info if --verbose was passed" do @filebucket.options.stubs(:[]).with(:verbose).returns(true) Puppet::Log.expects(:level=).with(:info) @filebucket.setup end it "should Parse puppet config" do Puppet.expects(:parse_config) @filebucket.setup end it "should print puppet config if asked to in Puppet config" do @filebucket.stubs(:exit) Puppet.settings.stubs(:print_configs?).returns(true) Puppet.settings.expects(:print_configs) @filebucket.setup end it "should exit after printing puppet config if asked to in Puppet config" do Puppet.settings.stubs(:print_configs?).returns(true) lambda { @filebucket.setup }.should raise_error(SystemExit) end describe "with local bucket" do before :each do @filebucket.options.stubs(:[]).with(:local).returns(true) end it "should create a client with the default bucket if none passed" do Puppet.stubs(:[]).with(:bucketdir).returns("path") Puppet::FileBucket::Dipper.expects(:new).with { |h| h[:Path] == "path" } @filebucket.setup end it "should create a local Dipper with the given bucket" do @filebucket.options.stubs(:[]).with(:bucket).returns("path") Puppet::FileBucket::Dipper.expects(:new).with { |h| h[:Path] == "path" } @filebucket.setup end end describe "with remote bucket" do it "should create a remote Client to the configured server" do Puppet.stubs(:[]).with(:server).returns("puppet.reductivelabs.com") Puppet::FileBucket::Dipper.expects(:new).with { |h| h[:Server] == "puppet.reductivelabs.com" } @filebucket.setup end end end describe "when running" do before :each do Puppet::Log.stubs(:newdestination) Puppet.stubs(:settraps) Puppet::Log.stubs(:level=) Puppet.stubs(:parse_config) Puppet::FileBucket::Dipper.stubs(:new) @filebucket.options.stubs(:[]).with(any_parameters) @client = stub 'client' Puppet::FileBucket::Dipper.stubs(:new).returns(@client) @filebucket.setup end it "should use the first non-option parameter as the dispatch" do @filebucket.command_line.stubs(:args).returns(['get']) @filebucket.expects(:get) @filebucket.run_command end describe "the command get" do before :each do @filebucket.stubs(:print) @filebucket.stubs(:args).returns([]) end it "should call the client getfile method" do @client.expects(:getfile) @filebucket.get end it "should call the client getfile method with the given md5" do md5="DEADBEEF" @filebucket.stubs(:args).returns([md5]) @client.expects(:getfile).with(md5) @filebucket.get end it "should print the file content" do @client.stubs(:getfile).returns("content") @filebucket.expects(:print).returns("content") @filebucket.get end end describe "the command backup" do it "should call the client backup method for each given parameter" do @filebucket.stubs(:puts) FileTest.stubs(:exists?).returns(true) FileTest.stubs(:readable?).returns(true) @filebucket.stubs(:args).returns(["file1", "file2"]) @client.expects(:backup).with("file1") @client.expects(:backup).with("file2") @filebucket.backup end end describe "the command restore" do it "should call the client getfile method with the given md5" do md5="DEADBEEF" file="testfile" @filebucket.stubs(:args).returns([file, md5]) @client.expects(:restore).with(file,md5) @filebucket.restore end end end end diff --git a/spec/unit/application/inspect_spec.rb b/spec/unit/application/inspect_spec.rb old mode 100644 new mode 100755 index 1d99c6ca9..d334a87ee --- a/spec/unit/application/inspect_spec.rb +++ b/spec/unit/application/inspect_spec.rb @@ -1,278 +1,278 @@ #!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../spec_helper' require 'puppet/application/inspect' require 'puppet/resource/catalog' require 'puppet/indirector/catalog/yaml' require 'puppet/indirector/report/rest' require 'puppet/indirector/file_bucket_file/rest' describe Puppet::Application::Inspect do include PuppetSpec::Files before :each do @inspect = Puppet::Application[:inspect] end describe "during setup" do it "should print its configuration if asked" do Puppet[:configprint] = "all" Puppet.settings.expects(:print_configs).returns(true) lambda { @inspect.setup }.should raise_error(SystemExit) end it "should fail if reporting is turned off" do Puppet[:report] = false lambda { @inspect.setup }.should raise_error(/report=true/) end end describe "when executing" do before :each do Puppet[:report] = true @inspect.options[:logset] = true Puppet::Transaction::Report::Rest.any_instance.stubs(:save) @inspect.setup end it "should retrieve the local catalog" do Puppet::Resource::Catalog::Yaml.any_instance.expects(:find).with {|request| request.key == Puppet[:certname] }.returns(Puppet::Resource::Catalog.new) @inspect.run_command end it "should save the report to REST" do Puppet::Resource::Catalog::Yaml.any_instance.stubs(:find).returns(Puppet::Resource::Catalog.new) Puppet::Transaction::Report::Rest.any_instance.expects(:save).with {|request| request.instance.host == Puppet[:certname] } @inspect.run_command end it "should audit the specified properties" do catalog = Puppet::Resource::Catalog.new file = Tempfile.new("foo") file.puts("file contents") file.close resource = Puppet::Resource.new(:file, file.path, :parameters => {:audit => "all"}) catalog.add_resource(resource) Puppet::Resource::Catalog::Yaml.any_instance.stubs(:find).returns(catalog) events = nil Puppet::Transaction::Report::Rest.any_instance.expects(:save).with do |request| events = request.instance.resource_statuses.values.first.events end @inspect.run_command properties = events.inject({}) do |property_values, event| property_values.merge(event.property => event.previous_value) end properties["ensure"].should == :file properties["content"].should == "{md5}#{Digest::MD5.hexdigest("file contents\n")}" properties.has_key?("target").should == false end it "should set audited to true for all events" do catalog = Puppet::Resource::Catalog.new file = Tempfile.new("foo") resource = Puppet::Resource.new(:file, file.path, :parameters => {:audit => "all"}) catalog.add_resource(resource) Puppet::Resource::Catalog::Yaml.any_instance.stubs(:find).returns(catalog) events = nil Puppet::Transaction::Report::Rest.any_instance.expects(:save).with do |request| events = request.instance.resource_statuses.values.first.events end @inspect.run_command events.each do |event| event.audited.should == true end end it "should not report irrelevent attributes if the resource is absent" do catalog = Puppet::Resource::Catalog.new file = Tempfile.new("foo") resource = Puppet::Resource.new(:file, file.path, :parameters => {:audit => "all"}) file.delete catalog.add_resource(resource) Puppet::Resource::Catalog::Yaml.any_instance.stubs(:find).returns(catalog) events = nil Puppet::Transaction::Report::Rest.any_instance.expects(:save).with do |request| events = request.instance.resource_statuses.values.first.events end @inspect.run_command properties = events.inject({}) do |property_values, event| property_values.merge(event.property => event.previous_value) end properties.should == {"ensure" => :absent} end describe "when archiving to a bucket" do before :each do Puppet[:archive_files] = true Puppet[:archive_file_server] = "filebucketserver" @catalog = Puppet::Resource::Catalog.new Puppet::Resource::Catalog::Yaml.any_instance.stubs(:find).returns(@catalog) end describe "when auditing files" do before :each do @file = tmpfile("foo") @resource = Puppet::Resource.new(:file, @file, :parameters => {:audit => "content"}) @catalog.add_resource(@resource) end it "should send an existing file to the file bucket" do File.open(@file, 'w') { |f| f.write('stuff') } Puppet::FileBucketFile::Rest.any_instance.expects(:head).with do |request| request.server == Puppet[:archive_file_server] end.returns(false) Puppet::FileBucketFile::Rest.any_instance.expects(:save).with do |request| request.server == Puppet[:archive_file_server] and request.instance.contents == 'stuff' end @inspect.run_command end it "should not send unreadable files" do File.open(@file, 'w') { |f| f.write('stuff') } File.chmod(0, @file) Puppet::FileBucketFile::Rest.any_instance.expects(:head).never Puppet::FileBucketFile::Rest.any_instance.expects(:save).never @inspect.run_command end it "should not try to send non-existent files" do Puppet::FileBucketFile::Rest.any_instance.expects(:head).never Puppet::FileBucketFile::Rest.any_instance.expects(:save).never @inspect.run_command end it "should not try to send files whose content we are not auditing" do @resource[:audit] = "group" Puppet::FileBucketFile::Rest.any_instance.expects(:head).never Puppet::FileBucketFile::Rest.any_instance.expects(:save).never @inspect.run_command end it "should continue if bucketing a file fails" do File.open(@file, 'w') { |f| f.write('stuff') } Puppet::FileBucketFile::Rest.any_instance.stubs(:head).returns false Puppet::FileBucketFile::Rest.any_instance.stubs(:save).raises "failure" Puppet::Transaction::Report::Rest.any_instance.expects(:save).with do |request| @report = request.instance end @inspect.run_command - @report.logs.count.should == 1 + @report.logs.first.should_not == nil @report.logs.first.message.should =~ /Could not back up/ end end describe "when auditing non-files" do before :each do Puppet::Type.newtype(:stub_type) do newparam(:name) do desc "The name var" isnamevar end newproperty(:content) do desc "content" def retrieve :whatever end end end @resource = Puppet::Resource.new(:stub_type, 'foo', :parameters => {:audit => "all"}) @catalog.add_resource(@resource) end after :each do Puppet::Type.rmtype(:stub_type) end it "should not try to send non-files" do Puppet::FileBucketFile::Rest.any_instance.expects(:head).never Puppet::FileBucketFile::Rest.any_instance.expects(:save).never @inspect.run_command end end end describe "when there are failures" do before :each do Puppet::Type.newtype(:stub_type) do newparam(:name) do desc "The name var" isnamevar end newproperty(:content) do desc "content" def retrieve raise "failed" end end end @catalog = Puppet::Resource::Catalog.new Puppet::Resource::Catalog::Yaml.any_instance.stubs(:find).returns(@catalog) Puppet::Transaction::Report::Rest.any_instance.expects(:save).with do |request| @report = request.instance end end after :each do Puppet::Type.rmtype(:stub_type) end it "should mark the report failed and create failed events for each property" do @resource = Puppet::Resource.new(:stub_type, 'foo', :parameters => {:audit => "all"}) @catalog.add_resource(@resource) @inspect.run_command @report.status.should == "failed" @report.logs.select{|log| log.message =~ /Could not inspect/}.count.should == 1 @report.resource_statuses.count.should == 1 @report.resource_statuses['Stub_type[foo]'].events.count.should == 1 event = @report.resource_statuses['Stub_type[foo]'].events.first event.property.should == "content" event.status.should == "failure" event.audited.should == true event.instance_variables.should_not include("@previous_value") end it "should continue to the next resource" do @resource = Puppet::Resource.new(:stub_type, 'foo', :parameters => {:audit => "all"}) @other_resource = Puppet::Resource.new(:stub_type, 'bar', :parameters => {:audit => "all"}) @catalog.add_resource(@resource) @catalog.add_resource(@other_resource) @inspect.run_command @report.resource_statuses.count.should == 2 @report.resource_statuses.keys.should =~ ['Stub_type[foo]', 'Stub_type[bar]'] end end end after :all do Puppet::Resource::Catalog.indirection.reset_terminus_class Puppet::Transaction::Report.indirection.terminus_class = :processor end end diff --git a/spec/unit/application/queue_spec.rb b/spec/unit/application/queue_spec.rb index 2ff9001af..bb485ac3c 100755 --- a/spec/unit/application/queue_spec.rb +++ b/spec/unit/application/queue_spec.rb @@ -1,187 +1,183 @@ #!/usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') require 'puppet/application/queue' require 'puppet/indirector/catalog/queue' describe Puppet::Application::Queue do before :each do @queue = Puppet::Application[:queue] @queue.stubs(:puts) @daemon = stub_everything 'daemon', :daemonize => nil Puppet::Util::Log.stubs(:newdestination) Puppet::Util::Log.stubs(:level=) Puppet::Resource::Catalog.indirection.stubs(:terminus_class=) end it "should ask Puppet::Application to parse Puppet configuration file" do @queue.should_parse_config?.should be_true end it "should declare a main command" do @queue.should respond_to(:main) end it "should declare a preinit block" do @queue.should respond_to(:preinit) end describe "in preinit" do - before :each do - @queue.stubs(:trap) - end - it "should catch INT" do - @queue.expects(:trap).with { |arg,block| arg == :INT } + Signal.expects(:trap).with { |arg,block| arg == :INT } @queue.preinit end it "should init :verbose to false" do @queue.preinit @queue.options[:verbose].should be_false end it "should init :debug to false" do @queue.preinit @queue.options[:debug].should be_false end it "should create a Daemon instance and copy ARGV to it" do ARGV.expects(:dup).returns "eh" daemon = mock("daemon") daemon.expects(:argv=).with("eh") Puppet::Daemon.expects(:new).returns daemon @queue.preinit end end describe "when handling options" do [:debug, :verbose].each do |option| it "should declare handle_#{option} method" do @queue.should respond_to("handle_#{option}".to_sym) end it "should store argument value when calling handle_#{option}" do @queue.options.expects(:[]=).with(option, 'arg') @queue.send("handle_#{option}".to_sym, 'arg') end end end describe "during setup" do before :each do @queue.options.stubs(:[]) @queue.daemon.stubs(:daemonize) Puppet.stubs(:info) Puppet.features.stubs(:stomp?).returns true Puppet::Resource::Catalog.indirection.stubs(:terminus_class=) Puppet.stubs(:settraps) Puppet.settings.stubs(:print_config?) Puppet.settings.stubs(:print_config) end it "should fail if the stomp feature is missing" do Puppet.features.expects(:stomp?).returns false lambda { @queue.setup }.should raise_error(ArgumentError) end it "should print puppet config if asked to in Puppet config" do @queue.stubs(:exit) Puppet.settings.stubs(:print_configs?).returns(true) Puppet.settings.expects(:print_configs) @queue.setup end it "should exit after printing puppet config if asked to in Puppet config" do Puppet.settings.stubs(:print_configs?).returns(true) lambda { @queue.setup }.should raise_error(SystemExit) end it "should call setup_logs" do @queue.expects(:setup_logs) @queue.setup end describe "when setting up logs" do before :each do Puppet::Util::Log.stubs(:newdestination) end it "should set log level to debug if --debug was passed" do @queue.options.stubs(:[]).with(:debug).returns(true) Puppet::Util::Log.expects(:level=).with(:debug) @queue.setup_logs end it "should set log level to info if --verbose was passed" do @queue.options.stubs(:[]).with(:verbose).returns(true) Puppet::Util::Log.expects(:level=).with(:info) @queue.setup_logs end [:verbose, :debug].each do |level| it "should set console as the log destination with level #{level}" do @queue.options.stubs(:[]).with(level).returns(true) Puppet::Util::Log.expects(:newdestination).with(:console) @queue.setup_logs end end end it "should configure the Catalog class to use ActiveRecord" do Puppet::Resource::Catalog.indirection.expects(:terminus_class=).with(:active_record) @queue.setup end it "should daemonize if needed" do Puppet.expects(:[]).with(:daemonize).returns(true) @queue.daemon.expects(:daemonize) @queue.setup end end describe "when running" do before :each do @queue.stubs(:sleep_forever) Puppet::Resource::Catalog::Queue.stubs(:subscribe) Thread.list.each { |t| t.stubs(:join) } end it "should subscribe to the queue" do Puppet::Resource::Catalog::Queue.expects(:subscribe) @queue.main end it "should log and save each catalog passed by the queue" do catalog = Puppet::Resource::Catalog.new('eh') Puppet::Resource::Catalog.indirection.expects(:save).with(catalog) Puppet::Resource::Catalog::Queue.expects(:subscribe).yields(catalog) Puppet.expects(:notice).times(2) @queue.main end it "should join all of the running threads" do Thread.list.each { |t| t.expects(:join) } @queue.main end end end diff --git a/spec/unit/application_spec.rb b/spec/unit/application_spec.rb index 65f06169c..befc4f510 100755 --- a/spec/unit/application_spec.rb +++ b/spec/unit/application_spec.rb @@ -1,528 +1,570 @@ #!/usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') require 'puppet/application' require 'puppet' require 'getoptlong' describe Puppet::Application do before do @app = Class.new(Puppet::Application).new @appclass = @app.class # avoid actually trying to parse any settings Puppet.settings.stubs(:parse) end describe "finding" do before do @klass = Puppet::Application @klass.stubs(:puts) end it "should find classes in the namespace" do @klass.find("Agent").should == @klass::Agent end it "should not find classes outside the namespace" do lambda { @klass.find("String") }.should raise_error(SystemExit) end it "should exit if it can't find a class" do lambda { @klass.find("ThisShallNeverEverEverExistAsdf") }.should raise_error(SystemExit) end end describe ".run_mode" do it "should default to user" do @appclass.run_mode.name.should == :user end it "should set and get a value" do @appclass.run_mode :agent @appclass.run_mode.name.should == :agent end end + it "should sadly and frighteningly allow run_mode to change at runtime" do + class TestApp < Puppet::Application + run_mode :master + def run_command + # This is equivalent to calling these methods externally to the + # instance, but since this is what "real world" code is likely to do + # (and we need the class anyway) we may as well test that. --daniel 2011-02-03 + set_run_mode self.class.run_mode "agent" + end + end + + Puppet[:run_mode].should == "user" + + expect { + app = TestApp.new + + Puppet[:run_mode].should == "master" + + app.run + + app.class.run_mode.name.should == :agent + $puppet_application_mode.name.should == :agent + }.should_not raise_error + + Puppet[:run_mode].should == "agent" + end + + it "it should not allow run mode to be set multiple times" do + pending "great floods of tears, you can do this right now" # --daniel 2011-02-03 + app = Puppet::Application.new + expect { + app.set_run_mode app.class.run_mode "master" + $puppet_application_mode.name.should == :master + app.set_run_mode app.class.run_mode "agent" + $puppet_application_mode.name.should == :agent + }.should raise_error + end + + it "should explode when an invalid run mode is set at runtime, for great victory" + # ...but you can, and while it will explode, that only happens too late for + # us to easily test. --daniel 2011-02-03 + it "should have a run entry-point" do @app.should respond_to(:run) end it "should have a read accessor to options" do @app.should respond_to(:options) end it "should include a default setup method" do @app.should respond_to(:setup) end it "should include a default preinit method" do @app.should respond_to(:preinit) end it "should include a default run_command method" do @app.should respond_to(:run_command) end it "should invoke main as the default" do @app.expects( :main ) @app.run_command end describe 'when invoking clear!' do before :each do Puppet::Application.run_status = :stop_requested Puppet::Application.clear! end it 'should have nil run_status' do Puppet::Application.run_status.should be_nil end it 'should return false for restart_requested?' do Puppet::Application.restart_requested?.should be_false end it 'should return false for stop_requested?' do Puppet::Application.stop_requested?.should be_false end it 'should return false for interrupted?' do Puppet::Application.interrupted?.should be_false end it 'should return true for clear?' do Puppet::Application.clear?.should be_true end end describe 'after invoking stop!' do before :each do Puppet::Application.run_status = nil Puppet::Application.stop! end after :each do Puppet::Application.run_status = nil end it 'should have run_status of :stop_requested' do Puppet::Application.run_status.should == :stop_requested end it 'should return true for stop_requested?' do Puppet::Application.stop_requested?.should be_true end it 'should return false for restart_requested?' do Puppet::Application.restart_requested?.should be_false end it 'should return true for interrupted?' do Puppet::Application.interrupted?.should be_true end it 'should return false for clear?' do Puppet::Application.clear?.should be_false end end describe 'when invoking restart!' do before :each do Puppet::Application.run_status = nil Puppet::Application.restart! end after :each do Puppet::Application.run_status = nil end it 'should have run_status of :restart_requested' do Puppet::Application.run_status.should == :restart_requested end it 'should return true for restart_requested?' do Puppet::Application.restart_requested?.should be_true end it 'should return false for stop_requested?' do Puppet::Application.stop_requested?.should be_false end it 'should return true for interrupted?' do Puppet::Application.interrupted?.should be_true end it 'should return false for clear?' do Puppet::Application.clear?.should be_false end end describe 'when performing a controlled_run' do it 'should not execute block if not :clear?' do Puppet::Application.run_status = :stop_requested target = mock 'target' target.expects(:some_method).never Puppet::Application.controlled_run do target.some_method end end it 'should execute block if :clear?' do Puppet::Application.run_status = nil target = mock 'target' target.expects(:some_method).once Puppet::Application.controlled_run do target.some_method end end describe 'on POSIX systems', :if => Puppet.features.posix? do it 'should signal process with HUP after block if restart requested during block execution' do Puppet::Application.run_status = nil target = mock 'target' target.expects(:some_method).once old_handler = trap('HUP') { target.some_method } begin Puppet::Application.controlled_run do Puppet::Application.run_status = :restart_requested end ensure trap('HUP', old_handler) end end end after :each do Puppet::Application.run_status = nil end end describe "when parsing command-line options" do before :each do @app.command_line.stubs(:args).returns([]) Puppet.settings.stubs(:optparse_addargs).returns([]) end it "should pass the banner to the option parser" do option_parser = stub "option parser" option_parser.stubs(:on) option_parser.stubs(:parse!) @app.class.instance_eval do banner "banner" end OptionParser.expects(:new).with("banner").returns(option_parser) @app.parse_options end it "should get options from Puppet.settings.optparse_addargs" do Puppet.settings.expects(:optparse_addargs).returns([]) @app.parse_options end it "should add Puppet.settings options to OptionParser" do Puppet.settings.stubs(:optparse_addargs).returns( [["--option","-o", "Funny Option"]]) Puppet.settings.expects(:handlearg).with("--option", 'true') @app.command_line.stubs(:args).returns(["--option"]) @app.parse_options end it "should ask OptionParser to parse the command-line argument" do @app.command_line.stubs(:args).returns(%w{ fake args }) OptionParser.any_instance.expects(:parse!).with(%w{ fake args }) @app.parse_options end - describe "when using --help", :if => Puppet.features.usage? do + describe "when using --help" do - it "should call RDoc::usage and exit" do + it "should call exit" do @app.expects(:exit) - RDoc.expects(:usage).returns(true) + @app.stubs(:puts) @app.handle_help(nil) end end describe "when using --version" do it "should declare a version option" do @app.should respond_to(:handle_version) end it "should exit after printing the version" do @app.stubs(:puts) lambda { @app.handle_version(nil) }.should raise_error(SystemExit) end end describe "when dealing with an argument not declared directly by the application" do it "should pass it to handle_unknown if this method exists" do Puppet.settings.stubs(:optparse_addargs).returns([["--not-handled", :REQUIRED]]) @app.expects(:handle_unknown).with("--not-handled", "value").returns(true) @app.command_line.stubs(:args).returns(["--not-handled", "value"]) @app.parse_options end it "should pass it to Puppet.settings if handle_unknown says so" do Puppet.settings.stubs(:optparse_addargs).returns([["--topuppet", :REQUIRED]]) @app.stubs(:handle_unknown).with("--topuppet", "value").returns(false) Puppet.settings.expects(:handlearg).with("--topuppet", "value") @app.command_line.stubs(:args).returns(["--topuppet", "value"]) @app.parse_options end it "should pass it to Puppet.settings if there is no handle_unknown method" do Puppet.settings.stubs(:optparse_addargs).returns([["--topuppet", :REQUIRED]]) @app.stubs(:respond_to?).returns(false) Puppet.settings.expects(:handlearg).with("--topuppet", "value") @app.command_line.stubs(:args).returns(["--topuppet", "value"]) @app.parse_options end it "should transform boolean false value to string for Puppet.settings" do Puppet.settings.expects(:handlearg).with("--option", "false") @app.handlearg("--option", false) end it "should transform boolean true value to string for Puppet.settings" do Puppet.settings.expects(:handlearg).with("--option", "true") @app.handlearg("--option", true) end it "should transform boolean option to normal form for Puppet.settings" do Puppet.settings.expects(:handlearg).with("--option", "true") @app.handlearg("--[no-]option", true) end it "should transform boolean option to no- form for Puppet.settings" do Puppet.settings.expects(:handlearg).with("--no-option", "false") @app.handlearg("--[no-]option", false) end end it "should exit if OptionParser raises an error" do $stderr.stubs(:puts) OptionParser.any_instance.stubs(:parse!).raises(OptionParser::ParseError.new("blah blah")) @app.expects(:exit) lambda { @app.parse_options }.should_not raise_error end end describe "when calling default setup" do before :each do @app.stubs(:should_parse_config?).returns(false) @app.options.stubs(:[]) end [ :debug, :verbose ].each do |level| it "should honor option #{level}" do @app.options.stubs(:[]).with(level).returns(true) Puppet::Util::Log.stubs(:newdestination) Puppet::Util::Log.expects(:level=).with(level == :verbose ? :info : :debug) @app.setup end end it "should honor setdest option" do @app.options.stubs(:[]).with(:setdest).returns(false) Puppet::Util::Log.expects(:newdestination).with(:syslog) @app.setup end end describe "when running" do before :each do @app.stubs(:preinit) @app.stubs(:setup) @app.stubs(:parse_options) end it "should call preinit" do @app.stubs(:run_command) @app.expects(:preinit) @app.run end it "should call parse_options" do @app.stubs(:run_command) @app.expects(:parse_options) @app.run end it "should call run_command" do @app.expects(:run_command) @app.run end it "should parse Puppet configuration if should_parse_config is called" do @app.stubs(:run_command) @app.class.should_parse_config Puppet.settings.expects(:parse) @app.run end it "should not parse_option if should_not_parse_config is called" do @app.stubs(:run_command) @app.class.should_not_parse_config Puppet.settings.expects(:parse).never @app.run end it "should parse Puppet configuration if needed" do @app.stubs(:run_command) @app.stubs(:should_parse_config?).returns(true) Puppet.settings.expects(:parse) @app.run end it "should call run_command" do @app.expects(:run_command) @app.run end it "should call main as the default command" do @app.expects(:main) @app.run end it "should warn and exit if no command can be called" do $stderr.expects(:puts) @app.expects(:exit).with(1) @app.run end it "should raise an error if dispatch returns no command" do @app.stubs(:get_command).returns(nil) $stderr.expects(:puts) @app.expects(:exit).with(1) @app.run end it "should raise an error if dispatch returns an invalid command" do @app.stubs(:get_command).returns(:this_function_doesnt_exist) $stderr.expects(:puts) @app.expects(:exit).with(1) @app.run end end describe "when metaprogramming" do describe "when calling option" do it "should create a new method named after the option" do @app.class.option("--test1","-t") do end @app.should respond_to(:handle_test1) end it "should transpose in option name any '-' into '_'" do @app.class.option("--test-dashes-again","-t") do end @app.should respond_to(:handle_test_dashes_again) end it "should create a new method called handle_test2 with option(\"--[no-]test2\")" do @app.class.option("--[no-]test2","-t") do end @app.should respond_to(:handle_test2) end describe "when a block is passed" do it "should create a new method with it" do @app.class.option("--[no-]test2","-t") do raise "I can't believe it, it works!" end lambda { @app.handle_test2 }.should raise_error end it "should declare the option to OptionParser" do OptionParser.any_instance.stubs(:on) OptionParser.any_instance.expects(:on).with { |*arg| arg[0] == "--[no-]test3" } @app.class.option("--[no-]test3","-t") do end @app.parse_options end it "should pass a block that calls our defined method" do OptionParser.any_instance.stubs(:on) OptionParser.any_instance.stubs(:on).with('--test4','-t').yields(nil) @app.expects(:send).with(:handle_test4, nil) @app.class.option("--test4","-t") do end @app.parse_options end end describe "when no block is given" do it "should declare the option to OptionParser" do OptionParser.any_instance.stubs(:on) OptionParser.any_instance.expects(:on).with("--test4","-t") @app.class.option("--test4","-t") @app.parse_options end it "should give to OptionParser a block that adds the the value to the options array" do OptionParser.any_instance.stubs(:on) OptionParser.any_instance.stubs(:on).with("--test4","-t").yields(nil) @app.options.expects(:[]=).with(:test4,nil) @app.class.option("--test4","-t") @app.parse_options end end end end end diff --git a/spec/unit/configurer/downloader_spec.rb b/spec/unit/configurer/downloader_spec.rb index b2485ccc8..266a96b03 100755 --- a/spec/unit/configurer/downloader_spec.rb +++ b/spec/unit/configurer/downloader_spec.rb @@ -1,188 +1,200 @@ #!/usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') require 'puppet/configurer/downloader' describe Puppet::Configurer::Downloader do + require 'puppet_spec/files' + include PuppetSpec::Files it "should require a name" do lambda { Puppet::Configurer::Downloader.new }.should raise_error(ArgumentError) end it "should require a path and a source at initialization" do lambda { Puppet::Configurer::Downloader.new("name") }.should raise_error(ArgumentError) end it "should set the name, path and source appropriately" do dler = Puppet::Configurer::Downloader.new("facts", "path", "source") dler.name.should == "facts" dler.path.should == "path" dler.source.should == "source" end it "should be able to provide a timeout value" do Puppet::Configurer::Downloader.should respond_to(:timeout) end it "should use the configtimeout, converted to an integer, as its timeout" do Puppet.settings.expects(:value).with(:configtimeout).returns "50" Puppet::Configurer::Downloader.timeout.should == 50 end describe "when creating the file that does the downloading" do before do @dler = Puppet::Configurer::Downloader.new("foo", "path", "source") end it "should create a file instance with the right path and source" do Puppet::Type.type(:file).expects(:new).with { |opts| opts[:path] == "path" and opts[:source] == "source" } @dler.file end it "should tag the file with the downloader name" do Puppet::Type.type(:file).expects(:new).with { |opts| opts[:tag] == "foo" } @dler.file end it "should always recurse" do Puppet::Type.type(:file).expects(:new).with { |opts| opts[:recurse] == true } @dler.file end it "should always purge" do Puppet::Type.type(:file).expects(:new).with { |opts| opts[:purge] == true } @dler.file end it "should never be in noop" do Puppet::Type.type(:file).expects(:new).with { |opts| opts[:noop] == false } @dler.file end it "should always set the owner to the current UID" do Process.expects(:uid).returns 51 Puppet::Type.type(:file).expects(:new).with { |opts| opts[:owner] == 51 } @dler.file end it "should always set the group to the current GID" do Process.expects(:gid).returns 61 Puppet::Type.type(:file).expects(:new).with { |opts| opts[:group] == 61 } @dler.file end it "should always force the download" do Puppet::Type.type(:file).expects(:new).with { |opts| opts[:force] == true } @dler.file end it "should never back up when downloading" do Puppet::Type.type(:file).expects(:new).with { |opts| opts[:backup] == false } @dler.file end it "should support providing an 'ignore' parameter" do Puppet::Type.type(:file).expects(:new).with { |opts| opts[:ignore] == [".svn"] } @dler = Puppet::Configurer::Downloader.new("foo", "path", "source", ".svn") @dler.file end it "should split the 'ignore' parameter on whitespace" do Puppet::Type.type(:file).expects(:new).with { |opts| opts[:ignore] == %w{.svn CVS} } @dler = Puppet::Configurer::Downloader.new("foo", "path", "source", ".svn CVS") @dler.file end end describe "when creating the catalog to do the downloading" do before do - @dler = Puppet::Configurer::Downloader.new("foo", "path", "source") + @dler = Puppet::Configurer::Downloader.new("foo", "/download/path", "source") end it "should create a catalog and add the file to it" do - file = mock 'file' - catalog = mock 'catalog' - - @dler.expects(:file).returns file - - Puppet::Resource::Catalog.expects(:new).returns catalog - catalog.expects(:add_resource).with(file) + catalog = @dler.catalog + catalog.resources.size.should == 1 + catalog.resources.first.class.should == Puppet::Type::File + catalog.resources.first.name.should == "/download/path" + end - @dler.catalog.should equal(catalog) + it "should specify that it is not managing a host catalog" do + @dler.catalog.host_config.should == false end + end describe "when downloading" do before do - @dler = Puppet::Configurer::Downloader.new("foo", "path", "source") + @dl_name = tmpfile("downloadpath") + source_name = tmpfile("source") + File.open(source_name, 'w') {|f| f.write('hola mundo') } + @dler = Puppet::Configurer::Downloader.new("foo", @dl_name, source_name) + end + + it "should not skip downloaded resources when filtering on tags" do + Puppet[:tags] = 'maytag' + @dler.evaluate + + File.exists?(@dl_name).should be_true end it "should log that it is downloading" do Puppet.expects(:info) Timeout.stubs(:timeout) @dler.evaluate end it "should set a timeout for the download" do Puppet::Configurer::Downloader.expects(:timeout).returns 50 Timeout.expects(:timeout).with(50) @dler.evaluate end it "should apply the catalog within the timeout block" do catalog = mock 'catalog' @dler.expects(:catalog).returns(catalog) Timeout.expects(:timeout).yields catalog.expects(:apply) @dler.evaluate end it "should return all changed file paths" do trans = mock 'transaction' catalog = mock 'catalog' @dler.expects(:catalog).returns(catalog) catalog.expects(:apply).yields(trans) Timeout.expects(:timeout).yields resource = mock 'resource' resource.expects(:[]).with(:path).returns "/changed/file" trans.expects(:changed?).returns([resource]) @dler.evaluate.should == %w{/changed/file} end it "should yield the resources if a block is given" do trans = mock 'transaction' catalog = mock 'catalog' @dler.expects(:catalog).returns(catalog) catalog.expects(:apply).yields(trans) Timeout.expects(:timeout).yields resource = mock 'resource' resource.expects(:[]).with(:path).returns "/changed/file" trans.expects(:changed?).returns([resource]) yielded = nil @dler.evaluate { |r| yielded = r } yielded.should == resource end it "should catch and log exceptions" do Puppet.expects(:err) Timeout.stubs(:timeout).raises(Puppet::Error, "testing") lambda { @dler.evaluate }.should_not raise_error end end end diff --git a/spec/unit/daemon_spec.rb b/spec/unit/daemon_spec.rb index 282a2bcbf..4de76b728 100755 --- a/spec/unit/daemon_spec.rb +++ b/spec/unit/daemon_spec.rb @@ -1,300 +1,296 @@ #!/usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') require 'puppet/daemon' def without_warnings flag = $VERBOSE $VERBOSE = nil yield $VERBOSE = flag end describe Puppet::Daemon do before do @daemon = Puppet::Daemon.new end it "should be able to manage an agent" do @daemon.should respond_to(:agent) end it "should be able to manage a network server" do @daemon.should respond_to(:server) end it "should reopen the Log logs when told to reopen logs" do Puppet::Util::Log.expects(:reopen) @daemon.reopen_logs end describe "when setting signal traps" do - before do - @daemon.stubs(:trap) - end - {:INT => :stop, :TERM => :stop, :HUP => :restart, :USR1 => :reload, :USR2 => :reopen_logs}.each do |signal, method| it "should log and call #{method} when it receives #{signal}" do - @daemon.expects(:trap).with(signal).yields + Signal.expects(:trap).with(signal).yields Puppet.expects(:notice) @daemon.expects(method) @daemon.set_signal_traps end end end describe "when starting" do before do @daemon.stubs(:create_pidfile) @daemon.stubs(:set_signal_traps) EventLoop.current.stubs(:run) end it "should fail if it has neither agent nor server" do lambda { @daemon.start }.should raise_error(Puppet::DevError) end it "should create its pidfile" do @daemon.stubs(:agent).returns stub('agent', :start => nil) @daemon.expects(:create_pidfile) @daemon.start end it "should start the agent if the agent is configured" do agent = mock 'agent' agent.expects(:start) @daemon.stubs(:agent).returns agent @daemon.start end it "should start its server if one is configured" do server = mock 'server' server.expects(:start) @daemon.stubs(:server).returns server @daemon.start end it "should let the current EventLoop run" do @daemon.stubs(:agent).returns stub('agent', :start => nil) EventLoop.current.expects(:run) @daemon.start end end describe "when stopping" do before do @daemon.stubs(:remove_pidfile) @daemon.stubs(:exit) Puppet::Util::Log.stubs(:close_all) # to make the global safe to mock, set it to a subclass of itself, # then restore it in an after pass without_warnings { Puppet::Application = Class.new(Puppet::Application) } end after do # restore from the superclass so we lose the stub garbage without_warnings { Puppet::Application = Puppet::Application.superclass } end it "should stop its server if one is configured" do server = mock 'server' server.expects(:stop) @daemon.stubs(:server).returns server @daemon.stop end it 'should request a stop from Puppet::Application' do Puppet::Application.expects(:stop!) @daemon.stop end it "should remove its pidfile" do @daemon.expects(:remove_pidfile) @daemon.stop end it "should close all logs" do Puppet::Util::Log.expects(:close_all) @daemon.stop end it "should exit unless called with ':exit => false'" do @daemon.expects(:exit) @daemon.stop end it "should not exit if called with ':exit => false'" do @daemon.expects(:exit).never @daemon.stop :exit => false end end describe "when creating its pidfile" do it "should use an exclusive mutex" do Puppet.settings.expects(:value).with(:name).returns "me" Puppet::Util.expects(:synchronize_on).with("me",Sync::EX) @daemon.create_pidfile end it "should lock the pidfile using the Pidlock class" do pidfile = mock 'pidfile' Puppet.settings.stubs(:value).with(:name).returns "eh" Puppet.settings.expects(:value).with(:pidfile).returns "/my/file" Puppet::Util::Pidlock.expects(:new).with("/my/file").returns pidfile pidfile.expects(:lock).returns true @daemon.create_pidfile end it "should fail if it cannot lock" do pidfile = mock 'pidfile' Puppet.settings.stubs(:value).with(:name).returns "eh" Puppet.settings.stubs(:value).with(:pidfile).returns "/my/file" Puppet::Util::Pidlock.expects(:new).with("/my/file").returns pidfile pidfile.expects(:lock).returns false lambda { @daemon.create_pidfile }.should raise_error end end describe "when removing its pidfile" do it "should use an exclusive mutex" do Puppet.settings.expects(:value).with(:name).returns "me" Puppet::Util.expects(:synchronize_on).with("me",Sync::EX) @daemon.remove_pidfile end it "should do nothing if the pidfile is not present" do pidfile = mock 'pidfile', :locked? => false Puppet::Util::Pidlock.expects(:new).with("/my/file").returns pidfile Puppet.settings.stubs(:value).with(:name).returns "eh" Puppet.settings.stubs(:value).with(:pidfile).returns "/my/file" pidfile.expects(:unlock).never @daemon.remove_pidfile end it "should unlock the pidfile using the Pidlock class" do pidfile = mock 'pidfile', :locked? => true Puppet::Util::Pidlock.expects(:new).with("/my/file").returns pidfile pidfile.expects(:unlock).returns true Puppet.settings.stubs(:value).with(:name).returns "eh" Puppet.settings.stubs(:value).with(:pidfile).returns "/my/file" @daemon.remove_pidfile end it "should warn if it cannot remove the pidfile" do pidfile = mock 'pidfile', :locked? => true Puppet::Util::Pidlock.expects(:new).with("/my/file").returns pidfile pidfile.expects(:unlock).returns false Puppet.settings.stubs(:value).with(:name).returns "eh" Puppet.settings.stubs(:value).with(:pidfile).returns "/my/file" Puppet.expects :err @daemon.remove_pidfile end end describe "when reloading" do it "should do nothing if no agent is configured" do @daemon.reload end it "should do nothing if the agent is running" do agent = mock 'agent' agent.expects(:running?).returns true @daemon.stubs(:agent).returns agent @daemon.reload end it "should run the agent if one is available and it is not running" do agent = mock 'agent' agent.expects(:running?).returns false agent.expects :run @daemon.stubs(:agent).returns agent @daemon.reload end end describe "when restarting" do before do without_warnings { Puppet::Application = Class.new(Puppet::Application) } end after do without_warnings { Puppet::Application = Puppet::Application.superclass } end it 'should set Puppet::Application.restart!' do Puppet::Application.expects(:restart!) @daemon.stubs(:reexec) @daemon.restart end it "should reexec itself if no agent is available" do @daemon.expects(:reexec) @daemon.restart end it "should reexec itself if the agent is not running" do agent = mock 'agent' agent.expects(:running?).returns false @daemon.stubs(:agent).returns agent @daemon.expects(:reexec) @daemon.restart end end describe "when reexecing it self" do before do @daemon.stubs(:exec) @daemon.stubs(:stop) end it "should fail if no argv values are available" do @daemon.expects(:argv).returns nil lambda { @daemon.reexec }.should raise_error(Puppet::DevError) end it "should shut down without exiting" do @daemon.argv = %w{foo} @daemon.expects(:stop).with(:exit => false) @daemon.reexec end it "should call 'exec' with the original executable and arguments" do @daemon.argv = %w{foo} @daemon.expects(:exec).with($0 + " foo") @daemon.reexec end end end diff --git a/spec/unit/file_bucket/dipper_spec.rb b/spec/unit/file_bucket/dipper_spec.rb index 189a3d870..4dabb722b 100755 --- a/spec/unit/file_bucket/dipper_spec.rb +++ b/spec/unit/file_bucket/dipper_spec.rb @@ -1,114 +1,114 @@ #!/usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') require 'pathname' require 'puppet/file_bucket/dipper' require 'puppet/indirector/file_bucket_file/rest' describe Puppet::FileBucket::Dipper do include PuppetSpec::Files def make_tmp_file(contents) file = tmpfile("file_bucket_file") File.open(file, 'w') { |f| f.write(contents) } file end it "should fail in an informative way when there are failures checking for the file on the server" do @dipper = Puppet::FileBucket::Dipper.new(:Path => "/my/bucket") file = make_tmp_file('contents') Puppet::FileBucket::File.indirection.expects(:head).raises ArgumentError lambda { @dipper.backup(file) }.should raise_error(Puppet::Error) end it "should fail in an informative way when there are failures backing up to the server" do @dipper = Puppet::FileBucket::Dipper.new(:Path => "/my/bucket") file = make_tmp_file('contents') Puppet::FileBucket::File.indirection.expects(:head).returns false Puppet::FileBucket::File.indirection.expects(:save).raises ArgumentError lambda { @dipper.backup(file) }.should raise_error(Puppet::Error) end it "should backup files to a local bucket" do Puppet[:bucketdir] = "/non/existent/directory" file_bucket = tmpdir("bucket") @dipper = Puppet::FileBucket::Dipper.new(:Path => file_bucket) file = make_tmp_file('my contents') checksum = "2975f560750e71c478b8e3b39a956adb" Digest::MD5.hexdigest('my contents').should == checksum @dipper.backup(file).should == checksum File.exists?("#{file_bucket}/2/9/7/5/f/5/6/0/2975f560750e71c478b8e3b39a956adb/contents").should == true end it "should not backup a file that is already in the bucket" do @dipper = Puppet::FileBucket::Dipper.new(:Path => "/my/bucket") file = make_tmp_file('my contents') checksum = Digest::MD5.hexdigest('my contents') Puppet::FileBucket::File.indirection.expects(:head).returns true Puppet::FileBucket::File.indirection.expects(:save).never @dipper.backup(file).should == checksum end it "should retrieve files from a local bucket" do @dipper = Puppet::FileBucket::Dipper.new(:Path => "/my/bucket") checksum = Digest::MD5.hexdigest('my contents') request = nil Puppet::FileBucketFile::File.any_instance.expects(:find).with{ |r| request = r }.once.returns(Puppet::FileBucket::File.new('my contents')) @dipper.getfile(checksum).should == 'my contents' request.key.should == "md5/#{checksum}" end it "should backup files to a remote server" do @dipper = Puppet::FileBucket::Dipper.new(:Server => "puppetmaster", :Port => "31337") file = make_tmp_file('my contents') checksum = Digest::MD5.hexdigest('my contents') real_path = Pathname.new(file).realpath request1 = nil request2 = nil Puppet::FileBucketFile::Rest.any_instance.expects(:head).with { |r| request1 = r }.once.returns(nil) Puppet::FileBucketFile::Rest.any_instance.expects(:save).with { |r| request2 = r }.once @dipper.backup(file).should == checksum [request1, request2].each do |r| r.server.should == 'puppetmaster' r.port.should == 31337 - r.key.should == "md5/#{checksum}" + r.key.should == "md5/#{checksum}#{real_path}" end end it "should retrieve files from a remote server" do @dipper = Puppet::FileBucket::Dipper.new(:Server => "puppetmaster", :Port => "31337") checksum = Digest::MD5.hexdigest('my contents') request = nil Puppet::FileBucketFile::Rest.any_instance.expects(:find).with { |r| request = r }.returns(Puppet::FileBucket::File.new('my contents')) @dipper.getfile(checksum).should == "my contents" request.server.should == 'puppetmaster' request.port.should == 31337 request.key.should == "md5/#{checksum}" end end diff --git a/spec/unit/file_bucket/file_spec.rb b/spec/unit/file_bucket/file_spec.rb index 6873264df..d79345736 100644 --- a/spec/unit/file_bucket/file_spec.rb +++ b/spec/unit/file_bucket/file_spec.rb @@ -1,142 +1,107 @@ #!/usr/bin/env ruby require ::File.dirname(__FILE__) + '/../../spec_helper' require 'puppet/file_bucket/file' require 'digest/md5' require 'digest/sha1' describe Puppet::FileBucket::File do include PuppetSpec::Files before do # this is the default from spec_helper, but it keeps getting reset at odd times @bucketdir = tmpdir('bucket') Puppet[:bucketdir] = @bucketdir @digest = "4a8ec4fa5f01b4ab1a0ab8cbccb709f0" @checksum = "{md5}4a8ec4fa5f01b4ab1a0ab8cbccb709f0" @dir = File.join(@bucketdir, '4/a/8/e/c/4/f/a/4a8ec4fa5f01b4ab1a0ab8cbccb709f0') @contents = "file contents" end it "should have a to_s method to return the contents" do Puppet::FileBucket::File.new(@contents).to_s.should == @contents end it "should raise an error if changing content" do x = Puppet::FileBucket::File.new("first") proc { x.contents = "new" }.should raise_error end it "should require contents to be a string" do proc { Puppet::FileBucket::File.new(5) }.should raise_error(ArgumentError) end it "should set the contents appropriately" do Puppet::FileBucket::File.new(@contents).contents.should == @contents end it "should default to 'md5' as the checksum algorithm if the algorithm is not in the name" do Puppet::FileBucket::File.new(@contents).checksum_type.should == "md5" end it "should calculate the checksum" do Puppet::FileBucket::File.new(@contents).checksum.should == @checksum end describe "when using back-ends" do it "should redirect using Puppet::Indirector" do Puppet::Indirector::Indirection.instance(:file_bucket_file).model.should equal(Puppet::FileBucket::File) end it "should have a :save instance method" do Puppet::FileBucket::File.indirection.should respond_to(:save) end end - describe "when saving files" do - it "should save the contents to the calculated path" do - ::File.stubs(:directory?).with(@dir).returns(true) - ::File.expects(:exist?).with("#{@dir}/contents").returns false - - mockfile = mock "file" - mockfile.expects(:print).with(@contents) - ::File.expects(:open).with("#{@dir}/contents", ::File::WRONLY|::File::CREAT, 0440).yields(mockfile) - - Puppet::FileBucket::File.indirection.save(Puppet::FileBucket::File.new(@contents)) - end - - it "should make any directories necessary for storage" do - FileUtils.expects(:mkdir_p).with do |arg| - ::File.umask == 0007 and arg == @dir - end - ::File.expects(:directory?).with(@dir).returns(false) - ::File.expects(:open).with("#{@dir}/contents", ::File::WRONLY|::File::CREAT, 0440) - ::File.expects(:exist?).with("#{@dir}/contents").returns false - - Puppet::FileBucket::File.indirection.save(Puppet::FileBucket::File.new(@contents)) - end - end - it "should return a url-ish name" do Puppet::FileBucket::File.new(@contents).name.should == "md5/4a8ec4fa5f01b4ab1a0ab8cbccb709f0" end it "should reject a url-ish name with an invalid checksum" do bucket = Puppet::FileBucket::File.new(@contents) lambda { bucket.name = "sha1/4a8ec4fa5f01b4ab1a0ab8cbccb709f0/new/path" }.should raise_error end it "should convert the contents to PSON" do Puppet::FileBucket::File.new(@contents).to_pson.should == '{"contents":"file contents"}' end it "should load from PSON" do Puppet::FileBucket::File.from_pson({"contents"=>"file contents"}).contents.should == "file contents" end - it "should save a file" do - ::File.expects(:exist?).with("#{@dir}/contents").returns false - ::File.expects(:directory?).with(@dir).returns false - ::FileUtils.expects(:mkdir_p).with(@dir) - ::File.expects(:open).with("#{@dir}/contents", ::File::WRONLY|::File::CREAT, 0440) - - bucketfile = Puppet::FileBucket::File.new(@contents) - Puppet::FileBucket::File.indirection.save(bucketfile) - - end - def make_bucketed_file FileUtils.mkdir_p(@dir) File.open("#{@dir}/contents", 'w') { |f| f.write @contents } end describe "using the indirector's find method" do it "should return nil if a file doesn't exist" do bucketfile = Puppet::FileBucket::File.indirection.find("md5/#{@digest}") bucketfile.should == nil end it "should find a filebucket if the file exists" do make_bucketed_file bucketfile = Puppet::FileBucket::File.indirection.find("md5/#{@digest}") bucketfile.should_not == nil end describe "using RESTish digest notation" do it "should return nil if a file doesn't exist" do bucketfile = Puppet::FileBucket::File.indirection.find("md5/#{@digest}") bucketfile.should == nil end it "should find a filebucket if the file exists" do make_bucketed_file bucketfile = Puppet::FileBucket::File.indirection.find("md5/#{@digest}") bucketfile.should_not == nil end end end end diff --git a/spec/unit/indirector/facts/inventory_active_record_spec.rb b/spec/unit/indirector/facts/inventory_active_record_spec.rb new file mode 100644 index 000000000..43b9fa397 --- /dev/null +++ b/spec/unit/indirector/facts/inventory_active_record_spec.rb @@ -0,0 +1,164 @@ +#!/usr/bin/env ruby + +require File.dirname(__FILE__) + '/../../../spec_helper' +require 'sqlite3' rescue nil +require 'tempfile' +require 'puppet/rails' + +describe "Puppet::Node::Facts::InventoryActiveRecord", :if => (Puppet.features.rails? and defined? SQLite3) do + let(:terminus) { Puppet::Node::Facts::InventoryActiveRecord.new } + + before :all do + require 'puppet/indirector/facts/inventory_active_record' + @dbfile = Tempfile.new("testdb") + @dbfile.close + end + + after :all do + Puppet::Node::Facts.indirection.reset_terminus_class + @dbfile.unlink + end + + before :each do + Puppet::Node::Facts.indirection.terminus_class = :inventory_active_record + Puppet[:dbadapter] = 'sqlite3' + Puppet[:dblocation] = @dbfile.path + Puppet[:railslog] = "/dev/null" + Puppet::Rails.init + end + + after :each do + Puppet::Rails.teardown + end + + describe "#save" do + it "should use an existing node if possible" do + node = Puppet::Rails::InventoryNode.new(:name => "foo", :timestamp => Time.now) + node.save + facts = Puppet::Node::Facts.new("foo", "uptime_days" => "60", "kernel" => "Darwin") + Puppet::Node::Facts.indirection.save(facts) + + Puppet::Rails::InventoryNode.count.should == 1 + Puppet::Rails::InventoryNode.first.should == node + end + + it "should create a new node if one can't be found" do + # This test isn't valid if there are nodes to begin with + Puppet::Rails::InventoryNode.count.should == 0 + + facts = Puppet::Node::Facts.new("foo", "uptime_days" => "60", "kernel" => "Darwin") + Puppet::Node::Facts.indirection.save(facts) + + Puppet::Rails::InventoryNode.count.should == 1 + Puppet::Rails::InventoryNode.first.name.should == "foo" + end + + it "should save the facts" do + facts = Puppet::Node::Facts.new("foo", "uptime_days" => "60", "kernel" => "Darwin") + Puppet::Node::Facts.indirection.save(facts) + + Puppet::Rails::InventoryFact.all.map{|f| [f.name,f.value]}.should =~ [["uptime_days","60"],["kernel","Darwin"]] + end + + it "should remove the previous facts for an existing node" do + facts = Puppet::Node::Facts.new("foo", "uptime_days" => "30", "kernel" => "Darwin") + Puppet::Node::Facts.indirection.save(facts) + bar_facts = Puppet::Node::Facts.new("bar", "uptime_days" => "35", "kernel" => "Linux") + foo_facts = Puppet::Node::Facts.new("foo", "uptime_days" => "60", "is_virtual" => "false") + Puppet::Node::Facts.indirection.save(bar_facts) + Puppet::Node::Facts.indirection.save(foo_facts) + + Puppet::Node::Facts.indirection.find("bar").should == bar_facts + Puppet::Node::Facts.indirection.find("foo").should == foo_facts + Puppet::Rails::InventoryFact.all.map{|f| [f.name,f.value]}.should_not include(["uptime_days", "30"], ["kernel", "Darwin"]) + end + end + + describe "#find" do + before do + @foo_facts = Puppet::Node::Facts.new("foo", "uptime_days" => "60", "kernel" => "Darwin") + @bar_facts = Puppet::Node::Facts.new("bar", "uptime_days" => "30", "kernel" => "Linux") + Puppet::Node::Facts.indirection.save(@foo_facts) + Puppet::Node::Facts.indirection.save(@bar_facts) + end + + it "should identify facts by node name" do + Puppet::Node::Facts.indirection.find("foo").should == @foo_facts + end + + it "should return nil if no node instance can be found" do + Puppet::Node::Facts.indirection.find("non-existent node").should == nil + end + end + + describe "#search" do + def search_request(conditions) + Puppet::Indirector::Request.new(:facts, :search, nil, conditions) + end + + before :each do + @now = Time.now + @foo = Puppet::Node::Facts.new("foo", "fact1" => "value1", "fact2" => "value2", "uptime_days" => "30") + @bar = Puppet::Node::Facts.new("bar", "fact1" => "value1", "uptime_days" => "60") + @baz = Puppet::Node::Facts.new("baz", "fact1" => "value2", "fact2" => "value1", "uptime_days" => "90") + @bat = Puppet::Node::Facts.new("bat") + @foo.timestamp = @now - 3600*1 + @bar.timestamp = @now - 3600*3 + @baz.timestamp = @now - 3600*5 + @bat.timestamp = @now - 3600*7 + [@foo, @bar, @baz, @bat].each {|facts| Puppet::Node::Facts.indirection.save(facts)} + end + + it "should return node names that match 'equal' constraints" do + request = search_request('facts.fact1.eq' => 'value1', + 'facts.fact2.eq' => 'value2') + terminus.search(request).should == ["foo"] + end + + it "should return node names that match 'not equal' constraints" do + request = search_request('facts.fact1.ne' => 'value2') + terminus.search(request).should == ["bar","foo"] + end + + it "should return node names that match strict inequality constraints" do + request = search_request('facts.uptime_days.gt' => '20', + 'facts.uptime_days.lt' => '70') + terminus.search(request).should == ["bar","foo"] + end + + it "should return node names that match non-strict inequality constraints" do + request = search_request('facts.uptime_days.ge' => '30', + 'facts.uptime_days.le' => '60') + terminus.search(request).should == ["bar","foo"] + end + + it "should return node names whose facts are within a given timeframe" do + request = search_request('meta.timestamp.ge' => @now - 3600*5, + 'meta.timestamp.le' => @now - 3600*1) + terminus.search(request).should == ["bar","baz","foo"] + end + + it "should return node names whose facts are from a specific time" do + request = search_request('meta.timestamp.eq' => @now - 3600*3) + terminus.search(request).should == ["bar"] + end + + it "should return node names whose facts are not from a specific time" do + request = search_request('meta.timestamp.ne' => @now - 3600*1) + terminus.search(request).should == ["bar","bat","baz"] + end + + it "should perform strict searches on nodes by timestamp" do + request = search_request('meta.timestamp.gt' => @now - 3600*5, + 'meta.timestamp.lt' => @now - 3600*1) + terminus.search(request).should == ["bar"] + end + + it "should search nodes based on both facts and timestamp values" do + request = search_request('facts.uptime_days.gt' => '45', + 'meta.timestamp.lt' => @now - 3600*4) + terminus.search(request).should == ["baz"] + end + end +end + diff --git a/spec/unit/indirector/facts/yaml_spec.rb b/spec/unit/indirector/facts/yaml_spec.rb index ae1e97812..c266df18f 100755 --- a/spec/unit/indirector/facts/yaml_spec.rb +++ b/spec/unit/indirector/facts/yaml_spec.rb @@ -1,26 +1,240 @@ #!/usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper') require 'puppet/node/facts' require 'puppet/indirector/facts/yaml' describe Puppet::Node::Facts::Yaml do it "should be a subclass of the Yaml terminus" do Puppet::Node::Facts::Yaml.superclass.should equal(Puppet::Indirector::Yaml) end it "should have documentation" do Puppet::Node::Facts::Yaml.doc.should_not be_nil Puppet::Node::Facts::Yaml.doc.should_not be_empty end it "should be registered with the facts indirection" do indirection = Puppet::Indirector::Indirection.instance(:facts) Puppet::Node::Facts::Yaml.indirection.should equal(indirection) end it "should have its name set to :yaml" do Puppet::Node::Facts::Yaml.name.should == :yaml end + + describe "#search" do + def assert_search_matches(matching, nonmatching, query) + request = Puppet::Indirector::Request.new(:inventory, :search, nil, query) + + Dir.stubs(:glob).returns(matching.keys + nonmatching.keys) + [matching, nonmatching].each do |examples| + examples.each do |key, value| + YAML.stubs(:load_file).with(key).returns value + end + end + Puppet::Node::Facts::Yaml.new.search(request).should =~ matching.values.map {|facts| facts.name} + end + + it "should return node names that match the search query options" do + assert_search_matches({ + '/path/to/matching.yaml' => Puppet::Node::Facts.new("matchingnode", "architecture" => "i386", 'processor_count' => '4'), + '/path/to/matching1.yaml' => Puppet::Node::Facts.new("matchingnode1", "architecture" => "i386", 'processor_count' => '4', 'randomfact' => 'foo') + }, + { + "/path/to/nonmatching.yaml" => Puppet::Node::Facts.new("nonmatchingnode", "architecture" => "powerpc", 'processor_count' => '4'), + "/path/to/nonmatching1.yaml" => Puppet::Node::Facts.new("nonmatchingnode1", "architecture" => "powerpc", 'processor_count' => '5'), + "/path/to/nonmatching2.yaml" => Puppet::Node::Facts.new("nonmatchingnode2", "architecture" => "i386", 'processor_count' => '5'), + "/path/to/nonmatching3.yaml" => Puppet::Node::Facts.new("nonmatchingnode3", 'processor_count' => '4'), + }, + {'facts.architecture' => 'i386', 'facts.processor_count' => '4'} + ) + end + + it "should return empty array when no nodes match the search query options" do + assert_search_matches({}, { + "/path/to/nonmatching.yaml" => Puppet::Node::Facts.new("nonmatchingnode", "architecture" => "powerpc", 'processor_count' => '10'), + "/path/to/nonmatching1.yaml" => Puppet::Node::Facts.new("nonmatchingnode1", "architecture" => "powerpc", 'processor_count' => '5'), + "/path/to/nonmatching2.yaml" => Puppet::Node::Facts.new("nonmatchingnode2", "architecture" => "i386", 'processor_count' => '5'), + "/path/to/nonmatching3.yaml" => Puppet::Node::Facts.new("nonmatchingnode3", 'processor_count' => '4'), + }, + {'facts.processor_count.lt' => '4', 'facts.processor_count.gt' => '4'} + ) + end + + + it "should return node names that match the search query options with the greater than operator" do + assert_search_matches({ + '/path/to/matching.yaml' => Puppet::Node::Facts.new("matchingnode", "architecture" => "i386", 'processor_count' => '5'), + '/path/to/matching1.yaml' => Puppet::Node::Facts.new("matchingnode1", "architecture" => "powerpc", 'processor_count' => '10', 'randomfact' => 'foo') + }, + { + "/path/to/nonmatching.yaml" => Puppet::Node::Facts.new("nonmatchingnode", "architecture" => "powerpc", 'processor_count' => '4'), + "/path/to/nonmatching2.yaml" => Puppet::Node::Facts.new("nonmatchingnode2", "architecture" => "i386", 'processor_count' => '3'), + "/path/to/nonmatching3.yaml" => Puppet::Node::Facts.new("nonmatchingnode3" ), + }, + {'facts.processor_count.gt' => '4'} + ) + end + + it "should return node names that match the search query options with the less than operator" do + assert_search_matches({ + '/path/to/matching.yaml' => Puppet::Node::Facts.new("matchingnode", "architecture" => "i386", 'processor_count' => '5'), + '/path/to/matching1.yaml' => Puppet::Node::Facts.new("matchingnode1", "architecture" => "powerpc", 'processor_count' => '30', 'randomfact' => 'foo') + }, + { + "/path/to/nonmatching.yaml" => Puppet::Node::Facts.new("nonmatchingnode", "architecture" => "powerpc", 'processor_count' => '50' ), + "/path/to/nonmatching2.yaml" => Puppet::Node::Facts.new("nonmatchingnode2", "architecture" => "i386", 'processor_count' => '100'), + "/path/to/nonmatching3.yaml" => Puppet::Node::Facts.new("nonmatchingnode3" ), + }, + {'facts.processor_count.lt' => '50'} + ) + end + + it "should return node names that match the search query options with the less than or equal to operator" do + assert_search_matches({ + '/path/to/matching.yaml' => Puppet::Node::Facts.new("matchingnode", "architecture" => "i386", 'processor_count' => '5'), + '/path/to/matching1.yaml' => Puppet::Node::Facts.new("matchingnode1", "architecture" => "powerpc", 'processor_count' => '50', 'randomfact' => 'foo') + }, + { + "/path/to/nonmatching.yaml" => Puppet::Node::Facts.new("nonmatchingnode", "architecture" => "powerpc", 'processor_count' => '100' ), + "/path/to/nonmatching2.yaml" => Puppet::Node::Facts.new("nonmatchingnode2", "architecture" => "i386", 'processor_count' => '5000'), + "/path/to/nonmatching3.yaml" => Puppet::Node::Facts.new("nonmatchingnode3" ), + }, + {'facts.processor_count.le' => '50'} + ) + end + + it "should return node names that match the search query options with the greater than or equal to operator" do + assert_search_matches({ + '/path/to/matching.yaml' => Puppet::Node::Facts.new("matchingnode", "architecture" => "i386", 'processor_count' => '100'), + '/path/to/matching1.yaml' => Puppet::Node::Facts.new("matchingnode1", "architecture" => "powerpc", 'processor_count' => '50', 'randomfact' => 'foo') + }, + { + "/path/to/nonmatching.yaml" => Puppet::Node::Facts.new("nonmatchingnode", "architecture" => "powerpc", 'processor_count' => '40'), + "/path/to/nonmatching2.yaml" => Puppet::Node::Facts.new("nonmatchingnode2", "architecture" => "i386", 'processor_count' => '9' ), + "/path/to/nonmatching3.yaml" => Puppet::Node::Facts.new("nonmatchingnode3" ), + }, + {'facts.processor_count.ge' => '50'} + ) + end + + it "should return node names that match the search query options with the not equal operator" do + assert_search_matches({ + '/path/to/matching.yaml' => Puppet::Node::Facts.new("matchingnode", "architecture" => 'arm' ), + '/path/to/matching1.yaml' => Puppet::Node::Facts.new("matchingnode1", "architecture" => 'powerpc', 'randomfact' => 'foo') + }, + { + "/path/to/nonmatching.yaml" => Puppet::Node::Facts.new("nonmatchingnode", "architecture" => "i386" ), + "/path/to/nonmatching2.yaml" => Puppet::Node::Facts.new("nonmatchingnode2", "architecture" => "i386", 'processor_count' => '9' ), + "/path/to/nonmatching3.yaml" => Puppet::Node::Facts.new("nonmatchingnode3" ), + }, + {'facts.architecture.ne' => 'i386'} + ) + end + + def apply_timestamp(facts, timestamp) + facts.timestamp = timestamp + facts + end + + it "should be able to query based on meta.timestamp.gt" do + assert_search_matches({ + '/path/to/2010-11-01.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-11-01", {}), Time.parse("2010-11-01")), + '/path/to/2010-11-10.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-11-10", {}), Time.parse("2010-11-10")), + }, + { + '/path/to/2010-10-01.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-01", {}), Time.parse("2010-10-01")), + '/path/to/2010-10-10.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-10", {}), Time.parse("2010-10-10")), + '/path/to/2010-10-15.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-15", {}), Time.parse("2010-10-15")), + }, + {'meta.timestamp.gt' => '2010-10-15'} + ) + end + + it "should be able to query based on meta.timestamp.le" do + assert_search_matches({ + '/path/to/2010-10-01.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-01", {}), Time.parse("2010-10-01")), + '/path/to/2010-10-10.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-10", {}), Time.parse("2010-10-10")), + '/path/to/2010-10-15.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-15", {}), Time.parse("2010-10-15")), + }, + { + '/path/to/2010-11-01.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-11-01", {}), Time.parse("2010-11-01")), + '/path/to/2010-11-10.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-11-10", {}), Time.parse("2010-11-10")), + }, + {'meta.timestamp.le' => '2010-10-15'} + ) + end + + it "should be able to query based on meta.timestamp.lt" do + assert_search_matches({ + '/path/to/2010-10-01.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-01", {}), Time.parse("2010-10-01")), + '/path/to/2010-10-10.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-10", {}), Time.parse("2010-10-10")), + }, + { + '/path/to/2010-11-01.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-11-01", {}), Time.parse("2010-11-01")), + '/path/to/2010-11-10.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-11-10", {}), Time.parse("2010-11-10")), + '/path/to/2010-10-15.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-15", {}), Time.parse("2010-10-15")), + }, + {'meta.timestamp.lt' => '2010-10-15'} + ) + end + + it "should be able to query based on meta.timestamp.ge" do + assert_search_matches({ + '/path/to/2010-11-01.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-11-01", {}), Time.parse("2010-11-01")), + '/path/to/2010-11-10.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-11-10", {}), Time.parse("2010-11-10")), + '/path/to/2010-10-15.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-15", {}), Time.parse("2010-10-15")), + }, + { + '/path/to/2010-10-01.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-01", {}), Time.parse("2010-10-01")), + '/path/to/2010-10-10.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-10", {}), Time.parse("2010-10-10")), + }, + {'meta.timestamp.ge' => '2010-10-15'} + ) + end + + it "should be able to query based on meta.timestamp.eq" do + assert_search_matches({ + '/path/to/2010-10-15.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-15", {}), Time.parse("2010-10-15")), + }, + { + '/path/to/2010-11-01.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-11-01", {}), Time.parse("2010-11-01")), + '/path/to/2010-11-10.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-11-10", {}), Time.parse("2010-11-10")), + '/path/to/2010-10-01.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-01", {}), Time.parse("2010-10-01")), + '/path/to/2010-10-10.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-10", {}), Time.parse("2010-10-10")), + }, + {'meta.timestamp.eq' => '2010-10-15'} + ) + end + + it "should be able to query based on meta.timestamp" do + assert_search_matches({ + '/path/to/2010-10-15.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-15", {}), Time.parse("2010-10-15")), + }, + { + '/path/to/2010-11-01.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-11-01", {}), Time.parse("2010-11-01")), + '/path/to/2010-11-10.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-11-10", {}), Time.parse("2010-11-10")), + '/path/to/2010-10-01.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-01", {}), Time.parse("2010-10-01")), + '/path/to/2010-10-10.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-10", {}), Time.parse("2010-10-10")), + }, + {'meta.timestamp' => '2010-10-15'} + ) + end + + it "should be able to query based on meta.timestamp.ne" do + assert_search_matches({ + '/path/to/2010-11-01.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-11-01", {}), Time.parse("2010-11-01")), + '/path/to/2010-11-10.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-11-10", {}), Time.parse("2010-11-10")), + '/path/to/2010-10-01.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-01", {}), Time.parse("2010-10-01")), + '/path/to/2010-10-10.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-10", {}), Time.parse("2010-10-10")), + }, + { + '/path/to/2010-10-15.yaml' => apply_timestamp(Puppet::Node::Facts.new("2010-10-15", {}), Time.parse("2010-10-15")), + }, + {'meta.timestamp.ne' => '2010-10-15'} + ) + end + end end diff --git a/spec/unit/indirector/file_bucket_file/file_spec.rb b/spec/unit/indirector/file_bucket_file/file_spec.rb index edf537a43..1423cb2e3 100755 --- a/spec/unit/indirector/file_bucket_file/file_spec.rb +++ b/spec/unit/indirector/file_bucket_file/file_spec.rb @@ -1,185 +1,274 @@ #!/usr/bin/env ruby require ::File.dirname(__FILE__) + '/../../../spec_helper' require 'puppet/indirector/file_bucket_file/file' describe Puppet::FileBucketFile::File do include PuppetSpec::Files it "should be a subclass of the Code terminus class" do Puppet::FileBucketFile::File.superclass.should equal(Puppet::Indirector::Code) end it "should have documentation" do Puppet::FileBucketFile::File.doc.should be_instance_of(String) end describe "non-stubbing tests" do include PuppetSpec::Files before do Puppet[:bucketdir] = tmpdir('bucketdir') end - describe "when diffing files" do - def save_bucket_file(contents) - bucket_file = Puppet::FileBucket::File.new(contents) - Puppet::FileBucket::File.indirection.save(bucket_file) - bucket_file.checksum_data + def save_bucket_file(contents, path = "/who_cares") + bucket_file = Puppet::FileBucket::File.new(contents) + Puppet::FileBucket::File.indirection.save(bucket_file, "md5/#{Digest::MD5.hexdigest(contents)}#{path}") + bucket_file.checksum_data + end + + describe "when servicing a save request" do + describe "when supplying a path" do + it "should store the path if not already stored" do + checksum = save_bucket_file("stuff", "/foo/bar") + dir_path = "#{Puppet[:bucketdir]}/c/1/3/d/8/8/c/b/c13d88cb4cb02003daedb8a84e5d272a" + File.read("#{dir_path}/contents").should == "stuff" + File.read("#{dir_path}/paths").should == "foo/bar\n" + end + + it "should leave the paths file alone if the path is already stored" do + checksum = save_bucket_file("stuff", "/foo/bar") + checksum = save_bucket_file("stuff", "/foo/bar") + dir_path = "#{Puppet[:bucketdir]}/c/1/3/d/8/8/c/b/c13d88cb4cb02003daedb8a84e5d272a" + File.read("#{dir_path}/contents").should == "stuff" + File.read("#{dir_path}/paths").should == "foo/bar\n" + end + + it "should store an additional path if the new path differs from those already stored" do + checksum = save_bucket_file("stuff", "/foo/bar") + checksum = save_bucket_file("stuff", "/foo/baz") + dir_path = "#{Puppet[:bucketdir]}/c/1/3/d/8/8/c/b/c13d88cb4cb02003daedb8a84e5d272a" + File.read("#{dir_path}/contents").should == "stuff" + File.read("#{dir_path}/paths").should == "foo/bar\nfoo/baz\n" + end + end + + describe "when not supplying a path" do + it "should save the file and create an empty paths file" do + checksum = save_bucket_file("stuff", "") + dir_path = "#{Puppet[:bucketdir]}/c/1/3/d/8/8/c/b/c13d88cb4cb02003daedb8a84e5d272a" + File.read("#{dir_path}/contents").should == "stuff" + File.read("#{dir_path}/paths").should == "" + end + end + end + + describe "when servicing a head/find request" do + describe "when supplying a path" do + it "should return false/nil if the file isn't bucketed" do + Puppet::FileBucket::File.indirection.head("md5/0ae2ec1980410229885fe72f7b44fe55/foo/bar").should == false + Puppet::FileBucket::File.indirection.find("md5/0ae2ec1980410229885fe72f7b44fe55/foo/bar").should == nil + end + + it "should return false/nil if the file is bucketed but with a different path" do + checksum = save_bucket_file("I'm the contents of a file", '/foo/bar') + Puppet::FileBucket::File.indirection.head("md5/#{checksum}/foo/baz").should == false + Puppet::FileBucket::File.indirection.find("md5/#{checksum}/foo/baz").should == nil + end + + it "should return true/file if the file is already bucketed with the given path" do + contents = "I'm the contents of a file" + checksum = save_bucket_file(contents, '/foo/bar') + Puppet::FileBucket::File.indirection.head("md5/#{checksum}/foo/bar").should == true + find_result = Puppet::FileBucket::File.indirection.find("md5/#{checksum}/foo/bar") + find_result.should be_a(Puppet::FileBucket::File) + find_result.checksum.should == "{md5}#{checksum}" + find_result.to_s.should == contents + end + end + + describe "when not supplying a path" do + [false, true].each do |trailing_slash| + describe "#{trailing_slash ? 'with' : 'without'} a trailing slash" do + trailing_string = trailing_slash ? '/' : '' + + it "should return false/nil if the file isn't bucketed" do + Puppet::FileBucket::File.indirection.head("md5/0ae2ec1980410229885fe72f7b44fe55#{trailing_string}").should == false + Puppet::FileBucket::File.indirection.find("md5/0ae2ec1980410229885fe72f7b44fe55#{trailing_string}").should == nil + end + + it "should return true/file if the file is already bucketed" do + contents = "I'm the contents of a file" + checksum = save_bucket_file(contents, '/foo/bar') + Puppet::FileBucket::File.indirection.head("md5/#{checksum}#{trailing_string}").should == true + find_result = Puppet::FileBucket::File.indirection.find("md5/#{checksum}#{trailing_string}") + find_result.should be_a(Puppet::FileBucket::File) + find_result.checksum.should == "{md5}#{checksum}" + find_result.to_s.should == contents + end + end + end end + end + describe "when diffing files" do it "should generate an empty string if there is no diff" do checksum = save_bucket_file("I'm the contents of a file") Puppet::FileBucket::File.indirection.find("md5/#{checksum}", :diff_with => checksum).should == '' end it "should generate a proper diff if there is a diff" do checksum1 = save_bucket_file("foo\nbar\nbaz") checksum2 = save_bucket_file("foo\nbiz\nbaz") diff = Puppet::FileBucket::File.indirection.find("md5/#{checksum1}", :diff_with => checksum2) diff.should == < biz HERE end it "should raise an exception if the hash to diff against isn't found" do checksum = save_bucket_file("whatever") bogus_checksum = "d1bf072d0e2c6e20e3fbd23f022089a1" lambda { Puppet::FileBucket::File.indirection.find("md5/#{checksum}", :diff_with => bogus_checksum) }.should raise_error "could not find diff_with #{bogus_checksum}" end it "should return nil if the hash to diff from isn't found" do checksum = save_bucket_file("whatever") bogus_checksum = "d1bf072d0e2c6e20e3fbd23f022089a1" Puppet::FileBucket::File.indirection.find("md5/#{bogus_checksum}", :diff_with => checksum).should == nil end end end describe "when initializing" do it "should use the filebucket settings section" do Puppet.settings.expects(:use).with(:filebucket) Puppet::FileBucketFile::File.new end end [true, false].each do |override_bucket_path| describe "when bucket path #{if override_bucket_path then 'is' else 'is not' end} overridden" do [true, false].each do |supply_path| describe "when #{supply_path ? 'supplying' : 'not supplying'} a path" do before :each do Puppet.settings.stubs(:use) @store = Puppet::FileBucketFile::File.new @contents = "my content" @digest = "f2bfa7fc155c4f42cb91404198dda01f" @digest.should == Digest::MD5.hexdigest(@contents) @bucket_dir = tmpdir("bucket") if override_bucket_path Puppet[:bucketdir] = "/bogus/path" # should not be used else Puppet[:bucketdir] = @bucket_dir end @dir = "#{@bucket_dir}/f/2/b/f/a/7/f/c/f2bfa7fc155c4f42cb91404198dda01f" @contents_path = "#{@dir}/contents" end describe "when retrieving files" do before :each do request_options = {} if override_bucket_path request_options[:bucket_path] = @bucket_dir end key = "md5/#{@digest}" if supply_path - key += "//path/to/file" + key += "/path/to/file" end @request = Puppet::Indirector::Request.new(:indirection_name, :find, key, request_options) end def make_bucketed_file FileUtils.mkdir_p(@dir) File.open(@contents_path, 'w') { |f| f.write @contents } end it "should return an instance of Puppet::FileBucket::File created with the content if the file exists" do make_bucketed_file - bucketfile = @store.find(@request) - bucketfile.should be_a(Puppet::FileBucket::File) - bucketfile.contents.should == @contents - @store.head(@request).should == true + if supply_path + @store.find(@request).should == nil + @store.head(@request).should == false # because path didn't match + else + bucketfile = @store.find(@request) + bucketfile.should be_a(Puppet::FileBucket::File) + bucketfile.contents.should == @contents + @store.head(@request).should == true + end end it "should return nil if no file is found" do @store.find(@request).should be_nil @store.head(@request).should == false end end describe "when saving files" do it "should save the contents to the calculated path" do options = {} if override_bucket_path options[:bucket_path] = @bucket_dir end key = "md5/#{@digest}" if supply_path key += "//path/to/file" end file_instance = Puppet::FileBucket::File.new(@contents, options) request = Puppet::Indirector::Request.new(:indirection_name, :save, key, file_instance) @store.save(request) File.read("#{@dir}/contents").should == @contents end end end end end end describe "when verifying identical files" do before do # this is the default from spec_helper, but it keeps getting reset at odd times Puppet[:bucketdir] = "/dev/null/bucket" @digest = "4a8ec4fa5f01b4ab1a0ab8cbccb709f0" @checksum = "{md5}4a8ec4fa5f01b4ab1a0ab8cbccb709f0" @dir = '/dev/null/bucket/4/a/8/e/c/4/f/a/4a8ec4fa5f01b4ab1a0ab8cbccb709f0' @contents = "file contents" @bucket = stub "bucket file" @bucket.stubs(:bucket_path) @bucket.stubs(:checksum).returns(@checksum) @bucket.stubs(:checksum_data).returns(@digest) @bucket.stubs(:path).returns(nil) @bucket.stubs(:contents).returns("file contents") end it "should raise an error if the files don't match" do File.expects(:read).with("#{@dir}/contents").returns("corrupt contents") lambda{ Puppet::FileBucketFile::File.new.send(:verify_identical_file!, @bucket) }.should raise_error(Puppet::FileBucket::BucketError) end it "should do nothing if the files match" do File.expects(:read).with("#{@dir}/contents").returns("file contents") Puppet::FileBucketFile::File.new.send(:verify_identical_file!, @bucket) end end end diff --git a/spec/unit/indirector/queue_spec.rb b/spec/unit/indirector/queue_spec.rb index 7732e411a..49e5e1015 100755 --- a/spec/unit/indirector/queue_spec.rb +++ b/spec/unit/indirector/queue_spec.rb @@ -1,121 +1,123 @@ #!/usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') require 'puppet/indirector/queue' class Puppet::Indirector::Queue::TestClient end class FooExampleData attr_accessor :name def self.pson_create(pson) new(pson['data'].to_sym) end def initialize(name = nil) @name = name if name end def render(format = :pson) to_pson end def to_pson(*args) {:type => self.class.to_s, :data => name}.to_pson(*args) end end describe Puppet::Indirector::Queue, :if => Puppet.features.pson? do before :each do @model = mock 'model' @indirection = stub 'indirection', :name => :my_queue, :register_terminus_type => nil, :model => @model Puppet::Indirector::Indirection.stubs(:instance).with(:my_queue).returns(@indirection) @store_class = Class.new(Puppet::Indirector::Queue) do def self.to_s 'MyQueue::MyType' end end @store = @store_class.new @subject_class = FooExampleData @subject = @subject_class.new @subject.name = :me - Puppet.settings.stubs(:value).returns("bogus setting data") - Puppet.settings.stubs(:value).with(:queue_type).returns(:test_client) + Puppet[:queue_type] = :test_client Puppet::Util::Queue.stubs(:queue_type_to_class).with(:test_client).returns(Puppet::Indirector::Queue::TestClient) @request = stub 'request', :key => :me, :instance => @subject end it "should require PSON" do Puppet.features.expects(:pson?).returns false lambda { @store_class.new }.should raise_error(ArgumentError) end it 'should use the correct client type and queue' do @store.queue.should == :my_queue @store.client.should be_an_instance_of(Puppet::Indirector::Queue::TestClient) end describe "when saving" do it 'should render the instance using pson' do @subject.expects(:render).with(:pson) @store.client.stubs(:send_message) @store.save(@request) end it "should send the rendered message to the appropriate queue on the client" do @subject.expects(:render).returns "mypson" @store.client.expects(:send_message).with(:my_queue, "mypson") @store.save(@request) end it "should catch any exceptions raised" do @store.client.expects(:send_message).raises ArgumentError lambda { @store.save(@request) }.should raise_error(Puppet::Error) end end describe "when subscribing to the queue" do before do @store_class.stubs(:model).returns @model end it "should use the model's Format support to intern the message from pson" do @model.expects(:convert_from).with(:pson, "mymessage") @store_class.client.expects(:subscribe).yields("mymessage") @store_class.subscribe {|o| o } end it "should yield each interned received message" do @model.stubs(:convert_from).returns "something" @subject_two = @subject_class.new @subject_two.name = :too @store_class.client.expects(:subscribe).with(:my_queue).multiple_yields(@subject, @subject_two) received = [] @store_class.subscribe do |obj| received.push(obj) end received.should == %w{something something} end it "should log but not propagate errors" do @store_class.client.expects(:subscribe).yields("foo") - @store_class.expects(:intern).raises ArgumentError - Puppet.expects(:err) - @store_class.subscribe {|o| o } + @store_class.expects(:intern).raises(ArgumentError) + expect { @store_class.subscribe {|o| o } }.should_not raise_error + + @logs.length.should == 1 + @logs.first.message.should =~ /Error occured with subscription to queue my_queue for indirection my_queue: ArgumentError/ + @logs.first.level.should == :err end end end diff --git a/spec/unit/module_spec.rb b/spec/unit/module_spec.rb index 8f1c794b2..54f5444ee 100755 --- a/spec/unit/module_spec.rb +++ b/spec/unit/module_spec.rb @@ -1,545 +1,545 @@ #!/usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe Puppet::Module do before do # This is necessary because of the extra checks we have for the deprecated # 'plugins' directory FileTest.stubs(:exist?).returns false end it "should have a class method that returns a named module from a given environment" do env = mock 'module' env.expects(:module).with("mymod").returns "yep" Puppet::Node::Environment.expects(:new).with("myenv").returns env Puppet::Module.find("mymod", "myenv").should == "yep" end it "should return nil if asked for a named module that doesn't exist" do env = mock 'module' env.expects(:module).with("mymod").returns nil Puppet::Node::Environment.expects(:new).with("myenv").returns env Puppet::Module.find("mymod", "myenv").should be_nil end it "should support a 'version' attribute" do mod = Puppet::Module.new("mymod") mod.version = 1.09 mod.version.should == 1.09 end it "should support a 'source' attribute" do mod = Puppet::Module.new("mymod") mod.source = "http://foo/bar" mod.source.should == "http://foo/bar" end it "should support a 'project_page' attribute" do mod = Puppet::Module.new("mymod") mod.project_page = "http://foo/bar" mod.project_page.should == "http://foo/bar" end it "should support an 'author' attribute" do mod = Puppet::Module.new("mymod") mod.author = "Luke Kanies " mod.author.should == "Luke Kanies " end it "should support a 'license' attribute" do mod = Puppet::Module.new("mymod") mod.license = "GPL2" mod.license.should == "GPL2" end it "should support a 'summary' attribute" do mod = Puppet::Module.new("mymod") mod.summary = "GPL2" mod.summary.should == "GPL2" end it "should support a 'description' attribute" do mod = Puppet::Module.new("mymod") mod.description = "GPL2" mod.description.should == "GPL2" end it "should support specifying a compatible puppet version" do mod = Puppet::Module.new("mymod") mod.puppetversion = "0.25" mod.puppetversion.should == "0.25" end it "should validate that the puppet version is compatible" do mod = Puppet::Module.new("mymod") mod.puppetversion = "0.25" Puppet.expects(:version).returns "0.25" mod.validate_puppet_version end it "should fail if the specified puppet version is not compatible" do mod = Puppet::Module.new("mymod") mod.puppetversion = "0.25" Puppet.stubs(:version).returns "0.24" lambda { mod.validate_puppet_version }.should raise_error(Puppet::Module::IncompatibleModule) end describe "when specifying required modules" do it "should support specifying a required module" do mod = Puppet::Module.new("mymod") mod.requires "foobar" end it "should support specifying multiple required modules" do mod = Puppet::Module.new("mymod") mod.requires "foobar" mod.requires "baz" end it "should support specifying a required module and version" do mod = Puppet::Module.new("mymod") mod.requires "foobar", 1.0 end it "should fail when required modules are missing" do mod = Puppet::Module.new("mymod") mod.requires "foobar" mod.environment.expects(:module).with("foobar").returns nil lambda { mod.validate_dependencies }.should raise_error(Puppet::Module::MissingModule) end it "should fail when required modules are present but of the wrong version" do mod = Puppet::Module.new("mymod") mod.requires "foobar", 1.0 foobar = Puppet::Module.new("foobar") foobar.version = 2.0 mod.environment.expects(:module).with("foobar").returns foobar lambda { mod.validate_dependencies }.should raise_error(Puppet::Module::IncompatibleModule) end it "should have valid dependencies when no dependencies have been specified" do mod = Puppet::Module.new("mymod") lambda { mod.validate_dependencies }.should_not raise_error end it "should fail when some dependencies are present but others aren't" do mod = Puppet::Module.new("mymod") mod.requires "foobar" mod.requires "baz" mod.environment.expects(:module).with("foobar").returns Puppet::Module.new("foobar") mod.environment.expects(:module).with("baz").returns nil lambda { mod.validate_dependencies }.should raise_error(Puppet::Module::MissingModule) end it "should have valid dependencies when all dependencies are met" do mod = Puppet::Module.new("mymod") mod.requires "foobar", 1.0 mod.requires "baz" foobar = Puppet::Module.new("foobar") foobar.version = 1.0 baz = Puppet::Module.new("baz") mod.environment.expects(:module).with("foobar").returns foobar mod.environment.expects(:module).with("baz").returns baz lambda { mod.validate_dependencies }.should_not raise_error end it "should validate its dependendencies on initialization" do Puppet::Module.any_instance.expects(:validate_dependencies) Puppet::Module.new("mymod") end end describe "when managing supported platforms" do it "should support specifying a supported platform" do mod = Puppet::Module.new("mymod") mod.supports "solaris" end it "should support specifying a supported platform and version" do mod = Puppet::Module.new("mymod") mod.supports "solaris", 1.0 end it "should fail when not running on a supported platform" do pending "Not sure how to send client platform to the module" mod = Puppet::Module.new("mymod") Facter.expects(:value).with("operatingsystem").returns "Solaris" mod.supports "hpux" lambda { mod.validate_supported_platform }.should raise_error(Puppet::Module::UnsupportedPlatform) end it "should fail when supported platforms are present but of the wrong version" do pending "Not sure how to send client platform to the module" mod = Puppet::Module.new("mymod") Facter.expects(:value).with("operatingsystem").returns "Solaris" Facter.expects(:value).with("operatingsystemrelease").returns 2.0 mod.supports "Solaris", 1.0 lambda { mod.validate_supported_platform }.should raise_error(Puppet::Module::IncompatiblePlatform) end it "should be considered supported when no supported platforms have been specified" do pending "Not sure how to send client platform to the module" mod = Puppet::Module.new("mymod") lambda { mod.validate_supported_platform }.should_not raise_error end it "should be considered supported when running on a supported platform" do pending "Not sure how to send client platform to the module" mod = Puppet::Module.new("mymod") Facter.expects(:value).with("operatingsystem").returns "Solaris" Facter.expects(:value).with("operatingsystemrelease").returns 2.0 mod.supports "Solaris", 1.0 lambda { mod.validate_supported_platform }.should raise_error(Puppet::Module::IncompatiblePlatform) end it "should be considered supported when running on any of multiple supported platforms" do pending "Not sure how to send client platform to the module" end it "should validate its platform support on initialization" do pending "Not sure how to send client platform to the module" end end it "should return nil if asked for a module whose name is 'nil'" do Puppet::Module.find(nil, "myenv").should be_nil end it "should provide support for logging" do Puppet::Module.ancestors.should be_include(Puppet::Util::Logging) end it "should be able to be converted to a string" do Puppet::Module.new("foo").to_s.should == "Module foo" end it "should add the path to its string form if the module is found" do mod = Puppet::Module.new("foo") mod.stubs(:path).returns "/a" mod.to_s.should == "Module foo(/a)" end it "should fail if its name is not alphanumeric" do lambda { Puppet::Module.new(".something") }.should raise_error(Puppet::Module::InvalidName) end it "should require a name at initialization" do lambda { Puppet::Module.new }.should raise_error(ArgumentError) end it "should convert an environment name into an Environment instance" do Puppet::Module.new("foo", "prod").environment.should be_instance_of(Puppet::Node::Environment) end it "should accept an environment at initialization" do Puppet::Module.new("foo", :prod).environment.name.should == :prod end it "should use the default environment if none is provided" do env = Puppet::Node::Environment.new Puppet::Module.new("foo").environment.should equal(env) end it "should use any provided Environment instance" do env = Puppet::Node::Environment.new Puppet::Module.new("foo", env).environment.should equal(env) end it "should return the path to the first found instance in its environment's module paths as its path" do mod = Puppet::Module.new("foo") env = mock 'environment' mod.stubs(:environment).returns env env.expects(:modulepath).returns %w{/a /b /c} FileTest.expects(:exist?).with("/a/foo").returns false FileTest.expects(:exist?).with("/b/foo").returns true FileTest.expects(:exist?).with("/c/foo").never mod.path.should == "/b/foo" end it "should be considered existent if it exists in at least one module path" do mod = Puppet::Module.new("foo") mod.expects(:path).returns "/a/foo" mod.should be_exist end it "should be considered nonexistent if it does not exist in any of the module paths" do mod = Puppet::Module.new("foo") mod.expects(:path).returns nil mod.should_not be_exist end [:plugins, :templates, :files, :manifests].each do |filetype| dirname = filetype == :plugins ? "lib" : filetype.to_s it "should be able to return individual #{filetype}" do mod = Puppet::Module.new("foo") mod.stubs(:path).returns "/a/foo" path = File.join("/a/foo", dirname, "my/file") FileTest.expects(:exist?).with(path).returns true mod.send(filetype.to_s.sub(/s$/, ''), "my/file").should == path end it "should consider #{filetype} to be present if their base directory exists" do mod = Puppet::Module.new("foo") mod.stubs(:path).returns "/a/foo" path = File.join("/a/foo", dirname) FileTest.expects(:exist?).with(path).returns true mod.send(filetype.to_s + "?").should be_true end it "should consider #{filetype} to be absent if their base directory does not exist" do mod = Puppet::Module.new("foo") mod.stubs(:path).returns "/a/foo" path = File.join("/a/foo", dirname) FileTest.expects(:exist?).with(path).returns false mod.send(filetype.to_s + "?").should be_false end it "should consider #{filetype} to be absent if the module base directory does not exist" do mod = Puppet::Module.new("foo") mod.stubs(:path).returns nil mod.send(filetype.to_s + "?").should be_false end it "should return nil if asked to return individual #{filetype} that don't exist" do mod = Puppet::Module.new("foo") mod.stubs(:path).returns "/a/foo" path = File.join("/a/foo", dirname, "my/file") FileTest.expects(:exist?).with(path).returns false mod.send(filetype.to_s.sub(/s$/, ''), "my/file").should be_nil end it "should return nil when asked for individual #{filetype} if the module does not exist" do mod = Puppet::Module.new("foo") mod.stubs(:path).returns nil mod.send(filetype.to_s.sub(/s$/, ''), "my/file").should be_nil end it "should return the base directory if asked for a nil path" do mod = Puppet::Module.new("foo") mod.stubs(:path).returns "/a/foo" base = File.join("/a/foo", dirname) FileTest.expects(:exist?).with(base).returns true mod.send(filetype.to_s.sub(/s$/, ''), nil).should == base end end %w{plugins files}.each do |filetype| short = filetype.sub(/s$/, '') dirname = filetype == "plugins" ? "lib" : filetype.to_s it "should be able to return the #{short} directory" do Puppet::Module.new("foo").should respond_to(short + "_directory") end it "should return the path to the #{short} directory" do mod = Puppet::Module.new("foo") mod.stubs(:path).returns "/a/foo" mod.send(short + "_directory").should == "/a/foo/#{dirname}" end end it "should throw a warning if plugins are in a 'plugins' directory rather than a 'lib' directory" do mod = Puppet::Module.new("foo") mod.stubs(:path).returns "/a/foo" FileTest.expects(:exist?).with("/a/foo/plugins").returns true - mod.expects(:warning) - mod.plugin_directory.should == "/a/foo/plugins" + @logs.first.message.should == "using the deprecated 'plugins' directory for ruby extensions; please move to 'lib'" + @logs.first.level.should == :warning end it "should default to 'lib' for the plugins directory" do mod = Puppet::Module.new("foo") mod.stubs(:path).returns "/a/foo" mod.plugin_directory.should == "/a/foo/lib" end end describe Puppet::Module, " when building its search path" do it "should use the current environment's search path if no environment is specified" do env = mock 'env' env.expects(:modulepath).returns "eh" Puppet::Node::Environment.expects(:new).with(nil).returns env Puppet::Module.modulepath.should == "eh" end it "should use the specified environment's search path if an environment is specified" do env = mock 'env' env.expects(:modulepath).returns "eh" Puppet::Node::Environment.expects(:new).with("foo").returns env Puppet::Module.modulepath("foo").should == "eh" end end describe Puppet::Module, "when finding matching manifests" do before do @mod = Puppet::Module.new("mymod") @mod.stubs(:path).returns "/a" @pq_glob_with_extension = "yay/*.xx" @fq_glob_with_extension = "/a/manifests/#{@pq_glob_with_extension}" end it "should return all manifests matching the glob pattern" do Dir.expects(:glob).with(@fq_glob_with_extension).returns(%w{foo bar}) FileTest.stubs(:directory?).returns false @mod.match_manifests(@pq_glob_with_extension).should == %w{foo bar} end it "should not return directories" do Dir.expects(:glob).with(@fq_glob_with_extension).returns(%w{foo bar}) FileTest.expects(:directory?).with("foo").returns false FileTest.expects(:directory?).with("bar").returns true @mod.match_manifests(@pq_glob_with_extension).should == %w{foo} end it "should default to the 'init' file if no glob pattern is specified" do Dir.expects(:glob).with("/a/manifests/init.{pp,rb}").returns(%w{/a/manifests/init.pp}) @mod.match_manifests(nil).should == %w{/a/manifests/init.pp} end it "should return all manifests matching the glob pattern in all existing paths" do Dir.expects(:glob).with(@fq_glob_with_extension).returns(%w{a b}) @mod.match_manifests(@pq_glob_with_extension).should == %w{a b} end it "should match the glob pattern plus '.{pp,rb}' if no extention is specified" do Dir.expects(:glob).with("/a/manifests/yay/foo.{pp,rb}").returns(%w{yay}) @mod.match_manifests("yay/foo").should == %w{yay} end it "should return an empty array if no manifests matched" do Dir.expects(:glob).with(@fq_glob_with_extension).returns([]) @mod.match_manifests(@pq_glob_with_extension).should == [] end end describe Puppet::Module do before do Puppet::Module.any_instance.stubs(:path).returns "/my/mod/path" @module = Puppet::Module.new("foo") end it "should use 'License' in its current path as its metadata file" do @module.license_file.should == "/my/mod/path/License" end it "should return nil as its license file when the module has no path" do Puppet::Module.any_instance.stubs(:path).returns nil Puppet::Module.new("foo").license_file.should be_nil end it "should cache the license file" do Puppet::Module.any_instance.expects(:path).once.returns nil mod = Puppet::Module.new("foo") mod.license_file.should == mod.license_file end it "should use 'metadata.json' in its current path as its metadata file" do @module.metadata_file.should == "/my/mod/path/metadata.json" end it "should return nil as its metadata file when the module has no path" do Puppet::Module.any_instance.stubs(:path).returns nil Puppet::Module.new("foo").metadata_file.should be_nil end it "should cache the metadata file" do Puppet::Module.any_instance.expects(:path).once.returns nil mod = Puppet::Module.new("foo") mod.metadata_file.should == mod.metadata_file end it "should know if it has a metadata file" do FileTest.expects(:exist?).with(@module.metadata_file).returns true @module.should be_has_metadata end it "should know if it is missing a metadata file" do FileTest.expects(:exist?).with(@module.metadata_file).returns false @module.should_not be_has_metadata end it "should be able to parse its metadata file" do @module.should respond_to(:load_metadata) end it "should parse its metadata file on initialization if it is present" do Puppet::Module.any_instance.expects(:has_metadata?).returns true Puppet::Module.any_instance.expects(:load_metadata) Puppet::Module.new("yay") end describe "when loading the medatada file", :if => Puppet.features.json? do before do @data = { :license => "GPL2", :author => "luke", :version => "1.0", :source => "http://foo/", :puppetversion => "0.25" } @text = @data.to_json @module = Puppet::Module.new("foo") @module.stubs(:metadata_file).returns "/my/file" File.stubs(:read).with("/my/file").returns @text end %w{source author version license}.each do |attr| it "should set #{attr} if present in the metadata file" do @module.load_metadata @module.send(attr).should == @data[attr.to_sym] end it "should fail if #{attr} is not present in the metadata file" do @data.delete(attr.to_sym) @text = @data.to_json File.stubs(:read).with("/my/file").returns @text lambda { @module.load_metadata }.should raise_error(Puppet::Module::MissingMetadata) end end it "should set puppetversion if present in the metadata file" do @module.load_metadata @module.puppetversion.should == @data[:puppetversion] end it "should fail if the discovered name is different than the metadata name" end end diff --git a/spec/unit/network/handler/fileserver_spec.rb b/spec/unit/network/handler/fileserver_spec.rb index b1306c69e..014b82e69 100644 --- a/spec/unit/network/handler/fileserver_spec.rb +++ b/spec/unit/network/handler/fileserver_spec.rb @@ -1,170 +1,170 @@ #!/usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper') require 'puppet/network/handler/fileserver' describe Puppet::Network::Handler::FileServer do include PuppetSpec::Files def create_file(filename) File.open(filename, "w") { |f| f.puts filename} end def create_nested_file dirname = File.join(@basedir, "nested_dir") Dir.mkdir(dirname) file = File.join(dirname, "nested_dir_file") create_file(file) end before do @basedir = tmpdir("test_network_handler") @file = File.join(@basedir, "aFile") @link = File.join(@basedir, "aLink") create_file(@file) @mount = Puppet::Network::Handler::FileServer::Mount.new("some_path", @basedir) end it "should list a single directory" do @mount.list("/", false, false).should == [["/", "directory"]] end it "should list a file within a directory when given the file path" do @mount.list("/aFile", false, "false").should == [["/", "file"]] end it "should list a file within a directory when given the file path with recursion" do @mount.list("/aFile", true, "false").should == [["/", "file"]] end it "should return nil for a non-existent path" do @mount.list("/no_such_file", false, false).should be(nil) end it "should list a symbolic link as a file when given the link path" do File.symlink(@file, @link) @mount.list("/aLink", false, false).should == [["/", "file"]] end it "should return nil for a dangling symbolic link when given the link path" do File.symlink("/some/where", @link) @mount.list("/aLink", false, false).should be(nil) end it "should list directory contents of a flat directory structure when asked to recurse" do list = @mount.list("/", true, false) list.should include(["/aFile", "file"]) list.should include(["/", "directory"]) list.should have(2).items end it "should list the contents of a nested directory" do create_nested_file list = @mount.list("/", true, false) list.sort.should == [ ["/aFile", "file"], ["/", "directory"] , ["/nested_dir", "directory"], ["/nested_dir/nested_dir_file", "file"]].sort end it "should list the contents of a directory ignoring files that match" do create_nested_file list = @mount.list("/", true, "*File") list.sort.should == [ ["/", "directory"] , ["/nested_dir", "directory"], ["/nested_dir/nested_dir_file", "file"]].sort end it "should list the contents of a directory ignoring directories that match" do create_nested_file list = @mount.list("/", true, "*nested_dir") list.sort.should == [ ["/aFile", "file"], ["/", "directory"] ].sort end it "should list the contents of a directory ignoring all ignore patterns that match" do create_nested_file list = @mount.list("/", true, ["*File" , "*nested_dir"]) list.should == [ ["/", "directory"] ] end it "should list the directory when recursing to a depth of zero" do create_nested_file list = @mount.list("/", 0, false) list.should == [["/", "directory"]] end it "should list the base directory and files and nested directory to a depth of one" do create_nested_file list = @mount.list("/", 1, false) list.sort.should == [ ["/aFile", "file"], ["/nested_dir", "directory"], ["/", "directory"] ].sort end it "should list the base directory and files and nested directory to a depth of two" do create_nested_file list = @mount.list("/", 2, false) list.sort.should == [ ["/aFile", "file"], ["/", "directory"] , ["/nested_dir", "directory"], ["/nested_dir/nested_dir_file", "file"]].sort end it "should list the base directory and files and nested directory to a depth greater than the directory structure" do create_nested_file list = @mount.list("/", 42, false) list.sort.should == [ ["/aFile", "file"], ["/", "directory"] , ["/nested_dir", "directory"], ["/nested_dir/nested_dir_file", "file"]].sort end it "should list a valid symbolic link as a file when recursing base dir" do File.symlink(@file, @link) list = @mount.list("/", true, false) list.sort.should == [ ["/", "directory"], ["/aFile", "file"], ["/aLink", "file"] ].sort end it "should not error when a dangling symlink is present" do File.symlink("/some/where", @link) lambda { @mount.list("/", true, false) }.should_not raise_error end it "should return the directory contents of valid entries when a dangling symlink is present" do File.symlink("/some/where", @link) list = @mount.list("/", true, false) list.sort.should == [ ["/aFile", "file"], ["/", "directory"] ].sort end describe Puppet::Network::Handler::FileServer::PluginMount do PLUGINS = Puppet::Network::Handler::FileServer::PLUGINS # create a module plugin hierarchy def create_plugin(mod, plugin) dirname = File.join(@basedir, mod) Dir.mkdir(dirname) plugins = File.join(dirname, PLUGINS) Dir.mkdir(plugins) facter = File.join(plugins, plugin) Dir.mkdir(facter) create_file(File.join(facter,"fact.rb")) end before :each do @modules = ["one","two"] @modules.each { |m| create_plugin(m, "facter") } Puppet::Node::Environment.new.stubs(:modulepath).returns @basedir @mount = Puppet::Network::Handler::FileServer::PluginMount.new(PLUGINS) @mount.allow("*") end it "should list a file within a directory when given the file path with recursion" do @mount.list("facter/fact.rb", true, "false").should == [["/", "file"], ["/", "file"]] end it "should return a merged view of all plugins for all modules" do list = @mount.list("facter",true,false) list.should == [["/", "directory"], ["/fact.rb", "file"], ["/", "directory"], ["/fact.rb", "file"]] end it "should not fail for inexistant plugins type" do - lambda { @mount.list("puppet/parser",true,false) }.should_not raise_error + @mount.list("puppet/parser",true,false) end end after do FileUtils.rm_rf(@basedir) end end diff --git a/spec/unit/network/http/api/v1_spec.rb b/spec/unit/network/http/api/v1_spec.rb index a1cb75841..25f6d8fe2 100644 --- a/spec/unit/network/http/api/v1_spec.rb +++ b/spec/unit/network/http/api/v1_spec.rb @@ -1,139 +1,167 @@ #!/usr/bin/env ruby Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") } require 'puppet/network/http/api/v1' class V1RestApiTester include Puppet::Network::HTTP::API::V1 end describe Puppet::Network::HTTP::API::V1 do before do @tester = V1RestApiTester.new end it "should be able to convert a URI into a request" do @tester.should respond_to(:uri2indirection) end it "should be able to convert a request into a URI" do @tester.should respond_to(:indirection2uri) end describe "when converting a URI into a request" do before do @tester.stubs(:handler).returns "foo" end it "should require the http method, the URI, and the query parameters" do # Not a terribly useful test, but an important statement for the spec lambda { @tester.uri2indirection("/foo") }.should raise_error(ArgumentError) end it "should use the first field of the URI as the environment" do @tester.uri2indirection("GET", "/env/foo/bar", {})[3][:environment].should == "env" end it "should fail if the environment is not alphanumeric" do lambda { @tester.uri2indirection("GET", "/env ness/foo/bar", {}) }.should raise_error(ArgumentError) end it "should use the environment from the URI even if one is specified in the parameters" do @tester.uri2indirection("GET", "/env/foo/bar", {:environment => "otherenv"})[3][:environment].should == "env" end it "should use the second field of the URI as the indirection name" do @tester.uri2indirection("GET", "/env/foo/bar", {})[0].should == "foo" end it "should fail if the indirection name is not alphanumeric" do lambda { @tester.uri2indirection("GET", "/env/foo ness/bar", {}) }.should raise_error(ArgumentError) end it "should use the remainder of the URI as the indirection key" do @tester.uri2indirection("GET", "/env/foo/bar", {})[2].should == "bar" end it "should support the indirection key being a /-separated file path" do @tester.uri2indirection("GET", "/env/foo/bee/baz/bomb", {})[2].should == "bee/baz/bomb" end it "should fail if no indirection key is specified" do lambda { @tester.uri2indirection("GET", "/env/foo/", {}) }.should raise_error(ArgumentError) lambda { @tester.uri2indirection("GET", "/env/foo", {}) }.should raise_error(ArgumentError) end it "should choose 'find' as the indirection method if the http method is a GET and the indirection name is singular" do @tester.uri2indirection("GET", "/env/foo/bar", {})[1].should == :find end it "should choose 'head' as the indirection method if the http method is a HEAD and the indirection name is singular" do @tester.uri2indirection("HEAD", "/env/foo/bar", {})[1].should == :head end it "should choose 'search' as the indirection method if the http method is a GET and the indirection name is plural" do @tester.uri2indirection("GET", "/env/foos/bar", {})[1].should == :search end it "should choose 'find' as the indirection method if the http method is a GET and the indirection name is facts" do @tester.uri2indirection("GET", "/env/facts/bar", {})[1].should == :find end it "should choose 'save' as the indirection method if the http method is a PUT and the indirection name is facts" do @tester.uri2indirection("PUT", "/env/facts/bar", {})[1].should == :save end it "should choose 'search' as the indirection method if the http method is a GET and the indirection name is inventory" do @tester.uri2indirection("GET", "/env/inventory/search", {})[1].should == :search end + it "should choose 'find' as the indirection method if the http method is a GET and the indirection name is facts" do + @tester.uri2indirection("GET", "/env/facts/bar", {})[1].should == :find + end + + it "should choose 'save' as the indirection method if the http method is a PUT and the indirection name is facts" do + @tester.uri2indirection("PUT", "/env/facts/bar", {})[1].should == :save + end + + it "should choose 'search' as the indirection method if the http method is a GET and the indirection name is inventory" do + @tester.uri2indirection("GET", "/env/inventory/search", {})[1].should == :search + end + + it "should choose 'search' as the indirection method if the http method is a GET and the indirection name is facts_search" do + @tester.uri2indirection("GET", "/env/facts_search/bar", {})[1].should == :search + end + + it "should change indirection name to 'facts' if the http method is a GET and the indirection name is facts_search" do + @tester.uri2indirection("GET", "/env/facts_search/bar", {})[0].should == 'facts' + end + + it "should not change indirection name from 'facts' if the http method is a GET and the indirection name is facts" do + @tester.uri2indirection("GET", "/env/facts/bar", {})[0].should == 'facts' + end + + it "should change indirection name to 'status' if the http method is a GET and the indirection name is statuses" do + @tester.uri2indirection("GET", "/env/statuses/bar", {})[0].should == 'status' + end + it "should choose 'delete' as the indirection method if the http method is a DELETE and the indirection name is singular" do @tester.uri2indirection("DELETE", "/env/foo/bar", {})[1].should == :destroy end it "should choose 'save' as the indirection method if the http method is a PUT and the indirection name is singular" do @tester.uri2indirection("PUT", "/env/foo/bar", {})[1].should == :save end it "should fail if an indirection method cannot be picked" do lambda { @tester.uri2indirection("UPDATE", "/env/foo/bar", {}) }.should raise_error(ArgumentError) end it "should URI unescape the indirection key" do escaped = URI.escape("foo bar") indirection_name, method, key, params = @tester.uri2indirection("GET", "/env/foo/#{escaped}", {}) key.should == "foo bar" end end describe "when converting a request into a URI" do before do @request = Puppet::Indirector::Request.new(:foo, :find, "with spaces", :foo => :bar, :environment => "myenv") end it "should use the environment as the first field of the URI" do @tester.indirection2uri(@request).split("/")[1].should == "myenv" end it "should use the indirection as the second field of the URI" do @tester.indirection2uri(@request).split("/")[2].should == "foo" end it "should pluralize the indirection name if the method is 'search'" do @request.stubs(:method).returns :search @tester.indirection2uri(@request).split("/")[2].should == "foos" end it "should use the escaped key as the remainder of the URI" do escaped = URI.escape("with spaces") @tester.indirection2uri(@request).split("/")[3].sub(/\?.+/, '').should == escaped end it "should add the query string to the URI" do @request.expects(:query_string).returns "?query" @tester.indirection2uri(@request).should =~ /\?query$/ end end end diff --git a/spec/unit/network/http/compression_spec.rb b/spec/unit/network/http/compression_spec.rb old mode 100644 new mode 100755 index d44c5f1bb..85c62f358 --- a/spec/unit/network/http/compression_spec.rb +++ b/spec/unit/network/http/compression_spec.rb @@ -1,197 +1,197 @@ #!/usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper') describe "http compression" do describe "when zlib is not available" do before(:each) do Puppet.features.stubs(:zlib?).returns false require 'puppet/network/http/compression' class HttpUncompressor include Puppet::Network::HTTP::Compression::None end @uncompressor = HttpUncompressor.new end it "should have a module function that returns the None underlying module" do Puppet::Network::HTTP::Compression.module.should == Puppet::Network::HTTP::Compression::None end it "should not add any Accept-Encoding header" do @uncompressor.add_accept_encoding({}).should == {} end it "should not tamper the body" do response = stub 'response', :body => "data" @uncompressor.uncompress_body(response).should == "data" end it "should yield an identity uncompressor" do response = stub 'response' @uncompressor.uncompress(response) { |u| u.should be_instance_of(Puppet::Network::HTTP::Compression::IdentityAdapter) } end end describe "when zlib is available", :if => Puppet.features.zlib? do before(:each) do Puppet.features.stubs(:zlib?).returns true require 'puppet/network/http/compression' class HttpUncompressor include Puppet::Network::HTTP::Compression::Active end @uncompressor = HttpUncompressor.new end it "should have a module function that returns the Active underlying module" do Puppet::Network::HTTP::Compression.module.should == Puppet::Network::HTTP::Compression::Active end it "should add an Accept-Encoding header when http compression is available" do Puppet.settings.expects(:[]).with(:http_compression).returns(true) headers = @uncompressor.add_accept_encoding({}) headers.should have_key('accept-encoding') headers['accept-encoding'].should =~ /gzip/ headers['accept-encoding'].should =~ /deflate/ headers['accept-encoding'].should =~ /identity/ end it "should not add Accept-Encoding header if http compression is not available" do Puppet.settings.stubs(:[]).with(:http_compression).returns(false) @uncompressor.add_accept_encoding({}).should == {} end describe "when uncompressing response body" do before do @response = stub 'response' @response.stubs(:[]).with('content-encoding') @response.stubs(:body).returns("mydata") end it "should return untransformed response body with no content-encoding" do @uncompressor.uncompress_body(@response).should == "mydata" end it "should return untransformed response body with 'identity' content-encoding" do @response.stubs(:[]).with('content-encoding').returns('identity') @uncompressor.uncompress_body(@response).should == "mydata" end it "should use a Zlib inflater with 'deflate' content-encoding" do @response.stubs(:[]).with('content-encoding').returns('deflate') inflater = stub 'inflater' Zlib::Inflate.expects(:new).returns(inflater) inflater.expects(:inflate).with("mydata").returns "uncompresseddata" @uncompressor.uncompress_body(@response).should == "uncompresseddata" end it "should use a GzipReader with 'gzip' content-encoding" do @response.stubs(:[]).with('content-encoding').returns('gzip') io = stub 'io' StringIO.expects(:new).with("mydata").returns io reader = stub 'gzip reader' Zlib::GzipReader.expects(:new).with(io).returns(reader) reader.expects(:read).returns "uncompresseddata" @uncompressor.uncompress_body(@response).should == "uncompresseddata" end end describe "when uncompressing by chunk" do before do @response = stub 'response' @response.stubs(:[]).with('content-encoding') @inflater = stub_everything 'inflater' Zlib::Inflate.stubs(:new).returns(@inflater) end it "should yield an identity uncompressor with no content-encoding" do @uncompressor.uncompress(@response) { |u| u.should be_instance_of(Puppet::Network::HTTP::Compression::IdentityAdapter) } end it "should yield an identity uncompressor with 'identity' content-encoding" do @response.stubs(:[]).with('content-encoding').returns 'identity' @uncompressor.uncompress(@response) { |u| u.should be_instance_of(Puppet::Network::HTTP::Compression::IdentityAdapter) } end %w{gzip deflate}.each do |c| it "should yield a Zlib uncompressor with '#{c}' content-encoding" do @response.stubs(:[]).with('content-encoding').returns c @uncompressor.uncompress(@response) { |u| u.should be_instance_of(Puppet::Network::HTTP::Compression::Active::ZlibAdapter) } end end it "should close the underlying adapter" do adapter = stub_everything 'adapter' Puppet::Network::HTTP::Compression::IdentityAdapter.expects(:new).returns(adapter) adapter.expects(:close) @uncompressor.uncompress(@response) { |u| } end end describe "zlib adapter" do before do @inflater = stub_everything 'inflater' Zlib::Inflate.stubs(:new).returns(@inflater) @adapter = Puppet::Network::HTTP::Compression::Active::ZlibAdapter.new end it "should initialize the underlying inflater with gzip/zlib header parsing" do Zlib::Inflate.expects(:new).with(15+32) Puppet::Network::HTTP::Compression::Active::ZlibAdapter.new end it "should inflate the given chunk" do @inflater.expects(:inflate).with("chunk") @adapter.uncompress("chunk") end it "should return the inflated chunk" do @inflater.stubs(:inflate).with("chunk").returns("uncompressed") @adapter.uncompress("chunk").should == "uncompressed" end it "should try a 'regular' inflater on Zlib::DataError" do @inflater.expects(:inflate).raises(Zlib::DataError.new("not a zlib stream")) inflater = stub_everything 'inflater2' inflater.expects(:inflate).with("chunk").returns("uncompressed") Zlib::Inflate.expects(:new).with.returns(inflater) @adapter.uncompress("chunk") end it "should raise the error the second time" do - @inflater.expects(:inflate).raises(Zlib::DataError.new("not a zlib stream")) + @inflater.stubs(:inflate).raises(Zlib::DataError.new("not a zlib stream")) Zlib::Inflate.expects(:new).with.returns(@inflater) lambda { @adapter.uncompress("chunk") }.should raise_error end it "should finish the stream on close" do @inflater.expects(:finish) @adapter.close end it "should close the stream on close" do @inflater.expects(:close) @adapter.close end end end end diff --git a/spec/unit/parser/ast/collection_spec.rb b/spec/unit/parser/ast/collection_spec.rb index a495bca15..99abc998d 100755 --- a/spec/unit/parser/ast/collection_spec.rb +++ b/spec/unit/parser/ast/collection_spec.rb @@ -1,67 +1,71 @@ #!/usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper') describe Puppet::Parser::AST::Collection do before :each do - @scope = stub_everything 'scope' - @mytype = stub_everything('mytype') - @scope.stubs(:find_resource_type).returns @mytype - @compiler = stub_everything 'compile' - @scope.stubs(:compiler).returns(@compiler) + @mytype = Puppet::Resource::Type.new(:definition, "mytype") + @environment = Puppet::Node::Environment.new + @environment.known_resource_types.add @mytype + + @compiler = Puppet::Parser::Compiler.new(Puppet::Node.new("foonode", :environment => @environment)) + @scope = Puppet::Parser::Scope.new(:compiler => @compiler) @overrides = stub_everything 'overrides' @overrides.stubs(:is_a?).with(Puppet::Parser::AST).returns(true) - end it "should evaluate its query" do query = mock 'query' collection = Puppet::Parser::AST::Collection.new :query => query, :form => :virtual + collection.type = 'mytype' query.expects(:safeevaluate).with(@scope) collection.evaluate(@scope) end it "should instantiate a Collector for this type" do collection = Puppet::Parser::AST::Collection.new :form => :virtual, :type => "test" - @test_type = stub 'type', :name => 'test' - @scope.expects(:find_resource_type).with('test').returns @test_type + @test_type = Puppet::Resource::Type.new(:definition, "test") + @environment.known_resource_types.add @test_type Puppet::Parser::Collector.expects(:new).with(@scope, "test", nil, nil, :virtual) collection.evaluate(@scope) end it "should tell the compiler about this collector" do - collection = Puppet::Parser::AST::Collection.new :form => :virtual, :type => "test" + collection = Puppet::Parser::AST::Collection.new :form => :virtual, :type => "mytype" Puppet::Parser::Collector.stubs(:new).returns("whatever") @compiler.expects(:add_collection).with("whatever") collection.evaluate(@scope) end it "should evaluate overriden paramaters" do collector = stub_everything 'collector' - collection = Puppet::Parser::AST::Collection.new :form => :virtual, :type => "test", :override => @overrides + collection = Puppet::Parser::AST::Collection.new :form => :virtual, :type => "mytype", :override => @overrides Puppet::Parser::Collector.stubs(:new).returns(collector) @overrides.expects(:safeevaluate).with(@scope) collection.evaluate(@scope) end it "should tell the collector about overrides" do collector = mock 'collector' - collection = Puppet::Parser::AST::Collection.new :form => :virtual, :type => "test", :override => @overrides + collection = Puppet::Parser::AST::Collection.new :form => :virtual, :type => "mytype", :override => @overrides Puppet::Parser::Collector.stubs(:new).returns(collector) collector.expects(:add_override) collection.evaluate(@scope) end - + it "should fail when evaluating undefined resource types" do + collection = Puppet::Parser::AST::Collection.new :form => :virtual, :type => "bogus" + lambda { collection.evaluate(@scope) }.should raise_error "Resource type bogus doesn't exist" + end end diff --git a/spec/unit/parser/functions/defined_spec.rb b/spec/unit/parser/functions/defined_spec.rb index 0dd1dadb8..0113c3233 100755 --- a/spec/unit/parser/functions/defined_spec.rb +++ b/spec/unit/parser/functions/defined_spec.rb @@ -1,50 +1,53 @@ #!/usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper') describe "the 'defined' function" do + before :all do + Puppet::Parser::Functions.autoloader.loadall + end before :each do Puppet::Node::Environment.stubs(:current).returns(nil) @compiler = Puppet::Parser::Compiler.new(Puppet::Node.new("foo")) @scope = Puppet::Parser::Scope.new(:compiler => @compiler) end it "should exist" do Puppet::Parser::Functions.function("defined").should == "function_defined" end it "should be true when the name is defined as a class" do @scope.known_resource_types.add Puppet::Resource::Type.new(:hostclass, "yayness") @scope.function_defined("yayness").should be_true end it "should be true when the name is defined as a definition" do @scope.known_resource_types.add Puppet::Resource::Type.new(:definition, "yayness") @scope.function_defined("yayness").should be_true end it "should be true when the name is defined as a builtin type" do @scope.function_defined("file").should be_true end it "should be true when any of the provided names are defined" do @scope.known_resource_types.add Puppet::Resource::Type.new(:definition, "yayness") @scope.function_defined(["meh", "yayness", "booness"]).should be_true end it "should be false when a single given name is not defined" do @scope.function_defined("meh").should be_false end it "should be false when none of the names are defined" do @scope.function_defined(["meh", "yayness", "booness"]).should be_false end it "should be true when a resource reference is provided and the resource is in the catalog" do resource = Puppet::Resource.new("file", "/my/file") @compiler.add_resource(@scope, resource) @scope.function_defined(resource).should be_true end end diff --git a/spec/unit/parser/functions/extlookup_spec.rb b/spec/unit/parser/functions/extlookup_spec.rb index a476dc844..46cd3cc27 100755 --- a/spec/unit/parser/functions/extlookup_spec.rb +++ b/spec/unit/parser/functions/extlookup_spec.rb @@ -1,95 +1,96 @@ #! /usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper') require 'tempfile' describe "the extlookup function" do + before :all do + Puppet::Parser::Functions.autoloader.loadall + end before :each do @scope = Puppet::Parser::Scope.new - @scope.stubs(:environment).returns(Puppet::Node::Environment.new('production')) - Puppet::Parser::Functions.function("extlookup") end it "should exist" do Puppet::Parser::Functions.function("extlookup").should == "function_extlookup" end it "should raise a ParseError if there is less than 1 arguments" do lambda { @scope.function_extlookup([]) }.should( raise_error(Puppet::ParseError)) end it "should raise a ParseError if there is more than 3 arguments" do lambda { @scope.function_extlookup(["foo", "bar", "baz", "gazonk"]) }.should( raise_error(Puppet::ParseError)) end it "should return the default" do result = @scope.function_extlookup([ "key", "default"]) result.should == "default" end it "should lookup the key in a supplied datafile" do t = Tempfile.new('extlookup.csv') do t.puts 'key,value' t.puts 'nonkey,nonvalue' t.close result = @scope.function_extlookup([ "key", "default", t.path]) result.should == "value" end end it "should return an array if the datafile contains more than two columns" do t = Tempfile.new('extlookup.csv') do t.puts 'key,value1,value2' t.puts 'nonkey,nonvalue,nonvalue' t.close result = @scope.function_extlookup([ "key", "default", t.path]) result.should == ["value1", "value2"] end end it "should raise an error if there's no matching key and no default" do t = Tempfile.new('extlookup.csv') do t.puts 'key,value' t.puts 'nonkey,nonvalue' t.close result = @scope.function_extlookup([ "key", nil, t.path]) result.should == "value" end end describe "should look in $extlookup_datadir for data files listed by $extlookup_precedence" do before do @scope.stubs(:lookupvar).with('extlookup_datadir').returns("/tmp") File.open("/tmp/one.csv","w"){|one| one.puts "key,value1" } File.open("/tmp/two.csv","w") do |two| two.puts "key,value2" two.puts "key2,value_two" end end it "when the key is in the first file" do @scope.stubs(:lookupvar).with('extlookup_precedence').returns(["one","two"]) result = @scope.function_extlookup([ "key" ]) result.should == "value1" end it "when the key is in the second file" do @scope.stubs(:lookupvar).with('extlookup_precedence').returns(["one","two"]) result = @scope.function_extlookup([ "key2" ]) result.should == "value_two" end it "should not modify extlookup_precedence data" do variable = '%{fqdn}' @scope.stubs(:lookupvar).with('extlookup_precedence').returns([variable,"one"]) @scope.stubs(:lookupvar).with('fqdn').returns('myfqdn') result = @scope.function_extlookup([ "key" ]) variable.should == '%{fqdn}' end end end diff --git a/spec/unit/parser/functions/fqdn_rand_spec.rb b/spec/unit/parser/functions/fqdn_rand_spec.rb old mode 100644 new mode 100755 index 151ebac9a..be2e6fa76 --- a/spec/unit/parser/functions/fqdn_rand_spec.rb +++ b/spec/unit/parser/functions/fqdn_rand_spec.rb @@ -1,62 +1,65 @@ #! /usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper') describe "the fqdn_rand function" do + before :all do + Puppet::Parser::Functions.autoloader.loadall + end before :each do @scope = Puppet::Parser::Scope.new end it "should exist" do Puppet::Parser::Functions.function("fqdn_rand").should == "function_fqdn_rand" end it "should handle 0 arguments" do @scope.expects(:lookupvar).with("fqdn").returns("127.0.0.1") lambda { @scope.function_fqdn_rand([]) }.should_not raise_error(Puppet::ParseError) end it "should handle 1 argument'}" do @scope.expects(:lookupvar).with("fqdn").returns("127.0.0.1") lambda { @scope.function_fqdn_rand([3]) }.should_not raise_error(Puppet::ParseError) end (1..10).each { |n| it "should handle #{n} additional arguments" do @scope.expects(:lookupvar).with("fqdn").returns("127.0.0.1") lambda { @scope.function_fqdn_rand([3,1,2,3,4,5,6,7,8,9,10][0..n]) }.should_not raise_error(Puppet::ParseError) end it "should handle #{n} additional string arguments" do @scope.expects(:lookupvar).with("fqdn").returns("127.0.0.1") lambda { @scope.function_fqdn_rand([3,%w{ 1 2 3 4 5 6 7 8 9 10}].flatten[0..n]) }.should_not raise_error(Puppet::ParseError) end } it "should return a value less than max" do @scope.expects(:lookupvar).with("fqdn").returns("127.0.0.1") @scope.function_fqdn_rand([3]).should satisfy {|n| n.to_i < 3 } end it "should return the same values on subsequent invocations for the same host" do @scope.expects(:lookupvar).with("fqdn").returns("127.0.0.1").twice @scope.function_fqdn_rand([3,4]).should eql(@scope.function_fqdn_rand([3, 4])) end it "should return different sequences of value for different hosts" do @scope.expects(:lookupvar).with("fqdn").returns("127.0.0.1") val1 = @scope.function_fqdn_rand([10000000,4]) @scope.expects(:lookupvar).with("fqdn").returns("127.0.0.2") val2 = @scope.function_fqdn_rand([10000000,4]) val1.should_not eql(val2) end it "should return different values for the same hosts with different seeds" do @scope.expects(:lookupvar).with("fqdn").returns("127.0.0.1") val1 = @scope.function_fqdn_rand([10000000,4]) @scope.expects(:lookupvar).with("fqdn").returns("127.0.0.1") val2 = @scope.function_fqdn_rand([10000000,42]) val1.should_not eql(val2) end end diff --git a/spec/unit/parser/functions/generate_spec.rb b/spec/unit/parser/functions/generate_spec.rb index 12f454210..d25015b56 100755 --- a/spec/unit/parser/functions/generate_spec.rb +++ b/spec/unit/parser/functions/generate_spec.rb @@ -1,41 +1,44 @@ #! /usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper') describe "the generate function" do + before :all do + Puppet::Parser::Functions.autoloader.loadall + end before :each do @scope = Puppet::Parser::Scope.new end it "should exist" do Puppet::Parser::Functions.function("generate").should == "function_generate" end it "should accept a fully-qualified path as a command" do command = File::SEPARATOR + "command" Puppet::Util.expects(:execute).with([command]).returns("yay") lambda { @scope.function_generate([command]) }.should_not raise_error(Puppet::ParseError) end it "should not accept a relative path as a command" do command = "command" lambda { @scope.function_generate([command]) }.should raise_error(Puppet::ParseError) end # Really not sure how to implement this test, just sure it needs # to be implemented. it "should not accept a command containing illegal characters" it "should not accept a command containing '..'" do command = File::SEPARATOR + "command#{File::SEPARATOR}..#{File::SEPARATOR}" lambda { @scope.function_generate([command]) }.should raise_error(Puppet::ParseError) end it "should execute the generate script with the correct working directory" do command = File::SEPARATOR + "command" Dir.expects(:chdir).with(File.dirname(command)).yields Puppet::Util.expects(:execute).with([command]).returns("yay") lambda { @scope.function_generate([command]) }.should_not raise_error(Puppet::ParseError) end end diff --git a/spec/unit/parser/functions/include_spec.rb b/spec/unit/parser/functions/include_spec.rb old mode 100644 new mode 100755 index 67227e7d9..cfaadfbb6 --- a/spec/unit/parser/functions/include_spec.rb +++ b/spec/unit/parser/functions/include_spec.rb @@ -1,33 +1,36 @@ #!/usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper') describe "the 'include' function" do + before :all do + Puppet::Parser::Functions.autoloader.loadall + end before :each do Puppet::Node::Environment.stubs(:current).returns(nil) @compiler = Puppet::Parser::Compiler.new(Puppet::Node.new("foo")) @scope = Puppet::Parser::Scope.new(:compiler => @compiler) end it "should exist" do Puppet::Parser::Functions.function("include").should == "function_include" end it "should include a single class" do inc = "foo" @compiler.expects(:evaluate_classes).with {|klasses,parser,lazy| klasses == [inc]}.returns([inc]) @scope.function_include("foo") end it "should include multiple classes" do inc = ["foo","bar"] @compiler.expects(:evaluate_classes).with {|klasses,parser,lazy| klasses == inc}.returns(inc) @scope.function_include(["foo","bar"]) end it "should not lazily evaluate the included class" do @compiler.expects(:evaluate_classes).with {|klasses,parser,lazy| lazy == false}.returns("foo") @scope.function_include("foo") end end diff --git a/spec/unit/parser/functions/inline_template_spec.rb b/spec/unit/parser/functions/inline_template_spec.rb index 36d53778d..712c68c69 100755 --- a/spec/unit/parser/functions/inline_template_spec.rb +++ b/spec/unit/parser/functions/inline_template_spec.rb @@ -1,59 +1,62 @@ #!/usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper') describe "the inline_template function" do + before :all do + Puppet::Parser::Functions.autoloader.loadall + end before :each do @scope = Puppet::Parser::Scope.new end it "should exist" do Puppet::Parser::Functions.function("inline_template").should == "function_inline_template" end it "should create a TemplateWrapper when called" do tw = stub_everything 'template_wrapper' Puppet::Parser::TemplateWrapper.expects(:new).returns(tw) @scope.function_inline_template("test") end it "should pass the template string to TemplateWrapper.result" do tw = stub_everything 'template_wrapper' Puppet::Parser::TemplateWrapper.stubs(:new).returns(tw) tw.expects(:result).with("test") @scope.function_inline_template("test") end it "should return what TemplateWrapper.result returns" do tw = stub_everything 'template_wrapper' Puppet::Parser::TemplateWrapper.stubs(:new).returns(tw) tw.expects(:result).returns("template contents evaluated") @scope.function_inline_template("test").should == "template contents evaluated" end it "should concatenate template wrapper outputs for multiple templates" do tw1 = stub_everything "template_wrapper1" tw2 = stub_everything "template_wrapper2" Puppet::Parser::TemplateWrapper.stubs(:new).returns(tw1,tw2) tw1.stubs(:result).returns("result1") tw2.stubs(:result).returns("result2") @scope.function_inline_template(["1","2"]).should == "result1result2" end it "should raise an error if the template raises an error" do tw = stub_everything 'template_wrapper' Puppet::Parser::TemplateWrapper.stubs(:new).returns(tw) tw.stubs(:result).raises lambda { @scope.function_inline_template("1") }.should raise_error(Puppet::ParseError) end -end \ No newline at end of file +end diff --git a/spec/unit/parser/functions/realize_spec.rb b/spec/unit/parser/functions/realize_spec.rb index 899f69b01..3106c42b6 100755 --- a/spec/unit/parser/functions/realize_spec.rb +++ b/spec/unit/parser/functions/realize_spec.rb @@ -1,51 +1,54 @@ #!/usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper') describe "the realize function" do + before :all do + Puppet::Parser::Functions.autoloader.loadall + end before :each do @collector = stub_everything 'collector' @scope = Puppet::Parser::Scope.new @compiler = stub 'compiler' @compiler.stubs(:add_collection).with(@collector) @scope.stubs(:compiler).returns(@compiler) end it "should exist" do Puppet::Parser::Functions.function("realize").should == "function_realize" end it "should create a Collector when called" do Puppet::Parser::Collector.expects(:new).returns(@collector) @scope.function_realize("test") end it "should assign the passed-in resources to the collector" do Puppet::Parser::Collector.stubs(:new).returns(@collector) @collector.expects(:resources=).with(["test"]) @scope.function_realize("test") end it "should flatten the resources assigned to the collector" do Puppet::Parser::Collector.stubs(:new).returns(@collector) @collector.expects(:resources=).with(["test"]) @scope.function_realize([["test"]]) end it "should let the compiler know this collector" do Puppet::Parser::Collector.stubs(:new).returns(@collector) @collector.stubs(:resources=).with(["test"]) @compiler.expects(:add_collection).with(@collector) @scope.function_realize("test") end end diff --git a/spec/unit/parser/functions/regsubst_spec.rb b/spec/unit/parser/functions/regsubst_spec.rb index 09aa92d28..1fb8e410c 100755 --- a/spec/unit/parser/functions/regsubst_spec.rb +++ b/spec/unit/parser/functions/regsubst_spec.rb @@ -1,192 +1,195 @@ #! /usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper') describe "the regsubst function" do + before :all do + Puppet::Parser::Functions.autoloader.loadall + end before :each do @scope = Puppet::Parser::Scope.new end it "should exist" do Puppet::Parser::Functions.function("regsubst").should == "function_regsubst" end it "should raise a ParseError if there is less than 3 arguments" do lambda { @scope.function_regsubst(["foo", "bar"]) }.should( raise_error(Puppet::ParseError)) end it "should raise a ParseError if there is more than 5 arguments" do lambda { @scope.function_regsubst(["foo", "bar", "gazonk", "del", "x", "y"]) }.should( raise_error(Puppet::ParseError)) end it "should raise a ParseError when given a bad flag" do lambda { @scope.function_regsubst(["foo", "bar", "gazonk", "X"]) }.should( raise_error(Puppet::ParseError)) end it "should raise a ParseError for non-string and non-array target" do lambda { @scope.function_regsubst([4711, "bar", "gazonk"]) }.should( raise_error(Puppet::ParseError)) end it "should raise a ParseError for array target with non-string element" do lambda { @scope.function_regsubst([["x", ["y"], "z"], "bar", "gazonk"]) }.should( raise_error(Puppet::ParseError)) end it "should raise a ParseError for a bad regular expression" do lambda { @scope.function_regsubst(["foo", "(bar", "gazonk"]) }.should( raise_error(Puppet::ParseError)) end it "should raise a ParseError for a non-string regular expression" do lambda { @scope.function_regsubst(["foo", ["bar"], "gazonk"]) }.should( raise_error(Puppet::ParseError)) end it "should handle groups" do result = @scope.function_regsubst( [ '130.236.254.10', '^([0-9]+)[.]([0-9]+)[.]([0-9]+)[.]([0-9]+)$', '\4-\3-\2-\1' ]) result.should(eql("10-254-236-130")) end it "should handle simple regexps" do result = @scope.function_regsubst( [ "the monkey breaks banana trees", "b[an]*a", "coconut" ]) result.should(eql("the monkey breaks coconut trees")) end it "should handle case-sensitive regexps" do result = @scope.function_regsubst( [ "the monkey breaks baNAna trees", "b[an]+a", "coconut" ]) result.should(eql("the monkey breaks baNAna trees")) end it "should handle case-insensitive regexps" do result = @scope.function_regsubst( [ "the monkey breaks baNAna trees", "b[an]+a", "coconut", "I" ]) result.should(eql("the monkey breaks coconut trees")) end it "should handle global substitutions" do result = @scope.function_regsubst( [ "the monkey breaks\tbanana trees", "[ \t]", "--", "G" ]) result.should(eql("the--monkey--breaks--banana--trees")) end it "should handle global substitutions with groups" do result = @scope.function_regsubst( [ '130.236.254.10', '([0-9]+)', '<\1>', 'G' ]) result.should(eql('<130>.<236>.<254>.<10>')) end it "should apply on all elements of an array" do data = ['130.236.254.10', 'foo.example.com', 'coconut', '10.20.30.40'] result = @scope.function_regsubst([ data, '[.]', '-']) result.should(eql( ['130-236.254.10', 'foo-example.com', 'coconut', '10-20.30.40'])) end it "should apply global substitutions on all elements of an array" do data = ['130.236.254.10', 'foo.example.com', 'coconut', '10.20.30.40'] result = @scope.function_regsubst([ data, '[.]', '-', 'G']) result.should(eql( ['130-236-254-10', 'foo-example-com', 'coconut', '10-20-30-40'])) end it "should handle groups on all elements of an array" do data = ['130.236.254.10', 'foo.example.com', 'coconut', '10.20.30.40'] result = @scope.function_regsubst( [ data, '^([0-9]+)[.]([0-9]+)[.]([0-9]+)[.]([0-9]+)$', '\4-\3-\2-\1' ]) result.should(eql( ['10-254-236-130', 'foo.example.com', 'coconut', '40-30-20-10'])) end it "should handle global substitutions with groups on all elements of an array" do data = ['130.236.254.10', 'foo.example.com', 'coconut', '10.20.30.40'] result = @scope.function_regsubst( [ data, '([^.]+)', '<\1>', 'G' ]) result.should(eql( ['<130>.<236>.<254>.<10>', '..', '', '<10>.<20>.<30>.<40>'])) end it "should return an array (not a string) for a single element array parameter" do data = ['130.236.254.10'] result = @scope.function_regsubst( [ data, '([^.]+)', '<\1>', 'G' ]) result.should(eql(['<130>.<236>.<254>.<10>'])) end it "should return a string (not a one element array) for a simple string parameter" do data = '130.236.254.10' result = @scope.function_regsubst( [ data, '([^.]+)', '<\1>', 'G' ]) result.should(eql('<130>.<236>.<254>.<10>')) end end diff --git a/spec/unit/parser/functions/require_spec.rb b/spec/unit/parser/functions/require_spec.rb index 4afbd5a63..edcbc4ae6 100755 --- a/spec/unit/parser/functions/require_spec.rb +++ b/spec/unit/parser/functions/require_spec.rb @@ -1,74 +1,77 @@ #!/usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper') describe "the require function" do + before :all do + Puppet::Parser::Functions.autoloader.loadall + end before :each do @catalog = stub 'catalog' @compiler = stub 'compiler', :catalog => @catalog, :environment => nil @scope = Puppet::Parser::Scope.new @scope.stubs(:findresource) @scope.stubs(:compiler).returns(@compiler) @klass = stub 'class', :name => "myclass" @scope.stubs(:find_hostclass).returns(@klass) @resource = Puppet::Parser::Resource.new(:file, "/my/file", :scope => @scope, :source => "source") @resource.stubs(:metaparam_compatibility_mode?).returns false @scope.stubs(:resource).returns @resource end it "should exist" do Puppet::Parser::Functions.function("require").should == "function_require" end it "should delegate to the 'include' puppet function" do @scope.expects(:function_include).with("myclass") @scope.function_require("myclass") end it "should set the 'require' prarameter on the resource to a resource reference" do @scope.stubs(:function_include) @scope.function_require("myclass") @resource["require"].should be_instance_of(Array) @resource["require"][0].should be_instance_of(Puppet::Resource) end it "should verify the 'include' function is loaded" do Puppet::Parser::Functions.expects(:function).with(:include).returns(:function_include) @scope.stubs(:function_include) @scope.function_require("myclass") end it "should include the class but not add a dependency if used on a client not at least version 0.25" do @resource.expects(:metaparam_compatibility_mode?).returns true @scope.expects(:warning) @resource.expects(:set_parameter).never @scope.expects(:function_include) @scope.function_require("myclass") end it "should lookup the absolute class path" do @scope.stubs(:function_include) @scope.expects(:find_hostclass).with("myclass").returns(@klass) @klass.expects(:name).returns("myclass") @scope.function_require("myclass") end it "should append the required class to the require parameter" do @scope.stubs(:function_include) one = Puppet::Resource.new(:file, "/one") @resource[:require] = one @scope.function_require("myclass") @resource[:require].should be_include(one) @resource[:require].detect { |r| r.to_s == "Class[Myclass]" }.should be_instance_of(Puppet::Resource) end end diff --git a/spec/unit/parser/functions/shellquote_spec.rb b/spec/unit/parser/functions/shellquote_spec.rb index c8b0d650d..55302b97b 100755 --- a/spec/unit/parser/functions/shellquote_spec.rb +++ b/spec/unit/parser/functions/shellquote_spec.rb @@ -1,81 +1,84 @@ #! /usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper') describe "the shellquote function" do + before :all do + Puppet::Parser::Functions.autoloader.loadall + end before :each do @scope = Puppet::Parser::Scope.new end it "should exist" do Puppet::Parser::Functions.function("shellquote").should == "function_shellquote" end it "should handle no arguments" do result = @scope.function_shellquote([]) result.should(eql("")) end it "should handle several simple arguments" do result = @scope.function_shellquote( ['foo', 'bar@example.com', 'localhost:/dev/null', 'xyzzy+-4711,23']) result.should(eql( 'foo bar@example.com localhost:/dev/null xyzzy+-4711,23')) end it "should handle array arguments" do result = @scope.function_shellquote( ['foo', ['bar@example.com', 'localhost:/dev/null'], 'xyzzy+-4711,23']) result.should(eql( 'foo bar@example.com localhost:/dev/null xyzzy+-4711,23')) end it "should quote unsafe characters" do result = @scope.function_shellquote( ['/etc/passwd ', '(ls)', '*', '[?]', "'&'"]) result.should(eql( '"/etc/passwd " "(ls)" "*" "[?]" "\'&\'"')) end it "should deal with double quotes" do result = @scope.function_shellquote( ['"foo"bar"']) result.should(eql( '\'"foo"bar"\'')) end it "should cope with dollar signs" do result = @scope.function_shellquote( ['$PATH', 'foo$bar', '"x$"']) result.should(eql( "'$PATH' 'foo$bar' '\"x$\"'")) end it "should deal with apostrophes (single quotes)" do result = @scope.function_shellquote( ["'foo'bar'", "`$'EDITOR'`"]) result.should(eql( '"\'foo\'bar\'" "\\`\\$\'EDITOR\'\\`"')) end it "should cope with grave accents (backquotes)" do result = @scope.function_shellquote( ['`echo *`', '`ls "$MAILPATH"`']) result.should(eql( "'`echo *`' '`ls \"$MAILPATH\"`'")) end it "should deal with both single and double quotes" do result = @scope.function_shellquote( ['\'foo"bar"xyzzy\'', '"foo\'bar\'xyzzy"']) result.should(eql( '"\'foo\\"bar\\"xyzzy\'" "\\"foo\'bar\'xyzzy\\""')) end it "should handle multiple quotes *and* dollars and backquotes" do result = @scope.function_shellquote( ['\'foo"$x`bar`"xyzzy\'']) result.should(eql( '"\'foo\\"\\$x\\`bar\\`\\"xyzzy\'"')) end it "should handle linefeeds" do result = @scope.function_shellquote( ["foo \n bar"]) result.should(eql( "\"foo \n bar\"")) end end diff --git a/spec/unit/parser/functions/split_spec.rb b/spec/unit/parser/functions/split_spec.rb index 39710003b..b892a5c2a 100755 --- a/spec/unit/parser/functions/split_spec.rb +++ b/spec/unit/parser/functions/split_spec.rb @@ -1,49 +1,52 @@ #! /usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper') describe "the split function" do + before :all do + Puppet::Parser::Functions.autoloader.loadall + end before :each do @scope = Puppet::Parser::Scope.new end it "should exist" do Puppet::Parser::Functions.function("split").should == "function_split" end it "should raise a ParseError if there is less than 2 arguments" do lambda { @scope.function_split(["foo"]) }.should( raise_error(Puppet::ParseError)) end it "should raise a ParseError if there is more than 2 arguments" do lambda { @scope.function_split(["foo", "bar", "gazonk"]) }.should( raise_error(Puppet::ParseError)) end it "should raise a RegexpError if the regexp is malformed" do lambda { @scope.function_split(["foo", "("]) }.should( raise_error(RegexpError)) end it "should handle simple string without metacharacters" do result = @scope.function_split([ "130;236;254;10", ";"]) result.should(eql(["130", "236", "254", "10"])) end it "should handle simple regexps" do result = @scope.function_split([ "130.236;254.;10", "[.;]+"]) result.should(eql(["130", "236", "254", "10"])) end it "should handle groups" do result = @scope.function_split([ "130.236;254.;10", "([.;]+)"]) result.should(eql(["130", ".", "236", ";", "254", ".;", "10"])) end it "should handle simple string without metacharacters" do result = @scope.function_split([ "130.236.254.10", ";"]) result.should(eql(["130.236.254.10"])) end end diff --git a/spec/unit/parser/functions/sprintf_spec.rb b/spec/unit/parser/functions/sprintf_spec.rb index 4f29012b3..69fbb5e97 100755 --- a/spec/unit/parser/functions/sprintf_spec.rb +++ b/spec/unit/parser/functions/sprintf_spec.rb @@ -1,41 +1,44 @@ #! /usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper') describe "the sprintf function" do + before :all do + Puppet::Parser::Functions.autoloader.loadall + end before :each do @scope = Puppet::Parser::Scope.new end it "should exist" do Puppet::Parser::Functions.function("sprintf").should == "function_sprintf" end it "should raise a ParseError if there is less than 1 argument" do lambda { @scope.function_sprintf([]) }.should( raise_error(Puppet::ParseError)) end it "should format integers" do result = @scope.function_sprintf(["%+05d", "23"]) result.should(eql("+0023")) end it "should format floats" do result = @scope.function_sprintf(["%+.2f", "2.7182818284590451"]) result.should(eql("+2.72")) end it "should format large floats" do result = @scope.function_sprintf(["%+.2e", "27182818284590451"]) result.should(eql("+2.72e+16")) end it "should perform more complex formatting" do result = @scope.function_sprintf( [ "<%.8s:%#5o %#8X (%-8s)>", "overlongstring", "23", "48879", "foo" ]) result.should(eql("")) end end diff --git a/spec/unit/parser/functions/tag_spec.rb b/spec/unit/parser/functions/tag_spec.rb index e9b5122c7..b6bb45252 100755 --- a/spec/unit/parser/functions/tag_spec.rb +++ b/spec/unit/parser/functions/tag_spec.rb @@ -1,25 +1,28 @@ #! /usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper') describe "the 'tag' function" do + before :all do + Puppet::Parser::Functions.autoloader.loadall + end before :each do @scope = Puppet::Parser::Scope.new @scope.stubs(:environment).returns(nil) end it "should exist" do Puppet::Parser::Functions.function(:tag).should == "function_tag" end it "should tag the resource with any provided tags" do resource = Puppet::Parser::Resource.new(:file, "/file", :scope => @scope) @scope.expects(:resource).returns resource @scope.function_tag ["one", "two"] resource.should be_tagged("one") resource.should be_tagged("two") end end diff --git a/spec/unit/parser/functions/template_spec.rb b/spec/unit/parser/functions/template_spec.rb index 9dd5cc947..7eaf3554d 100755 --- a/spec/unit/parser/functions/template_spec.rb +++ b/spec/unit/parser/functions/template_spec.rb @@ -1,62 +1,65 @@ #!/usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper') describe "the template function" do + before :all do + Puppet::Parser::Functions.autoloader.loadall + end before :each do @scope = Puppet::Parser::Scope.new end it "should exist" do Puppet::Parser::Functions.function("template").should == "function_template" end it "should create a TemplateWrapper when called" do tw = stub_everything 'template_wrapper' Puppet::Parser::TemplateWrapper.expects(:new).returns(tw) @scope.function_template("test") end it "should give the template filename to the TemplateWrapper" do tw = stub_everything 'template_wrapper' Puppet::Parser::TemplateWrapper.stubs(:new).returns(tw) tw.expects(:file=).with("test") @scope.function_template("test") end it "should return what TemplateWrapper.result returns" do tw = stub_everything 'template_wrapper' Puppet::Parser::TemplateWrapper.stubs(:new).returns(tw) tw.stubs(:file=).with("test") tw.expects(:result).returns("template contents evaluated") @scope.function_template("test").should == "template contents evaluated" end it "should concatenate template wrapper outputs for multiple templates" do tw1 = stub_everything "template_wrapper1" tw2 = stub_everything "template_wrapper2" Puppet::Parser::TemplateWrapper.stubs(:new).returns(tw1,tw2) tw1.stubs(:file=).with("1") tw2.stubs(:file=).with("2") tw1.stubs(:result).returns("result1") tw2.stubs(:result).returns("result2") @scope.function_template(["1","2"]).should == "result1result2" end it "should raise an error if the template raises an error" do tw = stub_everything 'template_wrapper' Puppet::Parser::TemplateWrapper.stubs(:new).returns(tw) tw.stubs(:result).raises lambda { @scope.function_template("1") }.should raise_error(Puppet::ParseError) end -end \ No newline at end of file +end diff --git a/spec/unit/parser/functions/versioncmp_spec.rb b/spec/unit/parser/functions/versioncmp_spec.rb index 2bc7be801..ddc79cd85 100755 --- a/spec/unit/parser/functions/versioncmp_spec.rb +++ b/spec/unit/parser/functions/versioncmp_spec.rb @@ -1,29 +1,32 @@ #!/usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper') describe "the versioncmp function" do + before :all do + Puppet::Parser::Functions.autoloader.loadall + end before :each do @scope = Puppet::Parser::Scope.new end it "should exist" do Puppet::Parser::Functions.function("versioncmp").should == "function_versioncmp" end it "should raise a ParseError if there is less than 2 arguments" do lambda { @scope.function_versioncmp(["1.2"]) }.should raise_error(Puppet::ParseError) end it "should raise a ParseError if there is more than 2 arguments" do lambda { @scope.function_versioncmp(["1.2", "2.4.5", "3.5.6"]) }.should raise_error(Puppet::ParseError) end it "should call Puppet::Util::Package.versioncmp (included in scope)" do Puppet::Util::Package.expects(:versioncmp).with("1.2", "1.3").returns(-1) @scope.function_versioncmp(["1.2", "1.3"]) end end diff --git a/spec/unit/parser/lexer_spec.rb b/spec/unit/parser/lexer_spec.rb index 58978ff03..96df61348 100755 --- a/spec/unit/parser/lexer_spec.rb +++ b/spec/unit/parser/lexer_spec.rb @@ -1,665 +1,678 @@ #!/usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') require 'puppet/parser/lexer' # This is a special matcher to match easily lexer output RSpec::Matchers.define :be_like do |*expected| match do |actual| expected.zip(actual).all? { |e,a| !e or a[0] == e or (e.is_a? Array and a[0] == e[0] and (a[1] == e[1] or (a[1].is_a?(Hash) and a[1][:value] == e[1]))) } end end __ = nil describe Puppet::Parser::Lexer do describe "when reading strings" do before { @lexer = Puppet::Parser::Lexer.new } it "should increment the line count for every carriage return in the string" do @lexer.line = 10 @lexer.string = "this\nis\natest'" @lexer.slurpstring("'") @lexer.line.should == 12 end it "should not increment the line count for escapes in the string" do @lexer.line = 10 @lexer.string = "this\\nis\\natest'" @lexer.slurpstring("'") @lexer.line.should == 10 end it "should not think the terminator is escaped, when preceeded by an even number of backslashes" do @lexer.line = 10 @lexer.string = "here\nis\nthe\nstring\\\\'with\nextra\njunk" @lexer.slurpstring("'") @lexer.line.should == 13 end end end describe Puppet::Parser::Lexer::Token do before do @token = Puppet::Parser::Lexer::Token.new(%r{something}, :NAME) end [:regex, :name, :string, :skip, :incr_line, :skip_text, :accumulate].each do |param| it "should have a #{param.to_s} reader" do @token.should be_respond_to(param) end it "should have a #{param.to_s} writer" do @token.should be_respond_to(param.to_s + "=") end end end describe Puppet::Parser::Lexer::Token, "when initializing" do it "should create a regex if the first argument is a string" do Puppet::Parser::Lexer::Token.new("something", :NAME).regex.should == %r{something} end it "should set the string if the first argument is one" do Puppet::Parser::Lexer::Token.new("something", :NAME).string.should == "something" end it "should set the regex if the first argument is one" do Puppet::Parser::Lexer::Token.new(%r{something}, :NAME).regex.should == %r{something} end end describe Puppet::Parser::Lexer::TokenList do before do @list = Puppet::Parser::Lexer::TokenList.new end it "should have a method for retrieving tokens by the name" do token = @list.add_token :name, "whatever" @list[:name].should equal(token) end it "should have a method for retrieving string tokens by the string" do token = @list.add_token :name, "whatever" @list.lookup("whatever").should equal(token) end it "should add tokens to the list when directed" do token = @list.add_token :name, "whatever" @list[:name].should equal(token) end it "should have a method for adding multiple tokens at once" do @list.add_tokens "whatever" => :name, "foo" => :bar @list[:name].should_not be_nil @list[:bar].should_not be_nil end it "should fail to add tokens sharing a name with an existing token" do @list.add_token :name, "whatever" lambda { @list.add_token :name, "whatever" }.should raise_error(ArgumentError) end it "should set provided options on tokens being added" do token = @list.add_token :name, "whatever", :skip_text => true token.skip_text.should == true end it "should define any provided blocks as a :convert method" do token = @list.add_token(:name, "whatever") do "foo" end token.convert.should == "foo" end it "should store all string tokens in the :string_tokens list" do one = @list.add_token(:name, "1") @list.string_tokens.should be_include(one) end it "should store all regex tokens in the :regex_tokens list" do one = @list.add_token(:name, %r{one}) @list.regex_tokens.should be_include(one) end it "should not store string tokens in the :regex_tokens list" do one = @list.add_token(:name, "1") @list.regex_tokens.should_not be_include(one) end it "should not store regex tokens in the :string_tokens list" do one = @list.add_token(:name, %r{one}) @list.string_tokens.should_not be_include(one) end it "should sort the string tokens inversely by length when asked" do one = @list.add_token(:name, "1") two = @list.add_token(:other, "12") @list.sort_tokens @list.string_tokens.should == [two, one] end end describe Puppet::Parser::Lexer::TOKENS do before do @lexer = Puppet::Parser::Lexer.new end { :LBRACK => '[', :RBRACK => ']', :LBRACE => '{', :RBRACE => '}', :LPAREN => '(', :RPAREN => ')', :EQUALS => '=', :ISEQUAL => '==', :GREATEREQUAL => '>=', :GREATERTHAN => '>', :LESSTHAN => '<', :LESSEQUAL => '<=', :NOTEQUAL => '!=', :NOT => '!', :COMMA => ',', :DOT => '.', :COLON => ':', :AT => '@', :LLCOLLECT => '<<|', :RRCOLLECT => '|>>', :LCOLLECT => '<|', :RCOLLECT => '|>', :SEMIC => ';', :QMARK => '?', :BACKSLASH => '\\', :FARROW => '=>', :PARROW => '+>', :APPENDS => '+=', :PLUS => '+', :MINUS => '-', :DIV => '/', :TIMES => '*', :LSHIFT => '<<', :RSHIFT => '>>', :MATCH => '=~', :NOMATCH => '!~', :IN_EDGE => '->', :OUT_EDGE => '<-', :IN_EDGE_SUB => '~>', :OUT_EDGE_SUB => '<~', }.each do |name, string| it "should have a token named #{name.to_s}" do Puppet::Parser::Lexer::TOKENS[name].should_not be_nil end it "should match '#{string}' for the token #{name.to_s}" do Puppet::Parser::Lexer::TOKENS[name].string.should == string end end { "case" => :CASE, "class" => :CLASS, "default" => :DEFAULT, "define" => :DEFINE, "import" => :IMPORT, "if" => :IF, "elsif" => :ELSIF, "else" => :ELSE, "inherits" => :INHERITS, "node" => :NODE, "and" => :AND, "or" => :OR, "undef" => :UNDEF, "false" => :FALSE, "true" => :TRUE, "in" => :IN, }.each do |string, name| it "should have a keyword named #{name.to_s}" do Puppet::Parser::Lexer::KEYWORDS[name].should_not be_nil end it "should have the keyword for #{name.to_s} set to #{string}" do Puppet::Parser::Lexer::KEYWORDS[name].string.should == string end end # These tokens' strings don't matter, just that the tokens exist. [:STRING, :DQPRE, :DQMID, :DQPOST, :BOOLEAN, :NAME, :NUMBER, :COMMENT, :MLCOMMENT, :RETURN, :SQUOTE, :DQUOTE, :VARIABLE].each do |name| it "should have a token named #{name.to_s}" do Puppet::Parser::Lexer::TOKENS[name].should_not be_nil end end end describe Puppet::Parser::Lexer::TOKENS[:CLASSNAME] do before { @token = Puppet::Parser::Lexer::TOKENS[:CLASSNAME] } it "should match against lower-case alpha-numeric terms separated by double colons" do @token.regex.should =~ "one::two" end it "should match against many lower-case alpha-numeric terms separated by double colons" do @token.regex.should =~ "one::two::three::four::five" end it "should match against lower-case alpha-numeric terms prefixed by double colons" do @token.regex.should =~ "::one" end end describe Puppet::Parser::Lexer::TOKENS[:CLASSREF] do before { @token = Puppet::Parser::Lexer::TOKENS[:CLASSREF] } it "should match against single upper-case alpha-numeric terms" do @token.regex.should =~ "One" end it "should match against upper-case alpha-numeric terms separated by double colons" do @token.regex.should =~ "One::Two" end it "should match against many upper-case alpha-numeric terms separated by double colons" do @token.regex.should =~ "One::Two::Three::Four::Five" end it "should match against upper-case alpha-numeric terms prefixed by double colons" do @token.regex.should =~ "::One" end end describe Puppet::Parser::Lexer::TOKENS[:NAME] do before { @token = Puppet::Parser::Lexer::TOKENS[:NAME] } it "should match against lower-case alpha-numeric terms" do @token.regex.should =~ "one-two" end it "should return itself and the value if the matched term is not a keyword" do Puppet::Parser::Lexer::KEYWORDS.expects(:lookup).returns(nil) @token.convert(stub("lexer"), "myval").should == [Puppet::Parser::Lexer::TOKENS[:NAME], "myval"] end it "should return the keyword token and the value if the matched term is a keyword" do keyword = stub 'keyword', :name => :testing Puppet::Parser::Lexer::KEYWORDS.expects(:lookup).returns(keyword) @token.convert(stub("lexer"), "myval").should == [keyword, "myval"] end it "should return the BOOLEAN token and 'true' if the matched term is the string 'true'" do keyword = stub 'keyword', :name => :TRUE Puppet::Parser::Lexer::KEYWORDS.expects(:lookup).returns(keyword) @token.convert(stub('lexer'), "true").should == [Puppet::Parser::Lexer::TOKENS[:BOOLEAN], true] end it "should return the BOOLEAN token and 'false' if the matched term is the string 'false'" do keyword = stub 'keyword', :name => :FALSE Puppet::Parser::Lexer::KEYWORDS.expects(:lookup).returns(keyword) @token.convert(stub('lexer'), "false").should == [Puppet::Parser::Lexer::TOKENS[:BOOLEAN], false] end end describe Puppet::Parser::Lexer::TOKENS[:NUMBER] do before do @token = Puppet::Parser::Lexer::TOKENS[:NUMBER] @regex = @token.regex end it "should match against numeric terms" do @regex.should =~ "2982383139" end it "should match against float terms" do @regex.should =~ "29823.235" end it "should match against hexadecimal terms" do @regex.should =~ "0xBEEF0023" end it "should match against float with exponent terms" do @regex.should =~ "10e23" end it "should match against float terms with negative exponents" do @regex.should =~ "10e-23" end it "should match against float terms with fractional parts and exponent" do @regex.should =~ "1.234e23" end it "should return the NAME token and the value" do @token.convert(stub("lexer"), "myval").should == [Puppet::Parser::Lexer::TOKENS[:NAME], "myval"] end end describe Puppet::Parser::Lexer::TOKENS[:COMMENT] do before { @token = Puppet::Parser::Lexer::TOKENS[:COMMENT] } it "should match against lines starting with '#'" do @token.regex.should =~ "# this is a comment" end it "should be marked to get skipped" do @token.skip?.should be_true end it "should be marked to accumulate" do @token.accumulate?.should be_true end it "'s block should return the comment without the #" do @token.convert(@lexer,"# this is a comment")[1].should == "this is a comment" end end describe Puppet::Parser::Lexer::TOKENS[:MLCOMMENT] do before do @token = Puppet::Parser::Lexer::TOKENS[:MLCOMMENT] @lexer = stub 'lexer', :line => 0 end it "should match against lines enclosed with '/*' and '*/'" do @token.regex.should =~ "/* this is a comment */" end it "should match multiple lines enclosed with '/*' and '*/'" do @token.regex.should =~ """/* this is a comment */""" end it "should increase the lexer current line number by the amount of lines spanned by the comment" do @lexer.expects(:line=).with(2) @token.convert(@lexer, "1\n2\n3") end it "should not greedily match comments" do match = @token.regex.match("/* first */ word /* second */") match[1].should == " first " end it "should be marked to accumulate" do @token.accumulate?.should be_true end it "'s block should return the comment without the comment marks" do @lexer.stubs(:line=).with(0) @token.convert(@lexer,"/* this is a comment */")[1].should == "this is a comment" end end describe Puppet::Parser::Lexer::TOKENS[:RETURN] do before { @token = Puppet::Parser::Lexer::TOKENS[:RETURN] } it "should match against carriage returns" do @token.regex.should =~ "\n" end it "should be marked to initiate text skipping" do @token.skip_text.should be_true end it "should be marked to increment the line" do @token.incr_line.should be_true end end def tokens_scanned_from(s) lexer = Puppet::Parser::Lexer.new lexer.string = s lexer.fullscan[0..-2] end describe Puppet::Parser::Lexer,"when lexing strings" do { %q{'single quoted string')} => [[:STRING,'single quoted string']], %q{"double quoted string"} => [[:STRING,'double quoted string']], %q{'single quoted string with an escaped "\\'"'} => [[:STRING,'single quoted string with an escaped "\'"']], %q{'single quoted string with an escaped "\$"'} => [[:STRING,'single quoted string with an escaped "\$"']], %q{'single quoted string with an escaped "\."'} => [[:STRING,'single quoted string with an escaped "\."']], %q{'single quoted string with an escaped "\n"'} => [[:STRING,'single quoted string with an escaped "\n"']], %q{'single quoted string with an escaped "\\\\"'} => [[:STRING,'single quoted string with an escaped "\\\\"']], %q{"string with an escaped '\\"'"} => [[:STRING,"string with an escaped '\"'"]], %q{"string with an escaped '\\$'"} => [[:STRING,"string with an escaped '$'"]], %Q{"string with a line ending with a backslash: \\\nfoo"} => [[:STRING,"string with a line ending with a backslash: foo"]], %q{"string with $v (but no braces)"} => [[:DQPRE,"string with "],[:VARIABLE,'v'],[:DQPOST,' (but no braces)']], %q["string with ${v} in braces"] => [[:DQPRE,"string with "],[:VARIABLE,'v'],[:DQPOST,' in braces']], %q["string with ${qualified::var} in braces"] => [[:DQPRE,"string with "],[:VARIABLE,'qualified::var'],[:DQPOST,' in braces']], %q{"string with $v and $v (but no braces)"} => [[:DQPRE,"string with "],[:VARIABLE,"v"],[:DQMID," and "],[:VARIABLE,"v"],[:DQPOST," (but no braces)"]], %q["string with ${v} and ${v} in braces"] => [[:DQPRE,"string with "],[:VARIABLE,"v"],[:DQMID," and "],[:VARIABLE,"v"],[:DQPOST," in braces"]], %q["string with ${'a nested single quoted string'} inside it."] => [[:DQPRE,"string with "],[:STRING,'a nested single quoted string'],[:DQPOST,' inside it.']], %q["string with ${['an array ',$v2]} in it."] => [[:DQPRE,"string with "],:LBRACK,[:STRING,"an array "],:COMMA,[:VARIABLE,"v2"],:RBRACK,[:DQPOST," in it."]], %q{a simple "scanner" test} => [[:NAME,"a"],[:NAME,"simple"], [:STRING,"scanner"],[:NAME,"test"]], %q{a simple 'single quote scanner' test} => [[:NAME,"a"],[:NAME,"simple"], [:STRING,"single quote scanner"],[:NAME,"test"]], %q{a harder 'a $b \c"'} => [[:NAME,"a"],[:NAME,"harder"], [:STRING,'a $b \c"']], %q{a harder "scanner test"} => [[:NAME,"a"],[:NAME,"harder"], [:STRING,"scanner test"]], %q{a hardest "scanner \"test\""} => [[:NAME,"a"],[:NAME,"hardest"],[:STRING,'scanner "test"']], %Q{a hardestest "scanner \\"test\\"\n"} => [[:NAME,"a"],[:NAME,"hardestest"],[:STRING,%Q{scanner "test"\n}]], %q{function("call")} => [[:NAME,"function"],[:LPAREN,"("],[:STRING,'call'],[:RPAREN,")"]], %q["string with ${(3+5)/4} nested math."] => [[:DQPRE,"string with "],:LPAREN,[:NAME,"3"],:PLUS,[:NAME,"5"],:RPAREN,:DIV,[:NAME,"4"],[:DQPOST," nested math."]], %q["$$$$"] => [[:STRING,"$$$$"]], %q["$variable"] => [[:DQPRE,""],[:VARIABLE,"variable"],[:DQPOST,""]], %q["$var$other"] => [[:DQPRE,""],[:VARIABLE,"var"],[:DQMID,""],[:VARIABLE,"other"],[:DQPOST,""]], %q["foo$bar$"] => [[:DQPRE,"foo"],[:VARIABLE,"bar"],[:DQPOST,"$"]], %q["foo$$bar"] => [[:DQPRE,"foo$"],[:VARIABLE,"bar"],[:DQPOST,""]], %q[""] => [[:STRING,""]], }.each { |src,expected_result| it "should handle #{src} correctly" do tokens_scanned_from(src).should be_like(*expected_result) end } end describe Puppet::Parser::Lexer::TOKENS[:DOLLAR_VAR] do before { @token = Puppet::Parser::Lexer::TOKENS[:DOLLAR_VAR] } it "should match against alpha words prefixed with '$'" do @token.regex.should =~ '$this_var' end it "should return the VARIABLE token and the variable name stripped of the '$'" do @token.convert(stub("lexer"), "$myval").should == [Puppet::Parser::Lexer::TOKENS[:VARIABLE], "myval"] end end describe Puppet::Parser::Lexer::TOKENS[:REGEX] do before { @token = Puppet::Parser::Lexer::TOKENS[:REGEX] } it "should match against any expression enclosed in //" do @token.regex.should =~ '/this is a regex/' end it 'should not match if there is \n in the regex' do @token.regex.should_not =~ "/this is \n a regex/" end describe "when scanning" do it "should not consider escaped slashes to be the end of a regex" do tokens_scanned_from("$x =~ /this \\/ foo/").should be_like(__,__,[:REGEX,%r{this / foo}]) end it "should not lex chained division as a regex" do tokens_scanned_from("$x = $a/$b/$c").collect { |name, data| name }.should_not be_include( :REGEX ) end it "should accept a regular expression after NODE" do tokens_scanned_from("node /www.*\.mysite\.org/").should be_like(__,[:REGEX,Regexp.new("www.*\.mysite\.org")]) end it "should accept regular expressions in a CASE" do s = %q{case $variable { "something": {$othervar = 4096 / 2} /regex/: {notice("this notably sucks")} } } tokens_scanned_from(s).should be_like( :CASE,:VARIABLE,:LBRACE,:STRING,:COLON,:LBRACE,:VARIABLE,:EQUALS,:NAME,:DIV,:NAME,:RBRACE,[:REGEX,/regex/],:COLON,:LBRACE,:NAME,:LPAREN,:STRING,:RPAREN,:RBRACE,:RBRACE ) end end it "should return the REGEX token and a Regexp" do @token.convert(stub("lexer"), "/myregex/").should == [Puppet::Parser::Lexer::TOKENS[:REGEX], Regexp.new(/myregex/)] end end describe Puppet::Parser::Lexer, "when lexing comments" do before { @lexer = Puppet::Parser::Lexer.new } it "should accumulate token in munge_token" do token = stub 'token', :skip => true, :accumulate? => true, :incr_line => nil, :skip_text => false token.stubs(:convert).with(@lexer, "# this is a comment").returns([token, " this is a comment"]) @lexer.munge_token(token, "# this is a comment") @lexer.munge_token(token, "# this is a comment") @lexer.getcomment.should == " this is a comment\n this is a comment\n" end it "should add a new comment stack level on LBRACE" do @lexer.string = "{" @lexer.expects(:commentpush) @lexer.fullscan end + it "should add a new comment stack level on LPAREN" do + @lexer.string = "(" + + @lexer.expects(:commentpush) + + @lexer.fullscan + end + + it "should pop the current comment on RPAREN" do + @lexer.string = ")" + + @lexer.expects(:commentpop) + + @lexer.fullscan + end + it "should return the current comments on getcomment" do @lexer.string = "# comment" @lexer.fullscan @lexer.getcomment.should == "comment\n" end it "should discard the previous comments on blank line" do @lexer.string = "# 1\n\n# 2" @lexer.fullscan @lexer.getcomment.should == "2\n" end it "should skip whitespace before lexing the next token after a non-token" do tokens_scanned_from("/* 1\n\n */ \ntest").should be_like([:NAME, "test"]) end it "should not return comments seen after the current line" do @lexer.string = "# 1\n\n# 2" @lexer.fullscan @lexer.getcomment(1).should == "" end it "should return a comment seen before the current line" do @lexer.string = "# 1\n# 2" @lexer.fullscan @lexer.getcomment(2).should == "1\n2\n" end end # FIXME: We need to rewrite all of these tests, but I just don't want to take the time right now. describe "Puppet::Parser::Lexer in the old tests" do before { @lexer = Puppet::Parser::Lexer.new } it "should do simple lexing" do { %q{\\} => [[:BACKSLASH,"\\"]], %q{simplest scanner test} => [[:NAME,"simplest"],[:NAME,"scanner"],[:NAME,"test"]], %Q{returned scanner test\n} => [[:NAME,"returned"],[:NAME,"scanner"],[:NAME,"test"]] }.each { |source,expected| tokens_scanned_from(source).should be_like(*expected) } end it "should fail usefully" do lambda { tokens_scanned_from('^') }.should raise_error(RuntimeError) end it "should fail if the string is not set" do lambda { @lexer.fullscan }.should raise_error(Puppet::LexError) end it "should correctly identify keywords" do tokens_scanned_from("case").should be_like([:CASE, "case"]) end it "should correctly parse class references" do %w{Many Different Words A Word}.each { |t| tokens_scanned_from(t).should be_like([:CLASSREF,t])} end # #774 it "should correctly parse namespaced class refernces token" do %w{Foo ::Foo Foo::Bar ::Foo::Bar}.each { |t| tokens_scanned_from(t).should be_like([:CLASSREF, t]) } end it "should correctly parse names" do %w{this is a bunch of names}.each { |t| tokens_scanned_from(t).should be_like([:NAME,t]) } end it "should correctly parse names with numerals" do %w{1name name1 11names names11}.each { |t| tokens_scanned_from(t).should be_like([:NAME,t]) } end it "should correctly parse empty strings" do lambda { tokens_scanned_from('$var = ""') }.should_not raise_error end it "should correctly parse virtual resources" do tokens_scanned_from("@type {").should be_like([:AT, "@"], [:NAME, "type"], [:LBRACE, "{"]) end it "should correctly deal with namespaces" do @lexer.string = %{class myclass} @lexer.fullscan @lexer.namespace.should == "myclass" @lexer.namepop @lexer.namespace.should == "" @lexer.string = "class base { class sub { class more" @lexer.fullscan @lexer.namespace.should == "base::sub::more" @lexer.namepop @lexer.namespace.should == "base::sub" end it "should not put class instantiation on the namespace" do @lexer.string = "class base { class sub { class { mode" @lexer.fullscan @lexer.namespace.should == "base::sub" end it "should correctly handle fully qualified names" do @lexer.string = "class base { class sub::more {" @lexer.fullscan @lexer.namespace.should == "base::sub::more" @lexer.namepop @lexer.namespace.should == "base" end it "should correctly lex variables" do ["$variable", "$::variable", "$qualified::variable", "$further::qualified::variable"].each do |string| tokens_scanned_from(string).should be_like([:VARIABLE,string.sub(/^\$/,'')]) end end end -require File.dirname(__FILE__) + '/../../../test/lib/puppettest' -require File.dirname(__FILE__) + '/../../../test/lib/puppettest/support/utils' describe "Puppet::Parser::Lexer in the old tests when lexing example files" do - extend PuppetTest::Support::Utils - textfiles do |file| + my_fixtures('*.pp') do |file| it "should correctly lex #{file}" do lexer = Puppet::Parser::Lexer.new lexer.file = file lambda { lexer.fullscan }.should_not raise_error end end end diff --git a/spec/unit/parser/parser_spec.rb b/spec/unit/parser/parser_spec.rb index f5df3041c..01cdcb976 100755 --- a/spec/unit/parser/parser_spec.rb +++ b/spec/unit/parser/parser_spec.rb @@ -1,419 +1,425 @@ #!/usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') describe Puppet::Parser do Puppet::Parser::AST before :each do @known_resource_types = Puppet::Resource::TypeCollection.new("development") @parser = Puppet::Parser::Parser.new "development" @parser.stubs(:known_resource_types).returns @known_resource_types @true_ast = Puppet::Parser::AST::Boolean.new :value => true end it "should require an environment at initialization" do lambda { Puppet::Parser::Parser.new }.should raise_error(ArgumentError) end it "should set the environment" do env = Puppet::Node::Environment.new Puppet::Parser::Parser.new(env).environment.should == env end it "should convert the environment into an environment instance if a string is provided" do env = Puppet::Node::Environment.new("testing") Puppet::Parser::Parser.new("testing").environment.should == env end it "should be able to look up the environment-specific resource type collection" do rtc = Puppet::Node::Environment.new("development").known_resource_types parser = Puppet::Parser::Parser.new "development" parser.known_resource_types.should equal(rtc) end it "should delegate importing to the known resource type loader" do parser = Puppet::Parser::Parser.new "development" parser.known_resource_types.loader.expects(:import).with("newfile", "current_file") parser.lexer.expects(:file).returns "current_file" parser.import("newfile") end describe "when parsing files" do before do FileTest.stubs(:exist?).returns true File.stubs(:read).returns "" @parser.stubs(:watch_file) end it "should treat files ending in 'rb' as ruby files" do @parser.expects(:parse_ruby_file) @parser.file = "/my/file.rb" @parser.parse end end describe "when parsing append operator" do it "should not raise syntax errors" do lambda { @parser.parse("$var += something") }.should_not raise_error end it "shouldraise syntax error on incomplete syntax " do lambda { @parser.parse("$var += ") }.should raise_error end it "should create ast::VarDef with append=true" do vardef = @parser.parse("$var += 2").code[0] vardef.should be_a(Puppet::Parser::AST::VarDef) vardef.append.should == true end it "should work with arrays too" do vardef = @parser.parse("$var += ['test']").code[0] vardef.should be_a(Puppet::Parser::AST::VarDef) vardef.append.should == true end end + describe "when parsing selector" do + it "should support hash access on the left hand side" do + lambda { @parser.parse("$h = { 'a' => 'b' } $a = $h['a'] ? { 'b' => 'd', default => undef }") }.should_not raise_error + end + end + describe "when parsing 'if'" do it "not, it should create the correct ast objects" do Puppet::Parser::AST::Not.expects(:new).with { |h| h[:value].is_a?(Puppet::Parser::AST::Boolean) } @parser.parse("if ! true { $var = 1 }") end it "boolean operation, it should create the correct ast objects" do Puppet::Parser::AST::BooleanOperator.expects(:new).with { |h| h[:rval].is_a?(Puppet::Parser::AST::Boolean) and h[:lval].is_a?(Puppet::Parser::AST::Boolean) and h[:operator]=="or" } @parser.parse("if true or true { $var = 1 }") end it "comparison operation, it should create the correct ast objects" do Puppet::Parser::AST::ComparisonOperator.expects(:new).with { |h| h[:lval].is_a?(Puppet::Parser::AST::Name) and h[:rval].is_a?(Puppet::Parser::AST::Name) and h[:operator]=="<" } @parser.parse("if 1 < 2 { $var = 1 }") end end describe "when parsing if complex expressions" do it "should create a correct ast tree" do aststub = stub_everything 'ast' Puppet::Parser::AST::ComparisonOperator.expects(:new).with { |h| h[:rval].is_a?(Puppet::Parser::AST::Name) and h[:lval].is_a?(Puppet::Parser::AST::Name) and h[:operator]==">" }.returns(aststub) Puppet::Parser::AST::ComparisonOperator.expects(:new).with { |h| h[:rval].is_a?(Puppet::Parser::AST::Name) and h[:lval].is_a?(Puppet::Parser::AST::Name) and h[:operator]=="==" }.returns(aststub) Puppet::Parser::AST::BooleanOperator.expects(:new).with { |h| h[:rval]==aststub and h[:lval]==aststub and h[:operator]=="and" } @parser.parse("if (1 > 2) and (1 == 2) { $var = 1 }") end it "should raise an error on incorrect expression" do lambda { @parser.parse("if (1 > 2 > ) or (1 == 2) { $var = 1 }") }.should raise_error end end describe "when parsing resource references" do it "should not raise syntax errors" do lambda { @parser.parse('exec { test: param => File["a"] }') }.should_not raise_error end it "should not raise syntax errors with multiple references" do lambda { @parser.parse('exec { test: param => File["a","b"] }') }.should_not raise_error end it "should create an ast::ResourceReference" do Puppet::Parser::AST::ResourceReference.expects(:new).with { |arg| arg[:line]==1 and arg[:type]=="File" and arg[:title].is_a?(Puppet::Parser::AST::ASTArray) } @parser.parse('exec { test: command => File["a","b"] }') end end describe "when parsing resource overrides" do it "should not raise syntax errors" do lambda { @parser.parse('Resource["title"] { param => value }') }.should_not raise_error end it "should not raise syntax errors with multiple overrides" do lambda { @parser.parse('Resource["title1","title2"] { param => value }') }.should_not raise_error end it "should create an ast::ResourceOverride" do #Puppet::Parser::AST::ResourceOverride.expects(:new).with { |arg| # arg[:line]==1 and arg[:object].is_a?(Puppet::Parser::AST::ResourceReference) and arg[:parameters].is_a?(Puppet::Parser::AST::ResourceParam) #} ro = @parser.parse('Resource["title1","title2"] { param => value }').code[0] ro.should be_a(Puppet::Parser::AST::ResourceOverride) ro.line.should == 1 ro.object.should be_a(Puppet::Parser::AST::ResourceReference) ro.parameters[0].should be_a(Puppet::Parser::AST::ResourceParam) end end describe "when parsing if statements" do it "should not raise errors with empty if" do lambda { @parser.parse("if true { }") }.should_not raise_error end it "should not raise errors with empty else" do lambda { @parser.parse("if false { notice('if') } else { }") }.should_not raise_error end it "should not raise errors with empty if and else" do lambda { @parser.parse("if false { } else { }") }.should_not raise_error end it "should create a nop node for empty branch" do Puppet::Parser::AST::Nop.expects(:new) @parser.parse("if true { }") end it "should create a nop node for empty else branch" do Puppet::Parser::AST::Nop.expects(:new) @parser.parse("if true { notice('test') } else { }") end it "should build a chain of 'ifs' if there's an 'elsif'" do lambda { @parser.parse(<<-PP) }.should_not raise_error if true { notice('test') } elsif true {} else { } PP end end describe "when parsing function calls" do it "should not raise errors with no arguments" do lambda { @parser.parse("tag()") }.should_not raise_error end it "should not raise errors with rvalue function with no args" do lambda { @parser.parse("$a = template()") }.should_not raise_error end it "should not raise errors with arguments" do lambda { @parser.parse("notice(1)") }.should_not raise_error end it "should not raise errors with multiple arguments" do lambda { @parser.parse("notice(1,2)") }.should_not raise_error end it "should not raise errors with multiple arguments and a trailing comma" do lambda { @parser.parse("notice(1,2,)") }.should_not raise_error end end describe "when parsing arrays with trailing comma" do it "should not raise errors with a trailing comma" do lambda { @parser.parse("$a = [1,2,]") }.should_not raise_error end end describe "when providing AST context" do before do @lexer = stub 'lexer', :line => 50, :file => "/foo/bar", :getcomment => "whev" @parser.stubs(:lexer).returns @lexer end it "should include the lexer's line" do @parser.ast_context[:line].should == 50 end it "should include the lexer's file" do @parser.ast_context[:file].should == "/foo/bar" end it "should include the docs if directed to do so" do @parser.ast_context(true)[:doc].should == "whev" end it "should not include the docs when told not to" do @parser.ast_context(false)[:doc].should be_nil end it "should not include the docs by default" do @parser.ast_context[:doc].should be_nil end end describe "when building ast nodes" do before do @lexer = stub 'lexer', :line => 50, :file => "/foo/bar", :getcomment => "whev" @parser.stubs(:lexer).returns @lexer - @class = stub 'class', :use_docs => false + @class = Puppet::Resource::Type.new(:hostclass, "myclass", :use_docs => false) end it "should return a new instance of the provided class created with the provided options" do @class.expects(:new).with { |opts| opts[:foo] == "bar" } @parser.ast(@class, :foo => "bar") end it "should merge the ast context into the provided options" do @class.expects(:new).with { |opts| opts[:file] == "/foo" } @parser.expects(:ast_context).returns :file => "/foo" @parser.ast(@class, :foo => "bar") end it "should prefer provided options over AST context" do @class.expects(:new).with { |opts| opts[:file] == "/bar" } @lexer.expects(:file).returns "/foo" @parser.ast(@class, :file => "/bar") end it "should include docs when the AST class uses them" do @class.expects(:use_docs).returns true @class.stubs(:new) - @parser.expects(:ast_context).with{ |a| a[0] == true }.returns({}) + @parser.expects(:ast_context).with{ |docs, line| docs == true }.returns({}) @parser.ast(@class, :file => "/bar") end it "should get docs from lexer using the correct AST line number" do @class.expects(:use_docs).returns true @class.stubs(:new).with{ |a| a[:doc] == "doc" } @lexer.expects(:getcomment).with(12).returns "doc" @parser.ast(@class, :file => "/bar", :line => 12) end end describe "when retrieving a specific node" do it "should delegate to the known_resource_types node" do @known_resource_types.expects(:node).with("node") @parser.node("node") end end describe "when retrieving a specific class" do it "should delegate to the loaded code" do @known_resource_types.expects(:hostclass).with("class") @parser.hostclass("class") end end describe "when retrieving a specific definitions" do it "should delegate to the loaded code" do @known_resource_types.expects(:definition).with("define") @parser.definition("define") end end describe "when determining the configuration version" do it "should determine it from the resource type collection" do @parser.known_resource_types.expects(:version).returns "foo" @parser.version.should == "foo" end end describe "when looking up definitions" do it "should use the known resource types to check for them by name" do @parser.known_resource_types.stubs(:find_or_load).with("namespace","name",:definition).returns(:this_value) @parser.find_definition("namespace","name").should == :this_value end end describe "when looking up hostclasses" do it "should use the known resource types to check for them by name" do @parser.known_resource_types.stubs(:find_or_load).with("namespace","name",:hostclass).returns(:this_value) @parser.find_hostclass("namespace","name").should == :this_value end end describe "when parsing classes" do before :each do @krt = Puppet::Resource::TypeCollection.new("development") @parser = Puppet::Parser::Parser.new "development" @parser.stubs(:known_resource_types).returns @krt end it "should not create new classes" do @parser.parse("class foobar {}").code[0].should be_a(Puppet::Parser::AST::Hostclass) @krt.hostclass("foobar").should be_nil end it "should correctly set the parent class when one is provided" do @parser.parse("class foobar inherits yayness {}").code[0].instantiate('')[0].parent.should == "yayness" end it "should correctly set the parent class for multiple classes at a time" do statements = @parser.parse("class foobar inherits yayness {}\nclass boo inherits bar {}").code statements[0].instantiate('')[0].parent.should == "yayness" statements[1].instantiate('')[0].parent.should == "bar" end it "should define the code when some is provided" do @parser.parse("class foobar { $var = val }").code[0].code.should_not be_nil end it "should define parameters when provided" do foobar = @parser.parse("class foobar($biz,$baz) {}").code[0].instantiate('')[0] foobar.arguments.should == {"biz" => nil, "baz" => nil} end end describe "when parsing resources" do before :each do @krt = Puppet::Resource::TypeCollection.new("development") @parser = Puppet::Parser::Parser.new "development" @parser.stubs(:known_resource_types).returns @krt end it "should be able to parse class resources" do @krt.add(Puppet::Resource::Type.new(:hostclass, "foobar", :arguments => {"biz" => nil})) lambda { @parser.parse("class { foobar: biz => stuff }") }.should_not raise_error end it "should correctly mark exported resources as exported" do @parser.parse("@@file { '/file': }").code[0].exported.should be_true end it "should correctly mark virtual resources as virtual" do @parser.parse("@file { '/file': }").code[0].virtual.should be_true end end describe "when parsing nodes" do it "should be able to parse a node with a single name" do node = @parser.parse("node foo { }").code[0] node.should be_a Puppet::Parser::AST::Node node.names.length.should == 1 node.names[0].value.should == "foo" end it "should be able to parse a node with two names" do node = @parser.parse("node foo, bar { }").code[0] node.should be_a Puppet::Parser::AST::Node node.names.length.should == 2 node.names[0].value.should == "foo" node.names[1].value.should == "bar" end it "should be able to parse a node with three names" do node = @parser.parse("node foo, bar, baz { }").code[0] node.should be_a Puppet::Parser::AST::Node node.names.length.should == 3 node.names[0].value.should == "foo" node.names[1].value.should == "bar" node.names[2].value.should == "baz" end end end diff --git a/spec/unit/provider/host/parsed_spec.rb b/spec/unit/provider/host/parsed_spec.rb old mode 100644 new mode 100755 index 5704304ba..048d77ba2 --- a/spec/unit/provider/host/parsed_spec.rb +++ b/spec/unit/provider/host/parsed_spec.rb @@ -1,204 +1,198 @@ #!/usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper') +require 'shared_behaviours/all_parsedfile_providers' require 'puppet_spec/files' -require 'puppettest/support/utils' -require 'puppettest/fileparsing' provider_class = Puppet::Type.type(:host).provider(:parsed) describe provider_class do include PuppetSpec::Files - extend PuppetTest::Support::Utils - include PuppetTest::FileParsing before do @host_class = Puppet::Type.type(:host) @provider = @host_class.provider(:parsed) @hostfile = tmpfile('hosts') @provider.any_instance.stubs(:target).returns @hostfile end after :each do @provider.initvars end def mkhost(args) hostresource = Puppet::Type::Host.new(:name => args[:name]) hostresource.stubs(:should).with(:target).returns @hostfile # Using setters of provider to build our testobject # Note: We already proved, that in case of host_aliases # the provider setter "host_aliases=(value)" will be # called with the joined array, so we just simulate that host = @provider.new(hostresource) args.each do |property,value| value = value.join(" ") if property == :host_aliases and value.is_a?(Array) host.send("#{property}=", value) end host end def genhost(host) @provider.stubs(:filetype).returns(Puppet::Util::FileType::FileTypeRam) File.stubs(:chown) File.stubs(:chmod) Puppet::Util::SUIDManager.stubs(:asuser).yields host.flush @provider.target_object(@hostfile).read end describe "when parsing a line with ip and hostname" do it "should parse an ipv4 from the first field" do @provider.parse_line("127.0.0.1 localhost")[:ip].should == "127.0.0.1" end it "should parse an ipv6 from the first field" do @provider.parse_line("::1 localhost")[:ip].should == "::1" end it "should parse the name from the second field" do @provider.parse_line("::1 localhost")[:name].should == "localhost" end it "should set an empty comment" do @provider.parse_line("::1 localhost")[:comment].should == "" end it "should set host_aliases to :absent" do @provider.parse_line("::1 localhost")[:host_aliases].should == :absent end end describe "when parsing a line with ip, hostname and comment" do before do @testline = "127.0.0.1 localhost # A comment with a #-char" end it "should parse the ip from the first field" do @provider.parse_line(@testline)[:ip].should == "127.0.0.1" end it "should parse the hostname from the second field" do @provider.parse_line(@testline)[:name].should == "localhost" end it "should parse the comment after the first '#' character" do @provider.parse_line(@testline)[:comment].should == 'A comment with a #-char' end end describe "when parsing a line with ip, hostname and aliases" do it "should parse alias from the third field" do @provider.parse_line("127.0.0.1 localhost localhost.localdomain")[:host_aliases].should == "localhost.localdomain" end it "should parse multiple aliases" do @provider.parse_line("127.0.0.1 host alias1 alias2")[:host_aliases].should == 'alias1 alias2' @provider.parse_line("127.0.0.1 host alias1\talias2")[:host_aliases].should == 'alias1 alias2' @provider.parse_line("127.0.0.1 host alias1\talias2 alias3")[:host_aliases].should == 'alias1 alias2 alias3' end end describe "when parsing a line with ip, hostname, aliases and comment" do before do # Just playing with a few different delimiters @testline = "127.0.0.1\t host alias1\talias2 alias3 # A comment with a #-char" end it "should parse the ip from the first field" do @provider.parse_line(@testline)[:ip].should == "127.0.0.1" end it "should parse the hostname from the second field" do @provider.parse_line(@testline)[:name].should == "host" end it "should parse all host_aliases from the third field" do @provider.parse_line(@testline)[:host_aliases].should == 'alias1 alias2 alias3' end it "should parse the comment after the first '#' character" do @provider.parse_line(@testline)[:comment].should == 'A comment with a #-char' end end describe "when operating on /etc/hosts like files" do - fakedata("data/providers/host/parsed","valid*").each do |file| - it "should be able to parse #{file}" do - fakedataparse(file) - end - end + it_should_behave_like "all parsedfile providers", + provider_class, my_fixtures('valid*') it "should be able to generate a simple hostfile entry" do host = mkhost( :name => 'localhost', :ip => '127.0.0.1', :ensure => :present ) genhost(host).should == "127.0.0.1\tlocalhost\n" end it "should be able to generate an entry with one alias" do host = mkhost( :name => 'localhost.localdomain', :ip => '127.0.0.1', :host_aliases => 'localhost', :ensure => :present ) genhost(host).should == "127.0.0.1\tlocalhost.localdomain\tlocalhost\n" end it "should be able to generate an entry with more than one alias" do host = mkhost( :name => 'host', :ip => '192.0.0.1', :host_aliases => [ 'a1','a2','a3','a4' ], :ensure => :present ) genhost(host).should == "192.0.0.1\thost\ta1 a2 a3 a4\n" end it "should be able to generate a simple hostfile entry with comments" do host = mkhost( :name => 'localhost', :ip => '127.0.0.1', :comment => 'Bazinga!', :ensure => :present ) genhost(host).should == "127.0.0.1\tlocalhost\t# Bazinga!\n" end it "should be able to generate an entry with one alias and a comment" do host = mkhost( :name => 'localhost.localdomain', :ip => '127.0.0.1', :host_aliases => 'localhost', :comment => 'Bazinga!', :ensure => :present ) genhost(host).should == "127.0.0.1\tlocalhost.localdomain\tlocalhost\t# Bazinga!\n" end it "should be able to generate an entry with more than one alias and a comment" do host = mkhost( :name => 'host', :ip => '192.0.0.1', :host_aliases => [ 'a1','a2','a3','a4' ], :comment => 'Bazinga!', :ensure => :present ) genhost(host).should == "192.0.0.1\thost\ta1 a2 a3 a4\t# Bazinga!\n" end end end diff --git a/spec/unit/provider/mount/parsed_spec.rb b/spec/unit/provider/mount/parsed_spec.rb index fc4df97ab..b63c0751f 100755 --- a/spec/unit/provider/mount/parsed_spec.rb +++ b/spec/unit/provider/mount/parsed_spec.rb @@ -1,192 +1,252 @@ #!/usr/bin/env ruby # # Created by Luke Kanies on 2007-9-12. # Copyright (c) 2006. All rights reserved. require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper') +require 'shared_behaviours/all_parsedfile_providers' -require 'puppettest/support/utils' -require 'puppettest/fileparsing' - -module ParsedMountTesting - include PuppetTest::Support::Utils - include PuppetTest::FileParsing - - def fake_fstab - os = Facter['operatingsystem'] - if os == "Solaris" - name = "solaris.fstab" - elsif os == "FreeBSD" - name = "freebsd.fstab" - else - # Catchall for other fstabs - name = "linux.fstab" - end - oldpath = @provider_class.default_target - fakefile(File::join("data/types/mount", name)) - end +provider_class = Puppet::Type.type(:mount).provider(:parsed) - def mkmountargs - mount = nil +describe provider_class do - if defined?(@pcount) - @pcount += 1 - else - @pcount = 1 - end - args = { - :name => "/fspuppet#{@pcount}", - :device => "/dev/dsk#{@pcount}", - } + before :each do + @mount_class = Puppet::Type.type(:mount) + @provider = @mount_class.provider(:parsed) + end - @provider_class.fields(:parsed).each do |field| - args[field] = "fake#{field}#{@pcount}" unless args.include? field - end + # LAK:FIXME I can't mock Facter because this test happens at parse-time. + it "should default to /etc/vfstab on Solaris" do + pending "This test only works on Solaris" unless Facter.value(:operatingsystem) == 'Solaris' + Puppet::Type.type(:mount).provider(:parsed).default_target.should == '/etc/vfstab' + end - args + it "should default to /etc/fstab on anything else" do + pending "This test does not work on Solaris" if Facter.value(:operatingsystem) == 'Solaris' + Puppet::Type.type(:mount).provider(:parsed).default_target.should == '/etc/fstab' end - def mkmount - hash = mkmountargs - #hash[:provider] = @provider_class.name + describe "when parsing a line" do - fakeresource = stub :type => :mount, :name => hash[:name] - fakeresource.stubs(:[]).with(:name).returns(hash[:name]) - fakeresource.stubs(:should).with(:target).returns(nil) + it "should not crash on incomplete lines in fstab" do + parse = @provider.parse <<-FSTAB +/dev/incomplete +/dev/device name +FSTAB + lambda{ @provider.to_line(parse[0]) }.should_not raise_error + end - mount = @provider_class.new(fakeresource) - hash[:record_type] = :parsed - hash[:ensure] = :present - mount.property_hash = hash +# it_should_behave_like "all parsedfile providers", +# provider_class, my_fixtures('*.fstab') - mount - end + describe "on Solaris", :if => Facter.value(:operatingsystem) == 'Solaris' do - # Here we just create a fake host type that answers to all of the methods - # but does not modify our actual system. - def mkfaketype - @provider.stubs(:filetype).returns(Puppet::Util::FileType.filetype(:ram)) - end -end + before :each do + @example_line = "/dev/dsk/c0d0s0 /dev/rdsk/c0d0s0 \t\t / \t ufs 1 no\t-" + end -provider_class = Puppet::Type.type(:mount).provider(:parsed) + it "should extract device from the first field" do + @provider.parse_line(@example_line)[:device].should == '/dev/dsk/c0d0s0' + end -describe provider_class do - before :each do - @mount_class = Puppet::Type.type(:mount) - @provider_class = @mount_class.provider(:parsed) - end + it "should extract blockdevice from second field" do + @provider.parse_line(@example_line)[:blockdevice].should == "/dev/rdsk/c0d0s0" + end + it "should extract name from third field" do + @provider.parse_line(@example_line)[:name].should == "/" + end - describe provider_class do - include ParsedMountTesting + it "should extract fstype from fourth field" do + @provider.parse_line(@example_line)[:fstype].should == "ufs" + end - it "should be able to parse all of the example mount tabs" do - tab = fake_fstab - @provider = @provider_class + it "should extract pass from fifth field" do + @provider.parse_line(@example_line)[:pass].should == "1" + end - # LAK:FIXME Again, a relatively bad test, but I don't know how to rspec-ify this. - # I suppose this is more of an integration test? I dunno. - fakedataparse(tab) do - # Now just make we've got some mounts we know will be there - hashes = @provider_class.target_records(tab).find_all { |i| i.is_a? Hash } - (hashes.length > 0).should be_true - root = hashes.find { |i| i[:name] == "/" } + it "should extract atboot from sixth field" do + @provider.parse_line(@example_line)[:atboot].should == "no" + end - proc { @provider_class.to_file(hashes) }.should_not raise_error + it "should extract options from seventh field" do + @provider.parse_line(@example_line)[:options].should == "-" end - end - # LAK:FIXME I can't mock Facter because this test happens at parse-time. - it "should default to /etc/vfstab on Solaris and /etc/fstab everywhere else" do - should = case Facter.value(:operatingsystem) - when "Solaris"; "/etc/vfstab" - else - "/etc/fstab" - end - Puppet::Type.type(:mount).provider(:parsed).default_target.should == should end - it "should not crash on incomplete lines in fstab" do - parse = @provider_class.parse <<-FSTAB -/dev/incomplete -/dev/device name - FSTAB + describe "on other platforms than Solaris", :if => Facter.value(:operatingsystem) != 'Solaris' do - lambda{ @provider_class.to_line(parse[0]) }.should_not raise_error - end - end + before :each do + @example_line = "/dev/vg00/lv01\t/spare \t \t ext3 defaults\t1 2" + end - describe provider_class, " when mounting an absent filesystem" do - include ParsedMountTesting + it "should extract device from the first field" do + @provider.parse_line(@example_line)[:device].should == '/dev/vg00/lv01' + end - # #730 - Make sure 'flush' is called when a mount is moving from absent to mounted - it "should flush the fstab to disk" do - mount = mkmount + it "should extract name from second field" do + @provider.parse_line(@example_line)[:name].should == "/spare" + end - # Mark the mount as absent - mount.property_hash[:ensure] = :absent + it "should extract fstype from third field" do + @provider.parse_line(@example_line)[:fstype].should == "ext3" + end - mount.stubs(:mountcmd) # just so we don't actually try to mount anything + it "should extract options from fourth field" do + @provider.parse_line(@example_line)[:options].should == "defaults" + end - mount.expects(:flush) - mount.mount - end - end + it "should extract dump from fifth field" do + @provider.parse_line(@example_line)[:dump].should == "1" + end - describe provider_class, " when modifying the filesystem tab" do - include ParsedMountTesting - before do - Puppet.settings.stubs(:use) - # Never write to disk, only to RAM. - #@provider_class.stubs(:filetype).returns(Puppet::Util::FileType.filetype(:ram)) - @provider_class.stubs(:target_object).returns(Puppet::Util::FileType.filetype(:ram).new("eh")) - @provider_class.clear - - @mount = mkmount - @target = @provider_class.default_target - end + it "should extract options from sixth field" do + @provider.parse_line(@example_line)[:pass].should == "2" + end - it "should write the mount to disk when :flush is called" do - old_text = @provider_class.target_object(@provider_class.default_target).read + end - @mount.flush + end - text = @provider_class.target_object(@provider_class.default_target).read - text.should == old_text + @mount.class.to_line(@mount.property_hash) + "\n" + describe "mountinstances" do + it "should get name from mountoutput found on Solaris" do + Facter.stubs(:value).with(:operatingsystem).returns 'Solaris' + @provider.stubs(:mountcmd).returns(File.read(my_fixture('solaris.mount'))) + mounts = @provider.mountinstances + mounts.size.should == 6 + mounts[0].should == { :name => '/', :mounted => :yes } + mounts[1].should == { :name => '/proc', :mounted => :yes } + mounts[2].should == { :name => '/etc/mnttab', :mounted => :yes } + mounts[3].should == { :name => '/tmp', :mounted => :yes } + mounts[4].should == { :name => '/export/home', :mounted => :yes } + mounts[5].should == { :name => '/ghost', :mounted => :yes } end - end - describe provider_class, " when parsing information about the root filesystem", :if => Facter["operatingsystem"].value != "Darwin" do - include ParsedMountTesting + it "should get name from mountoutput found on HP-UX" do + Facter.stubs(:value).with(:operatingsystem).returns 'HP-UX' + @provider.stubs(:mountcmd).returns(File.read(my_fixture('hpux.mount'))) + mounts = @provider.mountinstances + mounts.size.should == 17 + mounts[0].should == { :name => '/', :mounted => :yes } + mounts[1].should == { :name => '/devices', :mounted => :yes } + mounts[2].should == { :name => '/dev', :mounted => :yes } + mounts[3].should == { :name => '/system/contract', :mounted => :yes } + mounts[4].should == { :name => '/proc', :mounted => :yes } + mounts[5].should == { :name => '/etc/mnttab', :mounted => :yes } + mounts[6].should == { :name => '/etc/svc/volatile', :mounted => :yes } + mounts[7].should == { :name => '/system/object', :mounted => :yes } + mounts[8].should == { :name => '/etc/dfs/sharetab', :mounted => :yes } + mounts[9].should == { :name => '/lib/libc.so.1', :mounted => :yes } + mounts[10].should == { :name => '/dev/fd', :mounted => :yes } + mounts[11].should == { :name => '/tmp', :mounted => :yes } + mounts[12].should == { :name => '/var/run', :mounted => :yes } + mounts[13].should == { :name => '/export', :mounted => :yes } + mounts[14].should == { :name => '/export/home', :mounted => :yes } + mounts[15].should == { :name => '/rpool', :mounted => :yes } + mounts[16].should == { :name => '/ghost', :mounted => :yes } + end - before do - @mount = @mount_class.new :name => "/" - @provider = @mount.provider + it "should get name from mountoutput found on Darwin" do + Facter.stubs(:value).with(:operatingsystem).returns 'Darwin' + @provider.stubs(:mountcmd).returns(File.read(my_fixture('darwin.mount'))) + mounts = @provider.mountinstances + mounts.size.should == 6 + mounts[0].should == { :name => '/', :mounted => :yes } + mounts[1].should == { :name => '/dev', :mounted => :yes } + mounts[2].should == { :name => '/net', :mounted => :yes } + mounts[3].should == { :name => '/home', :mounted => :yes } + mounts[4].should == { :name => '/usr', :mounted => :yes } + mounts[5].should == { :name => '/ghost', :mounted => :yes } end - it "should have a filesystem tab" do - FileTest.should be_exist(@provider_class.default_target) + it "should get name from mountoutput found on Linux" do + Facter.stubs(:value).with(:operatingsystem).returns 'Gentoo' + @provider.stubs(:mountcmd).returns(File.read(my_fixture('linux.mount'))) + mounts = @provider.mountinstances + mounts[0].should == { :name => '/', :mounted => :yes } + mounts[1].should == { :name => '/lib64/rc/init.d', :mounted => :yes } + mounts[2].should == { :name => '/sys', :mounted => :yes } + mounts[3].should == { :name => '/usr/portage', :mounted => :yes } + mounts[4].should == { :name => '/ghost', :mounted => :yes } end - it "should find the root filesystem" do - @provider_class.prefetch("/" => @mount) - @mount.provider.property_hash[:ensure].should == :present + it "should get name from mountoutput found on AIX" do + Facter.stubs(:value).with(:operatingsystem).returns 'AIX' + @provider.stubs(:mountcmd).returns(File.read(my_fixture('aix.mount'))) + mounts = @provider.mountinstances + mounts[0].should == { :name => '/', :mounted => :yes } + mounts[1].should == { :name => '/tmp', :mounted => :yes } + mounts[2].should == { :name => '/home', :mounted => :yes } + mounts[3].should == { :name => '/usr', :mounted => :yes } + mounts[4].should == { :name => '/usr/code', :mounted => :yes } end - it "should determine that the root fs is mounted" do - @provider_class.prefetch("/" => @mount) - @mount.provider.should be_mounted + it "should raise an error if a line is not understandable" do + @provider.stubs(:mountcmd).returns("bazinga!") + lambda { @provider.mountinstances }.should raise_error Puppet::Error end + end - describe provider_class, " when mounting and unmounting" do - include ParsedMountTesting + it "should support AIX's paragraph based /etc/filesystems" - it "should call the 'mount' command to mount the filesystem" + my_fixtures('*.fstab').each do |fstab| + platform = File.basename(fstab, '.fstab') + describe "when prefetching on #{platform}" do + before :each do + if Facter[:operatingsystem] == "Solaris" then + platform == 'solaris' or + pending "We need to stub the operatingsystem fact at load time, but can't" + else + platform != 'solaris' or + pending "We need to stub the operatingsystem fact at load time, but can't" + end + + # Stub the mount output to our fixture. + begin + mount = my_fixture(platform + '.mount') + @provider.stubs(:mountcmd).returns File.read(mount) + rescue + pending "is #{platform}.mount missing at this point?" + end - it "should call the 'unmount' command to unmount the filesystem" + # Note: we have to stub default_target before creating resources + # because it is used by Puppet::Type::Mount.new to populate the + # :target property. + @provider.stubs(:default_target).returns fstab + + @res_ghost = Puppet::Type::Mount.new(:name => '/ghost') # in no fake fstab + @res_mounted = Puppet::Type::Mount.new(:name => '/') # in every fake fstab + @res_unmounted = Puppet::Type::Mount.new(:name => '/boot') # in every fake fstab + @res_absent = Puppet::Type::Mount.new(:name => '/absent') # in no fake fstab + + # Simulate transaction.rb:prefetch + @resource_hash = {} + [@res_ghost, @res_mounted, @res_unmounted, @res_absent].each do |resource| + @resource_hash[resource.name] = resource + end + end - it "should specify the filesystem when remounting a filesystem" + it "should set :ensure to :unmounted if found in fstab but not mounted" do + @provider.prefetch(@resource_hash) + @res_unmounted.provider.get(:ensure).should == :unmounted + end + + it "should set :ensure to :ghost if not found in fstab but mounted" do + @provider.prefetch(@resource_hash) + @res_ghost.provider.get(:ensure).should == :ghost + end + + it "should set :ensure to :mounted if found in fstab and mounted" do + @provider.prefetch(@resource_hash) + @res_mounted.provider.get(:ensure).should == :mounted + end + + it "should set :ensure to :absent if not found in fstab and not mounted" do + @provider.prefetch(@resource_hash) + @res_absent.provider.get(:ensure).should == :absent + end + end end end diff --git a/spec/unit/provider/mount_spec.rb b/spec/unit/provider/mount_spec.rb index 256295574..9cadfc403 100755 --- a/spec/unit/provider/mount_spec.rb +++ b/spec/unit/provider/mount_spec.rb @@ -1,145 +1,146 @@ #!/usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') require 'puppet/provider/mount' describe Puppet::Provider::Mount do before :each do @mounter = Object.new @mounter.extend(Puppet::Provider::Mount) @name = "/" @resource = stub 'resource' @resource.stubs(:[]).with(:name).returns(@name) @mounter.stubs(:resource).returns(@resource) end describe Puppet::Provider::Mount, " when mounting" do - it "should use the 'mountcmd' method to mount" do - @mounter.stubs(:options).returns(nil) - @mounter.expects(:mountcmd) - - @mounter.mount + before :each do + @mounter.stubs(:get).with(:ensure).returns(:mounted) end - it "should flush before mounting if a flush method exists" do - @mounter.meta_def(:flush) { } - @mounter.expects(:flush) - @mounter.stubs(:mountcmd) + it "should use the 'mountcmd' method to mount" do @mounter.stubs(:options).returns(nil) + @mounter.expects(:mountcmd) @mounter.mount end it "should add the options following '-o' if they exist and are not set to :absent" do @mounter.stubs(:options).returns("ro") @mounter.expects(:mountcmd).with { |*ary| ary[0] == "-o" and ary[1] == "ro" } @mounter.mount end it "should specify the filesystem name to the mount command" do @mounter.stubs(:options).returns(nil) @mounter.expects(:mountcmd).with { |*ary| ary[-1] == @name } @mounter.mount end + + it "should update the :ensure state to :mounted if it was :unmounted before" do + @mounter.expects(:mountcmd) + @mounter.stubs(:options).returns(nil) + @mounter.expects(:get).with(:ensure).returns(:unmounted) + @mounter.expects(:set).with(:ensure => :mounted) + @mounter.mount + end + + it "should update the :ensure state to :ghost if it was :absent before" do + @mounter.expects(:mountcmd) + @mounter.stubs(:options).returns(nil) + @mounter.expects(:get).with(:ensure).returns(:absent) + @mounter.expects(:set).with(:ensure => :ghost) + @mounter.mount + end + end describe Puppet::Provider::Mount, " when remounting" do it "should use '-o remount' if the resource specifies it supports remounting" do @mounter.stubs(:info) @resource.stubs(:[]).with(:remounts).returns(:true) @mounter.expects(:mountcmd).with("-o", "remount", @name) @mounter.remount end it "should unmount and mount if the resource does not specify it supports remounting" do @mounter.stubs(:info) @resource.stubs(:[]).with(:remounts).returns(false) @mounter.expects(:unmount) @mounter.expects(:mount) @mounter.remount end it "should log that it is remounting" do @resource.stubs(:[]).with(:remounts).returns(:true) @mounter.stubs(:mountcmd) @mounter.expects(:info).with("Remounting") @mounter.remount end end describe Puppet::Provider::Mount, " when unmounting" do + before :each do + @mounter.stubs(:get).with(:ensure).returns(:unmounted) + end + it "should call the :umount command with the resource name" do @mounter.expects(:umount).with(@name) @mounter.unmount end - end - - describe Puppet::Provider::Mount, " when determining if it is mounted" do - - it "should parse the results of running the mount command with no arguments" do - Facter.stubs(:value).returns("whatever") - @mounter.expects(:mountcmd).returns("") - @mounter.mounted? + it "should update the :ensure state to :absent if it was :ghost before" do + @mounter.expects(:umount).with(@name).returns true + @mounter.expects(:get).with(:ensure).returns(:ghost) + @mounter.expects(:set).with(:ensure => :absent) + @mounter.unmount end - it "should match ' on /private/var/automount' if the operating system is Darwin" do - Facter.stubs(:value).with("operatingsystem").returns("Darwin") - @mounter.expects(:mountcmd).returns("/dev/whatever on /private/var/automount/\ndevfs on /dev") - - @mounter.should be_mounted + it "should update the :ensure state to :unmounted if it was :mounted before" do + @mounter.expects(:umount).with(@name).returns true + @mounter.expects(:get).with(:ensure).returns(:mounted) + @mounter.expects(:set).with(:ensure => :unmounted) + @mounter.unmount end - it "should match ' on ' if the operating system is Darwin" do - Facter.stubs(:value).with("operatingsystem").returns("Darwin") - @mounter.expects(:mountcmd).returns("/dev/disk03 on / (local, journaled)\ndevfs on /dev") - - @mounter.should be_mounted - end + end - it "should match '^ on' if the operating system is Solaris" do - Facter.stubs(:value).with("operatingsystem").returns("Solaris") - @mounter.expects(:mountcmd).returns("/ on /dev/dsk/whatever\n/var on /dev/dsk/other") + describe Puppet::Provider::Mount, " when determining if it is mounted" do - @mounter.should be_mounted + it "should query the property_hash" do + @mounter.expects(:get).with(:ensure).returns(:mounted) + @mounter.mounted? end - it "should match '^ on' if the operating system is HP-UX" do - Facter.stubs(:value).with("operatingsystem").returns("HP-UX") - @mounter.expects(:mountcmd).returns("/ on /dev/dsk/whatever\n/var on /dev/dsk/other") - - @mounter.should be_mounted + it "should return true if prefetched value is :mounted" do + @mounter.stubs(:get).with(:ensure).returns(:mounted) + @mounter.mounted? == true end - it "should match mounted devices if the operating system is AIX" do - Facter.stubs(:value).with("operatingsystem").returns("AIX") - mount_data = File.read(File.join(File.dirname(__FILE__), '..', '..', 'fixtures', 'unit', 'provider', 'mount', 'mount-output.aix.txt')) - @mounter.expects(:mountcmd).returns(mount_data) - - @mounter.should be_mounted + it "should return true if prefetched value is :ghost" do + @mounter.stubs(:get).with(:ensure).returns(:ghost) + @mounter.mounted? == true end - it "should match ' on ' if the operating system is not Darwin, Solaris, or HP-UX" do - Facter.stubs(:value).with("operatingsystem").returns("Debian") - @mounter.expects(:mountcmd).returns("/dev/dsk/whatever on / and stuff\n/dev/other/disk on /var and stuff") - - @mounter.should be_mounted + it "should return false if prefetched value is :absent" do + @mounter.stubs(:get).with(:ensure).returns(:absent) + @mounter.mounted? == false end - it "should not be considered mounted if it did not match the mount output" do - Facter.stubs(:value).with("operatingsystem").returns("Debian") - @mounter.expects(:mountcmd).returns("/dev/dsk/whatever on /something/else and stuff\n/dev/other/disk on /var and stuff") - - @mounter.should_not be_mounted + it "should return false if prefetched value is :unmounted" do + @mounter.stubs(:get).with(:ensure).returns(:unmounted) + @mounter.mounted? == false end + end + end diff --git a/spec/unit/provider/ssh_authorized_key/parsed_spec.rb b/spec/unit/provider/ssh_authorized_key/parsed_spec.rb index fb4c64926..3ac57facc 100755 --- a/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +++ b/spec/unit/provider/ssh_authorized_key/parsed_spec.rb @@ -1,229 +1,212 @@ #!/usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper') - +require 'shared_behaviours/all_parsedfile_providers' require 'puppet_spec/files' -require 'puppettest/support/utils' -require 'puppettest/fileparsing' -require 'puppettest/fakes' provider_class = Puppet::Type.type(:ssh_authorized_key).provider(:parsed) describe provider_class do include PuppetSpec::Files - extend PuppetTest::Support::Utils - include PuppetTest - include PuppetTest::FileParsing before :each do @sshauthkey_class = Puppet::Type.type(:ssh_authorized_key) @provider = @sshauthkey_class.provider(:parsed) @keyfile = tmpfile('authorized_keys') @provider.any_instance.stubs(:target).returns @keyfile @user = 'random_bob' Puppet::Util.stubs(:uid).with(@user).returns 12345 end after :each do @provider.initvars end def mkkey(args) - fakeresource = fakeresource(:ssh_authorized_key, args[:name]) - fakeresource.stubs(:should).with(:user).returns @user - fakeresource.stubs(:should).with(:target).returns @keyfile - - key = @provider.new(fakeresource) + args[:target] = @keyfile + args[:user] = @user + resource = Puppet::Type.type(:ssh_authorized_key).new(args) + key = @provider.new(resource) args.each do |p,v| key.send(p.to_s + "=", v) end - key end def genkey(key) @provider.stubs(:filetype).returns(Puppet::Util::FileType::FileTypeRam) File.stubs(:chown) File.stubs(:chmod) Puppet::Util::SUIDManager.stubs(:asuser).yields key.flush @provider.target_object(@keyfile).read end - fakedata("data/providers/ssh_authorized_key/parsed").each { |file| - it "should be able to parse example data in #{file}" do - fakedataparse(file) - end - } + it_should_behave_like "all parsedfile providers", provider_class it "should be able to generate a basic authorized_keys file" do - key = mkkey( - { - :name => "Just Testing", - :key => "AAAAfsfddsjldjgksdflgkjsfdlgkj", - :type => "ssh-dss", - :ensure => :present, - - :options => [:absent] - }) + key = mkkey(:name => "Just Testing", + :key => "AAAAfsfddsjldjgksdflgkjsfdlgkj", + :type => "ssh-dss", + :ensure => :present, + :options => [:absent] + ) genkey(key).should == "ssh-dss AAAAfsfddsjldjgksdflgkjsfdlgkj Just Testing\n" end it "should be able to generate a authorized_keys file with options" do - key = mkkey( - { - :name => "root@localhost", - :key => "AAAAfsfddsjldjgksdflgkjsfdlgkj", - :type => "ssh-rsa", - :ensure => :present, - - :options => ['from="192.168.1.1"', "no-pty", "no-X11-forwarding"] - }) + key = mkkey(:name => "root@localhost", + :key => "AAAAfsfddsjldjgksdflgkjsfdlgkj", + :type => "ssh-rsa", + :ensure => :present, + :options => ['from="192.168.1.1"', "no-pty", "no-X11-forwarding"] + ) genkey(key).should == "from=\"192.168.1.1\",no-pty,no-X11-forwarding ssh-rsa AAAAfsfddsjldjgksdflgkjsfdlgkj root@localhost\n" end it "should be able to parse options containing commas via its parse_options method" do options = %w{from="host1.reductlivelabs.com,host.reductivelabs.com" command="/usr/local/bin/run" ssh-pty} optionstr = options.join(", ") @provider.parse_options(optionstr).should == options end it "should use '' as name for entries that lack a comment" do line = "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAut8aOSxenjOqF527dlsdHWV4MNoAsX14l9M297+SQXaQ5Z3BedIxZaoQthkDALlV/25A1COELrg9J2MqJNQc8Xe9XQOIkBQWWinUlD/BXwoOTWEy8C8zSZPHZ3getMMNhGTBO+q/O+qiJx3y5cA4MTbw2zSxukfWC87qWwcZ64UUlegIM056vPsdZWFclS9hsROVEa57YUMrehQ1EGxT4Z5j6zIopufGFiAPjZigq/vqgcAqhAKP6yu4/gwO6S9tatBeEjZ8fafvj1pmvvIplZeMr96gHE7xS3pEEQqnB3nd4RY7AF6j9kFixnsytAUO7STPh/M3pLiVQBN89TvWPQ==" @provider.parse(line)[0][:name].should == "" end end describe provider_class do before :each do @resource = stub("resource", :name => "foo") @resource.stubs(:[]).returns "foo" + @resource.class.stubs(:key_attributes).returns( [:name] ) @provider = provider_class.new(@resource) provider_class.stubs(:filetype).returns(Puppet::Util::FileType::FileTypeRam) Puppet::Util::SUIDManager.stubs(:asuser).yields end describe "when flushing" do before :each do # Stub file and directory operations Dir.stubs(:mkdir) File.stubs(:chmod) File.stubs(:chown) end describe "and both a user and a target have been specified" do before :each do Puppet::Util.stubs(:uid).with("random_bob").returns 12345 @resource.stubs(:should).with(:user).returns "random_bob" target = "/tmp/.ssh_dir/place_to_put_authorized_keys" @resource.stubs(:should).with(:target).returns target end it "should create the directory" do File.stubs(:exist?).with("/tmp/.ssh_dir").returns false Dir.expects(:mkdir).with("/tmp/.ssh_dir", 0700) @provider.flush end it "should chown the directory to the user" do uid = Puppet::Util.uid("random_bob") File.expects(:chown).with(uid, nil, "/tmp/.ssh_dir") @provider.flush end it "should chown the key file to the user" do uid = Puppet::Util.uid("random_bob") File.expects(:chown).with(uid, nil, "/tmp/.ssh_dir/place_to_put_authorized_keys") @provider.flush end it "should chmod the key file to 0600" do File.expects(:chmod).with(0600, "/tmp/.ssh_dir/place_to_put_authorized_keys") @provider.flush end end describe "and a user has been specified with no target" do before :each do @resource.stubs(:should).with(:user).returns "nobody" @resource.stubs(:should).with(:target).returns nil # # I'd like to use random_bob here and something like # # File.stubs(:expand_path).with("~random_bob/.ssh").returns "/users/r/random_bob/.ssh" # # but mocha objects strenuously to stubbing File.expand_path # so I'm left with using nobody. @dir = File.expand_path("~nobody/.ssh") end it "should create the directory if it doesn't exist" do File.stubs(:exist?).with(@dir).returns false Dir.expects(:mkdir).with(@dir,0700) @provider.flush end it "should not create or chown the directory if it already exist" do File.stubs(:exist?).with(@dir).returns false Dir.expects(:mkdir).never @provider.flush end it "should chown the directory to the user if it creates it" do File.stubs(:exist?).with(@dir).returns false Dir.stubs(:mkdir).with(@dir,0700) uid = Puppet::Util.uid("nobody") File.expects(:chown).with(uid, nil, @dir) @provider.flush end it "should not create or chown the directory if it already exist" do File.stubs(:exist?).with(@dir).returns false Dir.expects(:mkdir).never File.expects(:chown).never @provider.flush end it "should chown the key file to the user" do uid = Puppet::Util.uid("nobody") File.expects(:chown).with(uid, nil, File.expand_path("~nobody/.ssh/authorized_keys")) @provider.flush end it "should chmod the key file to 0600" do File.expects(:chmod).with(0600, File.expand_path("~nobody/.ssh/authorized_keys")) @provider.flush end end describe "and a target has been specified with no user" do before :each do @resource.stubs(:should).with(:user).returns nil @resource.stubs(:should).with(:target).returns("/tmp/.ssh_dir/place_to_put_authorized_keys") end it "should raise an error" do proc { @provider.flush }.should raise_error end end describe "and a invalid user has been specified with no target" do before :each do @resource.stubs(:should).with(:user).returns "thisusershouldnotexist" @resource.stubs(:should).with(:target).returns nil end it "should catch an exception and raise a Puppet error" do lambda { @provider.flush }.should raise_error(Puppet::Error) end end end end diff --git a/spec/unit/provider/user/user_role_add_spec.rb b/spec/unit/provider/user/user_role_add_spec.rb index 9cd0feb12..12a71d25a 100644 --- a/spec/unit/provider/user/user_role_add_spec.rb +++ b/spec/unit/provider/user/user_role_add_spec.rb @@ -1,266 +1,267 @@ #!/usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper') provider_class = Puppet::Type.type(:user).provider(:user_role_add) describe provider_class do before do @resource = stub("resource", :name => "myuser", :managehome? => nil) @resource.stubs(:should).returns "fakeval" @resource.stubs(:[]).returns "fakeval" @resource.stubs(:allowdupe?).returns false @provider = provider_class.new(@resource) end describe "when calling command" do before do klass = stub("provider") klass.stubs(:command).with(:foo).returns("userfoo") klass.stubs(:command).with(:role_foo).returns("rolefoo") @provider.stubs(:class).returns(klass) end it "should use the command if not a role and ensure!=role" do @provider.stubs(:is_role?).returns(false) @provider.stubs(:exists?).returns(false) @resource.stubs(:[]).with(:ensure).returns(:present) @provider.command(:foo).should == "userfoo" end it "should use the role command when a role" do @provider.stubs(:is_role?).returns(true) @provider.command(:foo).should == "rolefoo" end it "should use the role command when !exists and ensure=role" do @provider.stubs(:is_role?).returns(false) @provider.stubs(:exists?).returns(false) @resource.stubs(:[]).with(:ensure).returns(:role) @provider.command(:foo).should == "rolefoo" end end describe "when calling transition" do it "should return the type set to whatever is passed in" do @provider.expects(:command).with(:modify).returns("foomod") @provider.transition("bar").include?("type=bar") end end describe "when calling create" do before do @provider.stubs(:password=) end it "should use the add command when the user is not a role" do @provider.stubs(:is_role?).returns(false) @provider.expects(:addcmd).returns("useradd") @provider.expects(:run).at_least_once @provider.create end it "should use transition(normal) when the user is a role" do @provider.stubs(:is_role?).returns(true) @provider.expects(:transition).with("normal") @provider.expects(:run) @provider.create end it "should set password age rules" do @resource = Puppet::Type.type(:user).new :name => "myuser", :password_min_age => 5, :password_max_age => 10, :provider => :user_role_add @provider = provider_class.new(@resource) @provider.stubs(:user_attributes) @provider.stubs(:execute) @provider.expects(:execute).with { |cmd, *args| args == ["-n", 5, "-x", 10, "myuser"] } @provider.create end end describe "when calling destroy" do it "should use the delete command if the user exists and is not a role" do @provider.stubs(:exists?).returns(true) @provider.stubs(:is_role?).returns(false) @provider.expects(:deletecmd) @provider.expects(:run) @provider.destroy end it "should use the delete command if the user is a role" do @provider.stubs(:exists?).returns(true) @provider.stubs(:is_role?).returns(true) @provider.expects(:deletecmd) @provider.expects(:run) @provider.destroy end end describe "when calling create_role" do it "should use the transition(role) if the user exists" do @provider.stubs(:exists?).returns(true) @provider.stubs(:is_role?).returns(false) @provider.expects(:transition).with("role") @provider.expects(:run) @provider.create_role end it "should use the add command when role doesn't exists" do @provider.stubs(:exists?).returns(false) @provider.expects(:addcmd) @provider.expects(:run) @provider.create_role end end describe "when allow duplicate is enabled" do before do @resource.expects(:allowdupe?).returns true + @resource.stubs(:system?) @provider.stubs(:is_role?).returns(false) @provider.stubs(:execute) @provider.expects(:execute).with { |args| args.include?("-o") } end it "should add -o when the user is being created" do @provider.stubs(:password=) @provider.create end it "should add -o when the uid is being modified" do @provider.uid = 150 end end [:roles, :auths, :profiles].each do |val| describe "when getting #{val}" do it "should get the user_attributes" do @provider.expects(:user_attributes) @provider.send(val) end it "should get the #{val} attribute" do attributes = mock("attributes") attributes.expects(:[]).with(val) @provider.stubs(:user_attributes).returns(attributes) @provider.send(val) end end end describe "when getting the keys" do it "should get the user_attributes" do @provider.expects(:user_attributes) @provider.keys end it "should call removed_managed_attributes" do @provider.stubs(:user_attributes).returns({ :type => "normal", :foo => "something" }) @provider.expects(:remove_managed_attributes) @provider.keys end it "should removed managed attribute (type, auths, roles, etc)" do @provider.stubs(:user_attributes).returns({ :type => "normal", :foo => "something" }) @provider.keys.should == { :foo => "something" } end end describe "when adding properties" do it "should call build_keys_cmd" do @resource.stubs(:should).returns "" @resource.expects(:should).with(:keys).returns({ :foo => "bar" }) @provider.expects(:build_keys_cmd).returns([]) @provider.add_properties end it "should add the elements of the keys hash to an array" do @resource.stubs(:should).returns "" @resource.expects(:should).with(:keys).returns({ :foo => "bar"}) @provider.add_properties.must == ["-K", "foo=bar"] end end describe "when calling build_keys_cmd" do it "should build cmd array with keypairs seperated by -K ending with user" do @provider.build_keys_cmd({"foo" => "bar", "baz" => "boo"}).should.eql? ["-K", "foo=bar", "-K", "baz=boo"] end end describe "when setting the keys" do before do @provider.stubs(:is_role?).returns(false) end it "should run a command" do @provider.expects(:run) @provider.keys=({}) end it "should build the command" do @resource.stubs(:[]).with(:name).returns("someuser") @provider.stubs(:command).returns("usermod") @provider.expects(:build_keys_cmd).returns(["-K", "foo=bar"]) @provider.expects(:run).with(["usermod", "-K", "foo=bar", "someuser"], "modify attribute key pairs") @provider.keys=({}) end end describe "when getting the hashed password" do before do @array = mock "array" end it "should readlines of /etc/shadow" do File.expects(:readlines).with("/etc/shadow").returns([]) @provider.password end it "should reject anything that doesn't start with alpha numerics" do @array.expects(:reject).returns([]) File.stubs(:readlines).with("/etc/shadow").returns(@array) @provider.password end it "should collect splitting on ':'" do @array.stubs(:reject).returns(@array) @array.expects(:collect).returns([]) File.stubs(:readlines).with("/etc/shadow").returns(@array) @provider.password end it "should find the matching user" do @resource.stubs(:[]).with(:name).returns("username") @array.stubs(:reject).returns(@array) @array.stubs(:collect).returns([["username", "hashedpassword"], ["someoneelse", "theirpassword"]]) File.stubs(:readlines).with("/etc/shadow").returns(@array) @provider.password.must == "hashedpassword" end it "should get the right password" do @resource.stubs(:[]).with(:name).returns("username") File.stubs(:readlines).with("/etc/shadow").returns(["#comment", " nonsense", " ", "username:hashedpassword:stuff:foo:bar:::", "other:pword:yay:::"]) @provider.password.must == "hashedpassword" end end describe "when setting the password" do #how can you mock these blocks up? it "should open /etc/shadow for reading and /etc/shadow_tmp for writing" do File.expects(:open).with("/etc/shadow", "r") File.stubs(:rename) @provider.password=("hashedpassword") end it "should rename the /etc/shadow_tmp to /etc/shadow" do File.stubs(:open).with("/etc/shadow", "r") File.expects(:rename).with("/etc/shadow_tmp", "/etc/shadow") @provider.password=("hashedpassword") end end describe "#shadow_entry" do it "should return the line for the right user" do File.stubs(:readlines).returns(["someuser:!:10:5:20:7:1::\n", "fakeval:*:20:10:30:7:2::\n", "testuser:*:30:15:40:7:3::\n"]) @provider.shadow_entry.should == ["fakeval", "*", "20", "10", "30", "7", "2"] end end end diff --git a/spec/unit/provider/user/useradd_spec.rb b/spec/unit/provider/user/useradd_spec.rb index f9babe6aa..b1719eeaf 100755 --- a/spec/unit/provider/user/useradd_spec.rb +++ b/spec/unit/provider/user/useradd_spec.rb @@ -1,176 +1,216 @@ #!/usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper') provider_class = Puppet::Type.type(:user).provider(:useradd) describe provider_class do before do @resource = stub("resource", :name => "myuser", :managehome? => nil) @resource.stubs(:should).returns "fakeval" @resource.stubs(:[]).returns "fakeval" @provider = provider_class.new(@resource) end # #1360 it "should add -o when allowdupe is enabled and the user is being created" do @resource.expects(:allowdupe?).returns true + @resource.expects(:system?).returns true @provider.stubs(:execute) @provider.expects(:execute).with { |args| args.include?("-o") } @provider.create end it "should add -o when allowdupe is enabled and the uid is being modified" do @resource.expects(:allowdupe?).returns true @provider.expects(:execute).with { |args| args.include?("-o") } @provider.uid = 150 end + it "should add -r when system is enabled" do + @resource.expects(:allowdupe?).returns true + @resource.expects(:system?).returns true + @provider.stubs(:execute) + @provider.expects(:execute).with { |args| args.include?("-r") } + @provider.create + end + it "should set password age rules" do provider_class.has_feature :manages_password_age @resource = Puppet::Type.type(:user).new :name => "myuser", :password_min_age => 5, :password_max_age => 10, :provider => :useradd @provider = provider_class.new(@resource) @provider.stubs(:execute) @provider.expects(:execute).with { |cmd, *args| args == ["-m", 5, "-M", 10, "myuser"] } @provider.create end describe "when checking to add allow dup" do it "should check allow dup" do @resource.expects(:allowdupe?) @provider.check_allow_dup end it "should return an array with a flag if dup is allowed" do @resource.stubs(:allowdupe?).returns true @provider.check_allow_dup.must == ["-o"] end it "should return an empty array if no dup is allowed" do @resource.stubs(:allowdupe?).returns false @provider.check_allow_dup.must == [] end end + describe "when checking to add system users" do + it "should check system users" do + @resource.expects(:system?) + @provider.check_system_users + end + + it "should return an array with a flag if it's a system user" do + @resource.stubs(:system?).returns true + @provider.check_system_users.must == ["-r"] + end + + it "should return an empty array if it's not a system user" do + @resource.stubs(:system?).returns false + @provider.check_system_users.must == [] + end + end + describe "when checking manage home" do it "should check manage home" do @resource.expects(:managehome?) @provider.check_manage_home end it "should return an array with -m flag if home is managed" do @resource.stubs(:managehome?).returns true @provider.check_manage_home.must == ["-m"] end it "should return an array with -M if home is not managed and on Redhat" do Facter.stubs(:value).with("operatingsystem").returns("RedHat") @resource.stubs(:managehome?).returns false @provider.check_manage_home.must == ["-M"] end it "should return an empty array if home is not managed and not on Redhat" do Facter.stubs(:value).with("operatingsystem").returns("some OS") @resource.stubs(:managehome?).returns false @provider.check_manage_home.must == [] end end describe "when adding properties" do it "should get the valid properties" it "should not add the ensure property" it "should add the flag and value to an array" it "should return and array of flags and values" end describe "when calling addcmd" do before do @resource.stubs(:allowdupe?).returns true @resource.stubs(:managehome?).returns true + @resource.stubs(:system?).returns true end it "should call command with :add" do @provider.expects(:command).with(:add) @provider.addcmd end it "should add properties" do @provider.expects(:add_properties).returns([]) @provider.addcmd end it "should check and add if dup allowed" do @provider.expects(:check_allow_dup).returns([]) @provider.addcmd end it "should check and add if home is managed" do @provider.expects(:check_manage_home).returns([]) @provider.addcmd end it "should add the resource :name" do @resource.expects(:[]).with(:name) @provider.addcmd end + it "should return an array with -r if system? is true" do + resource = Puppet::Type.type(:user).new( :name => "bob", :system => true) + + provider_class.new( resource ).addcmd.should include("-r") + end + + it "should return an array without -r if system? is false" do + resource = Puppet::Type.type(:user).new( :name => "bob", :system => false) + + provider_class.new( resource ).addcmd.should_not include("-r") + end + it "should return an array with full command" do @provider.stubs(:command).with(:add).returns("useradd") @provider.stubs(:add_properties).returns(["-G", "somegroup"]) @resource.stubs(:[]).with(:name).returns("someuser") @resource.stubs(:[]).with(:expiry).returns("somedate") - @provider.addcmd.must == ["useradd", "-G", "somegroup", "-o", "-m", '-e somedate', "someuser"] + @provider.addcmd.must == ["useradd", "-G", "somegroup", "-o", "-m", '-e somedate', "-r", "someuser"] end - it "should return an array without -e if expery is undefined full command" do + it "should return an array without -e if expiry is undefined full command" do @provider.stubs(:command).with(:add).returns("useradd") @provider.stubs(:add_properties).returns(["-G", "somegroup"]) @resource.stubs(:[]).with(:name).returns("someuser") @resource.stubs(:[]).with(:expiry).returns nil - @provider.addcmd.must == ["useradd", "-G", "somegroup", "-o", "-m", "someuser"] + @provider.addcmd.must == ["useradd", "-G", "somegroup", "-o", "-m", "-r", "someuser"] end end describe "when calling passcmd" do before do @resource.stubs(:allowdupe?).returns true @resource.stubs(:managehome?).returns true + @resource.stubs(:system?).returns true end it "should call command with :pass" do @provider.expects(:command).with(:password) @provider.passcmd end it "should return nil if neither min nor max is set" do @resource.stubs(:should).with(:password_min_age).returns nil @resource.stubs(:should).with(:password_max_age).returns nil @provider.passcmd.must == nil end it "should return a chage command array with -m and the user name if password_min_age is set" do @provider.stubs(:command).with(:password).returns("chage") @resource.stubs(:[]).with(:name).returns("someuser") @resource.stubs(:should).with(:password_min_age).returns 123 @resource.stubs(:should).with(:password_max_age).returns nil @provider.passcmd.must == ['chage','-m',123,'someuser'] end it "should return a chage command array with -M if password_max_age is set" do @provider.stubs(:command).with(:password).returns("chage") @resource.stubs(:[]).with(:name).returns("someuser") @resource.stubs(:should).with(:password_min_age).returns nil @resource.stubs(:should).with(:password_max_age).returns 999 @provider.passcmd.must == ['chage','-M',999,'someuser'] end it "should return a chage command array with -M -m if both password_min_age and password_max_age are set" do @provider.stubs(:command).with(:password).returns("chage") @resource.stubs(:[]).with(:name).returns("someuser") @resource.stubs(:should).with(:password_min_age).returns 123 @resource.stubs(:should).with(:password_max_age).returns 999 @provider.passcmd.must == ['chage','-m',123,'-M',999,'someuser'] end end end diff --git a/spec/unit/provider/zpool/solaris_spec.rb b/spec/unit/provider/zpool/solaris_spec.rb index 805dd54df..e2a0e16c8 100755 --- a/spec/unit/provider/zpool/solaris_spec.rb +++ b/spec/unit/provider/zpool/solaris_spec.rb @@ -1,179 +1,209 @@ #!/usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper') provider_class = Puppet::Type.type(:zpool).provider(:solaris) describe provider_class do before do @resource = stub("resource", :name => "mypool") @resource.stubs(:[]).returns "shouldvalue" @provider = provider_class.new(@resource) end describe "when getting the instance" do it "should call process_zpool_data with the result of get_pool_data only once" do @provider.stubs(:get_pool_data).returns(["foo", "disk"]) @provider.expects(:process_zpool_data).with(["foo", "disk"]).returns("stuff").once @provider.current_pool @provider.current_pool end end describe "when calling flush" do it "should need to reload the pool" do @provider.stubs(:get_pool_data) @provider.expects(:process_zpool_data).returns("stuff").times(2) @provider.current_pool @provider.flush @provider.current_pool end end describe "when procesing zpool data" do before do @zpool_data = ["foo", "disk"] end describe "when there is no data" do it "should return a hash with ensure=>:absent" do @provider.process_zpool_data([])[:ensure].should == :absent end end describe "when there is a spare" do it "should add the spare disk to the hash" do @zpool_data += ["spares", "spare_disk"] @provider.process_zpool_data(@zpool_data)[:spare].should == ["spare_disk"] end end describe "when there are two spares" do it "should add the spare disk to the hash as a single string" do @zpool_data += ["spares", "spare_disk", "spare_disk2"] @provider.process_zpool_data(@zpool_data)[:spare].should == ["spare_disk spare_disk2"] end end describe "when there is a log" do it "should add the log disk to the hash" do @zpool_data += ["logs", "log_disk"] @provider.process_zpool_data(@zpool_data)[:log].should == ["log_disk"] end end describe "when there are two logs" do it "should add the log disks to the hash as a single string" do @zpool_data += ["spares", "spare_disk", "spare_disk2"] @provider.process_zpool_data(@zpool_data)[:spare].should == ["spare_disk spare_disk2"] end end describe "when the vdev is a single mirror" do it "should call create_multi_array with mirror" do @zpool_data = ["mirrorpool", "mirror", "disk1", "disk2"] @provider.process_zpool_data(@zpool_data)[:mirror].should == ["disk1 disk2"] end end + describe "when the vdev is a single mirror on solaris 10u9 or later" do + it "should call create_multi_array with mirror" do + @zpool_data = ["mirrorpool", "mirror-0", "disk1", "disk2"] + @provider.process_zpool_data(@zpool_data)[:mirror].should == ["disk1 disk2"] + end + end + describe "when the vdev is a double mirror" do it "should call create_multi_array with mirror" do @zpool_data = ["mirrorpool", "mirror", "disk1", "disk2", "mirror", "disk3", "disk4"] @provider.process_zpool_data(@zpool_data)[:mirror].should == ["disk1 disk2", "disk3 disk4"] end end + describe "when the vdev is a double mirror on solaris 10u9 or later" do + it "should call create_multi_array with mirror" do + @zpool_data = ["mirrorpool", "mirror-0", "disk1", "disk2", "mirror-1", "disk3", "disk4"] + @provider.process_zpool_data(@zpool_data)[:mirror].should == ["disk1 disk2", "disk3 disk4"] + end + end + describe "when the vdev is a raidz1" do it "should call create_multi_array with raidz1" do @zpool_data = ["mirrorpool", "raidz1", "disk1", "disk2"] @provider.process_zpool_data(@zpool_data)[:raidz].should == ["disk1 disk2"] end end + describe "when the vdev is a raidz1 on solaris 10u9 or later" do + it "should call create_multi_array with raidz1" do + @zpool_data = ["mirrorpool", "raidz1-0", "disk1", "disk2"] + @provider.process_zpool_data(@zpool_data)[:raidz].should == ["disk1 disk2"] + end + end + describe "when the vdev is a raidz2" do it "should call create_multi_array with raidz2 and set the raid_parity" do @zpool_data = ["mirrorpool", "raidz2", "disk1", "disk2"] pool = @provider.process_zpool_data(@zpool_data) pool[:raidz].should == ["disk1 disk2"] pool[:raid_parity].should == "raidz2" end end + + describe "when the vdev is a raidz2 on solaris 10u9 or later" do + it "should call create_multi_array with raidz2 and set the raid_parity" do + @zpool_data = ["mirrorpool", "raidz2-0", "disk1", "disk2"] + pool = @provider.process_zpool_data(@zpool_data) + pool[:raidz].should == ["disk1 disk2"] + pool[:raid_parity].should == "raidz2" + end + end end describe "when calling the getters and setters" do [:disk, :mirror, :raidz, :log, :spare].each do |field| describe "when calling #{field}" do it "should get the #{field} value from the current_pool hash" do pool_hash = mock "pool hash" pool_hash.expects(:[]).with(field) @provider.stubs(:current_pool).returns(pool_hash) @provider.send(field) end end describe "when setting the #{field}" do it "should warn the #{field} values were not in sync" do Puppet.expects(:warning).with("NO CHANGES BEING MADE: zpool #{field} does not match, should be 'shouldvalue' currently is 'currentvalue'") @provider.stubs(:current_pool).returns(Hash.new("currentvalue")) @provider.send((field.to_s + "=").intern, "shouldvalue") end end end end describe "when calling create" do before do @resource.stubs(:[]).with(:pool).returns("mypool") @provider.stubs(:zpool) end it "should call build_vdevs" do @provider.expects(:build_vdevs).returns([]) @provider.create end it "should call build_named with 'spares' and 'log" do @provider.expects(:build_named).with("spare").returns([]) @provider.expects(:build_named).with("log").returns([]) @provider.create end it "should call zpool with arguments from build_vdevs and build_named" do @provider.expects(:zpool).with(:create, 'mypool', 'shouldvalue', 'spare', 'shouldvalue', 'log', 'shouldvalue') @provider.create end end describe "when calling delete" do it "should call zpool with destroy and the pool name" do @resource.stubs(:[]).with(:pool).returns("poolname") @provider.expects(:zpool).with(:destroy, "poolname") @provider.delete end end describe "when calling exists?" do before do @current_pool = Hash.new(:absent) @provider.stubs(:get_pool_data).returns([]) @provider.stubs(:process_zpool_data).returns(@current_pool) end it "should get the current pool" do @provider.expects(:process_zpool_data).returns(@current_pool) @provider.exists? end it "should return false if the current_pool is absent" do #the before sets it up @provider.exists?.should == false end it "should return true if the current_pool has values" do @current_pool[:pool] = "mypool" @provider.exists?.should == true end end end diff --git a/spec/unit/reports/store_spec.rb b/spec/unit/reports/store_spec.rb index 1acb5badd..9d9042386 100644 --- a/spec/unit/reports/store_spec.rb +++ b/spec/unit/reports/store_spec.rb @@ -1,31 +1,31 @@ #!/usr/bin/env ruby Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") } require 'puppet/reports' require 'time' processor = Puppet::Reports.report(:store) describe processor do describe "#process" do include PuppetSpec::Files before :each do - Puppet[:reportdir] = tmpdir('reports') + Puppet[:reportdir] = tmpdir('reports') << '/reports' @report = YAML.load_file(File.join(PuppetSpec::FIXTURE_DIR, 'yaml/report2.6.x.yaml')).extend processor end it "should create a report directory for the client if one doesn't exist" do @report.process File.should be_directory(File.join(Puppet[:reportdir], @report.host)) end it "should write the report to the file in YAML" do Time.stubs(:now).returns(Time.parse("2011-01-06 12:00:00 UTC")) @report.process File.read(File.join(Puppet[:reportdir], @report.host, "201101061200.yaml")).should == @report.to_yaml end end end diff --git a/spec/unit/reports/tagmail_spec.rb b/spec/unit/reports/tagmail_spec.rb index 1dadfc7cd..fa8990ebb 100755 --- a/spec/unit/reports/tagmail_spec.rb +++ b/spec/unit/reports/tagmail_spec.rb @@ -1,95 +1,92 @@ #!/usr/bin/env ruby Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") } require 'puppet/reports' -require 'puppettest/support/utils' tagmail = Puppet::Reports.report(:tagmail) describe tagmail do - extend PuppetTest::Support::Utils - before do @processor = Puppet::Transaction::Report.new("apply") @processor.extend(Puppet::Reports.report(:tagmail)) end - passers = File.join(datadir, "reports", "tagmail_passers.conf") + passers = my_fixture "tagmail_passers.conf" File.readlines(passers).each do |line| it "should be able to parse '#{line.inspect}'" do @processor.parse(line) end end - failers = File.join(datadir, "reports", "tagmail_failers.conf") + failers = my_fixture "tagmail_failers.conf" File.readlines(failers).each do |line| it "should not be able to parse '#{line.inspect}'" do lambda { @processor.parse(line) }.should raise_error(ArgumentError) end end { "tag: abuse@domain.com" => [%w{abuse@domain.com}, %w{tag}, []], "tag.localhost: abuse@domain.com" => [%w{abuse@domain.com}, %w{tag.localhost}, []], "tag, other: abuse@domain.com" => [%w{abuse@domain.com}, %w{tag other}, []], "tag-other: abuse@domain.com" => [%w{abuse@domain.com}, %w{tag-other}, []], "tag, !other: abuse@domain.com" => [%w{abuse@domain.com}, %w{tag}, %w{other}], "tag, !other, one, !two: abuse@domain.com" => [%w{abuse@domain.com}, %w{tag one}, %w{other two}], "tag: abuse@domain.com, other@domain.com" => [%w{abuse@domain.com other@domain.com}, %w{tag}, []] }.each do |line, results| it "should parse '#{line}' as #{results.inspect}" do @processor.parse(line).shift.should == results end end describe "when matching logs" do before do @processor << Puppet::Util::Log.new(:level => :notice, :message => "first", :tags => %w{one}) @processor << Puppet::Util::Log.new(:level => :notice, :message => "second", :tags => %w{one two}) @processor << Puppet::Util::Log.new(:level => :notice, :message => "third", :tags => %w{one two three}) end def match(pos = [], neg = []) pos = Array(pos) neg = Array(neg) result = @processor.match([[%w{abuse@domain.com}, pos, neg]]) actual_result = result.shift if actual_result actual_result[1] else nil end end it "should match all messages when provided the 'all' tag as a positive matcher" do results = match("all") %w{first second third}.each do |str| results.should be_include(str) end end it "should remove messages that match a negated tag" do match("all", "three").should_not be_include("third") end it "should find any messages tagged with a provided tag" do results = match("two") results.should be_include("second") results.should be_include("third") results.should_not be_include("first") end it "should allow negation of specific tags from a specific tag list" do results = match("two", "three") results.should be_include("second") results.should_not be_include("third") end it "should allow a tag to negate all matches" do results = match([], "one") results.should be_nil end end end diff --git a/spec/unit/resource_spec.rb b/spec/unit/resource_spec.rb index 8b7bfc3e6..916741d1a 100755 --- a/spec/unit/resource_spec.rb +++ b/spec/unit/resource_spec.rb @@ -1,786 +1,812 @@ #!/usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') require 'puppet/resource' describe Puppet::Resource do before do @basepath = Puppet.features.posix? ? "/somepath" : "C:/somepath" end [:catalog, :file, :line].each do |attr| it "should have an #{attr} attribute" do resource = Puppet::Resource.new("file", "/my/file") resource.should respond_to(attr) resource.should respond_to(attr.to_s + "=") end end it "should have a :title attribute" do Puppet::Resource.new(:user, "foo").title.should == "foo" end it "should require the type and title" do lambda { Puppet::Resource.new }.should raise_error(ArgumentError) end it "should canonize types to capitalized strings" do Puppet::Resource.new(:user, "foo").type.should == "User" end it "should canonize qualified types so all strings are capitalized" do Puppet::Resource.new("foo::bar", "foo").type.should == "Foo::Bar" end it "should tag itself with its type" do Puppet::Resource.new("file", "/f").should be_tagged("file") end it "should tag itself with its title if the title is a valid tag" do Puppet::Resource.new("user", "bar").should be_tagged("bar") end it "should not tag itself with its title if the title is a not valid tag" do Puppet::Resource.new("file", "/bar").should_not be_tagged("/bar") end it "should allow setting of attributes" do Puppet::Resource.new("file", "/bar", :file => "/foo").file.should == "/foo" Puppet::Resource.new("file", "/bar", :exported => true).should be_exported end it "should set its type to 'Class' and its title to the passed title if the passed type is :component and the title has no square brackets in it" do ref = Puppet::Resource.new(:component, "foo") ref.type.should == "Class" ref.title.should == "Foo" end it "should interpret the title as a reference and assign appropriately if the type is :component and the title contains square brackets" do ref = Puppet::Resource.new(:component, "foo::bar[yay]") ref.type.should == "Foo::Bar" ref.title.should == "yay" end it "should set the type to 'Class' if it is nil and the title contains no square brackets" do ref = Puppet::Resource.new(nil, "yay") ref.type.should == "Class" ref.title.should == "Yay" end it "should interpret the title as a reference and assign appropriately if the type is nil and the title contains square brackets" do ref = Puppet::Resource.new(nil, "foo::bar[yay]") ref.type.should == "Foo::Bar" ref.title.should == "yay" end it "should interpret the title as a reference and assign appropriately if the type is nil and the title contains nested square brackets" do ref = Puppet::Resource.new(nil, "foo::bar[baz[yay]]") ref.type.should == "Foo::Bar" ref.title.should =="baz[yay]" end it "should interpret the type as a reference and assign appropriately if the title is nil and the type contains square brackets" do ref = Puppet::Resource.new("foo::bar[baz]") ref.type.should == "Foo::Bar" ref.title.should =="baz" end it "should be able to extract its information from a Puppet::Type instance" do ral = Puppet::Type.type(:file).new :path => @basepath+"/foo" ref = Puppet::Resource.new(ral) ref.type.should == "File" ref.title.should == @basepath+"/foo" end it "should fail if the title is nil and the type is not a valid resource reference string" do lambda { Puppet::Resource.new("foo") }.should raise_error(ArgumentError) end it 'should fail if strict is set and type does not exist' do - lambda { Puppet::Resource.new('foo', 'title', {:strict=>true}) }.should raise_error(ArgumentError, 'Invalid resource type foo') + lambda { Puppet::Resource.new('foo', 'title', {:strict=>true}) }.should raise_error(ArgumentError, 'Invalid resource type foo') end it 'should fail if strict is set and class does not exist' do - lambda { Puppet::Resource.new('Class', 'foo', {:strict=>true}) }.should raise_error(ArgumentError, 'Could not find declared class foo') + lambda { Puppet::Resource.new('Class', 'foo', {:strict=>true}) }.should raise_error(ArgumentError, 'Could not find declared class foo') end it "should fail if the title is a hash and the type is not a valid resource reference string" do lambda { Puppet::Resource.new({:type => "foo", :title => "bar"}) }.should raise_error(ArgumentError, 'Puppet::Resource.new does not take a hash as the first argument. Did you mean ("foo", "bar") ?' ) end it "should be able to produce a backward-compatible reference array" do Puppet::Resource.new("foobar", "/f").to_trans_ref.should == %w{Foobar /f} end it "should be taggable" do Puppet::Resource.ancestors.should be_include(Puppet::Util::Tagging) end it "should have an 'exported' attribute" do resource = Puppet::Resource.new("file", "/f") resource.exported = true resource.exported.should == true resource.should be_exported end it "should support an environment attribute" do Puppet::Resource.new("file", "/my/file", :environment => :foo).environment.name.should == :foo end describe "and munging its type and title" do describe "when modeling a builtin resource" do it "should be able to find the resource type" do Puppet::Resource.new("file", "/my/file").resource_type.should equal(Puppet::Type.type(:file)) end it "should set its type to the capitalized type name" do Puppet::Resource.new("file", "/my/file").type.should == "File" end end describe "when modeling a defined resource" do describe "that exists" do before do @type = Puppet::Resource::Type.new(:definition, "foo::bar") Puppet::Node::Environment.new.known_resource_types.add @type end it "should set its type to the capitalized type name" do Puppet::Resource.new("foo::bar", "/my/file").type.should == "Foo::Bar" end it "should be able to find the resource type" do Puppet::Resource.new("foo::bar", "/my/file").resource_type.should equal(@type) end it "should set its title to the provided title" do Puppet::Resource.new("foo::bar", "/my/file").title.should == "/my/file" end end describe "that does not exist" do it "should set its resource type to the capitalized resource type name" do Puppet::Resource.new("foo::bar", "/my/file").type.should == "Foo::Bar" end end end describe "when modeling a node" do # Life's easier with nodes, because they can't be qualified. it "should set its type to 'Node' and its title to the provided title" do node = Puppet::Resource.new("node", "foo") node.type.should == "Node" node.title.should == "foo" end end describe "when modeling a class" do it "should set its type to 'Class'" do Puppet::Resource.new("class", "foo").type.should == "Class" end describe "that exists" do before do @type = Puppet::Resource::Type.new(:hostclass, "foo::bar") Puppet::Node::Environment.new.known_resource_types.add @type end it "should set its title to the capitalized, fully qualified resource type" do Puppet::Resource.new("class", "foo::bar").title.should == "Foo::Bar" end it "should be able to find the resource type" do Puppet::Resource.new("class", "foo::bar").resource_type.should equal(@type) end end describe "that does not exist" do it "should set its type to 'Class' and its title to the capitalized provided name" do klass = Puppet::Resource.new("class", "foo::bar") klass.type.should == "Class" klass.title.should == "Foo::Bar" end end describe "and its name is set to the empty string" do it "should set its title to :main" do Puppet::Resource.new("class", "").title.should == :main end describe "and a class exists whose name is the empty string" do # this was a bit tough to track down it "should set its title to :main" do @type = Puppet::Resource::Type.new(:hostclass, "") Puppet::Node::Environment.new.known_resource_types.add @type Puppet::Resource.new("class", "").title.should == :main end end end describe "and its name is set to :main" do it "should set its title to :main" do Puppet::Resource.new("class", :main).title.should == :main end describe "and a class exists whose name is the empty string" do # this was a bit tough to track down it "should set its title to :main" do @type = Puppet::Resource::Type.new(:hostclass, "") Puppet::Node::Environment.new.known_resource_types.add @type Puppet::Resource.new("class", :main).title.should == :main end end end end end it "should return nil when looking up resource types that don't exist" do Puppet::Resource.new("foobar", "bar").resource_type.should be_nil end it "should not fail when an invalid parameter is used and strict mode is disabled" do type = Puppet::Resource::Type.new(:definition, "foobar") Puppet::Node::Environment.new.known_resource_types.add type resource = Puppet::Resource.new("foobar", "/my/file") resource[:yay] = true end it "should be considered equivalent to another resource if their type and title match and no parameters are set" do Puppet::Resource.new("file", "/f").should == Puppet::Resource.new("file", "/f") end it "should be considered equivalent to another resource if their type, title, and parameters are equal" do Puppet::Resource.new("file", "/f", :parameters => {:foo => "bar"}).should == Puppet::Resource.new("file", "/f", :parameters => {:foo => "bar"}) end it "should not be considered equivalent to another resource if their type and title match but parameters are different" do Puppet::Resource.new("file", "/f", :parameters => {:fee => "baz"}).should_not == Puppet::Resource.new("file", "/f", :parameters => {:foo => "bar"}) end it "should not be considered equivalent to a non-resource" do Puppet::Resource.new("file", "/f").should_not == "foo" end it "should not be considered equivalent to another resource if their types do not match" do Puppet::Resource.new("file", "/f").should_not == Puppet::Resource.new("exec", "/f") end it "should not be considered equivalent to another resource if their titles do not match" do Puppet::Resource.new("file", "/foo").should_not == Puppet::Resource.new("file", "/f") end describe "when referring to a resource with name canonicalization" do it "should canonicalize its own name" do res = Puppet::Resource.new("file", "/path/") res.uniqueness_key.should == ["/path"] res.ref.should == "File[/path/]" end end describe "when running in strict mode" do it "should be strict" do Puppet::Resource.new("file", "/path", :strict => true).should be_strict end it "should fail if invalid parameters are used" do lambda { Puppet::Resource.new("file", "/path", :strict => true, :parameters => {:nosuchparam => "bar"}) }.should raise_error end it "should fail if the resource type cannot be resolved" do lambda { Puppet::Resource.new("nosuchtype", "/path", :strict => true) }.should raise_error end end describe "when managing parameters" do before do @resource = Puppet::Resource.new("file", "/my/file") end it "should correctly detect when provided parameters are not valid for builtin types" do Puppet::Resource.new("file", "/my/file").should_not be_valid_parameter("foobar") end it "should correctly detect when provided parameters are valid for builtin types" do Puppet::Resource.new("file", "/my/file").should be_valid_parameter("mode") end it "should correctly detect when provided parameters are not valid for defined resource types" do type = Puppet::Resource::Type.new(:definition, "foobar") Puppet::Node::Environment.new.known_resource_types.add type Puppet::Resource.new("foobar", "/my/file").should_not be_valid_parameter("myparam") end it "should correctly detect when provided parameters are valid for defined resource types" do type = Puppet::Resource::Type.new(:definition, "foobar", :arguments => {"myparam" => nil}) Puppet::Node::Environment.new.known_resource_types.add type Puppet::Resource.new("foobar", "/my/file").should be_valid_parameter("myparam") end it "should allow setting and retrieving of parameters" do @resource[:foo] = "bar" @resource[:foo].should == "bar" end it "should allow setting of parameters at initialization" do Puppet::Resource.new("file", "/my/file", :parameters => {:foo => "bar"})[:foo].should == "bar" end it "should canonicalize retrieved parameter names to treat symbols and strings equivalently" do @resource[:foo] = "bar" @resource["foo"].should == "bar" end it "should canonicalize set parameter names to treat symbols and strings equivalently" do @resource["foo"] = "bar" @resource[:foo].should == "bar" end it "should set the namevar when asked to set the name" do resource = Puppet::Resource.new("user", "bob") Puppet::Type.type(:user).stubs(:key_attributes).returns [:myvar] resource[:name] = "bob" resource[:myvar].should == "bob" end it "should return the namevar when asked to return the name" do resource = Puppet::Resource.new("user", "bob") Puppet::Type.type(:user).stubs(:key_attributes).returns [:myvar] resource[:myvar] = "test" resource[:name].should == "test" end it "should be able to set the name for non-builtin types" do resource = Puppet::Resource.new(:foo, "bar") resource[:name] = "eh" lambda { resource[:name] = "eh" }.should_not raise_error end it "should be able to return the name for non-builtin types" do resource = Puppet::Resource.new(:foo, "bar") resource[:name] = "eh" resource[:name].should == "eh" end it "should be able to iterate over parameters" do @resource[:foo] = "bar" @resource[:fee] = "bare" params = {} @resource.each do |key, value| params[key] = value end params.should == {:foo => "bar", :fee => "bare"} end it "should include Enumerable" do @resource.class.ancestors.should be_include(Enumerable) end it "should have a method for testing whether a parameter is included" do @resource[:foo] = "bar" @resource.should be_has_key(:foo) @resource.should_not be_has_key(:eh) end it "should have a method for providing the list of parameters" do @resource[:foo] = "bar" @resource[:bar] = "foo" keys = @resource.keys keys.should be_include(:foo) keys.should be_include(:bar) end it "should have a method for providing the number of parameters" do @resource[:foo] = "bar" @resource.length.should == 1 end it "should have a method for deleting parameters" do @resource[:foo] = "bar" @resource.delete(:foo) @resource[:foo].should be_nil end it "should have a method for testing whether the parameter list is empty" do @resource.should be_empty @resource[:foo] = "bar" @resource.should_not be_empty end it "should be able to produce a hash of all existing parameters" do @resource[:foo] = "bar" @resource[:fee] = "yay" hash = @resource.to_hash hash[:foo].should == "bar" hash[:fee].should == "yay" end it "should not provide direct access to the internal parameters hash when producing a hash" do hash = @resource.to_hash hash[:foo] = "bar" @resource[:foo].should be_nil end it "should use the title as the namevar to the hash if no namevar is present" do resource = Puppet::Resource.new("user", "bob") Puppet::Type.type(:user).stubs(:key_attributes).returns [:myvar] resource.to_hash[:myvar].should == "bob" end it "should set :name to the title if :name is not present for non-builtin types" do krt = Puppet::Resource::TypeCollection.new("myenv") krt.add Puppet::Resource::Type.new(:definition, :foo) resource = Puppet::Resource.new :foo, "bar" resource.stubs(:known_resource_types).returns krt resource.to_hash[:name].should == "bar" end end describe "when serializing" do before do @resource = Puppet::Resource.new("file", "/my/file") @resource["one"] = "test" @resource["two"] = "other" end it "should be able to be dumped to yaml" do proc { YAML.dump(@resource) }.should_not raise_error end it "should produce an equivalent yaml object" do text = YAML.dump(@resource) newresource = YAML.load(text) newresource.title.should == @resource.title newresource.type.should == @resource.type %w{one two}.each do |param| newresource[param].should == @resource[param] end end end + describe "when loading 0.25.x storedconfigs YAML" do + before :each do + @old_storedconfig_yaml = %q{--- !ruby/object:Puppet::Resource::Reference +builtin_type: +title: /tmp/bar +type: File +} + end + + it "should deserialize a Puppet::Resource::Reference without exceptions" do + lambda { YAML.load(@old_storedconfig_yaml) }.should_not raise_error + end + + it "should deserialize as a Puppet::Resource::Reference as a Puppet::Resource" do + YAML.load(@old_storedconfig_yaml).class.should == Puppet::Resource + end + + it "should to_hash properly" do + YAML.load(@old_storedconfig_yaml).to_hash.should == { :path => "/tmp/bar" } + end + end + describe "when converting to a RAL resource" do it "should use the resource type's :new method to create the resource if the resource is of a builtin type" do resource = Puppet::Resource.new("file", @basepath+"/my/file") result = resource.to_ral result.should be_instance_of(Puppet::Type.type(:file)) result[:path].should == @basepath+"/my/file" end it "should convert to a component instance if the resource type is not of a builtin type" do resource = Puppet::Resource.new("foobar", "somename") result = resource.to_ral result.should be_instance_of(Puppet::Type.type(:component)) result.title.should == "Foobar[somename]" end end it "should be able to convert itself to Puppet code" do Puppet::Resource.new("one::two", "/my/file").should respond_to(:to_manifest) end describe "when converting to puppet code" do before do - @resource = Puppet::Resource.new("one::two", "/my/file", :parameters => {:noop => true, :foo => %w{one two}}) - end - - it "should print the type and title" do - @resource.to_manifest.should be_include("one::two { '/my/file':\n") - end - - it "should print each parameter, with the value single-quoted" do - @resource.to_manifest.should be_include(" noop => 'true'") + @resource = Puppet::Resource.new("one::two", "/my/file", + :parameters => { + :noop => true, + :foo => %w{one two}, + :ensure => 'present', + } + ) end - it "should print array values appropriately" do - @resource.to_manifest.should be_include(" foo => ['one','two']") + it "should align, sort and add trailing commas to attributes with ensure first" do + @resource.to_manifest.should == <<-HEREDOC.gsub(/^\s{8}/, '').gsub(/\n$/, '') + one::two { '/my/file': + ensure => 'present', + foo => ['one', 'two'], + noop => 'true', + } + HEREDOC end end it "should be able to convert itself to a TransObject instance" do Puppet::Resource.new("one::two", "/my/file").should respond_to(:to_trans) end describe "when converting to a TransObject" do describe "and the resource is not an instance of a builtin type" do before do @resource = Puppet::Resource.new("foo", "bar") end it "should return a simple TransBucket if it is not an instance of a builtin type" do bucket = @resource.to_trans bucket.should be_instance_of(Puppet::TransBucket) bucket.type.should == @resource.type bucket.name.should == @resource.title end it "should return a simple TransBucket if it is a stage" do @resource = Puppet::Resource.new("stage", "bar") bucket = @resource.to_trans bucket.should be_instance_of(Puppet::TransBucket) bucket.type.should == @resource.type bucket.name.should == @resource.title end it "should copy over the resource's file" do @resource.file = "/foo/bar" @resource.to_trans.file.should == "/foo/bar" end it "should copy over the resource's line" do @resource.line = 50 @resource.to_trans.line.should == 50 end end describe "and the resource is an instance of a builtin type" do before do @resource = Puppet::Resource.new("file", "bar") end it "should return a TransObject if it is an instance of a builtin resource type" do trans = @resource.to_trans trans.should be_instance_of(Puppet::TransObject) trans.type.should == "file" trans.name.should == @resource.title end it "should copy over the resource's file" do @resource.file = "/foo/bar" @resource.to_trans.file.should == "/foo/bar" end it "should copy over the resource's line" do @resource.line = 50 @resource.to_trans.line.should == 50 end # Only TransObjects support tags, annoyingly it "should copy over the resource's tags" do @resource.tag "foo" @resource.to_trans.tags.should == @resource.tags end it "should copy the resource's parameters into the transobject and convert the parameter name to a string" do @resource[:foo] = "bar" @resource.to_trans["foo"].should == "bar" end it "should be able to copy arrays of values" do @resource[:foo] = %w{yay fee} @resource.to_trans["foo"].should == %w{yay fee} end it "should reduce single-value arrays to just a value" do @resource[:foo] = %w{yay} @resource.to_trans["foo"].should == "yay" end it "should convert resource references into the backward-compatible form" do @resource[:foo] = Puppet::Resource.new(:file, "/f") @resource.to_trans["foo"].should == %w{File /f} end it "should convert resource references into the backward-compatible form even when within arrays" do @resource[:foo] = ["a", Puppet::Resource.new(:file, "/f")] @resource.to_trans["foo"].should == ["a", %w{File /f}] end end end describe "when converting to pson", :if => Puppet.features.pson? do def pson_output_should @resource.class.expects(:pson_create).with { |hash| yield hash } end it "should include the pson util module" do Puppet::Resource.singleton_class.ancestors.should be_include(Puppet::Util::Pson) end # LAK:NOTE For all of these tests, we convert back to the resource so we can # trap the actual data structure then. it "should set its type to the provided type" do Puppet::Resource.from_pson(PSON.parse(Puppet::Resource.new("File", "/foo").to_pson)).type.should == "File" end it "should set its title to the provided title" do Puppet::Resource.from_pson(PSON.parse(Puppet::Resource.new("File", "/foo").to_pson)).title.should == "/foo" end it "should include all tags from the resource" do resource = Puppet::Resource.new("File", "/foo") resource.tag("yay") Puppet::Resource.from_pson(PSON.parse(resource.to_pson)).tags.should == resource.tags end it "should include the file if one is set" do resource = Puppet::Resource.new("File", "/foo") resource.file = "/my/file" Puppet::Resource.from_pson(PSON.parse(resource.to_pson)).file.should == "/my/file" end it "should include the line if one is set" do resource = Puppet::Resource.new("File", "/foo") resource.line = 50 Puppet::Resource.from_pson(PSON.parse(resource.to_pson)).line.should == 50 end it "should include the 'exported' value if one is set" do resource = Puppet::Resource.new("File", "/foo") resource.exported = true Puppet::Resource.from_pson(PSON.parse(resource.to_pson)).exported.should be_true end it "should set 'exported' to false if no value is set" do resource = Puppet::Resource.new("File", "/foo") Puppet::Resource.from_pson(PSON.parse(resource.to_pson)).exported.should be_false end it "should set all of its parameters as the 'parameters' entry" do resource = Puppet::Resource.new("File", "/foo") resource[:foo] = %w{bar eh} resource[:fee] = %w{baz} result = Puppet::Resource.from_pson(PSON.parse(resource.to_pson)) result["foo"].should == %w{bar eh} result["fee"].should == %w{baz} end it "should serialize relationships as reference strings" do resource = Puppet::Resource.new("File", "/foo") resource[:requires] = Puppet::Resource.new("File", "/bar") result = Puppet::Resource.from_pson(PSON.parse(resource.to_pson)) result[:requires].should == "File[/bar]" end it "should serialize multiple relationships as arrays of reference strings" do resource = Puppet::Resource.new("File", "/foo") resource[:requires] = [Puppet::Resource.new("File", "/bar"), Puppet::Resource.new("File", "/baz")] result = Puppet::Resource.from_pson(PSON.parse(resource.to_pson)) result[:requires].should == [ "File[/bar]", "File[/baz]" ] end end describe "when converting from pson", :if => Puppet.features.pson? do def pson_result_should Puppet::Resource.expects(:new).with { |hash| yield hash } end before do @data = { 'type' => "file", 'title' => @basepath+"/yay", } end it "should set its type to the provided type" do Puppet::Resource.from_pson(@data).type.should == "File" end it "should set its title to the provided title" do Puppet::Resource.from_pson(@data).title.should == @basepath+"/yay" end it "should tag the resource with any provided tags" do @data['tags'] = %w{foo bar} resource = Puppet::Resource.from_pson(@data) resource.tags.should be_include("foo") resource.tags.should be_include("bar") end it "should set its file to the provided file" do @data['file'] = "/foo/bar" Puppet::Resource.from_pson(@data).file.should == "/foo/bar" end it "should set its line to the provided line" do @data['line'] = 50 Puppet::Resource.from_pson(@data).line.should == 50 end it "should 'exported' to true if set in the pson data" do @data['exported'] = true Puppet::Resource.from_pson(@data).exported.should be_true end it "should 'exported' to false if not set in the pson data" do Puppet::Resource.from_pson(@data).exported.should be_false end it "should fail if no title is provided" do @data.delete('title') lambda { Puppet::Resource.from_pson(@data) }.should raise_error(ArgumentError) end it "should fail if no type is provided" do @data.delete('type') lambda { Puppet::Resource.from_pson(@data) }.should raise_error(ArgumentError) end it "should set each of the provided parameters" do @data['parameters'] = {'foo' => %w{one two}, 'fee' => %w{three four}} resource = Puppet::Resource.from_pson(@data) resource['foo'].should == %w{one two} resource['fee'].should == %w{three four} end it "should convert single-value array parameters to normal values" do @data['parameters'] = {'foo' => %w{one}} resource = Puppet::Resource.from_pson(@data) resource['foo'].should == %w{one} end end describe "it should implement to_resource" do resource = Puppet::Resource.new("file", "/my/file") resource.to_resource.should == resource end describe "because it is an indirector model" do it "should include Puppet::Indirector" do Puppet::Resource.should be_is_a(Puppet::Indirector) end it "should have a default terminus" do Puppet::Resource.indirection.terminus_class.should == :ral end it "should have a name" do Puppet::Resource.new("file", "/my/file").name.should == "File//my/file" end end describe "when resolving resources with a catalog" do it "should resolve all resources using the catalog" do catalog = mock 'catalog' resource = Puppet::Resource.new("foo::bar", "yay") resource.catalog = catalog catalog.expects(:resource).with("Foo::Bar[yay]").returns(:myresource) resource.resolve.should == :myresource end end describe "when generating the uniqueness key" do it "should include all of the key_attributes in alphabetical order by attribute name" do Puppet::Type.type(:file).stubs(:key_attributes).returns [:myvar, :owner, :path] Puppet::Type.type(:file).stubs(:title_patterns).returns( [ [ /(.*)/, [ [:path, lambda{|x| x} ] ] ] ] ) res = Puppet::Resource.new("file", "/my/file", :parameters => {:owner => 'root', :content => 'hello'}) res.uniqueness_key.should == [ nil, 'root', '/my/file'] end end end diff --git a/spec/unit/simple_graph_spec.rb b/spec/unit/simple_graph_spec.rb index e49811ea7..c106f550b 100755 --- a/spec/unit/simple_graph_spec.rb +++ b/spec/unit/simple_graph_spec.rb @@ -1,762 +1,865 @@ #!/usr/bin/env ruby # # Created by Luke Kanies on 2007-11-1. # Copyright (c) 2006. All rights reserved. require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') require 'puppet/simple_graph' describe Puppet::SimpleGraph do it "should return the number of its vertices as its length" do @graph = Puppet::SimpleGraph.new @graph.add_vertex("one") @graph.add_vertex("two") @graph.size.should == 2 end it "should consider itself a directed graph" do Puppet::SimpleGraph.new.directed?.should be_true end it "should provide a method for reversing the graph" do @graph = Puppet::SimpleGraph.new @graph.add_edge(:one, :two) @graph.reversal.edge?(:two, :one).should be_true end it "should be able to produce a dot graph" do @graph = Puppet::SimpleGraph.new @graph.add_edge(:one, :two) proc { @graph.to_dot_graph }.should_not raise_error end describe "when managing vertices" do before do @graph = Puppet::SimpleGraph.new end it "should provide a method to add a vertex" do @graph.add_vertex(:test) @graph.vertex?(:test).should be_true end it "should reset its reversed graph when vertices are added" do rev = @graph.reversal @graph.add_vertex(:test) @graph.reversal.should_not equal(rev) end it "should ignore already-present vertices when asked to add a vertex" do @graph.add_vertex(:test) proc { @graph.add_vertex(:test) }.should_not raise_error end it "should return true when asked if a vertex is present" do @graph.add_vertex(:test) @graph.vertex?(:test).should be_true end it "should return false when asked if a non-vertex is present" do @graph.vertex?(:test).should be_false end it "should return all set vertices when asked" do @graph.add_vertex(:one) @graph.add_vertex(:two) @graph.vertices.length.should == 2 @graph.vertices.should include(:one) @graph.vertices.should include(:two) end it "should remove a given vertex when asked" do @graph.add_vertex(:one) @graph.remove_vertex!(:one) @graph.vertex?(:one).should be_false end it "should do nothing when a non-vertex is asked to be removed" do proc { @graph.remove_vertex!(:one) }.should_not raise_error end end describe "when managing edges" do before do @graph = Puppet::SimpleGraph.new end it "should provide a method to test whether a given vertex pair is an edge" do @graph.should respond_to(:edge?) end it "should reset its reversed graph when edges are added" do rev = @graph.reversal @graph.add_edge(:one, :two) @graph.reversal.should_not equal(rev) end it "should provide a method to add an edge as an instance of the edge class" do edge = Puppet::Relationship.new(:one, :two) @graph.add_edge(edge) @graph.edge?(:one, :two).should be_true end it "should provide a method to add an edge by specifying the two vertices" do @graph.add_edge(:one, :two) @graph.edge?(:one, :two).should be_true end it "should provide a method to add an edge by specifying the two vertices and a label" do @graph.add_edge(:one, :two, :callback => :awesome) @graph.edge?(:one, :two).should be_true end describe "when retrieving edges between two nodes" do it "should handle the case of nodes not in the graph" do @graph.edges_between(:one, :two).should == [] end it "should handle the case of nodes with no edges between them" do @graph.add_vertex(:one) @graph.add_vertex(:two) @graph.edges_between(:one, :two).should == [] end it "should handle the case of nodes connected by a single edge" do edge = Puppet::Relationship.new(:one, :two) @graph.add_edge(edge) @graph.edges_between(:one, :two).length.should == 1 @graph.edges_between(:one, :two)[0].should equal(edge) end it "should handle the case of nodes connected by multiple edges" do edge1 = Puppet::Relationship.new(:one, :two, :callback => :foo) edge2 = Puppet::Relationship.new(:one, :two, :callback => :bar) @graph.add_edge(edge1) @graph.add_edge(edge2) Set.new(@graph.edges_between(:one, :two)).should == Set.new([edge1, edge2]) end end it "should add the edge source as a vertex if it is not already" do edge = Puppet::Relationship.new(:one, :two) @graph.add_edge(edge) @graph.vertex?(:one).should be_true end it "should add the edge target as a vertex if it is not already" do edge = Puppet::Relationship.new(:one, :two) @graph.add_edge(edge) @graph.vertex?(:two).should be_true end it "should return all edges as edge instances when asked" do one = Puppet::Relationship.new(:one, :two) two = Puppet::Relationship.new(:two, :three) @graph.add_edge(one) @graph.add_edge(two) edges = @graph.edges edges.should be_instance_of(Array) edges.length.should == 2 edges.should include(one) edges.should include(two) end it "should remove an edge when asked" do edge = Puppet::Relationship.new(:one, :two) @graph.add_edge(edge) @graph.remove_edge!(edge) @graph.edge?(edge.source, edge.target).should be_false end it "should remove all related edges when a vertex is removed" do one = Puppet::Relationship.new(:one, :two) two = Puppet::Relationship.new(:two, :three) @graph.add_edge(one) @graph.add_edge(two) @graph.remove_vertex!(:two) @graph.edge?(:one, :two).should be_false @graph.edge?(:two, :three).should be_false @graph.edges.length.should == 0 end end describe "when finding adjacent vertices" do before do @graph = Puppet::SimpleGraph.new @one_two = Puppet::Relationship.new(:one, :two) @two_three = Puppet::Relationship.new(:two, :three) @one_three = Puppet::Relationship.new(:one, :three) @graph.add_edge(@one_two) @graph.add_edge(@one_three) @graph.add_edge(@two_three) end it "should return adjacent vertices" do adj = @graph.adjacent(:one) adj.should be_include(:three) adj.should be_include(:two) end it "should default to finding :out vertices" do @graph.adjacent(:two).should == [:three] end it "should support selecting :in vertices" do @graph.adjacent(:two, :direction => :in).should == [:one] end it "should default to returning the matching vertices as an array of vertices" do @graph.adjacent(:two).should == [:three] end it "should support returning an array of matching edges" do @graph.adjacent(:two, :type => :edges).should == [@two_three] end # Bug #2111 it "should not consider a vertex adjacent just because it was asked about previously" do @graph = Puppet::SimpleGraph.new @graph.add_vertex("a") @graph.add_vertex("b") @graph.edge?("a", "b") @graph.adjacent("a").should == [] end end describe "when clearing" do before do @graph = Puppet::SimpleGraph.new one = Puppet::Relationship.new(:one, :two) two = Puppet::Relationship.new(:two, :three) @graph.add_edge(one) @graph.add_edge(two) @graph.clear end it "should remove all vertices" do @graph.vertices.should be_empty end it "should remove all edges" do @graph.edges.should be_empty end end describe "when reversing graphs" do before do @graph = Puppet::SimpleGraph.new end it "should provide a method for reversing the graph" do @graph.add_edge(:one, :two) @graph.reversal.edge?(:two, :one).should be_true end it "should add all vertices to the reversed graph" do @graph.add_edge(:one, :two) @graph.vertex?(:one).should be_true @graph.vertex?(:two).should be_true end it "should retain labels on edges" do @graph.add_edge(:one, :two, :callback => :awesome) edge = @graph.reversal.edges_between(:two, :one)[0] edge.label.should == {:callback => :awesome} end end describe "when sorting the graph" do before do @graph = Puppet::SimpleGraph.new end def add_edges(hash) hash.each do |a,b| @graph.add_edge(a, b) end end it "should sort the graph topologically" do add_edges :a => :b, :b => :c @graph.topsort.should == [:a, :b, :c] end it "should fail on two-vertex loops" do add_edges :a => :b, :b => :a proc { @graph.topsort }.should raise_error(Puppet::Error) end it "should fail on multi-vertex loops" do add_edges :a => :b, :b => :c, :c => :a proc { @graph.topsort }.should raise_error(Puppet::Error) end it "should fail when a larger tree contains a small cycle" do add_edges :a => :b, :b => :a, :c => :a, :d => :c proc { @graph.topsort }.should raise_error(Puppet::Error) end it "should succeed on trees with no cycles" do add_edges :a => :b, :b => :e, :c => :a, :d => :c proc { @graph.topsort }.should_not raise_error end + it "should produce the correct relationship text" do + add_edges :a => :b, :b => :a + # cycle detection starts from a or b randomly + # so we need to check for either ordering in the error message + want = %r{Found 1 dependency cycle:\n\((a => b => a|b => a => b)\)\nTry} + expect { @graph.topsort }.to raise_error(Puppet::Error, want) + end + + it "cycle discovery should be the minimum cycle for a simple graph" do + add_edges "a" => "b" + add_edges "b" => "a" + add_edges "b" => "c" + + cycles = nil + expect { cycles = @graph.find_cycles_in_graph.sort }.should_not raise_error + cycles.should be == [["a", "b"]] + end + + it "cycle discovery should handle two distinct cycles" do + add_edges "a" => "a1", "a1" => "a" + add_edges "b" => "b1", "b1" => "b" + + cycles = nil + expect { cycles = @graph.find_cycles_in_graph.sort }.should_not raise_error + cycles.should be == [["a", "a1"], ["b", "b1"]] + end + + it "cycle discovery should handle two cycles in a connected graph" do + add_edges "a" => "b", "b" => "c", "c" => "d" + add_edges "a" => "a1", "a1" => "a" + add_edges "c" => "c1", "c1" => "c2", "c2" => "c3", "c3" => "c" + + cycles = nil + expect { cycles = @graph.find_cycles_in_graph.sort }.should_not raise_error + cycles.should be == [%w{a a1}, %w{c c1 c2 c3}] + end + + it "cycle discovery should handle a complicated cycle" do + add_edges "a" => "b", "b" => "c" + add_edges "a" => "c" + add_edges "c" => "c1", "c1" => "a" + add_edges "c" => "c2", "c2" => "b" + + cycles = nil + expect { cycles = @graph.find_cycles_in_graph.sort }.should_not raise_error + cycles.should be == [%w{a b c c1 c2}] + end + + it "cycle discovery should not fail with large data sets" do + limit = 3000 + (1..(limit - 1)).each do |n| add_edges n.to_s => (n+1).to_s end + + cycles = nil + expect { cycles = @graph.find_cycles_in_graph.sort }.should_not raise_error + cycles.should be == [] + end + + it "path finding should work with a simple cycle" do + add_edges "a" => "b", "b" => "c", "c" => "a" + + cycles = @graph.find_cycles_in_graph.sort + paths = @graph.paths_in_cycle(cycles.first, 100) + paths.should be == [%w{a b c a}] + end + + it "path finding should work with two independent cycles" do + add_edges "a" => "b1" + add_edges "a" => "b2" + add_edges "b1" => "a", "b2" => "a" + + cycles = @graph.find_cycles_in_graph.sort + cycles.length.should be == 1 + + paths = @graph.paths_in_cycle(cycles.first, 100) + paths.sort.should be == [%w{a b1 a}, %w{a b2 a}] + end + + it "path finding should prefer shorter paths in cycles" do + add_edges "a" => "b", "b" => "c", "c" => "a" + add_edges "b" => "a" + + cycles = @graph.find_cycles_in_graph.sort + cycles.length.should be == 1 + + paths = @graph.paths_in_cycle(cycles.first, 100) + paths.should be == [%w{a b a}, %w{a b c a}] + end + + it "path finding should respect the max_path value" do + (1..20).each do |n| add_edges "a" => "b#{n}", "b#{n}" => "a" end + + cycles = @graph.find_cycles_in_graph.sort + cycles.length.should be == 1 + + (1..20).each do |n| + paths = @graph.paths_in_cycle(cycles.first, n) + paths.length.should be == n + end + + paths = @graph.paths_in_cycle(cycles.first, 21) + paths.length.should be == 20 + end + # Our graph's add_edge method is smart enough not to add # duplicate edges, so we use the objects, which it doesn't # check. it "should be able to sort graphs with duplicate edges" do one = Puppet::Relationship.new(:a, :b) @graph.add_edge(one) two = Puppet::Relationship.new(:a, :b) @graph.add_edge(two) proc { @graph.topsort }.should_not raise_error end end describe "when writing dot files" do before do @graph = Puppet::SimpleGraph.new @name = :test @file = File.join(Puppet[:graphdir], @name.to_s + ".dot") end it "should only write when graphing is enabled" do File.expects(:open).with(@file).never Puppet[:graph] = false @graph.write_graph(@name) end it "should write a dot file based on the passed name" do File.expects(:open).with(@file, "w").yields(stub("file", :puts => nil)) @graph.expects(:to_dot).with("name" => @name.to_s.capitalize) Puppet[:graph] = true @graph.write_graph(@name) end after do Puppet.settings.clear end end describe Puppet::SimpleGraph do before do @graph = Puppet::SimpleGraph.new end it "should correctly clear vertices and edges when asked" do @graph.add_edge("a", "b") @graph.add_vertex "c" @graph.clear @graph.vertices.should be_empty @graph.edges.should be_empty end end describe "when matching edges" do before do @graph = Puppet::SimpleGraph.new @event = Puppet::Transaction::Event.new(:name => :yay, :resource => "a") @none = Puppet::Transaction::Event.new(:name => :NONE, :resource => "a") @edges = {} @edges["a/b"] = Puppet::Relationship.new("a", "b", {:event => :yay, :callback => :refresh}) @edges["a/c"] = Puppet::Relationship.new("a", "c", {:event => :yay, :callback => :refresh}) @graph.add_edge(@edges["a/b"]) end it "should match edges whose source matches the source of the event" do @graph.matching_edges(@event).should == [@edges["a/b"]] end it "should match always match nothing when the event is :NONE" do @graph.matching_edges(@none).should be_empty end it "should match multiple edges" do @graph.add_edge(@edges["a/c"]) edges = @graph.matching_edges(@event) edges.should be_include(@edges["a/b"]) edges.should be_include(@edges["a/c"]) end end describe "when determining dependencies" do before do @graph = Puppet::SimpleGraph.new @graph.add_edge("a", "b") @graph.add_edge("a", "c") @graph.add_edge("b", "d") end it "should find all dependents when they are on multiple levels" do @graph.dependents("a").sort.should == %w{b c d}.sort end it "should find single dependents" do @graph.dependents("b").sort.should == %w{d}.sort end it "should return an empty array when there are no dependents" do @graph.dependents("c").sort.should == [].sort end it "should find all dependencies when they are on multiple levels" do @graph.dependencies("d").sort.should == %w{a b} end it "should find single dependencies" do @graph.dependencies("c").sort.should == %w{a} end it "should return an empty array when there are no dependencies" do @graph.dependencies("a").sort.should == [] end end require 'puppet/util/graph' class Container include Puppet::Util::Graph include Enumerable attr_accessor :name def each @children.each do |c| yield c end end def initialize(name, ary) @name = name @children = ary end def push(*ary) ary.each { |c| @children.push(c)} end def to_s @name end end describe "when splicing the graph" do def container_graph @one = Container.new("one", %w{a b}) @two = Container.new("two", ["c", "d"]) @three = Container.new("three", ["i", "j"]) @middle = Container.new("middle", ["e", "f", @two]) @top = Container.new("top", ["g", "h", @middle, @one, @three]) @empty = Container.new("empty", []) @whit = Puppet::Type.type(:whit) @stage = Puppet::Type.type(:stage).new(:name => "foo") @contgraph = @top.to_graph # We have to add the container to the main graph, else it won't # be spliced in the dependency graph. @contgraph.add_vertex(@empty) end def dependency_graph @depgraph = Puppet::SimpleGraph.new @contgraph.vertices.each do |v| @depgraph.add_vertex(v) end # We have to specify a relationship to our empty container, else it # never makes it into the dep graph in the first place. {@one => @two, "f" => "c", "h" => @middle, "c" => @empty}.each do |source, target| @depgraph.add_edge(source, target, :callback => :refresh) end end def splice @depgraph.splice!(@contgraph, Container) end before do container_graph dependency_graph splice end # This is the real heart of splicing -- replacing all containers in # our relationship and exploding their relationships so that each # relationship to a container gets copied to all of its children. it "should remove all Container objects from the dependency graph" do @depgraph.vertices.find_all { |v| v.is_a?(Container) }.should be_empty end # This is a bit hideous, but required to make stages work with relationships - they're # the top of the graph. it "should remove all Stage resources from the dependency graph" do @depgraph.vertices.find_all { |v| v.is_a?(Puppet::Type.type(:stage)) }.should be_empty end it "should add container relationships to contained objects" do @contgraph.leaves(@middle).each do |leaf| @depgraph.should be_edge("h", leaf) end end it "should explode container-to-container relationships, making edges between all respective contained objects" do @one.each do |oobj| @two.each do |tobj| @depgraph.should be_edge(oobj, tobj) end end end it "should contain a whit-resource to mark the place held by the empty container" do @depgraph.vertices.find_all { |v| v.is_a?(@whit) }.length.should == 1 end it "should replace edges to empty containers with edges to their residual whit" do emptys_whit = @depgraph.vertices.find_all { |v| v.is_a?(@whit) }.first @depgraph.should be_edge("c", emptys_whit) end it "should no longer contain anything but the non-container objects" do @depgraph.vertices.find_all { |v| ! v.is_a?(String) and ! v.is_a?(@whit)}.should be_empty end it "should copy labels" do @depgraph.edges.each do |edge| edge.label.should == {:callback => :refresh} end end it "should not add labels to edges that have none" do @depgraph.add_edge(@two, @three) splice @depgraph.edges_between("c", "i")[0].label.should == {} end it "should copy labels over edges that have none" do @depgraph.add_edge("c", @three, {:callback => :refresh}) splice # And make sure the label got copied. @depgraph.edges_between("c", "i")[0].label.should == {:callback => :refresh} end it "should not replace a label with a nil label" do # Lastly, add some new label-less edges and make sure the label stays. @depgraph.add_edge(@middle, @three) @depgraph.add_edge("c", @three, {:callback => :refresh}) splice @depgraph.edges_between("c", "i")[0].label.should == {:callback => :refresh} end it "should copy labels to all created edges" do @depgraph.add_edge(@middle, @three) @depgraph.add_edge("c", @three, {:callback => :refresh}) splice @three.each do |child| edge = Puppet::Relationship.new("c", child) @depgraph.should be_edge(edge.source, edge.target) @depgraph.edges_between(edge.source, edge.target)[0].label.should == {:callback => :refresh} end end end it "should serialize to YAML using the old format by default" do Puppet::SimpleGraph.use_new_yaml_format.should == false end describe "(yaml tests)" do def empty_graph(graph) end def one_vertex_graph(graph) graph.add_vertex(:a) end def graph_without_edges(graph) [:a, :b, :c].each { |x| graph.add_vertex(x) } end def one_edge_graph(graph) graph.add_edge(:a, :b) end def many_edge_graph(graph) graph.add_edge(:a, :b) graph.add_edge(:a, :c) graph.add_edge(:b, :d) graph.add_edge(:c, :d) end def labeled_edge_graph(graph) graph.add_edge(:a, :b, :callback => :foo, :event => :bar) end def overlapping_edge_graph(graph) graph.add_edge(:a, :b, :callback => :foo, :event => :bar) graph.add_edge(:a, :b, :callback => :biz, :event => :baz) end def self.all_test_graphs [:empty_graph, :one_vertex_graph, :graph_without_edges, :one_edge_graph, :many_edge_graph, :labeled_edge_graph, :overlapping_edge_graph] end def object_ids(enumerable) # Return a sorted list of the object id's of the elements of an # enumerable. enumerable.collect { |x| x.object_id }.sort end def graph_to_yaml(graph, which_format) previous_use_new_yaml_format = Puppet::SimpleGraph.use_new_yaml_format Puppet::SimpleGraph.use_new_yaml_format = (which_format == :new) ZAML.dump(graph) ensure Puppet::SimpleGraph.use_new_yaml_format = previous_use_new_yaml_format end # Test serialization of graph to YAML. [:old, :new].each do |which_format| all_test_graphs.each do |graph_to_test| it "should be able to serialize #{graph_to_test} to YAML (#{which_format} format)" do graph = Puppet::SimpleGraph.new send(graph_to_test, graph) yaml_form = graph_to_yaml(graph, which_format) # Hack the YAML so that objects in the Puppet namespace get # changed to YAML::DomainType objects. This lets us inspect # the serialized objects easily without invoking any # yaml_initialize hooks. yaml_form.gsub!('!ruby/object:Puppet::', '!hack/object:Puppet::') serialized_object = YAML.load(yaml_form) # Check that the object contains instance variables @edges and # @vertices only. @reversal is also permitted, but we don't # check it, because it is going to be phased out. serialized_object.type_id.should == 'object:Puppet::SimpleGraph' serialized_object.value.keys.reject { |x| x == 'reversal' }.sort.should == ['edges', 'vertices'] # Check edges by forming a set of tuples (source, target, # callback, event) based on the graph and the YAML and make sure # they match. edges = serialized_object.value['edges'] edges.should be_a(Array) expected_edge_tuples = graph.edges.collect { |edge| [edge.source, edge.target, edge.callback, edge.event] } actual_edge_tuples = edges.collect do |edge| edge.type_id.should == 'object:Puppet::Relationship' %w{source target}.each { |x| edge.value.keys.should include(x) } edge.value.keys.each { |x| ['source', 'target', 'callback', 'event'].should include(x) } %w{source target callback event}.collect { |x| edge.value[x] } end Set.new(actual_edge_tuples).should == Set.new(expected_edge_tuples) actual_edge_tuples.length.should == expected_edge_tuples.length # Check vertices one by one. vertices = serialized_object.value['vertices'] if which_format == :old vertices.should be_a(Hash) Set.new(vertices.keys).should == Set.new(graph.vertices) vertices.each do |key, value| value.type_id.should == 'object:Puppet::SimpleGraph::VertexWrapper' value.value.keys.sort.should == %w{adjacencies vertex} value.value['vertex'].should equal(key) adjacencies = value.value['adjacencies'] adjacencies.should be_a(Hash) Set.new(adjacencies.keys).should == Set.new([:in, :out]) [:in, :out].each do |direction| adjacencies[direction].should be_a(Hash) expected_adjacent_vertices = Set.new(graph.adjacent(key, :direction => direction, :type => :vertices)) Set.new(adjacencies[direction].keys).should == expected_adjacent_vertices adjacencies[direction].each do |adj_key, adj_value| # Since we already checked edges, just check consistency # with edges. desired_source = direction == :in ? adj_key : key desired_target = direction == :in ? key : adj_key expected_edges = edges.select do |edge| edge.value['source'] == desired_source && edge.value['target'] == desired_target end adj_value.should be_a(Set) if object_ids(adj_value) != object_ids(expected_edges) raise "For vertex #{key.inspect}, direction #{direction.inspect}: expected adjacencies #{expected_edges.inspect} but got #{adj_value.inspect}" end end end end else vertices.should be_a(Array) Set.new(vertices).should == Set.new(graph.vertices) vertices.length.should == graph.vertices.length end end end # Test deserialization of graph from YAML. This presumes the # correctness of serialization to YAML, which has already been # tested. all_test_graphs.each do |graph_to_test| it "should be able to deserialize #{graph_to_test} from YAML (#{which_format} format)" do reference_graph = Puppet::SimpleGraph.new send(graph_to_test, reference_graph) yaml_form = graph_to_yaml(reference_graph, which_format) recovered_graph = YAML.load(yaml_form) # Test that the recovered vertices match the vertices in the # reference graph. expected_vertices = reference_graph.vertices.to_a recovered_vertices = recovered_graph.vertices.to_a Set.new(recovered_vertices).should == Set.new(expected_vertices) recovered_vertices.length.should == expected_vertices.length # Test that the recovered edges match the edges in the # reference graph. expected_edge_tuples = reference_graph.edges.collect do |edge| [edge.source, edge.target, edge.callback, edge.event] end recovered_edge_tuples = recovered_graph.edges.collect do |edge| [edge.source, edge.target, edge.callback, edge.event] end Set.new(recovered_edge_tuples).should == Set.new(expected_edge_tuples) recovered_edge_tuples.length.should == expected_edge_tuples.length # We ought to test that the recovered graph is self-consistent # too. But we're not going to bother with that yet because # the internal representation of the graph is about to change. end end it "should be able to serialize a graph where the vertices contain backreferences to the graph (#{which_format} format)" do reference_graph = Puppet::SimpleGraph.new vertex = Object.new vertex.instance_eval { @graph = reference_graph } reference_graph.add_edge(vertex, :other_vertex) yaml_form = graph_to_yaml(reference_graph, which_format) recovered_graph = YAML.load(yaml_form) recovered_graph.vertices.length.should == 2 recovered_vertex = recovered_graph.vertices.reject { |x| x.is_a?(Symbol) }[0] recovered_vertex.instance_eval { @graph }.should equal(recovered_graph) recovered_graph.edges.length.should == 1 recovered_edge = recovered_graph.edges[0] recovered_edge.source.should equal(recovered_vertex) recovered_edge.target.should == :other_vertex end end it "should serialize properly when used as a base class" do class Puppet::TestDerivedClass < Puppet::SimpleGraph attr_accessor :foo end derived = Puppet::TestDerivedClass.new derived.add_edge(:a, :b) derived.foo = 1234 recovered_derived = YAML.load(YAML.dump(derived)) recovered_derived.class.should equal(Puppet::TestDerivedClass) recovered_derived.edges.length.should == 1 recovered_derived.edges[0].source.should == :a recovered_derived.edges[0].target.should == :b recovered_derived.vertices.length.should == 2 recovered_derived.foo.should == 1234 end end end diff --git a/spec/unit/type/file/content_spec.rb b/spec/unit/type/file/content_spec.rb index 9178c94bf..bd2b2adaf 100755 --- a/spec/unit/type/file/content_spec.rb +++ b/spec/unit/type/file/content_spec.rb @@ -1,514 +1,436 @@ #!/usr/bin/env ruby Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") } content = Puppet::Type.type(:file).attrclass(:content) describe content do + include PuppetSpec::Files before do - @resource = Puppet::Type.type(:file).new :path => "/foo/bar" + @filename = tmpfile('testfile') + @resource = Puppet::Type.type(:file).new :path => @filename + File.open(@filename, 'w') {|f| f.write "initial file content"} content.stubs(:standalone?).returns(false) end - it "should be a subclass of Property" do - content.superclass.must == Puppet::Property - end - describe "when determining the checksum type" do it "should use the type specified in the source checksum if a source is set" do @resource[:source] = "/foo" @resource.parameter(:source).expects(:checksum).returns "{md5lite}eh" @content = content.new(:resource => @resource) @content.checksum_type.should == :md5lite end it "should use the type specified by the checksum parameter if no source is set" do @resource[:checksum] = :md5lite @content = content.new(:resource => @resource) @content.checksum_type.should == :md5lite end end describe "when determining the actual content to write" do it "should use the set content if available" do @content = content.new(:resource => @resource) @content.should = "ehness" @content.actual_content.should == "ehness" end it "should not use the content from the source if the source is set" do source = mock 'source' @resource.expects(:parameter).never.with(:source).returns source @content = content.new(:resource => @resource) @content.actual_content.should be_nil end end describe "when setting the desired content" do it "should make the actual content available via an attribute" do @content = content.new(:resource => @resource) @content.stubs(:checksum_type).returns "md5" @content.should = "this is some content" @content.actual_content.should == "this is some content" end it "should store the checksum as the desired content" do @content = content.new(:resource => @resource) digest = Digest::MD5.hexdigest("this is some content") @content.stubs(:checksum_type).returns "md5" @content.should = "this is some content" @content.should.must == "{md5}#{digest}" end it "should not checksum 'absent'" do @content = content.new(:resource => @resource) @content.should = :absent @content.should.must == :absent end it "should accept a checksum as the desired content" do @content = content.new(:resource => @resource) digest = Digest::MD5.hexdigest("this is some content") string = "{md5}#{digest}" @content.should = string @content.should.must == string end end describe "when retrieving the current content" do it "should return :absent if the file does not exist" do @content = content.new(:resource => @resource) @resource.expects(:stat).returns nil @content.retrieve.should == :absent end it "should not manage content on directories" do @content = content.new(:resource => @resource) stat = mock 'stat', :ftype => "directory" @resource.expects(:stat).returns stat @content.retrieve.should be_nil end it "should not manage content on links" do @content = content.new(:resource => @resource) stat = mock 'stat', :ftype => "link" @resource.expects(:stat).returns stat @content.retrieve.should be_nil end it "should always return the checksum as a string" do @content = content.new(:resource => @resource) @resource[:checksum] = :mtime stat = mock 'stat', :ftype => "file" @resource.expects(:stat).returns stat time = Time.now @resource.parameter(:checksum).expects(:mtime_file).with(@resource[:path]).returns time @content.retrieve.should == "{mtime}#{time}" end it "should return the checksum of the file if it exists and is a normal file" do @content = content.new(:resource => @resource) stat = mock 'stat', :ftype => "file" @resource.expects(:stat).returns stat @resource.parameter(:checksum).expects(:md5_file).with(@resource[:path]).returns "mysum" @content.retrieve.should == "{md5}mysum" end end describe "when testing whether the content is in sync" do before do @resource[:ensure] = :file @content = content.new(:resource => @resource) end it "should return true if the resource shouldn't be a regular file" do @resource.expects(:should_be_file?).returns false @content.should = "foo" @content.must be_safe_insync("whatever") end it "should return false if the current content is :absent" do @content.should = "foo" @content.should_not be_safe_insync(:absent) end it "should return false if the file should be a file but is not present" do @resource.expects(:should_be_file?).returns true @content.should = "foo" @content.should_not be_safe_insync(:absent) end describe "and the file exists" do before do @resource.stubs(:stat).returns mock("stat") end it "should return false if the current contents are different from the desired content" do @content.should = "some content" @content.should_not be_safe_insync("other content") end it "should return true if the sum for the current contents is the same as the sum for the desired content" do @content.should = "some content" @content.must be_safe_insync("{md5}" + Digest::MD5.hexdigest("some content")) end describe "and Puppet[:show_diff] is set" do before do Puppet[:show_diff] = true end it "should display a diff if the current contents are different from the desired content" do @content.should = "some content" @content.expects(:diff).returns("my diff").once @content.expects(:print).with("my diff").once @content.safe_insync?("other content") end it "should not display a diff if the sum for the current contents is the same as the sum for the desired content" do @content.should = "some content" @content.expects(:diff).never @content.safe_insync?("{md5}" + Digest::MD5.hexdigest("some content")) end end end describe "and :replace is false" do before do @resource.stubs(:replace?).returns false end it "should be insync if the file exists and the content is different" do @resource.stubs(:stat).returns mock('stat') @content.must be_safe_insync("whatever") end it "should be insync if the file exists and the content is right" do @resource.stubs(:stat).returns mock('stat') @content.must be_safe_insync("something") end it "should not be insync if the file does not exist" do @content.should = "foo" @content.should_not be_safe_insync(:absent) end end end describe "when changing the content" do before do @content = content.new(:resource => @resource) @content.should = "some content" @resource.stubs(:[]).with(:path).returns "/boo" @resource.stubs(:stat).returns "eh" end it "should use the file's :write method to write the content" do @resource.expects(:write).with(:content) @content.sync end it "should return :file_changed if the file already existed" do @resource.expects(:stat).returns "something" @resource.stubs(:write) @content.sync.should == :file_changed end it "should return :file_created if the file did not exist" do @resource.expects(:stat).returns nil @resource.stubs(:write) @content.sync.should == :file_created end end describe "when writing" do before do @content = content.new(:resource => @resource) - @fh = stub_everything end it "should attempt to read from the filebucket if no actual content nor source exists" do + @fh = File.open(@filename, 'w') @content.should = "{md5}foo" @content.resource.bucket.class.any_instance.stubs(:getfile).returns "foo" @content.write(@fh) end describe "from actual content" do before(:each) do @content.stubs(:actual_content).returns("this is content") end it "should write to the given file handle" do @fh.expects(:print).with("this is content") @content.write(@fh) end it "should return the current checksum value" do @resource.parameter(:checksum).expects(:sum_stream).returns "checksum" @content.write(@fh).should == "checksum" end end describe "from a file bucket" do it "should fail if a file bucket cannot be retrieved" do @content.should = "{md5}foo" @content.resource.expects(:bucket).returns nil lambda { @content.write(@fh) }.should raise_error(Puppet::Error) end it "should fail if the file bucket cannot find any content" do @content.should = "{md5}foo" bucket = stub 'bucket' @content.resource.expects(:bucket).returns bucket bucket.expects(:getfile).with("foo").raises "foobar" lambda { @content.write(@fh) }.should raise_error(Puppet::Error) end it "should write the returned content to the file" do @content.should = "{md5}foo" bucket = stub 'bucket' @content.resource.expects(:bucket).returns bucket bucket.expects(:getfile).with("foo").returns "mycontent" @fh.expects(:print).with("mycontent") @content.write(@fh) end end describe "from local source" do before(:each) do - @content.stubs(:actual_content).returns(nil) - @source = stub_everything 'source', :local? => true, :full_path => "/path/to/source" - @resource.stubs(:parameter).with(:source).returns @source - - @sum = stub_everything 'sum' - @resource.stubs(:parameter).with(:checksum).returns(@sum) - - @digest = stub_everything 'digest' - @sum.stubs(:sum_stream).yields(@digest) - - @file = stub_everything 'file' - File.stubs(:open).yields(@file) - @file.stubs(:read).with(8192).returns("chunk1").then.returns("chunk2").then.returns(nil) - end - - it "should open the local file" do - File.expects(:open).with("/path/to/source", "r") - @content.write(@fh) - end - - it "should read the local file by chunks" do - @file.expects(:read).with(8192).returns("chunk1").then.returns(nil) - @content.write(@fh) - end + @resource = Puppet::Type.type(:file).new :path => @filename, :backup => false + @sourcename = tmpfile('source') + @source_content = "source file content"*10000 + @sourcefile = File.open(@sourcename, 'w') {|f| f.write @source_content} - it "should write each chunk to the file" do - @fh.expects(:print).with("chunk1").then.with("chunk2") - @content.write(@fh) + @content = @resource.newattr(:content) + @source = @resource.newattr(:source) + @source.stubs(:metadata).returns stub_everything('metadata', :source => @sourcename, :ftype => 'file') end - it "should pass each chunk to the current sum stream" do - @digest.expects(:<<).with("chunk1").then.with("chunk2") - @content.write(@fh) + it "should copy content from the source to the file" do + @resource.write(@source) + File.read(@filename).should == @source_content end it "should return the checksum computed" do - @sum.stubs(:sum_stream).yields(@digest).returns("checksum") - @content.write(@fh).should == "checksum" + File.open(@filename, 'w') do |file| + @content.write(file).should == "{md5}#{Digest::MD5.hexdigest(@source_content)}" + end end end describe "from remote source" do before(:each) do - @response = stub_everything 'mock response', :code => "404" + @resource = Puppet::Type.type(:file).new :path => @filename, :backup => false + @response = stub_everything 'response', :code => "200" + @source_content = "source file content"*10000 + @response.stubs(:read_body).multiple_yields(*(["source file content"]*10000)) + @conn = stub_everything 'connection' @conn.stubs(:request_get).yields(@response) Puppet::Network::HttpPool.stubs(:http_instance).returns @conn - @content.stubs(:actual_content).returns(nil) - @source = stub_everything 'source', :local? => false, :full_path => "/path/to/source", :server => "server", :port => 1234 - @resource.stubs(:parameter).with(:source).returns @source - - @sum = stub_everything 'sum' - @resource.stubs(:parameter).with(:checksum).returns(@sum) - - @digest = stub_everything 'digest' - @sum.stubs(:sum_stream).yields(@digest) - end - - it "should open a network connection to source server and port" do - Puppet::Network::HttpPool.expects(:http_instance).with("server", 1234).returns @conn - @content.write(@fh) + @content = @resource.newattr(:content) + @sourcename = "puppet:///test/foo" + @source = @resource.newattr(:source) + @source.stubs(:metadata).returns stub_everything('metadata', :source => @sourcename, :ftype => 'file') end - it "should send the correct indirection uri" do - @conn.expects(:request_get).with { |uri,headers| uri == "/production/file_content/path/to/source" }.yields(@response) - @content.write(@fh) - end - - it "should return nil if source is not found" do - @response.expects(:code).returns("404") - @content.write(@fh).should == nil + it "should write the contents to the file" do + @resource.write(@source) + File.read(@filename).should == @source_content end it "should not write anything if source is not found" do - @response.expects(:code).returns("404") - @fh.expects(:print).never - @content.write(@fh).should == nil + @response.stubs(:code).returns("404") + lambda {@resource.write(@source)}.should raise_error(Net::HTTPError) { |e| e.message =~ /404/ } + File.read(@filename).should == "initial file content" end it "should raise an HTTP error in case of server error" do - @response.expects(:code).returns("500") - lambda { @content.write(@fh) }.should raise_error - end - - it "should write content by chunks" do - @response.expects(:code).returns("200") - @response.expects(:read_body).multiple_yields("chunk1","chunk2") - @fh.expects(:print).with("chunk1").then.with("chunk2") - @content.write(@fh) - end - - it "should pass each chunk to the current sum stream" do - @response.expects(:code).returns("200") - @response.expects(:read_body).multiple_yields("chunk1","chunk2") - @digest.expects(:<<).with("chunk1").then.with("chunk2") - @content.write(@fh) + @response.stubs(:code).returns("500") + lambda { @content.write(@fh) }.should raise_error { |e| e.message.include? @source_content } end it "should return the checksum computed" do - @response.expects(:code).returns("200") - @response.expects(:read_body).multiple_yields("chunk1","chunk2") - @sum.expects(:sum_stream).yields(@digest).returns("checksum") - @content.write(@fh).should == "checksum" - end - - it "should get the current accept encoding header value" do - @content.expects(:add_accept_encoding) - @content.write(@fh) - end - - it "should uncompress body on error" do - @response.expects(:code).returns("500") - @response.expects(:body).returns("compressed body") - @content.expects(:uncompress_body).with(@response).returns("uncompressed") - lambda { @content.write(@fh) }.should raise_error { |e| e.message =~ /uncompressed/ } - end - - it "should uncompress chunk by chunk" do - uncompressor = stub_everything 'uncompressor' - @content.expects(:uncompress).with(@response).yields(uncompressor) - @response.expects(:code).returns("200") - @response.expects(:read_body).multiple_yields("chunk1","chunk2") - - uncompressor.expects(:uncompress).with("chunk1").then.with("chunk2") - @content.write(@fh) - end - - it "should write uncompressed chunks to the file" do - uncompressor = stub_everything 'uncompressor' - @content.expects(:uncompress).with(@response).yields(uncompressor) - @response.expects(:code).returns("200") - @response.expects(:read_body).multiple_yields("chunk1","chunk2") - - uncompressor.expects(:uncompress).with("chunk1").returns("uncompressed1") - uncompressor.expects(:uncompress).with("chunk2").returns("uncompressed2") - - @fh.expects(:print).with("uncompressed1") - @fh.expects(:print).with("uncompressed2") - - @content.write(@fh) - end - - it "should pass each uncompressed chunk to the current sum stream" do - uncompressor = stub_everything 'uncompressor' - @content.expects(:uncompress).with(@response).yields(uncompressor) - @response.expects(:code).returns("200") - @response.expects(:read_body).multiple_yields("chunk1","chunk2") - - uncompressor.expects(:uncompress).with("chunk1").returns("uncompressed1") - uncompressor.expects(:uncompress).with("chunk2").returns("uncompressed2") - - @digest.expects(:<<).with("uncompressed1").then.with("uncompressed2") - @content.write(@fh) + File.open(@filename, 'w') do |file| + @content.write(file).should == "{md5}#{Digest::MD5.hexdigest(@source_content)}" + end end end - describe "from a filebucket" do - end - # These are testing the implementation rather than the desired behaviour; while that bites, there are a whole # pile of other methods in the File type that depend on intimate details of this implementation and vice-versa. # If these blow up, you are gonna have to review the callers to make sure they don't explode! --daniel 2011-02-01 describe "each_chunk_from should work" do before do @content = content.new(:resource => @resource) end it "when content is a string" do @content.each_chunk_from('i_am_a_string') { |chunk| chunk.should == 'i_am_a_string' } end + # The following manifest is a case where source and content.should are both set + # file { "/tmp/mydir" : + # source => '/tmp/sourcedir', + # recurse => true, + # } + it "when content checksum comes from source" do + source_param = Puppet::Type.type(:file).attrclass(:source) + source = source_param.new(:resource => @resource) + @content.should = "{md5}123abcd" + + @content.expects(:chunk_file_from_source).returns('from_source') + @content.each_chunk_from(source) { |chunk| chunk.should == 'from_source' } + end + it "when no content, source, but ensure present" do @resource[:ensure] = :present @content.each_chunk_from(nil) { |chunk| chunk.should == '' } end + # you might do this if you were just auditing it "when no content, source, but ensure file" do @resource[:ensure] = :file @content.each_chunk_from(nil) { |chunk| chunk.should == '' } end - it "when no content or source" do + it "when source_or_content is nil and content not a checksum" do + @content.each_chunk_from(nil) { |chunk| chunk.should == '' } + end + + # the content is munged so that if it's a checksum nil gets passed in + it "when content is a checksum it should try to read from filebucket" do + @content.should = "{md5}123abcd" @content.expects(:read_file_from_filebucket).once.returns('im_a_filebucket') @content.each_chunk_from(nil) { |chunk| chunk.should == 'im_a_filebucket' } end it "when running as puppet apply" do @content.class.expects(:standalone?).returns true source_or_content = stubs('source_or_content') source_or_content.expects(:content).once.returns :whoo @content.each_chunk_from(source_or_content) { |chunk| chunk.should == :whoo } end it "when running from source with a local file" do source_or_content = stubs('source_or_content') source_or_content.expects(:local?).returns true @content.expects(:chunk_file_from_disk).with(source_or_content).once.yields 'woot' @content.each_chunk_from(source_or_content) { |chunk| chunk.should == 'woot' } end it "when running from source with a remote file" do source_or_content = stubs('source_or_content') source_or_content.expects(:local?).returns false @content.expects(:chunk_file_from_source).with(source_or_content).once.yields 'woot' @content.each_chunk_from(source_or_content) { |chunk| chunk.should == 'woot' } end end end end diff --git a/spec/unit/type/file/selinux_spec.rb b/spec/unit/type/file/selinux_spec.rb index 043471dec..a2444acd9 100644 --- a/spec/unit/type/file/selinux_spec.rb +++ b/spec/unit/type/file/selinux_spec.rb @@ -1,83 +1,88 @@ #!/usr/bin/env ruby Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") } [:seluser, :selrole, :seltype, :selrange].each do |param| property = Puppet::Type.type(:file).attrclass(param) describe property do before do @resource = Puppet::Type.type(:file).new :path => "/my/file" @sel = property.new :resource => @resource end it "retrieve on #{param} should return :absent if the file isn't statable" do @resource.expects(:stat).returns nil @sel.retrieve.should == :absent end it "should retrieve nil for #{param} if there is no SELinux support" do stat = stub 'stat', :ftype => "foo" @resource.expects(:stat).returns stat @sel.expects(:get_selinux_current_context).with("/my/file").returns nil @sel.retrieve.should be_nil end it "should retrieve #{param} if a SELinux context is found with a range" do stat = stub 'stat', :ftype => "foo" @resource.expects(:stat).returns stat @sel.expects(:get_selinux_current_context).with("/my/file").returns "user_u:role_r:type_t:s0" expectedresult = case param when :seluser; "user_u" when :selrole; "role_r" when :seltype; "type_t" when :selrange; "s0" end @sel.retrieve.should == expectedresult end it "should retrieve #{param} if a SELinux context is found without a range" do stat = stub 'stat', :ftype => "foo" @resource.expects(:stat).returns stat @sel.expects(:get_selinux_current_context).with("/my/file").returns "user_u:role_r:type_t" expectedresult = case param when :seluser; "user_u" when :selrole; "role_r" when :seltype; "type_t" when :selrange; nil end @sel.retrieve.should == expectedresult end it "should handle no default gracefully" do @sel.expects(:get_selinux_default_context).with("/my/file").returns nil @sel.default.must be_nil end it "should be able to detect matchpathcon defaults" do @sel.stubs(:debug) @sel.expects(:get_selinux_default_context).with("/my/file").returns "user_u:role_r:type_t:s0" expectedresult = case param when :seluser; "user_u" when :selrole; "role_r" when :seltype; "type_t" when :selrange; "s0" end @sel.default.must == expectedresult end + it "should return nil for defaults if selinux_ignore_defaults is true" do + @resource[:selinux_ignore_defaults] = :true + @sel.default.must be_nil + end + it "should be able to set a new context" do stat = stub 'stat', :ftype => "foo" @sel.should = %w{newone} @sel.expects(:set_selinux_context).with("/my/file", ["newone"], param) @sel.sync end it "should do nothing for safe_insync? if no SELinux support" do @sel.should = %{newcontext} @sel.expects(:selinux_support?).returns false @sel.safe_insync?("oldcontext").should == true end end end diff --git a/spec/unit/type/file_spec.rb b/spec/unit/type/file_spec.rb index 539782fd4..b15d41d4b 100755 --- a/spec/unit/type/file_spec.rb +++ b/spec/unit/type/file_spec.rb @@ -1,1193 +1,1185 @@ #!/usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') describe Puppet::Type.type(:file) do before do Puppet.settings.stubs(:use) @real_posix = Puppet.features.posix? Puppet.features.stubs("posix?").returns(true) @path = Tempfile.new("puppetspec") pathname = @path.path @path.close!() @path = pathname @file = Puppet::Type::File.new(:name => @path) @catalog = Puppet::Resource::Catalog.new @file.catalog = @catalog end describe "when determining if recursion is enabled" do it "should default to recursion being disabled" do @file.should_not be_recurse end [true, "true", 10, "inf", "remote"].each do |value| it "should consider #{value} to enable recursion" do @file[:recurse] = value @file.must be_recurse end end [false, "false", 0].each do |value| it "should consider #{value} to disable recursion" do @file[:recurse] = value @file.should_not be_recurse end end end describe "#write" do it "should propagate failures encountered when renaming the temporary file" do File.stubs(:open) File.expects(:rename).raises ArgumentError file = Puppet::Type::File.new(:name => "/my/file", :backup => "puppet") file.stubs(:validate_checksum?).returns(false) property = stub('content_property', :actual_content => "something", :length => "something".length) file.stubs(:property).with(:content).returns(property) lambda { file.write(:content) }.should raise_error(Puppet::Error) end it "should delegate writing to the content property" do filehandle = stub_everything 'fh' File.stubs(:open).yields(filehandle) File.stubs(:rename) property = stub('content_property', :actual_content => "something", :length => "something".length) file = Puppet::Type::File.new(:name => "/my/file", :backup => "puppet") file.stubs(:validate_checksum?).returns(false) file.stubs(:property).with(:content).returns(property) property.expects(:write).with(filehandle) file.write(:content) end describe "when validating the checksum" do before { @file.stubs(:validate_checksum?).returns(true) } it "should fail if the checksum parameter and content checksums do not match" do checksum = stub('checksum_parameter', :sum => 'checksum_b', :sum_file => 'checksum_b') @file.stubs(:parameter).with(:checksum).returns(checksum) property = stub('content_property', :actual_content => "something", :length => "something".length, :write => 'checksum_a') @file.stubs(:property).with(:content).returns(property) lambda { @file.write :NOTUSED }.should raise_error(Puppet::Error) end end describe "when not validating the checksum" do before { @file.stubs(:validate_checksum?).returns(false) } it "should not fail if the checksum property and content checksums do not match" do checksum = stub('checksum_parameter', :sum => 'checksum_b') @file.stubs(:parameter).with(:checksum).returns(checksum) property = stub('content_property', :actual_content => "something", :length => "something".length, :write => 'checksum_a') @file.stubs(:property).with(:content).returns(property) lambda { @file.write :NOTUSED }.should_not raise_error(Puppet::Error) end end end it "should have a method for determining if the file is present" do @file.must respond_to(:exist?) end it "should be considered existent if it can be stat'ed" do @file.expects(:stat).returns mock('stat') @file.must be_exist end it "should be considered nonexistent if it can not be stat'ed" do @file.expects(:stat).returns nil @file.must_not be_exist end it "should have a method for determining if the file should be a normal file" do @file.must respond_to(:should_be_file?) end it "should be a file if :ensure is set to :file" do @file[:ensure] = :file @file.must be_should_be_file end it "should be a file if :ensure is set to :present and the file exists as a normal file" do @file.stubs(:stat).returns(mock('stat', :ftype => "file")) @file[:ensure] = :present @file.must be_should_be_file end it "should not be a file if :ensure is set to something other than :file" do @file[:ensure] = :directory @file.must_not be_should_be_file end it "should not be a file if :ensure is set to :present and the file exists but is not a normal file" do @file.stubs(:stat).returns(mock('stat', :ftype => "directory")) @file[:ensure] = :present @file.must_not be_should_be_file end it "should be a file if :ensure is not set and :content is" do @file[:content] = "foo" @file.must be_should_be_file end it "should be a file if neither :ensure nor :content is set but the file exists as a normal file" do @file.stubs(:stat).returns(mock("stat", :ftype => "file")) @file.must be_should_be_file end it "should not be a file if neither :ensure nor :content is set but the file exists but not as a normal file" do @file.stubs(:stat).returns(mock("stat", :ftype => "directory")) @file.must_not be_should_be_file end describe "when using POSIX filenames" do describe "on POSIX systems" do before do Puppet.features.stubs(:posix?).returns(true) Puppet.features.stubs(:microsoft_windows?).returns(false) end it "should autorequire its parent directory" do file = Puppet::Type::File.new(:path => "/foo/bar") dir = Puppet::Type::File.new(:path => "/foo") @catalog.add_resource file @catalog.add_resource dir reqs = file.autorequire reqs[0].source.must == dir reqs[0].target.must == file end it "should not autorequire its parent dir if its parent dir is itself" do file = Puppet::Type::File.new(:path => "/") @catalog.add_resource file file.autorequire.should be_empty end it "should remove trailing slashes" do file = Puppet::Type::File.new(:path => "/foo/bar/baz/") file[:path].should == "/foo/bar/baz" end it "should remove double slashes" do file = Puppet::Type::File.new(:path => "/foo/bar//baz") file[:path].should == "/foo/bar/baz" end it "should remove trailing double slashes" do file = Puppet::Type::File.new(:path => "/foo/bar/baz//") file[:path].should == "/foo/bar/baz" end it "should leave a single slash alone" do file = Puppet::Type::File.new(:path => "/") file[:path].should == "/" end it "should accept a double-slash at the start of the path" do expect { file = Puppet::Type::File.new(:path => "//tmp/xxx") # REVISIT: This should be wrong, later. See the next test. # --daniel 2011-01-31 file[:path].should == '/tmp/xxx' }.should_not raise_error end # REVISIT: This is pending, because I don't want to try and audit the # entire codebase to make sure we get this right. POSIX treats two (and # exactly two) '/' characters at the start of the path specially. # # See sections 3.2 and 4.11, which allow DomainOS to be all special like # and still have the POSIX branding and all. --daniel 2011-01-31 it "should preserve the double-slash at the start of the path" end describe "on Microsoft Windows systems" do before do Puppet.features.stubs(:posix?).returns(false) Puppet.features.stubs(:microsoft_windows?).returns(true) end it "should refuse to work" do lambda { Puppet::Type::File.new(:path => "/foo/bar") }.should raise_error(Puppet::Error) end end end describe "when using Microsoft Windows filenames", :if => Puppet.features.microsoft_windows? do describe "on Microsoft Windows systems" do before do Puppet.features.stubs(:posix?).returns(false) Puppet.features.stubs(:microsoft_windows?).returns(true) end it "should autorequire its parent directory" do file = Puppet::Type::File.new(:path => "X:/foo/bar") dir = Puppet::Type::File.new(:path => "X:/foo") @catalog.add_resource file @catalog.add_resource dir reqs = file.autorequire reqs[0].source.must == dir reqs[0].target.must == file end it "should not autorequire its parent dir if its parent dir is itself" do file = Puppet::Type::File.new(:path => "X:/") @catalog.add_resource file file.autorequire.should be_empty end it "should remove trailing slashes" do file = Puppet::Type::File.new(:path => "X:/foo/bar/baz/") file[:path].should == "X:/foo/bar/baz" end it "should remove double slashes" do file = Puppet::Type::File.new(:path => "X:/foo/bar//baz") file[:path].should == "X:/foo/bar/baz" end it "should remove trailing double slashes" do file = Puppet::Type::File.new(:path => "X:/foo/bar/baz//") file[:path].should == "X:/foo/bar/baz" end it "should leave a drive letter with a slash alone" do file = Puppet::Type::File.new(:path => "X:/") file[:path].should == "X:/" end it "should add a slash to a drive letter" do file = Puppet::Type::File.new(:path => "X:") file[:path].should == "X:/" end end describe "on POSIX systems" do before do Puppet.features.stubs(:posix?).returns(true) Puppet.features.stubs(:microsoft_windows?).returns(false) end it "should refuse to work" do lambda { Puppet::Type::File.new(:path => "X:/foo/bar") }.should raise_error(Puppet::Error) end end end describe "when using UNC filenames" do describe "on Microsoft Windows systems", :if => Puppet.features.microsoft_windows? do before do Puppet.features.stubs(:posix?).returns(false) Puppet.features.stubs(:microsoft_windows?).returns(true) end it "should autorequire its parent directory" do file = Puppet::Type::File.new(:path => "//server/foo/bar") dir = Puppet::Type::File.new(:path => "//server/foo") @catalog.add_resource file @catalog.add_resource dir reqs = file.autorequire reqs[0].source.must == dir reqs[0].target.must == file end it "should not autorequire its parent dir if its parent dir is itself" do file = Puppet::Type::File.new(:path => "//server/foo") @catalog.add_resource file puts file.autorequire file.autorequire.should be_empty end it "should remove trailing slashes" do file = Puppet::Type::File.new(:path => "//server/foo/bar/baz/") file[:path].should == "//server/foo/bar/baz" end it "should remove double slashes" do file = Puppet::Type::File.new(:path => "//server/foo/bar//baz") file[:path].should == "//server/foo/bar/baz" end it "should remove trailing double slashes" do file = Puppet::Type::File.new(:path => "//server/foo/bar/baz//") file[:path].should == "//server/foo/bar/baz" end it "should remove a trailing slash from a sharename" do file = Puppet::Type::File.new(:path => "//server/foo/") file[:path].should == "//server/foo" end it "should not modify a sharename" do file = Puppet::Type::File.new(:path => "//server/foo") file[:path].should == "//server/foo" end end describe "on POSIX systems" do before do Puppet.features.stubs(:posix?).returns(true) Puppet.features.stubs(:microsoft_windows?).returns(false) end it "should refuse to work" do lambda { Puppet::Type::File.new(:path => "X:/foo/bar") }.should raise_error(Puppet::Error) end end end describe "when initializing" do it "should set a desired 'ensure' value if none is set and 'content' is set" do file = Puppet::Type::File.new(:name => "/my/file", :content => "/foo/bar") file[:ensure].should == :file end it "should set a desired 'ensure' value if none is set and 'target' is set" do file = Puppet::Type::File.new(:name => "/my/file", :target => "/foo/bar") file[:ensure].should == :symlink end end describe "when validating attributes" do %w{path checksum backup recurse recurselimit source replace force ignore links purge sourceselect}.each do |attr| it "should have a '#{attr}' parameter" do Puppet::Type.type(:file).attrtype(attr.intern).should == :param end end %w{content target ensure owner group mode type}.each do |attr| it "should have a '#{attr}' property" do Puppet::Type.type(:file).attrtype(attr.intern).should == :property end end it "should have its 'path' attribute set as its namevar" do Puppet::Type.type(:file).key_attributes.should == [:path] end end describe "when managing links" do - require 'puppettest/support/assertions' - include PuppetTest require 'tempfile' if @real_posix describe "on POSIX systems" do before do @basedir = tempfile Dir.mkdir(@basedir) @file = File.join(@basedir, "file") @link = File.join(@basedir, "link") File.open(@file, "w", 0644) { |f| f.puts "yayness"; f.flush } File.symlink(@file, @link) - - @resource = Puppet::Type.type(:file).new( - - :path => @link, - - :mode => "755" - ) + @resource = Puppet::Type.type(:file).new(:path => @link, :mode => "755") @catalog.add_resource @resource end after do remove_tmp_files end it "should default to managing the link" do @catalog.apply # I convert them to strings so they display correctly if there's an error. ("%o" % (File.stat(@file).mode & 007777)).should == "%o" % 0644 end it "should be able to follow links" do @resource[:links] = :follow @catalog.apply ("%o" % (File.stat(@file).mode & 007777)).should == "%o" % 0755 end end else # @real_posix # should recode tests using expectations instead of using the filesystem end describe "on Microsoft Windows systems" do before do Puppet.features.stubs(:posix?).returns(false) Puppet.features.stubs(:microsoft_windows?).returns(true) end it "should refuse to work with links" end end it "should be able to retrieve a stat instance for the file it is managing" do Puppet::Type.type(:file).new(:path => "/foo/bar", :source => "/bar/foo").should respond_to(:stat) end describe "when stat'ing its file" do before do @resource = Puppet::Type.type(:file).new(:path => "/foo/bar") @resource[:links] = :manage # so we always use :lstat end it "should use :stat if it is following links" do @resource[:links] = :follow File.expects(:stat) @resource.stat end it "should use :lstat if is it not following links" do @resource[:links] = :manage File.expects(:lstat) @resource.stat end it "should stat the path of the file" do File.expects(:lstat).with("/foo/bar") @resource.stat end # This only happens in testing. it "should return nil if the stat does not exist" do File.expects(:lstat).returns nil @resource.stat.should be_nil end it "should return nil if the file does not exist" do File.expects(:lstat).raises(Errno::ENOENT) @resource.stat.should be_nil end it "should return nil if the file cannot be stat'ed" do File.expects(:lstat).raises(Errno::EACCES) @resource.stat.should be_nil end it "should return the stat instance" do File.expects(:lstat).returns "mystat" @resource.stat.should == "mystat" end it "should cache the stat instance if it has a catalog and is applying" do stat = mock 'stat' File.expects(:lstat).returns stat catalog = Puppet::Resource::Catalog.new @resource.catalog = catalog catalog.stubs(:applying?).returns true @resource.stat.should equal(@resource.stat) end end describe "when flushing" do it "should flush all properties that respond to :flush" do @resource = Puppet::Type.type(:file).new(:path => "/foo/bar", :source => "/bar/foo") @resource.parameter(:source).expects(:flush) @resource.flush end it "should reset its stat reference" do @resource = Puppet::Type.type(:file).new(:path => "/foo/bar") File.expects(:lstat).times(2).returns("stat1").then.returns("stat2") @resource.stat.should == "stat1" @resource.flush @resource.stat.should == "stat2" end end it "should have a method for performing recursion" do @file.must respond_to(:perform_recursion) end describe "when executing a recursive search" do it "should use Metadata to do its recursion" do Puppet::FileServing::Metadata.indirection.expects(:search) @file.perform_recursion(@file[:path]) end it "should use the provided path as the key to the search" do Puppet::FileServing::Metadata.indirection.expects(:search).with { |key, options| key == "/foo" } @file.perform_recursion("/foo") end it "should return the results of the metadata search" do Puppet::FileServing::Metadata.indirection.expects(:search).returns "foobar" @file.perform_recursion(@file[:path]).should == "foobar" end it "should pass its recursion value to the search" do @file[:recurse] = true Puppet::FileServing::Metadata.indirection.expects(:search).with { |key, options| options[:recurse] == true } @file.perform_recursion(@file[:path]) end it "should pass true if recursion is remote" do @file[:recurse] = :remote Puppet::FileServing::Metadata.indirection.expects(:search).with { |key, options| options[:recurse] == true } @file.perform_recursion(@file[:path]) end it "should pass its recursion limit value to the search" do @file[:recurselimit] = 10 Puppet::FileServing::Metadata.indirection.expects(:search).with { |key, options| options[:recurselimit] == 10 } @file.perform_recursion(@file[:path]) end it "should configure the search to ignore or manage links" do @file[:links] = :manage Puppet::FileServing::Metadata.indirection.expects(:search).with { |key, options| options[:links] == :manage } @file.perform_recursion(@file[:path]) end it "should pass its 'ignore' setting to the search if it has one" do @file[:ignore] = %w{.svn CVS} Puppet::FileServing::Metadata.indirection.expects(:search).with { |key, options| options[:ignore] == %w{.svn CVS} } @file.perform_recursion(@file[:path]) end end it "should have a method for performing local recursion" do @file.must respond_to(:recurse_local) end describe "when doing local recursion" do before do @metadata = stub 'metadata', :relative_path => "my/file" end it "should pass its path to the :perform_recursion method" do @file.expects(:perform_recursion).with(@file[:path]).returns [@metadata] @file.stubs(:newchild) @file.recurse_local end it "should return an empty hash if the recursion returns nothing" do @file.expects(:perform_recursion).returns nil @file.recurse_local.should == {} end it "should create a new child resource with each generated metadata instance's relative path" do @file.expects(:perform_recursion).returns [@metadata] @file.expects(:newchild).with(@metadata.relative_path).returns "fiebar" @file.recurse_local end it "should not create a new child resource for the '.' directory" do @metadata.stubs(:relative_path).returns "." @file.expects(:perform_recursion).returns [@metadata] @file.expects(:newchild).never @file.recurse_local end it "should return a hash of the created resources with the relative paths as the hash keys" do @file.expects(:perform_recursion).returns [@metadata] @file.expects(:newchild).with("my/file").returns "fiebar" @file.recurse_local.should == {"my/file" => "fiebar"} end it "should set checksum_type to none if this file checksum is none" do @file[:checksum] = :none Puppet::FileServing::Metadata.indirection.expects(:search).with { |path,params| params[:checksum_type] == :none }.returns [@metadata] @file.expects(:newchild).with("my/file").returns "fiebar" @file.recurse_local end end it "should have a method for performing link recursion" do @file.must respond_to(:recurse_link) end describe "when doing link recursion" do before do @first = stub 'first', :relative_path => "first", :full_path => "/my/first", :ftype => "directory" @second = stub 'second', :relative_path => "second", :full_path => "/my/second", :ftype => "file" @resource = stub 'file', :[]= => nil end it "should pass its target to the :perform_recursion method" do @file[:target] = "mylinks" @file.expects(:perform_recursion).with("mylinks").returns [@first] @file.stubs(:newchild).returns @resource @file.recurse_link({}) end it "should ignore the recursively-found '.' file and configure the top-level file to create a directory" do @first.stubs(:relative_path).returns "." @file[:target] = "mylinks" @file.expects(:perform_recursion).with("mylinks").returns [@first] @file.stubs(:newchild).never @file.expects(:[]=).with(:ensure, :directory) @file.recurse_link({}) end it "should create a new child resource for each generated metadata instance's relative path that doesn't already exist in the children hash" do @file.expects(:perform_recursion).returns [@first, @second] @file.expects(:newchild).with(@first.relative_path).returns @resource @file.recurse_link("second" => @resource) end it "should not create a new child resource for paths that already exist in the children hash" do @file.expects(:perform_recursion).returns [@first] @file.expects(:newchild).never @file.recurse_link("first" => @resource) end it "should set the target to the full path of discovered file and set :ensure to :link if the file is not a directory" do file = stub 'file' file.expects(:[]=).with(:target, "/my/second") file.expects(:[]=).with(:ensure, :link) @file.stubs(:perform_recursion).returns [@first, @second] @file.recurse_link("first" => @resource, "second" => file) end it "should :ensure to :directory if the file is a directory" do file = stub 'file' file.expects(:[]=).with(:ensure, :directory) @file.stubs(:perform_recursion).returns [@first, @second] @file.recurse_link("first" => file, "second" => @resource) end it "should return a hash with both created and existing resources with the relative paths as the hash keys" do file = stub 'file', :[]= => nil @file.expects(:perform_recursion).returns [@first, @second] @file.stubs(:newchild).returns file @file.recurse_link("second" => @resource).should == {"second" => @resource, "first" => file} end end it "should have a method for performing remote recursion" do @file.must respond_to(:recurse_remote) end describe "when doing remote recursion" do before do @file[:source] = "puppet://foo/bar" @first = Puppet::FileServing::Metadata.new("/my", :relative_path => "first") @second = Puppet::FileServing::Metadata.new("/my", :relative_path => "second") @first.stubs(:ftype).returns "directory" @second.stubs(:ftype).returns "directory" @parameter = stub 'property', :metadata= => nil @resource = stub 'file', :[]= => nil, :parameter => @parameter end it "should pass its source to the :perform_recursion method" do data = Puppet::FileServing::Metadata.new("/whatever", :relative_path => "foobar") @file.expects(:perform_recursion).with("puppet://foo/bar").returns [data] @file.stubs(:newchild).returns @resource @file.recurse_remote({}) end it "should not recurse when the remote file is not a directory" do data = Puppet::FileServing::Metadata.new("/whatever", :relative_path => ".") data.stubs(:ftype).returns "file" @file.expects(:perform_recursion).with("puppet://foo/bar").returns [data] @file.expects(:newchild).never @file.recurse_remote({}) end it "should set the source of each returned file to the searched-for URI plus the found relative path" do @first.expects(:source=).with File.join("puppet://foo/bar", @first.relative_path) @file.expects(:perform_recursion).returns [@first] @file.stubs(:newchild).returns @resource @file.recurse_remote({}) end it "should create a new resource for any relative file paths that do not already have a resource" do @file.stubs(:perform_recursion).returns [@first] @file.expects(:newchild).with("first").returns @resource @file.recurse_remote({}).should == {"first" => @resource} end it "should not create a new resource for any relative file paths that do already have a resource" do @file.stubs(:perform_recursion).returns [@first] @file.expects(:newchild).never @file.recurse_remote("first" => @resource) end it "should set the source of each resource to the source of the metadata" do @file.stubs(:perform_recursion).returns [@first] @resource.stubs(:[]=) @resource.expects(:[]=).with(:source, File.join("puppet://foo/bar", @first.relative_path)) @file.recurse_remote("first" => @resource) end # LAK:FIXME This is a bug, but I can't think of a fix for it. Fortunately it's already # filed, and when it's fixed, we'll just fix the whole flow. it "should set the checksum type to :md5 if the remote file is a file" do @first.stubs(:ftype).returns "file" @file.stubs(:perform_recursion).returns [@first] @resource.stubs(:[]=) @resource.expects(:[]=).with(:checksum, :md5) @file.recurse_remote("first" => @resource) end it "should store the metadata in the source property for each resource so the source does not have to requery the metadata" do @file.stubs(:perform_recursion).returns [@first] @resource.expects(:parameter).with(:source).returns @parameter @parameter.expects(:metadata=).with(@first) @file.recurse_remote("first" => @resource) end it "should not create a new resource for the '.' file" do @first.stubs(:relative_path).returns "." @file.stubs(:perform_recursion).returns [@first] @file.expects(:newchild).never @file.recurse_remote({}) end it "should store the metadata in the main file's source property if the relative path is '.'" do @first.stubs(:relative_path).returns "." @file.stubs(:perform_recursion).returns [@first] @file.parameter(:source).expects(:metadata=).with @first @file.recurse_remote("first" => @resource) end describe "and multiple sources are provided" do describe "and :sourceselect is set to :first" do it "should create file instances for the results for the first source to return any values" do data = Puppet::FileServing::Metadata.new("/whatever", :relative_path => "foobar") @file[:source] = %w{/one /two /three /four} @file.expects(:perform_recursion).with("/one").returns nil @file.expects(:perform_recursion).with("/two").returns [] @file.expects(:perform_recursion).with("/three").returns [data] @file.expects(:perform_recursion).with("/four").never @file.expects(:newchild).with("foobar").returns @resource @file.recurse_remote({}) end end describe "and :sourceselect is set to :all" do before do @file[:sourceselect] = :all end it "should return every found file that is not in a previous source" do klass = Puppet::FileServing::Metadata @file[:source] = %w{/one /two /three /four} @file.stubs(:newchild).returns @resource one = [klass.new("/one", :relative_path => "a")] @file.expects(:perform_recursion).with("/one").returns one @file.expects(:newchild).with("a").returns @resource two = [klass.new("/two", :relative_path => "a"), klass.new("/two", :relative_path => "b")] @file.expects(:perform_recursion).with("/two").returns two @file.expects(:newchild).with("b").returns @resource three = [klass.new("/three", :relative_path => "a"), klass.new("/three", :relative_path => "c")] @file.expects(:perform_recursion).with("/three").returns three @file.expects(:newchild).with("c").returns @resource @file.expects(:perform_recursion).with("/four").returns [] @file.recurse_remote({}) end end end end describe "when specifying both source, and content properties" do before do @file[:source] = '/one' @file[:content] = 'file contents' end it "should raise an exception" do lambda {@file.validate }.should raise_error(/You cannot specify more than one of/) end end describe "when using source" do before do @file[:source] = '/one' end Puppet::Type::File::ParameterChecksum.value_collection.values.reject {|v| v == :none}.each do |checksum_type| describe "with checksum '#{checksum_type}'" do before do @file[:checksum] = checksum_type end it 'should validate' do lambda { @file.validate }.should_not raise_error end end end describe "with checksum 'none'" do before do @file[:checksum] = :none end it 'should raise an exception when validating' do lambda { @file.validate }.should raise_error(/You cannot specify source when using checksum 'none'/) end end end describe "when using content" do before do @file[:content] = 'file contents' end (Puppet::Type::File::ParameterChecksum.value_collection.values - SOURCE_ONLY_CHECKSUMS).each do |checksum_type| describe "with checksum '#{checksum_type}'" do before do @file[:checksum] = checksum_type end it 'should validate' do lambda { @file.validate }.should_not raise_error end end end SOURCE_ONLY_CHECKSUMS.each do |checksum_type| describe "with checksum '#{checksum_type}'" do it 'should raise an exception when validating' do @file[:checksum] = checksum_type lambda { @file.validate }.should raise_error(/You cannot specify content when using checksum '#{checksum_type}'/) end end end end describe "when returning resources with :eval_generate" do before do @graph = stub 'graph', :add_edge => nil @catalog.stubs(:relationship_graph).returns @graph @file.catalog = @catalog @file[:recurse] = true end it "should recurse if recursion is enabled" do resource = stub('resource', :[] => "resource") @file.expects(:recurse?).returns true @file.expects(:recurse).returns [resource] @file.eval_generate.should == [resource] end it "should not recurse if recursion is disabled" do @file.expects(:recurse?).returns false @file.expects(:recurse).never @file.eval_generate.should == [] end it "should return each resource found through recursion" do foo = stub 'foo', :[] => "/foo" bar = stub 'bar', :[] => "/bar" bar2 = stub 'bar2', :[] => "/bar" @file.expects(:recurse).returns [foo, bar] @file.eval_generate.should == [foo, bar] end end describe "when recursing" do before do @file[:recurse] = true @metadata = Puppet::FileServing::Metadata end describe "and a source is set" do before { @file[:source] = "/my/source" } it "should pass the already-discovered resources to recurse_remote" do @file.stubs(:recurse_local).returns(:foo => "bar") @file.expects(:recurse_remote).with(:foo => "bar").returns [] @file.recurse end end describe "and a target is set" do before { @file[:target] = "/link/target" } it "should use recurse_link" do @file.stubs(:recurse_local).returns(:foo => "bar") @file.expects(:recurse_link).with(:foo => "bar").returns [] @file.recurse end end it "should use recurse_local if recurse is not remote" do @file.expects(:recurse_local).returns({}) @file.recurse end it "should not use recurse_local if recurse remote" do @file[:recurse] = :remote @file.expects(:recurse_local).never @file.recurse end it "should return the generated resources as an array sorted by file path" do one = stub 'one', :[] => "/one" two = stub 'two', :[] => "/one/two" three = stub 'three', :[] => "/three" @file.expects(:recurse_local).returns(:one => one, :two => two, :three => three) @file.recurse.should == [one, two, three] end describe "and purging is enabled" do before do @file[:purge] = true end it "should configure each file to be removed" do local = stub 'local' local.stubs(:[]).with(:source).returns nil # Thus, a local file local.stubs(:[]).with(:path).returns "foo" @file.expects(:recurse_local).returns("local" => local) local.expects(:[]=).with(:ensure, :absent) @file.recurse end it "should not remove files that exist in the remote repository" do @file["source"] = "/my/file" @file.expects(:recurse_local).returns({}) remote = stub 'remote' remote.stubs(:[]).with(:source).returns "/whatever" # Thus, a remote file remote.stubs(:[]).with(:path).returns "foo" @file.expects(:recurse_remote).with { |hash| hash["remote"] = remote } remote.expects(:[]=).with(:ensure, :absent).never @file.recurse end end describe "and making a new child resource" do it "should not copy the parent resource's parent" do Puppet::Type.type(:file).expects(:new).with { |options| ! options.include?(:parent) } @file.newchild("my/path") end {:recurse => true, :target => "/foo/bar", :ensure => :present, :alias => "yay", :source => "/foo/bar"}.each do |param, value| it "should not pass on #{param} to the sub resource" do @file = Puppet::Type::File.new(:name => @path, param => value, :catalog => @catalog) @file.class.expects(:new).with { |params| params[param].nil? } @file.newchild("sub/file") end end it "should copy all of the parent resource's 'should' values that were set at initialization" do file = @file.class.new(:path => "/foo/bar", :owner => "root", :group => "wheel") @catalog.add_resource(file) file.class.expects(:new).with { |options| options[:owner] == "root" and options[:group] == "wheel" } file.newchild("my/path") end it "should not copy default values to the new child" do @file.class.expects(:new).with { |params| params[:backup].nil? } @file.newchild("my/path") end it "should not copy values to the child which were set by the source" do @file[:source] = "/foo/bar" metadata = stub 'metadata', :owner => "root", :group => "root", :mode => 0755, :ftype => "file", :checksum => "{md5}whatever" @file.parameter(:source).stubs(:metadata).returns metadata @file.parameter(:source).copy_source_values @file.class.expects(:new).with { |params| params[:group].nil? } @file.newchild("my/path") end end end describe "when setting the backup" do it "should default to 'puppet'" do Puppet::Type::File.new(:name => "/my/file")[:backup].should == "puppet" end it "should allow setting backup to 'false'" do (!Puppet::Type::File.new(:name => "/my/file", :backup => false)[:backup]).should be_true end it "should set the backup to '.puppet-bak' if it is set to true" do Puppet::Type::File.new(:name => "/my/file", :backup => true)[:backup].should == ".puppet-bak" end it "should support any other backup extension" do Puppet::Type::File.new(:name => "/my/file", :backup => ".bak")[:backup].should == ".bak" end it "should set the filebucket when backup is set to a string matching the name of a filebucket in the catalog" do catalog = Puppet::Resource::Catalog.new bucket_resource = Puppet::Type.type(:filebucket).new :name => "foo", :path => "/my/file/bucket" catalog.add_resource bucket_resource file = Puppet::Type::File.new(:name => "/my/file") catalog.add_resource file file[:backup] = "foo" file.bucket.should == bucket_resource.bucket end it "should find filebuckets added to the catalog after the file resource was created" do catalog = Puppet::Resource::Catalog.new file = Puppet::Type::File.new(:name => "/my/file", :backup => "foo") catalog.add_resource file bucket_resource = Puppet::Type.type(:filebucket).new :name => "foo", :path => "/my/file/bucket" catalog.add_resource bucket_resource file.bucket.should == bucket_resource.bucket end it "should have a nil filebucket if backup is false" do catalog = Puppet::Resource::Catalog.new bucket_resource = Puppet::Type.type(:filebucket).new :name => "foo", :path => "/my/file/bucket" catalog.add_resource bucket_resource file = Puppet::Type::File.new(:name => "/my/file", :backup => false) catalog.add_resource file file.bucket.should be_nil end it "should have a nil filebucket if backup is set to a string starting with '.'" do catalog = Puppet::Resource::Catalog.new bucket_resource = Puppet::Type.type(:filebucket).new :name => "foo", :path => "/my/file/bucket" catalog.add_resource bucket_resource file = Puppet::Type::File.new(:name => "/my/file", :backup => ".foo") catalog.add_resource file file.bucket.should be_nil end it "should fail if there's no catalog and backup is not false" do file = Puppet::Type::File.new(:name => "/my/file", :backup => "foo") lambda { file.bucket }.should raise_error(Puppet::Error) end it "should fail if a non-existent catalog is specified" do file = Puppet::Type::File.new(:name => "/my/file", :backup => "foo") catalog = Puppet::Resource::Catalog.new catalog.add_resource file lambda { file.bucket }.should raise_error(Puppet::Error) end it "should be able to use the default filebucket without a catalog" do file = Puppet::Type::File.new(:name => "/my/file", :backup => "puppet") file.bucket.should be_instance_of(Puppet::FileBucket::Dipper) end it "should look up the filebucket during finish()" do file = Puppet::Type::File.new(:name => "/my/file", :backup => ".foo") file.expects(:bucket) file.finish end end describe "when retrieving the current file state" do it "should copy the source values if the 'source' parameter is set" do file = Puppet::Type::File.new(:name => "/my/file", :source => "/foo/bar") file.parameter(:source).expects(:copy_source_values) file.retrieve end end describe ".title_patterns" do before do @type_class = Puppet::Type.type(:file) end it "should have a regexp that captures the entire string, except for a terminating slash" do patterns = @type_class.title_patterns string = "abc/\n\tdef/" patterns[0][0] =~ string $1.should == "abc/\n\tdef" end end describe "when auditing" do it "should not fail if creating a new file if group is not set" do File.exists?(@path).should == false file = Puppet::Type::File.new(:name => @path, :audit => "all", :content => "content") catalog = Puppet::Resource::Catalog.new catalog.add_resource(file) Puppet::Util::Storage.stubs(:store) # to prevent the catalog from trying to write state.yaml transaction = catalog.apply transaction.report.resource_statuses["File[#{@path}]"].failed.should == false File.exists?(@path).should == true end it "should not log errors if creating a new file with ensure present and no content" do File.exists?(@path).should == false file = Puppet::Type::File.new(:name => @path, :audit => "content", :ensure => "present") catalog = Puppet::Resource::Catalog.new catalog.add_resource(file) Puppet::Util::Storage.stubs(:store) # to prevent the catalog from trying to write state.yaml catalog.apply @logs.reject {|l| l.level == :notice }.should be_empty end end describe "when specifying both source and checksum" do it 'should use the specified checksum when source is first' do @file[:source] = '/foo' @file[:checksum] = :md5lite @file[:checksum].should be :md5lite end it 'should use the specified checksum when source is last' do @file[:checksum] = :md5lite @file[:source] = '/foo' @file[:checksum].should be :md5lite end end end diff --git a/spec/unit/type/mount_spec.rb b/spec/unit/type/mount_spec.rb index 3df8de903..4638e9a2e 100755 --- a/spec/unit/type/mount_spec.rb +++ b/spec/unit/type/mount_spec.rb @@ -1,283 +1,330 @@ #!/usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') describe Puppet::Type.type(:mount) do it "should have a :refreshable feature that requires the :remount method" do Puppet::Type.type(:mount).provider_feature(:refreshable).methods.should == [:remount] end it "should have no default value for :ensure" do mount = Puppet::Type.type(:mount).new(:name => "yay") mount.should(:ensure).should be_nil end + + it "should have :name as the only keyattribut" do + Puppet::Type.type(:mount).key_attributes.should == [:name] + end end describe Puppet::Type.type(:mount), "when validating attributes" do - [:name, :remounts].each do |param| + [:name, :remounts, :provider].each do |param| it "should have a #{param} parameter" do Puppet::Type.type(:mount).attrtype(param).should == :param end end [:ensure, :device, :blockdevice, :fstype, :options, :pass, :dump, :atboot, :target].each do |param| it "should have a #{param} property" do Puppet::Type.type(:mount).attrtype(param).should == :property end end end describe Puppet::Type.type(:mount)::Ensure, "when validating values" do before do @provider = stub 'provider', :class => Puppet::Type.type(:mount).defaultprovider, :clear => nil Puppet::Type.type(:mount).defaultprovider.expects(:new).returns(@provider) end it "should alias :present to :defined as a value to :ensure" do mount = Puppet::Type.type(:mount).new(:name => "yay", :ensure => :present) mount.should(:ensure).should == :defined end + it "should support :present as a value to :ensure" do + Puppet::Type.type(:mount).new(:name => "yay", :ensure => :present) + end + + it "should support :defined as a value to :ensure" do + Puppet::Type.type(:mount).new(:name => "yay", :ensure => :defined) + end + it "should support :unmounted as a value to :ensure" do - mount = Puppet::Type.type(:mount).new(:name => "yay", :ensure => :unmounted) - mount.should(:ensure).should == :unmounted + Puppet::Type.type(:mount).new(:name => "yay", :ensure => :unmounted) end it "should support :absent as a value to :ensure" do Puppet::Type.type(:mount).new(:name => "yay", :ensure => :absent) end it "should support :mounted as a value to :ensure" do Puppet::Type.type(:mount).new(:name => "yay", :ensure => :mounted) end end describe Puppet::Type.type(:mount)::Ensure do before :each do - @provider = stub 'provider', :class => Puppet::Type.type(:mount).defaultprovider, :clear => nil, :satisfies? => true, :name => :mock + provider_properties = {} + @provider = stub 'provider', :class => Puppet::Type.type(:mount).defaultprovider, :clear => nil, :satisfies? => true, :name => :mock, :property_hash => provider_properties Puppet::Type.type(:mount).defaultprovider.stubs(:new).returns(@provider) @mount = Puppet::Type.type(:mount).new(:name => "yay", :check => :ensure) @ensure = @mount.property(:ensure) end def mount_stub(params) Puppet::Type.type(:mount).validproperties.each do |prop| unless params[prop] params[prop] = :absent @mount[prop] = :absent end end params.each do |param, value| @provider.stubs(param).returns(value) end end - describe Puppet::Type.type(:mount)::Ensure, "when retrieving its current state" do - - it "should return the provider's value if it is :absent" do - @provider.expects(:ensure).returns(:absent) - @ensure.retrieve.should == :absent - end - - it "should return :mounted if the provider indicates it is mounted and the value is not :absent" do - @provider.expects(:ensure).returns(:present) - @provider.expects(:mounted?).returns(true) - @ensure.retrieve.should == :mounted - end - - it "should return :unmounted if the provider indicates it is not mounted and the value is not :absent" do - @provider.expects(:ensure).returns(:present) - @provider.expects(:mounted?).returns(false) - @ensure.retrieve.should == :unmounted - end - end - describe Puppet::Type.type(:mount)::Ensure, "when changing the host" do - it "should destroy itself if it should be absent" do - @provider.stubs(:mounted?).returns(false) - @provider.expects(:destroy) - @ensure.should = :absent - @ensure.sync - end - - it "should unmount itself before destroying if it is mounted and should be absent" do - @provider.expects(:mounted?).returns(true) - @provider.expects(:unmount) - @provider.expects(:destroy) - @ensure.should = :absent - @ensure.sync - end - - it "should create itself if it is absent and should be defined" do - @provider.stubs(:ensure).returns(:absent) - @provider.stubs(:mounted?).returns(true) - - @provider.stubs(:mounted?).returns(false) - @provider.expects(:create) - @ensure.should = :defined - @ensure.sync - end - - it "should not unmount itself if it is mounted and should be defined" do - @provider.stubs(:ensure).returns(:mounted) - @provider.stubs(:mounted?).returns(true) - - @provider.stubs(:create) + def test_ensure_change(options) + @provider.stubs(:get).with(:ensure).returns options[:from] + @provider.stubs(:ensure).returns options[:from] + @provider.stubs(:mounted?).returns([:mounted,:ghost].include? options[:from]) + @provider.expects(:create).times(options[:create] || 0) + @provider.expects(:destroy).times(options[:destroy] || 0) @provider.expects(:mount).never - @provider.expects(:unmount).never - @ensure.should = :defined - @ensure.sync - end - - it "should not mount itself if it is unmounted and should be defined" do - @provider.stubs(:ensure).returns(:unmounted) - @provider.stubs(:mounted?).returns(false) - - @ensure.stubs(:syncothers) - @provider.stubs(:create) - @provider.expects(:mount).never - @provider.expects(:unmount).never - @ensure.should = :present - @ensure.sync - end - - it "should unmount itself if it is mounted and should be unmounted" do - @provider.stubs(:ensure).returns(:present) - @provider.stubs(:mounted?).returns(true) - + @provider.expects(:unmount).times(options[:unmount] || 0) @ensure.stubs(:syncothers) - @provider.expects(:unmount) - @ensure.should = :unmounted + @ensure.should = options[:to] @ensure.sync - end - - it "should create and mount itself if it does not exist and should be mounted" do - @provider.stubs(:ensure).returns(:absent) - @provider.stubs(:mounted?).returns(false) - @provider.expects(:create) - @ensure.stubs(:syncothers) - @provider.expects(:mount) - @ensure.should = :mounted - @ensure.sync - end - - it "should mount itself if it is present and should be mounted" do - @provider.stubs(:ensure).returns(:present) - @provider.stubs(:mounted?).returns(false) - @ensure.stubs(:syncothers) - @provider.expects(:mount) - @ensure.should = :mounted - @ensure.sync - end + (!!@provider.property_hash[:needs_mount]).should == (!!options[:mount]) + end + + it "should create itself when changing from :ghost to :present" do + test_ensure_change(:from => :ghost, :to => :present, :create => 1) + end + + it "should create itself when changing from :absent to :present" do + test_ensure_change(:from => :absent, :to => :present, :create => 1) + end - it "should create but not mount itself if it is absent and mounted and should be mounted" do - @provider.stubs(:ensure).returns(:absent) - @provider.stubs(:mounted?).returns(true) - @ensure.stubs(:syncothers) - @provider.expects(:create) - @ensure.should = :mounted - @ensure.sync - end + it "should create itself and unmount when changing from :ghost to :unmounted" do + test_ensure_change(:from => :ghost, :to => :unmounted, :create => 1, :unmount => 1) + end + + it "should unmount resource when changing from :mounted to :unmounted" do + test_ensure_change(:from => :mounted, :to => :unmounted, :unmount => 1) + end + + it "should create itself when changing from :absent to :unmounted" do + test_ensure_change(:from => :absent, :to => :unmounted, :create => 1) + end + + it "should unmount resource when changing from :ghost to :absent" do + test_ensure_change(:from => :ghost, :to => :absent, :unmount => 1) + end + + it "should unmount and destroy itself when changing from :mounted to :absent" do + test_ensure_change(:from => :mounted, :to => :absent, :destroy => 1, :unmount => 1) + end + + it "should destroy itself when changing from :unmounted to :absent" do + test_ensure_change(:from => :unmounted, :to => :absent, :destroy => 1) + end + + it "should create itself when changing from :ghost to :mounted" do + test_ensure_change(:from => :ghost, :to => :mounted, :create => 1) + end + + it "should create itself and mount when changing from :absent to :mounted" do + test_ensure_change(:from => :absent, :to => :mounted, :create => 1, :mount => 1) + end + + it "should mount resource when changing from :unmounted to :mounted" do + test_ensure_change(:from => :unmounted, :to => :mounted, :mount => 1) + end + + + it "should be in sync if it is :absent and should be :absent" do + @ensure.should = :absent + @ensure.safe_insync?(:absent).should == true + end + + it "should be out of sync if it is :absent and should be :defined" do + @ensure.should = :defined + @ensure.safe_insync?(:absent).should == false + end + + it "should be out of sync if it is :absent and should be :mounted" do + @ensure.should = :mounted + @ensure.safe_insync?(:absent).should == false + end + + it "should be out of sync if it is :absent and should be :unmounted" do + @ensure.should = :unmounted + @ensure.safe_insync?(:absent).should == false + end + + it "should be out of sync if it is :mounted and should be :absent" do + @ensure.should = :absent + @ensure.safe_insync?(:mounted).should == false + end + + it "should be in sync if it is :mounted and should be :defined" do + @ensure.should = :defined + @ensure.safe_insync?(:mounted).should == true + end + + it "should be in sync if it is :mounted and should be :mounted" do + @ensure.should = :mounted + @ensure.safe_insync?(:mounted).should == true + end + + it "should be out in sync if it is :mounted and should be :unmounted" do + @ensure.should = :unmounted + @ensure.safe_insync?(:mounted).should == false + end + + + it "should be out of sync if it is :unmounted and should be :absent" do + @ensure.should = :absent + @ensure.safe_insync?(:unmounted).should == false + end + + it "should be in sync if it is :unmounted and should be :defined" do + @ensure.should = :defined + @ensure.safe_insync?(:unmounted).should == true + end + + it "should be out of sync if it is :unmounted and should be :mounted" do + @ensure.should = :mounted + @ensure.safe_insync?(:unmounted).should == false + end + + it "should be in sync if it is :unmounted and should be :unmounted" do + @ensure.should = :unmounted + @ensure.safe_insync?(:unmounted).should == true + end - it "should be insync if it is mounted and should be defined" do - @ensure.should = :defined - @ensure.safe_insync?(:mounted).should == true - end - it "should be insync if it is unmounted and should be defined" do - @ensure.should = :defined - @ensure.safe_insync?(:unmounted).should == true - end + it "should be out of sync if it is :ghost and should be :absent" do + @ensure.should = :absent + @ensure.safe_insync?(:ghost).should == false + end - it "should be insync if it is mounted and should be present" do - @ensure.should = :present - @ensure.safe_insync?(:mounted).should == true - end + it "should be out of sync if it is :ghost and should be :defined" do + @ensure.should = :defined + @ensure.safe_insync?(:ghost).should == false + end + + it "should be out of sync if it is :ghost and should be :mounted" do + @ensure.should = :mounted + @ensure.safe_insync?(:ghost).should == false + end + + it "should be out of sync if it is :ghost and should be :unmounted" do + @ensure.should = :unmounted + @ensure.safe_insync?(:ghost).should == false + end - it "should be insync if it is unmounted and should be present" do - @ensure.should = :present - @ensure.safe_insync?(:unmounted).should == true - end - end + end describe Puppet::Type.type(:mount), "when responding to refresh" do + pending "2.6.x specifies slightly different behavior and the desired behavior needs to be clarified and revisited. See ticket #4904" do - it "should remount if it is supposed to be mounted" do - @mount[:ensure] = "mounted" - @provider.expects(:remount) + it "should remount if it is supposed to be mounted" do + @mount[:ensure] = "mounted" + @provider.expects(:remount) - @mount.refresh - end + @mount.refresh + end - it "should not remount if it is supposed to be present" do - @mount[:ensure] = "present" - @provider.expects(:remount).never + it "should not remount if it is supposed to be present" do + @mount[:ensure] = "present" + @provider.expects(:remount).never - @mount.refresh - end + @mount.refresh + end - it "should not remount if it is supposed to be absent" do - @mount[:ensure] = "absent" - @provider.expects(:remount).never + it "should not remount if it is supposed to be absent" do + @mount[:ensure] = "absent" + @provider.expects(:remount).never - @mount.refresh - end + @mount.refresh + end - it "should not remount if it is supposed to be defined" do - @mount[:ensure] = "defined" - @provider.expects(:remount).never + it "should not remount if it is supposed to be defined" do + @mount[:ensure] = "defined" + @provider.expects(:remount).never - @mount.refresh - end + @mount.refresh + end - it "should not remount if it is supposed to be unmounted" do - @mount[:ensure] = "unmounted" - @provider.expects(:remount).never + it "should not remount if it is supposed to be unmounted" do + @mount[:ensure] = "unmounted" + @provider.expects(:remount).never - @mount.refresh - end + @mount.refresh + end - it "should not remount swap filesystems" do - @mount[:ensure] = "mounted" - @mount[:fstype] = "swap" - @provider.expects(:remount).never + it "should not remount swap filesystems" do + @mount[:ensure] = "mounted" + @mount[:fstype] = "swap" + @provider.expects(:remount).never - @mount.refresh + @mount.refresh + end end end end describe Puppet::Type.type(:mount), "when modifying an existing mount entry" do before do @provider = stub 'provider', :class => Puppet::Type.type(:mount).defaultprovider, :clear => nil, :satisfies? => true, :name => :mock, :remount => nil Puppet::Type.type(:mount).defaultprovider.stubs(:new).returns(@provider) @mount = Puppet::Type.type(:mount).new(:name => "yay", :ensure => :mounted) {:device => "/foo/bar", :blockdevice => "/other/bar", :target => "/what/ever", :fstype => 'eh', :options => "", :pass => 0, :dump => 0, :atboot => 0, :ensure => :mounted}.each do |param, value| @mount.provider.stubs(param).returns value @mount[param] = value end @mount.provider.stubs(:mounted?).returns true # stub this to not try to create state.yaml Puppet::Util::Storage.stubs(:store) @catalog = Puppet::Resource::Catalog.new @catalog.add_resource @mount end it "should use the provider to change the dump value" do @mount.provider.expects(:dump).returns 0 @mount.provider.expects(:dump=).with(1) @mount[:dump] = 1 @catalog.apply end + + it "should umount before flushing changes to disk" do + syncorder = sequence('syncorder') + @mount.provider.expects(:options).returns 'soft' + @mount.provider.expects(:ensure).returns :mounted + + @mount.provider.expects(:unmount).in_sequence(syncorder) + @mount.provider.expects(:options=).in_sequence(syncorder).with 'hard' + @mount.expects(:flush).in_sequence(syncorder) # Call inside syncothers + @mount.expects(:flush).in_sequence(syncorder) # I guess transaction or anything calls flush again + + @mount[:ensure] = :unmounted + @mount[:options] = 'hard' + + @catalog.apply + end + end diff --git a/spec/unit/type/user_spec.rb b/spec/unit/type/user_spec.rb index 117c90f1c..6421e6049 100755 --- a/spec/unit/type/user_spec.rb +++ b/spec/unit/type/user_spec.rb @@ -1,332 +1,336 @@ #!/usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') user = Puppet::Type.type(:user) describe user do before do ENV["PATH"] += File::PATH_SEPARATOR + "/usr/sbin" unless ENV["PATH"].split(File::PATH_SEPARATOR).include?("/usr/sbin") @provider = stub 'provider' @resource = stub 'resource', :resource => nil, :provider => @provider, :line => nil, :file => nil end it "should have a default provider inheriting from Puppet::Provider" do user.defaultprovider.ancestors.should be_include(Puppet::Provider) end it "should be able to create a instance" do user.new(:name => "foo").should_not be_nil end it "should have an allows_duplicates feature" do user.provider_feature(:allows_duplicates).should_not be_nil end it "should have an manages_homedir feature" do user.provider_feature(:manages_homedir).should_not be_nil end it "should have an manages_passwords feature" do user.provider_feature(:manages_passwords).should_not be_nil end it "should have a manages_solaris_rbac feature" do user.provider_feature(:manages_solaris_rbac).should_not be_nil end it "should have a manages_expiry feature" do user.provider_feature(:manages_expiry).should_not be_nil end it "should have a manages_password_age feature" do user.provider_feature(:manages_password_age).should_not be_nil end + it "should have a system_users feature" do + user.provider_feature(:system_users).should_not be_nil + end + describe "instances" do it "should have a valid provider" do user.new(:name => "foo").provider.class.ancestors.should be_include(Puppet::Provider) end it "should delegate existence questions to its provider" do instance = user.new(:name => "foo") instance.provider.expects(:exists?).returns "eh" instance.exists?.should == "eh" end end properties = [:ensure, :uid, :gid, :home, :comment, :shell, :password, :password_min_age, :password_max_age, :groups, :roles, :auths, :profiles, :project, :keys, :expiry] properties.each do |property| it "should have a #{property} property" do user.attrclass(property).ancestors.should be_include(Puppet::Property) end it "should have documentation for its #{property} property" do user.attrclass(property).doc.should be_instance_of(String) end end list_properties = [:groups, :roles, :auths] list_properties.each do |property| it "should have a list '#{property}'" do user.attrclass(property).ancestors.should be_include(Puppet::Property::List) end end it "should have an ordered list 'profiles'" do user.attrclass(:profiles).ancestors.should be_include(Puppet::Property::OrderedList) end it "should have key values 'keys'" do user.attrclass(:keys).ancestors.should be_include(Puppet::Property::KeyValue) end describe "when retrieving all current values" do before do @user = user.new(:name => "foo", :uid => 10) end it "should return a hash containing values for all set properties" do @user[:gid] = 10 @user.property(:ensure).expects(:retrieve).returns :present @user.property(:uid).expects(:retrieve).returns 15 @user.property(:gid).expects(:retrieve).returns 15 values = @user.retrieve [@user.property(:uid), @user.property(:gid)].each { |property| values.should be_include(property) } end it "should set all values to :absent if the user is absent" do @user.property(:ensure).expects(:retrieve).returns :absent @user.property(:uid).expects(:retrieve).never @user.retrieve[@user.property(:uid)].should == :absent end it "should include the result of retrieving each property's current value if the user is present" do @user.property(:ensure).expects(:retrieve).returns :present @user.property(:uid).expects(:retrieve).returns 15 @user.retrieve[@user.property(:uid)].should == 15 end end describe "when managing the ensure property" do before do @ensure = user.attrclass(:ensure).new(:resource => @resource) end it "should support a :present value" do lambda { @ensure.should = :present }.should_not raise_error end it "should support an :absent value" do lambda { @ensure.should = :absent }.should_not raise_error end it "should call :create on the provider when asked to sync to the :present state" do @provider.expects(:create) @ensure.should = :present @ensure.sync end it "should call :delete on the provider when asked to sync to the :absent state" do @provider.expects(:delete) @ensure.should = :absent @ensure.sync end describe "and determining the current state" do it "should return :present when the provider indicates the user exists" do @provider.expects(:exists?).returns true @ensure.retrieve.should == :present end it "should return :absent when the provider indicates the user does not exist" do @provider.expects(:exists?).returns false @ensure.retrieve.should == :absent end end end describe "when managing the uid property" do it "should convert number-looking strings into actual numbers" do uid = user.attrclass(:uid).new(:resource => @resource) uid.should = "50" uid.should.must == 50 end it "should support UIDs as numbers" do uid = user.attrclass(:uid).new(:resource => @resource) uid.should = 50 uid.should.must == 50 end it "should :absent as a value" do uid = user.attrclass(:uid).new(:resource => @resource) uid.should = :absent uid.should.must == :absent end end describe "when managing the gid" do it "should :absent as a value" do gid = user.attrclass(:gid).new(:resource => @resource) gid.should = :absent gid.should.must == :absent end it "should convert number-looking strings into actual numbers" do gid = user.attrclass(:gid).new(:resource => @resource) gid.should = "50" gid.should.must == 50 end it "should support GIDs specified as integers" do gid = user.attrclass(:gid).new(:resource => @resource) gid.should = 50 gid.should.must == 50 end it "should support groups specified by name" do gid = user.attrclass(:gid).new(:resource => @resource) gid.should = "foo" gid.should.must == "foo" end describe "when testing whether in sync" do before do @gid = user.attrclass(:gid).new(:resource => @resource, :should => %w{foo bar}) end it "should return true if no 'should' values are set" do @gid = user.attrclass(:gid).new(:resource => @resource) @gid.must be_safe_insync(500) end it "should return true if any of the specified groups are equal to the current integer" do Puppet::Util.expects(:gid).with("foo").returns 300 Puppet::Util.expects(:gid).with("bar").returns 500 @gid.must be_safe_insync(500) end it "should return false if none of the specified groups are equal to the current integer" do Puppet::Util.expects(:gid).with("foo").returns 300 Puppet::Util.expects(:gid).with("bar").returns 500 @gid.should_not be_safe_insync(700) end end describe "when syncing" do before do @gid = user.attrclass(:gid).new(:resource => @resource, :should => %w{foo bar}) end it "should use the first found, specified group as the desired value and send it to the provider" do Puppet::Util.expects(:gid).with("foo").returns nil Puppet::Util.expects(:gid).with("bar").returns 500 @provider.expects(:gid=).with 500 @gid.sync end end end describe "when managing expiry" do before do @expiry = user.attrclass(:expiry).new(:resource => @resource) end it "should fail if given an invalid date" do lambda { @expiry.should = "200-20-20" }.should raise_error(Puppet::Error) end end describe "when managing minimum password age" do before do @age = user.attrclass(:password_min_age).new(:resource => @resource) end it "should accept a negative minimum age" do expect { @age.should = -1 }.should_not raise_error end it "should fail with an empty minimum age" do expect { @age.should = '' }.should raise_error(Puppet::Error) end end describe "when managing maximum password age" do before do @age = user.attrclass(:password_max_age).new(:resource => @resource) end it "should accept a negative maximum age" do expect { @age.should = -1 }.should_not raise_error end it "should fail with an empty maximum age" do expect { @age.should = '' }.should raise_error(Puppet::Error) end end describe "when managing passwords" do before do @password = user.attrclass(:password).new(:resource => @resource, :should => "mypass") end it "should not include the password in the change log when adding the password" do @password.change_to_s(:absent, "mypass").should_not be_include("mypass") end it "should not include the password in the change log when changing the password" do @password.change_to_s("other", "mypass").should_not be_include("mypass") end it "should fail if a ':' is included in the password" do lambda { @password.should = "some:thing" }.should raise_error(Puppet::Error) end it "should allow the value to be set to :absent" do lambda { @password.should = :absent }.should_not raise_error end end describe "when manages_solaris_rbac is enabled" do before do @provider.stubs(:satisfies?).returns(false) @provider.expects(:satisfies?).with([:manages_solaris_rbac]).returns(true) end it "should support a :role value for ensure" do @ensure = user.attrclass(:ensure).new(:resource => @resource) lambda { @ensure.should = :role }.should_not raise_error end end describe "when user has roles" do before do # To test this feature, we have to support it. user.new(:name => "foo").provider.class.stubs(:feature?).returns(true) end it "should autorequire roles" do testuser = Puppet::Type.type(:user).new(:name => "testuser") testuser[:roles] = "testrole" testrole = Puppet::Type.type(:user).new(:name => "testrole") config = Puppet::Resource::Catalog.new :testing do |conf| [testuser, testrole].each { |resource| conf.add_resource resource } end Puppet::Type::User::ProviderDirectoryservice.stubs(:get_macosx_version_major).returns "10.5" rel = testuser.autorequire[0] rel.source.ref.should == testrole.ref rel.target.ref.should == testuser.ref end end end diff --git a/spec/unit/type/zone_spec.rb b/spec/unit/type/zone_spec.rb index 726ccc28d..a3e748bde 100755 --- a/spec/unit/type/zone_spec.rb +++ b/spec/unit/type/zone_spec.rb @@ -1,60 +1,80 @@ #!/usr/bin/env ruby Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") } zone = Puppet::Type.type(:zone) describe zone do before do zone = Puppet::Type.type(:zone) provider = stub 'provider' provider.stubs(:name).returns(:solaris) zone.stubs(:defaultprovider).returns(provider) resource = stub 'resource', :resource => nil, :provider => provider, :line => nil, :file => nil end parameters = [:create_args, :install_args, :sysidcfg, :path, :realhostname] parameters.each do |parameter| it "should have a #{parameter} parameter" do zone.attrclass(parameter).ancestors.should be_include(Puppet::Parameter) end end properties = [:ip, :iptype, :autoboot, :pool, :shares, :inherit] properties.each do |property| it "should have a #{property} property" do zone.attrclass(property).ancestors.should be_include(Puppet::Property) end end it "should be invalid when :path is missing" do lambda { zone.new(:name => "dummy") }.should raise_error end it "should be invalid when :ip is missing a \":\" and iptype is :shared" do lambda { zone.new(:name => "dummy", :ip => "if") }.should raise_error end it "should be invalid when :ip has a \":\" and iptype is :exclusive" do lambda { zone.new(:name => "dummy", :ip => "if:1.2.3.4", :iptype => :exclusive) }.should raise_error end it "should be invalid when :ip has two \":\" and iptype is :exclusive" do lambda { zone.new(:name => "dummy", :ip => "if:1.2.3.4:2.3.4.5", :iptype => :exclusive) }.should raise_error end it "should be valid when :iptype is :shared and using interface and ip" do zone.new(:name => "dummy", :path => "/dummy", :ip => "if:1.2.3.4") end it "should be valid when :iptype is :shared and using interface, ip and default route" do zone.new(:name => "dummy", :path => "/dummy", :ip => "if:1.2.3.4:2.3.4.5") end it "should be valid when :iptype is :exclusive and using interface" do zone.new(:name => "dummy", :path => "/dummy", :ip => "if", :iptype => :exclusive) end + it "should auto-require :dataset entries" do + fs = 'random-pool/some-zfs' + + # ick + provider = stub 'zfs::provider' + provider.stubs(:name).returns(:solaris) + Puppet::Type.type(:zfs).stubs(:defaultprovider).returns(provider) + + catalog = Puppet::Resource::Catalog.new + zfs_instance = Puppet::Type.type(:zfs).new(:name => fs) + catalog.add_resource zfs_instance + + zone_instance = zone.new(:name => "dummy", + :path => "/foo", + :ip => 'en1:1.0.0.0', + :dataset => fs) + catalog.add_resource zone_instance + + catalog.relationship_graph.dependencies(zone_instance).should == [zfs_instance] + end end diff --git a/spec/unit/type_spec.rb b/spec/unit/type_spec.rb index d1143d92e..f9372fced 100755 --- a/spec/unit/type_spec.rb +++ b/spec/unit/type_spec.rb @@ -1,573 +1,584 @@ #!/usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe Puppet::Type do it "should include the Cacher module" do Puppet::Type.ancestors.should be_include(Puppet::Util::Cacher) end it "should consider a parameter to be valid if it is a valid parameter" do Puppet::Type.type(:mount).should be_valid_parameter(:path) end it "should consider a parameter to be valid if it is a valid property" do Puppet::Type.type(:mount).should be_valid_parameter(:fstype) end it "should consider a parameter to be valid if it is a valid metaparam" do Puppet::Type.type(:mount).should be_valid_parameter(:noop) end it "should use its catalog as its expirer" do catalog = Puppet::Resource::Catalog.new resource = Puppet::Type.type(:mount).new(:name => "foo", :fstype => "bar", :pass => 1, :ensure => :present) resource.catalog = catalog resource.expirer.should equal(catalog) end it "should do nothing when asked to expire when it has no catalog" do resource = Puppet::Type.type(:mount).new(:name => "foo", :fstype => "bar", :pass => 1, :ensure => :present) lambda { resource.expire }.should_not raise_error end it "should be able to retrieve a property by name" do resource = Puppet::Type.type(:mount).new(:name => "foo", :fstype => "bar", :pass => 1, :ensure => :present) resource.property(:fstype).must be_instance_of(Puppet::Type.type(:mount).attrclass(:fstype)) end it "should be able to retrieve a parameter by name" do resource = Puppet::Type.type(:mount).new(:name => "foo", :fstype => "bar", :pass => 1, :ensure => :present) resource.parameter(:name).must be_instance_of(Puppet::Type.type(:mount).attrclass(:name)) end it "should be able to retrieve a property by name using the :parameter method" do resource = Puppet::Type.type(:mount).new(:name => "foo", :fstype => "bar", :pass => 1, :ensure => :present) resource.parameter(:fstype).must be_instance_of(Puppet::Type.type(:mount).attrclass(:fstype)) end it "should be able to retrieve all set properties" do resource = Puppet::Type.type(:mount).new(:name => "foo", :fstype => "bar", :pass => 1, :ensure => :present) props = resource.properties props.should_not be_include(nil) [:fstype, :ensure, :pass].each do |name| props.should be_include(resource.parameter(name)) end end it "should have a method for setting default values for resources" do Puppet::Type.type(:mount).new(:name => "foo").should respond_to(:set_default) end it "should do nothing for attributes that have no defaults and no specified value" do Puppet::Type.type(:mount).new(:name => "foo").parameter(:noop).should be_nil end it "should have a method for adding tags" do Puppet::Type.type(:mount).new(:name => "foo").should respond_to(:tags) end it "should use the tagging module" do Puppet::Type.type(:mount).ancestors.should be_include(Puppet::Util::Tagging) end it "should delegate to the tagging module when tags are added" do resource = Puppet::Type.type(:mount).new(:name => "foo") resource.stubs(:tag).with(:mount) resource.expects(:tag).with(:tag1, :tag2) resource.tags = [:tag1,:tag2] end it "should add the current type as tag" do resource = Puppet::Type.type(:mount).new(:name => "foo") resource.stubs(:tag) resource.expects(:tag).with(:mount) resource.tags = [:tag1,:tag2] end it "should have a method to know if the resource is exported" do Puppet::Type.type(:mount).new(:name => "foo").should respond_to(:exported?) end it "should have a method to know if the resource is virtual" do Puppet::Type.type(:mount).new(:name => "foo").should respond_to(:virtual?) end it "should consider its version to be its catalog version" do resource = Puppet::Type.type(:mount).new(:name => "foo") catalog = Puppet::Resource::Catalog.new catalog.version = 50 catalog.add_resource resource resource.version.should == 50 end it "should consider its version to be zero if it has no catalog" do Puppet::Type.type(:mount).new(:name => "foo").version.should == 0 end it "should provide source_descriptors" do resource = Puppet::Type.type(:mount).new(:name => "foo") catalog = Puppet::Resource::Catalog.new catalog.version = 50 catalog.add_resource resource resource.source_descriptors.should == {:tags=>["mount", "foo"], :path=>"/Mount[foo]"} end it "should consider its type to be the name of its class" do Puppet::Type.type(:mount).new(:name => "foo").type.should == :mount end it "should use any provided noop value" do Puppet::Type.type(:mount).new(:name => "foo", :noop => true).must be_noop end it "should use the global noop value if none is provided" do Puppet[:noop] = true Puppet::Type.type(:mount).new(:name => "foo").must be_noop end it "should not be noop if in a non-host_config catalog" do resource = Puppet::Type.type(:mount).new(:name => "foo") catalog = Puppet::Resource::Catalog.new catalog.add_resource resource resource.should_not be_noop end describe "when creating an event" do before do @resource = Puppet::Type.type(:mount).new :name => "foo" end it "should have the resource's reference as the resource" do @resource.event.resource.should == "Mount[foo]" end it "should have the resource's log level as the default log level" do @resource[:loglevel] = :warning @resource.event.default_log_level.should == :warning end {:file => "/my/file", :line => 50, :tags => %{foo bar}}.each do |attr, value| it "should set the #{attr}" do @resource.stubs(attr).returns value @resource.event.send(attr).should == value end end it "should allow specification of event attributes" do @resource.event(:status => "noop").status.should == "noop" end end describe "when choosing a default provider" do it "should choose the provider with the highest specificity" do # Make a fake type type = Puppet::Type.newtype(:defaultprovidertest) do newparam(:name) do end end basic = type.provide(:basic) {} greater = type.provide(:greater) {} basic.stubs(:specificity).returns 1 greater.stubs(:specificity).returns 2 type.defaultprovider.should equal(greater) end end describe "when initializing" do describe "and passed a TransObject" do it "should fail" do trans = Puppet::TransObject.new("/foo", :mount) lambda { Puppet::Type.type(:mount).new(trans) }.should raise_error(Puppet::DevError) end end describe "and passed a Puppet::Resource instance" do it "should set its title to the title of the resource if the resource type is equal to the current type" do resource = Puppet::Resource.new(:mount, "/foo", :parameters => {:name => "/other"}) Puppet::Type.type(:mount).new(resource).title.should == "/foo" end it "should set its title to the resource reference if the resource type is not equal to the current type" do resource = Puppet::Resource.new(:user, "foo") Puppet::Type.type(:mount).new(resource).title.should == "User[foo]" end [:line, :file, :catalog, :exported, :virtual].each do |param| it "should copy '#{param}' from the resource if present" do resource = Puppet::Resource.new(:mount, "/foo") resource.send(param.to_s + "=", "foo") resource.send(param.to_s + "=", "foo") Puppet::Type.type(:mount).new(resource).send(param).should == "foo" end end it "should copy any tags from the resource" do resource = Puppet::Resource.new(:mount, "/foo") resource.tag "one", "two" tags = Puppet::Type.type(:mount).new(resource).tags tags.should be_include("one") tags.should be_include("two") end it "should copy the resource's parameters as its own" do resource = Puppet::Resource.new(:mount, "/foo", :parameters => {:atboot => true, :fstype => "boo"}) params = Puppet::Type.type(:mount).new(resource).to_hash params[:fstype].should == "boo" params[:atboot].should == true end end describe "and passed a Hash" do it "should extract the title from the hash" do Puppet::Type.type(:mount).new(:title => "/yay").title.should == "/yay" end it "should work when hash keys are provided as strings" do Puppet::Type.type(:mount).new("title" => "/yay").title.should == "/yay" end it "should work when hash keys are provided as symbols" do Puppet::Type.type(:mount).new(:title => "/yay").title.should == "/yay" end it "should use the name from the hash as the title if no explicit title is provided" do Puppet::Type.type(:mount).new(:name => "/yay").title.should == "/yay" end it "should use the Resource Type's namevar to determine how to find the name in the hash" do Puppet::Type.type(:file).new(:path => "/yay").title.should == "/yay" end [:catalog].each do |param| it "should extract '#{param}' from the hash if present" do Puppet::Type.type(:mount).new(:name => "/yay", param => "foo").send(param).should == "foo" end end it "should use any remaining hash keys as its parameters" do resource = Puppet::Type.type(:mount).new(:title => "/foo", :catalog => "foo", :atboot => true, :fstype => "boo") resource[:fstype].must == "boo" resource[:atboot].must == true end end it "should fail if any invalid attributes have been provided" do lambda { Puppet::Type.type(:mount).new(:title => "/foo", :nosuchattr => "whatever") }.should raise_error(Puppet::Error) end it "should set its name to the resource's title if the resource does not have a :name or namevar parameter set" do resource = Puppet::Resource.new(:mount, "/foo") Puppet::Type.type(:mount).new(resource).name.should == "/foo" end it "should fail if no title, name, or namevar are provided" do lambda { Puppet::Type.type(:file).new(:atboot => true) }.should raise_error(Puppet::Error) end it "should set the attributes in the order returned by the class's :allattrs method" do Puppet::Type.type(:mount).stubs(:allattrs).returns([:name, :atboot, :noop]) resource = Puppet::Resource.new(:mount, "/foo", :parameters => {:name => "myname", :atboot => "myboot", :noop => "whatever"}) set = [] Puppet::Type.type(:mount).any_instance.stubs(:newattr).with do |param, hash| set << param true end.returns(stub_everything("a property")) Puppet::Type.type(:mount).new(resource) set[-1].should == :noop set[-2].should == :atboot end it "should always set the name and then default provider before anything else" do Puppet::Type.type(:mount).stubs(:allattrs).returns([:provider, :name, :atboot]) resource = Puppet::Resource.new(:mount, "/foo", :parameters => {:name => "myname", :atboot => "myboot"}) set = [] Puppet::Type.type(:mount).any_instance.stubs(:newattr).with do |param, hash| set << param true end.returns(stub_everything("a property")) Puppet::Type.type(:mount).new(resource) set[0].should == :name set[1].should == :provider end # This one is really hard to test :/ it "should each default immediately if no value is provided" do defaults = [] Puppet::Type.type(:package).any_instance.stubs(:set_default).with { |value| defaults << value; true } Puppet::Type.type(:package).new :name => "whatever" defaults[0].should == :provider end it "should retain a copy of the originally provided parameters" do Puppet::Type.type(:mount).new(:name => "foo", :atboot => true, :noop => false).original_parameters.should == {:atboot => true, :noop => false} end it "should delete the name via the namevar from the originally provided parameters" do Puppet::Type.type(:file).new(:name => "/foo").original_parameters[:path].should be_nil end end it "should have a class method for converting a hash into a Puppet::Resource instance" do Puppet::Type.type(:mount).must respond_to(:hash2resource) end describe "when converting a hash to a Puppet::Resource instance" do before do @type = Puppet::Type.type(:mount) end it "should treat a :title key as the title of the resource" do @type.hash2resource(:name => "/foo", :title => "foo").title.should == "foo" end it "should use the name from the hash as the title if no explicit title is provided" do @type.hash2resource(:name => "foo").title.should == "foo" end it "should use the Resource Type's namevar to determine how to find the name in the hash" do @type.stubs(:key_attributes).returns([ :myname ]) @type.hash2resource(:myname => "foo").title.should == "foo" end [:catalog].each do |attr| it "should use any provided #{attr}" do @type.hash2resource(:name => "foo", attr => "eh").send(attr).should == "eh" end end it "should set all provided parameters on the resource" do @type.hash2resource(:name => "foo", :fstype => "boo", :boot => "fee").to_hash.should == {:name => "foo", :fstype => "boo", :boot => "fee"} end it "should not set the title as a parameter on the resource" do @type.hash2resource(:name => "foo", :title => "eh")[:title].should be_nil end it "should not set the catalog as a parameter on the resource" do @type.hash2resource(:name => "foo", :catalog => "eh")[:catalog].should be_nil end it "should treat hash keys equivalently whether provided as strings or symbols" do resource = @type.hash2resource("name" => "foo", "title" => "eh", "fstype" => "boo") resource.title.should == "eh" resource[:name].should == "foo" resource[:fstype].should == "boo" end end describe "when retrieving current property values" do before do @resource = Puppet::Type.type(:mount).new(:name => "foo", :fstype => "bar", :pass => 1, :ensure => :present) @resource.property(:ensure).stubs(:retrieve).returns :absent end it "should fail if its provider is unsuitable" do @resource = Puppet::Type.type(:mount).new(:name => "foo", :fstype => "bar", :pass => 1, :ensure => :present) @resource.provider.class.expects(:suitable?).returns false lambda { @resource.retrieve_resource }.should raise_error(Puppet::Error) end it "should return a Puppet::Resource instance with its type and title set appropriately" do result = @resource.retrieve_resource result.should be_instance_of(Puppet::Resource) result.type.should == "Mount" result.title.should == "foo" end it "should set the name of the returned resource if its own name and title differ" do @resource[:name] = "my name" @resource.title = "other name" @resource.retrieve_resource[:name].should == "my name" end it "should provide a value for all set properties" do values = @resource.retrieve_resource [:ensure, :fstype, :pass].each { |property| values[property].should_not be_nil } end it "should provide a value for 'ensure' even if no desired value is provided" do @resource = Puppet::Type.type(:file).new(:path => "/my/file/that/can't/exist") end it "should not call retrieve on non-ensure properties if the resource is absent and should consider the property absent" do @resource.property(:ensure).expects(:retrieve).returns :absent @resource.property(:fstype).expects(:retrieve).never @resource.retrieve_resource[:fstype].should == :absent end it "should include the result of retrieving each property's current value if the resource is present" do @resource.property(:ensure).expects(:retrieve).returns :present @resource.property(:fstype).expects(:retrieve).returns 15 @resource.retrieve_resource[:fstype] == 15 end end describe ".title_patterns" do describe "when there's one namevar" do before do @type_class = Puppet::Type.type(:notify) @type_class.stubs(:key_attributes).returns([:one]) end it "should have a default pattern for when there's one namevar" do patterns = @type_class.title_patterns patterns.length.should == 1 patterns[0].length.should == 2 end - + it "should have a regexp that captures the entire string" do patterns = @type_class.title_patterns string = "abc\n\tdef" patterns[0][0] =~ string $1.should == "abc\n\tdef" end end end describe "when in a catalog" do before do @catalog = Puppet::Resource::Catalog.new @container = Puppet::Type.type(:component).new(:name => "container") @one = Puppet::Type.type(:file).new(:path => "/file/one") @two = Puppet::Type.type(:file).new(:path => "/file/two") @catalog.add_resource @container @catalog.add_resource @one @catalog.add_resource @two @catalog.add_edge @container, @one @catalog.add_edge @container, @two end it "should have no parent if there is no in edge" do @container.parent.should be_nil end it "should set its parent to its in edge" do @one.parent.ref.should == @container.ref end after do @catalog.clear(true) end end it "should have a 'stage' metaparam" do Puppet::Type.metaparamclass(:stage).should be_instance_of(Class) end end describe Puppet::Type::RelationshipMetaparam do it "should be a subclass of Puppet::Parameter" do Puppet::Type::RelationshipMetaparam.superclass.should equal(Puppet::Parameter) end it "should be able to produce a list of subclasses" do Puppet::Type::RelationshipMetaparam.should respond_to(:subclasses) end describe "when munging relationships" do before do @resource = Puppet::Type.type(:mount).new :name => "/foo" @metaparam = Puppet::Type.metaparamclass(:require).new :resource => @resource end it "should accept Puppet::Resource instances" do ref = Puppet::Resource.new(:file, "/foo") @metaparam.munge(ref)[0].should equal(ref) end it "should turn any string into a Puppet::Resource" do @metaparam.munge("File[/ref]")[0].should be_instance_of(Puppet::Resource) end end it "should be able to validate relationships" do Puppet::Type.metaparamclass(:require).new(:resource => mock("resource")).should respond_to(:validate_relationship) end it "should fail if any specified resource is not found in the catalog" do catalog = mock 'catalog' resource = stub 'resource', :catalog => catalog, :ref => "resource" param = Puppet::Type.metaparamclass(:require).new(:resource => resource, :value => %w{Foo[bar] Class[test]}) catalog.expects(:resource).with("Foo[bar]").returns "something" catalog.expects(:resource).with("Class[Test]").returns nil param.expects(:fail).with { |string| string.include?("Class[Test]") } param.validate_relationship end end describe Puppet::Type.metaparamclass(:check) do it "should warn and create an instance of ':audit'" do file = Puppet::Type.type(:file).new :path => "/foo" file.expects(:warning) file[:check] = :mode file[:audit].should == [:mode] end end describe Puppet::Type.metaparamclass(:audit) do before do @resource = Puppet::Type.type(:file).new :path => "/foo" end it "should default to being nil" do @resource[:audit].should be_nil end it "should specify all possible properties when asked to audit all properties" do @resource[:audit] = :all list = @resource.class.properties.collect { |p| p.name } @resource[:audit].should == list end it "should accept the string 'all' to specify auditing all possible properties" do @resource[:audit] = 'all' list = @resource.class.properties.collect { |p| p.name } @resource[:audit].should == list end it "should fail if asked to audit an invalid property" do lambda { @resource[:audit] = :foobar }.should raise_error(Puppet::Error) end it "should create an attribute instance for each auditable property" do @resource[:audit] = :mode @resource.parameter(:mode).should_not be_nil end it "should accept properties specified as a string" do @resource[:audit] = "mode" @resource.parameter(:mode).should_not be_nil end it "should not create attribute instances for parameters, only properties" do @resource[:audit] = :noop @resource.parameter(:noop).should be_nil end + + describe "when generating the uniqueness key" do + it "should include all of the key_attributes in alphabetical order by attribute name" do + Puppet::Type.type(:file).stubs(:key_attributes).returns [:path, :mode, :owner] + Puppet::Type.type(:file).stubs(:title_patterns).returns( + [ [ /(.*)/, [ [:path, lambda{|x| x} ] ] ] ] + ) + res = Puppet::Type.type(:file).new( :title => '/my/file', :path => '/my/file', :owner => 'root', :content => 'hello' ) + res.uniqueness_key.should == [ nil, 'root', '/my/file'] + end + end end diff --git a/spec/unit/util/command_line_spec.rb b/spec/unit/util/command_line_spec.rb old mode 100644 new mode 100755 index 7ba965249..98ddb92f6 --- a/spec/unit/util/command_line_spec.rb +++ b/spec/unit/util/command_line_spec.rb @@ -1,108 +1,137 @@ #!/usr/bin/env ruby Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") } require 'puppet/util/command_line' describe Puppet::Util::CommandLine do + include PuppetSpec::Files before do @tty = stub("tty", :tty? => true ) @pipe = stub("pipe", :tty? => false) end it "should pull off the first argument if it looks like a subcommand" do command_line = Puppet::Util::CommandLine.new("puppet", %w{ client --help whatever.pp }, @tty ) command_line.subcommand_name.should == "client" command_line.args.should == %w{ --help whatever.pp } end it "should use 'apply' if the first argument looks like a .pp file" do command_line = Puppet::Util::CommandLine.new("puppet", %w{ whatever.pp }, @tty ) command_line.subcommand_name.should == "apply" command_line.args.should == %w{ whatever.pp } end it "should use 'apply' if the first argument looks like a .rb file" do command_line = Puppet::Util::CommandLine.new("puppet", %w{ whatever.rb }, @tty ) command_line.subcommand_name.should == "apply" command_line.args.should == %w{ whatever.rb } end it "should use 'apply' if the first argument looks like a flag" do command_line = Puppet::Util::CommandLine.new("puppet", %w{ --debug }, @tty ) command_line.subcommand_name.should == "apply" command_line.args.should == %w{ --debug } end it "should use 'apply' if the first argument is -" do command_line = Puppet::Util::CommandLine.new("puppet", %w{ - }, @tty ) command_line.subcommand_name.should == "apply" command_line.args.should == %w{ - } end it "should return nil if the first argument is --help" do command_line = Puppet::Util::CommandLine.new("puppet", %w{ --help }, @tty ) command_line.subcommand_name.should == nil end it "should return nil if there are no arguments on a tty" do command_line = Puppet::Util::CommandLine.new("puppet", [], @tty ) command_line.subcommand_name.should == nil command_line.args.should == [] end it "should use 'apply' if there are no arguments on a pipe" do command_line = Puppet::Util::CommandLine.new("puppet", [], @pipe ) command_line.subcommand_name.should == "apply" command_line.args.should == [] end it "should return the executable name if it is not puppet" do command_line = Puppet::Util::CommandLine.new("puppetmasterd", [], @tty ) command_line.subcommand_name.should == "puppetmasterd" end it "should translate subcommand names into their legacy equivalent" do command_line = Puppet::Util::CommandLine.new("puppet", ["master"], @tty) command_line.legacy_executable_name.should == "puppetmasterd" end it "should leave legacy command names alone" do command_line = Puppet::Util::CommandLine.new("puppetmasterd", [], @tty) command_line.legacy_executable_name.should == "puppetmasterd" end describe "when the subcommand is not implemented" do it "should find and invoke an executable with a hyphenated name" do commandline = Puppet::Util::CommandLine.new("puppet", ['whatever', 'argument'], @tty) Puppet::Util.expects(:which).with('puppet-whatever').returns('/dev/null/puppet-whatever') commandline.expects(:system).with('/dev/null/puppet-whatever', 'argument') commandline.execute end describe "and an external implementation cannot be found" do it "should abort and show the usage message" do commandline = Puppet::Util::CommandLine.new("puppet", ['whatever', 'argument'], @tty) Puppet::Util.expects(:which).with('puppet-whatever').returns(nil) commandline.expects(:system).never commandline.expects(:usage_message).returns("the usage message") commandline.expects(:abort).with{|x| x =~ /the usage message/}.raises("stubbed abort") lambda{ commandline.execute }.should raise_error('stubbed abort') end end end + describe 'when loading commands' do + before do + @core_apps = %w{describe filebucket kick queue resource agent cert apply doc master} + @command_line = Puppet::Util::CommandLine.new("foo", %w{ client --help whatever.pp }, @tty ) + end + it 'should be able to find all existing commands' do + @core_apps.each do |command| + @command_line.available_subcommands.should include command + end + end + describe 'when multiple paths have applications' do + before do + @dir=tmpdir('command_line_plugin_test') + @appdir="#{@dir}/puppet/application" + FileUtils.mkdir_p(@appdir) + FileUtils.touch("#{@appdir}/foo.rb") + $LOAD_PATH.unshift(@dir) # WARNING: MUST MATCH THE AFTER ACTIONS! + end + it 'should be able to find commands from both paths' do + found = @command_line.available_subcommands + found.should include 'foo' + @core_apps.each { |cmd| found.should include cmd } + end + after do + $LOAD_PATH.shift # WARNING: MUST MATCH THE BEFORE ACTIONS! + end + end + end end diff --git a/spec/unit/util/execution_spec.rb b/spec/unit/util/execution_spec.rb new file mode 100644 index 000000000..312dd3b8e --- /dev/null +++ b/spec/unit/util/execution_spec.rb @@ -0,0 +1,49 @@ +#!/usr/bin/env ruby + +require File.dirname(__FILE__) + '/../../spec_helper' + +describe Puppet::Util::Execution do + include Puppet::Util::Execution + describe "#withenv" do + before :each do + @original_path = ENV["PATH"] + @new_env = {:PATH => "/some/bogus/path"} + end + + it "should change environment variables within the block then reset environment variables to their original values" do + withenv @new_env do + ENV["PATH"].should == "/some/bogus/path" + end + ENV["PATH"].should == @original_path + end + + it "should reset environment variables to their original values even if the block fails" do + begin + withenv @new_env do + ENV["PATH"].should == "/some/bogus/path" + raise "This is a failure" + end + rescue + end + ENV["PATH"].should == @original_path + end + + it "should reset environment variables even when they are set twice" do + # Setting Path & Environment parameters in Exec type can cause weirdness + @new_env["PATH"] = "/someother/bogus/path" + withenv @new_env do + # When assigning duplicate keys, can't guarantee order of evaluation + ENV["PATH"].should =~ /\/some.*\/bogus\/path/ + end + ENV["PATH"].should == @original_path + end + + it "should remove any new environment variables after the block ends" do + @new_env[:FOO] = "bar" + withenv @new_env do + ENV["FOO"].should == "bar" + end + ENV["FOO"].should == nil + end + end +end diff --git a/spec/unit/util/execution_stub_spec.rb b/spec/unit/util/execution_stub_spec.rb new file mode 100644 index 000000000..14cf9c67a --- /dev/null +++ b/spec/unit/util/execution_stub_spec.rb @@ -0,0 +1,35 @@ +#!/usr/bin/env ruby + +require File.dirname(__FILE__) + '/../../spec_helper' + +describe Puppet::Util::ExecutionStub do + it "should use the provided stub code when 'set' is called" do + Puppet::Util::ExecutionStub.set do |command, options| + command.should == ['/bin/foo', 'bar'] + "stub output" + end + Puppet::Util::ExecutionStub.current_value.should_not == nil + Puppet::Util.execute(['/bin/foo', 'bar']).should == "stub output" + end + + it "should automatically restore normal execution at the conclusion of each spec test" do + # Note: this test relies on the previous test creating a stub. + Puppet::Util::ExecutionStub.current_value.should == nil + end + + it "should restore normal execution after 'reset' is called" do + true_command = Puppet::Util.which('true') # Note: "true" exists at different paths in different OSes + stub_call_count = 0 + Puppet::Util::ExecutionStub.set do |command, options| + command.should == [true_command] + stub_call_count += 1 + 'stub called' + end + Puppet::Util.execute([true_command]).should == 'stub called' + stub_call_count.should == 1 + Puppet::Util::ExecutionStub.reset + Puppet::Util::ExecutionStub.current_value.should == nil + Puppet::Util.execute([true_command]).should == '' + stub_call_count.should == 1 + end +end diff --git a/spec/unit/util/log/destinations_spec.rb b/spec/unit/util/log/destinations_spec.rb index 468702fb3..b84c2ab44 100755 --- a/spec/unit/util/log/destinations_spec.rb +++ b/spec/unit/util/log/destinations_spec.rb @@ -1,24 +1,37 @@ #!/usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper') require 'puppet/util/log' describe Puppet::Util::Log.desttypes[:report] do before do @dest = Puppet::Util::Log.desttypes[:report] end it "should require a report at initialization" do @dest.new("foo").report.should == "foo" end it "should send new messages to the report" do report = mock 'report' dest = @dest.new(report) report.expects(:<<).with("my log") dest.handle "my log" end end + + +describe Puppet::Util::Log.desttypes[:file] do + before do + File.stubs(:open) # prevent actually creating the file + @class = Puppet::Util::Log.desttypes[:file] + end + + it "should default to autoflush false" do + @class.new('/tmp/log').autoflush.should == false + end +end + diff --git a/spec/unit/util/log_spec.rb b/spec/unit/util/log_spec.rb index a6f11739b..29df0787a 100755 --- a/spec/unit/util/log_spec.rb +++ b/spec/unit/util/log_spec.rb @@ -1,222 +1,227 @@ #!/usr/bin/env ruby Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") } require 'puppet/util/log' describe Puppet::Util::Log do it "should write a given message to the specified destination" do arraydest = [] Puppet::Util::Log.newdestination(Puppet::Test::LogCollector.new(arraydest)) Puppet::Util::Log.new(:level => :notice, :message => "foo") message = arraydest.last.message message.should == "foo" end describe Puppet::Util::Log::DestConsole do before do @console = Puppet::Util::Log::DestConsole.new end it "should colorize if Puppet[:color] is :ansi" do Puppet[:color] = :ansi @console.colorize(:alert, "abc").should == "\e[0;31mabc\e[0m" end it "should colorize if Puppet[:color] is 'yes'" do Puppet[:color] = "yes" @console.colorize(:alert, "abc").should == "\e[0;31mabc\e[0m" end it "should htmlize if Puppet[:color] is :html" do Puppet[:color] = :html @console.colorize(:alert, "abc").should == "abc" end it "should do nothing if Puppet[:color] is false" do Puppet[:color] = false @console.colorize(:alert, "abc").should == "abc" end it "should do nothing if Puppet[:color] is invalid" do Puppet[:color] = "invalid option" @console.colorize(:alert, "abc").should == "abc" end end describe "instances" do before do Puppet::Util::Log.stubs(:newmessage) end [:level, :message, :time, :remote].each do |attr| it "should have a #{attr} attribute" do log = Puppet::Util::Log.new :level => :notice, :message => "A test message" log.should respond_to(attr) log.should respond_to(attr.to_s + "=") end end it "should fail if created without a level" do lambda { Puppet::Util::Log.new(:message => "A test message") }.should raise_error(ArgumentError) end it "should fail if created without a message" do lambda { Puppet::Util::Log.new(:level => :notice) }.should raise_error(ArgumentError) end it "should make available the level passed in at initialization" do Puppet::Util::Log.new(:level => :notice, :message => "A test message").level.should == :notice end it "should make available the message passed in at initialization" do Puppet::Util::Log.new(:level => :notice, :message => "A test message").message.should == "A test message" end # LAK:NOTE I don't know why this behavior is here, I'm just testing what's in the code, # at least at first. it "should always convert messages to strings" do Puppet::Util::Log.new(:level => :notice, :message => :foo).message.should == "foo" end it "should flush the log queue when the first destination is specified" do Puppet::Util::Log.close_all Puppet::Util::Log.expects(:flushqueue) Puppet::Util::Log.newdestination(:console) end it "should convert the level to a symbol if it's passed in as a string" do Puppet::Util::Log.new(:level => "notice", :message => :foo).level.should == :notice end it "should fail if the level is not a symbol or string" do lambda { Puppet::Util::Log.new(:level => 50, :message => :foo) }.should raise_error(ArgumentError) end it "should fail if the provided level is not valid" do Puppet::Util::Log.expects(:validlevel?).with(:notice).returns false lambda { Puppet::Util::Log.new(:level => :notice, :message => :foo) }.should raise_error(ArgumentError) end it "should set its time to the initialization time" do time = mock 'time' Time.expects(:now).returns time Puppet::Util::Log.new(:level => "notice", :message => :foo).time.should equal(time) end it "should make available any passed-in tags" do log = Puppet::Util::Log.new(:level => "notice", :message => :foo, :tags => %w{foo bar}) log.tags.should be_include("foo") log.tags.should be_include("bar") end it "should use an passed-in source" do Puppet::Util::Log.any_instance.expects(:source=).with "foo" Puppet::Util::Log.new(:level => "notice", :message => :foo, :source => "foo") end [:file, :line].each do |attr| it "should use #{attr} if provided" do Puppet::Util::Log.any_instance.expects(attr.to_s + "=").with "foo" Puppet::Util::Log.new(:level => "notice", :message => :foo, attr => "foo") end end it "should default to 'Puppet' as its source" do Puppet::Util::Log.new(:level => "notice", :message => :foo).source.should == "Puppet" end it "should register itself with Log" do Puppet::Util::Log.expects(:newmessage) Puppet::Util::Log.new(:level => "notice", :message => :foo) end + it "should update Log autoflush when Puppet[:autoflush] is set" do + Puppet::Util::Log.expects(:autoflush=).once.with(true) + Puppet[:autoflush] = true + end + it "should have a method for determining if a tag is present" do Puppet::Util::Log.new(:level => "notice", :message => :foo).should respond_to(:tagged?) end it "should match a tag if any of the tags are equivalent to the passed tag as a string" do Puppet::Util::Log.new(:level => "notice", :message => :foo, :tags => %w{one two}).should be_tagged(:one) end it "should tag itself with its log level" do Puppet::Util::Log.new(:level => "notice", :message => :foo).should be_tagged(:notice) end it "should return its message when converted to a string" do Puppet::Util::Log.new(:level => "notice", :message => :foo).to_s.should == "foo" end it "should include its time, source, level, and message when prepared for reporting" do log = Puppet::Util::Log.new(:level => "notice", :message => :foo) report = log.to_report report.should be_include("notice") report.should be_include("foo") report.should be_include(log.source) report.should be_include(log.time.to_s) end describe "when setting the source as a RAL object" do it "should tag itself with any tags the source has" do source = Puppet::Type.type(:file).new :path => "/foo/bar" log = Puppet::Util::Log.new(:level => "notice", :message => :foo, :source => source) source.tags.each do |tag| log.tags.should be_include(tag) end end it "should use the source_descriptors" do source = stub "source" source.stubs(:source_descriptors).returns(:tags => ["tag","tag2"], :path => "path", :version => 100) log = Puppet::Util::Log.new(:level => "notice", :message => :foo) log.expects(:tag).with("tag") log.expects(:tag).with("tag2") log.source = source log.source.should == "path" end it "should copy over any file and line information" do source = Puppet::Type.type(:file).new :path => "/foo/bar" source.file = "/my/file" source.line = 50 log = Puppet::Util::Log.new(:level => "notice", :message => :foo, :source => source) log.file.should == "/my/file" log.line.should == 50 end end describe "when setting the source as a non-RAL object" do it "should not try to copy over file, version, line, or tag information" do source = Puppet::Module.new("foo") source.expects(:file).never log = Puppet::Util::Log.new(:level => "notice", :message => :foo, :source => source) end end end describe "to_yaml" do it "should not include the @version attribute" do log = Puppet::Util::Log.new(:level => "notice", :message => :foo, :version => 100) log.to_yaml_properties.should_not include('@version') end it "should include attributes @level, @message, @source, @tags, and @time" do log = Puppet::Util::Log.new(:level => "notice", :message => :foo, :version => 100) log.to_yaml_properties.should == %w{@level @message @source @tags @time} end it "should include attributes @file and @line if specified" do log = Puppet::Util::Log.new(:level => "notice", :message => :foo, :file => "foo", :line => 35) log.to_yaml_properties.should include('@file') log.to_yaml_properties.should include('@line') end end end diff --git a/spec/unit/util/rdoc/parser_spec.rb b/spec/unit/util/rdoc/parser_spec.rb index 04713f293..8545def54 100755 --- a/spec/unit/util/rdoc/parser_spec.rb +++ b/spec/unit/util/rdoc/parser_spec.rb @@ -1,550 +1,562 @@ #!/usr/bin/env ruby Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") } require 'puppet/resource/type_collection' require 'puppet/util/rdoc/parser' require 'puppet/util/rdoc/code_objects' require 'rdoc/options' require 'rdoc/rdoc' describe RDoc::Parser do before :each do File.stubs(:stat).with("init.pp") @top_level = stub_everything 'toplevel', :file_relative_name => "init.pp" @parser = RDoc::Parser.new(@top_level, "module/manifests/init.pp", nil, Options.instance, RDoc::Stats.new) end describe "when scanning files" do it "should parse puppet files with the puppet parser" do @parser.stubs(:scan_top_level) parser = stub 'parser' Puppet::Parser::Parser.stubs(:new).returns(parser) parser.expects(:parse).returns(Puppet::Parser::AST::Hostclass.new('')) parser.expects(:file=).with("module/manifests/init.pp") @parser.scan end it "should scan the ast for Puppet files" do parser = stub_everything 'parser' Puppet::Parser::Parser.stubs(:new).returns(parser) parser.expects(:parse).returns(Puppet::Parser::AST::Hostclass.new('')) @parser.expects(:scan_top_level) @parser.scan end it "should return a PuppetTopLevel to RDoc" do parser = stub_everything 'parser' Puppet::Parser::Parser.stubs(:new).returns(parser) parser.expects(:parse).returns(Puppet::Parser::AST::Hostclass.new('')) @parser.expects(:scan_top_level) @parser.scan.should be_a(RDoc::PuppetTopLevel) end + + it "should scan the top level even if the file has already parsed" do + known_type = stub 'known_types' + env = stub 'env' + Puppet::Node::Environment.stubs(:new).returns(env) + env.stubs(:known_resource_types).returns(known_type) + known_type.expects(:watching_file?).with("module/manifests/init.pp").returns(true) + + @parser.expects(:scan_top_level) + + @parser.scan + end end describe "when scanning top level entities" do before :each do @resource_type_collection = resource_type_collection = stub_everything('resource_type_collection') @parser.instance_eval { @known_resource_types = resource_type_collection } @parser.stubs(:split_module).returns("module") @topcontainer = stub_everything 'topcontainer' @container = stub_everything 'container' @module = stub_everything 'module' @container.stubs(:add_module).returns(@module) @parser.stubs(:get_class_or_module).returns([@container, "module"]) end it "should read any present README as module documentation" do FileTest.stubs(:readable?).returns(true) File.stubs(:open).returns("readme") @parser.stubs(:parse_elements) @module.expects(:comment=).with("readme") @parser.scan_top_level(@topcontainer) end it "should tell the container its module name" do @parser.stubs(:parse_elements) @topcontainer.expects(:module_name=).with("module") @parser.scan_top_level(@topcontainer) end it "should not document our toplevel if it isn't a valid module" do @parser.stubs(:split_module).returns(nil) @topcontainer.expects(:document_self=).with(false) @parser.expects(:parse_elements).never @parser.scan_top_level(@topcontainer) end it "should set the module as global if we parse the global manifests (ie __site__ module)" do @parser.stubs(:split_module).returns(RDoc::Parser::SITE) @parser.stubs(:parse_elements) @topcontainer.expects(:global=).with(true) @parser.scan_top_level(@topcontainer) end it "should attach this module container to the toplevel container" do @parser.stubs(:parse_elements) @container.expects(:add_module).with(RDoc::PuppetModule, "module").returns(@module) @parser.scan_top_level(@topcontainer) end it "should defer ast parsing to parse_elements for this module" do @parser.expects(:parse_elements).with(@module) @parser.scan_top_level(@topcontainer) end it "should defer plugins parsing to parse_plugins for this module" do @parser.input_file_name = "module/lib/puppet/parser/function.rb" @parser.expects(:parse_plugins).with(@module) @parser.scan_top_level(@topcontainer) end end describe "when finding modules from filepath" do before :each do Puppet::Module.stubs(:modulepath).returns("/path/to/modules") end it "should return the module name for modulized puppet manifests" do File.stubs(:expand_path).returns("/path/to/module/manifests/init.pp") File.stubs(:identical?).with("/path/to", "/path/to/modules").returns(true) @parser.split_module("/path/to/modules/mymodule/manifests/init.pp").should == "module" end it "should return for manifests not under module path" do File.stubs(:expand_path).returns("/path/to/manifests/init.pp") File.stubs(:identical?).returns(false) @parser.split_module("/path/to/manifests/init.pp").should == RDoc::Parser::SITE end end describe "when parsing AST elements" do before :each do @klass = stub_everything 'klass', :file => "module/manifests/init.pp", :name => "myclass", :type => :hostclass @definition = stub_everything 'definition', :file => "module/manifests/init.pp", :type => :definition, :name => "mydef" @node = stub_everything 'node', :file => "module/manifests/init.pp", :type => :node, :name => "mynode" @resource_type_collection = resource_type_collection = Puppet::Resource::TypeCollection.new("env") @parser.instance_eval { @known_resource_types = resource_type_collection } @container = stub_everything 'container' end it "should document classes in the parsed file" do @resource_type_collection.add_hostclass(@klass) @parser.expects(:document_class).with("myclass", @klass, @container) @parser.parse_elements(@container) end it "should not document class parsed in an other file" do @klass.stubs(:file).returns("/not/same/path/file.pp") @resource_type_collection.add_hostclass(@klass) @parser.expects(:document_class).with("myclass", @klass, @container).never @parser.parse_elements(@container) end it "should document vardefs for the main class" do @klass.stubs(:name).returns :main @resource_type_collection.add_hostclass(@klass) code = stub 'code', :is_a? => false @klass.stubs(:name).returns("") @klass.stubs(:code).returns(code) @parser.expects(:scan_for_vardef).with(@container, code) @parser.parse_elements(@container) end it "should document definitions in the parsed file" do @resource_type_collection.add_definition(@definition) @parser.expects(:document_define).with("mydef", @definition, @container) @parser.parse_elements(@container) end it "should not document definitions parsed in an other file" do @definition.stubs(:file).returns("/not/same/path/file.pp") @resource_type_collection.add_definition(@definition) @parser.expects(:document_define).with("mydef", @definition, @container).never @parser.parse_elements(@container) end it "should document nodes in the parsed file" do @resource_type_collection.add_node(@node) @parser.expects(:document_node).with("mynode", @node, @container) @parser.parse_elements(@container) end it "should not document node parsed in an other file" do @node.stubs(:file).returns("/not/same/path/file.pp") @resource_type_collection.add_node(@node) @parser.expects(:document_node).with("mynode", @node, @container).never @parser.parse_elements(@container) end end describe "when documenting definition" do before(:each) do @define = stub_everything 'define', :arguments => [], :doc => "mydoc", :file => "file", :line => 42 @class = stub_everything 'class' @parser.stubs(:get_class_or_module).returns([@class, "mydef"]) end it "should register a RDoc method to the current container" do @class.expects(:add_method).with { |m| m.name == "mydef"} @parser.document_define("mydef", @define, @class) end it "should attach the documentation to this method" do @class.expects(:add_method).with { |m| m.comment = "mydoc" } @parser.document_define("mydef", @define, @class) end it "should produce a better error message on unhandled exception" do @class.expects(:add_method).raises(ArgumentError) lambda { @parser.document_define("mydef", @define, @class) }.should raise_error(Puppet::ParseError, /in file at line 42/) end it "should convert all definition parameter to string" do arg = stub 'arg' val = stub 'val' @define.stubs(:arguments).returns({arg => val}) arg.expects(:to_s).returns("arg") val.expects(:to_s).returns("val") @parser.document_define("mydef", @define, @class) end end describe "when documenting nodes" do before :each do @code = stub_everything 'code' @node = stub_everything 'node', :doc => "mydoc", :parent => "parent", :code => @code, :file => "file", :line => 42 @rdoc_node = stub_everything 'rdocnode' @class = stub_everything 'class' @class.stubs(:add_node).returns(@rdoc_node) end it "should add a node to the current container" do @class.expects(:add_node).with("mynode", "parent").returns(@rdoc_node) @parser.document_node("mynode", @node, @class) end it "should associate the node documentation to the rdoc node" do @rdoc_node.expects(:comment=).with("mydoc") @parser.document_node("mynode", @node, @class) end it "should scan for include and require" do @parser.expects(:scan_for_include_or_require).with(@rdoc_node, @code) @parser.document_node("mynode", @node, @class) end it "should scan for variable definition" do @parser.expects(:scan_for_vardef).with(@rdoc_node, @code) @parser.document_node("mynode", @node, @class) end it "should scan for resources if needed" do Puppet.settings.stubs(:[]).with(:document_all).returns(true) @parser.expects(:scan_for_resource).with(@rdoc_node, @code) @parser.document_node("mynode", @node, @class) end it "should produce a better error message on unhandled exception" do @class.stubs(:add_node).raises(ArgumentError) lambda { @parser.document_node("mynode", @node, @class) }.should raise_error(Puppet::ParseError, /in file at line 42/) end end describe "when documenting classes" do before :each do @code = stub_everything 'code' @class = stub_everything 'class', :doc => "mydoc", :parent => "parent", :code => @code, :file => "file", :line => 42 @rdoc_class = stub_everything 'rdoc-class' @module = stub_everything 'class' @module.stubs(:add_class).returns(@rdoc_class) @parser.stubs(:get_class_or_module).returns([@module, "myclass"]) end it "should add a class to the current container" do @module.expects(:add_class).with(RDoc::PuppetClass, "myclass", "parent").returns(@rdoc_class) @parser.document_class("mynode", @class, @module) end it "should set the superclass" do @rdoc_class.expects(:superclass=).with("parent") @parser.document_class("mynode", @class, @module) end it "should associate the node documentation to the rdoc class" do @rdoc_class.expects(:comment=).with("mydoc") @parser.document_class("mynode", @class, @module) end it "should scan for include and require" do @parser.expects(:scan_for_include_or_require).with(@rdoc_class, @code) @parser.document_class("mynode", @class, @module) end it "should scan for resources if needed" do Puppet.settings.stubs(:[]).with(:document_all).returns(true) @parser.expects(:scan_for_resource).with(@rdoc_class, @code) @parser.document_class("mynode", @class, @module) end it "should produce a better error message on unhandled exception" do @module.stubs(:add_class).raises(ArgumentError) lambda { @parser.document_class("mynode", @class, @module) }.should raise_error(Puppet::ParseError, /in file at line 42/) end end describe "when scanning for includes and requires" do def create_stmt(name) - stmt_value = stub "#{name}_value", :value => "myclass" + stmt_value = stub "#{name}_value", :to_s => "myclass" Puppet::Parser::AST::Function.new( :name => name, :arguments => [stmt_value], :doc => 'mydoc' ) end before(:each) do @class = stub_everything 'class' @code = stub_everything 'code' @code.stubs(:is_a?).with(Puppet::Parser::AST::ASTArray).returns(true) end it "should also scan mono-instruction code" do @class.expects(:add_include).with { |i| i.is_a?(RDoc::Include) and i.name == "myclass" and i.comment == "mydoc" } - @parser.scan_for_include_or_require(@class,create_stmt("include")) + @parser.scan_for_include_or_require(@class, create_stmt("include")) end it "should register recursively includes to the current container" do @code.stubs(:children).returns([ create_stmt("include") ]) - @class.expects(:add_include).with { |i| i.is_a?(RDoc::Include) and i.name == "myclass" and i.comment == "mydoc" } + @class.expects(:add_include)#.with { |i| i.is_a?(RDoc::Include) and i.name == "myclass" and i.comment == "mydoc" } @parser.scan_for_include_or_require(@class, [@code]) end it "should register requires to the current container" do @code.stubs(:children).returns([ create_stmt("require") ]) @class.expects(:add_require).with { |i| i.is_a?(RDoc::Include) and i.name == "myclass" and i.comment == "mydoc" } @parser.scan_for_include_or_require(@class, [@code]) end end describe "when scanning for realized virtual resources" do def create_stmt stmt_value = stub "resource_ref", :to_s => "File[\"/tmp/a\"]" Puppet::Parser::AST::Function.new( :name => 'realize', :arguments => [stmt_value], :doc => 'mydoc' ) end before(:each) do @class = stub_everything 'class' @code = stub_everything 'code' @code.stubs(:is_a?).with(Puppet::Parser::AST::ASTArray).returns(true) end it "should also scan mono-instruction code" do @class.expects(:add_realize).with { |i| i.is_a?(RDoc::Include) and i.name == "File[\"/tmp/a\"]" and i.comment == "mydoc" } @parser.scan_for_realize(@class,create_stmt) end it "should register recursively includes to the current container" do @code.stubs(:children).returns([ create_stmt ]) @class.expects(:add_realize).with { |i| i.is_a?(RDoc::Include) and i.name == "File[\"/tmp/a\"]" and i.comment == "mydoc" } @parser.scan_for_realize(@class, [@code]) end end describe "when scanning for variable definition" do before :each do @class = stub_everything 'class' @stmt = stub_everything 'stmt', :name => "myvar", :value => "myvalue", :doc => "mydoc" @stmt.stubs(:is_a?).with(Puppet::Parser::AST::ASTArray).returns(false) @stmt.stubs(:is_a?).with(Puppet::Parser::AST::VarDef).returns(true) @code = stub_everything 'code' @code.stubs(:is_a?).with(Puppet::Parser::AST::ASTArray).returns(true) end it "should recursively register variables to the current container" do @code.stubs(:children).returns([ @stmt ]) @class.expects(:add_constant).with { |i| i.is_a?(RDoc::Constant) and i.name == "myvar" and i.comment == "mydoc" } @parser.scan_for_vardef(@class, [ @code ]) end it "should also scan mono-instruction code" do @class.expects(:add_constant).with { |i| i.is_a?(RDoc::Constant) and i.name == "myvar" and i.comment == "mydoc" } @parser.scan_for_vardef(@class, @stmt) end end describe "when scanning for resources" do before :each do @class = stub_everything 'class' @stmt = Puppet::Parser::AST::Resource.new( :type => "File", :instances => Puppet::Parser::AST::ASTArray.new(:children => [ Puppet::Parser::AST::ResourceInstance.new( :title => Puppet::Parser::AST::Name.new(:value => "myfile"), :parameters => Puppet::Parser::AST::ASTArray.new(:children => []) ) ]), :doc => 'mydoc' ) @code = stub_everything 'code' @code.stubs(:is_a?).with(Puppet::Parser::AST::ASTArray).returns(true) end it "should register a PuppetResource to the current container" do @code.stubs(:children).returns([ @stmt ]) @class.expects(:add_resource).with { |i| i.is_a?(RDoc::PuppetResource) and i.title == "myfile" and i.comment == "mydoc" } @parser.scan_for_resource(@class, [ @code ]) end it "should also scan mono-instruction code" do @class.expects(:add_resource).with { |i| i.is_a?(RDoc::PuppetResource) and i.title == "myfile" and i.comment == "mydoc" } @parser.scan_for_resource(@class, @stmt) end end describe "when parsing plugins" do before :each do @container = stub 'container' end it "should delegate parsing custom facts to parse_facts" do @parser = RDoc::Parser.new(@top_level, "module/manifests/lib/puppet/facter/test.rb", nil, Options.instance, RDoc::Stats.new) @parser.expects(:parse_fact).with(@container) @parser.parse_plugins(@container) end it "should delegate parsing plugins to parse_plugins" do @parser = RDoc::Parser.new(@top_level, "module/manifests/lib/puppet/functions/test.rb", nil, Options.instance, RDoc::Stats.new) @parser.expects(:parse_puppet_plugin).with(@container) @parser.parse_plugins(@container) end end describe "when parsing plugins" do before :each do @container = stub_everything 'container' end it "should add custom functions to the container" do File.stubs(:open).yields("# documentation module Puppet::Parser::Functions newfunction(:myfunc, :type => :rvalue) do |args| File.dirname(args[0]) end end".split("\n")) @container.expects(:add_plugin).with do |plugin| plugin.comment == "documentation\n" #and plugin.name == "myfunc" end @parser.parse_puppet_plugin(@container) end it "should add custom types to the container" do File.stubs(:open).yields("# documentation Puppet::Type.newtype(:mytype) do end".split("\n")) @container.expects(:add_plugin).with do |plugin| plugin.comment == "documentation\n" #and plugin.name == "mytype" end @parser.parse_puppet_plugin(@container) end end describe "when parsing facts" do before :each do @container = stub_everything 'container' File.stubs(:open).yields(["# documentation", "Facter.add('myfact') do", "confine :kernel => :linux", "end"]) end it "should add facts to the container" do @container.expects(:add_fact).with do |fact| fact.comment == "documentation\n" and fact.name == "myfact" end @parser.parse_fact(@container) end it "should add confine to the parsed facts" do ourfact = nil @container.expects(:add_fact).with do |fact| ourfact = fact true end @parser.parse_fact(@container) ourfact.confine.should == { :type => "kernel", :value => ":linux" } end end end diff --git a/spec/unit/util/rdoc_spec.rb b/spec/unit/util/rdoc_spec.rb index 41d4b9cd0..93c4f9bfa 100755 --- a/spec/unit/util/rdoc_spec.rb +++ b/spec/unit/util/rdoc_spec.rb @@ -1,186 +1,148 @@ #!/usr/bin/env ruby Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") } require 'puppet/util/rdoc' require 'rdoc/rdoc' describe Puppet::Util::RDoc do describe "when generating RDoc HTML documentation" do before :each do @rdoc = stub_everything 'rdoc' RDoc::RDoc.stubs(:new).returns(@rdoc) end it "should tell the parser to ignore import" do Puppet.expects(:[]=).with(:ignoreimport, true) Puppet::Util::RDoc.rdoc("output", []) end it "should install the Puppet HTML Generator into RDoc generators" do Puppet::Util::RDoc.rdoc("output", []) RDoc::RDoc::GENERATORS["puppet"].file_name.should == "puppet/util/rdoc/generators/puppet_generator.rb" end it "should tell RDoc to generate documentation using the Puppet generator" do @rdoc.expects(:document).with { |args| args.include?("--fmt") and args.include?("puppet") } Puppet::Util::RDoc.rdoc("output", []) end it "should tell RDoc to be quiet" do @rdoc.expects(:document).with { |args| args.include?("--quiet") } Puppet::Util::RDoc.rdoc("output", []) end it "should pass charset to RDoc" do @rdoc.expects(:document).with { |args| args.include?("--charset") and args.include?("utf-8") } Puppet::Util::RDoc.rdoc("output", [], "utf-8") end it "should tell RDoc to force updates of indices when RDoc supports it" do Options::OptionList.stubs(:options).returns([["--force-update", "-U", 0 ]]) @rdoc.expects(:document).with { |args| args.include?("--force-update") } Puppet::Util::RDoc.rdoc("output", []) end it "should not tell RDoc to force updates of indices when RDoc doesn't support it" do Options::OptionList.stubs(:options).returns([]) @rdoc.expects(:document).never.with { |args| args.include?("--force-update") } Puppet::Util::RDoc.rdoc("output", []) end it "should tell RDoc to use the given outputdir" do @rdoc.expects(:document).with { |args| args.include?("--op") and args.include?("myoutputdir") } Puppet::Util::RDoc.rdoc("myoutputdir", []) end it "should tell RDoc to exclude .pp files under any modules//files section" do @rdoc.expects(:document).with { |args| args.include?("--exclude") and args.include?("/modules/[^/]*/files/.*\.pp$") } Puppet::Util::RDoc.rdoc("myoutputdir", []) end it "should give all the source directories to RDoc" do @rdoc.expects(:document).with { |args| args.include?("sourcedir") } Puppet::Util::RDoc.rdoc("output", ["sourcedir"]) end end describe "when running a manifest documentation" do it "should tell the parser to ignore import" do Puppet.expects(:[]=).with(:ignoreimport, true) Puppet::Util::RDoc.manifestdoc([]) end it "should use a parser with the correct environment" do FileTest.stubs(:file?).returns(true) Puppet::Util::RDoc.stubs(:output) parser = stub_everything Puppet::Parser::Parser.stubs(:new).with{ |env| env.is_a?(Puppet::Node::Environment) }.returns(parser) parser.expects(:file=).with("file") parser.expects(:parse) Puppet::Util::RDoc.manifestdoc(["file"]) end it "should puppet parse all given files" do FileTest.stubs(:file?).returns(true) Puppet::Util::RDoc.stubs(:output) parser = stub_everything Puppet::Parser::Parser.stubs(:new).returns(parser) parser.expects(:file=).with("file") parser.expects(:parse) Puppet::Util::RDoc.manifestdoc(["file"]) end it "should call output for each parsed file" do FileTest.stubs(:file?).returns(true) ast = stub_everything parser = stub_everything Puppet::Parser::Parser.stubs(:new).returns(parser) parser.stubs(:parse).returns(ast) Puppet::Util::RDoc.expects(:output).with("file", ast) Puppet::Util::RDoc.manifestdoc(["file"]) end describe "when outputing documentation" do - before :each do - @node = stub 'node', :file => "file", :line => 1, :doc => "" - @class = stub 'class', :file => "file", :line => 4, :doc => "" - @definition = stub 'definition', :file => "file", :line => 3, :doc => "" - @ast = stub 'ast', :nodes => { :node => @node }, :hostclasses => { :class => @class }, :definitions => { :definition => @definition } - end - - it "should output doc for ast nodes" do - @node.expects(:doc) - - Puppet::Util::RDoc.output("file", @ast) - end - - it "should output doc for ast classes" do - @class.expects(:doc) - - Puppet::Util::RDoc.output("file", @ast) - end - - it "should output doc for ast definitions" do - @definition.expects(:doc) - - Puppet::Util::RDoc.output("file", @ast) - end - - it "should output doc in order of increasing line number" do - byline = sequence('byline') - @node.expects(:doc).in_sequence(byline) - @definition.expects(:doc).in_sequence(byline) - @class.expects(:doc).in_sequence(byline) - - Puppet::Util::RDoc.output("file", @ast) - end - - it "should not output documentation of ast object of another node" do - klass = stub 'otherclass', :file => "otherfile", :line => 12, :doc => "" - @ast.stubs(:hostclasses).returns({ :otherclass => klass }) - - klass.expects(:doc).never - - Puppet::Util::RDoc.output("file", @ast) + it "should output doc for ast classes, nodes and definitions in order of increasing line number" do + byline = sequence('documentation outputs in line order') + Puppet::Util::RDoc.expects(:puts).with("im a class\n").in_sequence(byline) + Puppet::Util::RDoc.expects(:puts).with("im a node\n").in_sequence(byline) + Puppet::Util::RDoc.expects(:puts).with("im a define\n").in_sequence(byline) + # any other output must fail + Puppet::Util::RDoc.manifestdoc([my_fixture('basic.pp')]) end it "should output resource documentation if needed" do - Puppet.settings.stubs(:[]).with(:document_all).returns(true) - [@node,@definition].each do |o| - o.stubs(:code).returns([]) - end - - resource = stub_everything 'resource', :line => 1 - resource.stubs(:is_a?).with(Puppet::Parser::AST::ASTArray).returns(false) - resource.stubs(:is_a?).with(Puppet::Parser::AST::Resource).returns(true) - @class.stubs(:code).returns([resource]) - - resource.expects(:doc) - - Puppet::Util::RDoc.output("file", @ast) + pending "#6634 being fixed" + Puppet.settings[:document_all] = true + byline = sequence('documentation outputs in line order') + Puppet::Util::RDoc.expects(:puts).with("im a class\n").in_sequence(byline) + Puppet::Util::RDoc.expects(:puts).with("im a node\n").in_sequence(byline) + Puppet::Util::RDoc.expects(:puts).with("im a define\n").in_sequence(byline) + Puppet::Util::RDoc.expects(:puts).with("im a resource\n").in_sequence(byline) + # any other output must fail + Puppet::Util::RDoc.manifestdoc([my_fixture('basic.pp')]) end end end end diff --git a/spec/unit/util/settings_spec.rb b/spec/unit/util/settings_spec.rb index 732be6a08..2ab31c294 100755 --- a/spec/unit/util/settings_spec.rb +++ b/spec/unit/util/settings_spec.rb @@ -1,1099 +1,1108 @@ #!/usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') describe Puppet::Util::Settings do describe "when specifying defaults" do before do @settings = Puppet::Util::Settings.new end it "should start with no defined parameters" do @settings.params.length.should == 0 end it "should allow specification of default values associated with a section as an array" do @settings.setdefaults(:section, :myvalue => ["defaultval", "my description"]) end it "should not allow duplicate parameter specifications" do @settings.setdefaults(:section, :myvalue => ["a", "b"]) lambda { @settings.setdefaults(:section, :myvalue => ["c", "d"]) }.should raise_error(ArgumentError) end it "should allow specification of default values associated with a section as a hash" do @settings.setdefaults(:section, :myvalue => {:default => "defaultval", :desc => "my description"}) end it "should consider defined parameters to be valid" do @settings.setdefaults(:section, :myvalue => ["defaultval", "my description"]) @settings.valid?(:myvalue).should be_true end it "should require a description when defaults are specified with an array" do lambda { @settings.setdefaults(:section, :myvalue => ["a value"]) }.should raise_error(ArgumentError) end it "should require a description when defaults are specified with a hash" do lambda { @settings.setdefaults(:section, :myvalue => {:default => "a value"}) }.should raise_error(ArgumentError) end it "should raise an error if we can't guess the type" do lambda { @settings.setdefaults(:section, :myvalue => {:default => Object.new, :desc => "An impossible object"}) }.should raise_error(ArgumentError) end it "should support specifying owner, group, and mode when specifying files" do @settings.setdefaults(:section, :myvalue => {:default => "/some/file", :owner => "service", :mode => "boo", :group => "service", :desc => "whatever"}) end it "should support specifying a short name" do @settings.setdefaults(:section, :myvalue => {:default => "w", :desc => "b", :short => "m"}) end it "should support specifying the setting type" do @settings.setdefaults(:section, :myvalue => {:default => "/w", :desc => "b", :type => :setting}) @settings.setting(:myvalue).should be_instance_of(Puppet::Util::Settings::Setting) end it "should fail if an invalid setting type is specified" do lambda { @settings.setdefaults(:section, :myvalue => {:default => "w", :desc => "b", :type => :foo}) }.should raise_error(ArgumentError) end it "should fail when short names conflict" do @settings.setdefaults(:section, :myvalue => {:default => "w", :desc => "b", :short => "m"}) lambda { @settings.setdefaults(:section, :myvalue => {:default => "w", :desc => "b", :short => "m"}) }.should raise_error(ArgumentError) end end describe "when setting values" do before do @settings = Puppet::Util::Settings.new @settings.setdefaults :main, :myval => ["val", "desc"] @settings.setdefaults :main, :bool => [true, "desc"] end it "should provide a method for setting values from other objects" do @settings[:myval] = "something else" @settings[:myval].should == "something else" end it "should support a getopt-specific mechanism for setting values" do @settings.handlearg("--myval", "newval") @settings[:myval].should == "newval" end it "should support a getopt-specific mechanism for turning booleans off" do @settings[:bool] = true @settings.handlearg("--no-bool", "") @settings[:bool].should == false end it "should support a getopt-specific mechanism for turning booleans on" do # Turn it off first @settings[:bool] = false @settings.handlearg("--bool", "") @settings[:bool].should == true end it "should consider a cli setting with no argument to be a boolean" do # Turn it off first @settings[:bool] = false @settings.handlearg("--bool") @settings[:bool].should == true end it "should consider a cli setting with an empty string as an argument to be a boolean, if the setting itself is a boolean" do # Turn it off first @settings[:bool] = false @settings.handlearg("--bool", "") @settings[:bool].should == true end it "should consider a cli setting with an empty string as an argument to be an empty argument, if the setting itself is not a boolean" do @settings[:myval] = "bob" @settings.handlearg("--myval", "") @settings[:myval].should == "" end it "should consider a cli setting with a boolean as an argument to be a boolean" do # Turn it off first @settings[:bool] = false @settings.handlearg("--bool", "true") @settings[:bool].should == true end it "should not consider a cli setting of a non boolean with a boolean as an argument to be a boolean" do # Turn it off first @settings[:myval] = "bob" @settings.handlearg("--no-myval", "") @settings[:myval].should == "" end it "should clear the cache when setting getopt-specific values" do @settings.setdefaults :mysection, :one => ["whah", "yay"], :two => ["$one yay", "bah"] @settings[:two].should == "whah yay" @settings.handlearg("--one", "else") @settings[:two].should == "else yay" end it "should not clear other values when setting getopt-specific values" do @settings[:myval] = "yay" @settings.handlearg("--no-bool", "") @settings[:myval].should == "yay" end it "should clear the list of used sections" do @settings.expects(:clearused) @settings[:myval] = "yay" end it "should call passed blocks when values are set" do values = [] @settings.setdefaults(:section, :hooker => {:default => "yay", :desc => "boo", :hook => lambda { |v| values << v }}) values.should == [] @settings[:hooker] = "something" values.should == %w{something} end it "should call passed blocks when values are set via the command line" do values = [] @settings.setdefaults(:section, :hooker => {:default => "yay", :desc => "boo", :hook => lambda { |v| values << v }}) values.should == [] @settings.handlearg("--hooker", "yay") values.should == %w{yay} end it "should provide an option to call passed blocks during definition" do values = [] @settings.setdefaults(:section, :hooker => {:default => "yay", :desc => "boo", :call_on_define => true, :hook => lambda { |v| values << v }}) values.should == %w{yay} end it "should pass the fully interpolated value to the hook when called on definition" do values = [] @settings.setdefaults(:section, :one => ["test", "a"]) @settings.setdefaults(:section, :hooker => {:default => "$one/yay", :desc => "boo", :call_on_define => true, :hook => lambda { |v| values << v }}) values.should == %w{test/yay} end it "should munge values using the setting-specific methods" do @settings[:bool] = "false" @settings[:bool].should == false end it "should prefer cli values to values set in Ruby code" do @settings.handlearg("--myval", "cliarg") @settings[:myval] = "memarg" @settings[:myval].should == "cliarg" end it "should clear the list of environments" do Puppet::Node::Environment.expects(:clear).at_least(1) @settings[:myval] = "memarg" end it "should raise an error if we try to set 'name'" do lambda{ @settings[:name] = "foo" }.should raise_error(ArgumentError) end it "should raise an error if we try to set 'run_mode'" do lambda{ @settings[:run_mode] = "foo" }.should raise_error(ArgumentError) end it "should warn and use [master] if we ask for [puppetmasterd]" do Puppet.expects(:warning) @settings.set_value(:myval, "foo", :puppetmasterd) @settings.stubs(:run_mode).returns(:master) @settings.value(:myval).should == "foo" end it "should warn and use [agent] if we ask for [puppetd]" do Puppet.expects(:warning) @settings.set_value(:myval, "foo", :puppetd) @settings.stubs(:run_mode).returns(:agent) @settings.value(:myval).should == "foo" end end describe "when returning values" do before do @settings = Puppet::Util::Settings.new @settings.setdefaults :section, :config => ["/my/file", "eh"], :one => ["ONE", "a"], :two => ["$one TWO", "b"], :three => ["$one $two THREE", "c"], :four => ["$two $three FOUR", "d"] FileTest.stubs(:exist?).returns true end it "should provide a mechanism for returning set values" do @settings[:one] = "other" @settings[:one].should == "other" end it "should interpolate default values for other parameters into returned parameter values" do @settings[:one].should == "ONE" @settings[:two].should == "ONE TWO" @settings[:three].should == "ONE ONE TWO THREE" end it "should interpolate default values that themselves need to be interpolated" do @settings[:four].should == "ONE TWO ONE ONE TWO THREE FOUR" end it "should provide a method for returning uninterpolated values" do @settings[:two] = "$one tw0" @settings.uninterpolated_value(:two).should == "$one tw0" @settings.uninterpolated_value(:four).should == "$two $three FOUR" end it "should interpolate set values for other parameters into returned parameter values" do @settings[:one] = "on3" @settings[:two] = "$one tw0" @settings[:three] = "$one $two thr33" @settings[:four] = "$one $two $three f0ur" @settings[:one].should == "on3" @settings[:two].should == "on3 tw0" @settings[:three].should == "on3 on3 tw0 thr33" @settings[:four].should == "on3 on3 tw0 on3 on3 tw0 thr33 f0ur" end it "should not cache interpolated values such that stale information is returned" do @settings[:two].should == "ONE TWO" @settings[:one] = "one" @settings[:two].should == "one TWO" end it "should not cache values such that information from one environment is returned for another environment" do text = "[env1]\none = oneval\n[env2]\none = twoval\n" @settings.stubs(:read_file).returns(text) @settings.parse @settings.value(:one, "env1").should == "oneval" @settings.value(:one, "env2").should == "twoval" end it "should have a run_mode that defaults to user" do @settings.run_mode.should == :user end end describe "when choosing which value to return" do before do @settings = Puppet::Util::Settings.new @settings.setdefaults :section, :config => ["/my/file", "a"], - :one => ["ONE", "a"] + :one => ["ONE", "a"], + :two => ["TWO", "b"] FileTest.stubs(:exist?).returns true Puppet.stubs(:run_mode).returns stub('run_mode', :name => :mymode) end it "should return default values if no values have been set" do @settings[:one].should == "ONE" end it "should return values set on the cli before values set in the configuration file" do text = "[main]\none = fileval\n" @settings.stubs(:read_file).returns(text) @settings.handlearg("--one", "clival") @settings.parse @settings[:one].should == "clival" end it "should return values set on the cli before values set in Ruby" do @settings[:one] = "rubyval" @settings.handlearg("--one", "clival") @settings[:one].should == "clival" end it "should return values set in the mode-specific section before values set in the main section" do text = "[main]\none = mainval\n[mymode]\none = modeval\n" @settings.stubs(:read_file).returns(text) @settings.parse @settings[:one].should == "modeval" end it "should not return values outside of its search path" do text = "[other]\none = oval\n" file = "/some/file" @settings.stubs(:read_file).returns(text) @settings.parse @settings[:one].should == "ONE" end it "should return values in a specified environment" do text = "[env]\none = envval\n" @settings.stubs(:read_file).returns(text) @settings.parse @settings.value(:one, "env").should == "envval" end - it "should interpolate found values using the current environment" do + it 'should use the current environment for $environment' do @settings.setdefaults :main, :myval => ["$environment/foo", "mydocs"] @settings.value(:myval, "myenv").should == "myenv/foo" end + it "should interpolate found values using the current environment" do + text = "[main]\none = mainval\n[myname]\none = nameval\ntwo = $one/two\n" + @settings.stubs(:read_file).returns(text) + @settings.parse + + @settings.value(:two, "myname").should == "nameval/two" + end + it "should return values in a specified environment before values in the main or name sections" do text = "[env]\none = envval\n[main]\none = mainval\n[myname]\none = nameval\n" @settings.stubs(:read_file).returns(text) @settings.parse @settings.value(:one, "env").should == "envval" end end describe "when parsing its configuration" do before do @settings = Puppet::Util::Settings.new @settings.stubs(:service_user_available?).returns true @file = "/some/file" @settings.setdefaults :section, :user => ["suser", "doc"], :group => ["sgroup", "doc"] @settings.setdefaults :section, :config => ["/some/file", "eh"], :one => ["ONE", "a"], :two => ["$one TWO", "b"], :three => ["$one $two THREE", "c"] FileTest.stubs(:exist?).returns true end it "should not ignore the report setting" do @settings.setdefaults :section, :report => ["false", "a"] myfile = stub "myfile" @settings[:config] = myfile text = <<-CONF [puppetd] report=true CONF @settings.expects(:read_file).returns(text) @settings.parse @settings[:report].should be_true end it "should use its current ':config' value for the file to parse" do myfile = Puppet.features.posix? ? "/my/file" : "C:/myfile" # do not stub expand_path here, as this leads to a stack overflow, when mocha tries to use it @settings[:config] = myfile File.expects(:read).with(myfile).returns "[main]" @settings.parse end it "should fail if no configuration setting is defined" do @settings = Puppet::Util::Settings.new lambda { @settings.parse }.should raise_error(RuntimeError) end it "should not try to parse non-existent files" do FileTest.expects(:exist?).with("/some/file").returns false File.expects(:read).with("/some/file").never @settings.parse end it "should set a timer that triggers reparsing, even if the file does not exist" do FileTest.expects(:exist?).returns false @settings.expects(:set_filetimeout_timer) @settings.parse end it "should return values set in the configuration file" do text = "[main] one = fileval " @settings.expects(:read_file).returns(text) @settings.parse @settings[:one].should == "fileval" end #484 - this should probably be in the regression area it "should not throw an exception on unknown parameters" do text = "[main]\nnosuchparam = mval\n" @settings.expects(:read_file).returns(text) lambda { @settings.parse }.should_not raise_error end it "should convert booleans in the configuration file into Ruby booleans" do text = "[main] one = true two = false " @settings.expects(:read_file).returns(text) @settings.parse @settings[:one].should == true @settings[:two].should == false end it "should convert integers in the configuration file into Ruby Integers" do text = "[main] one = 65 " @settings.expects(:read_file).returns(text) @settings.parse @settings[:one].should == 65 end it "should support specifying all metadata (owner, group, mode) in the configuration file" do @settings.setdefaults :section, :myfile => ["/myfile", "a"] text = "[main] myfile = /other/file {owner = service, group = service, mode = 644} " @settings.expects(:read_file).returns(text) @settings.parse @settings[:myfile].should == "/other/file" @settings.metadata(:myfile).should == {:owner => "suser", :group => "sgroup", :mode => "644"} end it "should support specifying a single piece of metadata (owner, group, or mode) in the configuration file" do @settings.setdefaults :section, :myfile => ["/myfile", "a"] text = "[main] myfile = /other/file {owner = service} " file = "/some/file" @settings.expects(:read_file).returns(text) @settings.parse @settings[:myfile].should == "/other/file" @settings.metadata(:myfile).should == {:owner => "suser"} end it "should call hooks associated with values set in the configuration file" do values = [] @settings.setdefaults :section, :mysetting => {:default => "defval", :desc => "a", :hook => proc { |v| values << v }} text = "[main] mysetting = setval " @settings.expects(:read_file).returns(text) @settings.parse values.should == ["setval"] end it "should not call the same hook for values set multiple times in the configuration file" do values = [] @settings.setdefaults :section, :mysetting => {:default => "defval", :desc => "a", :hook => proc { |v| values << v }} text = "[user] mysetting = setval [main] mysetting = other " @settings.expects(:read_file).returns(text) @settings.parse values.should == ["setval"] end it "should pass the environment-specific value to the hook when one is available" do values = [] @settings.setdefaults :section, :mysetting => {:default => "defval", :desc => "a", :hook => proc { |v| values << v }} @settings.setdefaults :section, :environment => ["yay", "a"] @settings.setdefaults :section, :environments => ["yay,foo", "a"] text = "[main] mysetting = setval [yay] mysetting = other " @settings.expects(:read_file).returns(text) @settings.parse values.should == ["other"] end it "should pass the interpolated value to the hook when one is available" do values = [] @settings.setdefaults :section, :base => {:default => "yay", :desc => "a", :hook => proc { |v| values << v }} @settings.setdefaults :section, :mysetting => {:default => "defval", :desc => "a", :hook => proc { |v| values << v }} text = "[main] mysetting = $base/setval " @settings.expects(:read_file).returns(text) @settings.parse values.should == ["yay/setval"] end it "should allow empty values" do @settings.setdefaults :section, :myarg => ["myfile", "a"] text = "[main] myarg = " @settings.stubs(:read_file).returns(text) @settings.parse @settings[:myarg].should == "" end describe "and when reading a non-positive filetimeout value from the config file" do before do @settings.setdefaults :foo, :filetimeout => [5, "eh"] somefile = "/some/file" text = "[main] filetimeout = -1 " File.expects(:read).with(somefile).returns(text) File.expects(:expand_path).with(somefile).returns somefile @settings[:config] = somefile end it "should not set a timer" do EventLoop::Timer.expects(:new).never @settings.parse end end end describe "when reparsing its configuration" do before do @settings = Puppet::Util::Settings.new @settings.setdefaults :section, :config => ["/test/file", "a"], :one => ["ONE", "a"], :two => ["$one TWO", "b"], :three => ["$one $two THREE", "c"] FileTest.stubs(:exist?).returns true end it "should use a LoadedFile instance to determine if the file has changed" do file = mock 'file' Puppet::Util::LoadedFile.expects(:new).with("/test/file").returns file file.expects(:changed?) @settings.stubs(:parse) @settings.reparse end it "should not create the LoadedFile instance and should not parse if the file does not exist" do FileTest.expects(:exist?).with("/test/file").returns false Puppet::Util::LoadedFile.expects(:new).never @settings.expects(:parse).never @settings.reparse end it "should not reparse if the file has not changed" do file = mock 'file' Puppet::Util::LoadedFile.expects(:new).with("/test/file").returns file file.expects(:changed?).returns false @settings.expects(:parse).never @settings.reparse end it "should reparse if the file has changed" do file = stub 'file', :file => "/test/file" Puppet::Util::LoadedFile.expects(:new).with("/test/file").returns file file.expects(:changed?).returns true @settings.expects(:parse) @settings.reparse end it "should use a cached LoadedFile instance" do first = mock 'first' second = mock 'second' Puppet::Util::LoadedFile.expects(:new).times(2).with("/test/file").returns(first).then.returns(second) @settings.file.should equal(first) Puppet::Util::Cacher.expire @settings.file.should equal(second) end it "should replace in-memory values with on-file values" do # Init the value text = "[main]\none = disk-init\n" file = mock 'file' file.stubs(:changed?).returns(true) file.stubs(:file).returns("/test/file") @settings[:one] = "init" @settings.file = file # Now replace the value text = "[main]\none = disk-replace\n" # This is kinda ridiculous - the reason it parses twice is that # it goes to parse again when we ask for the value, because the # mock always says it should get reparsed. @settings.stubs(:read_file).returns(text) @settings.reparse @settings[:one].should == "disk-replace" end it "should retain parameters set by cli when configuration files are reparsed" do @settings.handlearg("--one", "clival") text = "[main]\none = on-disk\n" @settings.stubs(:read_file).returns(text) @settings.parse @settings[:one].should == "clival" end it "should remove in-memory values that are no longer set in the file" do # Init the value text = "[main]\none = disk-init\n" @settings.expects(:read_file).returns(text) @settings.parse @settings[:one].should == "disk-init" # Now replace the value text = "[main]\ntwo = disk-replace\n" @settings.expects(:read_file).returns(text) @settings.parse #@settings.reparse # The originally-overridden value should be replaced with the default @settings[:one].should == "ONE" # and we should now have the new value in memory @settings[:two].should == "disk-replace" end it "should retain in-memory values if the file has a syntax error" do # Init the value text = "[main]\none = initial-value\n" @settings.expects(:read_file).returns(text) @settings.parse @settings[:one].should == "initial-value" # Now replace the value with something bogus text = "[main]\nkenny = killed-by-what-follows\n1 is 2, blah blah florp\n" @settings.expects(:read_file).returns(text) @settings.parse # The originally-overridden value should not be replaced with the default @settings[:one].should == "initial-value" # and we should not have the new value in memory @settings[:kenny].should be_nil end end it "should provide a method for creating a catalog of resources from its configuration" do Puppet::Util::Settings.new.should respond_to(:to_catalog) end describe "when creating a catalog" do before do @settings = Puppet::Util::Settings.new @settings.stubs(:service_user_available?).returns true @prefix = Puppet.features.posix? ? "" : "C:" end it "should add all file resources to the catalog if no sections have been specified" do @settings.setdefaults :main, :maindir => [@prefix+"/maindir", "a"], :seconddir => [@prefix+"/seconddir", "a"] @settings.setdefaults :other, :otherdir => [@prefix+"/otherdir", "a"] catalog = @settings.to_catalog [@prefix+"/maindir", @prefix+"/seconddir", @prefix+"/otherdir"].each do |path| catalog.resource(:file, path).should be_instance_of(Puppet::Resource) end end it "should add only files in the specified sections if section names are provided" do @settings.setdefaults :main, :maindir => [@prefix+"/maindir", "a"] @settings.setdefaults :other, :otherdir => [@prefix+"/otherdir", "a"] catalog = @settings.to_catalog(:main) catalog.resource(:file, @prefix+"/otherdir").should be_nil catalog.resource(:file, @prefix+"/maindir").should be_instance_of(Puppet::Resource) end it "should not try to add the same file twice" do @settings.setdefaults :main, :maindir => [@prefix+"/maindir", "a"] @settings.setdefaults :other, :otherdir => [@prefix+"/maindir", "a"] lambda { @settings.to_catalog }.should_not raise_error end it "should ignore files whose :to_resource method returns nil" do @settings.setdefaults :main, :maindir => [@prefix+"/maindir", "a"] @settings.setting(:maindir).expects(:to_resource).returns nil Puppet::Resource::Catalog.any_instance.expects(:add_resource).never @settings.to_catalog end describe "when adding users and groups to the catalog" do before do Puppet.features.stubs(:root?).returns true @settings.setdefaults :foo, :mkusers => [true, "e"], :user => ["suser", "doc"], :group => ["sgroup", "doc"] @settings.setdefaults :other, :otherdir => {:default => "/otherdir", :desc => "a", :owner => "service", :group => "service"} @catalog = @settings.to_catalog end it "should add each specified user and group to the catalog if :mkusers is a valid setting, is enabled, and we're running as root" do @catalog.resource(:user, "suser").should be_instance_of(Puppet::Resource) @catalog.resource(:group, "sgroup").should be_instance_of(Puppet::Resource) end it "should only add users and groups to the catalog from specified sections" do @settings.setdefaults :yay, :yaydir => {:default => "/yaydir", :desc => "a", :owner => "service", :group => "service"} catalog = @settings.to_catalog(:other) catalog.resource(:user, "jane").should be_nil catalog.resource(:group, "billy").should be_nil end it "should not add users or groups to the catalog if :mkusers not running as root" do Puppet.features.stubs(:root?).returns false catalog = @settings.to_catalog catalog.resource(:user, "suser").should be_nil catalog.resource(:group, "sgroup").should be_nil end it "should not add users or groups to the catalog if :mkusers is not a valid setting" do Puppet.features.stubs(:root?).returns true settings = Puppet::Util::Settings.new settings.setdefaults :other, :otherdir => {:default => "/otherdir", :desc => "a", :owner => "service", :group => "service"} catalog = settings.to_catalog catalog.resource(:user, "suser").should be_nil catalog.resource(:group, "sgroup").should be_nil end it "should not add users or groups to the catalog if :mkusers is a valid setting but is disabled" do @settings[:mkusers] = false catalog = @settings.to_catalog catalog.resource(:user, "suser").should be_nil catalog.resource(:group, "sgroup").should be_nil end it "should not try to add users or groups to the catalog twice" do @settings.setdefaults :yay, :yaydir => {:default => "/yaydir", :desc => "a", :owner => "service", :group => "service"} # This would fail if users/groups were added twice lambda { @settings.to_catalog }.should_not raise_error end it "should set :ensure to :present on each created user and group" do @catalog.resource(:user, "suser")[:ensure].should == :present @catalog.resource(:group, "sgroup")[:ensure].should == :present end it "should set each created user's :gid to the service group" do @settings.to_catalog.resource(:user, "suser")[:gid].should == "sgroup" end it "should not attempt to manage the root user" do Puppet.features.stubs(:root?).returns true @settings.setdefaults :foo, :foodir => {:default => "/foodir", :desc => "a", :owner => "root", :group => "service"} @settings.to_catalog.resource(:user, "root").should be_nil end end end it "should be able to be converted to a manifest" do Puppet::Util::Settings.new.should respond_to(:to_manifest) end describe "when being converted to a manifest" do it "should produce a string with the code for each resource joined by two carriage returns" do @settings = Puppet::Util::Settings.new @settings.setdefaults :main, :maindir => ["/maindir", "a"], :seconddir => ["/seconddir", "a"] main = stub 'main_resource', :ref => "File[/maindir]" main.expects(:to_manifest).returns "maindir" second = stub 'second_resource', :ref => "File[/seconddir]" second.expects(:to_manifest).returns "seconddir" @settings.setting(:maindir).expects(:to_resource).returns main @settings.setting(:seconddir).expects(:to_resource).returns second @settings.to_manifest.split("\n\n").sort.should == %w{maindir seconddir} end end describe "when using sections of the configuration to manage the local host" do before do @settings = Puppet::Util::Settings.new @settings.stubs(:service_user_available?).returns true @settings.setdefaults :main, :noop => [false, ""] @settings.setdefaults :main, :maindir => ["/maindir", "a"], :seconddir => ["/seconddir", "a"] @settings.setdefaults :main, :user => ["suser", "doc"], :group => ["sgroup", "doc"] @settings.setdefaults :other, :otherdir => {:default => "/otherdir", :desc => "a", :owner => "service", :group => "service", :mode => 0755} @settings.setdefaults :third, :thirddir => ["/thirddir", "b"] @settings.setdefaults :files, :myfile => {:default => "/myfile", :desc => "a", :mode => 0755} end it "should provide a method that writes files with the correct modes" do @settings.should respond_to(:write) end it "should provide a method that creates directories with the correct modes" do Puppet::Util::SUIDManager.expects(:asuser).with("suser", "sgroup").yields Dir.expects(:mkdir).with("/otherdir", 0755) @settings.mkdir(:otherdir) end it "should create a catalog with the specified sections" do @settings.expects(:to_catalog).with(:main, :other).returns Puppet::Resource::Catalog.new("foo") @settings.use(:main, :other) end it "should canonicalize the sections" do @settings.expects(:to_catalog).with(:main, :other).returns Puppet::Resource::Catalog.new("foo") @settings.use("main", "other") end it "should ignore sections that have already been used" do @settings.expects(:to_catalog).with(:main).returns Puppet::Resource::Catalog.new("foo") @settings.use(:main) @settings.expects(:to_catalog).with(:other).returns Puppet::Resource::Catalog.new("foo") @settings.use(:main, :other) end it "should ignore tags and schedules when creating files and directories" it "should be able to provide all of its parameters in a format compatible with GetOpt::Long" do pending "Not converted from test/unit yet" end it "should convert the created catalog to a RAL catalog" do @catalog = Puppet::Resource::Catalog.new("foo") @settings.expects(:to_catalog).with(:main).returns @catalog @catalog.expects(:to_ral).returns @catalog @settings.use(:main) end it "should specify that it is not managing a host catalog" do catalog = Puppet::Resource::Catalog.new("foo") catalog.expects(:apply) @settings.expects(:to_catalog).returns catalog catalog.stubs(:to_ral).returns catalog catalog.expects(:host_config=).with false @settings.use(:main) end it "should support a method for re-using all currently used sections" do @settings.expects(:to_catalog).with(:main, :third).times(2).returns Puppet::Resource::Catalog.new("foo") @settings.use(:main, :third) @settings.reuse end it "should fail with an appropriate message if any resources fail" do @catalog = Puppet::Resource::Catalog.new("foo") @catalog.stubs(:to_ral).returns @catalog @settings.expects(:to_catalog).returns @catalog @trans = mock("transaction") @catalog.expects(:apply).yields(@trans) @trans.expects(:any_failed?).returns(true) report = mock 'report' @trans.expects(:report).returns report log = mock 'log', :to_s => "My failure", :level => :err report.expects(:logs).returns [log] @settings.expects(:raise).with { |msg| msg.include?("My failure") } @settings.use(:whatever) end end describe "when dealing with printing configs" do before do @settings = Puppet::Util::Settings.new #these are the magic default values @settings.stubs(:value).with(:configprint).returns("") @settings.stubs(:value).with(:genconfig).returns(false) @settings.stubs(:value).with(:genmanifest).returns(false) @settings.stubs(:value).with(:environment).returns(nil) end describe "when checking print_config?" do it "should return false when the :configprint, :genconfig and :genmanifest are not set" do @settings.print_configs?.should be_false end it "should return true when :configprint has a value" do @settings.stubs(:value).with(:configprint).returns("something") @settings.print_configs?.should be_true end it "should return true when :genconfig has a value" do @settings.stubs(:value).with(:genconfig).returns(true) @settings.print_configs?.should be_true end it "should return true when :genmanifest has a value" do @settings.stubs(:value).with(:genmanifest).returns(true) @settings.print_configs?.should be_true end end describe "when printing configs" do describe "when :configprint has a value" do it "should call print_config_options" do @settings.stubs(:value).with(:configprint).returns("something") @settings.expects(:print_config_options) @settings.print_configs end it "should get the value of the option using the environment" do @settings.stubs(:value).with(:configprint).returns("something") @settings.stubs(:include?).with("something").returns(true) @settings.expects(:value).with(:environment).returns("env") @settings.expects(:value).with("something", "env").returns("foo") @settings.stubs(:puts).with("foo") @settings.print_configs end it "should print the value of the option" do @settings.stubs(:value).with(:configprint).returns("something") @settings.stubs(:include?).with("something").returns(true) @settings.stubs(:value).with("something", nil).returns("foo") @settings.expects(:puts).with("foo") @settings.print_configs end it "should print the value pairs if there are multiple options" do @settings.stubs(:value).with(:configprint).returns("bar,baz") @settings.stubs(:include?).with("bar").returns(true) @settings.stubs(:include?).with("baz").returns(true) @settings.stubs(:value).with("bar", nil).returns("foo") @settings.stubs(:value).with("baz", nil).returns("fud") @settings.expects(:puts).with("bar = foo") @settings.expects(:puts).with("baz = fud") @settings.print_configs end it "should print a whole bunch of stuff if :configprint = all" it "should return true after printing" do @settings.stubs(:value).with(:configprint).returns("something") @settings.stubs(:include?).with("something").returns(true) @settings.stubs(:value).with("something", nil).returns("foo") @settings.stubs(:puts).with("foo") @settings.print_configs.should be_true end it "should return false if a config param is not found" do @settings.stubs :puts @settings.stubs(:value).with(:configprint).returns("something") @settings.stubs(:include?).with("something").returns(false) @settings.print_configs.should be_false end end describe "when genconfig is true" do before do @settings.stubs :puts end it "should call to_config" do @settings.stubs(:value).with(:genconfig).returns(true) @settings.expects(:to_config) @settings.print_configs end it "should return true from print_configs" do @settings.stubs(:value).with(:genconfig).returns(true) @settings.stubs(:to_config) @settings.print_configs.should be_true end end describe "when genmanifest is true" do before do @settings.stubs :puts end it "should call to_config" do @settings.stubs(:value).with(:genmanifest).returns(true) @settings.expects(:to_manifest) @settings.print_configs end it "should return true from print_configs" do @settings.stubs(:value).with(:genmanifest).returns(true) @settings.stubs(:to_manifest) @settings.print_configs.should be_true end end end end describe "when setting a timer to trigger configuration file reparsing" do before do @settings = Puppet::Util::Settings.new @settings.setdefaults :foo, :filetimeout => [5, "eh"] end it "should do nothing if no filetimeout setting is available" do @settings.expects(:value).with(:filetimeout).returns nil EventLoop::Timer.expects(:new).never @settings.set_filetimeout_timer end it "should always convert the timer interval to an integer" do @settings.expects(:value).with(:filetimeout).returns "10" EventLoop::Timer.expects(:new).with(:interval => 10, :start? => true, :tolerance => 1) @settings.set_filetimeout_timer end it "should do nothing if the filetimeout setting is not greater than 0" do @settings.expects(:value).with(:filetimeout).returns -2 EventLoop::Timer.expects(:new).never @settings.set_filetimeout_timer end it "should create a timer with its interval set to the filetimeout, start? set to true, and a tolerance of 1" do @settings.expects(:value).with(:filetimeout).returns 5 EventLoop::Timer.expects(:new).with(:interval => 5, :start? => true, :tolerance => 1) @settings.set_filetimeout_timer end it "should reparse when the timer goes off" do EventLoop::Timer.expects(:new).with(:interval => 5, :start? => true, :tolerance => 1).yields @settings.expects(:reparse) @settings.set_filetimeout_timer end end describe "when determining if the service user is available" do it "should return false if there is no user setting" do Puppet::Util::Settings.new.should_not be_service_user_available end it "should return false if the user provider says the user is missing" do settings = Puppet::Util::Settings.new settings.setdefaults :main, :user => ["foo", "doc"] user = mock 'user' user.expects(:exists?).returns false Puppet::Type.type(:user).expects(:new).with { |args| args[:name] == "foo" }.returns user settings.should_not be_service_user_available end it "should return true if the user provider says the user is present" do settings = Puppet::Util::Settings.new settings.setdefaults :main, :user => ["foo", "doc"] user = mock 'user' user.expects(:exists?).returns true Puppet::Type.type(:user).expects(:new).with { |args| args[:name] == "foo" }.returns user settings.should be_service_user_available end it "should cache the result" end end diff --git a/tasks/rake/git_workflow.rake b/tasks/rake/git_workflow.rake index 4c39f98de..1ba57c1aa 100644 --- a/tasks/rake/git_workflow.rake +++ b/tasks/rake/git_workflow.rake @@ -1,132 +1,132 @@ # This set of tasks helps automate the workflow as described on -# http://reductivelabs.com/trac/puppet/wiki/Development/DevelopmentLifecycle +# http://projects.puppetlabs.com/projects/puppet/wiki/Development_Lifecycle def find_start(start) # This is a case statement, as we might want to map certain # git tags to starting points that are not currently in git. case start when nil?: when @next_release: return "master" else return start end end desc "Set up git for working with Puppet" task :git_setup do # This should be changed as new versions get released @next_release = '0.26.x' @remote = {} default_remote = {} default_remote[:url] = 'git://github.com/reductivelabs/puppet' default_remote[:name] = 'origin' @remote[:name] = %x{git config puppet.defaultremote}.chomp @remote[:name] = @remote[:name].empty? ? default_remote[:name] : @remote[:name] @remote[:url] = default_remote[:url] if @remote[:name] == default_remote[:name] default_fetch = '+refs/heads/*:refs/remotes/puppet/*' @remote[:fetch] = %x{git config puppet.#{@remote[:name]}.fetch}.chomp @remote[:fetch] = @remote[:fetch].empty? ? default_fetch : @remote[:fetch] end desc "Start work on a feature" task :start_feature, [:feature,:remote,:branch] => :git_setup do |t, args| args.with_defaults(:remote => @remote[:name]) args.with_defaults(:branch => @next_release) start_at = find_start(args.branch) branch = "feature/#{start_at}/#{args.feature}" sh "git checkout -b #{branch} #{start_at}" do |ok, res| if ! ok raise < :git_setup do |t, args| args.with_defaults(:remote => @remote[:name]) args.with_defaults(:branch => @next_release) start_at = find_start(args.branch) branch = "tickets/#{start_at}/#{args.ticket}" sh "git checkout -b #{branch} #{start_at}" do |ok, res| unless ok raise < 0 raise "Patches already exist matching '00*.patch'; clean up first" end unless %x{git status} =~ /On branch (.+)/ raise "Could not get branch from 'git status'" end branch = $1 unless branch =~ %r{^([^\/]+)/([^\/]+)/([^\/]+)$} raise "Branch name does not follow // model; cannot autodetect parent branch" end type, parent, name = $1, $2, $3 # Create all of the patches sh "git format-patch -C -M -s -n --subject-prefix='PATCH/puppet' #{parent}..HEAD" # Add info to the patches additional_info = "Local-branch: #{branch}\n" files = Dir.glob("00*.patch") files.each do |file| contents = File.read(file) contents.sub!(/^---\n/, "---\n#{additional_info}") File.open(file, 'w') do |file_handle| file_handle.print contents end end # And then mail them out. # If we've got more than one patch, add --compose if files.length > 1 compose = "--compose" else compose = "" end # Now send the mail. sh "git send-email #{compose} --no-signed-off-by-cc --suppress-from --to puppet-dev@googlegroups.com 00*.patch" # Finally, clean up the patches sh "rm 00*.patch" end diff --git a/tasks/rake/manpages.rake b/tasks/rake/manpages.rake new file mode 100644 index 000000000..f7275e4c3 --- /dev/null +++ b/tasks/rake/manpages.rake @@ -0,0 +1,37 @@ +# require 'fileutils' + +desc "Build Puppet manpages" +task :gen_manpages do + + sbins = Dir.glob(%w{sbin/*}) + bins = Dir.glob(%w{bin/*}) + applications = Dir.glob(%w{lib/puppet/application/*}) + # Locate ronn + ronn = %x{which ronn}.chomp + unless File.executable?(ronn) then fail("Ronn does not appear to be installed.") end + + # Create puppet.conf.5 man page + %x{RUBYLIB=./lib:$RUBYLIB bin/puppetdoc --reference configuration > ./man/man5/puppetconf.5.ronn} + %x{#{ronn} --manual="Puppet manual" --organization="Puppet Labs, LLC" -r ./man/man5/puppetconf.5.ronn} + File.move("./man/man5/puppetconf.5", "./man/man5/puppet.conf.5") + File.unlink("./man/man5/puppetconf.5.ronn") + + # Create LEGACY binary man pages (i.e. delete me for 2.8.0) + binary = bins + sbins + binary.each do |bin| + b = bin.gsub( /^s?bin\//, "") + %x{RUBYLIB=./lib:$RUBYLIB #{bin} --help > ./man/man8/#{b}.8.ronn} + %x{#{ronn} --manual="Puppet manual" --organization="Puppet Labs, LLC" -r ./man/man8/#{b}.8.ronn} + File.unlink("./man/man8/#{b}.8.ronn") + end + + # Create modern binary man pages + applications.each do |app| + app.gsub!( /^lib\/puppet\/application\/(.*?)\.rb/, '\1') + %x{RUBYLIB=./lib:$RUBYLIB bin/puppet #{app} --help > ./man/man8/puppet-#{app}.8.ronn} + %x{#{ronn} --manual="Puppet manual" --organization="Puppet Labs, LLC" -r ./man/man8/puppet-#{app}.8.ronn} + File.unlink("./man/man8/puppet-#{app}.8.ronn") + end + + +end \ No newline at end of file diff --git a/test/Rakefile b/test/Rakefile index 47be213d9..7cde050f6 100644 --- a/test/Rakefile +++ b/test/Rakefile @@ -1,98 +1,96 @@ # let Emacs know it's -*- ruby -*- begin require 'rake/testtask' rescue LoadError $stderr.puts "You must have 'rake' installed to use this file" exit(1) end require 'find' include Find include FileTest $exclusions = %W(lib data) $test_library_paths = %W(lib ../lib) $: << File.join(Dir.getwd, "lib") require 'rake/puppet_testtask' filemap = Hash.new { |hash, key| hash[key] = [] } allfiles = [] # First collect the entire file list. find(".") do |f| # Get rid of the leading ./ f = f.sub(/^\.\//, '') file = File.basename(f) dir = File.dirname(f) # Prune . directories and excluded dirs if (file =~ /^\./ and f != ".") or $exclusions.include?(File.basename(file)) prune next end next if f == "." next if dir == "." # If we're a ruby script, then add it to the list of files for that dir if file =~ /\.rb$/ allfiles << f # Add it to all of the parent dirs, not just our own parts = File.split(dir) if parts[0] == "." parts.shift end parts.each_with_index { |part, i| path = File.join(parts[0..i]) filemap[path] << f } end end desc "Run the full test suite" Rake::PuppetTestTask.new :test do |t| t.libs += $test_library_paths # Add every file as a test file to run t.test_files = allfiles t.verbose = true end task :default => :test # Now create a task for every directory filemap.each do |dir, files| ns = dir.gsub "/", ":" # First create a separate task for each file in the namespace. namespace ns do files.each do |file| Rake::PuppetTestTask.new File.basename(file, '.rb').to_sym do |t| t.libs += $test_library_paths + ['..'] t.libs << '..' t.test_files = [ file ] t.verbose = true end end end # Then create a task that matches the directory itself. Rake::PuppetTestTask.new dir do |t| t.libs += $test_library_paths if ENV["TESTFILES"] t.test_files = ENV["TESTFILES"].split(/\s+/) else t.test_files = files.sort end t.verbose = true end # And alias it with a slash on the end task(dir + "/" => dir) end - -# $Id$ diff --git a/test/data/providers/mount/parsed/aix.mount b/test/data/providers/mount/parsed/aix.mount new file mode 100644 index 000000000..380dbc5ae --- /dev/null +++ b/test/data/providers/mount/parsed/aix.mount @@ -0,0 +1,7 @@ +node mounted mounted over vfs date options +---- ------- ------------ --- ------------ ------------------- + /dev/hd0 / jfs Dec 17 08:04 rw, log =/dev/hd8 + /dev/hd3 /tmp jfs Dec 17 08:04 rw, log =/dev/hd8 + /dev/hd1 /home jfs Dec 17 08:06 rw, log =/dev/hd8 + /dev/hd2 /usr jfs Dec 17 08:06 rw, log =/dev/hd8 +sue /home/local/src /usr/code nfs Dec 17 08:06 ro, log =/dev/hd8 diff --git a/test/data/providers/mount/parsed/darwin.mount b/test/data/providers/mount/parsed/darwin.mount new file mode 100644 index 000000000..1bdfcf89a --- /dev/null +++ b/test/data/providers/mount/parsed/darwin.mount @@ -0,0 +1,6 @@ +/dev/disk0s2 on / (hfs, local, journaled) +devfs on /dev (devfs, local, nobrowse) +map -hosts on /net (autofs, nosuid, automounted, nobrowse) +map auto_home on /home (autofs, automounted, nobrowse) +/dev/disk0s3 on /usr (hfs, local, journaled) +/dev/fake on /ghost (hfs, local, journaled) diff --git a/test/data/providers/mount/parsed/hpux.mount b/test/data/providers/mount/parsed/hpux.mount new file mode 100644 index 000000000..d414fa47a --- /dev/null +++ b/test/data/providers/mount/parsed/hpux.mount @@ -0,0 +1,17 @@ +/ on rpool/ROOT/opensolaris read/write/setuid/devices/dev=2d90002 on Wed Dec 31 16:00:00 1969 +/devices on /devices read/write/setuid/devices/dev=4a00000 on Thu Feb 17 14:34:02 2011 +/dev on /dev read/write/setuid/devices/dev=4a40000 on Thu Feb 17 14:34:02 2011 +/system/contract on ctfs read/write/setuid/devices/dev=4ac0001 on Thu Feb 17 14:34:02 2011 +/proc on proc read/write/setuid/devices/dev=4b00000 on Thu Feb 17 14:34:02 2011 +/etc/mnttab on mnttab read/write/setuid/devices/dev=4b40001 on Thu Feb 17 14:34:02 2011 +/etc/svc/volatile on swap read/write/setuid/devices/xattr/dev=4b80001 on Thu Feb 17 14:34:02 2011 +/system/object on objfs read/write/setuid/devices/dev=4bc0001 on Thu Feb 17 14:34:02 2011 +/etc/dfs/sharetab on sharefs read/write/setuid/devices/dev=4c00001 on Thu Feb 17 14:34:02 2011 +/lib/libc.so.1 on /usr/lib/libc/libc_hwcap1.so.1 read/write/setuid/devices/dev=2d90002 on Thu Feb 17 14:34:14 2011 +/dev/fd on fd read/write/setuid/devices/dev=4d00001 on Thu Feb 17 14:34:18 2011 +/tmp on swap read/write/setuid/devices/xattr/dev=4b80002 on Thu Feb 17 14:34:19 2011 +/var/run on swap read/write/setuid/devices/xattr/dev=4b80003 on Thu Feb 17 14:34:19 2011 +/export on rpool/export read/write/setuid/devices/nonbmand/exec/xattr/atime/dev=2d90006 on Thu Feb 17 14:37:48 2011 +/export/home on rpool/export/home read/write/setuid/devices/nonbmand/exec/xattr/atime/dev=2d90007 on Thu Feb 17 14:37:48 2011 +/rpool on rpool read/write/setuid/devices/nonbmand/exec/xattr/atime/dev=2d90009 on Thu Feb 17 14:37:48 2011 +/ghost on /dev/fake read/write/setuid/devices/nonbmand/exec/xattr/atime/dev=2d90009 on Thu Feb 17 14:37:48 2011 diff --git a/test/data/providers/mount/parsed/linux.mount b/test/data/providers/mount/parsed/linux.mount new file mode 100644 index 000000000..75dd71fd4 --- /dev/null +++ b/test/data/providers/mount/parsed/linux.mount @@ -0,0 +1,5 @@ +/dev/root on / type jfs (rw,noatime) +rc-svcdir on /lib64/rc/init.d type tmpfs (rw,nosuid,nodev,noexec,relatime,size=1024k,mode=755) +sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime) +/dev/sda9 on /usr/portage type jfs (rw) +/dev/fake on /ghost type jfs (rw) diff --git a/test/data/providers/mount/parsed/solaris.mount b/test/data/providers/mount/parsed/solaris.mount new file mode 100644 index 000000000..26fabc575 --- /dev/null +++ b/test/data/providers/mount/parsed/solaris.mount @@ -0,0 +1,6 @@ +/ on /dev/dsk/c0t0d0s0 read/write/setuid/intr/largefiles/xattr/onerror=panic/dev=2200000 on Mon Mar 18 08:48:45 2002 +/proc on /proc read/write/setuid/dev=4300000 on Mon Mar 18 08:48:44 2002 +/etc/mnttab on mnttab read/write/setuid/dev=43c0000 on Mon Mar 18 08:48:44 2002 +/tmp on swap read/write/setuid/xattr/dev=2 on Mon Mar 18 08:48:52 2002 +/export/home on /dev/dsk/c0t0d0s7 read/write/setuid/intr/largefiles/xattr/onerror=panic/dev=2200007 on Mon Mar 18 +/ghost on /dev/dsk/c0t1d0s7 read/write/setuid/intr/largefiles/xattr/onerror=panic/dev=2200007 on Mon Mar 18 diff --git a/test/data/types/mount/linux.fstab b/test/data/types/mount/linux.fstab index b1debff9c..c94ec7fa8 100644 --- a/test/data/types/mount/linux.fstab +++ b/test/data/types/mount/linux.fstab @@ -1,11 +1,12 @@ # A sample fstab, typical for a Fedora system /dev/vg00/lv00 / ext3 defaults 1 1 LABEL=/boot /boot ext3 defaults 1 2 devpts /dev/pts devpts gid=5,mode=620 0 tmpfs /dev/shm tmpfs defaults 0 LABEL=/home /home ext3 defaults 1 2 /home /homes auto bind 0 2 proc /proc proc defaults 0 0 /dev/vg00/lv01 /spare ext3 defaults 1 2 sysfs /sys sysfs defaults 0 0 LABEL=SWAP-hda6 swap swap defaults 0 0 +/dev/sda1 /usr xfs noatime 0 0 diff --git a/test/data/types/mount/solaris.fstab b/test/data/types/mount/solaris.fstab index 54afc898c..348b9d50b 100644 --- a/test/data/types/mount/solaris.fstab +++ b/test/data/types/mount/solaris.fstab @@ -1,11 +1,12 @@ #device device mount FS fsck mount mount #to mount to fsck point type pass at boot options # fd - /dev/fd fd - no - /proc - /proc proc - no - /dev/dsk/c0d0s0 /dev/rdsk/c0d0s0 / ufs 1 no - /dev/dsk/c0d0p0:boot - /boot pcfs - no - /devices - /devices devfs - no - ctfs - /system/contract ctfs - no - objfs - /system/object objfs - no - #swap - /tmp tmpfs - yes - +/dev/dsk/c0d0s2 /dev/rdsk/c0d0s2 /usr ufs 1 no - diff --git a/test/ral/type/exec.rb b/test/ral/type/exec.rb index 933994b88..829b1a068 100755 --- a/test/ral/type/exec.rb +++ b/test/ral/type/exec.rb @@ -1,847 +1,804 @@ #!/usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../../lib/puppettest') require 'puppettest' class TestExec < Test::Unit::TestCase include PuppetTest def test_numvsstring [0, "0"].each { |val| command = nil output = nil assert_nothing_raised { command = Puppet::Type.type(:exec).new( :command => "/bin/echo", :returns => val ) } assert_events([:executed_command], command) } end def test_path_or_qualified command = nil output = nil assert_raise(Puppet::Error) { command = Puppet::Type.type(:exec).new( :command => "echo" ) } assert_nothing_raised { command = Puppet::Type.type(:exec).new( :command => "echo", :path => "/usr/bin:/bin:/usr/sbin:/sbin" ) } assert_nothing_raised { command = Puppet::Type.type(:exec).new( :command => "/bin/echo" ) } assert_nothing_raised { command = Puppet::Type.type(:exec).new( :command => "/bin/echo", :path => "/usr/bin:/bin:/usr/sbin:/sbin" ) } end def test_nonzero_returns assert_nothing_raised { command = Puppet::Type.type(:exec).new( :command => "mkdir /this/directory/does/not/exist", :path => "/usr/bin:/bin:/usr/sbin:/sbin", :returns => 1 ) } assert_nothing_raised { command = Puppet::Type.type(:exec).new( :command => "touch /etc", :path => "/usr/bin:/bin:/usr/sbin:/sbin", :returns => 1 ) } assert_nothing_raised { command = Puppet::Type.type(:exec).new( :command => "thiscommanddoesnotexist", :path => "/usr/bin:/bin:/usr/sbin:/sbin", :returns => 127 ) } end def test_cwdsettings command = nil dir = "/tmp" wd = Dir.chdir(dir) { Dir.getwd } assert_nothing_raised { command = Puppet::Type.type(:exec).new( :command => "pwd", :cwd => dir, :path => "/usr/bin:/bin:/usr/sbin:/sbin", :returns => 0 ) } assert_events([:executed_command], command) assert_equal(wd,command.output.chomp) end def test_refreshonly_functional file = nil cmd = nil tmpfile = tempfile @@tmpfiles.push tmpfile trans = nil file = Puppet::Type.type(:file).new( :path => tmpfile, :content => "yay" ) # Get the file in sync assert_apply(file) # Now make an exec maker = tempfile assert_nothing_raised { cmd = Puppet::Type.type(:exec).new( :command => "touch #{maker}", :path => "/usr/bin:/bin:/usr/sbin:/sbin", :subscribe => file, :refreshonly => true ) } assert(cmd, "did not make exec") assert_nothing_raised do assert(! cmd.check, "Check passed when refreshonly is set") end assert_events([], file, cmd) assert(! FileTest.exists?(maker), "made file without refreshing") # Now change our content, so we throw a refresh file[:content] = "yayness" assert_events([:content_changed, :restarted], file, cmd) assert(FileTest.exists?(maker), "file was not made in refresh") end def test_refreshonly cmd = true assert_nothing_raised { cmd = Puppet::Type.type(:exec).new( :command => "pwd", :path => "/usr/bin:/bin:/usr/sbin:/sbin", :refreshonly => true ) } # Checks should always fail when refreshonly is enabled assert(!cmd.check, "Check passed with refreshonly true") # Now make sure it passes if we pass in "true" assert(cmd.check(true), "Check failed with refreshonly true while refreshing") # Now set it to false cmd[:refreshonly] = false assert(cmd.check, "Check failed with refreshonly false") end def test_creates file = tempfile exec = nil assert(! FileTest.exists?(file), "File already exists") assert_nothing_raised { exec = Puppet::Type.type(:exec).new( :command => "touch #{file}", :path => "/usr/bin:/bin:/usr/sbin:/sbin", :creates => file ) } comp = mk_catalog("createstest", exec) assert_events([:executed_command], comp, "creates") assert_events([], comp, "creates") end # Verify that we can download the file that we're going to execute. def test_retrievethenmkexe exe = tempfile oexe = tempfile sh = %x{which sh} File.open(exe, "w") { |f| f.puts "#!#{sh}\necho yup" } file = Puppet::Type.type(:file).new( :path => oexe, :source => exe, :mode => 0755 ) exec = Puppet::Type.type(:exec).new( :command => oexe, :require => Puppet::Resource.new(:file, oexe) ) comp = mk_catalog("Testing", file, exec) assert_events([:file_created, :executed_command], comp) end # Verify that we auto-require any managed scripts. def test_autorequire_files exe = tempfile oexe = tempfile sh = %x{which sh} File.open(exe, "w") { |f| f.puts "#!#{sh}\necho yup" } file = Puppet::Type.type(:file).new( :path => oexe, :source => exe, :mode => 755 ) basedir = File.dirname(oexe) baseobj = Puppet::Type.type(:file).new( :path => basedir, :source => exe, :mode => 755 ) ofile = Puppet::Type.type(:file).new( :path => exe, :mode => 755 ) exec = Puppet::Type.type(:exec).new( :command => oexe, :path => ENV["PATH"], :cwd => basedir ) cat = Puppet::Type.type(:exec).new( :command => "cat #{exe} #{oexe}", :path => ENV["PATH"] ) catalog = mk_catalog(file, baseobj, ofile, exec, cat) rels = nil assert_nothing_raised do rels = exec.autorequire end # Verify we get the script itself assert(rels.detect { |r| r.source == file }, "Exec did not autorequire its command") # Verify we catch the cwd assert(rels.detect { |r| r.source == baseobj }, "Exec did not autorequire its cwd") # Verify we don't require ourselves assert(! rels.detect { |r| r.source == ofile }, "Exec incorrectly required mentioned file") # We not longer autorequire inline files assert_nothing_raised do rels = cat.autorequire end assert(! rels.detect { |r| r.source == ofile }, "Exec required second inline file") assert(! rels.detect { |r| r.source == file }, "Exec required inline file") end def test_ifonly afile = tempfile bfile = tempfile exec = nil assert_nothing_raised { exec = Puppet::Type.type(:exec).new( :command => "touch #{bfile}", :onlyif => "test -f #{afile}", :path => ENV['PATH'] ) } assert_events([], exec) system("touch #{afile}") assert_events([:executed_command], exec) assert_events([:executed_command], exec) system("rm #{afile}") assert_events([], exec) end def test_unless afile = tempfile bfile = tempfile exec = nil assert_nothing_raised { exec = Puppet::Type.type(:exec).new( :command => "touch #{bfile}", :unless => "test -f #{afile}", :path => ENV['PATH'] ) } comp = mk_catalog(exec) assert_events([:executed_command], comp) assert_events([:executed_command], comp) system("touch #{afile}") assert_events([], comp) assert_events([], comp) system("rm #{afile}") assert_events([:executed_command], comp) assert_events([:executed_command], comp) end if Puppet.features.root? # Verify that we can execute commands as a special user def mknverify(file, user, group = nil, id = true) File.umask(0022) args = { :command => "touch #{file}", :path => "/usr/bin:/bin:/usr/sbin:/sbin", } if user #Puppet.warning "Using user #{user.name}" if id # convert to a string, because that's what the object expects args[:user] = user.uid.to_s else args[:user] = user.name end end if group #Puppet.warning "Using group #{group.name}" if id args[:group] = group.gid.to_s else args[:group] = group.name end end exec = nil assert_nothing_raised { exec = Puppet::Type.type(:exec).new(args) } comp = mk_catalog("usertest", exec) assert_events([:executed_command], comp, "usertest") assert(FileTest.exists?(file), "File does not exist") assert_equal(user.uid, File.stat(file).uid, "File UIDs do not match") if user # We can't actually test group ownership, unfortunately, because # behaviour changes wildlly based on platform. Puppet::Type.allclear end def test_userngroup file = tempfile [ [nonrootuser], # just user, by name [nonrootuser, nil, true], # user, by uid [nil, nonrootgroup], # just group [nil, nonrootgroup, true], # just group, by id [nonrootuser, nonrootgroup], # user and group, by name [nonrootuser, nonrootgroup, true], # user and group, by id ].each { |ary| mknverify(file, *ary) { } } end end def test_logoutput exec = nil assert_nothing_raised { exec = Puppet::Type.type(:exec).new( :title => "logoutputesting", :path => "/usr/bin:/bin", :command => "echo logoutput is false", :logoutput => false ) } assert_apply(exec) assert_nothing_raised { exec[:command] = "echo logoutput is true" exec[:logoutput] = true } assert_apply(exec) assert_nothing_raised { exec[:command] = "echo logoutput is on_failure" exec[:logoutput] = "on_failure" } assert_apply(exec) end def test_execthenfile exec = nil file = nil basedir = tempfile path = File.join(basedir, "subfile") assert_nothing_raised { exec = Puppet::Type.type(:exec).new( :title => "mkdir", :path => "/usr/bin:/bin", :creates => basedir, :command => "mkdir #{basedir}; touch #{path}" ) } assert_nothing_raised { file = Puppet::Type.type(:file).new( :path => basedir, :recurse => true, :mode => "755", :require => Puppet::Resource.new("exec", "mkdir") ) } comp = mk_catalog(file, exec) comp.finalize assert_events([:executed_command, :mode_changed], comp) assert(FileTest.exists?(path), "Exec ran first") assert(File.stat(path).mode & 007777 == 0755) end # Make sure all checks need to be fully qualified. def test_falsevals exec = nil assert_nothing_raised do exec = Puppet::Type.type(:exec).new( :command => "/bin/touch yayness" ) end Puppet::Type.type(:exec).checks.each do |check| klass = Puppet::Type.type(:exec).paramclass(check) next if klass.value_collection.values.include? :false assert_raise(Puppet::Error, "Check '#{check}' did not fail on false") do exec[check] = false end end end def test_createcwdandexe exec1 = exec2 = nil dir = tempfile file = tempfile assert_nothing_raised { exec1 = Puppet::Type.type(:exec).new( :title => "one", :path => ENV["PATH"], :command => "mkdir #{dir}" ) } assert_nothing_raised("Could not create exec w/out existing cwd") { exec2 = Puppet::Type.type(:exec).new( :title => "two", :path => ENV["PATH"], :command => "touch #{file}", :cwd => dir ) } # Throw a check in there with our cwd and make sure it works assert_nothing_raised("Could not check with a missing cwd") do exec2[:unless] = "test -f /this/file/does/not/exist" exec2.retrieve end assert_raise(Puppet::Error) do exec2.property(:returns).sync end assert_nothing_raised do exec2[:require] = exec1 end assert_apply(exec1, exec2) assert(FileTest.exists?(file)) end def test_checkarrays exec = nil file = tempfile test = "test -f #{file}" assert_nothing_raised { exec = Puppet::Type.type(:exec).new( :path => ENV["PATH"], :command => "touch #{file}" ) } assert_nothing_raised { exec[:unless] = test } assert_nothing_raised { assert(exec.check, "Check did not pass") } assert_nothing_raised { exec[:unless] = [test, test] } assert_nothing_raised { exec.finish } assert_nothing_raised { assert(exec.check, "Check did not pass") } assert_apply(exec) assert_nothing_raised { assert(! exec.check, "Check passed") } end def test_missing_checks_cause_failures # Solaris's sh exits with 1 here instead of 127 return if Facter.value(:operatingsystem) == "Solaris" exec = Puppet::Type.type(:exec).new( :command => "echo true", :path => ENV["PATH"], :onlyif => "/bin/nosuchthingexists" ) assert_raise(ArgumentError, "Missing command did not raise error") { exec.run("/bin/nosuchthingexists") } end - def test_envparam - - exec = Puppet::Type.newexec( - - :command => "echo $envtest", - :path => ENV["PATH"], - - :env => "envtest=yayness" - ) - - assert(exec, "Could not make exec") - - output = status = nil - assert_nothing_raised { - output, status = exec.run("echo $envtest") - } - - assert_equal("yayness\n", output) - - # Now check whether we can do multiline settings - assert_nothing_raised do - exec[:env] = "envtest=a list of things -and stuff" - end - - output = status = nil - assert_nothing_raised { - output, status = exec.run('echo "$envtest"') - } - assert_equal("a list of things\nand stuff\n", output) - - # Now test arrays - assert_nothing_raised do - exec[:env] = ["funtest=A", "yaytest=B"] - end - - output = status = nil - assert_nothing_raised { - output, status = exec.run('echo "$funtest" "$yaytest"') - } - assert_equal("A B\n", output) - end - def test_environmentparam exec = Puppet::Type.newexec( :command => "echo $environmenttest", :path => ENV["PATH"], :environment => "environmenttest=yayness" ) assert(exec, "Could not make exec") output = status = nil assert_nothing_raised { output, status = exec.run("echo $environmenttest") } assert_equal("yayness\n", output) # Now check whether we can do multiline settings assert_nothing_raised do exec[:environment] = "environmenttest=a list of things and stuff" end output = status = nil assert_nothing_raised { output, status = exec.run('echo "$environmenttest"') } assert_equal("a list of things\nand stuff\n", output) # Now test arrays assert_nothing_raised do exec[:environment] = ["funtest=A", "yaytest=B"] end output = status = nil assert_nothing_raised { output, status = exec.run('echo "$funtest" "$yaytest"') } assert_equal("A B\n", output) end def test_timeout exec = Puppet::Type.type(:exec).new(:command => "sleep 1", :path => ENV["PATH"], :timeout => "0.2") time = Time.now assert_raise(Timeout::Error) { exec.run("sleep 1") } Puppet.info "#{Time.now.to_f - time.to_f} seconds, vs a timeout of #{exec[:timeout]}" assert_apply(exec) end # Testing #470 def test_run_as_created_user exec = nil if Process.uid == 0 user = "nosuchuser" assert_nothing_raised("Could not create exec with non-existent user") do exec = Puppet::Type.type(:exec).new( :command => "/bin/echo yay", :user => user ) end end # Now try the group group = "nosuchgroup" assert_nothing_raised("Could not create exec with non-existent user") do exec = Puppet::Type.type(:exec).new( :command => "/bin/echo yay", :group => group ) end end # make sure paths work both as arrays and strings def test_paths_as_arrays path = %w{/usr/bin /usr/sbin /sbin} exec = nil assert_nothing_raised("Could not use an array for the path") do exec = Puppet::Type.type(:exec).new(:command => "echo yay", :path => path) end assert_equal(path, exec[:path], "array-based path did not match") assert_nothing_raised("Could not use a string for the path") do exec = Puppet::Type.type(:exec).new(:command => "echo yay", :path => path.join(":")) end assert_equal(path, exec[:path], "string-based path did not match") assert_nothing_raised("Could not use a colon-separated strings in an array for the path") do exec = Puppet::Type.type(:exec).new(:command => "echo yay", :path => ["/usr/bin", "/usr/sbin:/sbin"]) end assert_equal(path, exec[:path], "colon-separated array path did not match") end def test_checks_apply_to_refresh file = tempfile maker = tempfile exec = Puppet::Type.type(:exec).new( :title => "maker", :command => "touch #{maker}", :path => ENV["PATH"] ) # Make sure it runs normally assert_apply(exec) assert(FileTest.exists?(maker), "exec did not run") File.unlink(maker) # Now make sure it refreshes assert_nothing_raised("Failed to refresh exec") do exec.refresh end assert(FileTest.exists?(maker), "exec did not run refresh") File.unlink(maker) # Now add the checks exec[:creates] = file # Make sure it runs when the file doesn't exist assert_nothing_raised("Failed to refresh exec") do exec.refresh end assert(FileTest.exists?(maker), "exec did not refresh when checks passed") File.unlink(maker) # Now create the file and make sure it doesn't refresh File.open(file, "w") { |f| f.puts "" } assert_nothing_raised("Failed to refresh exec") do exec.refresh end assert(! FileTest.exists?(maker), "exec refreshed with failing checks") end def test_explicit_refresh refresher = tempfile maker = tempfile exec = Puppet::Type.type(:exec).new( :title => "maker", :command => "touch #{maker}", :path => ENV["PATH"] ) # Call refresh normally assert_nothing_raised do exec.refresh end # Make sure it created the normal file assert(FileTest.exists?(maker), "normal refresh did not work") File.unlink(maker) # Now reset refresh, and make sure it wins assert_nothing_raised("Could not set refresh parameter") do exec[:refresh] = "touch #{refresher}" end assert_nothing_raised do exec.refresh end # Make sure it created the normal file assert(FileTest.exists?(refresher), "refresh param was ignored") assert(! FileTest.exists?(maker), "refresh param also ran command") end if Puppet.features.root? def test_autorequire_user user = Puppet::Type.type(:user).new(:name => "yay") exec = Puppet::Type.type(:exec).new(:command => "/bin/echo fun", :user => "yay") rels = nil assert_nothing_raised("Could not evaluate autorequire") do rels = exec.autorequire end assert(rels.find { |r| r.source == user and r.target == exec }, "Exec did not autorequire user") end end end