diff options
| author | Ian Taylor <ian@lorf.org> | 2009-06-05 12:39:04 -0400 |
|---|---|---|
| committer | James Turnbull <james@lovedthanlost.net> | 2009-06-06 09:12:00 +1000 |
| commit | 4f2c066a97e59a89df64af4b25beac6f3f0553c2 (patch) | |
| tree | 126540beec3c65448e01e1b48d27275ec4ee6ea4 /lib/puppet | |
| parent | 97e6975d69f239e24993315a25a3117b1daa48c3 (diff) | |
| download | puppet-4f2c066a97e59a89df64af4b25beac6f3f0553c2.tar.gz puppet-4f2c066a97e59a89df64af4b25beac6f3f0553c2.tar.xz puppet-4f2c066a97e59a89df64af4b25beac6f3f0553c2.zip | |
Removed extra whitespace from end of lines
Diffstat (limited to 'lib/puppet')
212 files changed, 953 insertions, 953 deletions
diff --git a/lib/puppet/application.rb b/lib/puppet/application.rb index 88ad9d493..e7240f773 100644 --- a/lib/puppet/application.rb +++ b/lib/puppet/application.rb @@ -14,14 +14,14 @@ require 'optparse' # The executable uses the application object like this: # Puppet::Application[:example].run # -# +# # Puppet::Application.new(:example) do -# +# # preinit do # # perform some pre initialization # @all = false # end -# +# # # dispatch is called to know to what command to call # dispatch do # ARGV.shift @@ -30,15 +30,15 @@ require 'optparse' # option("--arg ARGUMENT") do |v| # @args << v # end -# +# # option("--debug", "-d") do |v| # @debug = v # end -# +# # option("--all", "-a:) do |v| # @all = v # end -# +# # unknown do |opt,arg| # # last chance to manage an option # ... @@ -49,11 +49,11 @@ require 'optparse' # command(:read) do # # read action # end -# +# # command(:write) do # # writeaction # end -# +# # end # # === Preinit @@ -62,7 +62,7 @@ require 'optparse' # # === Options # Puppet::Application uses +OptionParser+ to manage the application options. -# Options are defined with the +option+ method to which are passed various +# 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 @@ -142,7 +142,7 @@ class Puppet::Application end end - # used to declare accessor in a more natural way in the + # used to declare accessor in a more natural way in the # various applications def attr_accessor(*args) args.each do |arg| @@ -186,7 +186,7 @@ class Puppet::Application # initialize default application behaviour def init_default - setup do + setup do default_setup end diff --git a/lib/puppet/application/pi.rb b/lib/puppet/application/pi.rb index 3ac6081e1..67fffdc1b 100644 --- a/lib/puppet/application/pi.rb +++ b/lib/puppet/application/pi.rb @@ -161,7 +161,7 @@ class TypeDoc a.to_s <=> b.to_s }.each { |prov| puts "\n- **%s**" % prov - puts @format.wrap(type.provider(prov).doc, + puts @format.wrap(type.provider(prov).doc, :indent => 4, :scrub => true) } end diff --git a/lib/puppet/application/puppetd.rb b/lib/puppet/application/puppetd.rb index 17b07d98e..4799d5571 100644 --- a/lib/puppet/application/puppetd.rb +++ b/lib/puppet/application/puppetd.rb @@ -164,7 +164,7 @@ Puppet::Application.new(:puppetd) do # to clients. In the meantime, we just disable CRL checking if # the CRL file doesn't exist unless File::exist?(Puppet[:cacrl]) - Puppet[:cacrl] = 'false' + Puppet[:cacrl] = 'false' end handlers = nil @@ -199,7 +199,7 @@ Puppet::Application.new(:puppetd) do args[:Server] = Puppet[:server] if options[:fqdn] args[:FQDN] = options[:fqdn] - Puppet[:certname] = options[:fqdn] + Puppet[:certname] = options[:fqdn] end if options[:centrallogs] diff --git a/lib/puppet/configurer.rb b/lib/puppet/configurer.rb index 7db9972dd..8ec0b0055 100644 --- a/lib/puppet/configurer.rb +++ b/lib/puppet/configurer.rb @@ -58,7 +58,7 @@ class Puppet::Configurer end end end - + # Just so we can specify that we are "the" instance. def initialize Puppet.settings.use(:main, :ssl, :puppetd) @@ -124,7 +124,7 @@ class Puppet::Configurer return catalog end - # The code that actually runs the catalog. + # The code that actually runs the catalog. # This just passes any options on to the catalog, # which accepts :tags and :ignoreschedules. def run(options = {}) diff --git a/lib/puppet/daemon.rb b/lib/puppet/daemon.rb index 5f811d897..16b1f80d2 100755 --- a/lib/puppet/daemon.rb +++ b/lib/puppet/daemon.rb @@ -17,7 +17,7 @@ class Puppet::Daemon Process.detach(pid) exit(0) end - + create_pidfile() # Get rid of console logging diff --git a/lib/puppet/defaults.rb b/lib/puppet/defaults.rb index 538d31c96..3d0ad4bb8 100644 --- a/lib/puppet/defaults.rb +++ b/lib/puppet/defaults.rb @@ -39,7 +39,7 @@ module Puppet logopts = ["$vardir/log", "The Puppet log directory."] end setdefaults(:main, :logdir => logopts) - + # This name hackery is necessary so that the rundir is set reasonably during # unit tests. if Process.uid == 0 and %w{puppetd puppetmasterd}.include?(self.name) @@ -60,7 +60,7 @@ module Puppet this directory can be removed without causing harm (although it might result in spurious service restarts)." }, - :rundir => { + :rundir => { :default => rundir, :mode => 01777, :desc => "Where Puppet PID files are kept." @@ -192,7 +192,7 @@ module Puppet 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 + # 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.", @@ -320,13 +320,13 @@ module Puppet 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. + :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 + :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) + 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."], @@ -382,11 +382,11 @@ module Puppet }, :masterport => [8140, "Which port puppetmasterd 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 + :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", @@ -642,7 +642,7 @@ module Puppet :typecheck => [true, "Whether to validate types during parsing."], :paramcheck => [true, "Whether to validate parameters during parsing."] ) - + setdefaults(:main, :casesensitive => [false, "Whether matching in case statements and selectors diff --git a/lib/puppet/dsl.rb b/lib/puppet/dsl.rb index 714b350f8..ca01a9c42 100644 --- a/lib/puppet/dsl.rb +++ b/lib/puppet/dsl.rb @@ -1,5 +1,5 @@ # Just quick mess-around to see what a DSL would look like. -# +# # This is what the executable could look like: ##!/usr/bin/env ruby # @@ -28,22 +28,22 @@ # # require 'puppet' # require 'puppet/dsl' -# +# # include Puppet::DSL # init() -# +# # aspect :webserver do # file "/tmp/testone", :content => "yaytest" -# +# # exec "testing", :command => "/bin/echo this is a test" # end -# +# # aspect :other, :inherits => :webserver do # file "/tmp/testone", :mode => "755" # end -# +# # acquire :other -# +# # apply require 'puppet' diff --git a/lib/puppet/external/dot.rb b/lib/puppet/external/dot.rb index fcd5c6a85..b0d542891 100644 --- a/lib/puppet/external/dot.rb +++ b/lib/puppet/external/dot.rb @@ -1,5 +1,5 @@ # rdot.rb -# +# # # This is a modified version of dot.rb from Dave Thomas's rdoc project. I [Horst Duchene] # renamed it to rdot.rb to avoid collision with an installed rdoc/dot. @@ -7,19 +7,19 @@ # It also supports undirected edges. module DOT - + # These glogal vars are used to make nice graph source. $tab = ' ' $tab2 = $tab * 2 - + # if we don't like 4 spaces, we can change it any time def change_tab (t) $tab = t $tab2 = t * 2 end - + # options for node declaration NODE_OPTS = [ @@ -56,7 +56,7 @@ module DOT 'bgcolor', 'rank' ] - + # options for edge declaration EDGE_OPTS = [ @@ -96,7 +96,7 @@ module DOT # maintained for backward compatibility or rdot internal 'id' ] - + # options for graph declaration GRAPH_OPTS = [ @@ -111,7 +111,7 @@ module DOT 'rank', 'rankdir', 'ranksep', 'ratio', 'size' ] - + # a root class for any element in dot notation class DOTSimpleElement @@ -126,7 +126,7 @@ module DOT @name end end - + # an element that has options ( node, edge, or graph ) class DOTElement < DOTSimpleElement @@ -159,8 +159,8 @@ module DOT #end end - - + + # This is used when we build nodes that have shape=record # ports don't have options :) @@ -177,7 +177,7 @@ module DOT ( @name && @name != "" ? "<#{@name}>" : "" ) + "#{@label}" end end - + # node element class DOTNode < DOTElement @@ -300,7 +300,7 @@ module DOT @from = params['from'] ? params['from'] : nil @to = params['to'] ? params['to'] : nil end - + def edge_link '--' end @@ -315,7 +315,7 @@ module DOT end end # class DOTEdge - + class DOTDirectedEdge < DOTEdge def edge_link diff --git a/lib/puppet/external/event-loop/better-definers.rb b/lib/puppet/external/event-loop/better-definers.rb index 09e33fdb5..5d6175fe9 100644 --- a/lib/puppet/external/event-loop/better-definers.rb +++ b/lib/puppet/external/event-loop/better-definers.rb @@ -172,7 +172,7 @@ class Module def define_methods (*names, &body) names.each { |name| define_method(name, &body) } end - + def define_private_methods (*names, &body) define_methods(*names, &body) names.each { |name| private name } @@ -280,7 +280,7 @@ if __FILE__ == $0 assert_equal @y.baz, 321 assert_equal @y.quux, 654 end - + def test_define_soft_aliases @X.define_method(:foo) { 123 } @X.define_method(:baz) { 321 } diff --git a/lib/puppet/external/lock.rb b/lib/puppet/external/lock.rb index 5213f5657..785ecd637 100644 --- a/lib/puppet/external/lock.rb +++ b/lib/puppet/external/lock.rb @@ -36,7 +36,7 @@ class File flush flock(LOCK_UN) end - + # Get a shared (i.e., read) lock on the file, and yield to the block. # If the lock is not available, wait for it without blocking other ruby # threads. diff --git a/lib/puppet/external/nagios/base.rb b/lib/puppet/external/nagios/base.rb index 6a0c1831c..5185c92f7 100755 --- a/lib/puppet/external/nagios/base.rb +++ b/lib/puppet/external/nagios/base.rb @@ -231,9 +231,9 @@ class Nagios::Base # This is probably a bad idea. def name=(value) - unless self.class.namevar.to_s == "name" - send(self.class.namevar.to_s + "=", value) - end + unless self.class.namevar.to_s == "name" + send(self.class.namevar.to_s + "=", value) + end end def namevar diff --git a/lib/puppet/external/nagios/parser.rb b/lib/puppet/external/nagios/parser.rb index d8a8bceea..498b0884e 100644 --- a/lib/puppet/external/nagios/parser.rb +++ b/lib/puppet/external/nagios/parser.rb @@ -402,7 +402,7 @@ module Racc toks.each {|t| out.print ' ', racc_token2str(t) } end out.puts " --> #{racc_token2str(sim)}" - + racc_print_stacks tstack, vstack @racc_debug_out.puts end diff --git a/lib/puppet/file_serving/base.rb b/lib/puppet/file_serving/base.rb index d1fa9dfd2..c82bb1992 100644 --- a/lib/puppet/file_serving/base.rb +++ b/lib/puppet/file_serving/base.rb @@ -48,7 +48,7 @@ class Puppet::FileServing::Base def links=(value) value = value.to_sym value = :manage if value == :ignore - raise(ArgumentError, ":links can only be set to :manage or :follow") unless [:manage, :follow].include?(value) + raise(ArgumentError, ":links can only be set to :manage or :follow") unless [:manage, :follow].include?(value) @links = value end diff --git a/lib/puppet/file_serving/configuration/parser.rb b/lib/puppet/file_serving/configuration/parser.rb index 50368fdaf..eef2d7852 100644 --- a/lib/puppet/file_serving/configuration/parser.rb +++ b/lib/puppet/file_serving/configuration/parser.rb @@ -55,7 +55,7 @@ class Puppet::FileServing::Configuration::Parser < Puppet::Util::LoadedFile # Allow a given pattern access to a mount. def allow(mount, value) - # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com] + # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com] x = value.split(/\s*,\s*/).each { |val| begin mount.info "allowing %s access" % val @@ -69,7 +69,7 @@ class Puppet::FileServing::Configuration::Parser < Puppet::Util::LoadedFile # Deny a given pattern access to a mount. def deny(mount, value) - # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com] + # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com] x = value.split(/\s*,\s*/).each { |val| begin mount.info "denying %s access" % val diff --git a/lib/puppet/file_serving/content.rb b/lib/puppet/file_serving/content.rb index c1ecff749..9fc1d08b3 100644 --- a/lib/puppet/file_serving/content.rb +++ b/lib/puppet/file_serving/content.rb @@ -36,7 +36,7 @@ class Puppet::FileServing::Content < Puppet::FileServing::Base def content unless defined?(@content) and @content # This stat can raise an exception, too. - raise(ArgumentError, "Cannot read the contents of links unless following links") if stat().ftype == "symlink" + raise(ArgumentError, "Cannot read the contents of links unless following links") if stat().ftype == "symlink" @content = ::File.read(full_path()) end diff --git a/lib/puppet/file_serving/fileset.rb b/lib/puppet/file_serving/fileset.rb index a6a4b62a1..50e4e1e80 100644 --- a/lib/puppet/file_serving/fileset.rb +++ b/lib/puppet/file_serving/fileset.rb @@ -111,14 +111,14 @@ class Puppet::FileServing::Fileset elsif request.options.include?(param.to_s) value = request.options[param.to_s] end - next if value.nil? + next if value.nil? value = true if value == "true" value = false if value == "false" value = Integer(value) if value.is_a?(String) and value =~ /^\d+$/ send(param.to_s + "=", value) end end - + private # Pull the recursion logic into one place. It's moderately hairy, and this diff --git a/lib/puppet/file_serving/mount.rb b/lib/puppet/file_serving/mount.rb index 5b74ad218..5ab6d8688 100644 --- a/lib/puppet/file_serving/mount.rb +++ b/lib/puppet/file_serving/mount.rb @@ -15,7 +15,7 @@ class Puppet::FileServing::Mount < Puppet::Network::AuthStore include Puppet::Util::Logging attr_reader :name - + # Determine the environment to use, if any. def environment(node_name) if node_name and node = Puppet::Node.find(node_name) diff --git a/lib/puppet/file_serving/mount/file.rb b/lib/puppet/file_serving/mount/file.rb index 15e343c57..9053ee18c 100644 --- a/lib/puppet/file_serving/mount/file.rb +++ b/lib/puppet/file_serving/mount/file.rb @@ -79,7 +79,7 @@ class Puppet::FileServing::Mount::File < Puppet::FileServing::Mount # Create a map for a specific node. def clientmap(node) { - "h" => node.sub(/\..*$/, ""), + "h" => node.sub(/\..*$/, ""), "H" => node, "d" => node.sub(/[^.]+\./, "") # domain name } @@ -101,7 +101,7 @@ class Puppet::FileServing::Mount::File < Puppet::FileServing::Mount path.gsub(/%(.)/) do |v| key = $1 - if key == "%" + if key == "%" "%" else map[key] || v diff --git a/lib/puppet/indirector/catalog/active_record.rb b/lib/puppet/indirector/catalog/active_record.rb index 66348f9a4..e3b56ece6 100644 --- a/lib/puppet/indirector/catalog/active_record.rb +++ b/lib/puppet/indirector/catalog/active_record.rb @@ -12,7 +12,7 @@ class Puppet::Resource::Catalog::ActiveRecord < Puppet::Indirector::ActiveRecord return nil unless host = ar_model.find_by_name(request.key) catalog = Puppet::Resource::Catalog.new(host.name) - + host.resources.each do |resource| catalog.add_resource resource.to_transportable end diff --git a/lib/puppet/indirector/exec.rb b/lib/puppet/indirector/exec.rb index 5b51142c3..022ec5324 100644 --- a/lib/puppet/indirector/exec.rb +++ b/lib/puppet/indirector/exec.rb @@ -42,7 +42,7 @@ class Puppet::Indirector::Exec < Puppet::Indirector::Terminus Puppet.err "Failed to find %s via exec: %s" % [name, detail] return nil end - + if output =~ /\A\s*\Z/ # all whitespace Puppet.debug "Empty response for %s from exec %s terminus" % [name, self.name] return nil diff --git a/lib/puppet/indirector/facts/active_record.rb b/lib/puppet/indirector/facts/active_record.rb index 9478c3df2..a2d3e7758 100644 --- a/lib/puppet/indirector/facts/active_record.rb +++ b/lib/puppet/indirector/facts/active_record.rb @@ -28,7 +28,7 @@ class Puppet::Node::Facts::ActiveRecord < Puppet::Indirector::ActiveRecord facts = request.instance host = ar_model.find_by_name(facts.name) || ar_model.create(:name => facts.name) - + host.merge_facts(facts.values) host.save diff --git a/lib/puppet/indirector/indirection.rb b/lib/puppet/indirector/indirection.rb index 0623446d1..f16a9b5dc 100644 --- a/lib/puppet/indirector/indirection.rb +++ b/lib/puppet/indirector/indirection.rb @@ -23,14 +23,14 @@ class Puppet::Indirector::Indirection def self.instances @@indirections.collect { |i| i.name } end - + # Find an indirected model by name. This is provided so that Terminus classes # can specifically hook up with the indirections they are associated with. def self.model(name) return nil unless match = @@indirections.find { |i| i.name == name } match.model end - + attr_accessor :name, :model # Create and return our cache terminus. @@ -126,7 +126,7 @@ class Puppet::Indirector::Indirection unless terminus_name ||= terminus_class raise Puppet::DevError, "No terminus specified for %s; cannot redirect" % self.name end - + return termini[terminus_name] ||= make_terminus(terminus_name) end diff --git a/lib/puppet/indirector/node/ldap.rb b/lib/puppet/indirector/node/ldap.rb index ab5d47b1c..4600a0dd5 100644 --- a/lib/puppet/indirector/node/ldap.rb +++ b/lib/puppet/indirector/node/ldap.rb @@ -9,7 +9,7 @@ class Puppet::Node::Ldap < Puppet::Indirector::Ldap # The attributes that Puppet class information is stored in. def class_attributes - # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com] + # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com] x = Puppet[:ldapclassattrs].split(/\s*,\s*/) end diff --git a/lib/puppet/indirector/queue.rb b/lib/puppet/indirector/queue.rb index 91e431795..cd0e0c833 100644 --- a/lib/puppet/indirector/queue.rb +++ b/lib/puppet/indirector/queue.rb @@ -10,7 +10,7 @@ require 'yaml' # and specifies a default queue type of <tt>:stomp</tt>, appropriate for use with a variety of message brokers. # # It's up to the queue client type to instantiate itself correctly based on Puppet configuration information. -# +# # A single queue client is maintained for the abstract terminus, meaning that you can only use one type # of queue client, one message broker solution, etc., with the indirection mechanism. # diff --git a/lib/puppet/indirector/report/processor.rb b/lib/puppet/indirector/report/processor.rb index 135f1649d..9daf14641 100644 --- a/lib/puppet/indirector/report/processor.rb +++ b/lib/puppet/indirector/report/processor.rb @@ -45,7 +45,7 @@ class Puppet::Transaction::Report::Processor < Puppet::Indirector::Code # Handle the parsing of the reports attribute. def reports - # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com] + # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com] x = Puppet[:reports].gsub(/(^\s+)|(\s+$)/, '').split(/\s*,\s*/) end end diff --git a/lib/puppet/indirector/rest.rb b/lib/puppet/indirector/rest.rb index c3d689e93..6903f9a0d 100644 --- a/lib/puppet/indirector/rest.rb +++ b/lib/puppet/indirector/rest.rb @@ -6,7 +6,7 @@ require 'puppet/network/http/api/v1' # Access objects via REST class Puppet::Indirector::REST < Puppet::Indirector::Terminus - include Puppet::Network::HTTP::API::V1 + include Puppet::Network::HTTP::API::V1 class << self attr_reader :server_setting, :port_setting @@ -58,7 +58,7 @@ class Puppet::Indirector::REST < Puppet::Indirector::Terminus def headers {"Accept" => model.supported_formats.join(", ")} end - + def network(request) Puppet::Network::HttpPool.http_instance(request.server || self.class.server, request.port || self.class.port) end @@ -66,19 +66,19 @@ class Puppet::Indirector::REST < Puppet::Indirector::Terminus def find(request) deserialize network(request).get(indirection2uri(request), headers) end - + def search(request) unless result = deserialize(network(request).get(indirection2uri(request), headers), true) return [] end return result end - + def destroy(request) raise ArgumentError, "DELETE does not accept options" unless request.options.empty? deserialize network(request).delete(indirection2uri(request), headers) end - + def save(request) raise ArgumentError, "PUT does not accept options" unless request.options.empty? deserialize network(request).put(indirection2uri(request), request.instance.render, headers) diff --git a/lib/puppet/indirector/ssl_file.rb b/lib/puppet/indirector/ssl_file.rb index de7163700..67202699d 100644 --- a/lib/puppet/indirector/ssl_file.rb +++ b/lib/puppet/indirector/ssl_file.rb @@ -54,7 +54,7 @@ class Puppet::Indirector::SslFile < Puppet::Indirector::Terminus # Use a setting to determine our path. def path(name) - if ca?(name) and ca_location + if ca?(name) and ca_location ca_location elsif collection_directory File.join(collection_directory, name.to_s + ".pem") diff --git a/lib/puppet/indirector/terminus.rb b/lib/puppet/indirector/terminus.rb index 22c56a4d2..4d1d58f87 100644 --- a/lib/puppet/indirector/terminus.rb +++ b/lib/puppet/indirector/terminus.rb @@ -111,7 +111,7 @@ class Puppet::Indirector::Terminus # Return all terminus classes for a given indirection. def terminus_classes(indirection_name) setup_instance_loading indirection_name - + # Load them all. instance_loader(indirection_name).loadall @@ -137,15 +137,15 @@ class Puppet::Indirector::Terminus raise Puppet::DevError, "Cannot create instances of abstract terminus types" end end - + def model self.class.model end - + def name self.class.name end - + def terminus_type self.class.terminus_type end diff --git a/lib/puppet/indirector/yaml.rb b/lib/puppet/indirector/yaml.rb index 5b53a7628..782112ebd 100644 --- a/lib/puppet/indirector/yaml.rb +++ b/lib/puppet/indirector/yaml.rb @@ -52,7 +52,7 @@ class Puppet::Indirector::Yaml < Puppet::Indirector::Terminus def path(name) File.join(base, self.class.indirection_name.to_s, name.to_s + ".yaml") end - + # Do a glob on the yaml directory, loading each file found def search(request) Dir.glob(File.join(base, self.class.indirection_name.to_s, request.key)).collect { |f| YAML.load_file(f) } diff --git a/lib/puppet/metatype/manager.rb b/lib/puppet/metatype/manager.rb index 773f30b1b..865a7c296 100644 --- a/lib/puppet/metatype/manager.rb +++ b/lib/puppet/metatype/manager.rb @@ -19,7 +19,7 @@ module Manager @types.each do |name, type| # Only consider types that have names #if ! type.parameters.empty? or ! type.validproperties.empty? - yield type + yield type #end end end @@ -94,14 +94,14 @@ module Manager klass end - + # Remove an existing defined type. Largely used for testing. def rmtype(name) # Then create the class. klass = rmclass(name, :hash => @types ) - + if respond_to?("new" + name.to_s) metaclass.send(:remove_method, "new" + name.to_s) end diff --git a/lib/puppet/module.rb b/lib/puppet/module.rb index 30c2512f3..701e4b258 100644 --- a/lib/puppet/module.rb +++ b/lib/puppet/module.rb @@ -29,7 +29,7 @@ class Puppet::Module end end end - + # Return an array of paths by splitting the +modulepath+ config # parameter. Only consider paths that are absolute and existing # directories diff --git a/lib/puppet/network/authconfig.rb b/lib/puppet/network/authconfig.rb index 41f8f1c3e..0922393a2 100644 --- a/lib/puppet/network/authconfig.rb +++ b/lib/puppet/network/authconfig.rb @@ -16,7 +16,7 @@ module Puppet [:allow, :deny].each do |method| define_method(method) do |*args| @rights.send(method, *args) - end + end end # Here we add a little bit of semantics. They can set auth on a whole @@ -77,7 +77,7 @@ module Puppet else return end - else + else Puppet.notice "%s and %s" % [@configtimeout, @configstatted] end end diff --git a/lib/puppet/network/client/dipper.rb b/lib/puppet/network/client/dipper.rb index 0ec7087e5..8616d4f73 100644 --- a/lib/puppet/network/client/dipper.rb +++ b/lib/puppet/network/client/dipper.rb @@ -2,7 +2,7 @@ class Puppet::Network::Client::Dipper < Puppet::Network::Client @handler = Puppet::Network::Handler.handler(:filebucket) @drivername = :Bucket - + attr_accessor :name # Create our bucket client diff --git a/lib/puppet/network/format_handler.rb b/lib/puppet/network/format_handler.rb index e03432858..0a7e9dcad 100644 --- a/lib/puppet/network/format_handler.rb +++ b/lib/puppet/network/format_handler.rb @@ -96,7 +96,7 @@ module Puppet::Network::FormatHandler end def supported_formats - result = format_handler.formats.collect { |f| format_handler.format(f) }.find_all { |f| f.supported?(self) }.collect { |f| f.name }.sort do |a, b| + result = format_handler.formats.collect { |f| format_handler.format(f) }.find_all { |f| f.supported?(self) }.collect { |f| f.name }.sort do |a, b| # It's an inverse sort -- higher weight formats go first. format_handler.format(b).weight <=> format_handler.format(a).weight end diff --git a/lib/puppet/network/handler/filebucket.rb b/lib/puppet/network/handler/filebucket.rb index 38ef7f3f2..4973886f7 100755 --- a/lib/puppet/network/handler/filebucket.rb +++ b/lib/puppet/network/handler/filebucket.rb @@ -129,7 +129,7 @@ class Puppet::Network::Handler # :nodoc: File.open(bfile) { |of| contents = of.read } - + if client return Base64.encode64(contents) else diff --git a/lib/puppet/network/handler/fileserver.rb b/lib/puppet/network/handler/fileserver.rb index 50e2614aa..6bc6d9d4a 100755 --- a/lib/puppet/network/handler/fileserver.rb +++ b/lib/puppet/network/handler/fileserver.rb @@ -53,7 +53,7 @@ class Puppet::Network::Handler mount = Mount.new(MODULES) mount.allow("*") @mounts[MODULES] = mount - + Puppet.debug "No file server configuration file; autocreating #{PLUGINS} mount with default permissions" mount = PluginMount.new(PLUGINS) mount.allow("*") @@ -145,7 +145,7 @@ class Puppet::Network::Handler desc.collect { |sub| sub.join("\t") }.join("\n") end - + def local? self.local end @@ -349,14 +349,14 @@ class Puppet::Network::Handler mount.allow("*") newmounts[MODULES] = mount end - + unless newmounts[PLUGINS] Puppet.debug "No #{PLUGINS} mount given; autocreating with default permissions" mount = PluginMount.new(PLUGINS) mount.allow("*") newmounts[PLUGINS] = mount end - + unless newmounts[PLUGINS].valid? Puppet.debug "No path given for #{PLUGINS} mount; creating a special PluginMount" # We end up here if the user has specified access rules for @@ -372,7 +372,7 @@ class Puppet::Network::Handler ) newmounts[PLUGINS] = mount end - + # Verify each of the mounts are valid. # We let the check raise an error, so that it can raise an error # pointing to the specific problem. @@ -433,7 +433,7 @@ class Puppet::Network::Handler # Create a map for a specific client. def clientmap(client) { - "h" => client.sub(/\..*$/, ""), + "h" => client.sub(/\..*$/, ""), "H" => client, "d" => client.sub(/[^.]+\./, "") # domain name } @@ -454,7 +454,7 @@ class Puppet::Network::Handler end path.gsub(/%(.)/) do |v| key = $1 - if key == "%" + if key == "%" "%" else map[key] || v @@ -698,7 +698,7 @@ class Puppet::Network::Handler # A special mount class specifically for the plugins mount -- just # has some magic to effectively do a union mount of the 'plugins' # directory of all modules. - # + # class PluginMount < Mount def path(client) '' @@ -719,7 +719,7 @@ class Puppet::Network::Handler def mod_file_path(mod, relpath, client = nil) File.join(mod, PLUGINS, relpath) end - + def file_path(relpath, client = nil) return nil unless mod = valid_modules(client).find { |m| m.plugin(relpath) } mod.plugin(relpath) @@ -746,7 +746,7 @@ class Puppet::Network::Handler def valid_modules(client) Puppet::Node::Environment.new.modules.find_all { |mod| mod.exist? } end - + def add_to_filetree(f, filetree) first, rest = f.split(File::SEPARATOR, 2) end diff --git a/lib/puppet/network/handler/master.rb b/lib/puppet/network/handler/master.rb index 0d36c1e88..e21e1e6e3 100644 --- a/lib/puppet/network/handler/master.rb +++ b/lib/puppet/network/handler/master.rb @@ -74,7 +74,7 @@ class Puppet::Network::Handler end end - # + # def decode_facts(facts) if @local # we don't need to do anything, since we should already diff --git a/lib/puppet/network/handler/report.rb b/lib/puppet/network/handler/report.rb index b92b77ea5..8cfd8d83d 100755 --- a/lib/puppet/network/handler/report.rb +++ b/lib/puppet/network/handler/report.rb @@ -79,7 +79,7 @@ class Puppet::Network::Handler # Handle the parsing of the reports attribute. def reports - # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com] + # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com] x = Puppet[:reports].gsub(/(^\s+)|(\s+$)/, '').split(/\s*,\s*/) end end diff --git a/lib/puppet/network/handler/resource.rb b/lib/puppet/network/handler/resource.rb index 54391c3de..6f8d3df0a 100755 --- a/lib/puppet/network/handler/resource.rb +++ b/lib/puppet/network/handler/resource.rb @@ -7,7 +7,7 @@ class Puppet::Network::Handler desc "An interface for interacting with client-based resources that can be used for querying or managing remote machines without using Puppet's central server tools. - + The ``describe`` and ``list`` methods return TransBuckets containing TransObject instances (``describe`` returns a single TransBucket), and the ``apply`` method accepts a TransBucket of TransObjects and @@ -44,7 +44,7 @@ class Puppet::Network::Handler # And then apply the catalog. This way we're reusing all # the code in there. It should probably just be separated out, though. transaction = catalog.apply - + # And then clean up catalog.clear(true) @@ -173,14 +173,14 @@ class Puppet::Network::Handler end # Deal with ignore parameters. - def handleignore(children, path, ignore) - ignore.each { |ignore| + def handleignore(children, path, ignore) + ignore.each { |ignore| Dir.glob(File.join(path,ignore), File::FNM_DOTMATCH) { |match| children.delete(File.basename(match)) - } + } } return children - end + end def to_s "resource" diff --git a/lib/puppet/network/http.rb b/lib/puppet/network/http.rb index 844af909f..ee6b70422 100644 --- a/lib/puppet/network/http.rb +++ b/lib/puppet/network/http.rb @@ -7,7 +7,7 @@ module Puppet::Network::HTTP when :mongrel raise ArgumentError, "Mongrel is not installed on this platform" unless Puppet.features.mongrel? require 'puppet/network/http/mongrel' - return Puppet::Network::HTTP::Mongrel + return Puppet::Network::HTTP::Mongrel else raise ArgumentError, "Unknown HTTP server name [#{kind}]" end diff --git a/lib/puppet/network/http/handler.rb b/lib/puppet/network/http/handler.rb index 679bb8dcd..9528d39a6 100644 --- a/lib/puppet/network/http/handler.rb +++ b/lib/puppet/network/http/handler.rb @@ -165,7 +165,7 @@ module Puppet::Network::HTTP::Handler def path(request) raise NotImplementedError - end + end def request_key(request) raise NotImplementedError diff --git a/lib/puppet/network/http/mongrel.rb b/lib/puppet/network/http/mongrel.rb index 356402545..6c39bb37f 100644 --- a/lib/puppet/network/http/mongrel.rb +++ b/lib/puppet/network/http/mongrel.rb @@ -6,7 +6,7 @@ class Puppet::Network::HTTP::Mongrel def initialize(args = {}) @listening = false end - + def listen(args = {}) raise ArgumentError, ":protocols must be specified." if !args[:protocols] or args[:protocols].empty? raise ArgumentError, ":address must be specified." unless args[:address] @@ -15,26 +15,26 @@ class Puppet::Network::HTTP::Mongrel @protocols = args[:protocols] @xmlrpc_handlers = args[:xmlrpc_handlers] - @server = Mongrel::HttpServer.new(args[:address], args[:port]) + @server = Mongrel::HttpServer.new(args[:address], args[:port]) setup_handlers @listening = true @server.run end - + def unlisten raise "Mongrel server is not listening" unless listening? @server.stop @server = nil @listening = false end - + def listening? @listening end - + private - + def setup_handlers # Register our REST support at / klass = class_for_protocol(:rest) @@ -49,7 +49,7 @@ class Puppet::Network::HTTP::Mongrel def setup_xmlrpc_handlers @server.register('/RPC2', Puppet::Network::HTTPServer::Mongrel.new(@xmlrpc_handlers)) end - + def class_for_protocol(protocol) return Puppet::Network::HTTP::MongrelREST if protocol.to_sym == :rest raise ArgumentError, "Unknown protocol [#{protocol}]." diff --git a/lib/puppet/network/http/mongrel/rest.rb b/lib/puppet/network/http/mongrel/rest.rb index fe3f51d35..369d4c6c4 100644 --- a/lib/puppet/network/http/mongrel/rest.rb +++ b/lib/puppet/network/http/mongrel/rest.rb @@ -30,7 +30,7 @@ class Puppet::Network::HTTP::MongrelREST < Mongrel::HttpHandler # what path was requested? def path(request) - # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com] + # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com] #x = '/' + request.params[Mongrel::Const::REQUEST_PATH] request.params[Mongrel::Const::REQUEST_PATH] end diff --git a/lib/puppet/network/http/webrick.rb b/lib/puppet/network/http/webrick.rb index 46735c0f5..a60a22ba1 100644 --- a/lib/puppet/network/http/webrick.rb +++ b/lib/puppet/network/http/webrick.rb @@ -12,19 +12,19 @@ class Puppet::Network::HTTP::WEBrick @listening = false @mutex = Mutex.new end - + def self.class_for_protocol(protocol) return Puppet::Network::HTTP::WEBrickREST if protocol.to_sym == :rest raise "Unknown protocol [#{protocol}]." end - + def listen(args = {}) raise ArgumentError, ":protocols must be specified." if !args[:protocols] or args[:protocols].empty? raise ArgumentError, ":address must be specified." unless args[:address] raise ArgumentError, ":port must be specified." unless args[:port] - + @protocols = args[:protocols] - @xmlrpc_handlers = args[:xmlrpc_handlers] + @xmlrpc_handlers = args[:xmlrpc_handlers] arguments = {:BindAddress => args[:address], :Port => args[:port]} arguments.merge!(setup_logger) @@ -35,12 +35,12 @@ class Puppet::Network::HTTP::WEBrick setup_handlers @mutex.synchronize do - raise "WEBrick server is already listening" if @listening + raise "WEBrick server is already listening" if @listening @listening = true @thread = Thread.new { @server.start } end end - + def unlisten @mutex.synchronize do raise "WEBrick server is not listening" unless @listening @@ -50,7 +50,7 @@ class Puppet::Network::HTTP::WEBrick @listening = false end end - + def listening? @mutex.synchronize do @listening @@ -110,7 +110,7 @@ class Puppet::Network::HTTP::WEBrick end private - + def setup_handlers # Set up the new-style protocols. klass = self.class.class_for_protocol(:rest) diff --git a/lib/puppet/network/http_pool.rb b/lib/puppet/network/http_pool.rb index 9430457bb..b1206f7f9 100644 --- a/lib/puppet/network/http_pool.rb +++ b/lib/puppet/network/http_pool.rb @@ -10,7 +10,7 @@ module Puppet::Network::HttpPool include Puppet::Util::Cacher private - + cached_attr(:http_cache) { Hash.new } end diff --git a/lib/puppet/network/http_server/mongrel.rb b/lib/puppet/network/http_server/mongrel.rb index 382b4dc58..a10a42928 100644 --- a/lib/puppet/network/http_server/mongrel.rb +++ b/lib/puppet/network/http_server/mongrel.rb @@ -3,7 +3,7 @@ # Author: Manuel Holtgrewe <purestorm at ggnore.net> # # Copyright (c) 2006 Manuel Holtgrewe, 2007 Luke Kanies -# +# # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including @@ -11,10 +11,10 @@ # distribute, sublicense, and/or sell copies of the Software, and to # permit persons to whom the Software is furnished to do so, subject to # the following conditions: -# +# # The above copyright notice and this permission notice shall be # included in all copies or substantial portions of the Software. -# +# # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -113,7 +113,7 @@ module Puppet::Network end end end - + private def client_info(request) @@ -144,7 +144,7 @@ module Puppet::Network def parse_content_type(str) a, *b = str.split(";") return a.strip, *b - end + end end end diff --git a/lib/puppet/network/http_server/webrick.rb b/lib/puppet/network/http_server/webrick.rb index 0e835d057..a863d3a20 100644 --- a/lib/puppet/network/http_server/webrick.rb +++ b/lib/puppet/network/http_server/webrick.rb @@ -18,7 +18,7 @@ module Puppet include Puppet::SSLCertificates::Support # Read the CA cert and CRL and populate an OpenSSL::X509::Store - # with them, with flags appropriate for checking client + # with them, with flags appropriate for checking client # certificates for revocation def x509store if Puppet[:cacrl] == 'false' diff --git a/lib/puppet/network/rest_authorization.rb b/lib/puppet/network/rest_authorization.rb index 1294a3dd1..5dd4fb5e6 100644 --- a/lib/puppet/network/rest_authorization.rb +++ b/lib/puppet/network/rest_authorization.rb @@ -16,7 +16,7 @@ module Puppet::Network @authconfig end - # Verify that our client has access. + # Verify that our client has access. def check_authorization(request) authconfig.allowed?(request) end diff --git a/lib/puppet/network/rights.rb b/lib/puppet/network/rights.rb index 14b171081..e8267c927 100755 --- a/lib/puppet/network/rights.rb +++ b/lib/puppet/network/rights.rb @@ -42,7 +42,7 @@ class Rights res = :nomatch right = @rights.find do |acl| found = false - # an acl can return :dunno, which means "I'm not qualified to answer your question, + # 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) diff --git a/lib/puppet/network/server.rb b/lib/puppet/network/server.rb index 701be54ca..f21254be9 100644 --- a/lib/puppet/network/server.rb +++ b/lib/puppet/network/server.rb @@ -83,7 +83,7 @@ class Puppet::Network::Server @routes[name.to_sym] = true end end - + # Unregister Indirector handlers. def unregister(*indirections) raise "Cannot unregister indirections while server is listening." if listening? @@ -92,7 +92,7 @@ class Puppet::Network::Server indirections.flatten.each do |i| raise(ArgumentError, "Indirection [%s] is unknown." % i) unless @routes[i.to_sym] end - + indirections.flatten.each do |i| @routes.delete(i.to_sym) end @@ -106,7 +106,7 @@ class Puppet::Network::Server @xmlrpc_routes[name.to_sym] = true end end - + # Unregister xmlrpc handlers. def unregister_xmlrpc(*namespaces) raise "Cannot unregister xmlrpc handlers while server is listening." if listening? @@ -115,7 +115,7 @@ class Puppet::Network::Server namespaces.flatten.each do |i| raise(ArgumentError, "XMLRPC handler '%s' is unknown." % i) unless @xmlrpc_routes[i.to_sym] end - + namespaces.flatten.each do |i| @xmlrpc_routes.delete(i.to_sym) end @@ -124,19 +124,19 @@ class Puppet::Network::Server def listening? @listening end - + def listen raise "Cannot listen -- already listening." if listening? @listening = true http_server.listen(:address => address, :port => port, :handlers => @routes.keys, :xmlrpc_handlers => @xmlrpc_routes.keys, :protocols => protocols) end - + def unlisten raise "Cannot unlisten -- not currently listening." unless listening? - http_server.unlisten + http_server.unlisten @listening = false end - + def http_server_class http_server_class_by_type(@server_type) end @@ -152,11 +152,11 @@ class Puppet::Network::Server end private - + def http_server @http_server ||= http_server_class.new end - + def http_server_class_by_type(kind) Puppet::Network::HTTP.server_class_by_type(kind) end diff --git a/lib/puppet/network/xmlrpc/client.rb b/lib/puppet/network/xmlrpc/client.rb index 678ab6c00..ee2c008eb 100644 --- a/lib/puppet/network/xmlrpc/client.rb +++ b/lib/puppet/network/xmlrpc/client.rb @@ -82,7 +82,7 @@ module Puppet::Network if detail.message.include?(str) Puppet.warning "Certificate validation failed; consider using the certname configuration option" end - end + end raise XMLRPCClientError, "Certificates were not trusted: %s" % detail end @@ -90,7 +90,7 @@ module Puppet::Network if detail.message.to_s =~ /^Wrong size\. Was \d+, should be \d+$/ Puppet.warning "XMLRPC returned wrong size. Retrying." return :retry - end + end Puppet.err "Could not call %s.%s: %s" % [namespace, method, detail.inspect] error = XMLRPCClientError.new(detail.to_s) error.set_backtrace detail.backtrace @@ -107,7 +107,7 @@ module Puppet::Network if detail.message.include?(str) Puppet.warning "Certificate validation failed; consider using the certname configuration option" end - end + end raise XMLRPCClientError, "Certificates were not trusted: %s" % detail end @@ -185,7 +185,7 @@ module Puppet::Network ) @http = Puppet::Network::HttpPool.http_instance(@host, @port) end - + # Get rid of our existing connection, replacing it with a new one. # This should only happen if we lose our connection somehow (e.g., an EPIPE) # or we've just downloaded certs and we need to create new http instances @@ -197,7 +197,7 @@ module Puppet::Network @http = nil self.http # force a new one end - + def start begin @http.start unless @http.started? diff --git a/lib/puppet/network/xmlrpc/webrick_servlet.rb b/lib/puppet/network/xmlrpc/webrick_servlet.rb index 9a46ffb7c..ec64c1c60 100644 --- a/lib/puppet/network/xmlrpc/webrick_servlet.rb +++ b/lib/puppet/network/xmlrpc/webrick_servlet.rb @@ -42,7 +42,7 @@ module Puppet::Network::XMLRPC # we need to pass a ClientRequest object to process() so we can do # authorization. It's the only way to stay thread-safe. def service(request, response) - if @valid_ip + if @valid_ip raise WEBrick::HTTPStatus::Forbidden unless @valid_ip.any? { |ip| request.peeraddr[3] =~ ip } end @@ -51,9 +51,9 @@ module Puppet::Network::XMLRPC "unsupported method `#{request.request_method}'." end - if parse_content_type(request['Content-type']).first != "text/xml" + if parse_content_type(request['Content-type']).first != "text/xml" raise WEBrick::HTTPStatus::BadRequest - end + end length = (request['Content-length'] || 0).to_i @@ -66,14 +66,14 @@ module Puppet::Network::XMLRPC end resp = process(data, client_request(request)) - if resp.nil? or resp.size <= 0 + if resp.nil? or resp.size <= 0 raise WEBrick::HTTPStatus::InternalServerError end response.status = 200 response['Content-Length'] = resp.size response['Content-Type'] = "text/xml; charset=utf-8" - response.body = resp + response.body = resp end private @@ -97,7 +97,7 @@ module Puppet::Network::XMLRPC if cert = request.client_cert nameary = cert.subject.to_a.find { |ary| ary[0] == "CN" - } + } if nameary.nil? Puppet.warning "Could not retrieve server name from cert" diff --git a/lib/puppet/parameter.rb b/lib/puppet/parameter.rb index ae152de56..c594ed5f4 100644 --- a/lib/puppet/parameter.rb +++ b/lib/puppet/parameter.rb @@ -64,7 +64,7 @@ class Puppet::Parameter end private - + # A standard way of converting all of our values, so we're always # comparing apples to apples. def convert(value) @@ -130,7 +130,7 @@ class Puppet::Parameter if value = @strings.find { |v| v.match?(test_value) } return value end - + # Then look for a regex match @regexes.find { |v| v.match?(test_value) } end @@ -158,7 +158,7 @@ class Puppet::Parameter # * <tt>:event</tt>: The event that should be returned when this value is set. # * <tt>:call</tt>: When to call any associated block. The default value # is ``instead``, which means to call the value instead of calling the - # provider. You can also specify ``before`` or ``after``, which will + # provider. You can also specify ``before`` or ``after``, which will # call both the block and the provider, according to the order you specify # (the ``first`` refers to when the block is called, not the provider). def newvalue(name, options = {}, &block) diff --git a/lib/puppet/parser/ast/astarray.rb b/lib/puppet/parser/ast/astarray.rb index 8f09aa922..9b59d196a 100644 --- a/lib/puppet/parser/ast/astarray.rb +++ b/lib/puppet/parser/ast/astarray.rb @@ -19,7 +19,7 @@ class Puppet::Parser::AST # Make a new array, so we don't have to deal with the details of # flattening and such items = [] - + # First clean out any AST::ASTArrays @children.each { |child| if child.instance_of?(AST::ASTArray) diff --git a/lib/puppet/parser/ast/boolean_operator.rb b/lib/puppet/parser/ast/boolean_operator.rb index c3b5c7d41..160e0e69e 100644 --- a/lib/puppet/parser/ast/boolean_operator.rb +++ b/lib/puppet/parser/ast/boolean_operator.rb @@ -16,7 +16,7 @@ class Puppet::Parser::AST def evaluate(scope) # evaluate the first operand, should return a boolean value lval = @lval.safeevaluate(scope) - + # return result # lazy evaluate right operand case @operator @@ -27,8 +27,8 @@ class Puppet::Parser::AST else # false and false == false false end - when "or"; - if Puppet::Parser::Scope.true?(lval) + when "or"; + if Puppet::Parser::Scope.true?(lval) true else rval = @rval.safeevaluate(scope) diff --git a/lib/puppet/parser/ast/casestatement.rb b/lib/puppet/parser/ast/casestatement.rb index 73fbdcf1e..072747932 100644 --- a/lib/puppet/parser/ast/casestatement.rb +++ b/lib/puppet/parser/ast/casestatement.rb @@ -17,7 +17,7 @@ class Puppet::Parser::AST retvalue = nil found = false - + # Iterate across the options looking for a match. default = nil @options.each { |option| diff --git a/lib/puppet/parser/ast/collexpr.rb b/lib/puppet/parser/ast/collexpr.rb index 6ade58b7e..85bca583f 100644 --- a/lib/puppet/parser/ast/collexpr.rb +++ b/lib/puppet/parser/ast/collexpr.rb @@ -67,7 +67,7 @@ class CollExpr < AST::Branch else str = "(%s) %s (%s)" % [str1, oper, str2] end - + return str, code end diff --git a/lib/puppet/parser/ast/comparison_operator.rb b/lib/puppet/parser/ast/comparison_operator.rb index 3af86efea..0d2f8b16d 100644 --- a/lib/puppet/parser/ast/comparison_operator.rb +++ b/lib/puppet/parser/ast/comparison_operator.rb @@ -21,7 +21,7 @@ class Puppet::Parser::AST # convert to number if operands are number lval = Puppet::Parser::Scope.number?(lval) || lval rval = Puppet::Parser::Scope.number?(rval) || rval - + # return result unless @operator == '!=' lval.send(@operator,rval) diff --git a/lib/puppet/parser/ast/resource_defaults.rb b/lib/puppet/parser/ast/resource_defaults.rb index ed83d3573..3fde7ade2 100644 --- a/lib/puppet/parser/ast/resource_defaults.rb +++ b/lib/puppet/parser/ast/resource_defaults.rb @@ -2,7 +2,7 @@ require 'puppet/parser/ast/branch' class Puppet::Parser::AST # A statement syntactically similar to an ResourceDef, but uses a - # capitalized object type and cannot have a name. + # capitalized object type and cannot have a name. class ResourceDefaults < AST::Branch attr_accessor :type, :params diff --git a/lib/puppet/parser/ast/resource_override.rb b/lib/puppet/parser/ast/resource_override.rb index f8cf3a81e..5eac50982 100644 --- a/lib/puppet/parser/ast/resource_override.rb +++ b/lib/puppet/parser/ast/resource_override.rb @@ -34,7 +34,7 @@ class Puppet::Parser::AST # Now we just create a normal resource, but we call a very different # method on the scope. resource = [resource] unless resource.is_a?(Array) - + resource = resource.collect do |r| res = Puppet::Parser::Resource.new( :type => r.type, diff --git a/lib/puppet/parser/ast/resource_reference.rb b/lib/puppet/parser/ast/resource_reference.rb index e5e2dce99..5a521494f 100644 --- a/lib/puppet/parser/ast/resource_reference.rb +++ b/lib/puppet/parser/ast/resource_reference.rb @@ -25,7 +25,7 @@ class Puppet::Parser::AST def evaluate(scope) title = @title.safeevaluate(scope) title = [title] unless title.is_a?(Array) - + if @type.to_s.downcase == "class" resource_type = "class" title = title.collect { |t| qualified_class(scope, t) } diff --git a/lib/puppet/parser/ast/selector.rb b/lib/puppet/parser/ast/selector.rb index 399d405a3..ecad163d4 100644 --- a/lib/puppet/parser/ast/selector.rb +++ b/lib/puppet/parser/ast/selector.rb @@ -17,9 +17,9 @@ class Puppet::Parser::AST # Get our parameter. paramvalue = @param.safeevaluate(scope) - + sensitive = Puppet[:casesensitive] - + if ! sensitive and paramvalue.respond_to?(:downcase) paramvalue = paramvalue.downcase end diff --git a/lib/puppet/parser/functions.rb b/lib/puppet/parser/functions.rb index 0434e9b48..a0e629a5b 100644 --- a/lib/puppet/parser/functions.rb +++ b/lib/puppet/parser/functions.rb @@ -120,7 +120,7 @@ module Functions return false end end - + # Runs a newfunction to create a function for each of the log levels Puppet::Util::Log.levels.each do |level| diff --git a/lib/puppet/parser/functions/fqdn_rand.rb b/lib/puppet/parser/functions/fqdn_rand.rb index 2ae46de82..3741d2d32 100644 --- a/lib/puppet/parser/functions/fqdn_rand.rb +++ b/lib/puppet/parser/functions/fqdn_rand.rb @@ -1,6 +1,6 @@ -Puppet::Parser::Functions::newfunction(:fqdn_rand, :type => :rvalue, :doc => - "Generates random numbers based on the node's fqdn. The first argument - sets the range. The second argument specifies a number to add to the +Puppet::Parser::Functions::newfunction(:fqdn_rand, :type => :rvalue, :doc => + "Generates random numbers based on the node's fqdn. The first argument + sets the range. The second argument specifies a number to add to the seed and is optional.") do |args| require 'md5' max = args[0] diff --git a/lib/puppet/parser/functions/inline_template.rb b/lib/puppet/parser/functions/inline_template.rb index 289740873..b9547cac7 100644 --- a/lib/puppet/parser/functions/inline_template.rb +++ b/lib/puppet/parser/functions/inline_template.rb @@ -1,7 +1,7 @@ -Puppet::Parser::Functions::newfunction(:inline_template, :type => :rvalue, :doc => - "Evaluate a template string and return its value. See `the templating docs - </trac/puppet/wiki/PuppetTemplating>`_ for more information. Note that - if multiple template strings are specified, their output is all concatenated +Puppet::Parser::Functions::newfunction(:inline_template, :type => :rvalue, :doc => + "Evaluate a template string and return its value. See `the templating docs + </trac/puppet/wiki/PuppetTemplating>`_ for more information. Note that + if multiple template strings are specified, their output is all concatenated and returned as the output of the function.") do |vals| require 'erb' diff --git a/lib/puppet/parser/functions/regsubst.rb b/lib/puppet/parser/functions/regsubst.rb index 8a1a244ab..e6b98eb2c 100644 --- a/lib/puppet/parser/functions/regsubst.rb +++ b/lib/puppet/parser/functions/regsubst.rb @@ -1,7 +1,7 @@ module Puppet::Parser::Functions newfunction(:regsubst, :type => :rvalue, :doc => " - Perform regexp replacement on a string. + Perform regexp replacement on a string. - **Parameters** (in order): @@ -19,7 +19,7 @@ module Puppet::Parser::Functions - **G** Global replacement; all occurrences of the regexp in the 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: - + - **N** None - **E** EUC - **S** SJIS diff --git a/lib/puppet/parser/functions/template.rb b/lib/puppet/parser/functions/template.rb index 2eaace1d7..0a4cfc7aa 100644 --- a/lib/puppet/parser/functions/template.rb +++ b/lib/puppet/parser/functions/template.rb @@ -1,7 +1,7 @@ -Puppet::Parser::Functions::newfunction(:template, :type => :rvalue, :doc => - "Evaluate a template and return its value. See `the templating docs - </trac/puppet/wiki/PuppetTemplating>`_ for more information. Note that - if multiple templates are specified, their output is all concatenated +Puppet::Parser::Functions::newfunction(:template, :type => :rvalue, :doc => + "Evaluate a template and return its value. See `the templating docs + </trac/puppet/wiki/PuppetTemplating>`_ for more information. Note that + if multiple templates are specified, their output is all concatenated and returned as the output of the function.") do |vals| require 'erb' diff --git a/lib/puppet/parser/grammar.ra b/lib/puppet/parser/grammar.ra index 9da2999df..d7828d71a 100644 --- a/lib/puppet/parser/grammar.ra +++ b/lib/puppet/parser/grammar.ra @@ -471,10 +471,10 @@ else: # nothing # 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 @@ -525,10 +525,10 @@ expression: rvalue } | expression AND expression { result = ast AST::BooleanOperator, :operator => val[1], :lval => val[0], :rval => val[2] -} +} | expression OR expression { result = ast AST::BooleanOperator, :operator => val[1], :lval => val[0], :rval => val[2] -} +} | LPAREN expression RPAREN { result = val[1] } @@ -578,9 +578,9 @@ selector: selectlhand QMARK svalues { } svalues: selectval - | LBRACE sintvalues endcomma RBRACE { + | LBRACE sintvalues endcomma RBRACE { @lexer.commentpop - result = val[1] + result = val[1] } sintvalues: selectval @@ -670,7 +670,7 @@ classname: NAME # Multiple hostnames, as used for node names. These are all literal # strings, not AST objects. -hostnames: hostname +hostnames: hostname | hostnames COMMA hostname { result = val[0] result = [result] unless result.is_a?(Array) diff --git a/lib/puppet/parser/interpreter.rb b/lib/puppet/parser/interpreter.rb index c728b54a2..2e8924090 100644 --- a/lib/puppet/parser/interpreter.rb +++ b/lib/puppet/parser/interpreter.rb @@ -36,7 +36,7 @@ class Puppet::Parser::Interpreter # create our interpreter def initialize # The class won't always be defined during testing. - if Puppet[:storeconfigs] + if Puppet[:storeconfigs] if Puppet.features.rails? Puppet::Rails.init else diff --git a/lib/puppet/parser/lexer.rb b/lib/puppet/parser/lexer.rb index a7b87e6d1..8bbcb84fb 100644 --- a/lib/puppet/parser/lexer.rb +++ b/lib/puppet/parser/lexer.rb @@ -281,11 +281,11 @@ class Puppet::Parser::Lexer # 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| - next unless match_length = @scanner.match?(token.regex) - + next unless match_length = @scanner.match?(token.regex) + # We've found a longer match if match_length > length - value = @scanner.scan(token.regex) + value = @scanner.scan(token.regex) length = value.length matched_token = token end diff --git a/lib/puppet/parser/parser_support.rb b/lib/puppet/parser/parser_support.rb index 3a6853f27..1d81e6099 100644 --- a/lib/puppet/parser/parser_support.rb +++ b/lib/puppet/parser/parser_support.rb @@ -476,7 +476,7 @@ class Puppet::Parser::Parser private def check_and_add_to_watched_files(filename) - unless @files.include?(filename) + unless @files.include?(filename) @files[filename] = Puppet::Util::LoadedFile.new(filename) return true else diff --git a/lib/puppet/parser/resource.rb b/lib/puppet/parser/resource.rb index 17bf7867a..32ea4573c 100644 --- a/lib/puppet/parser/resource.rb +++ b/lib/puppet/parser/resource.rb @@ -285,7 +285,7 @@ class Puppet::Parser::Resource def to_ral to_resource.to_ral end - + private # Add default values from our definition. @@ -360,7 +360,7 @@ class Puppet::Parser::Resource def paramcheck(param) param = param.to_s # Now make sure it's a valid argument to our class. These checks - # are organized in order of commonhood -- most types, it's a valid + # are organized in order of commonhood -- most types, it's a valid # argument and paramcheck is enabled. if @ref.typeclass.validattr?(param) true diff --git a/lib/puppet/parser/resource/param.rb b/lib/puppet/parser/resource/param.rb index 0662ce953..f44d5a6e9 100644 --- a/lib/puppet/parser/resource/param.rb +++ b/lib/puppet/parser/resource/param.rb @@ -20,7 +20,7 @@ class Puppet::Parser::Resource::Param def line_to_i return line ? Integer(line) : nil end - + def to_s "%s => %s" % [self.name, self.value] end diff --git a/lib/puppet/parser/scope.rb b/lib/puppet/parser/scope.rb index b1f480ca6..0a182fe1d 100644 --- a/lib/puppet/parser/scope.rb +++ b/lib/puppet/parser/scope.rb @@ -49,7 +49,7 @@ class Puppet::Parser::Scope unless value.is_a?(Fixnum) or value.is_a?(Bignum) or value.is_a?(Float) or value.is_a?(String) return nil end - + if value.is_a?(String) if value =~ /^-?\d+(:?\.\d+|(:?\.\d+)?e\d+)$/ return value.to_f @@ -198,7 +198,7 @@ class Puppet::Parser::Scope else return @symtable[name] end - elsif self.parent + elsif self.parent return parent.lookupvar(name, usestring) elsif usestring return "" @@ -215,12 +215,12 @@ class Puppet::Parser::Scope target = parent.to_hash(recursive) end target ||= Hash.new - @symtable.keys.each { |name| + @symtable.keys.each { |name| value = @symtable[name] if value == :undef then target.delete(name) else - target[name] = value + target[name] = value end } return target @@ -301,7 +301,7 @@ class Puppet::Parser::Scope end raise error end - + unless append @symtable[name] = value else # append case @@ -322,7 +322,7 @@ class Puppet::Parser::Scope ss = StringScanner.new(string) out = "" while not ss.eos? - if ss.scan(/^\$\{((\w*::)*\w+)\}|^\$((\w*::)*\w+)/) + if ss.scan(/^\$\{((\w*::)*\w+)\}|^\$((\w*::)*\w+)/) # If it matches the backslash, then just retun the dollar sign. if ss.matched == '\\$' out << '$' @@ -357,7 +357,7 @@ class Puppet::Parser::Scope out << '$' elsif ss.scan(/^\\\n/) # an escaped carriage return next - else + else tmp = ss.scan(/[^\\$]+/) # Puppet.debug("Got other: pos:%d; m:%s" % [ss.pos, tmp]) unless tmp diff --git a/lib/puppet/parser/templatewrapper.rb b/lib/puppet/parser/templatewrapper.rb index 97b454569..b2eb3c422 100644 --- a/lib/puppet/parser/templatewrapper.rb +++ b/lib/puppet/parser/templatewrapper.rb @@ -91,7 +91,7 @@ class Puppet::Parser::TemplateWrapper # current object, making it possible to access them without conflict # to the regular methods. benchmark(:debug, "Bound template variables for #{template_source}") do - scope.to_hash.each { |name, value| + scope.to_hash.each { |name, value| if name.kind_of?(String) realname = name.gsub(/[^\w]/, "_") else diff --git a/lib/puppet/property.rb b/lib/puppet/property.rb index a144f28d0..487028ed2 100644 --- a/lib/puppet/property.rb +++ b/lib/puppet/property.rb @@ -76,7 +76,7 @@ class Puppet::Property < Puppet::Parameter # * <tt>:event</tt>: The event that should be returned when this value is set. # * <tt>:call</tt>: When to call any associated block. The default value # is ``instead``, which means to call the value instead of calling the - # provider. You can also specify ``before`` or ``after``, which will + # provider. You can also specify ``before`` or ``after``, which will # call both the block and the provider, according to the order you specify # (the ``first`` refers to when the block is called, not the provider). def self.newvalue(name, options = {}, &block) @@ -152,7 +152,7 @@ class Puppet::Property < Puppet::Parameter # Figure out which event to return. def event(name, event = nil) if value_event = self.class.value_option(name, :event) - return value_event + return value_event end if event and event.is_a?(Symbol) @@ -176,7 +176,7 @@ class Puppet::Property < Puppet::Parameter return event end - + attr_reader :shadow # initialize our property @@ -294,7 +294,7 @@ class Puppet::Property < Puppet::Parameter call = self.class.value_option(name, :call) || :none if call == :instead - event, tmp = call_valuemethod(name, value) + event, tmp = call_valuemethod(name, value) elsif call == :none if @resource.provider call_provider(value) diff --git a/lib/puppet/provider.rb b/lib/puppet/provider.rb index ce195c086..1f13538af 100644 --- a/lib/puppet/provider.rb +++ b/lib/puppet/provider.rb @@ -31,7 +31,7 @@ class Puppet::Provider # LAK 2007-05-09: Keep the model stuff around for backward compatibility attr_reader :model attr_accessor :resource - + def self.command(name) name = symbolize(name) @@ -123,7 +123,7 @@ class Puppet::Provider # will catch it, if so. return execute(cmd) end - + # And then define an instance method that just calls the class method. # We need both, so both instances and classes can easily run the commands. unless method_defined? name diff --git a/lib/puppet/provider/computer/computer.rb b/lib/puppet/provider/computer/computer.rb index f3e526105..73f2d2b89 100644 --- a/lib/puppet/provider/computer/computer.rb +++ b/lib/puppet/provider/computer/computer.rb @@ -5,10 +5,10 @@ Puppet::Type.type(:computer).provide :directoryservice, :parent => Puppet::Provi 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. @@ -16,7 +16,7 @@ Puppet::Type.type(:computer).provide :directoryservice, :parent => Puppet::Provi 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/confine/variable.rb b/lib/puppet/provider/confine/variable.rb index 9bef69412..8067ae954 100644 --- a/lib/puppet/provider/confine/variable.rb +++ b/lib/puppet/provider/confine/variable.rb @@ -57,6 +57,6 @@ class Puppet::Provider::Confine::Variable < Puppet::Provider::Confine end def test_value - setting? ? Puppet.settings[name] : facter_value + setting? ? Puppet.settings[name] : facter_value end end diff --git a/lib/puppet/provider/cron/crontab.rb b/lib/puppet/provider/cron/crontab.rb index d0f139cab..c05dacb47 100755 --- a/lib/puppet/provider/cron/crontab.rb +++ b/lib/puppet/provider/cron/crontab.rb @@ -126,7 +126,7 @@ Puppet::Type.type(:cron).provide(:crontab, next if (record[field] == resource.value(field)) #Puppet.info "Did not match %s: %s vs %s" % # [field, resource.value(field).inspect, record[field].inspect] - matched = false + matched = false break end return resource if matched @@ -145,7 +145,7 @@ Puppet::Type.type(:cron).provide(:crontab, if record[:name] name = record[:name] record[:skip] = true - + # Start collecting env values envs = [] end @@ -185,7 +185,7 @@ Puppet::Type.type(:cron).provide(:crontab, # on my machine). This is my attempt to fix it so the TZ lines don't # multiply. if text =~ /(^TZ=.+\n)/ - tz = $1 + tz = $1 text.sub!(tz, '') text = tz + text end diff --git a/lib/puppet/provider/group/directoryservice.rb b/lib/puppet/provider/group/directoryservice.rb index 63c100a58..d02273476 100644 --- a/lib/puppet/provider/group/directoryservice.rb +++ b/lib/puppet/provider/group/directoryservice.rb @@ -18,7 +18,7 @@ Puppet::Type.type(:group).provide :directoryservice, :parent => Puppet::Provider desc "Group management using DirectoryService on OS X. " - + commands :dscl => "/usr/bin/dscl" confine :operatingsystem => :darwin defaultfor :operatingsystem => :darwin diff --git a/lib/puppet/provider/group/ldap.rb b/lib/puppet/provider/group/ldap.rb index 94d61f5fb..6d5f663ed 100644 --- a/lib/puppet/provider/group/ldap.rb +++ b/lib/puppet/provider/group/ldap.rb @@ -7,7 +7,7 @@ Puppet::Type.type(:group).provide :ldap, :parent => Puppet::Provider::Ldap do ldap-related settings, including ``ldapbase``. You will also almost definitely need settings for ``ldapuser`` and ``ldappassword``, so that your clients can write to ldap. - + Note that this provider will automatically generate a GID for you if you do not specify one, but it is a potentially expensive operation, as it iterates across all existing groups to pick the appropriate next one. @@ -24,7 +24,7 @@ Puppet::Type.type(:group).provide :ldap, :parent => Puppet::Provider::Ldap do # Find the next gid after the current largest gid. provider = self - manager.generates(:gidNumber).with do + manager.generates(:gidNumber).with do largest = 500 if existing = provider.manager.search existing.each do |hash| diff --git a/lib/puppet/provider/host/parsed.rb b/lib/puppet/provider/host/parsed.rb index dfa60cc70..e6381384e 100644 --- a/lib/puppet/provider/host/parsed.rb +++ b/lib/puppet/provider/host/parsed.rb @@ -14,8 +14,8 @@ Puppet::Type.type(:host).provide(:parsed, ) do confine :exists => hosts - text_line :comment, :match => /^#/ - text_line :blank, :match => /^\s*$/ + text_line :comment, :match => /^#/ + text_line :blank, :match => /^\s*$/ record_line :parsed, :fields => %w{ip name alias}, :optional => %w{alias}, diff --git a/lib/puppet/provider/ldap.rb b/lib/puppet/provider/ldap.rb index 970ac5202..be6683891 100644 --- a/lib/puppet/provider/ldap.rb +++ b/lib/puppet/provider/ldap.rb @@ -97,7 +97,7 @@ class Puppet::Provider::Ldap < Puppet::Provider result end - # Make a duplicate, so that we have a copy for comparison + # Make a duplicate, so that we have a copy for comparison # at the end. @ldap_properties = @property_hash.dup end diff --git a/lib/puppet/provider/macauthorization/macauthorization.rb b/lib/puppet/provider/macauthorization/macauthorization.rb index 759540cc0..58f12b94c 100644 --- a/lib/puppet/provider/macauthorization/macauthorization.rb +++ b/lib/puppet/provider/macauthorization/macauthorization.rb @@ -11,47 +11,47 @@ Puppet::Type.type(:macauthorization).provide :macauthorization, :parent => Puppe commands :security => "/usr/bin/security" commands :sw_vers => "/usr/bin/sw_vers" - + confine :operatingsystem => :darwin - + # This should be confined based on macosx_productversion once - # http://projects.reductivelabs.com/issues/show/1796 + # http://projects.reductivelabs.com/issues/show/1796 # is resolved. if FileTest.exists?("/usr/bin/sw_vers") product_version = sw_vers "-productVersion" - + confine :true => if /^10.5/.match(product_version) or /^10.6/.match(product_version) true end end - + defaultfor :operatingsystem => :darwin - + AuthDB = "/etc/authorization" - + @rights = {} @rules = {} @parsed_auth_db = {} @comment = "" # Not implemented yet. Is there any real need to? - + # This map exists due to the use of hyphens and reserved words in # the authorization schema. PuppetToNativeAttributeMap = { :allow_root => "allow-root", - :authenticate_user => "authenticate-user", + :authenticate_user => "authenticate-user", :auth_class => "class", :k_of_n => "k-of-n", :session_owner => "session-owner", } - + class << self attr_accessor :parsed_auth_db attr_accessor :rights attr_accessor :rules attr_accessor :comments # Not implemented yet. - + def prefetch(resources) self.populate_rules_rights end - + def instances if self.parsed_auth_db == {} self.prefetch(nil) @@ -60,7 +60,7 @@ Puppet::Type.type(:macauthorization).provide :macauthorization, :parent => Puppe new(:name => k) end end - + def populate_rules_rights auth_plist = Plist::parse_xml(AuthDB) if not auth_plist @@ -71,21 +71,21 @@ Puppet::Type.type(:macauthorization).provide :macauthorization, :parent => Puppe self.parsed_auth_db = self.rights.dup self.parsed_auth_db.merge!(self.rules.dup) end - + end - + # standard required provider instance methods - + def initialize(resource) if self.class.parsed_auth_db == {} self.class.prefetch(resource) end super end - - + + def create - # we just fill the @property_hash in here and let the flush method + # we just fill the @property_hash in here and let the flush method # deal with it rather than repeating code. new_values = {} validprops = Puppet::Type.type(resource.class.name).validproperties @@ -109,7 +109,7 @@ Puppet::Type.type(:macauthorization).provide :macauthorization, :parent => Puppe raise Puppet::Error.new("Must specify auth_type when destroying.") end end - + def exists? if self.class.parsed_auth_db.has_key?(resource[:name]) return true @@ -117,8 +117,8 @@ Puppet::Type.type(:macauthorization).provide :macauthorization, :parent => Puppe return false end end - - + + def flush # deletion happens in the destroy methods if resource[:ensure] != :absent @@ -133,14 +133,14 @@ Puppet::Type.type(:macauthorization).provide :macauthorization, :parent => Puppe @property_hash.clear end end - - + + # utility methods below - + def destroy_right security "authorizationdb", :remove, resource[:name] end - + def destroy_rule authdb = Plist::parse_xml(AuthDB) authdb_rules = authdb["rules"].dup @@ -153,13 +153,13 @@ Puppet::Type.type(:macauthorization).provide :macauthorization, :parent => Puppe end end end - + def flush_right - # first we re-read the right just to make sure we're in sync for - # values that weren't specified in the manifest. As we're supplying - # the whole plist when specifying the right it seems safest to be + # first we re-read the right just to make sure we're in sync for + # values that weren't specified in the manifest. As we're supplying + # the whole plist when specifying the right it seems safest to be # paranoid given the low cost of quering the db once more. - cmds = [] + cmds = [] cmds << :security << "authorizationdb" << "read" << resource[:name] output = execute(cmds, :combine => false) current_values = Plist::parse_xml(output) @@ -168,12 +168,12 @@ Puppet::Type.type(:macauthorization).provide :macauthorization, :parent => Puppe end specified_values = convert_plist_to_native_attributes(@property_hash) - # take the current values, merge the specified values to obtain a + # take the current values, merge the specified values to obtain a # complete description of the new values. new_values = current_values.merge(specified_values) set_right(resource[:name], new_values) end - + def flush_rule authdb = Plist::parse_xml(AuthDB) authdb_rules = authdb["rules"].dup @@ -185,7 +185,7 @@ Puppet::Type.type(:macauthorization).provide :macauthorization, :parent => Puppe new_values = current_values.merge(specified_values) set_rule(resource[:name], new_values) end - + def set_right(name, values) # Both creates and modifies rights as it simply overwrites them. # The security binary only allows for writes using stdin, so we @@ -194,7 +194,7 @@ Puppet::Type.type(:macauthorization).provide :macauthorization, :parent => Puppe tmp = Tempfile.new('puppet_macauthorization') begin Plist::Emit.save_plist(values, tmp.path) - cmds = [] + cmds = [] cmds << :security << "authorizationdb" << "write" << name output = execute(cmds, :combine => false, :stdinfile => tmp.path.to_s) @@ -205,11 +205,11 @@ Puppet::Type.type(:macauthorization).provide :macauthorization, :parent => Puppe tmp.unlink end end - + def set_rule(name, values) - # Both creates and modifies rules as it overwrites the entry in the - # rules dictionary. Unfortunately the security binary doesn't - # support modifying rules at all so we have to twiddle the whole + # Both creates and modifies rules as it overwrites the entry in the + # rules dictionary. Unfortunately the security binary doesn't + # support modifying rules at all so we have to twiddle the whole # plist... :( See Apple Bug #6386000 values = convert_plist_to_native_attributes(values) authdb = Plist::parse_xml(AuthDB) @@ -221,11 +221,11 @@ Puppet::Type.type(:macauthorization).provide :macauthorization, :parent => Puppe raise Puppet::Error.new("Error writing to: #{AuthDB}") end end - + def convert_plist_to_native_attributes(propertylist) # This mainly converts the keys from the puppet attributes to the - # 'native' ones, but also enforces that the keys are all Strings - # rather than Symbols so that any merges of the resultant Hash are + # 'native' ones, but also enforces that the keys are all Strings + # rather than Symbols so that any merges of the resultant Hash are # sane. newplist = {} propertylist.each_pair do |key, value| @@ -241,13 +241,13 @@ Puppet::Type.type(:macauthorization).provide :macauthorization, :parent => Puppe end newplist end - + def retrieve_value(resource_name, attribute) - + if not self.class.parsed_auth_db.has_key?(resource_name) raise Puppet::Error.new("Cannot find #{resource_name} in auth db") end - + if PuppetToNativeAttributeMap.has_key?(attribute) native_attribute = PuppetToNativeAttributeMap[attribute] else @@ -270,13 +270,13 @@ Puppet::Type.type(:macauthorization).provide :macauthorization, :parent => Puppe return "" # so ralsh doesn't display it. end end - - + + # property methods below # # We define them all dynamically apart from auth_type which is a special # case due to not being in the actual authorization db schema. - + properties = [ :allow_root, :authenticate_user, :auth_class, :comment, :group, :k_of_n, :mechanisms, :rule, :session_owner, :shared, :timeout, :tries ] @@ -290,7 +290,7 @@ Puppet::Type.type(:macauthorization).provide :macauthorization, :parent => Puppe @property_hash[field] = value end end - + def auth_type if resource.should(:auth_type) != nil return resource.should(:auth_type) @@ -307,9 +307,9 @@ Puppet::Type.type(:macauthorization).provide :macauthorization, :parent => Puppe raise Puppet::Error.new("auth_type required for new resources.") end end - + def auth_type=(value) @property_hash[:auth_type] = value end - + end diff --git a/lib/puppet/provider/mailalias/aliases.rb b/lib/puppet/provider/mailalias/aliases.rb index f9217123e..f880ccea1 100755 --- a/lib/puppet/provider/mailalias/aliases.rb +++ b/lib/puppet/provider/mailalias/aliases.rb @@ -10,7 +10,7 @@ Puppet::Type.type(:mailalias).provide(:aliases, record_line :aliases, :fields => %w{name recipient}, :separator => /\s*:\s*/, :block_eval => :instance do def post_parse(record) - # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com] + # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com] # It's not sufficient to assign to an existing hash. recipient = record[:recipient].split(/\s*,\s*/).collect { |d| d.gsub(/^['"]|['"]$/, '') } record[:recipient] = recipient diff --git a/lib/puppet/provider/mcx/mcxcontent.rb b/lib/puppet/provider/mcx/mcxcontent.rb index b899aa108..002bb0dae 100644 --- a/lib/puppet/provider/mcx/mcxcontent.rb +++ b/lib/puppet/provider/mcx/mcxcontent.rb @@ -2,8 +2,8 @@ # 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 +# 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, @@ -66,7 +66,7 @@ Puppet::Type.type(:mcx).provide :mcxcontent, :parent => Puppet::Provider do content = mcxexport(ds_type, ds_name) if content.empty? Puppet.debug "/#{TypeMap[ds_type]}/#{ds_name} has no MCX data." - else + else # This node has MCX data. rsrc = self.new(:name => "/#{TypeMap[ds_type]}/#{ds_name}", :ds_type => ds_type, diff --git a/lib/puppet/provider/mount/netinfo.rb b/lib/puppet/provider/mount/netinfo.rb index 2cb125776..1cc6c4476 100644 --- a/lib/puppet/provider/mount/netinfo.rb +++ b/lib/puppet/provider/mount/netinfo.rb @@ -9,21 +9,21 @@ require 'puppet/provider/mount' # not to work currently." # commands :nireport => "nireport", :niutil => "niutil" # commands :mountcmd => "mount", :umount => "umount", :df => "df" -# +# # options :device, :key => "name" # options :name, :key => "dir" # options :dump, :key => "dump_freq" # options :pass, :key => "passno" # options :fstype, :key => "vfstype" # options :options, :key => "opts" -# +# # defaultfor :operatingsystem => :darwin -# +# # def initialize(resource) # warning "The NetInfo mount provider is highly experimental. Use at your own risk." # super # end -# +# # def mount # cmd = [] # if opts = @resource.should(:options) diff --git a/lib/puppet/provider/nameservice.rb b/lib/puppet/provider/nameservice.rb index 31572cc47..d7c54c1fc 100644 --- a/lib/puppet/provider/nameservice.rb +++ b/lib/puppet/provider/nameservice.rb @@ -128,7 +128,7 @@ class Puppet::Provider::NameService < Puppet::Provider @ops[property.name] || ("-" + property.name) end end - + # Autogenerate a value. Mostly used for uid/gid, but also used heavily # with netinfo, because netinfo is stupid. def autogen(field) @@ -159,7 +159,7 @@ class Puppet::Provider::NameService < Puppet::Provider else raise Puppet::DevError, "Invalid resource name %s" % resource end - + # Make sure we don't use the same value multiple times if defined? @@prevauto @@prevauto += 1 @@ -244,7 +244,7 @@ class Puppet::Provider::NameService < Puppet::Provider @objectinfo = nil end end - + # Now convert our Etc struct into a hash. if @objectinfo return info2hash(@objectinfo) diff --git a/lib/puppet/provider/nameservice/directoryservice.rb b/lib/puppet/provider/nameservice/directoryservice.rb index cd1e442d5..be0c2972c 100644 --- a/lib/puppet/provider/nameservice/directoryservice.rb +++ b/lib/puppet/provider/nameservice/directoryservice.rb @@ -30,7 +30,7 @@ class DirectoryService < Puppet::Provider::NameService attr_writer :macosx_version_major end - + # JJM 2007-07-24: Not yet sure what initvars() does. I saw it in netinfo.rb # I do know, however, that it makes methods "work" =) # e.g. addcmd isn't available if this method call isn't present. @@ -39,7 +39,7 @@ class DirectoryService < Puppet::Provider::NameService # of methods. If I put initvars after commands, confine and defaultfor, # then getinfo is called from the parent class, not this class. initvars() - + commands :dscl => "/usr/bin/dscl" commands :dseditgroup => "/usr/sbin/dseditgroup" commands :sw_vers => "/usr/bin/sw_vers" @@ -80,27 +80,27 @@ class DirectoryService < Puppet::Provider::NameService :ip_address => 'IPAddress', :members => 'GroupMembership', } - + @@password_hash_dir = "/var/db/shadow/hash" - + def self.instances # JJM Class method that provides an array of instance objects of this # type. # JJM: Properties are dependent on the Puppet::Type we're managine. type_property_array = [:name] + @resource_type.validproperties - + # Create a new instance of this Puppet::Type for each object present # on the system. list_all_present.collect do |name_string| self.new(single_report(name_string, *type_property_array)) end end - + def self.get_ds_path # JJM: 2007-07-24 This method dynamically returns the DS path we're concerned with. # For example, if we're working with an user type, this will be /Users # with a group type, this will be /Groups. - # @ds_path is an attribute of the class itself. + # @ds_path is an attribute of the class itself. if defined? @ds_path return @ds_path end @@ -110,7 +110,7 @@ class DirectoryService < Puppet::Provider::NameService # Puppet::Type this class object is providing for. return @resource_type.name.to_s.capitalize + "s" end - + def self.get_macosx_version_major if defined? @macosx_version_major return @macosx_version_major @@ -140,7 +140,7 @@ class DirectoryService < Puppet::Provider::NameService end return dscl_output.split("\n") end - + def self.parse_dscl_url_data(dscl_output) # we need to construct a Hash from the dscl -url output to match # that returned by the dscl -plist output for 10.5+ clients. @@ -150,7 +150,7 @@ class DirectoryService < Puppet::Provider::NameService # b) if a line ends in a colon and the next line does start with # a space, then the second line is a value of the first. # c) (implied by (b)) keys don't start with spaces. - + dscl_plist = {} dscl_output.split("\n").inject([]) do |array, line| if line =~ /^\s+/ # it's a value @@ -180,11 +180,11 @@ class DirectoryService < Puppet::Provider::NameService end return dscl_plist end - + def self.parse_dscl_plist_data(dscl_output) return Plist.parse_xml(dscl_output) end - + def self.generate_attribute_hash(input_hash, *type_properties) attribute_hash = {} input_hash.keys().each do |key| @@ -208,37 +208,37 @@ class DirectoryService < Puppet::Provider::NameService end attribute_hash[@@ds_to_ns_attribute_map[ds_attribute]] = ds_value end - + # NBK: need to read the existing password here as it's not actually # stored in the user record. It is stored at a path that involves the - # UUID of the user record for non-Mobile local acccounts. + # UUID of the user record for non-Mobile local acccounts. # Mobile Accounts are out of scope for this provider for now if @resource_type.validproperties.include?(:password) attribute_hash[:password] = self.get_password(attribute_hash[:guid]) end return attribute_hash end - + def self.single_report(resource_name, *type_properties) # JJM 2007-07-24: # Given a the name of an object and a list of properties of that # object, return all property values in a hash. - # + # # This class method returns nil if the object doesn't exist # Otherwise, it returns a hash of the object properties. - + all_present_str_array = list_all_present() - + # NBK: shortcut the process if the resource is missing return nil unless all_present_str_array.include? resource_name - + dscl_vector = get_exec_preamble("-read", resource_name) begin dscl_output = execute(dscl_vector) rescue Puppet::ExecutionFailure => detail raise Puppet::Error, "Could not get report. command execution failed." end - + # Two code paths is ugly, but until we can drop 10.4 support we don't # have a lot of choice. Ultimately this should all be done using Ruby # to access the DirectoryService APIs directly, but that's simply not @@ -249,10 +249,10 @@ class DirectoryService < Puppet::Provider::NameService when "10.5", "10.6" dscl_plist = self.parse_dscl_plist_data(dscl_output) end - + return self.generate_attribute_hash(dscl_plist, *type_properties) end - + def self.get_exec_preamble(ds_action, resource_name = nil) # JJM 2007-07-24 # DSCL commands are often repetitive and contain the same positional @@ -285,7 +285,7 @@ class DirectoryService < Puppet::Provider::NameService # e.g. 'dscl / -create /Users/mccune' return command_vector end - + def self.set_password(resource_name, guid, password_hash) password_hash_file = "#{@@password_hash_dir}/#{guid}" begin @@ -293,7 +293,7 @@ class DirectoryService < Puppet::Provider::NameService rescue Errno::EACCES => detail raise Puppet::Error, "Could not write to password hash file: #{detail}" end - + # NBK: For shadow hashes, the user AuthenticationAuthority must contain a value of # ";ShadowHash;". The LKDC in 10.5 makes this more interesting though as it # will dynamically generate ;Kerberosv5;;username@LKDC:SHA1 attributes if @@ -302,12 +302,12 @@ class DirectoryService < Puppet::Provider::NameService # use other custom AuthenticationAuthority attributes without stomping on them. # # There is a potential problem here in that we're only doing this when setting - # the password, and the attribute could get modified at other times while the + # the password, and the attribute could get modified at other times while the # hash doesn't change and so this doesn't get called at all... but # without switching all the other attributes to merge instead of create I can't # see a simple enough solution for this that doesn't modify the user record # every single time. This should be a rather rare edge case. (famous last words) - + dscl_vector = self.get_exec_preamble("-merge", resource_name) dscl_vector << "AuthenticationAuthority" << ";ShadowHash;" begin @@ -316,7 +316,7 @@ class DirectoryService < Puppet::Provider::NameService raise Puppet::Error, "Could not set AuthenticationAuthority." end end - + def self.get_password(guid) password_hash = nil password_hash_file = "#{@@password_hash_dir}/#{guid}" @@ -352,9 +352,9 @@ class DirectoryService < Puppet::Provider::NameService next end end - end + end end - + def password=(passphrase) exec_arg_vector = self.class.get_exec_preamble("-read", @resource.name) exec_arg_vector << @@ns_to_ds_attribute_map[:guid] @@ -370,11 +370,11 @@ class DirectoryService < Puppet::Provider::NameService raise Puppet::Error, "Could not set %s on %s[%s]: %s" % [param, @resource.class.name, @resource.name, detail] end end - + # NBK: we override @parent.set as we need to execute a series of commands # to deal with array values, rather than the single command nameservice.rb # expects to be returned by modifycmd. Thus we don't bother defining modifycmd. - + def set(param, value) self.class.validate(param, value) current_members = @property_value_cache_hash[:members] @@ -385,7 +385,7 @@ class DirectoryService < Puppet::Provider::NameService if @resource[:auth_membership] and not current_members.nil? remove_unwanted_members(current_members, value) end - + # if they're not a member, make them one. add_members(current_members, value) else @@ -402,7 +402,7 @@ class DirectoryService < Puppet::Provider::NameService end end end - + # NBK: we override @parent.create as we need to execute a series of commands # to create objects with dscl, rather than the single command nameservice.rb # expects to be returned by addcmd. Thus we don't bother defining addcmd. @@ -411,7 +411,7 @@ class DirectoryService < Puppet::Provider::NameService info "already exists" return nil end - + # NBK: First we create the object with a known guid so we can set the contents # of the password hash if required # Shelling out sucks, but for a single use case it doesn't seem worth @@ -419,7 +419,7 @@ class DirectoryService < Puppet::Provider::NameService # This should be revisited if Puppet starts managing UUIDs for other platform # user records. guid = %x{/usr/bin/uuidgen}.chomp - + exec_arg_vector = self.class.get_exec_preamble("-create", @resource[:name]) exec_arg_vector << @@ns_to_ds_attribute_map[:guid] << guid begin @@ -428,11 +428,11 @@ class DirectoryService < Puppet::Provider::NameService raise Puppet::Error, "Could not set GeneratedUID for %s %s: %s" % [@resource.class.name, @resource.name, detail] end - + if value = @resource.should(:password) and value != "" self.class.set_password(@resource[:name], guid, value) end - + # Now we create all the standard properties Puppet::Type.type(@resource.class.name).validproperties.each do |property| next if property == :ensure @@ -454,7 +454,7 @@ class DirectoryService < Puppet::Provider::NameService end end end - + def remove_unwanted_members(current_members, new_members) current_members.each do |member| if not new_members.include?(member) @@ -467,7 +467,7 @@ class DirectoryService < Puppet::Provider::NameService end end end - + def add_members(current_members, new_members) new_members.each do |new_member| if current_members.nil? or not current_members.include?(new_member) @@ -480,20 +480,20 @@ class DirectoryService < Puppet::Provider::NameService end end end - + def deletecmd # JJM: Like addcmd, only called when deleting the object itself # Note, this isn't used to delete properties of the object, # at least that's how I understand it... self.class.get_exec_preamble("-delete", @resource[:name]) end - + def getinfo(refresh = false) - # JJM 2007-07-24: + # JJM 2007-07-24: # Override the getinfo method, which is also defined in nameservice.rb # This method returns and sets @infohash, which looks like: # (NetInfo provider, user type...) - # @infohash = {:comment=>"Jeff McCune", :home=>"/Users/mccune", + # @infohash = {:comment=>"Jeff McCune", :home=>"/Users/mccune", # :shell=>"/bin/zsh", :password=>"********", :uid=>502, :gid=>502, # :name=>"mccune"} # @@ -502,24 +502,24 @@ class DirectoryService < Puppet::Provider::NameService if refresh or (! defined?(@property_value_cache_hash) or ! @property_value_cache_hash) # JJM 2007-07-24: OK, there's a bit of magic that's about to # happen... Let's see how strong my grip has become... =) - # + # # self is a provider instance of some Puppet::Type, like # Puppet::Type::User::ProviderDirectoryservice for the case of the # user type and this provider. - # + # # self.class looks like "user provider directoryservice", if that # helps you ... - # + # # self.class.resource_type is a reference to the Puppet::Type class, # probably Puppet::Type::User or Puppet::Type::Group, etc... - # + # # self.class.resource_type.validproperties is a class method, # returning an Array of the valid properties of that specific # Puppet::Type. - # + # # So... something like [:comment, :home, :password, :shell, :uid, # :groups, :ensure, :gid] - # + # # Ultimately, we add :name to the list, delete :ensure from the # list, then report on the remaining list. Pretty whacky, ehh? type_properties = [:name] + self.class.resource_type.validproperties diff --git a/lib/puppet/provider/nameservice/netinfo.rb b/lib/puppet/provider/nameservice/netinfo.rb index 8de141068..ec79f1980 100644 --- a/lib/puppet/provider/nameservice/netinfo.rb +++ b/lib/puppet/provider/nameservice/netinfo.rb @@ -46,14 +46,14 @@ class NetInfo < Puppet::Provider::NameService noautogen end end - + def self.instances warnonce "The NetInfo provider is deprecated; use directoryservice instead" report(@resource_type.validproperties).collect do |hash| self.new(hash) end end - + # Convert a NetInfo line into a hash of data. def self.line2hash(line, params) values = line.split(/\t/) @@ -69,20 +69,20 @@ class NetInfo < Puppet::Provider::NameService end hash end - + # What field the value is stored under. def self.netinfokey(name) name = symbolize(name) self.option(name, :key) || name end - + # Retrieve the data, yo. # FIXME This should retrieve as much information as possible, # rather than retrieving it one at a time. def self.report(*params) dir = self.netinfodir() cmd = [command(:nireport), "/", "/%s" % dir] - + params.flatten! # We require the name in order to know if we match. There's no @@ -111,7 +111,7 @@ class NetInfo < Puppet::Provider::NameService line2hash(line, params) } end - + # How to add an object. def addcmd creatorcmd("-create") @@ -128,7 +128,7 @@ class NetInfo < Puppet::Provider::NameService def deletecmd creatorcmd("-destroy") end - + def destroy delete() end @@ -203,7 +203,7 @@ class NetInfo < Puppet::Provider::NameService def netinfokey(name) self.class.netinfokey(name) end - + # Get a report for a single resource, not the whole table def single_report(*properties) warnonce "The NetInfo provider is deprecated; use directoryservice instead" diff --git a/lib/puppet/provider/package/appdmg.rb b/lib/puppet/provider/package/appdmg.rb index 4b9730c1c..5d64effac 100644 --- a/lib/puppet/provider/package/appdmg.rb +++ b/lib/puppet/provider/package/appdmg.rb @@ -7,7 +7,7 @@ # and are easier to manage. # # Note: the 'apple' Provider checks for the package name -# in /L/Receipts. Since we possibly install multiple apps's from +# in /L/Receipts. Since we possibly install multiple apps's from # a single source, we treat the source .app.dmg file as the package name. # As a result, we store installed .app.dmg file names # in /var/db/.puppet_appdmg_installed_<name> @@ -37,7 +37,7 @@ Puppet::Type.type(:package).provide(:appdmg, :parent => Puppet::Provider::Packag new(:name => name, :provider => :appdmg, :ensure => :installed) end end - + def self.installapp(source, name, orig_source) appname = File.basename(source); ditto "--rsrc", source, "/Applications/#{appname}" @@ -64,7 +64,7 @@ Puppet::Type.type(:package).provide(:appdmg, :parent => Puppet::Provider::Packag cached_source = source end end - + begin open(cached_source) do |dmg| xml_str = hdiutil "mount", "-plist", "-nobrowse", "-readonly", "-mountrandom", "/tmp", dmg.path diff --git a/lib/puppet/provider/package/apt.rb b/lib/puppet/provider/package/apt.rb index ee645242e..7bbbcfe03 100755 --- a/lib/puppet/provider/package/apt.rb +++ b/lib/puppet/provider/package/apt.rb @@ -69,7 +69,7 @@ Puppet::Type.type(:package).provide :apt, :parent => :dpkg, :source => :dpkg do end cmd << :install << str - + aptget(*cmd) end @@ -93,7 +93,7 @@ Puppet::Type.type(:package).provide :apt, :parent => :dpkg, :source => :dpkg do self.info("Preseeding %s to debconf-set-selections" % response) preseed response - else + else self.info "No responsefile specified or non existant, not preseeding anything" end end diff --git a/lib/puppet/provider/package/aptrpm.rb b/lib/puppet/provider/package/aptrpm.rb index 9b3e7f015..0471fb915 100644 --- a/lib/puppet/provider/package/aptrpm.rb +++ b/lib/puppet/provider/package/aptrpm.rb @@ -36,7 +36,7 @@ Puppet::Type.type(:package).provide :aptrpm, :parent => :rpm, :source => :rpm do cmd = %w{-q -y} cmd << 'install' << str - + aptget(*cmd) end diff --git a/lib/puppet/provider/package/dpkg.rb b/lib/puppet/provider/package/dpkg.rb index 67d31a592..a4c398282 100755 --- a/lib/puppet/provider/package/dpkg.rb +++ b/lib/puppet/provider/package/dpkg.rb @@ -8,7 +8,7 @@ Puppet::Type.type(:package).provide :dpkg, :parent => Puppet::Provider::Package commands :dpkg => "/usr/bin/dpkg" commands :dpkg_deb => "/usr/bin/dpkg-deb" commands :dpkgquery => "/usr/bin/dpkg-query" - + def self.instances packages = [] @@ -62,7 +62,7 @@ Puppet::Type.type(:package).provide :dpkg, :parent => Puppet::Provider::Package unless file = @resource[:source] raise ArgumentError, "You cannot install dpkg packages without a source" end - + args = [] if @resource[:configfiles] == :keep diff --git a/lib/puppet/provider/package/fink.rb b/lib/puppet/provider/package/fink.rb index 1a779f083..5d9e86313 100755 --- a/lib/puppet/provider/package/fink.rb +++ b/lib/puppet/provider/package/fink.rb @@ -3,7 +3,7 @@ Puppet::Type.type(:package).provide :fink, :parent => :dpkg, :source => :dpkg do include Puppet::Util::Package desc "Package management via ``fink``." - + commands :fink => "/sw/bin/fink" commands :aptget => "/sw/bin/apt-get" commands :aptcache => "/sw/bin/apt-cache" @@ -40,7 +40,7 @@ Puppet::Type.type(:package).provide :fink, :parent => :dpkg, :source => :dpkg do keep = "" cmd << :install << str - + finkcmd(cmd) end @@ -64,7 +64,7 @@ Puppet::Type.type(:package).provide :fink, :parent => :dpkg, :source => :dpkg do self.info("Preseeding %s to debconf-set-selections" % response) preseed response - else + else self.info "No responsefile specified or non existant, not preseeding anything" end end diff --git a/lib/puppet/provider/package/freebsd.rb b/lib/puppet/provider/package/freebsd.rb index 18df015fd..f4ca35466 100755 --- a/lib/puppet/provider/package/freebsd.rb +++ b/lib/puppet/provider/package/freebsd.rb @@ -8,7 +8,7 @@ Puppet::Type.type(:package).provide :freebsd, :parent => :openbsd do commands :pkginfo => "/usr/sbin/pkg_info", :pkgadd => "/usr/sbin/pkg_add", :pkgdelete => "/usr/sbin/pkg_delete" - + confine :operatingsystem => :freebsd def self.listcmd diff --git a/lib/puppet/provider/package/gem.rb b/lib/puppet/provider/package/gem.rb index 2f1aebcb3..56350fd36 100755 --- a/lib/puppet/provider/package/gem.rb +++ b/lib/puppet/provider/package/gem.rb @@ -90,7 +90,7 @@ Puppet::Type.type(:package).provide :gem, :parent => Puppet::Provider::Package d command << uri.path when 'puppet' # we don't support puppet:// URLs (yet) - raise Puppet::Error.new("puppet:// URLs are not supported as gem sources") + raise Puppet::Error.new("puppet:// URLs are not supported as gem sources") else # interpret it as a gem repository command << "--source" << "#{source}" << resource[:name] diff --git a/lib/puppet/provider/package/hpux.rb b/lib/puppet/provider/package/hpux.rb index 202fa24c9..0c4fb36f0 100644 --- a/lib/puppet/provider/package/hpux.rb +++ b/lib/puppet/provider/package/hpux.rb @@ -13,19 +13,19 @@ Puppet::Type.type(:package).provide :hpux, :parent => Puppet::Provider::Package confine :operatingsystem => "hp-ux" defaultfor :operatingsystem => "hp-ux" - + def self.instances # TODO: This is very hard on HP-UX! [] end - + # source and name are required def install raise ArgumentError, "source must be provided to install HP-UX packages" unless resource[:source] args = standard_args + ["-s", resource[:source], resource[:name]] swinstall(*args) end - + def query begin swlist resource[:name] @@ -34,12 +34,12 @@ Puppet::Type.type(:package).provide :hpux, :parent => Puppet::Provider::Package {:ensure => :absent} end end - + def uninstall args = standard_args + [resource[:name]] swremove(*args) end - + def standard_args return ["-x", "mount_all_filesystems=false"] end diff --git a/lib/puppet/provider/package/pkgdmg.rb b/lib/puppet/provider/package/pkgdmg.rb index 3b32fcb6a..8f11a0aa3 100644 --- a/lib/puppet/provider/package/pkgdmg.rb +++ b/lib/puppet/provider/package/pkgdmg.rb @@ -30,7 +30,7 @@ require 'facter/util/plist' Puppet::Type.type(:package).provide :pkgdmg, :parent => Puppet::Provider::Package do desc "Package management based on Apple's Installer.app and DiskUtility.app. This package works by checking the contents of a DMG image for Apple pkg or mpkg files. Any number of pkg or mpkg files may exist in the root directory of the DMG file system. Sub directories are not checked for packages. See `the wiki docs </trac/puppet/wiki/DmgPackages>` for more detail." - + confine :exists => "/Library/Receipts" commands :installer => "/usr/sbin/installer" commands :hdiutil => "/usr/bin/hdiutil" @@ -65,7 +65,7 @@ Puppet::Type.type(:package).provide :pkgdmg, :parent => Puppet::Provider::Packag t.print "source: '#{orig_source}'\n" end end - + def self.installpkgdmg(source, name) unless source =~ /\.dmg$/i raise Puppet::Error.new("Mac OS X PKG DMG's must specificy a source string ending in .dmg") @@ -82,7 +82,7 @@ Puppet::Type.type(:package).provide :pkgdmg, :parent => Puppet::Provider::Packag cached_source = source end end - + begin File.open(cached_source) do |dmg| xml_str = hdiutil "mount", "-plist", "-nobrowse", "-readonly", "-noidme", "-mountrandom", "/tmp", dmg.path diff --git a/lib/puppet/provider/package/ports.rb b/lib/puppet/provider/package/ports.rb index 96ef3f042..21696721e 100755 --- a/lib/puppet/provider/package/ports.rb +++ b/lib/puppet/provider/package/ports.rb @@ -53,7 +53,7 @@ Puppet::Type.type(:package).provide :ports, :parent => :freebsd, :source => :fre name, version = $1, $2 - if match == "=" or match == ">" + if match == "=" or match == ">" # we're up to date or more recent return version end diff --git a/lib/puppet/provider/package/rpm.rb b/lib/puppet/provider/package/rpm.rb index 09f78bf72..a9da43fac 100755 --- a/lib/puppet/provider/package/rpm.rb +++ b/lib/puppet/provider/package/rpm.rb @@ -49,12 +49,12 @@ Puppet::Type.type(:package).provide :rpm, :source => :rpm, :parent => Puppet::Pr end # Find the fully versioned package name and the version alone. Returns - # a hash with entries :instance => fully versioned package name, and + # a hash with entries :instance => fully versioned package name, and # :ensure => version-release def query #NOTE: Prior to a fix for issue 1243, this method potentially returned a cached value #IF YOU CALL THIS METHOD, IT WILL CALL RPM - #Use get(:property) to check if cached values are available + #Use get(:property) to check if cached values are available cmd = ["-q", @resource[:name], "--nosignature", "--nodigest", "--qf", "#{NEVRAFORMAT}\n"] begin @@ -62,7 +62,7 @@ Puppet::Type.type(:package).provide :rpm, :source => :rpm, :parent => Puppet::Pr rescue Puppet::ExecutionFailure return nil end - + # FIXME: We could actually be getting back multiple packages # for multilib @property_hash.update(self.class.nevra_to_hash(output)) @@ -75,7 +75,7 @@ Puppet::Type.type(:package).provide :rpm, :source => :rpm, :parent => Puppet::Pr unless source = @resource[:source] @resource.fail "RPMs must specify a package source" end - + cmd = [command(:rpm), "-q", "--qf", "#{NEVRAFORMAT}\n", "-p", "#{@resource[:source]}"] h = self.class.nevra_to_hash(execfail(cmd, Puppet::Error)) return h[:ensure] @@ -86,7 +86,7 @@ Puppet::Type.type(:package).provide :rpm, :source => :rpm, :parent => Puppet::Pr unless source = @resource[:source] @resource.fail "RPMs must specify a package source" end - # RPM gets pissy if you try to install an already + # RPM gets pissy if you try to install an already # installed package if @resource.should(:ensure) == @property_hash[:ensure] or @resource.should(:ensure) == :latest && @property_hash[:ensure] == latest diff --git a/lib/puppet/provider/package/sun.rb b/lib/puppet/provider/package/sun.rb index d916eb78c..f72738e2f 100755 --- a/lib/puppet/provider/package/sun.rb +++ b/lib/puppet/provider/package/sun.rb @@ -121,7 +121,7 @@ Puppet::Type.type(:package).provide :sun, :parent => Puppet::Provider::Package d raise Puppet::Error, "Sun packages must specify a package source" end cmd = [] - + if @resource[:adminfile] cmd << "-a" << @resource[:adminfile] end diff --git a/lib/puppet/provider/package/yum.rb b/lib/puppet/provider/package/yum.rb index 581a446ea..6fdff6997 100755 --- a/lib/puppet/provider/package/yum.rb +++ b/lib/puppet/provider/package/yum.rb @@ -4,7 +4,7 @@ Puppet::Type.type(:package).provide :yum, :parent => :rpm, :source => :rpm do has_feature :versionable commands :yum => "yum", :rpm => "rpm", :python => "python" - + YUMHELPER = File::join(File::dirname(__FILE__), "yumhelper.py") attr_accessor :latest_info @@ -100,7 +100,7 @@ Puppet::Type.type(:package).provide :yum, :parent => :rpm, :source => :rpm do # Install in yum can be used for update, too self.install end - + def purge yum "-y", :erase, @resource[:name] end diff --git a/lib/puppet/provider/package/yumhelper.py b/lib/puppet/provider/package/yumhelper.py index 7d73cdd23..e7b5fe13d 100644 --- a/lib/puppet/provider/package/yumhelper.py +++ b/lib/puppet/provider/package/yumhelper.py @@ -64,7 +64,7 @@ def shell_out(): return WEXITSTATUS(rc) else: # Exit code is None (0), no updates waiting so don't both parsing output - return 0 + return 0 # Yum prints a line of hyphens (old versions) or a blank line between # headers and package data, so skip everything before them diff --git a/lib/puppet/provider/selmodule/semodule.rb b/lib/puppet/provider/selmodule/semodule.rb index 498136691..2b65c0d4a 100644 --- a/lib/puppet/provider/selmodule/semodule.rb +++ b/lib/puppet/provider/selmodule/semodule.rb @@ -45,7 +45,7 @@ Puppet::Type.type(:selmodule).provide(:semodule) do end return :false end - + def syncversion= (dosync) begin execoutput("#{command(:semodule)} --upgrade #{selmod_name_to_filename}") @@ -115,13 +115,13 @@ Puppet::Type.type(:selmodule).provide(:semodule) do # At last! the version - v = selmod_readnext(mod) + v = selmod_readnext(mod) self.debug "file version #{v}" return v end - def selmodversion_loaded + def selmodversion_loaded lines = () begin execpipe("#{command(:semodule)} --list") do |output| diff --git a/lib/puppet/provider/service/daemontools.rb b/lib/puppet/provider/service/daemontools.rb index 67520da06..63666e149 100644 --- a/lib/puppet/provider/service/daemontools.rb +++ b/lib/puppet/provider/service/daemontools.rb @@ -11,7 +11,7 @@ Puppet::Type.type(:service).provide :daemontools, :parent => :base do * /etc/service * /var/lib/svscan - The daemon directory should be placed in a directory that can be + The daemon directory should be placed in a directory that can be by default in: * /var/lib/service @@ -43,7 +43,7 @@ Puppet::Type.type(:service).provide :daemontools, :parent => :base do class << self attr_writer :defpath - + # Determine the daemon path. def defpath unless defined?(@defpath) and @defpath @@ -111,10 +111,10 @@ Puppet::Type.type(:service).provide :daemontools, :parent => :base do def daemon File.join(resource[:path], resource[:name]) end - + def status begin - output = svstat self.service + output = svstat self.service if output =~ /:\s+up \(/ return :running end diff --git a/lib/puppet/provider/service/freebsd.rb b/lib/puppet/provider/service/freebsd.rb index 356feeee4..baf5e5a11 100644 --- a/lib/puppet/provider/service/freebsd.rb +++ b/lib/puppet/provider/service/freebsd.rb @@ -5,7 +5,7 @@ Puppet::Type.type(:service).provide :freebsd, :parent => :init do Uses ``rc.conf.d`` for service enabling and disabling. " - + confine :operatingsystem => [:freebsd, :netbsd, :openbsd] defaultfor :operatingsystem => :freebsd @@ -15,7 +15,7 @@ Puppet::Type.type(:service).provide :freebsd, :parent => :init do def self.defpath superclass.defpath end - + # remove service file from rc.conf.d to disable it def disable rcfile = File.join(@@rcconf_dir, @model[:name]) @@ -23,7 +23,7 @@ Puppet::Type.type(:service).provide :freebsd, :parent => :init do File.delete(rcfile) end end - + # if the service file exists in rc.conf.d then it's already enabled def enabled? rcfile = File.join(@@rcconf_dir, @model[:name]) @@ -33,7 +33,7 @@ Puppet::Type.type(:service).provide :freebsd, :parent => :init do return :false end - + # enable service by creating a service file under rc.conf.d with the # proper contents def enable @@ -43,7 +43,7 @@ Puppet::Type.type(:service).provide :freebsd, :parent => :init do rcfile = File.join(@@rcconf_dir, @model[:name]) open(rcfile, 'w') { |f| f << "%s_enable=\"YES\"\n" % @model[:name] } end - + # Override stop/start commands to use one<cmd>'s and the avoid race condition # where provider trys to stop/start the service before it is enabled def startcmd diff --git a/lib/puppet/provider/service/gentoo.rb b/lib/puppet/provider/service/gentoo.rb index bf9c3a173..ed643119d 100644 --- a/lib/puppet/provider/service/gentoo.rb +++ b/lib/puppet/provider/service/gentoo.rb @@ -38,7 +38,7 @@ Puppet::Type.type(:service).provide :gentoo, :parent => :init do 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)/ + if output =~ /^\s*#{@resource[:name]}\s*\|\s*(boot|default)/ return :true else return :false diff --git a/lib/puppet/provider/service/init.rb b/lib/puppet/provider/service/init.rb index f70b12c42..1bf11fbba 100755 --- a/lib/puppet/provider/service/init.rb +++ b/lib/puppet/provider/service/init.rb @@ -29,21 +29,21 @@ Puppet::Type.type(:service).provide :init, :parent => :base do # List all services of this type. def self.instances self.defpath = [self.defpath] unless self.defpath.is_a? Array - + instances = [] - + self.defpath.each do |path| unless FileTest.directory?(path) Puppet.debug "Service path %s does not exist" % path next end - + check = [:ensure] - + if public_method_defined? :enabled? check << :enable end - + Dir.entries(path).each do |name| fullpath = File.join(path, name) next if name =~ /^\./ diff --git a/lib/puppet/provider/service/launchd.rb b/lib/puppet/provider/service/launchd.rb index ee0dac6a5..16fc55bba 100644 --- a/lib/puppet/provider/service/launchd.rb +++ b/lib/puppet/provider/service/launchd.rb @@ -2,29 +2,29 @@ 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. - + 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. - + 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 @@ -37,12 +37,12 @@ Puppet::Type.type(:service).provide :launchd, :parent => :base do " commands :launchctl => "/bin/launchctl" - + defaultfor :operatingsystem => :darwin confine :operatingsystem => :darwin - + has_feature :enableable - + Launchd_Paths = ["/Library/LaunchAgents", "/Library/LaunchDaemons", "/System/Library/LaunchAgents", @@ -129,7 +129,7 @@ Puppet::Type.type(:service).provide :launchd, :parent => :base do job_path, job_plist = plist_from_label(resource[:name]) did_enable_job = false cmds = [] - cmds << :launchctl << :load + cmds << :launchctl << :load if self.enabled? == :false # launchctl won't load disabled jobs cmds << "-w" did_enable_job = true @@ -143,7 +143,7 @@ Puppet::Type.type(:service).provide :launchd, :parent => :base do # As load -w clears the Disabled flag, we need to add it in after if did_enable_job and resource[:enable] == :false self.disable - end + end end @@ -151,7 +151,7 @@ Puppet::Type.type(:service).provide :launchd, :parent => :base do job_path, job_plist = plist_from_label(resource[:name]) did_disable_job = false cmds = [] - cmds << :launchctl << :unload + cmds << :launchctl << :unload if self.enabled? == :true # keepalive jobs can't be stopped without disabling cmds << "-w" did_disable_job = true diff --git a/lib/puppet/provider/service/redhat.rb b/lib/puppet/provider/service/redhat.rb index aec49a583..63a545dd9 100755 --- a/lib/puppet/provider/service/redhat.rb +++ b/lib/puppet/provider/service/redhat.rb @@ -8,7 +8,7 @@ Puppet::Type.type(:service).provide :redhat, :parent => :init do " commands :chkconfig => "/sbin/chkconfig", :service => "/sbin/service" - + defaultfor :operatingsystem => [:redhat, :fedora, :suse, :centos, :sles, :oel, :ovm] def self.defpath @@ -51,7 +51,7 @@ Puppet::Type.type(:service).provide :redhat, :parent => :init do [self.name, detail] end end - + def restart if @resource[:hasrestart] == :true service(@resource[:name], "restart") diff --git a/lib/puppet/provider/service/runit.rb b/lib/puppet/provider/service/runit.rb index 0deeb0f22..45713b270 100644 --- a/lib/puppet/provider/service/runit.rb +++ b/lib/puppet/provider/service/runit.rb @@ -11,7 +11,7 @@ Puppet::Type.type(:service).provide :runit, :parent => :daemontools do * /var/service * /etc/service - The daemon directory should be placed in a directory that can be + The daemon directory should be placed in a directory that can be by default in: * /etc/sv diff --git a/lib/puppet/provider/sshkey/parsed.rb b/lib/puppet/provider/sshkey/parsed.rb index 57cfb5b67..0dc791bff 100755 --- a/lib/puppet/provider/sshkey/parsed.rb +++ b/lib/puppet/provider/sshkey/parsed.rb @@ -28,7 +28,7 @@ Puppet::Type.type(:sshkey).provide(:parsed, :pre_gen => proc { |hash| if hash[:alias] names = [hash[:name], hash[:alias]].flatten - + hash[:name] = [hash[:name], hash[:alias]].flatten.join(",") hash.delete(:alias) end diff --git a/lib/puppet/provider/user/directoryservice.rb b/lib/puppet/provider/user/directoryservice.rb index 706840822..63e3a35e1 100644 --- a/lib/puppet/provider/user/directoryservice.rb +++ b/lib/puppet/provider/user/directoryservice.rb @@ -20,15 +20,15 @@ Puppet::Type.type(:user).provide :directoryservice, :parent => Puppet::Provider: commands :dscl => "/usr/bin/dscl" confine :operatingsystem => :darwin defaultfor :operatingsystem => :darwin - + # JJM: DirectoryService can manage passwords. # This needs to be a special option to dscl though (-passwd) has_feature :manages_passwords - + # JJM: comment matches up with the /etc/passwd concept of an user options :comment, :key => "realname" options :password, :key => "passwd" - + autogen_defaults :home => "/var/empty", :shell => "/usr/bin/false" verify :gid, "GID must be an integer" do |value| @@ -38,11 +38,11 @@ Puppet::Type.type(:user).provide :directoryservice, :parent => Puppet::Provider: verify :uid, "UID must be an integer" do |value| value.is_a? Integer end - + def autogen_comment return @resource[:name].capitalize end - + # The list of all groups the user is a member of. Different # user mgmt systems will need to override this method. # JJM: FIXME: Override this method... @@ -57,7 +57,7 @@ Puppet::Type.type(:user).provide :directoryservice, :parent => Puppet::Provider: # next unless members # next if members =~ /NoValue/ # members = members.split(",") - # + # # if members.include? user # groups << name # end @@ -80,12 +80,12 @@ Puppet::Type.type(:user).provide :directoryservice, :parent => Puppet::Provider: # end # # Get just the groups we need to modify # diff = groups - (@is || []) - # + # # data = {} # open("| #{command(:nireport)} / /groups name users") do |file| # file.each do |line| # name, members = line.split(/\s+/) - # + # # if members.nil? or members =~ /NoValue/ # data[name] = [] # else @@ -94,7 +94,7 @@ Puppet::Type.type(:user).provide :directoryservice, :parent => Puppet::Provider: # end # end # end - # + # # user = @resource[:name] # data.each do |name, members| # if members.include? user and groups.include? name @@ -112,6 +112,6 @@ Puppet::Type.type(:user).provide :directoryservice, :parent => Puppet::Provider: # end # end end - - + + end diff --git a/lib/puppet/provider/user/hpux.rb b/lib/puppet/provider/user/hpux.rb index 76549ec69..db8dd194e 100644 --- a/lib/puppet/provider/user/hpux.rb +++ b/lib/puppet/provider/user/hpux.rb @@ -3,7 +3,7 @@ Puppet::Type.type(:user).provide :hpuxuseradd, :parent => :useradd do defaultfor :operatingsystem => "hp-ux" confine :operatingsystem => "hp-ux" - + commands :modify => "/usr/sam/lbin/usermod.sam", :delete => "/usr/sam/lbin/userdel.sam", :add => "/usr/sbin/useradd" options :comment, :method => :gecos options :groups, :flag => "-G" diff --git a/lib/puppet/provider/user/ldap.rb b/lib/puppet/provider/user/ldap.rb index 2e200a88e..4ac18030a 100644 --- a/lib/puppet/provider/user/ldap.rb +++ b/lib/puppet/provider/user/ldap.rb @@ -6,7 +6,7 @@ Puppet::Type.type(:user).provide :ldap, :parent => Puppet::Provider::Ldap do including ``ldapbase``. You will also almost definitely need settings for ``ldapuser`` and ``ldappassword``, so that your clients can write to ldap. - + Note that this provider will automatically generate a UID for you if you do not specify one, but it is a potentially expensive operation, as it iterates across all existing users to pick the appropriate next @@ -33,7 +33,7 @@ Puppet::Type.type(:user).provide :ldap, :parent => Puppet::Provider::Ldap do # Find the next uid after the current largest uid. provider = self - manager.generates(:uidNumber).with do + manager.generates(:uidNumber).with do largest = 500 if existing = provider.manager.search existing.each do |hash| diff --git a/lib/puppet/provider/user/netinfo.rb b/lib/puppet/provider/user/netinfo.rb index 22fb95056..9ec7c89ab 100644 --- a/lib/puppet/provider/user/netinfo.rb +++ b/lib/puppet/provider/user/netinfo.rb @@ -39,7 +39,7 @@ Puppet::Type.type(:user).provide :netinfo, :parent => Puppet::Provider::NameServ # user mgmt systems will need to override this method. def groups warnonce "The NetInfo provider is deprecated; use directoryservice instead" - + groups = [] user = @resource[:name] @@ -64,7 +64,7 @@ Puppet::Type.type(:user).provide :netinfo, :parent => Puppet::Provider::NameServ # of the groups and add us to them. def groups=(groups) warnonce "The NetInfo provider is deprecated; use directoryservice instead" - + case groups when Fixnum groups = [groups.to_s] diff --git a/lib/puppet/provider/zone/solaris.rb b/lib/puppet/provider/zone/solaris.rb index 9d6e24338..778b9e0a1 100644 --- a/lib/puppet/provider/zone/solaris.rb +++ b/lib/puppet/provider/zone/solaris.rb @@ -27,7 +27,7 @@ Puppet::Type.type(:zone).provide(:solaris) do end def self.instances - # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com] + # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com] x = adm(:list, "-cp").split("\n").collect do |line| new(line2hash(line)) end diff --git a/lib/puppet/rails.rb b/lib/puppet/rails.rb index 1a240e206..fc8eacd68 100644 --- a/lib/puppet/rails.rb +++ b/lib/puppet/rails.rb @@ -31,13 +31,13 @@ module Puppet::Rails puts detail.backtrace end raise Puppet::Error, "Could not connect to database: %s" % detail - end + end end # The arguments for initializing the database connection. def self.database_arguments adapter = Puppet[:dbadapter] - + args = {:adapter => adapter, :log_level => Puppet[:rails_loglevel]} case adapter @@ -48,7 +48,7 @@ module Puppet::Rails args[:username] = Puppet[:dbuser] unless Puppet[:dbuser].empty? args[:password] = Puppet[:dbpassword] unless Puppet[:dbpassword].empty? args[:database] = Puppet[:dbname] - + socket = Puppet[:dbsocket] args[:socket] = socket unless socket.empty? else @@ -93,7 +93,7 @@ module Puppet::Rails unless ActiveRecord::Base.connection.tables.include?("resources") raise Puppet::Error, "Database has problems, can't migrate." - end + end Puppet.notice "Migrating" @@ -122,9 +122,9 @@ module Puppet::Rails puts detail.backtrace end raise Puppet::Error, "Could not connect to database: %s" % detail - end + end - ActiveRecord::Base.connection.tables.each do |t| + ActiveRecord::Base.connection.tables.each do |t| ActiveRecord::Base.connection.drop_table t end end diff --git a/lib/puppet/rails/database/001_add_created_at_to_all_tables.rb b/lib/puppet/rails/database/001_add_created_at_to_all_tables.rb index d1035b0db..138f9f151 100644 --- a/lib/puppet/rails/database/001_add_created_at_to_all_tables.rb +++ b/lib/puppet/rails/database/001_add_created_at_to_all_tables.rb @@ -2,16 +2,16 @@ class AddCreatedAtToAllTables < ActiveRecord::Migration def self.up ActiveRecord::Base.connection.tables.each do |t| unless ActiveRecord::Base.connection.columns(t).collect {|c| c.name}.include?("created_at") - add_column t.to_s, :created_at, :datetime - end - end + add_column t.to_s, :created_at, :datetime + end + end end def self.down ActiveRecord::Base.connection.tables.each do |t| unless ActiveRecord::Base.connection.columns(t).collect {|c| c.name}.include?("created_at") remove_column t.to_s, :created_at - end - end + end + end end end diff --git a/lib/puppet/rails/database/002_remove_duplicated_index_on_all_tables.rb b/lib/puppet/rails/database/002_remove_duplicated_index_on_all_tables.rb index 3873a13e2..050ca7f43 100644 --- a/lib/puppet/rails/database/002_remove_duplicated_index_on_all_tables.rb +++ b/lib/puppet/rails/database/002_remove_duplicated_index_on_all_tables.rb @@ -4,7 +4,7 @@ class RemoveDuplicatedIndexOnAllTables < ActiveRecord::Migration if ActiveRecord::Base.connection.indexes(t).collect {|c| c.columns}.include?("id") remove_index t.to_s, :id end - end + end end def self.down @@ -12,6 +12,6 @@ class RemoveDuplicatedIndexOnAllTables < ActiveRecord::Migration unless ActiveRecord::Base.connection.indexes(t).collect {|c| c.columns}.include?("id") add_index t.to_s, :id, :integer => true end - end + end end end diff --git a/lib/puppet/rails/database/003_add_environment_to_host.rb b/lib/puppet/rails/database/003_add_environment_to_host.rb index 3ed10e946..4ab2fbc63 100644 --- a/lib/puppet/rails/database/003_add_environment_to_host.rb +++ b/lib/puppet/rails/database/003_add_environment_to_host.rb @@ -4,7 +4,7 @@ class AddEnvironmentToHost < ActiveRecord::Migration add_column :hosts, :environment, :string end end - + def self.down if ActiveRecord::Base.connection.columns(:hosts).collect {|c| c.name}.include?("environment") remove_column :hosts, :environment diff --git a/lib/puppet/rails/database/schema.rb b/lib/puppet/rails/database/schema.rb index 246bec482..d8fcbb418 100644 --- a/lib/puppet/rails/database/schema.rb +++ b/lib/puppet/rails/database/schema.rb @@ -27,7 +27,7 @@ class Puppet::Rails::Schema add_index :resources, [:title, :restype] end - create_table :source_files do |t| + create_table :source_files do |t| t.column :filename, :string t.column :path, :string t.column :updated_at, :datetime @@ -44,7 +44,7 @@ class Puppet::Rails::Schema add_index :resource_tags, :resource_id, :integer => true add_index :resource_tags, :puppet_tag_id, :integer => true - create_table :puppet_tags do |t| + create_table :puppet_tags do |t| t.column :name, :string t.column :updated_at, :datetime t.column :created_at, :datetime @@ -66,20 +66,20 @@ class Puppet::Rails::Schema add_index :hosts, :source_file_id, :integer => true add_index :hosts, :name - create_table :fact_names do |t| + 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| + 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 + end add_index :fact_values, :fact_name_id, :integer => true add_index :fact_values, :host_id, :integer => true @@ -93,14 +93,14 @@ class Puppet::Rails::Schema end add_index :param_values, :param_name_id, :integer => true add_index :param_values, :resource_id, :integer => true - - create_table :param_names do |t| + + 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 - end + end end ensure $stdout.close diff --git a/lib/puppet/rails/fact_value.rb b/lib/puppet/rails/fact_value.rb index b53591d7e..e4cc6dd3c 100644 --- a/lib/puppet/rails/fact_value.rb +++ b/lib/puppet/rails/fact_value.rb @@ -4,7 +4,7 @@ class Puppet::Rails::FactValue < ActiveRecord::Base def to_label "#{self.fact_name.name}" - end + end end # $Id: fact_value.rb 1952 2006-12-19 05:47:57Z luke $ diff --git a/lib/puppet/rails/host.rb b/lib/puppet/rails/host.rb index 1ddc01244..14ad5e6aa 100644 --- a/lib/puppet/rails/host.rb +++ b/lib/puppet/rails/host.rb @@ -84,13 +84,13 @@ class Puppet::Rails::Host < ActiveRecord::Base # Return the value of a fact. def fact(name) if fv = self.fact_values.find(:all, :include => :fact_name, - :conditions => "fact_names.name = '#{name}'") + :conditions => "fact_names.name = '#{name}'") return fv else return nil end end - + # returns a hash of fact_names.name => [ fact_values ] for this host. # Note that 'fact_values' is actually a list of the value instances, not # just actual values. @@ -102,7 +102,7 @@ class Puppet::Rails::Host < ActiveRecord::Base hash end end - + # This is *very* similar to the merge_parameters method # of Puppet::Rails::Resource. @@ -208,7 +208,7 @@ class Puppet::Rails::Host < ActiveRecord::Base end end - # Turn a parser resource into a Rails resource. + # Turn a parser resource into a Rails resource. def build_rails_resource_from_parser_resource(resource) db_resource = nil accumulate_benchmark("Added resources", :initialization) { diff --git a/lib/puppet/rails/param_name.rb b/lib/puppet/rails/param_name.rb index b4eb1df05..69e2fb6e2 100644 --- a/lib/puppet/rails/param_name.rb +++ b/lib/puppet/rails/param_name.rb @@ -4,7 +4,7 @@ require 'puppet/util/rails/cache_accumulator' class Puppet::Rails::ParamName < ActiveRecord::Base include Puppet::Util::CollectionMerger - has_many :param_values, :dependent => :destroy + has_many :param_values, :dependent => :destroy include Puppet::Util::CacheAccumulator accumulates :name diff --git a/lib/puppet/rails/param_value.rb b/lib/puppet/rails/param_value.rb index 46d7fc1fb..21415ef4b 100644 --- a/lib/puppet/rails/param_value.rb +++ b/lib/puppet/rails/param_value.rb @@ -67,7 +67,7 @@ class Puppet::Rails::ParamValue < ActiveRecord::Base end params end - + def to_s "%s => %s" % [self.name, self.value] end diff --git a/lib/puppet/rails/resource.rb b/lib/puppet/rails/resource.rb index 758df64b1..12d321143 100644 --- a/lib/puppet/rails/resource.rb +++ b/lib/puppet/rails/resource.rb @@ -150,7 +150,7 @@ class Puppet::Rails::Resource < ActiveRecord::Base end end end - + # Make sure the tag list is correct. def merge_tags(resource) in_db = [] diff --git a/lib/puppet/rails/resource_tag.rb b/lib/puppet/rails/resource_tag.rb index 57649b959..8aeec0ee8 100644 --- a/lib/puppet/rails/resource_tag.rb +++ b/lib/puppet/rails/resource_tag.rb @@ -4,7 +4,7 @@ class Puppet::Rails::ResourceTag < ActiveRecord::Base def to_label "#{self.puppet_tag.name}" - end + end # returns an array of hash containing tags of resource def self.find_all_tags_from_resource(db_resource) diff --git a/lib/puppet/rails/source_file.rb b/lib/puppet/rails/source_file.rb index 3ccf87ac6..de95f755a 100644 --- a/lib/puppet/rails/source_file.rb +++ b/lib/puppet/rails/source_file.rb @@ -4,5 +4,5 @@ class Puppet::Rails::SourceFile < ActiveRecord::Base def to_label "#{self.filename}" - end + end end diff --git a/lib/puppet/reference/configuration.rb b/lib/puppet/reference/configuration.rb index 6c40c86ba..60cbb8639 100644 --- a/lib/puppet/reference/configuration.rb +++ b/lib/puppet/reference/configuration.rb @@ -53,20 +53,20 @@ the parameters below, but not all of the arguments make sense for every executab 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 +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``:: - + $ puppetd --confdir=/private/puppet - + Note that boolean options are turned on and off with a slightly different syntax on the command line:: $ puppetd --storeconfigs - + $ puppetd --no-storeconfigs -The invocations above will enable and disable, respectively, the storage of +The invocations above will enable and disable, respectively, the storage of the client configuration. Configuration Files @@ -95,7 +95,7 @@ The file follows INI-style formatting. Here is an example of a very simple [main] confdir = /private/puppet storeconfigs = true - + Note that boolean parameters must be explicitly specified as `true` or `false` as seen above. @@ -112,13 +112,13 @@ will print a template configuration to standard output, which can be redirected to a file like so:: $ puppetd --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 +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:: @@ -128,16 +128,16 @@ 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:: $ puppetd --mkusers - + Signals ------- -The ``puppetd`` and ``puppetmasterd`` 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 +The ``puppetd`` and ``puppetmasterd`` 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 ``puppetd`` or ``puppetmasterd``. -Sending the ``SIGUSR1`` signal to an instance of ``puppetd`` will cause it to -immediately begin a new configuration transaction with the server. This +Sending the ``SIGUSR1`` signal to an instance of ``puppetd`` will cause it to +immediately begin a new configuration transaction with the server. This signal has no effect on ``puppetmasterd``. Configuration Parameter Reference diff --git a/lib/puppet/reference/function.rb b/lib/puppet/reference/function.rb index 5c62c88d5..0dc2f7967 100644 --- a/lib/puppet/reference/function.rb +++ b/lib/puppet/reference/function.rb @@ -6,7 +6,7 @@ There are two types of functions in Puppet: Statements and rvalues. Statements stand on their own and do not return arguments; they are used for performing stand-alone work like importing. Rvalues return values and can only be used in a statement requiring a value, such as an assignment or a case -statement. +statement. Here are the functions available in Puppet: diff --git a/lib/puppet/reference/metaparameter.rb b/lib/puppet/reference/metaparameter.rb index 45e5ea4e6..2d24a4209 100644 --- a/lib/puppet/reference/metaparameter.rb +++ b/lib/puppet/reference/metaparameter.rb @@ -6,7 +6,7 @@ metaparameter = Puppet::Util::Reference.newreference :metaparameter, :doc => "Al next if type.name == :puppet next if type.name == :component types[type.name] = type - } + } str = %{ Metaparameters @@ -23,7 +23,7 @@ Available Metaparameters params = [] Puppet::Type.eachmetaparam { |param| params << param - } + } params.sort { |a,b| a.to_s <=> b.to_s @@ -37,12 +37,12 @@ Available Metaparameters #puts "</dd>" #puts "" - } + } rescue => detail puts detail.backtrace puts "incorrect metaparams: %s" % detail exit(1) end - - str + + str end diff --git a/lib/puppet/reference/providers.rb b/lib/puppet/reference/providers.rb index f9f83a0fc..d425d803e 100644 --- a/lib/puppet/reference/providers.rb +++ b/lib/puppet/reference/providers.rb @@ -80,7 +80,7 @@ providers = Puppet::Util::Reference.newreference :providers, :title => "Provider end end notes << details - + count += 1 end diff --git a/lib/puppet/reference/type.rb b/lib/puppet/reference/type.rb index c80b17b0a..6f8d480c6 100644 --- a/lib/puppet/reference/type.rb +++ b/lib/puppet/reference/type.rb @@ -17,7 +17,7 @@ Resource Types This is the parameter that gets assigned when a string is provided before the colon in a type declaration. In general, only developers will need to worry about which parameter is the ``namevar``. - + In the following code:: file { "/etc/passwd": diff --git a/lib/puppet/relationship.rb b/lib/puppet/relationship.rb index 984dffeeb..97c84ac0e 100644 --- a/lib/puppet/relationship.rb +++ b/lib/puppet/relationship.rb @@ -13,7 +13,7 @@ class Puppet::Relationship attr_accessor :source, :target, :callback attr_reader :event - + def event=(event) if event != :NONE and ! callback raise ArgumentError, "You must pass a callback for non-NONE events" @@ -31,9 +31,9 @@ class Puppet::Relationship end end end - + # Does the passed event match our event? This is where the meaning - # of :NONE comes from. + # of :NONE comes from. def match?(event) if self.event.nil? or event == :NONE or self.event == :NONE return false @@ -50,7 +50,7 @@ class Puppet::Relationship result[:event] = event if event result end - + def ref "%s => %s" % [source, target] end diff --git a/lib/puppet/reports/rrdgraph.rb b/lib/puppet/reports/rrdgraph.rb index 5889750dd..0c1cbf202 100644 --- a/lib/puppet/reports/rrdgraph.rb +++ b/lib/puppet/reports/rrdgraph.rb @@ -3,21 +3,21 @@ Puppet::Reports.register_report(:rrdgraph) do must have the Ruby RRDtool library installed to use this report, which you can get from `the RubyRRDTool RubyForge page`_. This package may also be available as ``ruby-rrd`` or ``rrdtool-ruby`` in your distribution's package - management system. The library and/or package will both require the binary + management system. The library and/or package will both require the binary ``rrdtool`` package from your distribution to be installed. .. _the RubyRRDTool RubyForge page: http://rubyforge.org/projects/rubyrrdtool/ - + This report will create, manage, and graph RRD database files for each of the metrics generated during transactions, and it will create a few simple html files to display the reporting host's graphs. At this point, it will not create a common index file to display links to all hosts. - + All RRD files and graphs get created in the ``rrddir`` directory. If you want to serve these publicly, you should be able to just alias that directory in a web server. - + If you really know what you're doing, you can tune the ``rrdinterval``, which defaults to the ``runinterval``." diff --git a/lib/puppet/reports/store.rb b/lib/puppet/reports/store.rb index 0c7f8cea9..720e78cea 100644 --- a/lib/puppet/reports/store.rb +++ b/lib/puppet/reports/store.rb @@ -5,7 +5,7 @@ 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)." diff --git a/lib/puppet/reports/tagmail.rb b/lib/puppet/reports/tagmail.rb index 963cc0c19..4fdaa5137 100644 --- a/lib/puppet/reports/tagmail.rb +++ b/lib/puppet/reports/tagmail.rb @@ -8,12 +8,12 @@ Puppet::Reports.register_report(:tagmail) do based on the tags in the log messages. See the `UsingTags tag documentation`:trac: for more information on tags. - + To use this report, you must create a ``tagmail.conf`` (in the location specified by ``tagmap``). This is a simple file that maps tags to email addresses: Any log messages in the report that match the specified tags will be sent to the specified email addresses. - + Tags must be comma-separated, and they can be negated so that messages only match when they do not have that tag. The tags are separated from the email addresses by a colon, and the email addresses should also @@ -29,9 +29,9 @@ Puppet::Reports.register_report(:tagmail) do This will send all messages to ``me@domain.com``, and all messages from webservers that are not also from mailservers to ``httpadmins@domain.com``. - If you are using anti-spam controls, such as grey-listing, on your mail - server you should whitelist the sending email (controlled by ``reportform`` - configuration option) to ensure your email is not discarded as spam. + If you are using anti-spam controls, such as grey-listing, on your mail + server you should whitelist the sending email (controlled by ``reportform`` + configuration option) to ensure your email is not discarded as spam. " @@ -65,10 +65,10 @@ Puppet::Reports.register_report(:tagmail) do reports << [emails, messages.collect { |m| m.to_report }.join("\n")] end end - + return reports end - + # Load the config file def parse(text) taglists = [] @@ -114,13 +114,13 @@ Puppet::Reports.register_report(:tagmail) do end taglists = parse(File.read(Puppet[:tagmap])) - + # Now find any appropriately tagged messages. reports = match(taglists) send(reports) end - + # Send the email reports. def send(reports) pid = fork do @@ -136,7 +136,7 @@ Puppet::Reports.register_report(:tagmail) do p.puts "Date: " + Time.now.rfc2822 p.puts p.puts messages - end + end end end rescue => detail diff --git a/lib/puppet/resource/catalog.rb b/lib/puppet/resource/catalog.rb index c885c8d78..eb42ff690 100644 --- a/lib/puppet/resource/catalog.rb +++ b/lib/puppet/resource/catalog.rb @@ -92,7 +92,7 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph # Create an alias for a resource. def alias(resource, name) - #set $1 + #set $1 resource.ref =~ /^(.+)\[/ newref = "%s[%s]" % [$1 || resource.class.name, name] @@ -148,7 +148,7 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph end yield transaction if block_given? - + transaction.send_report if host_config and (Puppet[:report] or Puppet[:summarize]) return transaction @@ -162,7 +162,7 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph def applying? @applying end - + def clear(remove_resources = true) super() # We have to do this so that the resources clean themselves up. @@ -271,7 +271,7 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph make_default_resources @resource_table.values.each { |resource| resource.finish } - + write_graph(:resources) end @@ -304,13 +304,13 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph # First create the default scheduling objects Puppet::Type.type(:schedule).mkdefaultschedules.each { |res| add_resource(res) unless resource(res.ref) } - + # And filebuckets if bucket = Puppet::Type.type(:filebucket).mkdefaultbucket add_resource(bucket) unless resource(bucket.ref) end end - + # Create a graph of all of the relationships in our catalog. def relationship_graph unless defined? @relationship_graph and @relationship_graph @@ -320,7 +320,7 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph # spitting out the messages. If this is not set, # then we get into an infinite loop. @relationship_graph = Puppet::SimpleGraph.new - + # First create the dependency graph self.vertices.each do |vertex| @relationship_graph.add_vertex vertex @@ -328,7 +328,7 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph @relationship_graph.add_edge(edge) end end - + # Lastly, add in any autorequires @relationship_graph.vertices.each do |vertex| vertex.autorequire(self).each do |edge| @@ -343,7 +343,7 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph end end @relationship_graph.write_graph(:relationships) if host_config? - + # Then splice in the container information @relationship_graph.splice!(self, Puppet::Type::Component) @@ -432,7 +432,7 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph # Verify that the given resource isn't defined elsewhere. def fail_unless_unique(resource) - # Short-curcuit the common case, + # Short-curcuit the common case, return unless existing_resource = @resource_table[resource.ref] # If we've gotten this far, it's a real conflict diff --git a/lib/puppet/resource/reference.rb b/lib/puppet/resource/reference.rb index b08f2a380..c205f1038 100644 --- a/lib/puppet/resource/reference.rb +++ b/lib/puppet/resource/reference.rb @@ -37,7 +37,7 @@ class Puppet::Resource::Reference # Don't override whatever was done by setting the title. self.type ||= argtype end - + @builtin_type = nil end @@ -63,7 +63,7 @@ class Puppet::Resource::Reference if value.nil? or value.to_s.downcase == "component" @type = "Class" else - # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com] + # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com] x = @type = value.to_s.split("::").collect { |s| s.capitalize }.join("::") end end diff --git a/lib/puppet/simple_graph.rb b/lib/puppet/simple_graph.rb index 5d6f72943..34db59e5c 100644 --- a/lib/puppet/simple_graph.rb +++ b/lib/puppet/simple_graph.rb @@ -117,7 +117,7 @@ class Puppet::SimpleGraph def dependents(resource) tree_from_vertex(resource).keys end - + # Which resources depend upon the given resource. def dependencies(resource) # Cache the reversal graph, because it's somewhat expensive @@ -142,7 +142,7 @@ class Puppet::SimpleGraph l = tree.keys.find_all { |c| adjacent(c, :direction => direction).empty? } return l end - + # Collect all of the edges that the passed events match. Returns # an array of edges. def matching_edges(events, base = nil) @@ -284,7 +284,7 @@ class Puppet::SimpleGraph def remove_edge!(edge) @vertices[edge.source].remove_edge(:out, edge) @vertices[edge.target].remove_edge(:in, edge) - + @edges.delete(edge) nil end @@ -302,9 +302,9 @@ class Puppet::SimpleGraph def setup_vertex(vertex) @vertices[vertex] = VertexWrapper.new(vertex) end - + public - + # # For some reason, unconnected vertices do not show up in # # this graph. # def to_jpg(path, name) @@ -313,11 +313,11 @@ class Puppet::SimpleGraph # induced_subgraph(gv).write_to_graphic_file('jpg', name) # end # 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. + # 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 @@ -335,7 +335,7 @@ class Puppet::SimpleGraph remove_vertex!(container) next end - + # First create new edges for each of the :in edges [:in, :out].each do |dir| edges = adjacent(container, :direction => dir, :type => :edges) @@ -386,7 +386,7 @@ class Puppet::SimpleGraph walk(start, direction) do |parent, child| predecessor[child] = parent end - predecessor + predecessor end # LAK:FIXME This is just a paste of the GRATR code with slight modifications. @@ -419,7 +419,7 @@ class Puppet::SimpleGraph end graph end - + # Output the dot format as a string def to_dot (params={}) to_dot_graph(params).to_s; end @@ -435,9 +435,9 @@ class Puppet::SimpleGraph def write_to_graphic_file (fmt='png', dotfile='graph') src = dotfile + '.dot' dot = dotfile + '.' + fmt - + File.open(src, 'w') {|f| f << self.to_dot << "\n"} - + system( "dot -T#{fmt} #{src} -o #{dot}" ) dot end diff --git a/lib/puppet/ssl/certificate_authority/interface.rb b/lib/puppet/ssl/certificate_authority/interface.rb index b355e21f0..e4552950c 100644 --- a/lib/puppet/ssl/certificate_authority/interface.rb +++ b/lib/puppet/ssl/certificate_authority/interface.rb @@ -1,6 +1,6 @@ # This class is basically a hidden class that knows how to act # on the CA. It's only used by the 'puppetca' executable, and its -# job is to provide a CLI-like interface to the CA class. +# job is to provide a CLI-like interface to the CA class. class Puppet::SSL::CertificateAuthority::Interface INTERFACE_METHODS = [:destroy, :list, :revoke, :generate, :sign, :print, :verify] diff --git a/lib/puppet/ssl/certificate_factory.rb b/lib/puppet/ssl/certificate_factory.rb index 41155fd41..73b8a54c3 100644 --- a/lib/puppet/ssl/certificate_factory.rb +++ b/lib/puppet/ssl/certificate_factory.rb @@ -12,7 +12,7 @@ class Puppet::SSL::CertificateFactory } attr_reader :name, :cert_type, :csr, :issuer, :serial - + def initialize(cert_type, csr, issuer, serial) @cert_type, @csr, @issuer, @serial = cert_type, csr, issuer, serial @@ -77,7 +77,7 @@ class Puppet::SSL::CertificateFactory @extensions << @ef.create_extension("authorityKeyIdentifier", "keyid:always,issuer:always") if @cert_type == :ca end - # TTL for new certificates in seconds. If config param :ca_ttl is set, + # TTL for new certificates in seconds. If config param :ca_ttl is set, # use that, otherwise use :ca_days for backwards compatibility def ttl ttl = Puppet.settings[:ca_ttl] diff --git a/lib/puppet/ssl/host.rb b/lib/puppet/ssl/host.rb index acd27edb6..29b947eea 100644 --- a/lib/puppet/ssl/host.rb +++ b/lib/puppet/ssl/host.rb @@ -253,7 +253,7 @@ class Puppet::SSL::Host if time < 1 puts "Exiting; no certificate found and waitforcert is disabled" - exit(1) + exit(1) end while true do diff --git a/lib/puppet/sslcertificates/ca.rb b/lib/puppet/sslcertificates/ca.rb index 2a16a32ba..b0bcdb612 100644 --- a/lib/puppet/sslcertificates/ca.rb +++ b/lib/puppet/sslcertificates/ca.rb @@ -31,7 +31,7 @@ class Puppet::SSLCertificates::CA [file, detail] end end - + end end @@ -39,7 +39,7 @@ class Puppet::SSLCertificates::CA File.join(Puppet[:csrdir], [hostname.downcase, "pem"].join(".")) end - # this stores signed certs in a directory unrelated to + # this stores signed certs in a directory unrelated to # normal client certs def host2certfile(hostname) File.join(Puppet[:signeddir], [hostname.downcase, "pem"].join(".")) @@ -142,15 +142,15 @@ class Puppet::SSLCertificates::CA } end - # List signed certificates. This returns a list of hostnames, not actual - # files -- the names can be converted to full paths with host2csrfile. - def list_signed - return Dir.entries(Puppet[:signeddir]).find_all { |file| - file =~ /\.pem$/ - }.collect { |file| - file.sub(/\.pem$/, '') - } - end + # List signed certificates. This returns a list of hostnames, not actual + # files -- the names can be converted to full paths with host2csrfile. + def list_signed + return Dir.entries(Puppet[:signeddir]).find_all { |file| + file =~ /\.pem$/ + }.collect { |file| + file.sub(/\.pem$/, '') + } + end # Create the root certificate. def mkrootcert @@ -207,7 +207,7 @@ class Puppet::SSLCertificates::CA @crl.add_revoked(revoked) store_crl end - + # Take the Puppet config and store it locally. def setconfig(hash) @config = {} @@ -306,7 +306,7 @@ class Puppet::SSLCertificates::CA end end - # TTL for new certificates in seconds. If config param :ca_ttl is set, + # TTL for new certificates in seconds. If config param :ca_ttl is set, # use that, otherwise use :ca_days for backwards compatibility def ttl days = @config[:ca_days] @@ -337,7 +337,7 @@ class Puppet::SSLCertificates::CA end end end - + private def init_crl if FileTest.exists?(@config[:cacrl]) @@ -355,7 +355,7 @@ class Puppet::SSLCertificates::CA @crl end end - + def store_crl # Increment the crlNumber e = @crl.extensions.find { |e| e.oid == 'crlNumber' } diff --git a/lib/puppet/sslcertificates/certificate.rb b/lib/puppet/sslcertificates/certificate.rb index f348cdcb8..191f553b0 100644 --- a/lib/puppet/sslcertificates/certificate.rb +++ b/lib/puppet/sslcertificates/certificate.rb @@ -98,9 +98,9 @@ class Puppet::SSLCertificates::Certificate @encrypt = hash[:encrypt] || false @replace = hash[:replace] || false @issuer = hash[:issuer] || nil - + if hash.include?(:type) - case hash[:type] + case hash[:type] when :ca, :client, :server; @type = hash[:type] else raise "Invalid Cert type %s" % hash[:type] @@ -168,7 +168,7 @@ class Puppet::SSLCertificates::Certificate # case p # when 0; Puppet.info "key info: ." # BN_generate_prime # when 1; Puppet.info "key info: +" # BN_generate_prime -# when 2; Puppet.info "key info: *" # searching good prime, +# when 2; Puppet.info "key info: *" # searching good prime, # # n = #of try, # # but also data from BN_generate_prime # when 3; Puppet.info "key info: \n" # found good prime, n==0 - p, n==1 - q, diff --git a/lib/puppet/sslcertificates/inventory.rb b/lib/puppet/sslcertificates/inventory.rb index 295c416cb..b86ee0b90 100644 --- a/lib/puppet/sslcertificates/inventory.rb +++ b/lib/puppet/sslcertificates/inventory.rb @@ -4,7 +4,7 @@ module Puppet::SSLCertificates module Inventory # Add CERT to the inventory of issued certs in '$cadir/inventory.txt' - # If no inventory exists yet, build an inventory and list all the + # If no inventory exists yet, build an inventory and list all the # certificates that have been signed so far def self.add(cert) inited = false @@ -30,8 +30,8 @@ module Puppet::SSLCertificates def self.format(cert) iso = '%Y-%m-%dT%H:%M:%S%Z' - return "0x%04x %s %s %s" % [cert.serial, - cert.not_before.strftime(iso), + return "0x%04x %s %s %s" % [cert.serial, + cert.not_before.strftime(iso), cert.not_after.strftime(iso), cert.subject] end diff --git a/lib/puppet/transaction.rb b/lib/puppet/transaction.rb index dd8689447..f09ca804b 100644 --- a/lib/puppet/transaction.rb +++ b/lib/puppet/transaction.rb @@ -16,7 +16,7 @@ class Transaction # The list of events generated in this transaction. attr_reader :events - + include Puppet::Util # Add some additional times for reporting @@ -35,7 +35,7 @@ class Transaction if resource.purging? and resource.deleting? if deps = relationship_graph.dependents(resource) and ! deps.empty? and deps.detect { |d| ! d.deleting? } resource.warning "%s still depend%s on me -- not purging" % - [deps.collect { |r| r.ref }.join(","), deps.length > 1 ? "":"s"] + [deps.collect { |r| r.ref }.join(","), deps.length > 1 ? "":"s"] return false end end @@ -91,7 +91,7 @@ class Transaction if resource.respond_to?(:flush) resource.flush end - + # And set a trigger for refreshing this resource if it's a # self-refresher if resource.self_refresh? and ! resource.deleting? @@ -149,7 +149,7 @@ class Transaction change.property.resource }.uniq end - + # Do any necessary cleanup. If we don't get rid of the graphs, the # contained resources might never get cleaned up. def cleanup @@ -162,7 +162,7 @@ class Transaction # child resource. def make_parent_child_relationship(resource, children) depthfirst = resource.depthfirst? - + children.each do |gen_child| if depthfirst edge = [gen_child, resource] @@ -190,15 +190,15 @@ class Transaction def eval_generate(resource) generate_additional_resources(resource, :eval_generate) end - + # Evaluate a single resource. def eval_resource(resource) events = [] - + if resource.is_a?(Puppet::Type::Component) raise Puppet::DevError, "Got a component to evaluate" end - + if skip?(resource) @resourcemetrics[:skipped] += 1 else @@ -230,13 +230,13 @@ class Transaction events = [] @resourcemetrics[:scheduled] += 1 - + changecount = @changes.length - + # We need to generate first regardless, because the recursive # actions sometimes change how the top resource is applied. children = eval_generate(resource) - + if ! children.empty? and resource.depthfirst? children.each do |child| # The child will never be skipped when the parent isn't @@ -278,7 +278,7 @@ class Transaction # Start logging. Puppet::Util::Log.newdestination(@report) - + prepare() begin @@ -333,10 +333,10 @@ class Transaction skip = true end end - + return skip end - + # A general method for recursively generating new resources from a # resource. def generate_additional_resources(resource, method) @@ -481,7 +481,7 @@ class Transaction end end end - + # Prepare to evaluate the resources in a transaction. def prepare # Now add any dynamically generated resources @@ -490,7 +490,7 @@ class Transaction # Then prefetch. It's important that we generate and then prefetch, # so that any generated resources also get prefetched. prefetch() - + # This will throw an error if there are cycles in the graph. @sorted_resources = relationship_graph.topsort end @@ -498,7 +498,7 @@ class Transaction def relationship_graph catalog.relationship_graph end - + # Send off the transaction report. def send_report begin @@ -515,7 +515,7 @@ class Transaction if Puppet[:summarize] puts report.summary end - + if Puppet[:report] begin report.save() @@ -550,7 +550,7 @@ class Transaction # this still could get hairy; what if file contents changed, # but a chmod failed? how would i handle that error? dern end - + # FIXME This won't work right now. relationship_graph.matching_edges(events).each do |edge| @targets[edge.target] << edge @@ -565,7 +565,7 @@ class Transaction events }.flatten.reject { |e| e.nil? } end - + # Is the resource currently scheduled? def scheduled?(resource) self.ignoreschedules or resource.scheduled? @@ -582,7 +582,7 @@ class Transaction end @targets[edge.target] << edge end - + # Should this resource be skipped? def skip?(resource) skip = false @@ -597,7 +597,7 @@ class Transaction end return true end - + # The tags we should be checking. def tags unless defined? @tags @@ -608,7 +608,7 @@ class Transaction @tags = tags.split(/\s*,\s*/) end end - + @tags end @@ -616,13 +616,13 @@ class Transaction tags = [tags] unless tags.is_a?(Array) @tags = tags end - + # Is this resource tagged appropriately? def missing_tags?(resource) return false if self.ignore_tags? or tags.empty? return true unless resource.tagged?(tags) end - + # Are there any edges that target this resource? def targeted?(resource) # The default value is a new array so we have to test the length of it. @@ -665,7 +665,7 @@ class Transaction [callback, subs.length] end resource.notice message - + # At this point, just log failures, don't try to react # to them in any way. begin diff --git a/lib/puppet/transaction/change.rb b/lib/puppet/transaction/change.rb index 42c3a174f..b710ee08d 100644 --- a/lib/puppet/transaction/change.rb +++ b/lib/puppet/transaction/change.rb @@ -5,7 +5,7 @@ require 'puppet/transaction/event' # including calling 'sync' on the properties and producing events. class Puppet::Transaction::Change attr_accessor :is, :should, :path, :property, :changed, :proxy - + # Switch the goals of the property, thus running the change in reverse. def backward @is, @should = @should, @is @@ -14,7 +14,7 @@ class Puppet::Transaction::Change @property.info "Reversing %s" % self return self.go end - + def changed? self.changed end @@ -28,7 +28,7 @@ class Puppet::Transaction::Change name = @property.event(should) end - + Puppet::Transaction::Event.new(name, self.resource) end @@ -61,7 +61,7 @@ class Puppet::Transaction::Change else events = [events] end - + return events.collect { |name| @report = @property.log(@property.change_to_s(@is, @should)) event(name) @@ -71,12 +71,12 @@ class Puppet::Transaction::Change def forward return self.go end - + # Is our property noop? This is used for generating special events. def noop? return @property.noop end - + # The resource that generated this change. This is used for handling events, # and the proxy resource is used for generated resources, since we can't # send an event to a resource we don't have a direct relationship. If we diff --git a/lib/puppet/transaction/event.rb b/lib/puppet/transaction/event.rb index f1a48b382..54c092e65 100644 --- a/lib/puppet/transaction/event.rb +++ b/lib/puppet/transaction/event.rb @@ -8,7 +8,7 @@ require 'puppet/util/errors' class Puppet::Transaction::Event include Puppet::Util::MethodHelper include Puppet::Util::Errors - + attr_reader :name, :source def initialize(name, source) diff --git a/lib/puppet/transportable.rb b/lib/puppet/transportable.rb index 052f6bab1..85a75d453 100644 --- a/lib/puppet/transportable.rb +++ b/lib/puppet/transportable.rb @@ -66,7 +66,7 @@ module Puppet end def to_manifest - "%s { '%s':\n%s\n}" % + "%s { '%s':\n%s\n}" % [self.type.to_s, self.name, @params.collect { |p, v| if v.is_a? Array @@ -209,7 +209,7 @@ module Puppet end end end - + begin delver.call(self) catalog.finalize @@ -218,7 +218,7 @@ module Puppet catalog.clear if (clear_on_failure) raise end - + return catalog end diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb index 320f82f0c..d30033870 100644 --- a/lib/puppet/type.rb +++ b/lib/puppet/type.rb @@ -149,7 +149,7 @@ class Type return 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 @@ -201,7 +201,7 @@ class Type if options[:required_features] param.required_features = options[:required_features] end - + handle_param_options(name, options) param.metaparam = true @@ -239,7 +239,7 @@ class Type :array => @parameters, :hash => @paramhash ) - + handle_param_options(name, options) # Grr. @@ -278,7 +278,7 @@ class Type "Options must be a hash, not %s" % options.inspect end - if @validproperties.include?(name) + if @validproperties.include?(name) raise Puppet::DevError, "Class %s already has a property named %s" % [self.name, name] end @@ -390,7 +390,7 @@ class Type return name end end - + # Are we deleting this resource? def deleting? obj = @parameters[:ensure] and obj.should == :absent @@ -405,7 +405,7 @@ class Type end return false 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' @@ -575,7 +575,7 @@ class Type # Convert our object to a hash. This just includes properties. def to_hash rethash = {} - + @parameters.each do |name, obj| rethash[name] = obj.value end @@ -669,7 +669,7 @@ class Type return false end end - + def depthfirst? self.class.depthfirst? end @@ -746,14 +746,14 @@ class Type # 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 '%s'" % [property.name] end - ensureis = is[property] + ensureis = is[property] if property.insync?(ensureis) and property.should == :absent return true end @@ -779,12 +779,12 @@ class Type #self.debug("%s sync status is %s" % [self,insync]) return insync end - + # retrieve the current value of all contained properties def retrieve return currentpropvalues 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. @@ -821,7 +821,7 @@ class Type def noop noop? end - + # Retrieve the changes associated with all of the properties. def propertychanges(currentvalues) # If we are changing the existence of the object, then none of @@ -1073,7 +1073,7 @@ class Type newmetaparam(:noop) do desc "Boolean flag indicating whether work should actually be done." - + newvalues(:true, :false) munge do |value| case value @@ -1165,8 +1165,8 @@ class Type munge do |loglevel| val = super(loglevel) if val == :verbose - val = :info - end + val = :info + end val end end @@ -1174,7 +1174,7 @@ class Type 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\", @@ -1207,7 +1207,7 @@ class Type should be affecting the same file. See the `LanguageTutorial language tutorial`:trac: for more information. - + " munge do |aliases| @@ -1239,7 +1239,7 @@ class Type Tags are currently useful for things like applying a subset of a host's configuration:: - + puppetd --test --tags mytag This way, when you're testing a configuration you can run just the @@ -1253,18 +1253,18 @@ class Type 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| @@ -1284,7 +1284,7 @@ class Type 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 @@ -1296,7 +1296,7 @@ class Type 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 @@ -1325,12 +1325,12 @@ class Type subargs = nil self.debug("requires %s" % [related_resource.ref]) end - + rel = Puppet::Relationship.new(source, target, subargs) end end end - + def self.relationship_params RelationshipMetaparam.subclasses end @@ -1345,7 +1345,7 @@ class Type 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 @@ -1371,7 +1371,7 @@ class Type 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 @@ -1386,7 +1386,7 @@ class Type 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\", @@ -1418,11 +1418,11 @@ class Type 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:: @@ -1435,7 +1435,7 @@ class Type service { sshd: ensure => running } - + This will restart the sshd service if the sshd config file changes.} end @@ -1768,7 +1768,7 @@ class Type attr_writer :noop include Enumerable - + # class methods dealing with Type management public @@ -1838,7 +1838,7 @@ class Type # The catalog that this resource is stored in. attr_accessor :catalog - + # create a log at specified level def log(msg) Puppet::Util::Log.create( @@ -1985,7 +1985,7 @@ class Type def ref "%s[%s]" % [self.class.name.to_s.capitalize, self.title] end - + def self_refresh? self.class.self_refresh end diff --git a/lib/puppet/type/component.rb b/lib/puppet/type/component.rb index 724e2985a..5fed1760e 100644 --- a/lib/puppet/type/component.rb +++ b/lib/puppet/type/component.rb @@ -34,7 +34,7 @@ Puppet::Type.newtype(:component) do catalog.alias(self, ref) end end - + # Component paths are special because they function as containers. def pathbuilder if reference.type == "Class" diff --git a/lib/puppet/type/computer.rb b/lib/puppet/type/computer.rb index 0888325a8..ba394f57b 100644 --- a/lib/puppet/type/computer.rb +++ b/lib/puppet/type/computer.rb @@ -1,5 +1,5 @@ Puppet::Type.newtype(:computer) do - + @doc = "Computer object management using DirectoryService on OS X. @@ -15,12 +15,12 @@ Puppet::Type.newtype(:computer) do This type primarily exists to create localhost Computer objects that MCX policy can then be attached to." - + # 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" @@ -28,7 +28,7 @@ Puppet::Type.newtype(:computer) do 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`` @@ -41,22 +41,22 @@ Puppet::Type.newtype(:computer) 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/cron.rb b/lib/puppet/type/cron.rb index c46a7c83b..dcc363254 100755 --- a/lib/puppet/type/cron.rb +++ b/lib/puppet/type/cron.rb @@ -3,20 +3,20 @@ require 'facter' require 'puppet/util/filetype' Puppet::Type.newtype(:cron) do - @doc = "Installs and manages cron jobs. All fields except the command + @doc = "Installs and manages cron jobs. All fields except the command and the user are optional, although specifying no periodic fields would result in the command being executed every minute. While the name of the cron job is not part of the actual job, it is used by Puppet to store and retrieve it. - + If you specify a cron job that matches an existing job in every way except name, then the jobs will be considered equivalent and the new name will be permanently associated with that job. Once this association is made and synced to disk, you can then manage the job normally (e.g., change the schedule of the job). - + Example:: - + cron { logrotate: command => \"/usr/sbin/logrotate\", user => root, @@ -89,7 +89,7 @@ Puppet::Type.newtype(:cron) do # or the first three letters of the word. def alphacheck(value, ary) tmp = value.downcase - + # If they specified a shortened version of the name, then see # if we can lengthen it (e.g., mon => monday). if tmp.length == 3 @@ -211,16 +211,16 @@ Puppet::Type.newtype(:cron) do best to always provide a fully qualified command. The user's profile is not sourced when the command is run, so if the user's environment is desired it should be sourced manually. - + All cron parameters support ``absent`` as a value; this will remove any existing values for that field." - def retrieve + def retrieve return_value = super if return_value && return_value.is_a?(Array) return_value = return_value[0] end - + return return_value end @@ -302,7 +302,7 @@ Puppet::Type.newtype(:cron) do job. If you already have cron jobs with environment settings, then Puppet will keep those settings in the same place in the file, but will not associate them with a specific job. - + Settings should be specified exactly as they should appear in the crontab, e.g., ``PATH=/bin:/usr/bin:/usr/sbin``." @@ -322,7 +322,7 @@ Puppet::Type.newtype(:cron) do end def is_to_s(newvalue) - if newvalue + if newvalue if newvalue.is_a?(Array) newvalue.join(",") else @@ -363,7 +363,7 @@ Puppet::Type.newtype(:cron) do desc "The user to run the command as. This user must be allowed to run cron jobs, which is not currently checked by Puppet. - + The user defaults to whomever Puppet is running as." defaultto { Etc.getpwuid(Process.uid).name || "root" } diff --git a/lib/puppet/type/exec.rb b/lib/puppet/type/exec.rb index a211f8572..730417cda 100755 --- a/lib/puppet/type/exec.rb +++ b/lib/puppet/type/exec.rb @@ -46,7 +46,7 @@ module Puppet Note 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`` @@ -114,8 +114,8 @@ module Puppet end if log = @resource[:logoutput] - case log - when :true + case log + when :true log = @resource[:loglevel] when :on_failure if status.exitstatus.to_s != self.should.to_s @@ -200,7 +200,7 @@ module Puppet if dir.is_a?(Array) dir = dir[0] end - + dir end end @@ -249,13 +249,13 @@ module Puppet 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) @@ -267,7 +267,7 @@ module Puppet value end end - + defaultto 300 end @@ -276,7 +276,7 @@ module Puppet 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\" @@ -288,7 +288,7 @@ module Puppet 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``." @@ -306,7 +306,7 @@ module Puppet end end - newcheck(:creates) do + 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:: @@ -316,10 +316,10 @@ module Puppet creates => \"/var/tmp/myfile\", path => [\"/usr/bin\", \"/usr/sbin\"] } - + " - # FIXME if they try to set this and fail, then we should probably + # 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 @@ -343,7 +343,7 @@ module Puppet 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\" @@ -380,7 +380,7 @@ module Puppet 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\" diff --git a/lib/puppet/type/file.rb b/lib/puppet/type/file.rb index 1d50de5ed..721b5a1fa 100644 --- a/lib/puppet/type/file.rb +++ b/lib/puppet/type/file.rb @@ -17,7 +17,7 @@ module Puppet 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 Reductive Labs and we can hopefully work with you to develop a @@ -33,7 +33,7 @@ module Puppet end end - # convert the current path in an index into the collection and the last + # 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) @@ -58,11 +58,11 @@ module Puppet 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 } @@ -88,7 +88,7 @@ module Puppet " defaultto { "puppet" } - + munge do |value| # I don't really know how this is happening. value = value.shift if value.is_a?(Array) @@ -228,7 +228,7 @@ module Puppet 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." @@ -249,7 +249,7 @@ module Puppet newvalues(:first, :all) end - + attr_accessor :bucket # Autorequire any parent directories. @@ -277,7 +277,7 @@ module Puppet end end end - + CREATORS = [:content, :source, :target] validate do @@ -300,7 +300,7 @@ module Puppet self.warning "Possible error: recurselimit is set but not recurse, no recursion will happen" end end - + def self.[](path) return nil unless path super(path.gsub(/\/+/, '/').sub(/\/$/, '')) @@ -381,7 +381,7 @@ module Puppet end super end - + # Create any children via recursion or whatever. def eval_generate return [] unless self.recurse? @@ -499,7 +499,7 @@ module Puppet return false end end - + def initialize(hash) # Used for caching clients @clients = {} @@ -508,7 +508,7 @@ module Puppet # Get rid of any duplicate slashes, and remove any trailing slashes. @title = @title.gsub(/\/+/, "/") - + @title.sub!(/\/$/, "") unless @title == "/" @stat = nil @@ -521,7 +521,7 @@ module Puppet child[:ensure] = :absent end end - + # Create a new file or directory object as a child to the current # object. def newchild(path) @@ -567,7 +567,7 @@ module Puppet return [self.ref] end end - + # Should we be purging? def purge? @parameters.include?(:purge) and (self[:purge] == :true or self[:purge] == "true") @@ -715,7 +715,7 @@ module Puppet self.fail "Could not back up; will not replace" unless handlebackup unless should.to_s == "link" - return if s.ftype.to_s == should.to_s + return if s.ftype.to_s == should.to_s end case s.ftype diff --git a/lib/puppet/type/file/checksum.rb b/lib/puppet/type/file/checksum.rb index 54d1c463b..23a3e5adc 100755 --- a/lib/puppet/type/file/checksum.rb +++ b/lib/puppet/type/file/checksum.rb @@ -12,11 +12,11 @@ Puppet::Type.type(:file).newproperty(:checksum) do specify that a file's checksum should be monitored and then subscribe to the file from another object and receive events to signify checksum changes, for instance. - + There are a number of checksum types available including MD5 hashing (and - an md5lite variation that only hashes the first 500 characters of the + an md5lite variation that only hashes the first 500 characters of the file. - + The default checksum parameter, if checksums are enabled, is md5." @event = :file_changed @@ -74,7 +74,7 @@ Puppet::Type.type(:file).newproperty(:checksum) do type = :mtime if type == :timestamp type = :ctime if type == :time - unless state = @resource.cached(:checksums) + unless state = @resource.cached(:checksums) self.debug "Initializing checksum hash" state = {} @resource.cache(:checksums, state) @@ -174,7 +174,7 @@ Puppet::Type.type(:file).newproperty(:checksum) do # not existing yet return nil unless @resource.property(:source) end - + # If the sums are different, then return an event. if self.updatesum(currentvalue) return :file_changed @@ -193,7 +193,7 @@ Puppet::Type.type(:file).newproperty(:checksum) do return true end end - + # Even though they can specify multiple checksums, the insync? # mechanism can really only test against one, so we'll just retrieve # the first specified sum type. @@ -220,7 +220,7 @@ Puppet::Type.type(:file).newproperty(:checksum) do # out of sync. We don't want to generate an event the first # time we get a sum. self.updatesum(currentvalue) unless cache(checktype()) - + # @resource.debug "checksum state is %s" % self.is return currentvalue end diff --git a/lib/puppet/type/file/content.rb b/lib/puppet/type/file/content.rb index f48e601fb..f30833bd0 100755 --- a/lib/puppet/type/file/content.rb +++ b/lib/puppet/type/file/content.rb @@ -21,7 +21,7 @@ module Puppet content => $str } } - + This attribute is especially useful when used with `PuppetTemplating templating`:trac:." @@ -64,7 +64,7 @@ module Puppet end return nil end - + def content self.should || (s = resource.parameter(:source) and s.content) end @@ -120,7 +120,7 @@ module Puppet # 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. diff --git a/lib/puppet/type/file/ensure.rb b/lib/puppet/type/file/ensure.rb index 4ec35ceb0..f4236b4fc 100755 --- a/lib/puppet/type/file/ensure.rb +++ b/lib/puppet/type/file/ensure.rb @@ -9,14 +9,14 @@ module Puppet Anything other than those values will be considered to be a symlink. For instance, the following text creates a link:: - + # Useful on solaris file { \"/etc/inetd.conf\": ensure => \"/etc/inet/inetd.conf\" } - + You can make relative links:: - + # Useful on solaris file { \"/etc/inetd.conf\": ensure => \"inet/inetd.conf\" diff --git a/lib/puppet/type/file/owner.rb b/lib/puppet/type/file/owner.rb index e4339f05b..15a34a696 100755 --- a/lib/puppet/type/file/owner.rb +++ b/lib/puppet/type/file/owner.rb @@ -89,13 +89,13 @@ module Puppet end end end - + unless stat = @resource.stat(false) return :absent end currentvalue = stat.uid - + # On OS X, files that are owned by -2 get returned as really # large UIDs instead of negative ones. This isn't a Ruby bug, # it's an OS X bug, since it shows up in perl, too. diff --git a/lib/puppet/type/file/source.rb b/lib/puppet/type/file/source.rb index f7c0fa4fc..39d9a20df 100755 --- a/lib/puppet/type/file/source.rb +++ b/lib/puppet/type/file/source.rb @@ -33,15 +33,15 @@ module Puppet 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 + 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``) and the client demon (``puppetd``) differs slightly: ``puppet`` will look such a file up on the module path - on the local host, whereas ``puppetd`` will connect to the + on the local host, whereas ``puppetd`` will connect to the puppet server that it received the manifest from. - + See the `FileServingConfiguration fileserver configuration documentation`:trac: for information on how to configure and use file services within Puppet. @@ -56,9 +56,9 @@ module Puppet \"/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. " @@ -77,12 +77,12 @@ module Puppet end 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 @@ -91,7 +91,7 @@ module Puppet return "replacing from source %s with contents %s" % [metadata.source, metadata.checksum] end end - + def checksum if metadata metadata.checksum @@ -167,7 +167,7 @@ module Puppet checks = (pinparams + [:ensure]) checks.delete(:checksum) - + resource[:check] = checks resource[:checksum] = :md5 unless resource.property(:checksum) end diff --git a/lib/puppet/type/file/target.rb b/lib/puppet/type/file/target.rb index 73787c7e9..fe547e498 100644 --- a/lib/puppet/type/file/target.rb +++ b/lib/puppet/type/file/target.rb @@ -55,7 +55,7 @@ module Puppet if [:nochange, :notlink].include?(self.should) or @resource.recurse? return true elsif ! @resource.replace? and File.exists?(@resource[:path]) - return true + return true else return super(currentvalue) end diff --git a/lib/puppet/type/file/type.rb b/lib/puppet/type/file/type.rb index 1835078a1..19816a20a 100755 --- a/lib/puppet/type/file/type.rb +++ b/lib/puppet/type/file/type.rb @@ -6,7 +6,7 @@ module Puppet #munge do |value| # raise Puppet::Error, ":type is read-only" #end - + def retrieve currentvalue = :absent if stat = @resource.stat(false) diff --git a/lib/puppet/type/filebucket.rb b/lib/puppet/type/filebucket.rb index 03970aee8..6e8e38adc 100755 --- a/lib/puppet/type/filebucket.rb +++ b/lib/puppet/type/filebucket.rb @@ -9,16 +9,16 @@ module Puppet can later be used to retrieve the file if restoration becomes necessary. A filebucket does not do any work itself; instead, it can be specified as the value of *backup* in a **file** object. - + Currently, filebuckets are only useful for manual retrieval of accidentally removed files (e.g., you look in the log for the md5 sum and retrieve the file with that sum from the filebucket), but when transactions are fully supported filebuckets will be used to undo transactions. - + You will normally want to define a single filebucket for your whole network and then use that as the default backup location:: - + # Define the bucket filebucket { main: server => puppet } @@ -74,7 +74,7 @@ module Puppet def mkbucket if self[:server] begin - @bucket = Puppet::Network::Client.client(:Dipper).new( + @bucket = Puppet::Network::Client.client(:Dipper).new( :Server => self[:server], :Port => self[:port] ) diff --git a/lib/puppet/type/group.rb b/lib/puppet/type/group.rb index e3507ad5c..3ce60995e 100755 --- a/lib/puppet/type/group.rb +++ b/lib/puppet/type/group.rb @@ -5,13 +5,13 @@ require 'facter' module Puppet newtype(:group) do @doc = "Manage groups. On most platforms this can only create groups. - Group membership must be managed on individual users. - + Group membership must be managed on individual users. + On some platforms such as OS X, group membership is managed as an - attribute of the group, not the user record. Providers must have + attribute of the group, not the user record. Providers must have the feature 'manages_members' to manage the 'members' property of a group record." - + feature :manages_members, "For directories where membership is an attribute of groups not users." @@ -67,18 +67,18 @@ module Puppet return gid end end - + newproperty(:members, :array_matching => :all, :required_features => :manages_members) do desc "The members of the group. For directory services where group membership is stored in the group objects, not the users." - + def change_to_s(currentvalue, newvalue) currentvalue = currentvalue.join(",") if currentvalue != :absent newvalue = newvalue.join(",") super(currentvalue, newvalue) end end - + newparam(:auth_membership) do desc "whether the provider is authoritative for group membership." defaultto true @@ -95,7 +95,7 @@ module Puppet newparam(:allowdupe, :boolean => true) do desc "Whether to allow duplicate GIDs. This option does not work on FreeBSD (contract to the ``pw`` man page)." - + newvalues(:true, :false) defaultto false diff --git a/lib/puppet/type/host.rb b/lib/puppet/type/host.rb index 763841fd8..6f6ea9480 100755 --- a/lib/puppet/type/host.rb +++ b/lib/puppet/type/host.rb @@ -7,7 +7,7 @@ module Puppet validate do |value| unless value =~ /((([0-9a-fA-F]+:){7}[0-9a-fA-F]+)|(([0-9a-fA-F]+:)*[0-9a-fA-F]+)?::(([0-9a-fA-F]+:)*[0-9a-fA-F]+)?)|((25[0-5]|2[0-4][\d]|[0-1]?\d?\d)(\.(25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3})/ - raise Puppet::Error, "Invalid IP address" + raise Puppet::Error, "Invalid IP address" end end @@ -23,7 +23,7 @@ module Puppet def insync?(is) is == @should end - + def is_to_s(currentvalue = @is) currentvalue = [currentvalue] unless currentvalue.is_a? Array currentvalue.join(" ") @@ -87,13 +87,13 @@ module Puppet isnamevar validate do |value| - # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com] - x = value.split('.').each do |hostpart| + # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com] + x = value.split('.').each do |hostpart| unless hostpart =~ /^([\d\w]+|[\d\w][\d\w\-]+[\d\w])$/ raise Puppet::Error, "Invalid host name" end end - end + end end @doc = "Installs and manages host entries. For most systems, these diff --git a/lib/puppet/type/k5login.rb b/lib/puppet/type/k5login.rb index d22be11b7..20c03241f 100644 --- a/lib/puppet/type/k5login.rb +++ b/lib/puppet/type/k5login.rb @@ -3,7 +3,7 @@ # 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 + @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." @@ -33,7 +33,7 @@ Puppet::Type.newtype(:k5login) do end provide(:k5login) do - desc "The k5login provider is the only provider for the k5login + desc "The k5login provider is the only provider for the k5login type." # Does this file exist? diff --git a/lib/puppet/type/macauthorization.rb b/lib/puppet/type/macauthorization.rb index 800d58d1c..3399cf3e2 100644 --- a/lib/puppet/type/macauthorization.rb +++ b/lib/puppet/type/macauthorization.rb @@ -1,15 +1,15 @@ Puppet::Type.newtype(:macauthorization) do - + @doc = "Manage the Mac OS X authorization database. See: http://developer.apple.com/documentation/Security/Conceptual/Security_Overview/Security_Services/chapter_4_section_5.html for more information." - + ensurable - + autorequire(:file) do ["/etc/authorization"] end - + def munge_boolean(value) case value when true, "true", :true @@ -20,122 +20,122 @@ Puppet::Type.newtype(:macauthorization) do raise Puppet::Error("munge_boolean only takes booleans") end 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. + 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 + 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 + 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, + 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 + desc "Corresponds to 'class' in the authorization store, renamed due to 'class' being a reserved word." - + newvalue(:user) newvalue(:'evaluate-mechanisms') 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 + 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. Built-in rights only show a value of '1' or absent, + desc "k-of-n. Built-in rights only show a value of '1' or absent, other values may be acceptable. Undocumented." end - + newproperty(:mechanisms, :array_matching => :all) do desc "an array of suitable mechanisms." end - + newproperty(:rule, :array_match => :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 + 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 + 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 + 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." end - + newproperty(:tries) do desc "The number of tries allowed." end - + end diff --git a/lib/puppet/type/mailalias.rb b/lib/puppet/type/mailalias.rb index 50ca26ef6..249f99d5e 100755 --- a/lib/puppet/type/mailalias.rb +++ b/lib/puppet/type/mailalias.rb @@ -1,7 +1,7 @@ module Puppet newtype(:mailalias) do @doc = "Creates an email alias in the local alias database." - + ensurable newparam(:name, :namevar => true) do diff --git a/lib/puppet/type/maillist.rb b/lib/puppet/type/maillist.rb index 088004a1c..e2430aa13 100755 --- a/lib/puppet/type/maillist.rb +++ b/lib/puppet/type/maillist.rb @@ -2,7 +2,7 @@ module Puppet newtype(:maillist) do @doc = "Manage email lists. This resource type currently can only create and remove lists, it cannot reconfigure them." - + ensurable do defaultvalues diff --git a/lib/puppet/type/mcx.rb b/lib/puppet/type/mcx.rb index f92cc467d..388d02357 100644 --- a/lib/puppet/type/mcx.rb +++ b/lib/puppet/type/mcx.rb @@ -2,8 +2,8 @@ # 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 +# 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, @@ -61,7 +61,7 @@ to other machines. default naming convention is followed." isnamevar end - + newparam(:ds_type) do desc "The DirectoryService type this MCX setting attaches to." diff --git a/lib/puppet/type/mount.rb b/lib/puppet/type/mount.rb index 2ceacb3fe..18509e349 100755 --- a/lib/puppet/type/mount.rb +++ b/lib/puppet/type/mount.rb @@ -2,7 +2,7 @@ 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 + 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, @@ -10,7 +10,7 @@ module Puppet 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 @@ -44,7 +44,7 @@ module Puppet 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 + provider.create if current_value.nil? or current_value == :absent syncothers() @@ -54,7 +54,7 @@ module Puppet def retrieve # We need to special case :mounted; if we're absent, we still - # want + # want curval = super() if curval == :absent return curval @@ -179,12 +179,12 @@ module Puppet 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) diff --git a/lib/puppet/type/notify.rb b/lib/puppet/type/notify.rb index 15911d441..cfaa24056 100644 --- a/lib/puppet/type/notify.rb +++ b/lib/puppet/type/notify.rb @@ -12,7 +12,7 @@ module Puppet case @resource["withpath"] when :true send(@resource[:loglevel], self.should) - else + else Puppet.send(@resource[:loglevel], self.should) end return @@ -29,11 +29,11 @@ module Puppet defaultto { @resource[:name] } end - newparam(:withpath) do + newparam(:withpath) do desc "Whether to not to show the full object path." defaultto :false - newvalues(:true, :false) + newvalues(:true, :false) end newparam(:name) do diff --git a/lib/puppet/type/package.rb b/lib/puppet/type/package.rb index 655f9e06d..bb3db2838 100644 --- a/lib/puppet/type/package.rb +++ b/lib/puppet/type/package.rb @@ -55,7 +55,7 @@ module Puppet newvalue(:absent, :event => :package_removed) do provider.uninstall end - + newvalue(:purged, :event => :package_purged, :required_features => :purgeable) do provider.purge end @@ -115,7 +115,7 @@ module Puppet 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" @@ -202,7 +202,7 @@ module Puppet alias => openssh, require => Package[openssl] } - + " isnamevar end diff --git a/lib/puppet/type/resources.rb b/lib/puppet/type/resources.rb index d316b4b13..ab564a1d6 100644 --- a/lib/puppet/type/resources.rb +++ b/lib/puppet/type/resources.rb @@ -8,27 +8,27 @@ Puppet::Type.newtype(:resources) do metaparams specified here will be passed on to any generated resources, so you can purge umanaged resources but set ``noop`` to true so the purging is only logged and does not actually happen." - - + + newparam(:name) do desc "The name of the type to be managed." - + validate do |name| unless Puppet::Type.type(name) raise ArgumentError, "Could not find resource type '%s'" % name end end - + munge { |v| v.to_s } end - + newparam(:purge, :boolean => true) do desc "Purge unmanaged resources. This will delete any resource that is not specified in your configuration and is not required by any specified resources." - + newvalues(:true, :false) - + validate do |value| if [:true, true, "true"].include?(value) unless @resource.resource_type.respond_to?(:instances) @@ -40,14 +40,14 @@ Puppet::Type.newtype(:resources) do end end end - + newparam(:unless_system_user) do desc "This keeps system users from being purged. By default, it does not purge users whose UIDs are less than or equal to 500, but you can specify a different UID as the inclusive limit." - + newvalues(:true, :false, /^\d+$/) - + munge do |value| case value when /^\d+/ @@ -61,7 +61,7 @@ Puppet::Type.newtype(:resources) do raise ArgumentError, "Invalid value %s" % value.inspect end end - + defaultto { if @resource[:name] == "user" 500 @@ -70,7 +70,7 @@ Puppet::Type.newtype(:resources) do end } end - + def check(resource) unless defined? @checkmethod @checkmethod = "%s_check" % self[:name] @@ -84,13 +84,13 @@ Puppet::Type.newtype(:resources) do return true end end - + # Generate any new resources we need to manage. This is pretty hackish # right now, because it only supports purging. def generate return [] unless self.purge? hascheck = false - method = + method = resource_type.instances.find_all do |resource| ! resource.managed? end.find_all do |resource| @@ -113,7 +113,7 @@ Puppet::Type.newtype(:resources) do resource.purging end end - + def resource_type unless defined? @resource_type unless type = Puppet::Type.type(self[:name]) @@ -123,16 +123,16 @@ Puppet::Type.newtype(:resources) do end @resource_type end - + # Make sure we don't purge users below a certain uid, if the check # is enabled. def user_check(resource) return true unless self[:name] == "user" return true unless self[:unless_system_user] - + resource[:check] = :uid current_values = resource.retrieve - + if system_users().include?(resource[:name]) return false end diff --git a/lib/puppet/type/schedule.rb b/lib/puppet/type/schedule.rb index 5c9cfd7f4..e51744c69 100755 --- a/lib/puppet/type/schedule.rb +++ b/lib/puppet/type/schedule.rb @@ -4,7 +4,7 @@ module Puppet 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 @@ -12,12 +12,12 @@ module Puppet 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, @@ -29,7 +29,7 @@ module Puppet 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, @@ -46,7 +46,7 @@ module Puppet 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] @@ -55,7 +55,7 @@ module Puppet exec { \"/usr/bin/apt-get update\": schedule => daily } - + " isnamevar end @@ -70,7 +70,7 @@ module Puppet 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." @@ -169,7 +169,7 @@ module Puppet ary = limits[1].to_a ary[3] += 1 limits[1] = Time.local(*ary) - + #self.devfail("Lower limit is above higher limit: %s" % # limits.inspect #) @@ -224,7 +224,7 @@ module Puppet 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." diff --git a/lib/puppet/type/selmodule.rb b/lib/puppet/type/selmodule.rb index 883cd954d..90b28b094 100644 --- a/lib/puppet/type/selmodule.rb +++ b/lib/puppet/type/selmodule.rb @@ -48,7 +48,7 @@ Puppet::Type.newtype(:selmodule) do [self[:selmodulepath]] else ["#{self[:selmoduledir]}/#{self[:name]}.pp"] - end + end end end diff --git a/lib/puppet/type/service.rb b/lib/puppet/type/service.rb index b296f7c39..04fd9042c 100644 --- a/lib/puppet/type/service.rb +++ b/lib/puppet/type/service.rb @@ -21,10 +21,10 @@ module Puppet the service will get restarted. The actual command to restart the service depends on the platform. You can provide a special command for restarting with the ``restart`` attribute." - + feature :refreshable, "The provider can restart the service.", :methods => [:restart] - + feature :enableable, "The provider can enable and disable the service", :methods => [:disable, :enable, :enabled?] @@ -95,7 +95,7 @@ module Puppet manually whether the service you are running has such a command (or you can specify a specific command using the ``status`` parameter). - + If you do not specify anything, then the service name will be looked for in the process table." @@ -113,7 +113,7 @@ module Puppet munge do |value| value = [value] unless value.is_a?(Array) - # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com] + # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com] # It affects stand-alone blocks, too. paths = value.flatten.collect { |p| x = p.split(":") }.flatten.find_all do |path| if FileTest.directory?(path) @@ -139,10 +139,10 @@ module Puppet support init scripts, and is also used for determining service status on those service whose init scripts do not include a status command. - + If this is left unspecified and is needed to check the status of a service, then the service name will be used instead. - + The pattern can be a simple string or any legal Ruby pattern." defaultto { @resource[:binary] || @resource[:name] } diff --git a/lib/puppet/type/ssh_authorized_key.rb b/lib/puppet/type/ssh_authorized_key.rb index 52c650998..d02170e4a 100644 --- a/lib/puppet/type/ssh_authorized_key.rb +++ b/lib/puppet/type/ssh_authorized_key.rb @@ -60,7 +60,7 @@ module Puppet end newproperty(:options, :array_matching => :all) do - desc "Key options, see sshd(8) for possible values. Multiple values + desc "Key options, see sshd(8) for possible values. Multiple values should be specified as an array." defaultto do :absent end diff --git a/lib/puppet/type/sshkey.rb b/lib/puppet/type/sshkey.rb index c2bdd39e3..c9e8f3d8b 100755 --- a/lib/puppet/type/sshkey.rb +++ b/lib/puppet/type/sshkey.rb @@ -3,12 +3,12 @@ module Puppet @doc = "Installs and manages ssh host keys. At this point, this type only knows how to install keys into /etc/ssh/ssh_known_hosts, and it cannot manage user authorized keys yet." - + ensurable newproperty(:type) do desc "The encryption type used. Probably ssh-dss or ssh-rsa." - + newvalue("ssh-dss") newvalue("ssh-rsa") aliasvalue(:dsa, "ssh-dss") diff --git a/lib/puppet/type/tidy.rb b/lib/puppet/type/tidy.rb index d9469aee4..f45171d90 100755 --- a/lib/puppet/type/tidy.rb +++ b/lib/puppet/type/tidy.rb @@ -68,7 +68,7 @@ Puppet::Type.newtype(:tidy) do the specified time. You can choose seconds, minutes, hours, days, or weeks by specifying the first letter of any of those words (e.g., '1w'). - + Specifying 0 will remove all files." @@ageconvertors = { @@ -91,7 +91,7 @@ Puppet::Type.newtype(:tidy) do def tidy?(path, stat) # If the file's older than we allow, we should get rid of it. if (Time.now.to_i - stat.send(resource[:type]).to_i) > value - return true + return true else return false end @@ -137,7 +137,7 @@ Puppet::Type.newtype(:tidy) do self.fail "Invalid size unit '%s'" % unit end end - + def tidy?(path, stat) if stat.size > value return true @@ -145,7 +145,7 @@ Puppet::Type.newtype(:tidy) do return false end end - + munge do |size| case size when /^([0-9]+)(\w)\w*$/ @@ -164,7 +164,7 @@ Puppet::Type.newtype(:tidy) do newparam(:type) do desc "Set the mechanism for determining age." - + newvalues(:atime, :mtime, :ctime) defaultto :atime @@ -200,7 +200,7 @@ Puppet::Type.newtype(:tidy) do newvalues :true, :false end - + # Erase PFile's validate method validate do end @@ -219,7 +219,7 @@ Puppet::Type.newtype(:tidy) do self[:backup] = false end end - + # Make a file resource to remove a given file. def mkfile(path) # Force deletion, so directories actually get deleted. @@ -228,13 +228,13 @@ Puppet::Type.newtype(:tidy) do def retrieve # Our ensure property knows how to retrieve everything for us. - if obj = @parameters[:ensure] + if obj = @parameters[:ensure] return obj.retrieve else return {} end end - + # Hack things a bit so we only ever check the ensure property. def properties [] @@ -267,7 +267,7 @@ Puppet::Type.newtype(:tidy) do files_by_name.keys.sort { |a,b| b <=> b }.each do |path| dir = File.dirname(path) next unless resource = files_by_name[dir] - if resource[:require] + if resource[:require] resource[:require] << Puppet::Resource::Reference.new(:file, path) else resource[:require] = [Puppet::Resource::Reference.new(:file, path)] diff --git a/lib/puppet/type/user.rb b/lib/puppet/type/user.rb index bc7c243a1..28b1631cb 100755 --- a/lib/puppet/type/user.rb +++ b/lib/puppet/type/user.rb @@ -9,7 +9,7 @@ module Puppet @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." diff --git a/lib/puppet/type/yumrepo.rb b/lib/puppet/type/yumrepo.rb index 4f7b26b8a..5d6a727f6 100644 --- a/lib/puppet/type/yumrepo.rb +++ b/lib/puppet/type/yumrepo.rb @@ -30,7 +30,7 @@ module Puppet def retrieve return resource.section[inikey] end - + def inikey name.to_s end @@ -56,7 +56,7 @@ module Puppet the files indicated by reposdir in that file (see yum.conf(5) for details) - Most parameters are identical to the ones documented + Most parameters are identical to the ones documented in yum.conf(5) Continuation lines that yum supports for example for the @@ -74,7 +74,7 @@ module Puppet self.filetype = Puppet::Util::FileType.filetype(:flat) @inifile = nil - + @yumconf = "/etc/yum.conf" # Where to put files for brand new sections @@ -107,9 +107,9 @@ module Puppet @inifile = read() main = @inifile['main'] if main.nil? - raise Puppet::Error, "File #{yumconf} does not contain a main section" + raise Puppet::Error, "File #{yumconf} does not contain a main section" end - reposdir = main['reposdir'] + reposdir = main['reposdir'] reposdir ||= "/etc/yum.repos.d, /etc/yum/repos.d" reposdir.gsub!(/[\n,]/, " ") reposdir.split.each do |dir| @@ -137,7 +137,7 @@ module Puppet result.read(yumconf) main = result['main'] if main.nil? - raise Puppet::Error, "File #{yumconf} does not contain a main section" + raise Puppet::Error, "File #{yumconf} does not contain a main section" end reposdir = main['reposdir'] reposdir ||= "/etc/yum.repos.d, /etc/yum/repos.d" @@ -231,13 +231,13 @@ module Puppet end newproperty(:descr, :parent => Puppet::IniProperty) do - desc "A human readable description of the repository. + desc "A human readable description of the repository. #{ABSENT_DOC}" newvalue(:absent) { self.should = :absent } newvalue(/.*/) { } inikey "name" end - + newproperty(:mirrorlist, :parent => Puppet::IniProperty) do desc "The URL that holds the list of mirrors for this repository. #{ABSENT_DOC}" @@ -252,9 +252,9 @@ module Puppet # Should really check that it's a valid URL newvalue(/.*/) { } end - + newproperty(:enabled, :parent => Puppet::IniProperty) do - desc "Whether this repository is enabled or disabled. Possible + desc "Whether this repository is enabled or disabled. Possible values are '0', and '1'.\n#{ABSENT_DOC}" newvalue(:absent) { self.should = :absent } newvalue(%r{(0|1)}) { } @@ -301,7 +301,7 @@ module Puppet newproperty(:enablegroups, :parent => Puppet::IniProperty) do desc "Determines whether yum will allow the use of - package groups for this repository. Possible + package groups for this repository. Possible values are '0', and '1'.\n#{ABSENT_DOC}" newvalue(:absent) { self.should = :absent } newvalue(%r{(0|1)}) { } @@ -314,14 +314,14 @@ module Puppet end newproperty(:keepalive, :parent => Puppet::IniProperty) do - desc "Either '1' or '0'. This tells yum whether or not HTTP/1.1 + desc "Either '1' or '0'. This tells yum whether or not HTTP/1.1 keepalive should be used with this repository.\n#{ABSENT_DOC}" newvalue(:absent) { self.should = :absent } newvalue(%r{(0|1)}) { } end newproperty(:timeout, :parent => Puppet::IniProperty) do - desc "Number of seconds to wait for a connection before timing + desc "Number of seconds to wait for a connection before timing out.\n#{ABSENT_DOC}" newvalue(:absent) { self.should = :absent } newvalue(%r{[0-9]+}) { } @@ -335,7 +335,7 @@ module Puppet end newproperty(:protect, :parent => Puppet::IniProperty) do - desc "Enable or disable protection for this repository. Requires + desc "Enable or disable protection for this repository. Requires that the protectbase plugin is installed and enabled. #{ABSENT_DOC}" newvalue(:absent) { self.should = :absent } diff --git a/lib/puppet/type/zone.rb b/lib/puppet/type/zone.rb index c286ececd..b8a7e9aa9 100644 --- a/lib/puppet/type/zone.rb +++ b/lib/puppet/type/zone.rb @@ -15,7 +15,7 @@ Puppet::Type.newtype(:zone) do class ZoneMultiConfigProperty < ZoneConfigProperty def configtext list = @should - + current_value = self.retrieve unless current_value.is_a? Symbol @@ -212,7 +212,7 @@ Puppet::Type.newtype(:zone) do end interface, address = value.split(':') - + begin IPAddr.new(address) rescue ArgumentError @@ -230,7 +230,7 @@ end " end - # Convert a string into the component interface and address + # Convert a string into the component interface and address def ipsplit(str) interface, address = str.split(':') return interface, address @@ -260,7 +260,7 @@ end end newproperty(:pool, :parent => ZoneConfigProperty) do - desc "The resource pool for this zone." + desc "The resource pool for this zone." def configtext "set pool=#{self.should}" @@ -307,7 +307,7 @@ end 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 @@ -361,7 +361,7 @@ 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 diff --git a/lib/puppet/util.rb b/lib/puppet/util.rb index fc9f36083..50a669e9b 100644 --- a/lib/puppet/util.rb +++ b/lib/puppet/util.rb @@ -9,7 +9,7 @@ module Puppet 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' @@ -37,8 +37,8 @@ module Util end unless Puppet::Util::SUIDManager.gid == group begin - Puppet::Util::SUIDManager.egid = group - Puppet::Util::SUIDManager.gid = group + Puppet::Util::SUIDManager.egid = group + Puppet::Util::SUIDManager.gid = group rescue => detail Puppet.warning "could not change to group %s: %s" % [group.inspect, detail] @@ -58,8 +58,8 @@ module Util end unless Puppet::Util::SUIDManager.uid == user begin - Puppet::Util::SUIDManager.uid = user - Puppet::Util::SUIDManager.euid = user + Puppet::Util::SUIDManager.uid = user + Puppet::Util::SUIDManager.euid = user rescue $stderr.puts "could not change to user %s" % user exit(74) @@ -255,14 +255,14 @@ module Util else Puppet.debug "Executing '%s'" % str end - + if arguments[:uid] arguments[:uid] = Puppet::Util::SUIDManager.convert_xid(:uid, arguments[:uid]) end if arguments[:gid] arguments[:gid] = Puppet::Util::SUIDManager.convert_xid(:gid, arguments[:gid]) end - + @@os ||= Facter.value(:operatingsystem) output = nil child_pid, child_status = nil @@ -300,7 +300,7 @@ module Util $stdout.reopen(output_file) $stderr.reopen(error_file) - 3.upto(256){|fd| IO::new(fd).close rescue nil} + 3.upto(256){|fd| IO::new(fd).close rescue nil} if arguments[:gid] Process.egid = arguments[:gid] Process.gid = arguments[:gid] unless @@os == "Darwin" diff --git a/lib/puppet/util/classgen.rb b/lib/puppet/util/classgen.rb index 4e1e57c85..1aa961399 100644 --- a/lib/puppet/util/classgen.rb +++ b/lib/puppet/util/classgen.rb @@ -95,7 +95,7 @@ module Puppet::Util::ClassGen end @name = name end - else + else options[:parent] ||= self evalmethod = :class_eval # Create the class, with the correct name. diff --git a/lib/puppet/util/config_store.rb b/lib/puppet/util/config_store.rb index 668d73f6e..ad18259bd 100644 --- a/lib/puppet/util/config_store.rb +++ b/lib/puppet/util/config_store.rb @@ -54,8 +54,8 @@ module Puppet::Util def collect_exported(client, conditions) raise Puppet::DevError, "%s has not overridden collect_exported" % self.class.name - end - + end + end end diff --git a/lib/puppet/util/constant_inflector.rb b/lib/puppet/util/constant_inflector.rb index eeeaa0632..29d334348 100644 --- a/lib/puppet/util/constant_inflector.rb +++ b/lib/puppet/util/constant_inflector.rb @@ -5,7 +5,7 @@ # file names. module Puppet::Util::ConstantInflector def file2constant(file) - # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com] + # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com] x = file.split("/").collect { |name| name.capitalize }.join("::").gsub(/_+(.)/) { |term| $1.capitalize } end diff --git a/lib/puppet/util/diff.rb b/lib/puppet/util/diff.rb index f37ea0850..ac3a1c3c9 100644 --- a/lib/puppet/util/diff.rb +++ b/lib/puppet/util/diff.rb @@ -35,8 +35,8 @@ module Puppet::Util::Diff diffs.each do |piece| begin - hunk = ::Diff::LCS::Hunk.new(data_old, data_new, piece, - context_lines, + hunk = ::Diff::LCS::Hunk.new(data_old, data_new, piece, + context_lines, file_length_difference) file_length_difference = hunk.file_length_difference next unless oldhunk diff --git a/lib/puppet/util/execution.rb b/lib/puppet/util/execution.rb index b8dcde58d..7db7137fb 100644 --- a/lib/puppet/util/execution.rb +++ b/lib/puppet/util/execution.rb @@ -1,5 +1,5 @@ module Puppet::Util::Execution - module_function + module_function # Run some code with a specific environment. Resets the environment back to # what it was at the end of the code. diff --git a/lib/puppet/util/feature.rb b/lib/puppet/util/feature.rb index 2669d1ab1..94ee3be8b 100644 --- a/lib/puppet/util/feature.rb +++ b/lib/puppet/util/feature.rb @@ -26,7 +26,7 @@ class Puppet::Util::Feature end @results[name] = result end - + meta_def(method) do unless @results.include?(name) @results[name] = test(name, options) @@ -34,14 +34,14 @@ class Puppet::Util::Feature @results[name] end end - + # Create a new feature collection. def initialize(path) @path = path @results = {} @loader = Puppet::Util::Autoload.new(self, @path) end - + def load @loader.loadall end @@ -66,12 +66,12 @@ class Puppet::Util::Feature result = true if ary = options[:libs] ary = [ary] unless ary.is_a?(Array) - + ary.each do |lib| unless lib.is_a?(String) raise ArgumentError, "Libraries must be passed as strings not %s" % lib.class end - + begin require lib rescue Exception diff --git a/lib/puppet/util/fileparsing.rb b/lib/puppet/util/fileparsing.rb index dca0d51c0..06f8a2e7d 100644 --- a/lib/puppet/util/fileparsing.rb +++ b/lib/puppet/util/fileparsing.rb @@ -169,7 +169,7 @@ module Puppet::Util::FileParsing fields = [] ret = {} record.fields.zip(match.captures).each do |field, value| - if value == record.absent + if value == record.absent ret[field] = :absent else ret[field] = value @@ -223,7 +223,7 @@ module Puppet::Util::FileParsing # Split text into separate lines using the record separator. def lines(text) # Remove any trailing separators, and then split based on them - # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com] + # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com] x = text.sub(/#{self.line_separator}\Q/,'').split(self.line_separator) end diff --git a/lib/puppet/util/filetype.rb b/lib/puppet/util/filetype.rb index 34feeab90..93c002fa9 100755 --- a/lib/puppet/util/filetype.rb +++ b/lib/puppet/util/filetype.rb @@ -111,9 +111,9 @@ class Puppet::Util::FileType # Overwrite the file. def write(text) require "tempfile" - tf = Tempfile.new("puppet") - tf.print text; tf.flush - FileUtils.cp(tf.path, @path) + tf = Tempfile.new("puppet") + tf.print text; tf.flush + FileUtils.cp(tf.path, @path) tf.close # If SELinux is present, we need to ensure the file has its expected context set_selinux_default_context(@path) @@ -217,7 +217,7 @@ class Puppet::Util::FileType raise Puppet::Error, "User %s not authorized to use cron" % @path if output.include?("you are not authorized to use cron") return output rescue => detail - raise Puppet::Error, "Could not read crontab for %s: %s" % [@path, detail] + raise Puppet::Error, "Could not read crontab for %s: %s" % [@path, detail] end end diff --git a/lib/puppet/util/graph.rb b/lib/puppet/util/graph.rb index fc05cafd9..a052bf8f1 100644 --- a/lib/puppet/util/graph.rb +++ b/lib/puppet/util/graph.rb @@ -13,11 +13,11 @@ module Puppet::Util::Graph # Allow our calling function to send in a graph, so that we # can call this recursively with one graph. graph ||= Puppet::SimpleGraph.new - + self.each do |child| unless block_given? and ! yield(child) graph.add_edge(self, child) - + if child.respond_to?(:to_graph) child.to_graph(graph, &block) end @@ -25,7 +25,7 @@ module Puppet::Util::Graph end # Do a topsort, which will throw an exception if the graph is cyclic. - + graph end end diff --git a/lib/puppet/util/inifile.rb b/lib/puppet/util/inifile.rb index f5fab8530..3c82f7d37 100644 --- a/lib/puppet/util/inifile.rb +++ b/lib/puppet/util/inifile.rb @@ -5,7 +5,7 @@ # something has changed are written back to disk # Great care is taken to preserve comments and blank lines from the original # files -# +# # The parsing tries to stay close to python's ConfigParser require 'puppet/util/filetype' @@ -79,7 +79,7 @@ module Puppet::Util::IniConfig return text end - private + private def find_entry(key) @entries.each do |entry| if entry.is_a?(Array) && entry[0] == key @@ -88,7 +88,7 @@ module Puppet::Util::IniConfig end return nil end - + end # A logical .ini-file that can be spread across several physical @@ -113,7 +113,7 @@ module Puppet::Util::IniConfig text.each_line do |l| line += 1 if l.strip.empty? || "#;".include?(l[0,1]) || - (l.split(nil, 2)[0].downcase == "rem" && + (l.split(nil, 2)[0].downcase == "rem" && l[0,1].downcase == "r") # Whitespace or comment if section.nil? @@ -146,7 +146,7 @@ module Puppet::Util::IniConfig end # Store all modifications made to sections in this file back - # to the physical files. If no modifications were made to + # to the physical files. If no modifications were made to # a physical file, nothing is written def store @files.each do |file, lines| diff --git a/lib/puppet/util/log.rb b/lib/puppet/util/log.rb index 8f8d46097..94b0bcffa 100644 --- a/lib/puppet/util/log.rb +++ b/lib/puppet/util/log.rb @@ -129,7 +129,7 @@ class Puppet::Util::Log unless @levels.index(hash[:level]) raise Puppet::DevError, "Invalid log level %s" % hash[:level] end - if @levels.index(hash[:level]) >= @loglevel + if @levels.index(hash[:level]) >= @loglevel return Puppet::Util::Log.new(hash) else return nil @@ -251,8 +251,8 @@ class Puppet::Util::Log end newdesttype :console do - - + + RED = {:console => "[0;31m", :html => "FFA0A0"} GREEN = {:console => "[0;32m", :html => "00CD00"} YELLOW = {:console => "[0;33m", :html => "FFFF60"} @@ -279,7 +279,7 @@ class Puppet::Util::Log :emerg => HRED, :crit => HRED } - + def colorize(level, str) case Puppet[:color] when false; str @@ -287,11 +287,11 @@ class Puppet::Util::Log when :html, "html"; html_color(level, str) end end - + def console_color(level, str) @@colormap[level][:console] + str + RESET[:console] end - + def html_color(level, str) %{<span style="color: %s">%s</span>} % [@@colormap[level][:html], str] end @@ -432,7 +432,7 @@ class Puppet::Util::Log # for a loop here, if the machine somehow gets the destination set as # itself. def Log.newmessage(msg) - if @levels.index(msg.level) < @loglevel + if @levels.index(msg.level) < @loglevel return end @@ -444,7 +444,7 @@ class Puppet::Util::Log end def Log.sendlevel?(level) - @levels.index(level) >= @loglevel + @levels.index(level) >= @loglevel end # Reopen all of our logs. diff --git a/lib/puppet/util/metric.rb b/lib/puppet/util/metric.rb index f352462cd..b713246d5 100644 --- a/lib/puppet/util/metric.rb +++ b/lib/puppet/util/metric.rb @@ -3,7 +3,7 @@ require 'puppet' # A class for handling metrics. This is currently ridiculously hackish. class Puppet::Util::Metric - + attr_accessor :type, :name, :value, :label attr_writer :values @@ -32,7 +32,7 @@ class Puppet::Util::Metric start ||= Time.now.to_i - 5 @rrd = RRDtool.new(self.path) - args = [] + args = [] values.each { |value| # the 7200 is the heartbeat -- this means that any data that isn't @@ -81,7 +81,7 @@ class Puppet::Util::Metric args << defs args << lines args.flatten! - if range + if range args.push("--start",range[0],"--end",range[1]) else args.push("--start", Time.now.to_i - time, "--end", Time.now.to_i) @@ -147,7 +147,7 @@ class Puppet::Util::Metric end private - + # Convert a name into a label. def labelize(name) name.to_s.capitalize.gsub("_", " ") diff --git a/lib/puppet/util/package.rb b/lib/puppet/util/package.rb index 613aa6b1e..9beed3d00 100644 --- a/lib/puppet/util/package.rb +++ b/lib/puppet/util/package.rb @@ -11,10 +11,10 @@ module Puppet::Util::Package b = bx.shift if( a == b ) then next - elsif (a == '-' && b == '-') then next + elsif (a == '-' && b == '-') then next elsif (a == '-') then return -1 elsif (b == '-') then return 1 - elsif (a == '.' && b == '.') then next + elsif (a == '.' && b == '.') then next elsif (a == '.' ) then return -1 elsif (b == '.' ) then return 1 elsif (a =~ /^\d+$/ && b =~ /^\d+$/) then @@ -22,12 +22,12 @@ module Puppet::Util::Package return a.to_s.upcase <=> b.to_s.upcase end return a.to_i <=> b.to_i - else + else return a.upcase <=> b.upcase end end return version_a <=> version_b; end - + module_function :versioncmp end diff --git a/lib/puppet/util/posix.rb b/lib/puppet/util/posix.rb index 40a175eb3..837c37a07 100755 --- a/lib/puppet/util/posix.rb +++ b/lib/puppet/util/posix.rb @@ -28,7 +28,7 @@ module Puppet::Util::POSIX end # A degenerate method of retrieving name/id mappings. The job of this method is - # to retrieve all objects of a certain type, search for a specific entry + # to retrieve all objects of a certain type, search for a specific entry # and then return a given field from that entry. def search_posix_field(type, field, id) idmethod = idfield(type) @@ -57,7 +57,7 @@ module Puppet::Util::POSIX end return nil end - + # Determine what the field name is for users and groups. def idfield(space) case Puppet::Util.symbolize(space) @@ -67,7 +67,7 @@ module Puppet::Util::POSIX raise ArgumentError.new("Can only handle users and groups") end end - + # Determine what the method is to get users and groups by id def methodbyid(space) case Puppet::Util.symbolize(space) @@ -77,7 +77,7 @@ module Puppet::Util::POSIX raise ArgumentError.new("Can only handle users and groups") end end - + # Determine what the method is to get users and groups by name def methodbyname(space) case Puppet::Util.symbolize(space) @@ -87,7 +87,7 @@ module Puppet::Util::POSIX raise ArgumentError.new("Can only handle users and groups") end end - + # Get the GID of a given group, provided either a GID or a name def gid(group) begin diff --git a/lib/puppet/util/provider_features.rb b/lib/puppet/util/provider_features.rb index 5b0c99525..7986f6eae 100644 --- a/lib/puppet/util/provider_features.rb +++ b/lib/puppet/util/provider_features.rb @@ -14,7 +14,7 @@ module Puppet::Util::ProviderFeatures # Are all of the requirements met? def available?(obj) - if self.methods + if self.methods if methods_available?(obj) return true else @@ -126,8 +126,8 @@ module Puppet::Util::ProviderFeatures # Create a method that will list all functional features. @feature_module.send(:define_method, :features) do return false unless defined?(features) - features.keys.find_all { |n| feature?(n) }.sort { |a,b| - a.to_s <=> b.to_s + features.keys.find_all { |n| feature?(n) }.sort { |a,b| + a.to_s <=> b.to_s } end diff --git a/lib/puppet/util/queue.rb b/lib/puppet/util/queue.rb index ce462ac66..329b07b22 100644 --- a/lib/puppet/util/queue.rb +++ b/lib/puppet/util/queue.rb @@ -5,7 +5,7 @@ require 'puppet/util/instance_loader' # Implements a message queue client type plugin registry for use by the indirector facility. # Client modules for speaking a particular protocol (e.g. Stomp::Client for Stomp message # brokers, Memcached for Starling and Sparrow, etc.) register themselves with this module. -# +# # Client classes are expected to live under the Puppet::Util::Queue namespace and corresponding # directory; the attempted use of a client via its typename (see below) will cause Puppet::Util::Queue # to attempt to load the corresponding plugin if it is not yet loaded. The client class registers itself @@ -43,7 +43,7 @@ module Puppet::Util::Queue # # # register with default name +:you+ # register_queue_type(Foo::You) - # + # # # register with explicit queue type name +:myself+ # register_queue_type(Foo::Me, :myself) # diff --git a/lib/puppet/util/rdoc/code_objects.rb b/lib/puppet/util/rdoc/code_objects.rb index 52df2193e..312fe0c9b 100644 --- a/lib/puppet/util/rdoc/code_objects.rb +++ b/lib/puppet/util/rdoc/code_objects.rb @@ -4,7 +4,7 @@ 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. diff --git a/lib/puppet/util/rdoc/generators/puppet_generator.rb b/lib/puppet/util/rdoc/generators/puppet_generator.rb index 22f001164..bf2609fd6 100644 --- a/lib/puppet/util/rdoc/generators/puppet_generator.rb +++ b/lib/puppet/util/rdoc/generators/puppet_generator.rb @@ -4,14 +4,14 @@ 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 + # + # 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: # @@ -20,7 +20,7 @@ module Generators # Module Module # Class Class # Definition Method - # Resource + # Resource # Node # Plugin # Fact diff --git a/lib/puppet/util/rdoc/generators/template/puppet/puppet.rb b/lib/puppet/util/rdoc/generators/template/puppet/puppet.rb index c71f81915..e12b6519c 100644 --- a/lib/puppet/util/rdoc/generators/template/puppet/puppet.rb +++ b/lib/puppet/util/rdoc/generators/template/puppet/puppet.rb @@ -239,11 +239,11 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; } ##################################################################### -### H E A D E R T E M P L A T E +### H E A D E R T E M P L A T E ##################################################################### XHTML_PREAMBLE = %{<?xml version="1.0" encoding="%charset%"?> -<!DOCTYPE html +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> } @@ -271,7 +271,7 @@ HEADER = XHTML_PREAMBLE + %{ return false; elemStyle = elem.style; - + if ( elemStyle.display != "block" ) { elemStyle.display = "block" } else { @@ -280,10 +280,10 @@ HEADER = XHTML_PREAMBLE + %{ return true; } - + // Make codeblocks hidden by default document.writeln( "<style type=\\"text/css\\">div.method-source-code { display: none }</style>" ) - + // ]]> </script> @@ -516,7 +516,7 @@ IF:sectitle IF:seccomment <div class="section-comment"> %seccomment% - </div> + </div> ENDIF:seccomment ENDIF:sectitle END:sections @@ -608,7 +608,7 @@ IF:sectitle IF:seccomment <div class="section-comment"> %seccomment% - </div> + </div> ENDIF:seccomment ENDIF:sectitle @@ -720,7 +720,7 @@ END:attributes </div> </div> ENDIF:attributes - + <!-- if method_list --> @@ -755,7 +755,7 @@ IF:sourcecode </a> ENDIF:sourcecode </div> - + <div class="method-description"> IF:m_desc %m_desc% @@ -797,7 +797,7 @@ START:params END:params ENDIF:params </div> - + <div class="method-description"> IF:m_desc %m_desc% @@ -935,7 +935,7 @@ METHOD_INDEX = FILE_INDEX COMBO_INDEX = XHTML_PREAMBLE + %{ <!-- - %classes_title% & %defines_title% + %classes_title% & %defines_title% --> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> @@ -950,7 +950,7 @@ COMBO_INDEX = XHTML_PREAMBLE + %{ parent.docwin.location.href = url; } //--></SCRIPT> - + </head> <body> <div id="index"> @@ -1019,7 +1019,7 @@ ENDIF:plugins } INDEX = %{<?xml version="1.0" encoding="%charset%"?> -<!DOCTYPE html +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"> diff --git a/lib/puppet/util/selinux.rb b/lib/puppet/util/selinux.rb index f13600680..7be119c6f 100644 --- a/lib/puppet/util/selinux.rb +++ b/lib/puppet/util/selinux.rb @@ -122,7 +122,7 @@ module Puppet::Util::SELinux else context = value end - + retval = Selinux.lsetfilecon(file, context) if retval == 0 return true @@ -179,12 +179,12 @@ module Puppet::Util::SELinux unless mnts = read_mounts() return nil end - + # For a given file: - # Check if the filename is in the data structure; + # Check if the filename is in the data structure; # return the fstype if it is. # Just in case: return something if you're down to "/" or "" - # Remove the last slash and everything after it, + # Remove the last slash and everything after it, # and repeat with that as the file for the next loop through. ary = file.split('/') while not ary.empty? do diff --git a/lib/puppet/util/settings.rb b/lib/puppet/util/settings.rb index 0871ee869..4fbf602f6 100644 --- a/lib/puppet/util/settings.rb +++ b/lib/puppet/util/settings.rb @@ -168,7 +168,7 @@ class Puppet::Util::Settings def initialize @config = {} @shortnames = {} - + @created = [] @searchpath = nil @@ -332,7 +332,7 @@ class Puppet::Util::Settings parse_file(file).each do |area, values| @values[area] = values end - + # Determine our environment, if we have one. if @config[:environment] env = self.value(:environment).to_sym @@ -616,7 +616,7 @@ Generated on #{Time.now}. if transaction.any_failed? report = transaction.report failures = report.logs.find_all { |log| log.level == :err } - raise "Got %s failure(s) while initializing: %s" % [failures.length, failures.collect { |l| l.to_s }.join("; ")] + raise "Got %s failure(s) while initializing: %s" % [failures.length, failures.collect { |l| l.to_s }.join("; ")] end end end @@ -663,7 +663,7 @@ Generated on #{Time.now}. end throw :foundval, nil end - + # If we didn't get a value, use the default val = @config[param].default if val.nil? @@ -759,7 +759,7 @@ Generated on #{Time.now}. return obj end - + # Create the transportable objects for users and groups. def add_user_resources(catalog, sections) return unless Puppet.features.root? diff --git a/lib/puppet/util/subclass_loader.rb b/lib/puppet/util/subclass_loader.rb index dd0d6dd03..8776e855c 100644 --- a/lib/puppet/util/subclass_loader.rb +++ b/lib/puppet/util/subclass_loader.rb @@ -31,7 +31,7 @@ module Puppet::Util::SubclassLoader # that we're defining a class method here, not an instance. meta_def(name) do |subname| subname = subname.to_s.downcase - + unless c = @subclasses.find { |c| c.name.to_s.downcase == subname } loader.load(subname) c = @subclasses.find { |c| c.name.to_s.downcase == subname } diff --git a/lib/puppet/util/suidmanager.rb b/lib/puppet/util/suidmanager.rb index b071dca6f..c5df0d198 100644 --- a/lib/puppet/util/suidmanager.rb +++ b/lib/puppet/util/suidmanager.rb @@ -29,14 +29,14 @@ module Puppet::Util::SUIDManager begin self.egid = convert_xid :gid, new_gid if new_gid self.euid = convert_xid :uid, new_uid if new_uid - + yield ensure self.euid, self.egid = old_euid, old_egid end end module_function :asuser - + # Make sure the passed argument is a number. def convert_xid(type, id) map = {:gid => :group, :uid => :user} diff --git a/lib/puppet/util/tagging.rb b/lib/puppet/util/tagging.rb index e06e13a2c..f421d18d8 100644 --- a/lib/puppet/util/tagging.rb +++ b/lib/puppet/util/tagging.rb @@ -16,7 +16,7 @@ module Puppet::Util::Tagging @tags << tag unless @tags.include?(tag) end - # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com] + # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com] qualified.collect { |name| x = name.split("::") }.flatten.each { |tag| @tags << tag unless @tags.include?(tag) } end |
