diff options
-rw-r--r-- | CHANGELOG | 2 | ||||
-rwxr-xr-x | install.rb | 18 | ||||
-rw-r--r-- | lib/puppet.rb | 11 | ||||
-rw-r--r-- | lib/puppet/network/server.rb | 2 | ||||
-rw-r--r-- | lib/puppet/node.rb | 2 | ||||
-rw-r--r-- | lib/puppet/util/settings.rb | 88 | ||||
-rw-r--r-- | man/man8/puppet.8 | 3 | ||||
-rw-r--r-- | spec/unit/network/server.rb | 8 | ||||
-rwxr-xr-x | spec/unit/node.rb | 16 | ||||
-rwxr-xr-x | spec/unit/util/settings.rb | 5 | ||||
-rwxr-xr-x | test/util/settings.rb | 63 |
11 files changed, 42 insertions, 176 deletions
@@ -141,6 +141,8 @@ permission denied exceptions caught, thus forbidding them from being replaced with 'nil'. + The environment is now available as a variable in the manifests. + Fixed #1043 -- autoloading now searches the plugins directory in each module, in addition to the lib directory. The 'lib' directory is also deprecated, but supported for now to give diff --git a/install.rb b/install.rb index 087c3c860..d744f2d2d 100755 --- a/install.rb +++ b/install.rb @@ -51,10 +51,10 @@ begin if $haverdoc rst2man = %x{which rst2man.py} $haveman = true - else + else $haveman = false end -rescue +rescue puts "Missing rst2man; skipping man page creation" $haveman = false end @@ -151,6 +151,15 @@ def prepare_installation InstallOptions.tests = true + if $haveman + InstallOptions.man = true + if RUBY_PLATFORM == "i386-mswin32" + InstallOptions.man = false + end + else + InstallOptions.man = false + end + ARGV.options do |opts| opts.banner = "Usage: #{File.basename($0)} [options]" opts.separator "" @@ -173,6 +182,7 @@ def prepare_installation end opts.on('--full', 'Performs a full installation. All', 'optional installation steps are run.') do |full| InstallOptions.rdoc = true + InstallOptions.man = true InstallOptions.ri = true InstallOptions.tests = true end @@ -268,13 +278,13 @@ def build_man(bins) File.unlink("./puppet.conf.rst") # Create binary man pages - bins.each do |bin| + bins.each do |bin| b = bin.gsub( "bin/", "") %x{#{bin} --help > ./#{b}.rst} %x{#{rst2man} ./#{b}.rst ./man/man8/#{b}.8} File.unlink("./#{b}.rst") end - rescue SystemCallError + rescue SystemCallError $stderr.puts "Couldn't build man pages: " + $! $stderr.puts "Continuing with install..." end diff --git a/lib/puppet.rb b/lib/puppet.rb index 66a52f9e3..cde25721e 100644 --- a/lib/puppet.rb +++ b/lib/puppet.rb @@ -205,16 +205,7 @@ module Puppet end # Parse the config file for this process. - def self.parse_config(oldconfig = nil) - # First look for the old configuration file. - oldconfig ||= File.join(Puppet[:confdir], Puppet[:name].to_s + ".conf") - if FileTest.exists?(oldconfig) and Puppet[:name] != "puppet" - Puppet.warning "Individual config files are deprecated; remove %s and use puppet.conf" % oldconfig - Puppet.settings.old_parse(oldconfig) - return - end - - # Now check for the normal config. + def self.parse_config if Puppet[:config] and File.exists? Puppet[:config] Puppet.debug "Parsing %s" % Puppet[:config] Puppet.settings.parse(Puppet[:config]) diff --git a/lib/puppet/network/server.rb b/lib/puppet/network/server.rb index 50e3bd686..f2c8dc18c 100644 --- a/lib/puppet/network/server.rb +++ b/lib/puppet/network/server.rb @@ -1,3 +1,5 @@ +require 'puppet/network/http' + class Puppet::Network::Server attr_reader :server_type, :protocols, :address, :port diff --git a/lib/puppet/node.rb b/lib/puppet/node.rb index c0628ecdc..252ab961e 100644 --- a/lib/puppet/node.rb +++ b/lib/puppet/node.rb @@ -161,5 +161,7 @@ class Puppet::Node params.each do |name, value| @parameters[name] = value unless @parameters.include?(name) end + + @parameters["environment"] ||= self.environment if self.environment end end diff --git a/lib/puppet/util/settings.rb b/lib/puppet/util/settings.rb index d27406d6d..089389a09 100644 --- a/lib/puppet/util/settings.rb +++ b/lib/puppet/util/settings.rb @@ -312,94 +312,6 @@ class Puppet::Util::Settings end end - # Parse the configuration file. As of May 2007, this is a backward-compatibility method and - # will be deprecated soon. - def old_parse(file) - text = nil - - if file.is_a? Puppet::Util::LoadedFile - @file = file - else - @file = Puppet::Util::LoadedFile.new(file) - end - - # Don't create a timer for the old style parsing. - # settimer() - - begin - text = File.read(@file.file) - rescue Errno::ENOENT - raise Puppet::Error, "No such file %s" % file - rescue Errno::EACCES - raise Puppet::Error, "Permission denied to file %s" % file - end - - @values = Hash.new { |names, name| - names[name] = {} - } - - # Get rid of the values set by the file, keeping cli values. - self.clear(true) - - section = "puppet" - metas = %w{owner group mode} - values = Hash.new { |hash, key| hash[key] = {} } - text.split(/\n/).each { |line| - case line - when /^\[(\w+)\]$/: section = $1 # Section names - when /^\s*#/: next # Skip comments - when /^\s*$/: next # Skip blanks - when /^\s*(\w+)\s*=\s*(.+)$/: # settings - var = $1.intern - if var == :mode - value = $2 - else - value = munge_value($2) - end - - # Only warn if we don't know what this config var is. This - # prevents exceptions later on. - unless @config.include?(var) or metas.include?(var.to_s) - Puppet.warning "Discarded unknown configuration parameter %s" % var.inspect - next # Skip this line. - end - - # Mmm, "special" attributes - if metas.include?(var.to_s) - unless values.include?(section) - values[section] = {} - end - values[section][var.to_s] = value - - # If the parameter is valid, then set it. - if section == Puppet[:name] and @config.include?(var) - #@config[var].value = value - @values[:main][var] = value - end - next - end - - # Don't override set parameters, since the file is parsed - # after cli arguments are handled. - unless @config.include?(var) and @config[var].setbycli - Puppet.debug "%s: Setting %s to '%s'" % [section, var, value] - @values[:main][var] = value - end - @config[var].section = symbolize(section) - - metas.each { |meta| - if values[section][meta] - if @config[var].respond_to?(meta + "=") - @config[var].send(meta + "=", values[section][meta]) - end - end - } - else - raise Puppet::Error, "Could not match line %s" % line - end - } - end - # Create a new element. The value is passed in because it's used to determine # what kind of element we're creating, but the value itself might be either # a default or a value, so we can't actually assign it. diff --git a/man/man8/puppet.8 b/man/man8/puppet.8 index 190aab2f8..0281d330e 100644 --- a/man/man8/puppet.8 +++ b/man/man8/puppet.8 @@ -67,8 +67,7 @@ puppet \-l /tmp/script.log script.pp .SH AUTHOR Luke Kanies - - +.\" Generated by docutils manpage writer on 2008-01-20 10:28. .SH COPYRIGHT Copyright (c) 2005 Reductive Labs, LLC Licensed under the GNU Public License diff --git a/spec/unit/network/server.rb b/spec/unit/network/server.rb index 3e29807ad..846b5471d 100644 --- a/spec/unit/network/server.rb +++ b/spec/unit/network/server.rb @@ -212,7 +212,7 @@ describe Puppet::Network::Server, "when listening is on" do @server.listen end - it "should indicate that listening is turned off" do + it "should indicate that it is listening" do @server.should be_listening end @@ -235,14 +235,14 @@ describe Puppet::Network::Server, "when listening is being turned on" do @mock_http_server.stubs(:listen) end - it "should fetch an instance of an HTTP server when listening is turned on" do + it "should fetch an instance of an HTTP server" do mock_http_server_class = mock('http server class') mock_http_server_class.expects(:new).returns(@mock_http_server) @server.expects(:http_server_class).returns(mock_http_server_class) @server.listen end - it "should cause the HTTP server to listen when listening is turned on" do + it "should cause the HTTP server to listen" do @mock_http_server.expects(:listen) @server.expects(:http_server).returns(@mock_http_server) @server.listen @@ -261,7 +261,7 @@ describe Puppet::Network::Server, "when listening is being turned off" do @server.listen end - it "should cause the HTTP server to stop listening when listening is turned off" do + it "should cause the HTTP server to stop listening" do @mock_http_server.expects(:unlisten) @server.unlisten end diff --git a/spec/unit/node.rb b/spec/unit/node.rb index e62bd5d07..bb99378d9 100755 --- a/spec/unit/node.rb +++ b/spec/unit/node.rb @@ -113,6 +113,22 @@ describe Puppet::Node, " when merging facts" do @node.merge "two" => "three" @node.parameters["two"].should == "three" end + + it "should add the environment to the list of parameters" do + Puppet.settings.stubs(:value).with(:environments).returns("one,two") + Puppet.settings.stubs(:value).with(:environment).returns("one") + @node = Puppet::Node.new("testnode", :environment => "one") + @node.merge "two" => "three" + @node.parameters["environment"].should == "one" + end + + it "should not set the environment if it is already set in the parameters" do + Puppet.settings.stubs(:value).with(:environments).returns("one,two") + Puppet.settings.stubs(:value).with(:environment).returns("one") + @node = Puppet::Node.new("testnode", :environment => "one") + @node.merge "environment" => "two" + @node.parameters["environment"].should == "two" + end end describe Puppet::Node, " when indirecting" do diff --git a/spec/unit/util/settings.rb b/spec/unit/util/settings.rb index a6b358462..9f7018697 100755 --- a/spec/unit/util/settings.rb +++ b/spec/unit/util/settings.rb @@ -284,11 +284,6 @@ describe Puppet::Util::Settings, " when parsing its configuration" do lambda { @settings.parse(file) }.should_not raise_error end - it "should support an old parse method when per-executable configuration files still exist" do - # I'm not going to bother testing this method. - @settings.should respond_to(:old_parse) - end - it "should convert booleans in the configuration file into Ruby booleans" do text = "[main] one = true diff --git a/test/util/settings.rb b/test/util/settings.rb index cf5dca76d..de6fff946 100755 --- a/test/util/settings.rb +++ b/test/util/settings.rb @@ -256,69 +256,6 @@ yay = /a/path end end - def test_old_parse - text = %{ -one = this is a test -two = another test -owner = root -group = root -yay = /a/path - -[section1] - attr = value - owner = puppet - group = puppet - attrdir = /some/dir - attr3 = $attrdir/other - } - - file = tempfile() - File.open(file, "w") { |f| f.puts text } - - assert_nothing_raised { - @config.setdefaults("puppet", - :one => ["a", "one"], - :two => ["a", "two"], - :yay => ["/default/path", "boo"], - :mkusers => [true, "uh, yeah"] - ) - } - - assert_nothing_raised { - @config.setdefaults("section1", - :attr => ["a", "one"], - :attrdir => ["/another/dir", "two"], - :attr3 => ["$attrdir/maybe", "boo"] - ) - } - - assert_nothing_raised { - @config.old_parse(file) - } - - assert_equal("value", @config[:attr]) - assert_equal("/some/dir", @config[:attrdir]) - assert_equal(:directory, @config.element(:attrdir).type) - assert_equal("/some/dir/other", @config[:attr3]) - - elem = nil - assert_nothing_raised { - elem = @config.element(:attr3) - } - - assert(elem) - assert_equal("puppet", elem.owner) - - config = nil - assert_nothing_raised { - config = @config.to_config - } - - assert_nothing_raised("Could not create transportable config") { - @config.to_transportable - } - end - def test_parse result = { :main => {:main => "main", :bad => "invalid", :cliparam => "reset"}, |