summaryrefslogtreecommitdiffstats
path: root/lib/puppet/feature
Commit message (Collapse)AuthorAgeFilesLines
* (#8662) Break circular feature dependencyJosh Cooper2011-08-221-26/+28
| | | | | | | | | | | | | | | | | | | | The root feature was being evaluated prior to the microsoft_windows feature being defined. On Windows, this had the side-effect of calling Process.uid prior to the win32 sys/admin gem being loaded. And the default ruby implementation of Process.uid always returns 0, which caused Puppet.features.root? to always return true. This commit reorders the syslog, posix, microsoft_windows, and root features due to dependencies among them. This ensures the microsoft_windows feature is defined prior to evaluating the root feature. As a result of this commit, the SUIDManager now calls the win32 sys/admin version of the Process.uid method, which returns the RID component of the user's SID. As this is not 0, Puppet.features.root? will now always return false on Windows. A future commit will fix this, so that Puppet.feature.root? only returns true when running as the Windows-equivalent of root.
* (#8408/8409) Add a Windows ADSI helper moduleNick Lewis2011-08-191-0/+3
| | | | | | | | | | | | | | | | This module (Puppet::Util::ADSI) provides access to Active Directory Services Interfaces, using win32ole. The base module has methods for generating resource URIs and connecting to ADSI. It also provides classes Puppet::Util::ADSI::User and Puppet::Util::ADSI::Group for managing Active Directory users and groups, along with their properties and group memberships. This will be used to implement the Windows ADSI user and group providers. Based on work by: Joel Rosario <joel.r@.internal.directi.com> Based on work by: Cameron Thomas <cameron@puppetlabs.com> Reviewed-By: Matt Robinson <matt@puppetlabs.com> (cherry picked from commit b5fd95336e71ad428109cddf6cd2f33bdd31e025)
* Add basic service provider for WindowsCameron Thomas2011-08-191-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This provider allows us to query the system state through "puppet resource", and manage the ensure, and enabled properties of services on Windows. This also adds support for a new enabled value of 'manual' on Windows only. With this we support the three major start types for services on Windows, with the following mapping of enabled to start type: true => Automatic false => Disabled manual => Manual (Demand) We use the win32-service gem to provide access to the Windows APIs for our operations. This does add a new gem requirement for running Puppet on Windows, but we were already requiring some gems from the same suite that win32-service is a part of. When referring to a service, the simple service name must be used, instead of the display name. For example, "snmptrap", instead of "SNMP Trap". All system services are reported in 'puppet resource service', including those started prior to run level 3 (system, device drivers, etc.). These services should probably not be managed, without careful thought and planning. This currently does not support being able to move a service from {enabled => false, ensure => stopped} to {enabled => true, ensure => running} (or enabled => manual) in a single Puppet run, since Puppet currently always tries to sync ensure before any other property. Because of this, the puppet run will fail every time, and the service must first be managed as {ensure => stopped, enabled => true} (or enabled => manual), before it can be managed as running and automatic start or manual start. Reviewed by: Jacob Helwig <jacob@puppetlabs.com> (cherry picked from commit 82476e8be41b62ce1767ab6854a72b481b917380)
* (#7581) Provide more detailed error message when missing gems on WindowsJacob Helwig2011-08-191-1/+9
| | | | | | | | | | | | | | | | | | Running Puppet on Windows requires the sys-admin, win32-process & win32-dir gems. If any of these gems were missing, Puppet would fail with the message "Cannot determine basic system flavour". When trying to determine if we are on Windows, we now warn with the message "Cannot run on Microsoft Windows without the sys-admin, win32-process & win32-dir gems: #{err}", where err is the normal ruby load error message stating which gem could not be loaded. We also only warn if the POSIX feature is not present. Signed-off-by: James Turnbull <james@puppetlabs.com> Signed-off-by: Jacob Helwig <jacob@puppetlabs.com> Reviewed-by: Cameron Thomas <cameron@puppetlabs.com> (cherry picked from commit faf8a5c05f50d98835a1db05b96146618f485a04)
* maint: remove inaccurate copyright and license statements.Daniel Pittman2011-08-183-9/+0
| | | | | | | | | | | For a while Luke, and other authors, injected a created tag, copyright statement, and "All rights reserved" into every new file they added to the Puppet project. This isn't really true, and we have a global license covering the code, so we have now stripped out all those old tags. Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
* Ssh transport for network device managementBrice Figureau2011-04-081-0/+4
| | | | | | | It is an adapatation of net-ssh-telnet, so that net-ssh conforms to a saner interface for consumer. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Fix #4726 Update puppet rrdtool metric code to support modern rrd ruby bindingsJesse Wolfe2010-09-281-1/+2
| | | | | | | | | The rrd project has been shipping ruby bindings since 1.3.0, and the old rrdtool ruby library is no longer being maintained. This patch is based upon Davor Ocelic's submitted code, with the addition that I've added conditionals so it can still call the old rrdtool library if a modern rrd is not installed.
* (#4763) Don't call a method that was removed in Rails 3 activerecordMatt Robinson2010-09-221-3/+1
| | | | | | | | | | Calling this method caused storeconfigs not to run. ActiveRecord::Base.allow_concurrency was deprecated in Rails 2.2. We support activerecord 2.1 and higher, so we still need to call this method for 2.1. I factored out the code that determines our activerecord version to a method in util so that the code was easier to read and test.
* Fixed #4763 - Hardcoded ActiveRecord versionJames Turnbull2010-09-221-1/+1
|
* Code smell: Two space indentationMarkus Roberts2010-07-094-43/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Replaced 106806 occurances of ^( +)(.*$) with The ruby community almost universally (i.e. everyone but Luke, Markus, and the other eleven people who learned ruby in the 1900s) uses two-space indentation. 3 Examples: The code: end # Tell getopt which arguments are valid def test_get_getopt_args element = Setting.new :name => "foo", :desc => "anything", :settings => Puppet::Util::Settings.new assert_equal([["--foo", GetoptLong::REQUIRED_ARGUMENT]], element.getopt_args, "Did not produce appropriate getopt args") becomes: end # Tell getopt which arguments are valid def test_get_getopt_args element = Setting.new :name => "foo", :desc => "anything", :settings => Puppet::Util::Settings.new assert_equal([["--foo", GetoptLong::REQUIRED_ARGUMENT]], element.getopt_args, "Did not produce appropriate getopt args") The code: assert_equal(str, val) assert_instance_of(Float, result) end # Now test it with a passed object becomes: assert_equal(str, val) assert_instance_of(Float, result) end # Now test it with a passed object The code: end assert_nothing_raised do klass[:Yay] = "boo" klass["Cool"] = :yayness end becomes: end assert_nothing_raised do klass[:Yay] = "boo" klass["Cool"] = :yayness end
* Code smell: Avoid needless decorationsMarkus Roberts2010-07-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Replaced 704 occurances of (.*)\b([a-z_]+)\(\) with \1\2 3 Examples: The code: ctx = OpenSSL::SSL::SSLContext.new() becomes: ctx = OpenSSL::SSL::SSLContext.new The code: skip() becomes: skip The code: path = tempfile() becomes: path = tempfile * Replaced 31 occurances of ^( *)end *#.* with \1end 3 Examples: The code: becomes: The code: end # Dir.foreach becomes: end The code: end # def becomes: end
* Code smell: Line modifiers are preferred to one-line blocks.Markus Roberts2010-07-091-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Replaced 6 occurances of (while .*?) *do$ with The do is unneeded in the block header form and causes problems with the block-to-one-line transformation. 3 Examples: The code: while line = f.gets do becomes: while line = f.gets The code: while line = shadow.gets do becomes: while line = shadow.gets The code: while wrapper = zeros.pop do becomes: while wrapper = zeros.pop * Replaced 19 occurances of ((if|unless) .*?) *then$ with The then is unneeded in the block header form and causes problems with the block-to-one-line transformation. 3 Examples: The code: if f = test_files_for(failed).find { |f| failed_trace =~ Regexp.new(f) } then becomes: if f = test_files_for(failed).find { |f| failed_trace =~ Regexp.new(f) } The code: unless defined?(@spec_command) then becomes: unless defined?(@spec_command) The code: if c == ?\n then becomes: if c == ?\n * Replaced 758 occurances of ((?:if|unless|while|until) .*) (.*) end with The one-line form is preferable provided: * The condition is not used to assign a variable * The body line is not already modified * The resulting line is not too long 3 Examples: The code: if Puppet.features.libshadow? has_feature :manages_passwords end becomes: has_feature :manages_passwords if Puppet.features.libshadow? The code: unless (defined?(@current_pool) and @current_pool) @current_pool = process_zpool_data(get_pool_data) end becomes: @current_pool = process_zpool_data(get_pool_data) unless (defined?(@current_pool) and @current_pool) The code: if Puppet[:trace] puts detail.backtrace end becomes: puts detail.backtrace if Puppet[:trace]
* Code smell: English names for special globals rather than line-noiseMarkus Roberts2010-07-091-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Replaced 36 occurances of [$][?] with $CHILD_STATUS 3 Examples: The code: print "%s finished with exit code %s\n" % [host, $?.exitstatus] becomes: print "%s finished with exit code %s\n" % [host, $CHILD_STATUS.exitstatus] The code: $stderr.puts "Could not find host for PID %s with status %s" % [pid, $?.exitstatus] becomes: $stderr.puts "Could not find host for PID %s with status %s" % [pid, $CHILD_STATUS.exitstatus] The code: unless $? == 0 becomes: unless $CHILD_STATUS == 0 * Replaced 3 occurances of [$][$] with $PID 3 Examples: The code: Process.kill(:HUP, $$) if restart_requested? becomes: Process.kill(:HUP, $PID) if restart_requested? The code: if pid == $$ becomes: if pid == $PID The code: host[:name] = "!invalid.hostname.$$$" becomes: host[:name] = "!invalid.hostname.$PID$" * Replaced 7 occurances of [$]& with $MATCH 3 Examples: The code: work.slice!(0, $&.length) becomes: work.slice!(0, $MATCH.length) The code: if $& becomes: if $MATCH The code: if $& becomes: if $MATCH * Replaced 28 occurances of [$]:(?!:) with $LOAD_PATH 3 Examples: The code: sitelibdir = $:.find { |x| x =~ /site_ruby/ } becomes: sitelibdir = $LOAD_PATH.find { |x| x =~ /site_ruby/ } The code: $:.unshift "lib" becomes: $LOAD_PATH.unshift "lib" The code: $:.shift becomes: $LOAD_PATH.shift * Replaced 3 occurances of [$]! with $ERROR_INFO 3 Examples: The code: $LOG.fatal("Problem reading #{filepath}: #{$!}") becomes: $LOG.fatal("Problem reading #{filepath}: #{$ERROR_INFO}") The code: $stderr.puts "Couldn't build man pages: " + $! becomes: $stderr.puts "Couldn't build man pages: " + $ERROR_INFO The code: $stderr.puts $!.message becomes: $stderr.puts $ERROR_INFO.message * Replaced 3 occurances of ^(.*)[$]" with \1$LOADED_FEATURES 3 Examples: The code: unless $".index 'racc/parser.rb' becomes: unless $LOADED_FEATURES.index 'racc/parser.rb' The code: $".push 'racc/parser.rb' becomes: $LOADED_FEATURES.push 'racc/parser.rb' The code: $".should be_include("tmp/myfile.rb") becomes: $LOADED_FEATURES.should be_include("tmp/myfile.rb")
* Code smell: Win32 --> MS_windowsMarkus Roberts2010-07-091-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Replaced 12 occurances of Win32 with Microsoft Windows 3 Examples: The code: # and all .rb files in lib/. This is disabled by default on Win32. becomes: # and all .rb files in lib/. This is disabled by default on Microsoft Windows. The code: # We can use Win32 functions becomes: # We can use Microsoft Windows functions The code: desc "Uses Win32 functionality to manage file's users and rights." becomes: desc "Uses Microsoft Windows functionality to manage file's users and rights." * Replaced 10 occurances of :win32 with :microsoft_windows 3 Examples: The code: Puppet.features.add(:win32, :libs => ["sys/admin", "win32/process", "win32/dir"]) becomes: Puppet.features.add(:microsoft_windows, :libs => ["sys/admin", "win32/process", "win32/dir"]) The code: Puppet::Type.type(:file).provide :win32 do becomes: Puppet::Type.type(:file).provide :microsoft_windows do The code: confine :feature => :win32 becomes: confine :feature => :microsoft_windows * Replaced 13 occurances of win32\? with microsoft_windows? 3 Examples: The code: signals.update({:HUP => :restart, :USR1 => :reload, :USR2 => :reopen_logs }) unless Puppet.features.win32? becomes: signals.update({:HUP => :restart, :USR1 => :reload, :USR2 => :reopen_logs }) unless Puppet.features.microsoft_windows? The code: raise Puppet::Error,"Cannot determine basic system flavour" unless Puppet.features.posix? or Puppet.features.win32? becomes: raise Puppet::Error,"Cannot determine basic system flavour" unless Puppet.features.posix? or Puppet.features.microsoft_windows? The code: require 'sys/admin' if Puppet.features.win32? becomes: require 'sys/admin' if Puppet.features.microsoft_windows?
* maint: Confine a test that depends on sqliteMatt Robinson2010-06-281-0/+3
| | | | I'm also going to update the wiki to mention sqlite is a test dependency
* Fix for #3985 typo causing warningMarkus Roberts2010-06-261-1/+1
| | | | There was a comma missing from a raise, which caused a warning message on each run.
* [#4055] Add CouchDB terminus for factsRein Henrichs2010-02-171-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | Implements an abstract CouchDB terminus and a concrete CouchDB terminus used to store node facts. Node facts are stored in a "node" document as the "facts" attribute. This node document may also be used by other couchdb termini that store node-related information. It is recommended to use a separate document (or documents) to store large data structures like catalogs, linking them to their related node document using embedded ids. This implementation depends on the "couchrest" gem. * Add Puppet.features.couchdb? * Add Puppet[:couchdb_url] setting * Add Puppet::Node::Facts#== for testing * Add PuppetSpec::FIXTURE_DIR for easy access to fixture files * Add CouchDB Terminus * Add Facts::CouchDB terminus * Stores facts inside a "node" document * Use key (hostname) as _id for node document * #find returns nil if document cannot be found * #save finds and updates existing document OR creates new doc [1] * Store facts in "facts" attribute of node document
* Move syslog into a featureDavid Schmitt2010-02-171-2/+5
|
* More win32? feature defDavid Schmitt2010-02-171-1/+1
|
* Define posix and win32 featuresDavid Schmitt2010-02-171-0/+11
|
* Feature #2935 Modes: root? predicateJesse Wolfe2010-02-171-1/+1
| | | | | | | Use a predicate method to check if we're running as root, rather than comparing the effective user id Signed-off-by: Jesse Wolfe <jes5199@gmail.com>
* Closed #2937 - Migrated a number of requires to featuresJames Turnbull2009-12-182-0/+6
|
* Fixing 2855 Inadvertent zlib dependencyJesse Wolfe2009-12-161-0/+6
| | | | | | | | | | | | | Disables the b64_zlib_yaml format if zlib cannot be loaded. I've added a --no-zlib to make it possible to test this on a single machine, but it might also be useful if someone finds themselves failing to connect to a server that doesn't have zlib installed. FactHandler' format is still hard-coded to YAML rather than using facts.class.default_format Signed-off-by: Jesse Wolfe <jes5199@gmail.com>
* Bundling of pure ruby json lib as "pson"Markus Roberts2009-10-173-7/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bundeling and renaming the pure ruby json library to addresses a number of cross version serliaization bugs (#2615, et al). This patch adds a subset of the files from the json_pure gem to lib/puppet/external/pson (renamed to avoid conflicts with rails) so that we will always have a known-good erialization format available. The pure ruby json gem as distibuted defers to the compiled version if it is installed. This is problematic in some circumstances so the files that have been brought over have been modified to always and only use the bundled version. It's a large patch, so here's a breakdown of the change categories: The majority of the lines are only marginally interesting: * The json lib itself (in lib/puppet/external/pson) make up the bulk of the lines. * Renaming of json to pson make up the second largest group. Somewhat more interesting are the following, which can be located by searching the diffs for the indicated strings: * Adjusting tests to reflect the changes * Changing the encoding/decoding behavior so that nested structures (e.g. resources) don't serialize as escaped strings. This should make it much easier to process the results with external tools, if needed. Search for "to_pson" and "to_pson_data_hash" * Cleaning up the envelope/metadata * Now provides a document_type (as opposed to a ruby class name) by using a symple registration scheme instead of constant lookup (search for "document_type") * Added an api_version (search for "api_version") * Added a hash for document metadata (search for "metadata") * Removing the yaml monkeypatch and instead disabling yaml serialization on ruby 1.8.1 in favor of pson (search for "yaml") * Cleaning up the json/rails feature interaction (they're now totally independent) (search for "feature")
* Require active_record/version to support ActiveRecord < 2.3Todd Zullinger2009-09-091-0/+1
| | | | | | | | | ActiveRecord < 2.3.0 did not autoload active_record/version which caused puppet to incorrectly believe ActiveRecord was not available. This compliments 1a5c5b3 (Fixing #2508 - removing mention of ActiveRecord 2.3). Signed-off-by: Todd Zullinger <tmz@pobox.com>
* Fixed #2102 - Rails feature update fixed for Debian and UbuntuJames Turnbull2009-06-131-1/+1
|
* Adding a "json" featureLuke Kanies2009-06-063-1/+6
| | | | | We have to guarantee that the Rails code is loaded before the JSON code, because Rails includes its own incompatible JSON support.
* Fixes Bug #2324 - Puppetd fails to start without railsStéphan Gorget2009-06-051-1/+1
| | | | Signed-off-by: Stéphan Gorget <gorget@ocre.cea.fr>
* Fixing the rails feature to be compatible with 2.1+Luke Kanies2009-06-031-19/+16
| | | | Signed-off-by: Luke Kanies <luke@madstop.com>
* Fix for #2234: test fails with old Rack versionChristian Hofstaedtler2009-05-202-2/+24
|
* Puppet as a Rack applicationChristian Hofstaedtler2009-05-021-0/+3
| | | | | | | This lays the ground: a wrapper for the REST handler, and an application confirming to the Rack standard. Also includes a base class for Rack handlers, as RackREST will not stay the only one, and there needs to be a central place where client authentication data can be checked.
* Fixing rails feature testLuke Kanies2009-04-241-5/+7
| | | | Signed-off-by: Luke Kanies <luke@madstop.com>
* Fixing the Rails feature test to require 2.3.xLuke Kanies2009-04-251-17/+4
| | | | Signed-off-by: Luke Kanies <luke@madstop.com>
* Adding "rubygems" and "stomp" featuresLuke Kanies2009-04-222-0/+12
| | | | Signed-off-by: Luke Kanies <luke@madstop.com>
* Moved RRD feature from util/metric.rb to feature/base.rbJames Turnbull2008-11-171-0/+3
|
* Added augeas type and featureJames Turnbull2008-10-241-0/+3
|
* Moving the webrick/mongrel "servers" over to HTTPServer module instead of ↵Rick Bradley2007-10-051-1/+1
| | | | 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.
* Removing the Id tags from all of the filesLuke Kanies2007-10-031-1/+0
|
* Adding support for providing a diff when files are being changed. Currently ↵Luke Kanies2007-08-271-1/+2
| | | | 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.
* A few small fixes here and there, and the rest of the zones commitluke2007-06-141-1/+1
| | | | git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2577 980ebf18-57e1-0310-9a29-db15c13687c0
* Adding a simple unit test for mongrel, and adding the ability to select the ↵luke2007-06-111-0/+3
| | | | | | header used to store the client SSL dn. git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2558 980ebf18-57e1-0310-9a29-db15c13687c0
* Switching the simpler features to a single file, so it is easier to add new ↵luke2007-04-304-24/+20
| | | | | | features git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2441 980ebf18-57e1-0310-9a29-db15c13687c0
* Adding the ability to manage passwords with the useradd providerluke2007-04-251-0/+8
| | | | git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2414 980ebf18-57e1-0310-9a29-db15c13687c0
* This works for me. Probably not the most universal fix.shadoi2007-02-151-0/+4
| | | | git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2195 980ebf18-57e1-0310-9a29-db15c13687c0
* Apparently using "gem" requires an environment we don't have.shadoi2007-02-151-1/+1
| | | | git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2194 980ebf18-57e1-0310-9a29-db15c13687c0
* Merge fact_names & fact_values, and param_names & param_values.shadoi2007-02-151-1/+1
| | | | git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2191 980ebf18-57e1-0310-9a29-db15c13687c0
* Fixing features to use the new feature locationluke2007-02-153-4/+4
| | | | git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2190 980ebf18-57e1-0310-9a29-db15c13687c0
* Use a specific ActiveRecord subclass to check for the proper existence of AR ↵mpalmer2007-01-151-1/+4
| | | | | | 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 git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2071 980ebf18-57e1-0310-9a29-db15c13687c0
* Trying to clean up how rails is loadedluke2006-12-291-0/+1
| | | | git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1989 980ebf18-57e1-0310-9a29-db15c13687c0
* A couple of small bug-fixesluke2006-12-281-0/+8
| | | | git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1976 980ebf18-57e1-0310-9a29-db15c13687c0