[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 0.25.5-639-g8f94f35
Markus Roberts
Markus at reality.com
Wed Jul 14 10:35:59 UTC 2010
The following commit has been merged in the upstream branch:
commit 2a2588392a2eead4265afcb93ff7bc16b5fc1ef1
Author: Matt Robinson <matt at puppetlabs.com>
Date: Wed Jun 30 12:43:23 2010 -0700
[#4090] Git rid of the idea that run_mode is a configurable option with defaults
Along the way this fixes an issue with 2.6 alpha that sections of the
puppet config file were getting ignored.
diff --git a/lib/puppet.rb b/lib/puppet.rb
index 4e496e7..af1bd8d 100644
--- a/lib/puppet.rb
+++ b/lib/puppet.rb
@@ -93,7 +93,7 @@ module Puppet
def self.run_mode
require 'puppet/util/run_mode'
- $puppet_application_mode ||= Puppet::Util::RunMode.new( :user )
+ $puppet_application_mode || Puppet::Util::RunMode.new( :user )
end
def self.application_name
diff --git a/lib/puppet/application.rb b/lib/puppet/application.rb
index f74b375..c49f42f 100644
--- a/lib/puppet/application.rb
+++ b/lib/puppet/application.rb
@@ -221,10 +221,14 @@ class Application
find(name).new
end
+ # Sets or gets the run_mode name. Sets the run_mode name if a mode_name is
+ # passed. Otherwise, gets the run_mode or a default run_mode
+ #
def run_mode( mode_name = nil)
- @run_mode ||= mode_name || @run_mode || :user
+ return @run_mode if @run_mode and not mode_name
+
require 'puppet/util/run_mode'
- Puppet::Util::RunMode.new( @run_mode )
+ @run_mode = Puppet::Util::RunMode.new( mode_name || :user )
end
end
diff --git a/lib/puppet/defaults.rb b/lib/puppet/defaults.rb
index bfc18d8..ac82975 100644
--- a/lib/puppet/defaults.rb
+++ b/lib/puppet/defaults.rb
@@ -6,8 +6,6 @@ module Puppet
it defaults to being in ``~``."],
:vardir => [Puppet.run_mode.var_dir, "Where Puppet stores dynamic and growing data. The default for this parameter is calculated specially, like `confdir`_."],
:name => [Puppet.application_name.to_s, "The name of the application, if we are running as one. The
- default is essentially $0 without the path or ``.rb``."],
- :run_mode => [Puppet.run_mode.name.to_s, "The name of the application, if we are running as one. The
default is essentially $0 without the path or ``.rb``."]
)
diff --git a/lib/puppet/reports/store.rb b/lib/puppet/reports/store.rb
index a745275..a71cd33 100644
--- a/lib/puppet/reports/store.rb
+++ b/lib/puppet/reports/store.rb
@@ -1,8 +1,6 @@
require 'puppet'
Puppet::Reports.register_report(:store) do
- Puppet.settings.use(:reporting)
-
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.
diff --git a/lib/puppet/util/settings.rb b/lib/puppet/util/settings.rb
index 398fa48..3e2020c 100644
--- a/lib/puppet/util/settings.rb
+++ b/lib/puppet/util/settings.rb
@@ -284,9 +284,9 @@ class Puppet::Util::Settings
end
end
- # Figure out the section name for the mode.
+ # Figure out the section name for the run_mode.
def run_mode
- convert(@config[:run_mode].default).intern if @config[:run_mode]
+ Puppet.run_mode.name
end
# Return all of the parameters associated with a given section.
diff --git a/spec/unit/application/agent_spec.rb b/spec/unit/application/agent_spec.rb
index 76a378e..21f5143 100755
--- a/spec/unit/application/agent_spec.rb
+++ b/spec/unit/application/agent_spec.rb
@@ -8,6 +8,31 @@ require 'puppet/network/server'
require 'puppet/daemon'
describe Puppet::Application::Agent do
+ it "should ask Puppet::Application to parse Puppet configuration file" do
+ agent = Puppet::Application::Agent.new
+ agent.preinit
+
+ Puppet[:vardir].should == '/dev/null'
+ Puppet[:report].should be_false
+
+ text = <<-CONF
+ [main]
+ vardir='/foo/bar'
+ [puppetd]
+ report=true
+ CONF
+
+ FileTest.expects(:exist?).with('file').returns true
+ Puppet.settings.expects(:read_file).returns(text)
+
+ Puppet.settings.unsafe_parse('file')
+
+ Puppet[:vardir].should == '/foo/bar'
+ Puppet[:report].should be_true
+ end
+end
+
+describe Puppet::Application::Agent do
before :each do
@puppetd = Puppet::Application[:agent]
@puppetd.stubs(:puts)
diff --git a/spec/unit/application_spec.rb b/spec/unit/application_spec.rb
index 9dc655d..87424fb 100755
--- a/spec/unit/application_spec.rb
+++ b/spec/unit/application_spec.rb
@@ -10,11 +10,23 @@ describe Puppet::Application do
before do
@app = Class.new(Puppet::Application).new
+ @appclass = @app.class
# avoid actually trying to parse any settings
Puppet.settings.stubs(:parse)
end
+ describe ".run_mode" do
+ it "should default to user" do
+ @appclass.run_mode.name.should == :user
+ end
+
+ it "should set and get a value" do
+ @appclass.run_mode :agent
+ @appclass.run_mode.name.should == :agent
+ end
+ end
+
it "should have a run entry-point" do
@app.should respond_to(:run)
end
@@ -150,7 +162,7 @@ describe Puppet::Application do
describe 'on POSIX systems' do
confine "HUP works only on POSIX systems" => Puppet.features.posix?
-
+
it 'should signal process with HUP after block if restart requested during block execution' do
Puppet::Application.run_status = nil
target = mock 'target'
diff --git a/spec/unit/util/settings_spec.rb b/spec/unit/util/settings_spec.rb
index 1e694a4..9aeed60 100755
--- a/spec/unit/util/settings_spec.rb
+++ b/spec/unit/util/settings_spec.rb
@@ -274,11 +274,18 @@ describe Puppet::Util::Settings do
@settings.value(:one, "env2").should == "twoval"
end
- it "should have a run_mode determined by the 'run_mode' parameter that cannot be edited" do
+ it "should have a run_mode that defaults to user" do
+ @settings.run_mode.should == :user
+ end
+
+ it "should not give a shit if you set a default run_mode yourself" do
@settings.setdefaults(:whatever, :run_mode => ["something", "yayness"])
- @settings.run_mode.should == :something
+ lambda{ @settings[:run_mode] = :other }.should raise_error(ArgumentError, /read-only/)
+ end
- lambda{ @settings[:run_mode] = :other }.should raise_error
+ it "CURRENTLY should not allow the user to set a run_mode default" do
+ @settings.setdefaults(:whatever, :run_mode => ["something", "yayness"])
+ @settings.run_mode.should == :user
end
end
@@ -286,10 +293,10 @@ describe Puppet::Util::Settings do
before do
@settings = Puppet::Util::Settings.new
@settings.setdefaults :section,
- :config => ["/my/file", "a"],
- :one => ["ONE", "a" ],
- :run_mode => ["mymode", "w" ]
+ :config => ["/my/file", "a"],
+ :one => ["ONE", "a"]
FileTest.stubs(:exist?).returns true
+ Puppet.stubs(:run_mode).returns stub('run_mode', :name => :mymode)
end
it "should return default values if no values have been set" do
@@ -358,6 +365,19 @@ describe Puppet::Util::Settings do
FileTest.stubs(:exist?).returns true
end
+ it "should not ignore the report setting" do
+ @settings.setdefaults :section, :report => ["false", "a"]
+ myfile = stub "myfile"
+ @settings[:config] = myfile
+ text = <<-CONF
+ [puppetd]
+ report=true
+ CONF
+ @settings.expects(:read_file).returns(text)
+ @settings.parse
+ @settings[:report].should be_true
+ end
+
it "should use its current ':config' value for the file to parse" do
myfile = Puppet.features.posix? ? "/my/file" : "C:/myfile" # do not stub expand_path here, as this leads to a stack overflow, when mocha tries to use it
@settings[:config] = myfile
@@ -464,9 +484,9 @@ describe Puppet::Util::Settings do
values = []
@settings.setdefaults :section, :mysetting => {:default => "defval", :desc => "a", :hook => proc { |v| values << v }}
- text = "[main]
+ text = "[user]
mysetting = setval
- [puppet]
+ [main]
mysetting = other
"
@settings.expects(:read_file).returns(text)
--
Puppet packaging for Debian
More information about the Pkg-puppet-devel
mailing list